6.1-rasm. MainMenu1 Items
6.16. ADO bo’limida ADOConnection, ADOTable, ADOQuery komponentasini
olib Form1 oynasiga ixtiyoriy joylashtiriladi.
6.17. Data Accessbo’limidaDataSource komponentasini olib Form1 oynasiga
ixtiyoriy joylashtiriladi.
6.18. ADOConnection ustiga sichqoncha ikki marotaba bosiladi:
6.2-rasm
~ 45 ~
6.3-rasm
6.4-rasm.1. “dorixona.mbd” bu - Microsoft Access ma’lumotlar bazasi. (Baza
fayl yonida yurishi kerak), 2. Ma’lumotlar bazasi to’g’ri ulanganini tekshirish
tugmasi, 3.Ulanganlik haqidagi ma’lumotllarni saqlash va tasdiqlash
1
2
3
~ 46 ~
6.19. ADOConnection1 LoginPromt xususiyatiga false tanlanadi;
6.20. ADOQuery1 komponentasi Connection xususiyatiga ADOConnection1
tanlanadi;
6.21. ADOTable1 komponentasi Connection xususiyatiga ADOConnection1
tanlanadi;
6.22. ADOTable1 komponentasi TableName xususiyatiga dorilar tanlanadi;
6.23. ADOTable1 komponentasi Active xususiyatiga true tanlanadi;
6.24. DataSource1 komponentasi DataSet xususiyatiga ADOQuery1 tanlanadi;
6.25. DBGrid1 komponentasi ustiga sichqoncha chap tugmasi ikki marotaba
bosiladi va “nomi” dan boshqa barcha ma’lumotlar uchiriladi;
6.25.1. “name” ma’lumotlar ustuni razmeri kattalashtiriladi.
6.26. System bo’limida Timer komponentasini olib Form1 oynasiga ixtiyoriy
joylashtiriladi;
6.26.1. Sichqonchaning chap tugmasini Timer1 ustiga 2 marta bosgan holda
ichiga kiriladi va quyidagi dastur kod yoziladi:
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
Label8->Caption=Time();
Label9->Caption=Date();
}
Ushbu dastur kod joriy soat va sanani ko’rsatib turadi.
6.27. Sotish tugmasi ichiga quyidagi dastur dastur kodi yoziladi:
void __fastcall TForm1::sButton1Click(TObject *Sender)
{
kl: String p;
InputQuery(ADOQuery1->FieldByName("nomi")->AsString,"Dorilar
hajmi
kiriting",p);
if(p!="0"&&p!=""&&StrToInt(p)<=StrToInt(ADOQuery1-
>FieldByName("soni")->AsString))
~ 47 ~
{
ADOQuery1->Edit();
ADOQuery1->FieldByName("soni")-
>AsString=IntToStr(StrToInt(ADOQuery1->FieldByName("soni")->AsString)-
StrToInt(p));
ADOQuery1->FieldByName("sotilanlari")-
>AsString=IntToStr(StrToInt(ADOQuery1->FieldByName("sotilanlari")-
>AsString)+StrToInt(p));
ADOQuery1->FieldByName("summasi")-
>AsString=IntToStr(StrToInt(ADOQuery1->FieldByName("summasi")-
>AsString)+(StrToInt(p)*StrToInt(ADOQuery1->FieldByName("narxi")-
>AsString)));
ADOQuery1->Post();
ADOQuery1->Refresh();
ADOTable2->Insert();
ADOTable2->FieldByName("nomi")->AsString=ADOQuery1-
>FieldByName("nomi")->AsString;
ADOTable2->FieldByName("narxi")->AsString=ADOQuery1-
>FieldByName("narxi")->AsString;
ADOTable2->FieldByName("turi")->AsString=ADOQuery1-
>FieldByName("turi")->AsString;
ADOTable2->FieldByName("soni")->AsString=p;
ADOTable2->FieldByName("summasi")-
>AsString=IntToStr(StrToInt(p)*StrToInt(ADOQuery1->FieldByName("narxi")-
>AsString));
ADOTable2->FieldByName("vaqti")->AsString=Label9->Caption+"
"+Label8->Caption;
if(rasm)
{
~ 48 ~
TMemoryStream * strm = new TMemoryStream();
Image1->Picture->Graphic->SaveToStream(strm);
((TGraphicField
*)ADOTable2->FieldByName("surati"))-
>LoadFromStream(strm);
delete strm;
}
ADOTable2->Post();
}
else
{ if(p=="")
{
return;
}
ShowWarning("Siz bergan hajm dorilar sonidan ko’p\n Qaytadan o’rinib
ko’ring");
goto kl;
}
}
6.28. Form1 oynasi ob’yektni ichki xossalaridan OnResize xossasiga quyidagicha
dastur dastur kod yoziladi:
void __fastcall TForm1::FormShow(TObject *Sender)
{
sEdit1->Text="s";
sEdit1->Text="";
Form1->Width=1000;
Form1->Height=500;
Form1->Top=150;
Form1->Left=150;
}
~ 49 ~
6.29. Form1 oynasi ob’yektni ichki xossalaridan OnShow xossasiga quyidagicha
dastur dastur kod yoziladi:
void __fastcall TForm1::FormShow(TObject *Sender)
{
sEdit1->Text="s";
sEdit1->Text="";
Form1->Width=1000;
Form1->Height=500;
Form1->Top=150;
Form1->Left=150;
}
6.30. Edit komponentasini ustiga sichqonchani chap tugmasini ikki marta bosamiz
va ushbu dastur kodni yozamiz:
void __fastcall TForm1::sEdit1Change(TObject *Sender)
{
ADOQuery1->Close();
ADOQuery1->SQL->Clear();
ADOQuery1->SQL->Add("SELECT *FROM dorilar WHERE `nomi` like
‘"+sEdit1->Text+"%’");
ADOQuery1->Open();
}
6.31. Form1 komponentasi Caption xususiyatiga “DORIXONA” deb yoziladi;
6.32. Form1 komponentasi BorderStyle xususiyatiga bsSingle tanlanadi;
6.33.
Form1
komponentasi
BorderIcons
xususiyatiga
[biSystemMenu,biMinimize,biMaximize] deb yoziladi;
6.34. CHIQISH tugmasi ichiga quyidagi dastur kodni yozamiz:
void __fastcall TForm1::c1Click(TObject *Sender)
{
Form1->Close();
~ 50 ~
}
6.35. YO‘RIQNOMA tugmasi ichiga quyidagi dastur kodni yozamiz:
void __fastcall TForm1::Y1Click(TObject *Sender)
{
Form7->Show();
}
6.36. MENYU ichidagi YANGI DORI tugmasini ichiga quyidagi dastur kodni
yozamiz:
void __fastcall TForm1::Y2Click(TObject *Sender)
{
Form2->ShowModal();
sEdit1->Text="s";
sEdit1->Text="";
sButton1->Enabled=false;
}
6.37. MENYU ichidagi DORILAR SONINI O‘ZGARTIRISH tugmasini ichiga
quyidagi dastur kodni yozamiz:
void __fastcall TForm1::D1Click(TObject *Sender)
{
Form4->ShowModal();
sEdit1->Text="s";
sEdit1->Text="";
sButton1->Enabled=false;
}
6.38. MENYU ichidagi ARXIV tugmasini ichiga quyidagi dastur kodni yozamiz:
void __fastcall TForm1::A1Click(TObject *Sender)
{
Form6->ShowModal();
}
~ 51 ~
6.38.1. MENYU ichidagi Dastur Haqida tugmasini ichiga quyidagi dastur kodni
yozamiz:
void __fastcall TForm1::d2Click(TObject *Sender)
{
Form3->ShowModal();
}
6.39. DBGrid1 komponentasi OnCellClik xossasiga quyidagi dastur kodni
yozamiz:
void __fastcall TForm1::DBGrid1CellClick(TColumn *Column)
{
DBText6->Left=(sPanel2->Width-(DBText6->Width))/2;
Label1->Left=(sPanel2->Width-(DBText1->Width+10+Label1->Width))/2;
DBText1->Left=Label1->Left+10+Label1->Width;
Label5->Left=(sPanel2->Width-(DBText7->Width+10+Label5->Width))/2;
DBText7->Left=Label5->Left+10+Label5->Width;
Label4->Left=(sPanel2->Width-(DBText3->Width+10+Label4->Width))/2;
DBText3->Left=Label4->Left+10+Label4->Width;
Label2->Left=(sPanel2->Width-(DBText2->Width+10+Label2->Width))/2;
DBText2->Left=Label2->Left+10+Label2->Width;
Label6->Left=(sPanel2->Width-(DBText4->Width+10+Label6->Width))/2;
DBText4->Left=Label6->Left+10+Label6->Width;
Label7->Left=(sPanel2->Width-(DBText8->Width+10+Label7->Width))/2;
DBText8->Left=Label7->Left+10+Label7->Width;
if(!(TBlobField*)ADOQuery1->FieldByName("surati")->IsNull)
{
if(!Image1->Visible)Image1->Visible=true;
TMemoryStream * strm = new TMemoryStream;
TJPEGImage *ptJpg=new TJPEGImage;
~ 52 ~
((TGraphicField*)ADOQuery1->FieldByName("surati"))-
>SaveToStream(strm);
strm->Seek(0, 0);
if(*(Word*)strm->Memory == 0xD8FF)
Image1->Picture->Graphic=ptJpg;
Image1->Picture->Graphic->LoadFromStream(strm);
delete strm;
delete ptJpg;
rasm=true;
}
else {
Image1->Visible=false;
sPanel3->Caption="Surat mavjud emas";
rasm=false;
}
sButton1->Enabled=true;
}
Do'stlaringiz bilan baham: |