2.1 Ma’lumotlar bazasi acsess yordamida ombordagi mollarni iqtisodiy kirim chiqim ishlarni hisoblovchi dastur yaratish
Bu dasturda Skaladda bo’ladigan ishlar amalga oshiriladi.Yani Kirim chiqim sotilgan kimga kim tomonidan qanchaga sotgan qancha qolgani haqida ishlar bajariladi.
Ma’lumotlar bazasi acsess yordamida ombordagi mollarni iqtisodiy kirim chiqim ishlarni hisoblovchi dastur yaratish
void __fastcall TFormMain::barchasiniyopish1Click(TObject *Sender)
{
for (int i = 0; i < MDIChildCount; i++)
MDIChildren[i]->Close();
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::Gorizontal1Click(TObject *Sender)
{
Application->MainForm->TileMode = tbHorizontal;
Application->MainForm->Tile();
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::Vertikal1Click(TObject *Sender)
{
Application->MainForm->TileMode = tbVertical;
Application->MainForm->Tile();
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::Caskadli1Click(TObject *Sender)
{
Application->MainForm->Cascade();
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::Mahsulot1Click(TObject *Sender)
{
if (FormMahsulot == NULL)
FormMahsulot = new TFormMahsulot(this);
FormMahsulot->Show();
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::Guruhlar1Click(TObject *Sender)
{
if (FormGuruh == NULL)
FormGuruh = new TFormGuruh(this);
FormGuruh->Show();
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::Savdogar1Click(TObject *Sender)
{
if (FormSavdogar == NULL)
FormSavdogar = new TFormSavdogar(this);
FormSavdogar->Show();
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::Haridor1Click(TObject *Sender)
{
if (FormHaridor == NULL)
FormHaridor = new TFormHaridor(this);
FormHaridor->Show();
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::Form11Click(TObject *Sender)
{
if (FormKirim == NULL)
FormKirim = new TFormKirim(this);
FormKirim->Show();
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::Form21Click(TObject *Sender)
{
if (FormChiqim == NULL)
FormChiqim = new TFormChiqim(this);
FormChiqim->Show();
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::Kirimhisoboti1Click(TObject *Sender)
{
if (FormKirimHisobot == NULL)
FormKirimHisobot = new TFormKirimHisobot(this);
FormKirimHisobot->Show();
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::Chiqimhisoboti1Click(TObject *Sender)
{
if (FormChiqimHisobot == NULL)
FormChiqimHisobot = new TFormChiqimHisobot(this);
FormChiqimHisobot->Show();
}
void __fastcall TFormChiqimHisobot::FormClose(TObject *Sender,
TCloseAction &Action)
{
Action = caFree;
FormChiqimHisobot = NULL;
}
void __fastcall TFormGuruh::FormClose(TObject *Sender,
TCloseAction &Action)
{
Action = caFree;
FormGuruh = NULL;
}
void __fastcall TFormKirim::FormClose(TObject *Sender,
TCloseAction &Action)
{
Action = caFree;
FormKirim = NULL;
}
//---------------------------------------------------------------------------
void __fastcall TFormKirim::FormCreate(TObject *Sender)
{
DateTimePicker1->Date = Now();
ADOQuerySelect->Open();
while (!ADOQuerySelect->Eof)
{
ComboBoxGuruh->Items->AddObject(ADOQuerySelect->FieldByName("g_nomi")->AsString,
(TObject*)ADOQuerySelect->FieldByName("id_guruh")->AsInteger);
ADOQuerySelect->Next();
}
ADOQuerySelect->Close();
ADOQuerySelect->SQL->Clear();
ADOQuerySelect->SQL->Add("select * from savdogar");
ADOQuerySelect->Open();
while (!ADOQuerySelect->Eof)
{
ComboBoxSavdogar->Items->AddObject(ADOQuerySelect->FieldByName("sd_ismi")->AsString,
(TObject*)ADOQuerySelect->FieldByName("id_savdogar")->AsInteger);
ADOQuerySelect->Next();
}
}
//---------------------------------------------------------------------------
void __fastcall TFormKirim::ComboBoxGuruhChange(TObject *Sender)
{
int id;
id = (int) ComboBoxGuruh->Items->Objects[ComboBoxGuruh->ItemIndex];
ADOQuerySelect->Close();
ADOQuerySelect->SQL->Clear();
ADOQuerySelect->SQL->Add("select * from mahsulot");
ADOQuerySelect->SQL->Add("where m_guruh_id=" + IntToStr(id));
ADOQuerySelect->Open();
ComboBoxMahsulot->Items->Clear();
while (!ADOQuerySelect->Eof)
{
ComboBoxMahsulot->Items->AddObject(ADOQuerySelect->FieldByName("m_nomi")->AsString,
(TObject*)ADOQuerySelect->FieldByName("id_mahsulot")->AsInteger);
ADOQuerySelect->Next();
}
}
//---------------------------------------------------------------------------
void __fastcall TFormKirim::BitBtn1Click(TObject *Sender)
{
if (ComboBoxSavdogar->ItemIndex < 0)
{
ShowMessage("Savdogar tanlanmagan");
return ;
}
if (ComboBoxGuruh->ItemIndex < 0)
{
ShowMessage("Gurug tanlanmagan");
return ;
}
if (ComboBoxMahsulot->ItemIndex < 0)
{
ShowMessage("Mahsulot tanlanmagan");
return ;
}
if (LabeledEditNarxi->Text == "")
{
ShowMessage("Mahsulot narxi kiritilmagam ");
LabeledEditNarxi->SetFocus();
return ;
}
if (LabeledEditSoni->Text == "")
{
ShowMessage("Mahsulot soni kiritilmagam ");
LabeledEditSoni->SetFocus();
return ;
}
int id_mahsulot, id_savdogar, soni;
Currency bahosi;
bahosi = StrToCurr(LabeledEditNarxi->Text);
soni = StrToInt(LabeledEditSoni->Text);
id_mahsulot = (int) ComboBoxMahsulot->Items->Objects[ComboBoxMahsulot->ItemIndex];
id_savdogar = (int) ComboBoxSavdogar->Items->Objects[ComboBoxSavdogar->ItemIndex];
ADOQuery1->Close();
ADOQuery1->SQL->Clear();
ADOQuery1->SQL->Add("INSERT into kirim (k_savdogar_id, k_sana, k_mahsulot_id, k_soni, k_bahosi)");
ADOQuery1->SQL->Add("Values (:k_savdogar_id, :k_sana, :k_mahsulot_id, :k_soni, :k_bahosi)");
ADOQuery1->Parameters->ParamByName("k_savdogar_id")->Value = id_savdogar;
ADOQuery1->Parameters->ParamByName("k_sana")->Value = DateTimePicker1->Date;
ADOQuery1->Parameters->ParamByName("k_mahsulot_id")->Value = id_mahsulot;
ADOQuery1->Parameters->ParamByName("k_soni")->Value = soni;
ADOQuery1->Parameters->ParamByName("k_bahosi")->Value = bahosi;
ADOQuery1->ExecSQL();
ADOQuery1->Close();
ADOQuery1->SQL->Clear();
ADOQuery1->SQL->Add("select max(id_kirim) as id from kirim");
ADOQuery1->Open();
// Kirim_tolov jadvaliga qo'shish
int id_kirim;
id_kirim = ADOQuery1->FieldByName("id")->AsInteger;
ADOQuery1->Close();
ADOQuery1->SQL->Clear();
ADOQuery1->SQL->Add("INSERT into kirim_tolov (kt_kirim_id, kt_sana, kt_summa)");
ADOQuery1->SQL->Add("Values (:kt_kirim_id, :kt_sana, 0)");
ADOQuery1->Parameters->ParamByName("kt_kirim_id")->Value = id_kirim;
ADOQuery1->Parameters->ParamByName("kt_sana")->Value = DateTimePicker1->Date;
ADOQuery1->ExecSQL();
Button1Click(Sender);
}
//---------------------------------------------------------------------------
void __fastcall TFormKirim::Button1Click(TObject *Sender)
{
int id_savdogar;
ADOQuery1->Close();
ADOQuery1->SQL->Clear();
ADOQuery1->SQL->Add("select sd_ismi, m_nomi, g_nomi, k_bahosi, k_soni, (k_bahosi * k_soni) as jami, k_sana, sum(kt_summa) as tolandi, id_kirim");
ADOQuery1->SQL->Add("from savdogar, mahsulot, kirim, guruh, kirim_tolov");
ADOQuery1->SQL->Add("where id_savdogar = k_savdogar_id and id_mahsulot = k_mahsulot_id");
ADOQuery1->SQL->Add("and kt_kirim_id = id_kirim");
ADOQuery1->SQL->Add("and id_guruh = m_guruh_id and k_sana = :sana");
if (ComboBoxSavdogar->ItemIndex > -1)
{
id_savdogar = (int) ComboBoxSavdogar->Items->Objects[ComboBoxSavdogar->ItemIndex];
ADOQuery1->SQL->Add("and id_savdogar = " + IntToStr(id_savdogar));
}
ADOQuery1->SQL->Add("group by sd_ismi, m_nomi, g_nomi, k_bahosi, k_soni, k_sana, id_kirim");
ADOQuery1->Parameters->ParamByName("sana")->Value = DateTimePicker1->Date;
ADOQuery1->Open();
}
void __fastcall TFormKirimTolov::BitBtn1Click(TObject *Sender)
{
ADOQuery1->Close();
FormKirimTolov->ADOQuery1->Close();
FormKirimTolov->ADOQuery1->SQL->Clear();
FormKirimTolov->ADOQuery1->SQL->Add("insert into kirim_tolov(kt_kirim_id, kt_summa, kt_sana)");
FormKirimTolov->ADOQuery1->SQL->Add("VALUES (:kirim_id, :summa, :sana)");
ADOQuery1->Parameters->ParamByName("kirim_id")->Value = FormKirim->ADOQuery1->FieldByName("id_kirim")->AsInteger;
ADOQuery1->Parameters->ParamByName("sana")->Value = DateTimePicker1->Date;
ADOQuery1->Parameters->ParamByName("summa")->Value = LabeledEdit1->Text;
ADOQuery1->ExecSQL();
FormKirimTolov->ADOQuery1->Close();
FormKirimTolov->ADOQuery1->SQL->Clear();
FormKirimTolov->ADOQuery1->SQL->Add("select * from kirim_tolov");
FormKirimTolov->ADOQuery1->SQL->Add("where kt_kirim_id = " + FormKirim->ADOQuery1->FieldByName("id_kirim")->AsVariant);
FormKirimTolov->ADOQuery1->Open();
}
//---------------------------------------------------------------------------
Do'stlaringiz bilan baham: |