if qryCHUKUMX.State in [dsEdit, dsInsert] then
qryCHUKUMX.Post;
qryBatch := TADOQuery.Create(Self);
try
if DataSet.FieldByName('是否已审核').AsBoolean then
begin
qryBatch.Connection := Data1.csglconnection;
qryBatch.LockType := ltBatchOptimistic;
qryCHUKUMX.First;
ApplySQL(qryBatch, Format(SQL_KCB, [Trim(DataSet.FieldByName('仓库号').AsString)]));
while not qryCHUKUMX.Eof do
begin
if qryBatch.Locate('商品编码', qryCHUKUMX.FieldByName('商品编码').Value, []) then
begin
if qryBatch.Fields[1].AsFloat - qryCHUKUMX.FieldByName('数量').AsFloat <0 then
begin
ShowMessage(qryCHUKUMXProductName.AsString + '出库量大于库存量,审核失败!');
DataSet.Cancel;
Abort;
end
else begin
if qryBatch.Fields[1].AsFloat - qryCHUKUMX.FieldByName('数量').AsFloat < qryBatch.FieldByName('最小库存').AsFloat then
ShowMessage(qryCHUKUMXProductName.AsString + '库存量已经不足,请及时补货!');
qryBatch.Edit;
qryBatch.Fields[1].AsFloat := qryBatch.Fields[1].AsFloat - qryCHUKUMX.FieldByName('数量').AsFloat;
qryBatch.Post;
end;
end;
qryCHUKUMX.Next;
end;
qryBatch.UpdateBatch(arAll);
end;
finally
qryBatch.Free;
end;
end;
procedure TfrmOutDepot.LoadPickList;
const
SQLStr ='SELECT A.商品编码, A.商品名称 '+
'FROM spjbxxb A INNER JOIN kcb B ON Trim(A.商品编码) = Trim(B.商品编码) '+