代码:
procedure TFrmQxQp_XSTK.MainAfterPost(DataSet: TDataSet);
var
strSQL:string;
S1,S2,S3,S4,S5,S6,S7
ouble;
const
cSQL='select 数量,货款,税额,总金额,成本,配件利润,退料标记 from xslr where 业务单号=''%s'' and 配件代码=''%s''';
begin
inherited;
strSQL:=Format(cSQL,[QryBase.FieldByName('原单号').Asstring,QryDetail.FieldByName('配件代码').Asstring]);
if DM_Main.OpenQueryEx(strSQL) then
begin
S1:=DM_Main.QryMain.Fields[0].AsFloat;
S2:=DM_Main.QryMain.Fields[1].AsFloat;
S3:=DM_Main.QryMain.Fields[2].AsFloat;
S4:=DM_Main.QryMain.Fields[3].AsFloat;
S5:=DM_Main.QryMain.Fields[4].AsFloat;
S6:=DM_Main.QryMain.Fields[5].AsFloat;
S7:=DM_Main.QryMain.Fields[6].AsFloat;
with DM_Main.QryMain do
begin
Open;
Edit;
FieldByName('数量').AsFloat:=S1-Detail.FieldByName('数量').AsFloat;
FieldByName('货款').AsFloat:=S2-Detail.FieldByName('货款').AsFloat;
FieldByName('税额').AsFloat:=S3-Detail.FieldByName('税额').AsFloat;
FieldByName('总金额').AsFloat:=S4-Detail.FieldByName('总金额').AsFloat;
FieldByName('成本').AsFloat:=S5-Detail.FieldByName('成本').AsFloat;
FieldByName('配件利润').AsFloat:=S6-Detail.FieldByName('配件利润').AsFloat;
FieldByName('退料标记').AsFloat:=S7+Detail.FieldByName('数量').AsFloat;
Post;
Close;
end;