对DBGrid 的巧妙用法实现查询

王朝other·作者佚名  2006-01-08
宽屏版  字体: |||超大  

void __fastcall TForm1::DBGrid2DblClick(TObject *Sender)

{

// INGOODS‘ 是进货表

int sumno=0,i;

INGOODS->Edit();

file://-----------------------------------------------------

AnsiString thisgoodsname;

DBGrid2->SelectedIndex=1;

thisgoodsname=DBGrid2->SelectedField->Value;

file://ShowMessage(thisgoodsname);

//

file://-----------------------------------------------------

Query2->Close();

Query2->SQL->Clear();

Query2->DatabaseName=".\\";

Query2->SQL->Add("Select * from INGOODS");

Query2->SQL->Add("where GOODSNAME='"+thisgoodsname+"'");

Query2->Prepare();

Query2->Open();

for(i=0;i<Query2->RecordCount;i++){

sumno+=Query2->FieldByName("INGOODSNO")->AsInteger;

Query2->Next();

}

Form4=new TForm4(this);

Form4->DBText1->DataSource=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="现总销售量:";

file://Form4->DBText6->DataSource=DataSource1;

file://Form4->DBText6->DataField="THISGOODSNO";

Form4->Label7->Caption=IntToStr(sumno);

file://Form4->Edit2->Text=

Form4->Show();

}

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有