帮忙看一下这段代码 谢谢
procedure TForm1.StringGrid2DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var checkStr2:String;
begin
if ACol=1 then
begin
if ARow>0 then
begin
checkStr2:=StringGrid2.Cells[1,ARow];
if Length(Trim(checkStr2))=5 then
begin
Query3.Close;
Query3.SQL.Clear;
Query3.SQL.add('select * from goods where tda01c='+''''+checkStr2+'''');
Query3.Open;
if Query3.RecordCount<>0 then
begin
with DBEdit8 do
begin
DBEdit8.DataSource:=DataSource4;
DBEdit8.DataField:='tda03c';
end;
with DBEdit9 do
begin
DBEdit9.DataSource:=DataSource4;
DBEdit9.DataField:='tda08c';
end;
with DBEdit10 do
begin
DBEdit10.DataSource:=DataSource4;
DBEdit10.DataField:='tda092f';
end;
StringGrid2.Cells[2,ARow]:=DBEdit8.Text;
StringGrid2.Cells[3,ARow]:='1';
StringGrid2.Cells[4,ARow]:=DBEdit9.Text;
StringGrid2.Cells[5,ARow]:=DBEdit10.Text;
StringGrid2.Cells[6,ARow]:='10';
StringGrid2.Cells[7,ARow]:=DBEdit10.Text;
StringGrid2.Cells[8,ARow]:=floattostr(strtofloat(StringGrid2.Cells[3,ARow])*strtofloat(StringGrid2.Cells[7,ARow]));
DBEdit8.Text:='';
DBEdit9.Text:='';
DBEdit10.Text:='';
end;
end;
end;
end;
if ACol=3 then
begin
if ARow>0 then
begin
if StringGrid2.Cells[2,ARow]<>'' then
begin
StringGrid2.Cells[8,ARow]:=floattostr(strtofloat(StringGrid2.Cells[3,Arow])*strtofloat(StringGrid2.Cells[7,ARow]));
end;
end;
end;
if ACol=6 then
begin
if ARow>0 then
begin
if StringGrid2.Cells[2,ARow]<>'' then
begin
StringGrid2.Cells[8,ARow]:=floattostr(strtofloat(StringGrid2.Cells[3,Arow])*strtofloat(StringGrid2.Cells[5,ARow])*strtofloat(StringGrid2.Cells[6,ARow])/10);
*************StringGrid2.Cells[7,ARow]:='1000';
end;
end;
end;
if ACol=7 then
begin
if ARow>0 then
begin
if StringGrid2.Cells[2,ARow]<>'' then
begin
StringGrid2.Cells[8,ARow]:=floattostr(strtofloat(StringGrid2.Cells[3,Arow])*strtofloat(StringGrid2.Cells[7,ARow]));
StringGrid2.Cells[6,ARow]:=floattostr(strtofloat(StringGrid2.Cells[7,Arow])/strtofloat(StringGrid2.Cells[5,Arow])*10);
end;
end;
end;
end;
简单的cells编辑 但加上有很多*的那句以后就会不停的执行SQL语句...
郁闷好几天了....
不知道为什么 只要对cells[7,Arow]进行赋值就出错 无论放到哪儿都这样
谁能帮帮我 谢谢