📄 frm_allexportbilledit.pas
字号:
SG2.Cells[6,CRowLast]:=floattostr(chargeweight)
else
SG2.Cells[6,CRowLast]:=SG2.Cells[1,cRowLast];
end;
end;
{计费重量}
str1:=strtofloat(SG2.Cells[6,cRowLast]);
{单价}
str2:=strtofloat(SG2.Cells[7,cRowLast]);
if SG2.Cells[4,cRowLast]='M' then
SG2.Cells[8,CRowLast]:=SG2.Cells[6,CRowLast]
else
SG2.Cells[8,cRowLast]:=Formatfloat('0.00',(str1*str2));
end;
procedure TFrmAllExportBillEdit.ChangePrice(OldCode,NewCode,FileCode:string);
var
sqlstr,sqlstr1:string;
begin
if trim(oldcode)='' then
else
begin
SqlStr:='update fareinfo set Filecode=null '+
' where relacode='''+
Oldcode+'''';
sqlstr1:='update Planegoods set Filecode=null '+
' where relacode='''+
oldcode+'''';
if FrmMain.ExecSQL(sqlstr) then
else
ShowMessage('更新费用记录失败,请检查');
if FrmMain.ExecSQL(sqlstr1) then
else
ShowMessage('更新货物记录失败,请检查');
end;
if newcode='' then
exit;
SqlStr:='update fareinfo set Filecode='''+Filecode+
''' where relacode='''+
Newcode+'''';
sqlstr1:='update Planegoods set Filecode='''+FileCode+
''' where relacode='''+
Newcode+'''';
if FrmMain.ExecSQL(sqlstr) then
else
ShowMessage('更新费用记录失败,请检查');
if FrmMain.ExecSQL(sqlstr1) then
else
ShowMessage('更新货物记录失败,请检查');
end;
procedure TFrmAllExportBillEdit.Saveifdiscard;
var
sqlstr:string;
begin
if ChkDiscard.Checked then
sqlstr:='update Filetable set ifdiscard=1 where Maincode='''+varMain+''''
else
sqlstr:='update Filetable set ifdiscard=0 where Maincode='''+varMain+'''';
if FrmMain.execsql(sqlstr) then
else
begin
ShowMessage('操作有失误,记录未保存,请检查!');
end;
end;
procedure TFrmAllExportBillEdit.Saveifchecked;
var
sqlstr:string;
begin
if Chkkeydown.Checked then
begin
sqlstr:='update Filetable set keydown=1 where Maincode='''+varMain+'''';
if FrmMain.execsql(sqlstr) then
else
begin
ShowMessage('操作有失误,更新分单完成标记时有错,请检查!');
end;
end;
end;
procedure TFrmAllExportBillEdit.ShowPreDo(Code: string);
begin
CurrentFileCode:=Code; {当前编辑的FileCode的值}
LVddo.Items.Clear;
if Code='' then
exit;
try
with QryTemp do
begin
close;
sql.text:='select docode,dodate,doplace,doresult from planepredo where '+
' filecode ='''+code+''' ';
open;
end;
FrmMain.AddData(LVddo,QryTemp);
QryTemp.close;
except
end;
end;
procedure TFrmAllExportBillEdit.SaveMainstat;
var
sqlstr:string;
carbindesc:string;
i:integer;
Number,NumberStr,weight,size,chargeweight:real;
goodsdesc:string;
GoodsOther:String;
Credit,debit,profit:real;
begin
if VarMain='' then
exit;
{*统计主单中的货物记录*}
{Select 出货物记录中相对于主单的记录}
qrytemp.close;
qrytemp.sql.text:='select * from PlaneGoods '+
' where Filecode='''+varmain+'''';
qrytemp.open;
goodsdesc:=''; {存储货物描述}
GoodsOther:='';{其他描述}
while not qrytemp.Eof do
begin
goodsdesc:=goodsdesc+chr(13)+qrytemp.fieldbyname('goods').asstring;
goodsother:=goodsother+chr(13)+qrytemp.fieldbyname('spegoods').asstring;
qrytemp.next;
end;
{*统计出主单货物记录中货物的件数,重量,体积,计费重量*}
qrytemp.close;
qrytemp.sql.Text:='select sum(Pieces) as GoodsNumber ,sum(weight) as Goodsweight,'+
' sum(size) as goodssize ,sum(Chargweight) as GoodsChargeweight'+
' from PlaneGoods '+
' where Filecode='''+varmain+'''';
qrytemp.open;
if qrytemp.RecordCount >0 then
begin
number:=qrytemp.fieldbyname('GoodsNumber').asfloat; {统计货物件数}
weight:=qrytemp.fieldbyname('Goodsweight').asfloat; {统计货物重量}
size:=qrytemp.fieldbyname('goodssize').asfloat; {统计货物体积}
chargeweight:=qrytemp.fieldbyname('GoodsChargeweight').asfloat; {统计计费重量}
sqlstr:='update FileTable set GoodsDesc='''+FrmMain.FullStrYh(goodsdesc)+''','+
'Goodsweight='''+floattostr(weight)+
''',Goodsnumber='''+floattostr(number)+''',goodsdescr='''+FrmMain.FullStrYh(goodsother)+''',Goodssize='''+floattostr(size)+''',GoodsChargeweight='''+floattostr(chargeweight)+''' '+
' where Filecode='''+varmain+'''';
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='''+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 TFrmAllExportBillEdit.SaveHawbstat;
var
sqlstr:string;
carbindesc:string;
i:integer;
Number,NumberStr,weight,size,chargeweight:real;
goodsdesc,Hawbcode,goodsother:string;
Credit,debit,profit:real;
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 * from PlaneGoods '+
' where Filecode='''+Hawbcode+'''';
qrytemp.open;
goodsdesc:='';
goodsother:='';
while not qrytemp.Eof do
begin
goodsdesc:=goodsdesc+chr(13)+qrytemp.fieldbyname('goods').asstring;
goodsother:=goodsother+chr(13)+qrytemp.fieldbyname('spegoods').asstring;
qrytemp.next;
end;
{依次统计分单中的货物的件数,重量,尺寸,计费重量}
qrytemp.close;
qrytemp.sql.Text:='select sum(Pieces) as GoodsNumber ,sum(weight) as Goodsweight,'+
' sum(size) as goodssize ,sum(Chargweight) as GoodsChargeweight'+
' from PlaneGoods '+
' where Filecode='''+Hawbcode+'''';
qrytemp.open;
if qrytemp.RecordCount >0 then
begin
number:=qrytemp.fieldbyname('GoodsNumber').asfloat; {统计件数}
weight:=qrytemp.fieldbyname('Goodsweight').asfloat; {统计重量}
size:=qrytemp.fieldbyname('goodssize').asfloat; {统计尺寸}
chargeweight:=qrytemp.fieldbyname('GoodsChargeweight').asfloat; {统计计费重量}
{更新分单中的货物的件数,重量,尺寸,计费重量数据}
sqlstr:='update FileTable set GoodsDesc='''+FrmMain.Fullstryh(goodsdesc)+''','+
' Goodsweight='''+floattostr(weight)+
''',Goodsnumber='''+floattostr(number)+''',goodsdescr='''+FrmMain.FullStrYh(goodsother)+
''',Goodssize='''+floattostr(size)+''',GoodsChargeweight='''+floattostr(chargeweight)+''' '+
' 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 TFrmAllExportBillEdit.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(total) as yun from planegoods '+
' where Filecode='''+Varmain+''' ';
qrytemp.open;
}
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:=qrytemp.fieldbyname('farename').asstring+':'+trim(qrytemp.fieldbyname('name').asstring+' '+floattostr(qrytemp.fieldbyname('acount').asfloat));
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('主单运费,杂费预付到付数据统计失败,请检查!');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -