Курсовая работа: База данных "Магазин по продаже дисков"
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{ADOConnection1->Connected = false;
ADOConnection1->ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source="+ExtractFileDir(Application->ExeName)+" \\ БАЗА ДАННЫХ \\ CD.mdb; Mode=Share Deny None;Extended Properties=\"\";Jet OLEDB:System database=\"\";Jet OLEDB:Registry Path=\"\";Jet OLEDB:Database Password=\"\";Jet OLEDB:Engine Type=5;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password=\"\";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False";
ADOConnection1->Connected = true;
PageControl1->ActivePage = TabSheet1;}
//---------------------------------------------------------------------------
void __fastcall TForm1::N1Click(TObject *Sender)
{AboutBox->Show();}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{DataSource1->DataSet = ADOQuery1;
ADOQuery1->SQL->Clear();
ADOQuery1->SQL->Add("SELECT [Наименование] FROM Tab1 WHERE [Наименование] =\""+Edit1->Text+"\";");
ADOQuery1->ExecSQL();
ADOQuery1->Open();
if(Edit1->Text!=""&&ComboBox1->Text!=" "&&Edit2->Text!=" "&Edit3->Text!=""&&Edit4->Text!="")
{if(ADOQuery1->RecordCount==0)
{ADOQuery1->SQL->Clear();
ADOQuery1->SQL->Add("INSERT INTO Tab1 ([Наименование],[Группа],[Количество],[Закупочная цена],[Цена продажи])");
ADOQuery1->SQL->Add("Values("+QuotedStr(Edit1->Text)+","+QuotedStr(ComboBox1->Text)+","+Edit2->Text+","+Edit3->Text+","+Edit4->Text+");");
ADOQuery1->ExecSQL();}else
{MessageDlg("Такие диски уже есть!"mtInformation,TMsgDlgButtons()<<mbOK,0);}
else
{MessageDlg("Введены не все данные для добавления диска(-ов) в базу!"mtInformation,TMsgDlgButtons()<<mbOK,0);}