對DBGrid 的巧妙用法實現查詢 (轉)

gugu99發表於2008-08-05
對DBGrid 的巧妙用法實現查詢 (轉)[@more@]

void __fastcall TForm1::Grid2DblClick(T *Sender)
{
 // INGOODS‘ 是進貨表


  int sumno=0,i;


  INGOODS->Edit();

  AnsiString thisgoodsname;
  DBGrid2->edIndex=1;
  thisgoodsname=DBGrid2->SelectedField->Value;
  (thisgoodsname);
//

  Query2->Close();
  Query2->->Clear();
  Query2->DatabaseName=".";
  Query2->SQL->Add("Select * from INGOODS");
  Query2->SQL->Add("where GOODSNAME=+thisgoodsname+");
  Query2->Prepare();
  Query2->Open();
  for(i=0;iRecordCount;i++){
  sumno+=Query2->FieldByName("INGOODSNO")->AsInteger;
  Query2->Next();
  }
  Form4=new TForm4(this);
  Form4->DBText1->Data=DataSource1;
  Form4->DBText1->DataField="ID";
  Form4->DBText2->DataSource=DataSource1;
  Form4->DBText2->DataField="GOODSNAME";
  Form4->DBText3->DataSource=DataSource1;
  Form4->DBText3->DataField="CLASS";
  Form4->DBText4->DataSource=DataSource1;
  Form4->DBText4->DataField="THENMAN";
  Form4->Label5->Caption="最近出貨時間: ";
  Form4->DBText5->DataSource=DataSource1;
  Form4->DBText5->DataField="LASTTIME";
  Form4->Label6->Caption="現總銷售量:";
  >DBText6->DataSource=DataSource1;
  >DBText6->DataField="THISGOODSNO";
  Form4->Label7->Caption=IntToStr(sumno);
  >Edit2->Text=
  Form4->Show();
}


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10748419/viewspace-1008536/,如需轉載,請註明出處,否則將追究法律責任。

相關文章