做了一个防止库存不够就出问题了
var
sum,gcol,grow,xhjc,i:integer;
begin
inherited;
For i := 1 to StringGrid1.RowCount-1 do
begin
Sum := GroupSL(StringGrid1.Cells[1,i]);(鼠标停在这)
with ADOQuery3 do
begin
Close;
SQL.Clear;
SQL.Add('select * from tb_stock where tradecode = :a');
Parameters.ParamByName('a').Value := Trim(StringGrid1.Cells[1,i]);
Open;
end;
if Sum >ADOQuery3.FieldByName('qty').Value then
begin
Application.MessageBox(Pchar('商品编号为'+ Trim(StringGrid1.Cells[1,i])+'的出货数量大于库存数量,不能完成出库。'),'提示',64);
Exit;
end
end;
end;
function TF_xsd.GroupSL(SPbh: String): Integer;
var
i: Integer;
begin
ReSult := 0;
For i := 1 to StringGrid1.RowCount -1 do
begin
if Trim(Spbh)= Trim(StringGrid1.Cells[1,i]) then
Result := ReSult + StrToInt(StringGrid1.Cells[7,i]);
end;
end;
把这些代码去掉就挺正常的,不知道问题出在哪,看英文解释为不是整数或空值,我明明输的是10呀!
在GroupSL函数中最好做一个整型判断,或者使用try