以下是引用片段: 采购单信息核心代码: procedure TfrmCgjl.FormShow(Sender: TObject); var i: integer; j: integer; begin self.StringGrid1.ColCount :=8; self.StringGrid1.RowCount:=2; self.StringGrid1.Cells[0,0]:='汽车编号'; self.StringGrid1.Cells[1,0]:='汽车名称'; self.StringGrid1.Cells[2,0]:='类别名称'; self.StringGrid1.Cells[3,0]:='汽车规格'; self.StringGrid1.Cells[4,0]:='厂家名称'; self.StringGrid1.Cells[5,0]:='采购单价'; self.StringGrid1.Cells[6,0]:='数量'; self.StringGrid1.Cells[7,0]:='金额'; self.StringGrid1.RowCount:=16; for i:=0 to self.StringGrid1.ColCount-1 do begin self.StringGrid1.ColWidths[i]:=80; end; for i:=1 to self.StringGrid1.RowCount-1 do begin for j:=0 to self.StringGrid1.ColCount-1 do begin self.StringGrid1.Cells[j,i]:='' end; end; if self.Tag=0 then begin self.Edit1.Text:=inttostr(ShowMaxRecord('采购记录')); self.Edit7.Text:=''; self.Edit3.Text:='0'; self.Edit5.Text:='0'; self.DateTimePicker2.Date :=date; end else begin self.AdoTmp.Close ; self.AdoTmp.Connection:=frmmain.ADOConnection1 ; self.AdoTmp.CommandText:='SELECT dbo.采购记录.采购时间, dbo.采购记录.总数量, dbo.采购记录.总金额,dbo.采购记录.经办人, dbo.客户.客户代码, dbo.客户.客户名称 ' + ' FROM dbo.采购记录 INNER JOIN dbo.客户 ON dbo.采购记录.客户代码 = dbo.客户. 客户代码 where 采购代码='''+ self.Edit1.Text +''''; self.AdoTmp.Active:=true; if self.AdoTmp.Recordset.RecordCount>0 then begin Edit3.Text:=self.AdoTmp.Recordset.Fields[1].Value ; DateTimePicker2.Date:=self.AdoTmp.Recordset.Fields[0].Value ; Edit7.Text:=self.AdoTmp.Recordset.Fields[3].Value ; edit5.Text:= self.AdoTmp.Recordset.Fields[2].Value; edit2.Tag:=self.AdoTmp.Recordset.Fields[4].Value; edit2.Text:=self.AdoTmp.Recordset.Fields[5].Value; self.AdoTmp.Close; self.AdoTmp.Connection:=frmmain.ADOConnection1 ; self.AdoTmp.CommandText:='SELECT dbo.汽车信息.汽车代码, dbo.汽车信息.汽车名称, dbo. 汽车类别.类别名称, ' + ' dbo.汽车信息.汽车规格, dbo.汽车信息.厂家名称, dbo.采购明细.采购单价, ' + ' dbo.采购明细.数量, dbo.采购明细.金额 FROM dbo.汽车信息 INNER JOIN ' + ' dbo.汽车类别 ON dbo.汽车信息.类别代码 = dbo.汽车类别.类别代码 INNER JOIN ' + ' dbo.采购明细 ON dbo.汽车信息.汽车代码 = dbo.采购明细.汽车代码 and 采购明细.采购代码='''+ self.Edit1.Text +''''; self.AdoTmp.Active:=true; if self.AdoTmp.Recordset.RecordCount >0 then begin for i:=0 to self.AdoTmp.Recordset.RecordCount-1 do begin for j:=0 to self.StringGrid1.ColCount-1 do begin self.StringGrid1.Cells[j,i+1]:=self.AdoTmp.Recordset.Fields[j].Value; end; self.AdoTmp.Recordset.MoveNext end;
|