unit u_rp_fenzhang; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, bsSkinCtrls, dxExEdtr, dxCntner, dxTL, dxDBCtrl, dxDBGrid, DB, ADODB, dxDBTLCl, dxGrClms, ComCtrls, bsSkinTabs, wwdblook, RxLookup, wwdbdatetimepicker, StdCtrls, Menus, ExtCtrls, XPMenu; type Tfrm_rp_fenzhang = class(TForm) p_fenzhang: TADOStoredProc; p_fenzhang1: TDataSource; bsSkinPageControl1: TbsSkinPageControl; bsSkinTabSheet1: TbsSkinTabSheet; dxDBGrid1: TdxDBGrid; dxDBGrid1Column1: TdxDBGridColumn; dxDBGrid1Column2: TdxDBGridColumn; dxDBGrid1Column59: TdxDBGridColumn; dxDBGrid1DEBIT: TdxDBGridColumn; dxDBGrid1CREDIT: TdxDBGridColumn; dxDBGrid1Column3: TdxDBGridColumn; dxDBGrid1Column4: TdxDBGridColumn; dxDBGrid1Column5: TdxDBGridColumn; dxDBGrid1Column6: TdxDBGridColumn; dxDBGrid1Column7: TdxDBGridColumn; dxDBGrid1Column8: TdxDBGridColumn; dxDBGrid1Column9: TdxDBGridColumn; dxDBGrid1Column10: TdxDBGridColumn; dxDBGrid1Column11: TdxDBGridColumn; dxDBGrid1Column12: TdxDBGridColumn; dxDBGrid1Column13: TdxDBGridColumn; dxDBGrid1Column14: TdxDBGridColumn; dxDBGrid1Column15: TdxDBGridColumn; dxDBGrid1Column16: TdxDBGridColumn; dxDBGrid1Column17: TdxDBGridColumn; dxDBGrid1Column18: TdxDBGridColumn; dxDBGrid1Column19: TdxDBGridColumn; dxDBGrid1Column20: TdxDBGridColumn; dxDBGrid1Column21: TdxDBGridColumn; dxDBGrid1Column22: TdxDBGridColumn; dxDBGrid11: TdxDBGridColumn; dxDBGrid12: TdxDBGridColumn; dxDBGrid13: TdxDBGridColumn; dxDBGrid14: TdxDBGridColumn; dxDBGrid15: TdxDBGridColumn; dxDBGrid16: TdxDBGridColumn; dxDBGrid17: TdxDBGridColumn; dxDBGrid18: TdxDBGridColumn; dxDBGrid19: TdxDBGridColumn; dxDBGrid110: TdxDBGridColumn; dxDBGrid111: TdxDBGridColumn; dxDBGrid112: TdxDBGridColumn; dxDBGrid113: TdxDBGridColumn; dxDBGrid114: TdxDBGridColumn; dxDBGrid115: TdxDBGridColumn; dxDBGrid116: TdxDBGridColumn; dxDBGrid117: TdxDBGridColumn; dxDBGrid118: TdxDBGridColumn; dxDBGrid119: TdxDBGridColumn; dxDBGrid120: TdxDBGridColumn; dxDBGrid1Column43: TdxDBGridColumn; dxDBGrid1TEU: TdxDBGridColumn; dxDBGrid1Column45: TdxDBGridColumn; dxDBGrid1Column58: TdxDBGridColumn; dxDBGrid1Column48: TdxDBGridColumn; dxDBGrid1Column49: TdxDBGridColumn; dxDBGrid1Column50: TdxDBGridColumn; dxDBGrid1Column57: TdxDBGridColumn; dxDBGrid1Column56: TdxDBGridColumn; dxDBGrid1Column46: TdxDBGridColumn; dxDBGrid1Column47: TdxDBGridColumn; dxDBGrid1Column51: TdxDBGridColumn; dxDBGrid1Column52: TdxDBGridColumn; dxDBGrid1Column53: TdxDBGridColumn; dxDBGrid1Column54: TdxDBGridColumn; dxDBGrid1Column55: TdxDBGridColumn; bsSkinTabSheet2: TbsSkinTabSheet; p_sum_daili: TADOStoredProc; p_sum_daili1: TDataSource; p_sum_currency: TADOStoredProc; p_sum_currency1: TDataSource; dxDBGrid2: TdxDBGrid; dxDBGrid2Column1: TdxDBGridColumn; dxDBGrid2DEBIT: TdxDBGridColumn; dxDBGrid2CREDIT: TdxDBGridColumn; dxDBGrid3: TdxDBGrid; dxDBGridColumn1: TdxDBGridColumn; dxDBGridColumn2: TdxDBGridColumn; dxDBGridColumn3: TdxDBGridColumn; dxDBGrid3Column4: TdxDBGridColumn; PopupMenu2: TPopupMenu; N10: TMenuItem; N11: TMenuItem; N14: TMenuItem; N13: TMenuItem; N12: TMenuItem; N15: TMenuItem; N16: TMenuItem; Panel1: TPanel; bsSkinPanel1: TbsSkinPanel; Label6: TLabel; Label1: TLabel; Label10: TLabel; Label5: TLabel; Label11: TLabel; Label8: TLabel; Label9: TLabel; Label23: TLabel; Label22: TLabel; Label124: TLabel; Label16: TLabel; Label14: TLabel; Label3: TLabel; Label2: TLabel; Label4: TLabel; Label7: TLabel; Edit1: TEdit; Edit4: TEdit; Edit3: TEdit; Edit2: TEdit; wwDBDateTimePicker1: TwwDBDateTimePicker; wwDBDateTimePicker2: TwwDBDateTimePicker; wwDBDateTimePicker4: TwwDBDateTimePicker; wwDBDateTimePicker3: TwwDBDateTimePicker; RxDBLookupCombo2: TRxDBLookupCombo; RxDBLookupCombo10: TRxDBLookupCombo; RxDBLookupCombo12: TRxDBLookupCombo; wwDBLookupCombo52: TwwDBLookupCombo; RxDBLookupCombo6: TRxDBLookupCombo; RxDBLookupCombo3: TRxDBLookupCombo; RxDBLookupCombo1: TRxDBLookupCombo; wwDBLookupCombo3: TwwDBLookupCombo; bsSkinPanel2: TbsSkinPanel; bsSkinButton10: TbsSkinButton; bsSkinButton6: TbsSkinButton; bsSkinButton9: TbsSkinButton; bsSkinButton5: TbsSkinButton; XPMenu1: TXPMenu; p_fenzhangbill: TADOStoredProc; p_fenzhangbill1: TDataSource; bsSkinTabSheet3: TbsSkinTabSheet; dxDBGrid4: TdxDBGrid; dxDBGridColumn4: TdxDBGridColumn; dxDBGridColumn5: TdxDBGridColumn; dxDBGridColumn6: TdxDBGridColumn; dxDBGridColumn7: TdxDBGridColumn; dxDBGrid4Column5: TdxDBGridColumn; dxDBGrid4Column6: TdxDBGridColumn; dxDBGrid4Column7: TdxDBGridColumn; bsSkinPanel3: TbsSkinPanel; Label12: TLabel; Edit5: TEdit; PopupMenu1: TPopupMenu; MenuItem7: TMenuItem; procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure bsSkinButton5Click(Sender: TObject); procedure bsSkinButton6Click(Sender: TObject); procedure bsSkinButton10Click(Sender: TObject); procedure bsSkinButton9Click(Sender: TObject); procedure FormShow(Sender: TObject); procedure N10Click(Sender: TObject); procedure N14Click(Sender: TObject); procedure N12Click(Sender: TObject); procedure N16Click(Sender: TObject); procedure Edit1KeyPress(Sender: TObject; var Key: Char); procedure MenuItem7Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var frm_rp_fenzhang: Tfrm_rp_fenzhang; implementation uses u_main, u_data_share, my_sys_function; {$R *.dfm} procedure Tfrm_rp_fenzhang.FormClose(Sender: TObject; var Action: TCloseAction); begin savereggrid(dxdbgrid1,caption); frm_rp_fenzhang.Hide; frm_rp_fenzhang.ManualFloat(frm_rp_fenzhang.BoundsRect ); frm_main.freeTabs('frm_rp_fenzhang'); action:=cafree; frm_rp_fenzhang:=nil; end; procedure Tfrm_rp_fenzhang.bsSkinButton5Click(Sender: TObject); begin close; end; procedure Tfrm_rp_fenzhang.bsSkinButton6Click(Sender: TObject); begin Edit1.text:=''; Edit4.text:=''; Edit2.text:=''; Edit3.text:=''; Edit5.text:=''; wwDBDateTimePicker1.text:=''; wwDBDateTimePicker2.text:=''; wwDBDateTimePicker3.text:=''; wwDBDateTimePicker4.text:=''; RxDBLookupCombo2.ClearValue; RxDBLookupCombo1.ClearValue; wwDBLookupCombo52.text:=''; wwDBLookupCombo3.text:=''; RxDBLookupCombo6.ClearValue; RxDBLookupCombo12.ClearValue; RxDBLookupCombo3.ClearValue; RxDBLookupCombo10.ClearValue; end; procedure Tfrm_rp_fenzhang.bsSkinButton10Click(Sender: TObject); var str:widestring; str_fields:widestring; begin str_fields:='v_op_bscard.编号, v_op_bscard.业务编号, v_op_bscard.会计期间, v_op_bscard.主提单号,'; str_fields:=str_fields+'v_op_bscard.分提单号, v_op_bscard.委托编号, v_op_bscard.装运方式, v_op_bscard.委托单位, '; str_fields:=str_fields+'v_op_bscard.船名, '; str_fields:=str_fields+'v_op_bscard.航次, v_op_bscard.开船日期, '; str_fields:=str_fields+'v_op_bscard.装货港, v_op_bscard.卸货港, v_op_bscard.件数, v_op_bscard.重量, '; str_fields:=str_fields+'v_op_bscard.尺码, v_op_bscard.箱型1, v_op_bscard.箱型2, v_op_bscard.箱型3, v_op_bscard.箱型4, '; str_fields:=str_fields+'v_op_bscard.箱型5, v_op_bscard.箱型6, v_op_bscard.箱型7, v_op_bscard.箱型8, v_op_bscard.箱型9, '; str_fields:=str_fields+'v_op_bscard.箱型10,v_op_bscard.其他箱型, v_op_bscard.箱TEU, v_op_bscard.集装箱, v_op_bscard.录入人, '; str_fields:=str_fields+'v_op_bscard.录入日期, v_op_bscard.操作员, v_op_bscard.揽货人, v_op_bscard.客服员, v_op_bscard.航线, '; str_fields:=str_fields+'v_op_bscard.船公司, v_op_bscard.货代公司, v_op_bscard.报关行, '; str_fields:=str_fields+'v_op_bscard.销售部门, v_op_bscard.操作部门, v_op_bscard.业务来源, t_ch_fee_fenzhang.代理名称,t_ch_fee_fenzhang.币别'; str:=' where '+open_data('0037','v_op_bscard.揽货人','v_op_bscard.操作员','v_op_bscard.客服员','v_op_bscard.报关操作','v_op_bscard.报检操作'); if Edit1.text<>''then str:=str+' and v_op_bscard.业务编号 like '+''''+Edit1.text+''''; if Edit4.text<>''then str:=str+' and v_op_bscard.委托编号 like '+''''+Edit4.text+''''; if Edit2.text<>''then str:=str+' and v_op_bscard.主提单号 like '+''''+Edit2.text+''''; if Edit3.text<>''then str:=str+' and v_op_bscard.分提单号 like '+''''+Edit3.text+''''; if wwDBDateTimePicker1.text<>''then str:=str+' and v_op_bscard.开船日期>='+''''+wwDBDateTimePicker1.text+''''; if wwDBDateTimePicker2.text<>''then str:=str+' and v_op_bscard.开船日期<='+''''+wwDBDateTimePicker2.text+''''; if wwDBDateTimePicker3.text<>''then str:=str+' and v_op_bscard.会计期间>='+''''+wwDBDateTimePicker3.text+''''; if wwDBDateTimePicker4.text<>''then str:=str+' and v_op_bscard.会计期间<='+''''+wwDBDateTimePicker4.text+''''; if RxDBLookupCombo2.DisplayValue<>''then str:=str+' and v_op_bscard.委托单位='+''''+RxDBLookupCombo2.DisplayValues[1]+''''; if RxDBLookupCombo1.DisplayValue<>''then str:=str+' and t_ch_fee_fenzhang.代理名称='+''''+RxDBLookupCombo1.DisplayValues[1]+''''; if RxDBLookupCombo6.DisplayValue<>''then str:=str+' and v_op_bscard.操作员='+''''+RxDBLookupCombo6.DisplayValue+''''; if RxDBLookupCombo12.DisplayValue<>''then str:=str+' and v_op_bscard.操作部门='+''''+RxDBLookupCombo12.DisplayValue+''''; if RxDBLookupCombo3.DisplayValue<>''then str:=str+' and v_op_bscard.揽货人='+''''+RxDBLookupCombo3.DisplayValue+''''; if RxDBLookupCombo10.DisplayValue<>''then str:=str+' and v_op_bscard.销售部门='+''''+RxDBLookupCombo10.DisplayValue+''''; if wwDBLookupCombo52.text<>''then str:=str+' and v_op_bscard.卸货港 like '+''''+wwDBLookupCombo52.text+''''; if wwDBLookupCombo3.text<>''then str:=str+' and t_ch_fee_fenzhang.币别='+''''+wwDBLookupCombo3.text+''''; p_fenzhang.close; p_fenzhang.Parameters.ParamByName('SQLStr').value:='select ' +str_fields +', SUM(t_ch_fee_fenzhang.应收金额) AS DEBIT,' +'SUM(t_ch_fee_fenzhang.应付金额) AS CREDIT ' +'FROM v_op_bscard INNER JOIN ' +'t_ch_fee_fenzhang ON ' +'v_op_bscard.编号 = t_ch_fee_fenzhang.编号' +str +' group by '+str_fields; p_fenzhang.open; p_sum_daili.close; p_sum_daili.Parameters.ParamByName('SQLStr').value:= 'select t_ch_fee_fenzhang.代理名称,t_ch_fee_fenzhang.币别' +', SUM(t_ch_fee_fenzhang.应收金额) AS DEBIT,' +'SUM(t_ch_fee_fenzhang.应付金额) AS CREDIT ' +'FROM v_op_bscard INNER JOIN ' +'t_ch_fee_fenzhang ON ' +'v_op_bscard.编号 = t_ch_fee_fenzhang.编号' +str +' group by t_ch_fee_fenzhang.代理名称,t_ch_fee_fenzhang.币别' +' order by t_ch_fee_fenzhang.代理名称,t_ch_fee_fenzhang.币别'; p_sum_daili.open; p_sum_currency.close; p_sum_currency.Parameters.ParamByName('SQLStr').value:= 'select t_ch_fee_fenzhang.币别' +', SUM(t_ch_fee_fenzhang.应收金额) AS DEBIT,' +'SUM(t_ch_fee_fenzhang.应付金额) AS CREDIT ' +'FROM v_op_bscard INNER JOIN ' +'t_ch_fee_fenzhang ON ' +'v_op_bscard.编号 = t_ch_fee_fenzhang.编号' +str +' group by t_ch_fee_fenzhang.币别' +' order by t_ch_fee_fenzhang.币别'; p_sum_currency.open; if Edit5.text<>''then str:=str+' and t_ch_fee_agentdc.帐单编号 like '+''''+'%'+Edit5.text+'%'+''''; p_fenzhangbill.close; p_fenzhangbill.Parameters.ParamByName('SQLStr').value:= 'select v_op_bscard.主提单号,t_ch_fee_agentdc.帐单编号,t_ch_fee_agentdc.代理名称,t_ch_fee_agentdc.币别' +', t_ch_fee_agentdc.应收金额 DEBIT' +',t_ch_fee_agentdc.应付金额 CREDIT' +',t_ch_fee_agentdc.结余金额 BALANCE' +' FROM v_op_bscard INNER JOIN ' +'t_ch_fee_agentdc ON ' +'v_op_bscard.编号 = t_ch_fee_agentdc.编号' +str +' order by t_ch_fee_agentdc.帐单编号,t_ch_fee_agentdc.代理名称,t_ch_fee_agentdc.币别'; // showmessage(p_fenzhangbill.Parameters.ParamByName('SQLStr').value); p_fenzhangbill.open; end; procedure Tfrm_rp_fenzhang.bsSkinButton9Click(Sender: TObject); begin sys_print('海运代理分帐统计',2,nil,nil,nil,nil,p_fenzhang1,p_sum_daili1,p_sum_currency1,p_fenzhangbill1,nil,nil,nil); end; procedure Tfrm_rp_fenzhang.FormShow(Sender: TObject); begin loadreggrid(dxdbgrid1,true,caption); end; procedure Tfrm_rp_fenzhang.N10Click(Sender: TObject); begin update_grid_view_no(dxdbgrid1); end; procedure Tfrm_rp_fenzhang.N14Click(Sender: TObject); begin update_grid_view_all(dxdbgrid1); end; procedure Tfrm_rp_fenzhang.N12Click(Sender: TObject); begin update_grid(dxdbgrid1,97); end; procedure Tfrm_rp_fenzhang.N16Click(Sender: TObject); begin grid_save_xls(dxdbgrid1); end; procedure Tfrm_rp_fenzhang.Edit1KeyPress(Sender: TObject; var Key: Char); begin if key=#13 then begin key:=#0; frm_rp_fenzhang.bsSkinButton10Click(Sender); end; end; procedure Tfrm_rp_fenzhang.MenuItem7Click(Sender: TObject); begin grid_save_xls(dxdbgrid4); end; end.