📄 frm_allimportbilledit.~pas
字号:
Data := StrToFloat(vararray[0]) - StrToFloat(vararray[2]);
if vararray[1] = '*' then
Data := StrToFloat(vararray[0]) * StrToFloat(vararray[2]);
if vararray[1] = '/' then
Data := StrToFloat(vararray[0]) / StrToFloat(vararray[2]);
i := 3;
while true do
begin
if i > j then
Break;
if uppercase(VarArray[i + 1]) = 'X' then
VarArray[i + 1] := floattostr(day);
if vararray[i] = '+' then
Data := Data + StrToFloat(vararray[i + 1]);
if vararray[i] = '-' then
Data := Data - StrToFloat(vararray[i + 1]);
if vararray[i] = '*' then
Data := Data * StrToFloat(vararray[i + 1]);
if vararray[i] = '/' then
Data := Data / StrToFloat(vararray[i + 1]);
i := i + 2;
end;
Data := Data * Weight;
Data := strtofloat(FormatFloat('0.00', Data));
result := data;
except
ShowMessage('公式中存在错误的字符,请检查!');
end;
end;
function TFrmAllImportBillEdit.Havefendan: boolean;
var
FilterStr: string;
begin
result := false;
QryTemp.Close;
QryTemp.SQL.Text := 'Select * From FareiNfo where Filecode=''' +
lvhw.selected.caption + ''' and substring(relacode,1,1)=''F''';
QryTemp.Open;
if FrmMain.RecordCount(QryTemp) > 0 then
result := true;
end;
procedure TFrmAllImportBillEdit.SaveMainstat;
var
sqlstr: string;
carbindesc: string;
i: integer;
Number, NumberStr, weight, size, chargeweight: real48;
goodsdesc: string;
Credit, debit, profit: real48;
begin
if VarMain = '' then
exit;
{*统计主单中的费用的应收,应付,利润*}
qrytemp.close;
Qrytemp.SQL.Text := 'select ' +
' sum(b.acount*g.rate) as rmb,b.recedeal ' +
' from fareinfo b,currency g where ' +
' g.code=*b.currencytype and ' +
' b.Filecode=''' + varmain + ''' ' +
' and b.OperCwMark=''业务操作''' +
' group by b.recedeal ';
QryTemp.open;
debit := 0;
credit := 0;
profit := 0;
while not qrytemp.eof do
begin
if qrytemp.FieldByName('recedeal').asinteger = 1 then
debit := qrytemp.fieldbyname('rmb').asfloat {得出 应收的多少}
else
credit := qrytemp.fieldbyname('rmb').asfloat; {得出 应付的多少}
Qrytemp.next;
end;
profit := debit - credit; {得出利润的多少}
{把得出的应收,应付,利润的数值更新到表中}
sqlstr := 'update Filetable set credit=' + floattostr(credit) + ', ' +
'debit=' + floattostr(debit) + ',profit=' + floattostr(profit) +
' where Filecode=''' + varmain + '''';
if FrmMain.ExecSQL(sqlstr) then
else
begin
ShowMessage('主单费用利润统计失败,请检查!');
end;
end;
procedure TFrmAllImportBillEdit.SaveHawbstat;
var
sqlstr: string;
carbindesc: string;
i: integer;
Number, NumberStr, weight, size, chargeweight: real48;
goodsdesc, Hawbcode: string;
Credit, debit, profit: real48;
begin
{*Select 出主单数据中的所有分单数据*}
Query1.close;
Query1.sql.text := 'select * from Filetable ' +
' where Maincode=''' + varmain + '''';
Query1.open;
while not query1.Eof do
begin
HawbCode := query1.fieldbyname('Filecode').Asstring;
{得出当前分单FileCode的值}
{依次统计分单中的货物的件数,重量,尺寸,计费重量}
qrytemp.close;
qrytemp.sql.Text := 'select SUM(size) as jingzhong from PlaneGoods ' +
' where Filecode=''' + Hawbcode + '''';
qrytemp.open;
if qrytemp.RecordCount > 0 then
begin
size := qrytemp.fieldbyname('jingzhong').asfloat; {统计尺寸}
{更新分单中的货物的件数,重量,尺寸,计费重量数据}
sqlstr := 'update FileTable set jingzhong=''' + floattostr(size) +
''' where Filecode=''' + Hawbcode + '''';
if FrmMain.ExecSQL(sqlstr) then
else
begin
ShowMessage('分单货物数据统计失败,请检查!');
end;
end;
{统计分单中的费用信息}
qrytemp.close;
Qrytemp.SQL.Text := 'select ' +
' sum(b.acount*g.rate) as rmb,b.recedeal ' +
' from fareinfo b,currency g where ' +
' g.code=*b.currencytype and ' +
' b.Filecode=''' + Hawbcode + ''' ' +
' and b.OperCwMark=''业务操作''' +
' group by b.recedeal ';
QryTemp.open;
debit := 0;
credit := 0;
profit := 0;
while not qrytemp.eof do
begin
if qrytemp.FieldByName('recedeal').asinteger = 1 then
begin
debit := qrytemp.fieldbyname('rmb').asfloat; {统计应收}
end
else
begin
credit := qrytemp.fieldbyname('rmb').asfloat; {统计应付}
end;
Qrytemp.next;
end;
profit := debit - credit; {统计利润}
{更新分单数据中相关的费用信息}
sqlstr := 'update Filetable set credit=' + floattostr(credit) + ', ' +
'debit=' + floattostr(debit) + ',profit= ' + floattostr(profit) +
' where Filecode=''' + Hawbcode + '''';
if FrmMain.ExecSQL(sqlstr) then
else
begin
ShowMessage('分单收入利润统计失败,请检查!');
end;
Query1.Next;
end;
Query1.close;
end;
procedure TFrmAllImportBillEdit.SaveMawbparpay;
var
sqlstr: string;
yunFare, zaFare: Real;
PPd, coll, oppd, ocoll: string;
ZaDes: string;
begin
if VarMain = '' then
exit;
PPD := '';
Coll := '';
Oppd := '';
OColl := '';
yunFare := 0; {运费统计}
zaFare := 0; {杂费统计}
{统计主单中的运费}
qrytemp.close;
qrytemp.sql.text := 'select Sum(Acount) as yun from Fareinfo ' +
' where Filecode=''' + varmain + ''' and goodscode=''运费''' +
' and OperCwMark=''业务操作''';
qrytemp.open;
yunFare := qrytemp.fieldbyname('yun').asfloat;
{统计主单中的杂费}
qrytemp.close;
qrytemp.sql.text := 'select Sum(Acount) as zafare from Fareinfo ' +
' where Filecode=''' + varmain + ''' and goodscode=''杂费''' +
' and OperCwMark=''业务操作''';
qrytemp.open;
zaFare := qrytemp.fieldbyname('zafare').asfloat;
{统计杂费的合计信息}
qrytemp.close;
qrytemp.sql.text := 'select a.acount,b.name,c.farecname,c.farename' +
' from Fareinfo a,currency b,fareinformation c ' +
' where b.code=*a.currencytype and c.farecode=*a.farecode and ' +
' a.Filecode=''' + varmain + ''' and a.goodscode=''杂费''' +
' and a.OperCwMark=''业务操作''';
qrytemp.open;
zades := '';
while not qrytemp.Eof do
begin
zades := zades + qrytemp.fieldbyname('farename').asstring + ' ' +
FloatTOstrF(qrytemp.fieldbyname('acount').asfloat, ffFixed, 16, 2) +
chr(13);
qrytemp.next;
end;
sqlstr := 'update Filetable set otherdesc=''' + zades + ''' where Filecode='''
+ varmain + ''' ';
if FrmMain.ExecSQL(sqlstr) then
else
ShowMessage('统计主单杂费费用的项数时出错,请检查!');
{得到主单中的预付,到付信息}
qrytemp.close;
qrytemp.sql.text := 'select * from Filetable ' +
' where Filecode=''' + varmain + ''' ';
qrytemp.open;
PPd := qrytemp.fieldbyname('PPd').asstring; {运费预付}
coll := qrytemp.fieldbyname('coll').asstring; {运费到付}
oppd := qrytemp.fieldbyname('oppd').asstring; {杂费预付}
ocoll := qrytemp.fieldbyname('ocoll').asstring; {杂费到付}
{保存到主单中的运费,杂费,预付到付信息}
if PPd = 'PP' then
begin
{PrePay 运费预付,DPay 运费到付 TOCPre 杂费预付 TOCCollect 杂费到付}
if oppd = 'PP' then
sqlstr := 'update Filetable set prepay=' + Floattostr(yunFare) +
',Dpay=0,Tocpre=' + floattostr(zaFare) + ',TocCollect=0,Pretotal=' +
floattostr(zaFare + yunfare) + ',Dtotal=0 where Filecode=''' + varmain
+
''' ';
if ocoll = 'CC' then
sqlstr := 'update Filetable set prepay=' + floattostr(yunFare) +
',Dpay=0,Tocpre=0,TocCollect=' + floattostr(zaFare) + ',Pretotal=' +
floattostr(yunfare) + ',Dtotal=' + floattostr(zaFare) +
' where Filecode=''' + varmain + '''';
end;
if coll = 'CC' then
begin
if oppd = 'PP' then
sqlstr := 'update Filetable set prepay=0,Dpay=' + floattostr(yunFare) +
',Tocpre=' + floattostr(zaFare) + ',TocCollect=0,Pretotal=' +
floattostr(zafare) + ',Dtotal=' + floattostr(yunFare) +
' where Filecode=''' + varmain + '''';
if ocoll = 'CC' then
sqlstr := 'update Filetable set prepay=0,Dpay=' + floattostr(yunFare) +
',Tocpre=0,TocCollect=' + floattostr(zaFare) + ',Pretotal=0,Dtotal=' +
floattostr(yunFare + zafare) + ' where Filecode=''' + varmain + '''';
end;
if FrmMain.ExecSQL(sqlstr) then
else
ShowMessage('主单运费,杂费预付到付数据统计失败,请检查!');
end;
procedure TFrmAllImportBillEdit.SaveHawbparpay;
var
sqlstr, Varfendan: string;
yunFare, zaFare: real48;
PPd, coll, oppd, ocoll: string;
zades: string;
begin
PPd := '';
coll := '';
oppd := '';
ocoll := '';
{Select 出主单中所包括的所有分单数据}
Query1.close;
Query1.sql.text := 'select * from Filetable ' +
' where Maincode=''' + varmain + '''';
query1.open;
while not query1.Eof do
begin
Varfendan := query1.fieldbyname('Filecode').Asstring; {记录分单的FileCode号}
yunFare := 0;
zaFare := 0;
PPd := '';
coll := '';
oppd := '';
ocoll := '';
{统计分单运费}
qrytemp.close;
qrytemp.sql.text := 'select Sum(Acount) as yun from Fareinfo ' +
' where Filecode=''' + Varfendan + ''' and goodscode=''运费''' +
' and OperCwMark=''业务操作''';
qrytemp.open;
yunFare := qrytemp.fieldbyname('yun').asfloat; {记录运费金额}
{统计分单杂费}
qrytemp.close;
qrytemp.sql.text := 'select Sum(Acount) as zafare from Fareinfo ' +
' where Filecode=''' + Varfendan + ''' and goodscode=''杂费''' +
' and OperCwMark=''业务操作''';
qrytemp.open;
zaFare := qrytemp.fieldbyname('zafare').asfloat;
{统计分单的杂费的合计信息}
qrytemp.close;
qrytemp.sql.text := 'select a.acount,b.name,c.farecname,c.farename' +
' from Fareinfo a,currency b,fareinformation c ' +
' where b.code=*a.currencytype and c.farecode=*a.farecode and ' +
' a.Filecode=''' + Varfendan + ''' and a.goodscode=''杂费''' +
' and a.OperCwMark=''业务操作''';
qrytemp.open;
zades := '';
while not qrytemp.Eof do
begin
zades := zades + qrytemp.fieldbyname('farename').asstring + ' ' +
FloatTOstrF(qrytemp.fieldbyname('acount').asfloat, ffFixed, 16, 2) +
chr(13);
qrytemp.next;
end;
sqlstr := 'update Filetable set otherdesc=''' + zades +
''' where Filecode=''' + Varfendan + ''' ';
if FrmMain.ExecSQL(sqlstr) then
else
ShowMessage('统计分单杂费费用的项数时出错,请检查!');
{得到预付到付的标记}
qrytemp.close;
qrytemp.sql.text := 'select * from Filetable ' +
' where Filecode=''' + Varfendan + ''' ';
qrytemp.open;
PPd := qrytemp.fieldbyname('PPd').asstring;
coll := qrytemp.fieldbyname('coll').asstring;
oppd := qrytemp.fieldbyname('oppd').asstring;
ocoll := qrytemp.fieldbyname('ocoll').asstring;
{保存到分单中的运费,杂费,预付到付信息}
if PPd = 'PP' then
begin
{PrePay 运费预付,DPay 运费到付 TOCPre 杂费预付 TOCCollect 杂费到付}
if oppd = 'PP' then
sqlstr := 'update Filetable set prepay=' + Floattostr(yunFare) +
',Dpay=0,Tocpre=' + floattostr(zaFare) + ',TocCollect=0,Pretotal=' +
floattostr(zaFare + yunfare) + ',Dtotal=0 where Filecode=''' +
varfendan
+ ''' ';
if ocoll = 'CC' then
sqlstr := 'update Filetable set prepay=' + floattostr(yunFare) +
',Dpay=0,Tocpre=0,TocCollect=' + floattostr(zaFare) + ',Pretotal=' +
floattostr(yunfare) + ',Dtotal=' + floattostr(zaFare) +
' where Filecode=''' + varfendan + '''';
end;
if coll = 'CC' then
begin
if oppd = 'PP' then
sqlstr := 'update Filetable set prepay=0,Dpay=' + floattostr(yunFare) +
',Tocpre=' + floattostr(zaFare) + ',TocCollect=0,Pretotal=' +
floattostr(zafare) + ',Dtotal=' + floattostr(yunFare) +
' where Filecode=''' + varfendan + '''';
if ocoll = 'CC' then
sqlstr := 'update Filetable set prepay=0,Dpay=' + floattostr(yunFare) +
',Tocpre=0,TocCollect=' + floattostr(zaFare) + ',Pretotal=0,Dtotal=' +
floattostr(yunFare + zafare) + ' where Filecode=''' + varfendan +
'''';
end;
if FrmMain.ExecSQL(sqlstr) then
else
ShowMessage('分单运费,杂费预付到付数据统计失败,请检查');
Query1.Next;
end;
Query1.close;
end;
procedure TFrmAllImportBillEdit.SaveifChecked;
var
sqlstr: string;
begin
if Chkkeydown.Checked then
begin
sqlstr := 'update Filetable set befinish=1 where Maincode=''' + varMain +
'''';
if FrmMain.execsql(sqlstr) then
else
begin
ShowMessage('操作有失误,更新主单包含的相应的分单作废标记失败,请检查!');
end;
end;
end;
procedure TFrmAllImportBillEdit.ShowHanding(Code: string);
begin
CurrentFileCode := Code; {记录当前编辑的业务操作的FileCode号}
LVDDO.Items.Clear;
if Code = '' then
exit;
try
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -