unit U_ch_prnFee; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, dxExEdtr, u_fee_check, StdCtrls, Mask, DBCtrls, dxDBTLCl, dxGrClms, dxDBGrid, dxTL, dxDBCtrl, dxCntner, bsSkinCtrls, DB, ADODB, Menus, Grids, Wwdbigrd, Wwdbgrid, ExtCtrls, bsSkinBoxCtrls, bsdbctrls, DBGrids, DBGridEh, kbmMemTable, kbmMemBinaryStreamFormat; type Tfrm_cw_prnFee = class(TForm) tv_bscard_all: TADOQuery; tv_bscard_all1: TDataSource; t_ch_accept: TADOQuery; Splitter1: TSplitter; t_op_gain_main: TADOQuery; t_op_gain: TADOQuery; t_ch_pay: TADOQuery; t_ch_accept1: TDataSource; t_ch_pay1: TDataSource; Panel2: TPanel; bsSkinStdLabel4: TbsSkinStdLabel; bsSkinStdLabel2: TbsSkinStdLabel; bsSkinStdLabel3: TbsSkinStdLabel; bsSkinStdLabel1: TbsSkinStdLabel; bsSkinStdLabel5: TbsSkinStdLabel; bsSkinStdLabel6: TbsSkinStdLabel; bsSkinStdLabel7: TbsSkinStdLabel; bsSkinStdLabel8: TbsSkinStdLabel; bsSkinStdLabel9: TbsSkinStdLabel; bsSkinStdLabel10: TbsSkinStdLabel; bsSkinDBEdit6: TbsSkinDBEdit; bsSkinDBEdit4: TbsSkinDBEdit; bsSkinDBEdit1: TbsSkinDBEdit; bsSkinDBEdit3: TbsSkinDBEdit; bsSkinDBEdit5: TbsSkinDBEdit; bsSkinDBEdit2: TbsSkinDBEdit; bsSkinDBEdit8: TbsSkinDBEdit; bsSkinDBEdit7: TbsSkinDBEdit; bsSkinDBEdit9: TbsSkinDBEdit; bsSkinDBEdit10: TbsSkinDBEdit; Panel9: TPanel; bsSkinStdLabel11: TbsSkinStdLabel; bsSkinStdLabel12: TbsSkinStdLabel; bsSkinStdLabel13: TbsSkinStdLabel; bsSkinStdLabel14: TbsSkinStdLabel; bsSkinStdLabel15: TbsSkinStdLabel; bsSkinStdLabel16: TbsSkinStdLabel; bsSkinStdLabel17: TbsSkinStdLabel; bsSkinStdLabel18: TbsSkinStdLabel; bsSkinStdLabel19: TbsSkinStdLabel; bsSkinStdLabel20: TbsSkinStdLabel; bsSkinDBEdit11: TbsSkinDBEdit; bsSkinDBEdit12: TbsSkinDBEdit; bsSkinDBEdit13: TbsSkinDBEdit; bsSkinDBEdit14: TbsSkinDBEdit; bsSkinDBEdit15: TbsSkinDBEdit; bsSkinDBEdit16: TbsSkinDBEdit; bsSkinDBEdit17: TbsSkinDBEdit; bsSkinDBEdit18: TbsSkinDBEdit; bsSkinDBEdit19: TbsSkinDBEdit; bsSkinDBEdit20: TbsSkinDBEdit; t_op_gain1: TDataSource; t_op_gain_main1: TDataSource; Panel1: TPanel; DBGridEh1: TDBGridEh; DBGridEh2: TDBGridEh; Panel3: TPanel; dxDBGrid1: TdxDBGrid; dxDBGrid1Column1: TdxDBGridMaskColumn; dxDBGrid1Column2: TdxDBGridMaskColumn; dxDBGrid1Column3: TdxDBGridMaskColumn; dxDBGrid1Column4: TdxDBGridMaskColumn; dxDBGrid1Column5: TdxDBGridMaskColumn; dxDBGrid1Column6: TdxDBGridDateColumn; dxDBGrid1Column7: TdxDBGridMaskColumn; dxDBGrid1Column8: TdxDBGridMaskColumn; dxDBGrid1Column9: TdxDBGridMaskColumn; dxDBGrid1Column10: TdxDBGridMaskColumn; dxDBGrid1Column11: TdxDBGridMaskColumn; dxDBGrid1Column12: TdxDBGridMaskColumn; dxDBGrid1Column13: TdxDBGridMaskColumn; dxDBGrid1Column14: TdxDBGridDateColumn; dxDBGrid1Column15: TdxDBGridMaskColumn; dxDBGrid1Column16: TdxDBGridMaskColumn; dxDBGrid1Column17: TdxDBGridMaskColumn; dxDBGrid1Column18: TdxDBGridMaskColumn; dxDBGrid1Column19: TdxDBGridCurrencyColumn; dxDBGrid1Column20: TdxDBGridMaskColumn; dxDBGrid1Column21: TdxDBGridDateColumn; dxDBGrid1Column22: TdxDBGridMaskColumn; dxDBGrid1Column23: TdxDBGridMaskColumn; dxDBGrid1Column24: TdxDBGridMaskColumn; dxDBGrid1Column25: TdxDBGridMaskColumn; dxDBGrid1Column26: TdxDBGridMaskColumn; dxDBGrid1Column27: TdxDBGridCheckColumn; dxDBGrid1Column28: TdxDBGridCheckColumn; dxDBGrid1Column29: TdxDBGridCheckColumn; dxDBGrid1Column30: TdxDBGridDateColumn; dxDBGrid1Column31: TdxDBGridMaskColumn; dxDBGrid1Column32: TdxDBGridMaskColumn; dxDBGrid1Column33: TdxDBGridMaskColumn; dxDBGrid1Column34: TdxDBGridMaskColumn; dxDBGrid1Column35: TdxDBGridMaskColumn; dxDBGrid1Column36: TdxDBGridMaskColumn; dxDBGrid1Column37: TdxDBGridMaskColumn; dxDBGrid1Column38: TdxDBGridDateColumn; dxDBGrid1Column39: TdxDBGridMaskColumn; dxDBGrid1Column40: TdxDBGridMaskColumn; dxDBGrid1Column41: TdxDBGridMaskColumn; dxDBGrid1Column42: TdxDBGridMaskColumn; dxDBGrid1Column43: TdxDBGridMaskColumn; dxDBGrid1Column44: TdxDBGridMaskColumn; dxDBGrid1Column45: TdxDBGridMaskColumn; dxDBGrid1Column46: TdxDBGridMaskColumn; dxDBGrid1Column47: TdxDBGridMaskColumn; dxDBGrid1Column48: TdxDBGridCurrencyColumn; dxDBGrid1Column49: TdxDBGridDateColumn; dxDBGrid1Column50: TdxDBGridDateColumn; dxDBGrid1Column51: TdxDBGridMaskColumn; dxDBGrid1Column52: TdxDBGridDateColumn; dxDBGrid1Column53: TdxDBGridDateColumn; dxDBGrid1Column54: TdxDBGridDateColumn; dxDBGrid1Column55: TdxDBGridDateColumn; dxDBGrid1Column56: TdxDBGridMaskColumn; dxDBGrid1Column57: TdxDBGridMaskColumn; dxDBGrid1Column58: TdxDBGridMaskColumn; dxDBGrid1Column59: TdxDBGridMaskColumn; dxDBGrid1Column60: TdxDBGridMaskColumn; dxDBGrid1Column61: TdxDBGridMaskColumn; dxDBGrid1Column62: TdxDBGridMaskColumn; dxDBGrid1Column63: TdxDBGridMaskColumn; dxDBGrid1Column64: TdxDBGridMaskColumn; dxDBGrid1Column65: TdxDBGridDateColumn; DBEdit1: TDBEdit; DBEdit6: TDBEdit; bsSkinPanel1: TbsSkinPanel; bsSkinButton5: TbsSkinButton; bsSkinButton11: TbsSkinButton; bsSkinButton10: TbsSkinButton; bsSkinButton4: TbsSkinButton; dxDBGrid1Column67: TdxDBGridCheckColumn; PopupMenu2: TPopupMenu; N10: TMenuItem; N11: TMenuItem; N14: TMenuItem; N13: TMenuItem; N12: TMenuItem; N15: TMenuItem; N74: TMenuItem; qrytmp: TADOQuery; PopupMenu1: TPopupMenu; N1: TMenuItem; N2: TMenuItem; N3: TMenuItem; N4: TMenuItem; N20: TMenuItem; bsSkinPanel2: TbsSkinPanel; Label3: TLabel; bsSkinPanel3: TbsSkinPanel; Label1: TLabel; N5: TMenuItem; N6: TMenuItem; t_pin_gain: TADOStoredProc; t_pin_gain1: TDataSource; t_pin_pay: TADOStoredProc; t_pin_pay1: TDataSource; t_pin_accept: TADOStoredProc; t_pin_accept1: TDataSource; dxDBGrid1Column68: TdxDBGridColumn; dxDBGrid1Column69: TdxDBGridColumn; dxDBGrid1Column70: TdxDBGridColumn; N7: TMenuItem; N8: TMenuItem; kbmBinaryStreamFormat1: TkbmBinaryStreamFormat; kbmThreadDataSet1: TkbmThreadDataSet; memtblprint: TkbmMemTable; memtblprint1: TDataSource; N9: TMenuItem; N16: TMenuItem; memtblprintFee: TkbmMemTable; memtblprintFee1: TDataSource; memtblprintFeeField: TStringField; memtblprintFeeACCNAME: TStringField; memtblprintFeeOBJDR: TStringField; memtblprintFeeOBJCR: TStringField; memtblprintFeeREMARKCR: TStringField; memtblprintFeeUSDCR: TFloatField; memtblprintFeeRMBCR: TFloatField; memtblprintFeeOTCR: TFloatField; memtblprintFeeTTLCR: TFloatField; memtblprintFeeDR: TStringField; memtblprintFeeCR: TStringField; memtblprintFeeUSDDR: TFloatField; memtblprintFeeTTLDR: TFloatField; memtblprintFeeRMBDR: TFloatField; memtblprintFeeOTDR: TFloatField; memtblprintFeeREMARKDR: TStringField; memtblprintFeeFRT: TStringField; memtblprintFeeORDNO: TIntegerField; memtblprintFeeField2: TStringField; memtblprintFeeField3: TStringField; memtblprintFeeField4: TStringField; memtblprintFeeField5: TStringField; memtblprintFeeField6: TStringField; memtblprintFeeField7: TStringField; memtblprintFeeField8: TStringField; memtblprintFeeField9: TStringField; memtblprintFeeField10: TStringField; memtblprintFeeField11: TStringField; memtblprintFeeField12: TStringField; memtblprintFeeField13: TStringField; memtblprintFeeField14: TStringField; memtblprintFeeField15: TStringField; memtblprintFeeField16: TStringField; memtblprintFeeField17: TStringField; memtblprintFeeField18: TStringField; memtblprintFeeField19: TStringField; memtblprintFeeField20: TStringField; procedure bsSkinButton5Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormShow(Sender: TObject); procedure DBEdit1Change(Sender: TObject); procedure DBGridEh1GetCellParams(Sender: TObject; Column: TColumnEh; AFont: TFont; var Background: TColor; State: TGridDrawState); procedure DBGridEh2GetCellParams(Sender: TObject; Column: TColumnEh; AFont: TFont; var Background: TColor; State: TGridDrawState); procedure N10Click(Sender: TObject); procedure N14Click(Sender: TObject); procedure N12Click(Sender: TObject); procedure N74Click(Sender: TObject); procedure bsSkinButton4Click(Sender: TObject); procedure bsSkinButton11Click(Sender: TObject); procedure N1Click(Sender: TObject); procedure N3Click(Sender: TObject); procedure N20Click(Sender: TObject); procedure bsSkinButton10Click(Sender: TObject); procedure N6Click(Sender: TObject); procedure N8Click(Sender: TObject); procedure N16Click(Sender: TObject); private { Private declarations } procedure updateprn(V_value:integer); public { Public declarations } end; var frm_cw_prnFee: Tfrm_cw_prnFee; implementation {$R *.dfm} uses u_main,my_sys_function, u_data_share, u_ch_prnFee_query,u_ch_piliang_prnfee, u_ch_piliang_zhuprnfee; procedure Tfrm_cw_prnFee.bsSkinButton5Click(Sender: TObject); begin close ; end; procedure Tfrm_cw_prnFee.FormClose(Sender: TObject; var Action: TCloseAction); begin savereggrid(dxdbgrid1,caption+'1'); frm_cw_prnFee.Hide; frm_cw_prnFee.ManualFloat(frm_cw_prnFee.BoundsRect ); frm_main.freeTabs('frm_cw_prnFee'); action:=cafree; frm_cw_prnFee:=nil; end; procedure Tfrm_cw_prnFee.FormShow(Sender: TObject); begin with tv_bscard_all,sql do begin Close; clear ; add('select top 50 * from V_op_bscard_All where 主编号=编号 and (录入人='''+employee+''' or 操作员='''+employee+''' or 揽货人='''+employee+''') order by 会计期间 desc,船名,航次 '); //会计期间,业务类别 desc'); open; end ; loadreggrid(dxdbgrid1,true,caption+'1'); t_ch_pay.open ; t_ch_accept.open ; t_op_gain_main.Open ; t_op_gain.Open ; end; procedure Tfrm_cw_prnFee.DBEdit1Change(Sender: TObject); begin if (DBEdit1.Text='拼箱主票')then Panel9.Visible:=true else Panel9.Visible:=false; end; procedure Tfrm_cw_prnFee.DBGridEh1GetCellParams(Sender: TObject; Column: TColumnEh; AFont: TFont; var Background: TColor; State: TGridDrawState); begin if frm_data_share.t_code_fee_color.Locate('费用状态',t_ch_accept.FieldByName('费用状态').asstring,[])then begin try Background:=StringToColor(frm_data_share.t_code_fee_color.fieldbyname('颜色').asstring); except Background:=clwhite; end; end else Background:=clwhite; end; procedure Tfrm_cw_prnFee.DBGridEh2GetCellParams(Sender: TObject; Column: TColumnEh; AFont: TFont; var Background: TColor; State: TGridDrawState); begin if frm_data_share.t_code_fee_color.Locate('费用状态',t_ch_pay.FieldByName('费用状态').asstring,[])then begin try Background:=StringToColor(frm_data_share.t_code_fee_color.fieldbyname('颜色').asstring); except Background:=clwhite; end; end else Background:=clwhite; end; procedure Tfrm_cw_prnFee.N10Click(Sender: TObject); begin update_grid_view_no(dxdbgrid1); end; procedure Tfrm_cw_prnFee.N14Click(Sender: TObject); begin update_grid_view_all(dxdbgrid1); end; procedure Tfrm_cw_prnFee.N12Click(Sender: TObject); begin update_grid(dxdbgrid1,112); end; procedure Tfrm_cw_prnFee.N74Click(Sender: TObject); begin update_grid_sort(dxdbgrid1,112); end; procedure Tfrm_cw_prnFee.bsSkinButton4Click(Sender: TObject); var i:integer ; myNO:string ; begin if tv_bscard_all.IsEmpty then exit; if dxDBGrid1.SelectedCount<1 then begin showmessage('请选择要取消打印的业务帐单!!'); exit; end; myNO:=tv_bscard_all.fieldbyname('编号').AsString ; try tv_bscard_all.DisableControls; for i:=0 to dxDBGrid1.SelectedCount-1 do begin tv_bscard_all.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); if tv_bscard_all.FieldByName('是否打印').asboolean then updateprn(0); end ; finally tv_bscard_all.Requery(); tv_bscard_all.enableControls; tv_bscard_all.Locate('编号',myNO,[]) ; end ; end; procedure Tfrm_cw_prnFee.bsSkinButton11Click(Sender: TObject); begin PopupMenu1.Popup(mouse.CursorPos.X,mouse.CursorPos.Y); end; procedure Tfrm_cw_prnFee.updateprn(V_value: integer); var tblname:string ; myNo:String ; begin myNo:=tv_bscard_all.fieldbyname('编号').asstring ; tblname:='' ; if trim(tv_bscard_all.FieldByName('业务类型').asstring)='海运出口' then tblname:='t_op_seae' else if trim(tv_bscard_all.FieldByName('业务类型').asstring)='海运进口' then tblname:='t_op_seai' else if trim(tv_bscard_all.FieldByName('业务类型').asstring)='空运出口' then tblname:='t_op_aire' else if trim(tv_bscard_all.FieldByName('业务类型').asstring)='空运进口' then tblname:='t_op_airi' else if trim(tv_bscard_all.FieldByName('业务类型').asstring)='铁路运输' then tblname:='t_op_RailWay' else raise exception.Create('发生不可预知错误!') ; with qrytmp,sql do begin close ; clear ; add('update '+tblname+' set 是否打印= '+inttostr(V_value)); if strtobool(get_parameters_value(63,'false'))then add(' ,费用状态=''费用封帐'''); add('where 编号='''+tv_bscard_all.FieldByName('编号').asstring+''''); execsql ; end ; tv_bscard_all.Requery(); tv_bscard_all.Locate('编号',myNO,[]) ; end; procedure Tfrm_cw_prnFee.N1Click(Sender: TObject); var frt:string; begin updateprn(1); if tv_bscard_all.FieldByName('装运方式').AsString='拼箱主票' then begin t_pin_accept.close; t_pin_accept.Parameters[1].value:=tv_bscard_all.fieldbyname('编号').asstring; t_pin_accept.open; t_pin_pay.close; t_pin_pay.Parameters[1].value:=tv_bscard_all.fieldbyname('编号').asstring; t_pin_pay.open; t_pin_gain.close; t_pin_gain.Parameters[1].value:=tv_bscard_all.fieldbyname('编号').asstring; t_pin_gain.open; sys_print('主票核算单打印',1,tv_bscard_all1,nil,nil,nil, t_pin_accept1,t_pin_pay1,t_pin_gain1,t_op_gain_main1,nil,nil,nil); end else begin if strtobool(get_parameters_value(111,'false')) then begin memtblprint.close; memtblprint.Open; t_ch_accept.First; while not t_ch_accept.Eof do begin Frt:=GetFrt(t_ch_accept.FieldByName('客户名称').AsString); if memtblprint.Locate('Frt;ACCNAME;OBJDR',vararrayof([Frt,t_ch_accept.FieldByName('费用名称').asstring,t_ch_accept.FieldByName('客户名称').asstring]),[]) then begin memtblprint.Edit; if t_ch_accept.FieldByName('币别').AsString='USD' then begin memtblprint.FieldByName('USDDR').AsFloat:=memtblprint.FieldByName('USDDR').AsFloat+t_ch_accept.fieldByName('金额').AsFloat; memtblprint.FieldByName('TTLDR').AsFloat:=memtblprint.FieldByName('TTLDR').AsFloat+(t_ch_accept.fieldByName('金额').AsFloat*t_ch_accept.fieldByName('汇率').AsFloat); end else if t_ch_accept.FieldByName('币别').AsString='RMB' then begin memtblprint.FieldByName('RMBDR').AsFloat:=memtblprint.FieldByName('RMBDR').AsFloat+t_ch_accept.fieldByName('金额').AsFloat; memtblprint.FieldByName('TTLDR').AsFloat:=memtblprint.FieldByName('TTLDR').AsFloat+(t_ch_accept.fieldByName('金额').AsFloat*t_ch_accept.fieldByName('汇率').AsFloat); end else begin memtblprint.FieldByName('OTDR').AsFloat:=memtblprint.FieldByName('OTDR').AsFloat+t_ch_accept.fieldByName('金额').AsFloat; memtblprint.FieldByName('TTLDR').AsFloat:=memtblprint.FieldByName('TTLDR').AsFloat+(t_ch_accept.fieldByName('金额').AsFloat*t_ch_accept.fieldByName('汇率').AsFloat); end; if memtblprint.FieldByName('REMARKDR').AsString='' then begin memtblprint.FieldByName('REMARKDR').AsString:=t_ch_accept.fieldbyName('备注').AsString; end else begin memtblprint.FieldByName('REMARKDR').AsString:=memtblprint.FieldByName('REMARKDR').AsString+' '+t_ch_accept.fieldbyName('备注').AsString; end; memtblprint.Post; end else begin memtblprint.Insert; memtblprint.FieldByName('ORDNO').AsInteger:=0; memtblprint.FieldByName('FRT').AsString:=GetFrt(t_ch_accept.FieldByName('客户名称').AsString); memtblprint.FieldByName('ACCNAME').AsString:=t_ch_accept.FieldByName('费用名称').AsString; memtblprint.FieldByName('OBJDR').AsString:=t_ch_accept.FieldByName('客户名称').AsString; memtblprint.FieldByName('OBJCR').AsString:=''; memtblprint.FieldByName('REMARKCR').AsString:=''; memtblprint.FieldByName('USDCR').AsFloat:=0; memtblprint.FieldByName('RMBCR').AsFloat:=0; memtblprint.FieldByName('OTCR').AsFloat:=0; memtblprint.FieldByName('TTLCR').AsFloat:=0; memtblprint.FieldByName('DR').AsString:='T'; memtblprint.FieldByName('CR').AsString:='F'; if t_ch_accept.FieldByName('币别').AsString='USD' then begin memtblprint.FieldByName('USDDR').AsFloat:=t_ch_accept.fieldByName('金额').AsFloat; memtblprint.FieldByName('TTLDR').AsFloat:=(t_ch_accept.fieldByName('金额').AsFloat*t_ch_accept.fieldByName('汇率').AsFloat); end else if t_ch_accept.FieldByName('币别').AsString='RMB' then begin memtblprint.FieldByName('RMBDR').AsFloat:=t_ch_accept.fieldByName('金额').AsFloat; memtblprint.FieldByName('TTLDR').AsFloat:=(t_ch_accept.fieldByName('金额').AsFloat*t_ch_accept.fieldByName('汇率').AsFloat); end else begin memtblprint.FieldByName('OTDR').AsFloat:=t_ch_accept.fieldByName('金额').AsFloat; memtblprint.FieldByName('TTLDR').AsFloat:=(t_ch_accept.fieldByName('金额').AsFloat*t_ch_accept.fieldByName('汇率').AsFloat); end; memtblprint.FieldByName('REMARKDR').AsString:=memtblprint.FieldByName('REMARKDR').AsString+' '+t_ch_accept.fieldbyName('备注').AsString; memtblprint.Post; end; t_ch_accept.Next; end; t_ch_pay.First; while not t_ch_pay.Eof do begin Frt:=GetFrt(t_ch_pay.FieldByName('客户名称').AsString); if memtblprint.Locate('Frt;ACCNAME;CR',vararrayof([Frt,t_ch_pay.FieldByName('费用名称').asstring,'F']),[]) then begin memtblprint.Edit; memtblprint.FieldByName('OBJCR').AsString:=t_ch_pay.FieldByName('客户名称').AsString; if t_ch_pay.FieldByName('币别').AsString='USD' then begin memtblprint.FieldByName('USDCR').AsFloat:=memtblprint.FieldByName('USDCR').AsFloat+t_ch_pay.fieldByName('金额').AsFloat; memtblprint.FieldByName('TTLCR').AsFloat:=memtblprint.FieldByName('TTLCR').AsFloat+(t_ch_pay.fieldByName('金额').AsFloat*t_ch_pay.fieldByName('汇率').AsFloat); end else if t_ch_pay.FieldByName('币别').AsString='RMB' then begin memtblprint.FieldByName('RMBCR').AsFloat:=memtblprint.FieldByName('RMBCR').AsFloat+t_ch_pay.fieldByName('金额').AsFloat; memtblprint.FieldByName('TTLCR').AsFloat:=memtblprint.FieldByName('TTLCR').AsFloat+(t_ch_pay.fieldByName('金额').AsFloat*t_ch_pay.fieldByName('汇率').AsFloat); end else begin memtblprint.FieldByName('OTCR').AsFloat:=memtblprint.FieldByName('OTCR').AsFloat+t_ch_pay.fieldByName('金额').AsFloat; memtblprint.FieldByName('TTLCR').AsFloat:=memtblprint.FieldByName('TTLCR').AsFloat+(t_ch_pay.fieldByName('金额').AsFloat*t_ch_pay.fieldByName('汇率').AsFloat); end; if memtblprint.FieldByName('REMARKCR').AsString='' then begin memtblprint.FieldByName('REMARKCR').AsString:=t_ch_pay.fieldbyName('备注').AsString; end else begin memtblprint.FieldByName('REMARKCR').AsString:=memtblprint.FieldByName('REMARKCR').AsString+' '+t_ch_pay.fieldbyName('备注').AsString; end; memtblprint.FieldByName('CR').AsString:='T'; memtblprint.Post; end else begin if memtblprint.Locate('Frt;ACCNAME;OBJCR',vararrayof([Frt,t_ch_pay.FieldByName('费用名称').asstring,t_ch_pay.FieldByName('客户名称').asstring]),[]) then begin memtblprint.Edit; if t_ch_pay.FieldByName('币别').AsString='USD' then begin memtblprint.FieldByName('USDCR').AsFloat:=memtblprint.FieldByName('USDCR').AsFloat+t_ch_pay.fieldByName('金额').AsFloat; memtblprint.FieldByName('TTLCR').AsFloat:=memtblprint.FieldByName('TTLCR').AsFloat+(t_ch_pay.fieldByName('金额').AsFloat*t_ch_pay.fieldByName('汇率').AsFloat); end else if t_ch_pay.FieldByName('币别').AsString='RMB' then begin memtblprint.FieldByName('RMBCR').AsFloat:=memtblprint.FieldByName('RMBCR').AsFloat+t_ch_pay.fieldByName('金额').AsFloat; memtblprint.FieldByName('TTLCR').AsFloat:=memtblprint.FieldByName('TTLCR').AsFloat+(t_ch_pay.fieldByName('金额').AsFloat*t_ch_pay.fieldByName('汇率').AsFloat); end else begin memtblprint.FieldByName('OTCR').AsFloat:=memtblprint.FieldByName('OTCR').AsFloat+t_ch_pay.fieldByName('金额').AsFloat; memtblprint.FieldByName('TTLCR').AsFloat:=memtblprint.FieldByName('TTLCR').AsFloat+(t_ch_pay.fieldByName('金额').AsFloat*t_ch_pay.fieldByName('汇率').AsFloat); end; if memtblprint.FieldByName('REMARKCR').AsString='' then begin memtblprint.FieldByName('REMARKCR').AsString:=t_ch_pay.fieldbyName('备注').AsString; end else begin memtblprint.FieldByName('REMARKCR').AsString:=memtblprint.FieldByName('REMARKCR').AsString+' '+t_ch_pay.fieldbyName('备注').AsString; end; memtblprint.FieldByName('CR').AsString:='T'; memtblprint.Post; end else begin memtblprint.Insert; memtblprint.FieldByName('ORDNO').AsInteger:=0; memtblprint.FieldByName('FRT').AsString:=GetFrt(t_ch_pay.FieldByName('客户名称').AsString); memtblprint.FieldByName('ACCNAME').AsString:=t_ch_pay.FieldByName('费用名称').AsString; memtblprint.FieldByName('OBJCR').AsString:=t_ch_pay.FieldByName('客户名称').AsString; memtblprint.FieldByName('OBJDR').AsString:=''; memtblprint.FieldByName('REMARKCR').AsString:=''; memtblprint.FieldByName('USDDR').AsFloat:=0; memtblprint.FieldByName('RMBDR').AsFloat:=0; memtblprint.FieldByName('OTDR').AsFloat:=0; memtblprint.FieldByName('TTLDR').AsFloat:=0; memtblprint.FieldByName('DR').AsString:='F'; memtblprint.FieldByName('CR').AsString:='T'; if t_ch_pay.FieldByName('币别').AsString='USD' then begin memtblprint.FieldByName('USDCR').AsFloat:=t_ch_pay.fieldByName('金额').AsFloat; memtblprint.FieldByName('TTLCR').AsFloat:=(t_ch_pay.fieldByName('金额').AsFloat*t_ch_pay.fieldByName('汇率').AsFloat); end else if t_ch_pay.FieldByName('币别').AsString='RMB' then begin memtblprint.FieldByName('RMBCR').AsFloat:=t_ch_pay.fieldByName('金额').AsFloat; memtblprint.FieldByName('TTLCR').AsFloat:=(t_ch_pay.fieldByName('金额').AsFloat*t_ch_pay.fieldByName('汇率').AsFloat); end else begin memtblprint.FieldByName('OTCR').AsFloat:=t_ch_pay.fieldByName('金额').AsFloat; memtblprint.FieldByName('TTLCR').AsFloat:=(t_ch_pay.fieldByName('金额').AsFloat*t_ch_pay.fieldByName('汇率').AsFloat); end; memtblprint.FieldByName('REMARKCR').AsString:=memtblprint.FieldByName('REMARKCR').AsString+' '+t_ch_pay.fieldbyName('备注').AsString; memtblprint.Post; end; end; t_ch_pay.Next; end; memtblprint.SortOn('FRT;ACCNAME',[]); sys_print('核算单打印',1,tv_bscard_all1,nil,nil,nil, memtblprint1,nil,t_op_gain1,t_op_gain_main1,nil,nil,nil); end else begin sys_print('核算单打印',1,tv_bscard_all1,nil,nil,nil, t_ch_accept1,t_ch_pay1,t_op_gain1,t_op_gain_main1,nil,nil,nil); end; end; end; procedure Tfrm_cw_prnFee.N3Click(Sender: TObject); var Frt:String; begin updateprn(1); if tv_bscard_all.FieldByName('装运方式').AsString='拼箱主票' then begin t_pin_accept.close; t_pin_accept.Parameters[1].value:=tv_bscard_all.fieldbyname('编号').asstring; t_pin_accept.open; t_pin_pay.close; t_pin_pay.Parameters[1].value:=tv_bscard_all.fieldbyname('编号').asstring; t_pin_pay.open; t_pin_gain.close; t_pin_gain.Parameters[1].value:=tv_bscard_all.fieldbyname('编号').asstring; t_pin_gain.open; sys_print('主票核算单打印',3,tv_bscard_all1,nil,nil,nil, t_pin_accept1,t_pin_pay1,t_pin_gain1,t_op_gain_main1,nil,nil,nil); end else begin if strtobool(get_parameters_value(111,'false')) then begin memtblprint.close; memtblprint.Open; t_ch_accept.First; while not t_ch_accept.Eof do begin Frt:=GetFrt(t_ch_accept.FieldByName('客户名称').AsString); if memtblprint.Locate('Frt;ACCNAME;OBJDR',vararrayof([Frt,t_ch_accept.FieldByName('费用名称').asstring,t_ch_accept.FieldByName('客户名称').asstring]),[]) then begin memtblprint.Edit; if t_ch_accept.FieldByName('币别').AsString='USD' then begin memtblprint.FieldByName('USDDR').AsFloat:=memtblprint.FieldByName('USDDR').AsFloat+t_ch_accept.fieldByName('金额').AsFloat; memtblprint.FieldByName('TTLDR').AsFloat:=memtblprint.FieldByName('TTLDR').AsFloat+(t_ch_accept.fieldByName('金额').AsFloat*t_ch_accept.fieldByName('汇率').AsFloat); end else begin memtblprint.FieldByName('RMBDR').AsFloat:=memtblprint.FieldByName('RMBDR').AsFloat+t_ch_accept.fieldByName('金额').AsFloat; memtblprint.FieldByName('TTLDR').AsFloat:=memtblprint.FieldByName('TTLDR').AsFloat+(t_ch_accept.fieldByName('金额').AsFloat*t_ch_accept.fieldByName('汇率').AsFloat); end; if memtblprint.FieldByName('REMARKDR').AsString='' then begin memtblprint.FieldByName('REMARKDR').AsString:=t_ch_accept.fieldbyName('备注').AsString; end else begin memtblprint.FieldByName('REMARKDR').AsString:=memtblprint.FieldByName('REMARKDR').AsString+' '+t_ch_accept.fieldbyName('备注').AsString; end; memtblprint.Post; end else begin memtblprint.Insert; memtblprint.FieldByName('ORDNO').AsInteger:=0; memtblprint.FieldByName('FRT').AsString:=GetFrt(t_ch_accept.FieldByName('客户名称').AsString); memtblprint.FieldByName('ACCNAME').AsString:=t_ch_accept.FieldByName('费用名称').AsString; memtblprint.FieldByName('OBJDR').AsString:=t_ch_accept.FieldByName('客户名称').AsString; memtblprint.FieldByName('OBJCR').AsString:=''; memtblprint.FieldByName('REMARKCR').AsString:=''; memtblprint.FieldByName('USDCR').AsFloat:=0; memtblprint.FieldByName('RMBCR').AsFloat:=0; memtblprint.FieldByName('TTLCR').AsFloat:=0; memtblprint.FieldByName('DR').AsString:='T'; memtblprint.FieldByName('CR').AsString:='F'; if t_ch_accept.FieldByName('币别').AsString='USD' then begin memtblprint.FieldByName('USDDR').AsFloat:=t_ch_accept.fieldByName('金额').AsFloat; memtblprint.FieldByName('TTLDR').AsFloat:=(t_ch_accept.fieldByName('金额').AsFloat*t_ch_accept.fieldByName('汇率').AsFloat); end else begin memtblprint.FieldByName('RMBDR').AsFloat:=t_ch_accept.fieldByName('金额').AsFloat; memtblprint.FieldByName('TTLDR').AsFloat:=(t_ch_accept.fieldByName('金额').AsFloat*t_ch_accept.fieldByName('汇率').AsFloat); end; memtblprint.FieldByName('REMARKDR').AsString:=memtblprint.FieldByName('REMARKDR').AsString+' '+t_ch_accept.fieldbyName('备注').AsString; memtblprint.Post; end; t_ch_accept.Next; end; t_ch_pay.First; while not t_ch_pay.Eof do begin Frt:=GetFrt(t_ch_pay.FieldByName('客户名称').AsString); if memtblprint.Locate('Frt;ACCNAME;CR',vararrayof([Frt,t_ch_pay.FieldByName('费用名称').asstring,'F']),[]) then begin memtblprint.Edit; memtblprint.FieldByName('OBJCR').AsString:=t_ch_pay.FieldByName('客户名称').AsString; if t_ch_pay.FieldByName('币别').AsString='USD' then begin memtblprint.FieldByName('USDCR').AsFloat:=memtblprint.FieldByName('USDCR').AsFloat+t_ch_pay.fieldByName('金额').AsFloat; memtblprint.FieldByName('TTLCR').AsFloat:=memtblprint.FieldByName('TTLCR').AsFloat+(t_ch_pay.fieldByName('金额').AsFloat*t_ch_pay.fieldByName('汇率').AsFloat); end else begin memtblprint.FieldByName('RMBCR').AsFloat:=memtblprint.FieldByName('RMBCR').AsFloat+t_ch_pay.fieldByName('金额').AsFloat; memtblprint.FieldByName('TTLCR').AsFloat:=memtblprint.FieldByName('TTLCR').AsFloat+(t_ch_pay.fieldByName('金额').AsFloat*t_ch_pay.fieldByName('汇率').AsFloat); end; if memtblprint.FieldByName('REMARKCR').AsString='' then begin memtblprint.FieldByName('REMARKCR').AsString:=t_ch_pay.fieldbyName('备注').AsString; end else begin memtblprint.FieldByName('REMARKCR').AsString:=memtblprint.FieldByName('REMARKCR').AsString+' '+t_ch_pay.fieldbyName('备注').AsString; end; memtblprint.FieldByName('CR').AsString:='T'; memtblprint.Post; end else begin if memtblprint.Locate('Frt;ACCNAME;OBJCR',vararrayof([Frt,t_ch_pay.FieldByName('费用名称').asstring,t_ch_pay.FieldByName('客户名称').asstring]),[]) then begin memtblprint.Edit; if t_ch_pay.FieldByName('币别').AsString='USD' then begin memtblprint.FieldByName('USDCR').AsFloat:=memtblprint.FieldByName('USDCR').AsFloat+t_ch_pay.fieldByName('金额').AsFloat; memtblprint.FieldByName('TTLCR').AsFloat:=memtblprint.FieldByName('TTLCR').AsFloat+(t_ch_pay.fieldByName('金额').AsFloat*t_ch_pay.fieldByName('汇率').AsFloat); end else begin memtblprint.FieldByName('RMBCR').AsFloat:=memtblprint.FieldByName('RMBCR').AsFloat+t_ch_pay.fieldByName('金额').AsFloat; memtblprint.FieldByName('TTLCR').AsFloat:=memtblprint.FieldByName('TTLCR').AsFloat+(t_ch_pay.fieldByName('金额').AsFloat*t_ch_pay.fieldByName('汇率').AsFloat); end; if memtblprint.FieldByName('REMARKCR').AsString='' then begin memtblprint.FieldByName('REMARKCR').AsString:=t_ch_pay.fieldbyName('备注').AsString; end else begin memtblprint.FieldByName('REMARKCR').AsString:=memtblprint.FieldByName('REMARKCR').AsString+' '+t_ch_pay.fieldbyName('备注').AsString; end; memtblprint.FieldByName('CR').AsString:='T'; memtblprint.Post; end else begin memtblprint.Insert; memtblprint.FieldByName('ORDNO').AsInteger:=0; memtblprint.FieldByName('FRT').AsString:=GetFrt(t_ch_pay.FieldByName('客户名称').AsString); memtblprint.FieldByName('ACCNAME').AsString:=t_ch_pay.FieldByName('费用名称').AsString; memtblprint.FieldByName('OBJCR').AsString:=t_ch_pay.FieldByName('客户名称').AsString; memtblprint.FieldByName('OBJDR').AsString:=''; memtblprint.FieldByName('REMARKCR').AsString:=''; memtblprint.FieldByName('USDDR').AsFloat:=0; memtblprint.FieldByName('RMBDR').AsFloat:=0; memtblprint.FieldByName('TTLDR').AsFloat:=0; memtblprint.FieldByName('DR').AsString:='F'; memtblprint.FieldByName('CR').AsString:='T'; if t_ch_pay.FieldByName('币别').AsString='USD' then begin memtblprint.FieldByName('USDCR').AsFloat:=t_ch_pay.fieldByName('金额').AsFloat; memtblprint.FieldByName('TTLCR').AsFloat:=(t_ch_pay.fieldByName('金额').AsFloat*t_ch_pay.fieldByName('汇率').AsFloat); end else begin memtblprint.FieldByName('RMBCR').AsFloat:=t_ch_pay.fieldByName('金额').AsFloat; memtblprint.FieldByName('TTLCR').AsFloat:=(t_ch_pay.fieldByName('金额').AsFloat*t_ch_pay.fieldByName('汇率').AsFloat); end; memtblprint.FieldByName('REMARKCR').AsString:=memtblprint.FieldByName('REMARKCR').AsString+' '+t_ch_pay.fieldbyName('备注').AsString; memtblprint.Post; end; end; t_ch_pay.Next; end; memtblprint.SortOn('FRT;ACCNAME',[]); sys_print('核算单打印',3,tv_bscard_all1,nil,nil,nil, memtblprint1,nil,t_op_gain1,t_op_gain_main1,nil,nil,nil); end else begin sys_print('核算单打印',3,tv_bscard_all1,nil,nil,nil, t_ch_accept1,t_ch_pay1,t_op_gain1,t_op_gain_main1,nil,nil,nil); end; end; end; procedure Tfrm_cw_prnFee.N20Click(Sender: TObject); var Frt:String; i:Integer; begin updateprn(1); // showmessage(tv_bscard_all.FieldByName('装运方式').AsString); if tv_bscard_all.FieldByName('装运方式').AsString='拼箱主票' then begin t_pin_accept.close; t_pin_accept.Parameters[1].value:=tv_bscard_all.fieldbyname('编号').asstring; t_pin_accept.open; t_pin_pay.close; t_pin_pay.Parameters[1].value:=tv_bscard_all.fieldbyname('编号').asstring; t_pin_pay.open; t_pin_gain.close; t_pin_gain.Parameters[1].value:=tv_bscard_all.fieldbyname('编号').asstring; t_pin_gain.open; sys_print('主票核算单打印',2,tv_bscard_all1,nil,nil,nil, t_pin_accept1,t_pin_pay1,t_pin_gain1,t_op_gain_main1,nil,nil,nil); end else begin if strtobool(get_parameters_value(111,'false')) then begin frm_ch_piliang_prnfee:=tfrm_ch_piliang_prnfee.Create (self); tv_bscard_all.DisableControls; memtblprint.close; memtblprint.Open; memtblprint.EmptyTable; t_ch_accept.First; while not t_ch_accept.Eof do begin Frt:=GetFrt(t_ch_accept.FieldByName('客户名称').AsString); if memtblprint.Locate('Frt;ACCNAME;OBJDR',vararrayof([Frt,t_ch_accept.FieldByName('费用名称').asstring,t_ch_accept.FieldByName('客户名称').asstring]),[]) then begin memtblprint.Edit; if t_ch_accept.FieldByName('币别').AsString='USD' then begin memtblprint.FieldByName('USDDR').AsFloat:=memtblprint.FieldByName('USDDR').AsFloat+t_ch_accept.fieldByName('金额').AsFloat; memtblprint.FieldByName('TTLDR').AsFloat:=memtblprint.FieldByName('TTLDR').AsFloat+(t_ch_accept.fieldByName('金额').AsFloat*t_ch_accept.fieldByName('汇率').AsFloat); end else begin memtblprint.FieldByName('RMBDR').AsFloat:=memtblprint.FieldByName('RMBDR').AsFloat+t_ch_accept.fieldByName('金额').AsFloat; memtblprint.FieldByName('TTLDR').AsFloat:=memtblprint.FieldByName('TTLDR').AsFloat+(t_ch_accept.fieldByName('金额').AsFloat*t_ch_accept.fieldByName('汇率').AsFloat); end; if memtblprint.FieldByName('REMARKDR').AsString='' then begin memtblprint.FieldByName('REMARKDR').AsString:=t_ch_accept.fieldbyName('备注').AsString; end else begin memtblprint.FieldByName('REMARKDR').AsString:=memtblprint.FieldByName('REMARKDR').AsString+' '+t_ch_accept.fieldbyName('备注').AsString; end; memtblprint.Post; end else begin memtblprint.Insert; memtblprint.FieldByName('ORDNO').AsInteger:=0; memtblprint.FieldByName('FRT').AsString:=GetFrt(t_ch_accept.FieldByName('客户名称').AsString); memtblprint.FieldByName('ACCNAME').AsString:=t_ch_accept.FieldByName('费用名称').AsString; memtblprint.FieldByName('OBJDR').AsString:=t_ch_accept.FieldByName('客户名称').AsString; memtblprint.FieldByName('OBJCR').AsString:=''; memtblprint.FieldByName('REMARKCR').AsString:=''; memtblprint.FieldByName('USDCR').AsFloat:=0; memtblprint.FieldByName('RMBCR').AsFloat:=0; memtblprint.FieldByName('TTLCR').AsFloat:=0; memtblprint.FieldByName('DR').AsString:='T'; memtblprint.FieldByName('CR').AsString:='F'; if t_ch_accept.FieldByName('币别').AsString='USD' then begin memtblprint.FieldByName('USDDR').AsFloat:=t_ch_accept.fieldByName('金额').AsFloat; memtblprint.FieldByName('TTLDR').AsFloat:=(t_ch_accept.fieldByName('金额').AsFloat*t_ch_accept.fieldByName('汇率').AsFloat); end else begin memtblprint.FieldByName('RMBDR').AsFloat:=t_ch_accept.fieldByName('金额').AsFloat; memtblprint.FieldByName('TTLDR').AsFloat:=(t_ch_accept.fieldByName('金额').AsFloat*t_ch_accept.fieldByName('汇率').AsFloat); end; memtblprint.FieldByName('REMARKDR').AsString:=memtblprint.FieldByName('REMARKDR').AsString+' '+t_ch_accept.fieldbyName('备注').AsString; memtblprint.Post; end; t_ch_accept.Next; end; t_ch_pay.First; while not t_ch_pay.Eof do begin Frt:=GetFrt(t_ch_pay.FieldByName('客户名称').AsString); if memtblprint.Locate('Frt;ACCNAME;CR',vararrayof([Frt,t_ch_pay.FieldByName('费用名称').asstring,'F']),[]) then begin memtblprint.Edit; memtblprint.FieldByName('OBJCR').AsString:=t_ch_pay.FieldByName('客户名称').AsString; if t_ch_pay.FieldByName('币别').AsString='USD' then begin memtblprint.FieldByName('USDCR').AsFloat:=memtblprint.FieldByName('USDCR').AsFloat+t_ch_pay.fieldByName('金额').AsFloat; memtblprint.FieldByName('TTLCR').AsFloat:=memtblprint.FieldByName('TTLCR').AsFloat+(t_ch_pay.fieldByName('金额').AsFloat*t_ch_pay.fieldByName('汇率').AsFloat); end else begin memtblprint.FieldByName('RMBCR').AsFloat:=memtblprint.FieldByName('RMBCR').AsFloat+t_ch_pay.fieldByName('金额').AsFloat; memtblprint.FieldByName('TTLCR').AsFloat:=memtblprint.FieldByName('TTLCR').AsFloat+(t_ch_pay.fieldByName('金额').AsFloat*t_ch_pay.fieldByName('汇率').AsFloat); end; if memtblprint.FieldByName('REMARKCR').AsString='' then begin memtblprint.FieldByName('REMARKCR').AsString:=t_ch_pay.fieldbyName('备注').AsString; end else begin memtblprint.FieldByName('REMARKCR').AsString:=memtblprint.FieldByName('REMARKCR').AsString+' '+t_ch_pay.fieldbyName('备注').AsString; end; memtblprint.FieldByName('CR').AsString:='T'; memtblprint.Post; end else begin if memtblprint.Locate('Frt;ACCNAME;OBJCR',vararrayof([Frt,t_ch_pay.FieldByName('费用名称').asstring,t_ch_pay.FieldByName('客户名称').asstring]),[]) then begin memtblprint.Edit; if t_ch_pay.FieldByName('币别').AsString='USD' then begin memtblprint.FieldByName('USDCR').AsFloat:=memtblprint.FieldByName('USDCR').AsFloat+t_ch_pay.fieldByName('金额').AsFloat; memtblprint.FieldByName('TTLCR').AsFloat:=memtblprint.FieldByName('TTLCR').AsFloat+(t_ch_pay.fieldByName('金额').AsFloat*t_ch_pay.fieldByName('汇率').AsFloat); end else begin memtblprint.FieldByName('RMBCR').AsFloat:=memtblprint.FieldByName('RMBCR').AsFloat+t_ch_pay.fieldByName('金额').AsFloat; memtblprint.FieldByName('TTLCR').AsFloat:=memtblprint.FieldByName('TTLCR').AsFloat+(t_ch_pay.fieldByName('金额').AsFloat*t_ch_pay.fieldByName('汇率').AsFloat); end; if memtblprint.FieldByName('REMARKCR').AsString='' then begin memtblprint.FieldByName('REMARKCR').AsString:=t_ch_pay.fieldbyName('备注').AsString; end else begin memtblprint.FieldByName('REMARKCR').AsString:=memtblprint.FieldByName('REMARKCR').AsString+' '+t_ch_pay.fieldbyName('备注').AsString; end; memtblprint.FieldByName('CR').AsString:='T'; memtblprint.Post; end else begin memtblprint.Insert; memtblprint.FieldByName('ORDNO').AsInteger:=0; memtblprint.FieldByName('FRT').AsString:=GetFrt(t_ch_pay.FieldByName('客户名称').AsString); memtblprint.FieldByName('ACCNAME').AsString:=t_ch_pay.FieldByName('费用名称').AsString; memtblprint.FieldByName('OBJCR').AsString:=t_ch_pay.FieldByName('客户名称').AsString; memtblprint.FieldByName('OBJDR').AsString:=''; memtblprint.FieldByName('REMARKCR').AsString:=''; memtblprint.FieldByName('USDDR').AsFloat:=0; memtblprint.FieldByName('RMBDR').AsFloat:=0; memtblprint.FieldByName('TTLDR').AsFloat:=0; memtblprint.FieldByName('DR').AsString:='F'; memtblprint.FieldByName('CR').AsString:='T'; if t_ch_pay.FieldByName('币别').AsString='USD' then begin memtblprint.FieldByName('USDCR').AsFloat:=t_ch_pay.fieldByName('金额').AsFloat; memtblprint.FieldByName('TTLCR').AsFloat:=(t_ch_pay.fieldByName('金额').AsFloat*t_ch_pay.fieldByName('汇率').AsFloat); end else begin memtblprint.FieldByName('RMBCR').AsFloat:=t_ch_pay.fieldByName('金额').AsFloat; memtblprint.FieldByName('TTLCR').AsFloat:=(t_ch_pay.fieldByName('金额').AsFloat*t_ch_pay.fieldByName('汇率').AsFloat); end; memtblprint.FieldByName('REMARKCR').AsString:=memtblprint.FieldByName('REMARKCR').AsString+' '+t_ch_pay.fieldbyName('备注').AsString; memtblprint.Post; end; end; t_ch_pay.Next; end; memtblprint.SortOn('FRT;ACCNAME',[]); sys_print('核算单打印',2,tv_bscard_all1,nil,nil,nil, memtblprint1,nil,t_op_gain1,t_op_gain_main1,nil,nil,nil); tv_bscard_all.EnableControls; end else begin sys_print('核算单打印',2,tv_bscard_all1,nil,nil,nil, t_ch_accept1,t_ch_pay1,t_op_gain1,t_op_gain_main1,nil,nil,nil); end; end; end; procedure Tfrm_cw_prnFee.bsSkinButton10Click(Sender: TObject); begin frm_ch_prnfee_query:=Tfrm_ch_prnfee_query.create(self); if frm_ch_prnfee_query.showmodal=mrok then begin with tv_bscard_all,sql do begin close ; clear ; add('select * from V_op_bscard_All '); add(frm_ch_prnfee_query.getprnstr); add(' order by 编号 '); open ; end ; end ; frm_ch_prnfee_query.free ; end; procedure Tfrm_cw_prnFee.N6Click(Sender: TObject); var str:widestring; i:integer; myNO:string ; begin if tv_bscard_all.IsEmpty then exit; if dxDBGrid1.SelectedCount<1 then begin showmessage('请选择要打印的业务帐单!!'); exit; end; str:='' ; myNO:=tv_bscard_all.fieldbyname('编号').AsString ; try frm_ch_piliang_prnfee:=tfrm_ch_piliang_prnfee.Create (self); tv_bscard_all.DisableControls; for i:=0 to dxDBGrid1.SelectedCount-1 do begin tv_bscard_all.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); if (not tv_bscard_all.FieldByName('是否打印').asboolean) and (tv_bscard_all.FieldByName('装运方式').AsString<>'拼箱主票') then begin if str='' then str:=''''+tv_bscard_all.fieldbyname('编号').AsString+'''' else str:=str+','+''''+tv_bscard_all.fieldbyname('编号').AsString+''''; end ; end; if str<>'' then begin str:='('+str+')'; str:='select * from V_op_bscard_All where 编号 in '+str+default_sort(53,'V_op_bscard_All','','desc'); frm_ch_piliang_prnfee.tv_bscard_all.Parameters.ParamByName('SQLStr').value:=str; frm_ch_piliang_prnfee.tv_bscard_all.open; frm_ch_piliang_prnfee.ShowModal; tv_bscard_all.Requery(); tv_bscard_all.Locate('编号',myNO,[]) ; end; finally tv_bscard_all.EnableControls; frm_ch_piliang_prnfee.Free; frm_ch_piliang_prnfee:=nil; end; end; procedure Tfrm_cw_prnFee.N8Click(Sender: TObject); var str:widestring; i:integer; myNO:string ; begin if tv_bscard_all.IsEmpty then exit; if dxDBGrid1.SelectedCount<1 then begin showmessage('请选择要打印的业务帐单!!'); exit; end; str:='' ; myNO:=tv_bscard_all.fieldbyname('编号').AsString ; try frm_ch_piliang_zhuprnfee:=tfrm_ch_piliang_zhuprnfee.Create (self); tv_bscard_all.DisableControls; for i:=0 to dxDBGrid1.SelectedCount-1 do begin tv_bscard_all.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); if (not tv_bscard_all.FieldByName('是否打印').asboolean) and (tv_bscard_all.FieldByName('装运方式').AsString='拼箱主票') then begin if str='' then str:=''''+tv_bscard_all.fieldbyname('编号').AsString+'''' else str:=str+','+''''+tv_bscard_all.fieldbyname('编号').AsString+''''; end ; end; str:='('+str+')'; str:='select * from V_op_bscard_All where 编号 in '+str+default_sort(53,'V_op_bscard_All','','desc'); //showmessage(str); frm_ch_piliang_zhuprnfee.tv_bscard_all.Parameters.ParamByName('SQLStr').value:=str; frm_ch_piliang_zhuprnfee.tv_bscard_all.open; frm_ch_piliang_zhuprnfee.ShowModal; tv_bscard_all.Requery(); tv_bscard_all.Locate('编号',myNO,[]) ; finally tv_bscard_all.EnableControls; frm_ch_piliang_prnfee.Free; frm_ch_piliang_prnfee:=nil; end; end; procedure Tfrm_cw_prnFee.N16Click(Sender: TObject); var Frt:String; i,ordNO:Integer; aQueryaccept:TADOQuery; aQuerypay:TADOQuery; begin tv_bscard_all.DisableControls; memtblprintFee.close; memtblprintFee.Open; memtblprintFee.EmptyTable; ordNO:=1; for i:=0 to dxDBGrid1.SelectedCount-1 do begin tv_bscard_all.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); updateprn(1); aQueryaccept:=CreateAdoQuery; aQuerypay:=CreateAdoQuery; try aQueryaccept.Close;aQueryaccept.sql.Clear; aQueryaccept.sql.Text:='select * from t_ch_fee where 类型=''收'' and 编号='''+tv_bscard_all.fieldbyname('编号').asstring+''' order by CH_ID'; aQueryaccept.Open; aQuerypay.Close;aQuerypay.sql.Clear; aQuerypay.sql.Text:='select * from t_ch_fee where 类型=''付'' and 编号='''+tv_bscard_all.fieldbyname('编号').asstring+''' order by CH_ID'; aQuerypay.Open; aQueryaccept.First; while not aQueryaccept.Eof do begin Frt:=GetFrt(aQueryaccept.FieldByName('客户名称').AsString); if memtblprintFee.Locate('编号;ACCNAME;OBJDR',vararrayof([tv_bscard_all.fieldbyname('编号').asstring,trim(aQueryaccept.FieldByName('费用名称').asstring),trim(aQueryaccept.FieldByName('客户名称').asstring)]),[]) then begin memtblprintFee.Edit; if aQueryaccept.FieldByName('币别').AsString='USD' then begin memtblprintFee.FieldByName('USDDR').AsFloat:=memtblprintFee.FieldByName('USDDR').AsFloat+aQueryaccept.fieldByName('金额').AsFloat; memtblprintFee.FieldByName('TTLDR').AsFloat:=memtblprintFee.FieldByName('TTLDR').AsFloat+(aQueryaccept.fieldByName('金额').AsFloat*aQueryaccept.fieldByName('汇率').AsFloat); end else if aQueryaccept.FieldByName('币别').AsString='RMB' then begin memtblprintFee.FieldByName('RMBDR').AsFloat:=memtblprintFee.FieldByName('RMBDR').AsFloat+aQueryaccept.fieldByName('金额').AsFloat; memtblprintFee.FieldByName('TTLDR').AsFloat:=memtblprintFee.FieldByName('TTLDR').AsFloat+(aQueryaccept.fieldByName('金额').AsFloat*aQueryaccept.fieldByName('汇率').AsFloat); end else begin memtblprintFee.FieldByName('OTDR').AsFloat:=memtblprintFee.FieldByName('OTDR').AsFloat+aQueryaccept.fieldByName('金额').AsFloat; memtblprintFee.FieldByName('TTLDR').AsFloat:=memtblprintFee.FieldByName('TTLDR').AsFloat+(aQueryaccept.fieldByName('金额').AsFloat*aQueryaccept.fieldByName('汇率').AsFloat); end; if memtblprintFee.FieldByName('REMARKDR').AsString='' then begin memtblprintFee.FieldByName('REMARKDR').AsString:=aQueryaccept.fieldbyName('备注').AsString; end else begin memtblprintFee.FieldByName('REMARKDR').AsString:=memtblprintFee.FieldByName('REMARKDR').AsString+' '+aQueryaccept.fieldbyName('备注').AsString; end; memtblprintFee.Post; end else begin ordNO:=ordNO+1; memtblprintFee.Append; memtblprintFee.FieldByName('ORDNO').AsInteger:=ordNO; memtblprintFee.FieldByName('编号').AsString:=tv_bscard_all.fieldbyname('编号').asstring; memtblprintFee.FieldByName('FRT').AsString:=GetFrt(aQueryaccept.FieldByName('客户名称').AsString); memtblprintFee.FieldByName('ACCNAME').AsString:=aQueryaccept.FieldByName('费用名称').AsString; memtblprintFee.FieldByName('OBJDR').AsString:=trim(aQueryaccept.FieldByName('客户名称').AsString); memtblprintFee.FieldByName('OBJCR').AsString:=''; memtblprintFee.FieldByName('REMARKCR').AsString:=''; memtblprintFee.FieldByName('USDCR').AsFloat:=0; memtblprintFee.FieldByName('RMBCR').AsFloat:=0; memtblprintFee.FieldByName('OTCR').AsFloat:=0; memtblprintFee.FieldByName('TTLCR').AsFloat:=0; memtblprintFee.FieldByName('DR').AsString:='T'; memtblprintFee.FieldByName('CR').AsString:='F'; if aQueryaccept.FieldByName('币别').AsString='USD' then begin memtblprintFee.FieldByName('USDDR').AsFloat:=aQueryaccept.fieldByName('金额').AsFloat; memtblprintFee.FieldByName('TTLDR').AsFloat:=(aQueryaccept.fieldByName('金额').AsFloat*aQueryaccept.fieldByName('汇率').AsFloat); end else if aQueryaccept.FieldByName('币别').AsString='RMB' then begin memtblprintFee.FieldByName('RMBDR').AsFloat:=aQueryaccept.fieldByName('金额').AsFloat; memtblprintFee.FieldByName('TTLDR').AsFloat:=(aQueryaccept.fieldByName('金额').AsFloat*aQueryaccept.fieldByName('汇率').AsFloat); end else begin memtblprintFee.FieldByName('OTDR').AsFloat:=aQueryaccept.fieldByName('金额').AsFloat; memtblprintFee.FieldByName('TTLDR').AsFloat:=(aQueryaccept.fieldByName('金额').AsFloat*aQueryaccept.fieldByName('汇率').AsFloat); end; memtblprintFee.FieldByName('REMARKDR').AsString:=memtblprintFee.FieldByName('REMARKDR').AsString+' '+aQueryaccept.fieldbyName('备注').AsString; memtblprintFee.FieldByName('船名').AsString:=tv_bscard_all.fieldbyname('船名').asstring; memtblprintFee.FieldByName('航次').AsString:=tv_bscard_all.fieldbyname('航次').asstring; memtblprintFee.FieldByName('主提单号').AsString:=tv_bscard_all.fieldbyname('主提单号').asstring; memtblprintFee.FieldByName('委托编号').AsString:=tv_bscard_all.fieldbyname('委托编号').asstring; memtblprintFee.FieldByName('业务编号').AsString:=tv_bscard_all.fieldbyname('业务编号').asstring; memtblprintFee.FieldByName('卸货港').AsString:=tv_bscard_all.fieldbyname('卸货港').asstring; memtblprintFee.FieldByName('装货港').AsString:=tv_bscard_all.fieldbyname('装货港').asstring; memtblprintFee.FieldByName('开船日期').AsString:=tv_bscard_all.fieldbyname('开船日期').asstring; memtblprintFee.FieldByName('集装箱').AsString:=tv_bscard_all.fieldbyname('集装箱').asstring; memtblprintFee.FieldByName('揽货人').AsString:=tv_bscard_all.fieldbyname('揽货人').asstring; memtblprintFee.FieldByName('操作员').AsString:=tv_bscard_all.fieldbyname('操作员').asstring; memtblprintFee.FieldByName('委托单位').AsString:=tv_bscard_all.fieldbyname('委托单位').asstring; memtblprintFee.FieldByName('预抵日期').AsString:=tv_bscard_all.fieldbyname('预抵日期').asstring; memtblprintFee.FieldByName('付费方式').AsString:=tv_bscard_all.fieldbyname('付费方式').asstring; memtblprintFee.FieldByName('件数').AsString:=tv_bscard_all.fieldbyname('件数').asstring; memtblprintFee.FieldByName('重量').AsString:=tv_bscard_all.fieldbyname('重量').asstring; memtblprintFee.FieldByName('尺码').AsString:=tv_bscard_all.fieldbyname('尺码').asstring; memtblprintFee.FieldByName('包装').AsString:=tv_bscard_all.fieldbyname('包装').asstring; memtblprintFee.Post; end; aQueryaccept.Next; end; aQuerypay.First; while not aQuerypay.Eof do begin Frt:=GetFrt(aQuerypay.FieldByName('客户名称').AsString); if memtblprintFee.Locate('编号;ACCNAME;CR',vararrayof([tv_bscard_all.fieldbyname('编号').asstring,aQuerypay.FieldByName('费用名称').asstring,'F']),[]) then begin memtblprintFee.Edit; memtblprintFee.FieldByName('OBJCR').AsString:=trim(aQuerypay.FieldByName('客户名称').AsString); if aQuerypay.FieldByName('币别').AsString='USD' then begin memtblprintFee.FieldByName('USDCR').AsFloat:=memtblprintFee.FieldByName('USDCR').AsFloat+aQuerypay.fieldByName('金额').AsFloat; memtblprintFee.FieldByName('TTLCR').AsFloat:=memtblprintFee.FieldByName('TTLCR').AsFloat+(aQuerypay.fieldByName('金额').AsFloat*aQuerypay.fieldByName('汇率').AsFloat); end else if aQuerypay.FieldByName('币别').AsString='RMB' then begin memtblprintFee.FieldByName('RMBCR').AsFloat:=memtblprintFee.FieldByName('RMBCR').AsFloat+aQuerypay.fieldByName('金额').AsFloat; memtblprintFee.FieldByName('TTLCR').AsFloat:=memtblprintFee.FieldByName('TTLCR').AsFloat+(aQuerypay.fieldByName('金额').AsFloat*aQuerypay.fieldByName('汇率').AsFloat); end else begin memtblprintFee.FieldByName('OTCR').AsFloat:=memtblprintFee.FieldByName('OTCR').AsFloat+aQuerypay.fieldByName('金额').AsFloat; memtblprintFee.FieldByName('TTLCR').AsFloat:=memtblprintFee.FieldByName('TTLCR').AsFloat+(aQuerypay.fieldByName('金额').AsFloat*aQuerypay.fieldByName('汇率').AsFloat); end; if memtblprintFee.FieldByName('REMARKCR').AsString='' then begin memtblprintFee.FieldByName('REMARKCR').AsString:=aQuerypay.fieldbyName('备注').AsString; end else begin memtblprintFee.FieldByName('REMARKCR').AsString:=memtblprintFee.FieldByName('REMARKCR').AsString+' '+aQuerypay.fieldbyName('备注').AsString; end; memtblprintFee.FieldByName('CR').AsString:='T'; memtblprintFee.FieldByName('编号').AsString:=tv_bscard_all.fieldbyname('编号').asstring; memtblprintFee.Post; end else begin if memtblprintFee.Locate('编号;ACCNAME;OBJCR',vararrayof([tv_bscard_all.fieldbyname('编号').asstring,aQuerypay.FieldByName('费用名称').asstring,trim(aQuerypay.FieldByName('客户名称').asstring)]),[]) then begin memtblprintFee.Edit; if aQuerypay.FieldByName('币别').AsString='USD' then begin memtblprintFee.FieldByName('USDCR').AsFloat:=memtblprintFee.FieldByName('USDCR').AsFloat+aQuerypay.fieldByName('金额').AsFloat; memtblprintFee.FieldByName('TTLCR').AsFloat:=memtblprintFee.FieldByName('TTLCR').AsFloat+(aQuerypay.fieldByName('金额').AsFloat*aQuerypay.fieldByName('汇率').AsFloat); end else if aQuerypay.FieldByName('币别').AsString='RMB' then begin memtblprintFee.FieldByName('RMBCR').AsFloat:=memtblprintFee.FieldByName('RMBCR').AsFloat+aQuerypay.fieldByName('金额').AsFloat; memtblprintFee.FieldByName('TTLCR').AsFloat:=memtblprintFee.FieldByName('TTLCR').AsFloat+(aQuerypay.fieldByName('金额').AsFloat*aQuerypay.fieldByName('汇率').AsFloat); end else begin memtblprintFee.FieldByName('OTCR').AsFloat:=memtblprintFee.FieldByName('OTCR').AsFloat+aQuerypay.fieldByName('金额').AsFloat; memtblprintFee.FieldByName('TTLCR').AsFloat:=memtblprintFee.FieldByName('TTLCR').AsFloat+(aQuerypay.fieldByName('金额').AsFloat*aQuerypay.fieldByName('汇率').AsFloat); end; if memtblprintFee.FieldByName('REMARKCR').AsString='' then begin memtblprintFee.FieldByName('REMARKCR').AsString:=aQuerypay.fieldbyName('备注').AsString; end else begin memtblprintFee.FieldByName('REMARKCR').AsString:=memtblprintFee.FieldByName('REMARKCR').AsString+' '+aQuerypay.fieldbyName('备注').AsString; end; memtblprintFee.FieldByName('CR').AsString:='T'; memtblprintFee.FieldByName('编号').AsString:=tv_bscard_all.fieldbyname('编号').asstring; memtblprintFee.Post; end else begin ordNO:=ordNO+1; memtblprintFee.Append; memtblprintFee.FieldByName('ORDNO').AsInteger:=ordNO; memtblprintFee.FieldByName('FRT').AsString:=GetFrt(aQuerypay.FieldByName('客户名称').AsString); memtblprintFee.FieldByName('编号').AsString:=tv_bscard_all.fieldbyname('编号').asstring; memtblprintFee.FieldByName('ACCNAME').AsString:=aQuerypay.FieldByName('费用名称').AsString; memtblprintFee.FieldByName('OBJCR').AsString:=aQuerypay.FieldByName('客户名称').AsString; memtblprintFee.FieldByName('OBJDR').AsString:=''; memtblprintFee.FieldByName('REMARKCR').AsString:=''; memtblprintFee.FieldByName('USDDR').AsFloat:=0; memtblprintFee.FieldByName('RMBDR').AsFloat:=0; memtblprintFee.FieldByName('OTDR').AsFloat:=0; memtblprintFee.FieldByName('TTLDR').AsFloat:=0; memtblprintFee.FieldByName('DR').AsString:='F'; memtblprintFee.FieldByName('CR').AsString:='T'; if aQuerypay.FieldByName('币别').AsString='USD' then begin memtblprintFee.FieldByName('USDCR').AsFloat:=aQuerypay.fieldByName('金额').AsFloat; memtblprintFee.FieldByName('TTLCR').AsFloat:=(aQuerypay.fieldByName('金额').AsFloat*aQuerypay.fieldByName('汇率').AsFloat); end else if aQuerypay.FieldByName('币别').AsString='RMB' then begin memtblprintFee.FieldByName('RMBCR').AsFloat:=aQuerypay.fieldByName('金额').AsFloat; memtblprintFee.FieldByName('TTLCR').AsFloat:=(aQuerypay.fieldByName('金额').AsFloat*aQuerypay.fieldByName('汇率').AsFloat); end else begin memtblprintFee.FieldByName('OTCR').AsFloat:=aQuerypay.fieldByName('金额').AsFloat; memtblprintFee.FieldByName('TTLCR').AsFloat:=(aQuerypay.fieldByName('金额').AsFloat*aQuerypay.fieldByName('汇率').AsFloat); end; memtblprintFee.FieldByName('REMARKCR').AsString:=memtblprintFee.FieldByName('REMARKCR').AsString+' '+aQuerypay.fieldbyName('备注').AsString; memtblprintFee.FieldByName('船名').AsString:=tv_bscard_all.fieldbyname('船名').asstring; memtblprintFee.FieldByName('航次').AsString:=tv_bscard_all.fieldbyname('航次').asstring; memtblprintFee.FieldByName('主提单号').AsString:=tv_bscard_all.fieldbyname('主提单号').asstring; memtblprintFee.FieldByName('委托编号').AsString:=tv_bscard_all.fieldbyname('委托编号').asstring; memtblprintFee.FieldByName('业务编号').AsString:=tv_bscard_all.fieldbyname('业务编号').asstring; memtblprintFee.FieldByName('卸货港').AsString:=tv_bscard_all.fieldbyname('卸货港').asstring; memtblprintFee.FieldByName('装货港').AsString:=tv_bscard_all.fieldbyname('装货港').asstring; memtblprintFee.FieldByName('开船日期').AsString:=tv_bscard_all.fieldbyname('开船日期').asstring; memtblprintFee.FieldByName('集装箱').AsString:=tv_bscard_all.fieldbyname('集装箱').asstring; memtblprintFee.FieldByName('揽货人').AsString:=tv_bscard_all.fieldbyname('揽货人').asstring; memtblprintFee.FieldByName('操作员').AsString:=tv_bscard_all.fieldbyname('操作员').asstring; memtblprintFee.FieldByName('委托单位').AsString:=tv_bscard_all.fieldbyname('委托单位').asstring; memtblprintFee.FieldByName('预抵日期').AsString:=tv_bscard_all.fieldbyname('预抵日期').asstring; memtblprintFee.FieldByName('付费方式').AsString:=tv_bscard_all.fieldbyname('付费方式').asstring; memtblprintFee.FieldByName('件数').AsString:=tv_bscard_all.fieldbyname('件数').asstring; memtblprintFee.FieldByName('重量').AsString:=tv_bscard_all.fieldbyname('重量').asstring; memtblprintFee.FieldByName('尺码').AsString:=tv_bscard_all.fieldbyname('尺码').asstring; memtblprintFee.FieldByName('包装').AsString:=tv_bscard_all.fieldbyname('包装').asstring; memtblprintFee.Post; end; end; aQuerypay.Next; end; finally aQueryaccept.Free; aQuerypay.Free; end; end; memtblprintFee.SortOn('编号;ordNO;FRT;ACCNAME',[]); sys_print('核算单打印',2,tv_bscard_all1,nil,nil,nil,memtblprintFee1,nil,t_op_gain1,t_op_gain_main1,nil,nil,nil); tv_bscard_all.EnableControls; end; {procedure Tfrm_cw_prnFee.N16Click(Sender: TObject); var Frt:String; i,ordNO:Integer; aQueryaccept:TADOQuery; aQuerypay:TADOQuery; begin tv_bscard_all.DisableControls; memtblprintFee.close; memtblprintFee.Open; memtblprintFee.EmptyTable; ordNO:=1; for i:=0 to dxDBGrid1.SelectedCount-1 do begin tv_bscard_all.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); aQueryaccept:=CreateAdoQuery; aQuerypay:=CreateAdoQuery; try aQueryaccept.Close;aQueryaccept.sql.Clear; aQueryaccept.sql.Text:='select * from t_ch_fee where 类型=''收'' and 编号='''+tv_bscard_all.fieldbyname('编号').asstring+''' order by CH_ID'; aQueryaccept.Open; aQuerypay.Close;aQuerypay.sql.Clear; aQuerypay.sql.Text:='select * from t_ch_fee where 类型=''付'' and 编号='''+tv_bscard_all.fieldbyname('编号').asstring+''' order by CH_ID'; aQuerypay.Open; aQueryaccept.First; while not aQueryaccept.Eof do begin Frt:=GetFrt(aQueryaccept.FieldByName('客户名称').AsString); if memtblprintFee.Locate('编号;Frt;ACCNAME;OBJDR',vararrayof([tv_bscard_all.fieldbyname('编号').asstring,Frt,trim(aQueryaccept.FieldByName('费用名称').asstring),trim(aQueryaccept.FieldByName('客户名称').asstring)]),[]) then begin memtblprintFee.Edit; if aQueryaccept.FieldByName('币别').AsString='USD' then begin memtblprintFee.FieldByName('USDDR').AsFloat:=memtblprintFee.FieldByName('USDDR').AsFloat+aQueryaccept.fieldByName('金额').AsFloat; memtblprintFee.FieldByName('TTLDR').AsFloat:=memtblprintFee.FieldByName('TTLDR').AsFloat+(aQueryaccept.fieldByName('金额').AsFloat*aQueryaccept.fieldByName('汇率').AsFloat); end else if aQueryaccept.FieldByName('币别').AsString='RMB' then begin memtblprintFee.FieldByName('RMBDR').AsFloat:=memtblprintFee.FieldByName('RMBDR').AsFloat+aQueryaccept.fieldByName('金额').AsFloat; memtblprintFee.FieldByName('TTLDR').AsFloat:=memtblprintFee.FieldByName('TTLDR').AsFloat+(aQueryaccept.fieldByName('金额').AsFloat*aQueryaccept.fieldByName('汇率').AsFloat); end else begin memtblprintFee.FieldByName('OTDR').AsFloat:=memtblprintFee.FieldByName('OTDR').AsFloat+aQueryaccept.fieldByName('金额').AsFloat; memtblprintFee.FieldByName('TTLDR').AsFloat:=memtblprintFee.FieldByName('TTLDR').AsFloat+(aQueryaccept.fieldByName('金额').AsFloat*aQueryaccept.fieldByName('汇率').AsFloat); end; if memtblprintFee.FieldByName('REMARKDR').AsString='' then begin memtblprintFee.FieldByName('REMARKDR').AsString:=aQueryaccept.fieldbyName('备注').AsString; end else begin memtblprintFee.FieldByName('REMARKDR').AsString:=memtblprintFee.FieldByName('REMARKDR').AsString+' '+aQueryaccept.fieldbyName('备注').AsString; end; memtblprintFee.Post; end else begin ordNO:=ordNO+1; memtblprintFee.Append; memtblprintFee.FieldByName('ORDNO').AsInteger:=ordNO; memtblprintFee.FieldByName('编号').AsString:=tv_bscard_all.fieldbyname('编号').asstring; memtblprintFee.FieldByName('FRT').AsString:=GetFrt(aQueryaccept.FieldByName('客户名称').AsString); memtblprintFee.FieldByName('ACCNAME').AsString:=aQueryaccept.FieldByName('费用名称').AsString; memtblprintFee.FieldByName('OBJDR').AsString:=trim(aQueryaccept.FieldByName('客户名称').AsString); memtblprintFee.FieldByName('OBJCR').AsString:=''; memtblprintFee.FieldByName('REMARKCR').AsString:=''; memtblprintFee.FieldByName('USDCR').AsFloat:=0; memtblprintFee.FieldByName('RMBCR').AsFloat:=0; memtblprintFee.FieldByName('OTCR').AsFloat:=0; memtblprintFee.FieldByName('TTLCR').AsFloat:=0; memtblprintFee.FieldByName('DR').AsString:='T'; memtblprintFee.FieldByName('CR').AsString:='F'; if aQueryaccept.FieldByName('币别').AsString='USD' then begin memtblprintFee.FieldByName('USDDR').AsFloat:=aQueryaccept.fieldByName('金额').AsFloat; memtblprintFee.FieldByName('TTLDR').AsFloat:=(aQueryaccept.fieldByName('金额').AsFloat*aQueryaccept.fieldByName('汇率').AsFloat); end else if aQueryaccept.FieldByName('币别').AsString='RMB' then begin memtblprintFee.FieldByName('RMBDR').AsFloat:=aQueryaccept.fieldByName('金额').AsFloat; memtblprintFee.FieldByName('TTLDR').AsFloat:=(aQueryaccept.fieldByName('金额').AsFloat*aQueryaccept.fieldByName('汇率').AsFloat); end else begin memtblprintFee.FieldByName('OTDR').AsFloat:=aQueryaccept.fieldByName('金额').AsFloat; memtblprintFee.FieldByName('TTLDR').AsFloat:=(aQueryaccept.fieldByName('金额').AsFloat*aQueryaccept.fieldByName('汇率').AsFloat); end; memtblprintFee.FieldByName('REMARKDR').AsString:=memtblprintFee.FieldByName('REMARKDR').AsString+' '+aQueryaccept.fieldbyName('备注').AsString; memtblprintFee.Post; end; aQueryaccept.Next; end; aQuerypay.First; while not aQuerypay.Eof do begin Frt:=GetFrt(aQuerypay.FieldByName('客户名称').AsString); ShowMessage(tv_bscard_all.fieldbyname('编号').asstring+' '+Frt+' '+aQuerypay.FieldByName('费用名称').asstring); if memtblprintFee.Locate('编号;Frt;ACCNAME;CR',vararrayof([tv_bscard_all.fieldbyname('编号').asstring,Frt,aQuerypay.FieldByName('费用名称').asstring,'F']),[]) then begin ShowMessage('1'+tv_bscard_all.fieldbyname('编号').asstring); memtblprintFee.Edit; memtblprintFee.FieldByName('OBJCR').AsString:=trim(aQuerypay.FieldByName('客户名称').AsString); if aQuerypay.FieldByName('币别').AsString='USD' then begin memtblprintFee.FieldByName('USDCR').AsFloat:=memtblprintFee.FieldByName('USDCR').AsFloat+aQuerypay.fieldByName('金额').AsFloat; memtblprintFee.FieldByName('TTLCR').AsFloat:=memtblprintFee.FieldByName('TTLCR').AsFloat+(aQuerypay.fieldByName('金额').AsFloat*aQuerypay.fieldByName('汇率').AsFloat); end else if aQuerypay.FieldByName('币别').AsString='RMB' then begin memtblprintFee.FieldByName('RMBCR').AsFloat:=memtblprintFee.FieldByName('RMBCR').AsFloat+aQuerypay.fieldByName('金额').AsFloat; memtblprintFee.FieldByName('TTLCR').AsFloat:=memtblprintFee.FieldByName('TTLCR').AsFloat+(aQuerypay.fieldByName('金额').AsFloat*aQuerypay.fieldByName('汇率').AsFloat); end else begin memtblprintFee.FieldByName('OTCR').AsFloat:=memtblprintFee.FieldByName('OTCR').AsFloat+aQuerypay.fieldByName('金额').AsFloat; memtblprintFee.FieldByName('TTLCR').AsFloat:=memtblprintFee.FieldByName('TTLCR').AsFloat+(aQuerypay.fieldByName('金额').AsFloat*aQuerypay.fieldByName('汇率').AsFloat); end; if memtblprintFee.FieldByName('REMARKCR').AsString='' then begin memtblprintFee.FieldByName('REMARKCR').AsString:=aQuerypay.fieldbyName('备注').AsString; end else begin memtblprintFee.FieldByName('REMARKCR').AsString:=memtblprintFee.FieldByName('REMARKCR').AsString+' '+aQuerypay.fieldbyName('备注').AsString; end; memtblprintFee.FieldByName('CR').AsString:='T'; memtblprintFee.FieldByName('编号').AsString:=tv_bscard_all.fieldbyname('编号').asstring; memtblprintFee.Post; end else begin ShowMessage(tv_bscard_all.fieldbyname('编号').asstring+' '+Frt+' '+aQuerypay.FieldByName('费用名称').asstring); if memtblprintFee.Locate('编号;Frt;ACCNAME;OBJCR',vararrayof([tv_bscard_all.fieldbyname('编号').asstring,Frt,aQuerypay.FieldByName('费用名称').asstring,trim(aQuerypay.FieldByName('客户名称').asstring)]),[]) then begin ShowMessage('2'+tv_bscard_all.fieldbyname('编号').asstring); memtblprintFee.Edit; if aQuerypay.FieldByName('币别').AsString='USD' then begin memtblprintFee.FieldByName('USDCR').AsFloat:=memtblprintFee.FieldByName('USDCR').AsFloat+aQuerypay.fieldByName('金额').AsFloat; memtblprintFee.FieldByName('TTLCR').AsFloat:=memtblprintFee.FieldByName('TTLCR').AsFloat+(aQuerypay.fieldByName('金额').AsFloat*aQuerypay.fieldByName('汇率').AsFloat); end else if aQuerypay.FieldByName('币别').AsString='RMB' then begin memtblprintFee.FieldByName('RMBCR').AsFloat:=memtblprintFee.FieldByName('RMBCR').AsFloat+aQuerypay.fieldByName('金额').AsFloat; memtblprintFee.FieldByName('TTLCR').AsFloat:=memtblprintFee.FieldByName('TTLCR').AsFloat+(aQuerypay.fieldByName('金额').AsFloat*aQuerypay.fieldByName('汇率').AsFloat); end else begin memtblprintFee.FieldByName('OTCR').AsFloat:=memtblprintFee.FieldByName('OTCR').AsFloat+aQuerypay.fieldByName('金额').AsFloat; memtblprintFee.FieldByName('TTLCR').AsFloat:=memtblprintFee.FieldByName('TTLCR').AsFloat+(aQuerypay.fieldByName('金额').AsFloat*aQuerypay.fieldByName('汇率').AsFloat); end; if memtblprintFee.FieldByName('REMARKCR').AsString='' then begin memtblprintFee.FieldByName('REMARKCR').AsString:=aQuerypay.fieldbyName('备注').AsString; end else begin memtblprintFee.FieldByName('REMARKCR').AsString:=memtblprintFee.FieldByName('REMARKCR').AsString+' '+aQuerypay.fieldbyName('备注').AsString; end; memtblprintFee.FieldByName('CR').AsString:='T'; memtblprintFee.FieldByName('编号').AsString:=tv_bscard_all.fieldbyname('编号').asstring; memtblprintFee.Post; end else begin ShowMessage('3'+tv_bscard_all.fieldbyname('编号').asstring); ordNO:=ordNO+1; memtblprintFee.Append; memtblprintFee.FieldByName('ORDNO').AsInteger:=ordNO; memtblprintFee.FieldByName('FRT').AsString:=GetFrt(aQuerypay.FieldByName('客户名称').AsString); memtblprintFee.FieldByName('编号').AsString:=tv_bscard_all.fieldbyname('编号').asstring; memtblprintFee.FieldByName('ACCNAME').AsString:=aQuerypay.FieldByName('费用名称').AsString; memtblprintFee.FieldByName('OBJCR').AsString:=aQuerypay.FieldByName('客户名称').AsString; memtblprintFee.FieldByName('OBJDR').AsString:=''; memtblprintFee.FieldByName('REMARKCR').AsString:=''; memtblprintFee.FieldByName('USDDR').AsFloat:=0; memtblprintFee.FieldByName('RMBDR').AsFloat:=0; memtblprintFee.FieldByName('OTDR').AsFloat:=0; memtblprintFee.FieldByName('TTLDR').AsFloat:=0; memtblprintFee.FieldByName('DR').AsString:='F'; memtblprintFee.FieldByName('CR').AsString:='T'; if aQuerypay.FieldByName('币别').AsString='USD' then begin memtblprintFee.FieldByName('USDCR').AsFloat:=aQuerypay.fieldByName('金额').AsFloat; memtblprintFee.FieldByName('TTLCR').AsFloat:=(aQuerypay.fieldByName('金额').AsFloat*aQuerypay.fieldByName('汇率').AsFloat); end else if aQuerypay.FieldByName('币别').AsString='RMB' then begin memtblprintFee.FieldByName('RMBCR').AsFloat:=aQuerypay.fieldByName('金额').AsFloat; memtblprintFee.FieldByName('TTLCR').AsFloat:=(aQuerypay.fieldByName('金额').AsFloat*aQuerypay.fieldByName('汇率').AsFloat); end else begin memtblprintFee.FieldByName('OTCR').AsFloat:=aQuerypay.fieldByName('金额').AsFloat; memtblprintFee.FieldByName('TTLCR').AsFloat:=(aQuerypay.fieldByName('金额').AsFloat*aQuerypay.fieldByName('汇率').AsFloat); end; memtblprintFee.FieldByName('REMARKCR').AsString:=memtblprintFee.FieldByName('REMARKCR').AsString+' '+aQuerypay.fieldbyName('备注').AsString; memtblprintFee.Post; end; end; aQuerypay.Next; end; finally aQueryaccept.Free; aQuerypay.Free; end; end;} end.