41
void __fastcall TForm9::DBGrid1DblClick(TObject *Sender)
{
String id = ADOQuery1->FieldByName("id")->AsString;
String q = InputBox("Прихід матеріалів", "Введіть кількість:", "");
if(q == "")return;
int i=0;
try
{
i = StrToInt(q);
}catch(...){ShowMessage("Введіть ціле число!");return;}
ADOQuery2->SQL->Text = "insert into pruxid(id_mat, quant) values(:p1, :p2)";
ADOQuery2->Parameters->ParamByName("p1")->Value = id;
ADOQuery2->Parameters->ParamByName("p2")->Value = i;
ADOQuery2->ExecSQL();
ADOQuery2->SQL->Text = "select p.id as 'id', m.id as 'idd', m.name as 'name', p.quant as 'quant' from
material m, pruxid p where m.id = p.id_mat";
ADOQuery2->ExecSQL();
ADOQuery2->Active = true;
}
//---------------------------------------------------------------------------
void __fastcall TForm9::Button2Click(TObject *Sender)
{
String id = ADOQuery2->FieldByName("'id'")->AsString;
ADOQuery2->SQL->Text = "delete from pruxid where id = :p1";
ADOQuery2->Parameters->ParamByName("p1")->Value = id;
ADOQuery2->ExecSQL();
ADOQuery2->SQL->Text = "select p.id as 'id', m.id as 'idd', m.name as 'name', p.quant as 'quant' from
material m, pruxid p where m.id = p.id_mat";
ADOQuery2->ExecSQL();
ADOQuery2->Active = true;
}
//---------------------------------------------------------------------------
void __fastcall TForm9::Button3Click(TObject *Sender)
{
ADOQuery1->SQL->Text = "select m.id, m.name, o.name, m.quant from material m, ov o where m.id_ov
= o.id";
ADOQuery1->ExecSQL();
ADOQuery1->Active = true;
}
//---------------------------------------------------------------------------
void __fastcall TForm9::Button1Click(TObject *Sender)
{
ADOQuery2->First();
for(int i=0;i<ADOQuery2->RecordCount;i++)
{
String id = ADOQuery2->FieldByName("'idd'")->AsString;
String q = ADOQuery2->FieldByName("'quant'")->AsString;
AQ->SQL->Text = "update material set quant = quant + :p1 where id = :p2";
AQ->Parameters->ParamByName("p1")->Value = q;
AQ->Parameters->ParamByName("p2")->Value = id;
AQ->ExecSQL();
AQ->SQL->Text = "insert into pruxid_zvit(id_tov, quant, dat) values(:p1, :p2, :p3)";
AQ->Parameters->ParamByName("p1")->Value = id;
AQ->Parameters->ParamByName("p2")->Value = q;
AQ->Parameters->ParamByName("p3")->Value = Date();
AQ->ExecSQL();
ADOQuery2->Next();
}
/*ADOQuery2->First();
for(int i=0;i<ADOQuery2->RecordCount;i++)
{
String idd = ADOQuery2->FieldByName("'id'")->AsString;
AQ->SQL->Text = "delete from pruxid where id = :p1";
AQ->Parameters->ParamByName("p1")->Value = idd;
AQ->ExecSQL();
ADOQuery2->Next();