unit u_rp_ch_currency_change; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, bsSkinCtrls, wwdblook, RxLookup, wwdbdatetimepicker, StdCtrls, dxExEdtr, dxCntner, dxTL, dxDBCtrl, dxDBGrid, DB, ADODB, dxDBTLCl, dxGrClms, ComCtrls, bsSkinTabs; type Tfrm_rp_ch_currency_change = class(TForm) bsSkinPanel1: TbsSkinPanel; Label10: TLabel; Label5: TLabel; Label8: TLabel; Label11: TLabel; wwDBDateTimePicker1: TwwDBDateTimePicker; wwDBDateTimePicker2: TwwDBDateTimePicker; wwDBDateTimePicker3: TwwDBDateTimePicker; wwDBDateTimePicker4: TwwDBDateTimePicker; bsSkinButton1: TbsSkinButton; bsSkinButton5: TbsSkinButton; bsSkinButton9: TbsSkinButton; bsSkinPanel2: TbsSkinPanel; p_accept_usdtormb: TADOStoredProc; p_accept_usdtormb1: TDataSource; p_accept_rmbtousd: TADOStoredProc; p_accept_rmbtousd1: TDataSource; p_pay_usdtormb: TADOStoredProc; p_pay_usdtormb1: TDataSource; p_pay_rmbtousd: TADOStoredProc; p_pay_rmbtousd1: TDataSource; bsSkinPageControl1: TbsSkinPageControl; bsSkinTabSheet1: TbsSkinTabSheet; bsSkinTabSheet2: TbsSkinTabSheet; dxDBGrid2: TdxDBGrid; dxDBGridMaskColumn1: TdxDBGridMaskColumn; dxDBGridColumn1: TdxDBGridColumn; dxDBGrid1: TdxDBGrid; dxDBGrid1Column1: TdxDBGridMaskColumn; dxDBGrid1USDTORMB: TdxDBGridColumn; dxDBGrid3: TdxDBGrid; dxDBGridMaskColumn2: TdxDBGridMaskColumn; dxDBGridColumn2: TdxDBGridColumn; dxDBGrid4: TdxDBGrid; dxDBGridMaskColumn3: TdxDBGridMaskColumn; dxDBGridColumn3: TdxDBGridColumn; bsSkinPageControl2: TbsSkinPageControl; bsSkinTabSheet11: TbsSkinTabSheet; bsSkinTabSheet12: TbsSkinTabSheet; bsSkinTabSheet3: TbsSkinTabSheet; bsSkinTabSheet4: TbsSkinTabSheet; p_accept_RmbtousdDetail: TADOStoredProc; p_accept_usdtormbDetail: TADOStoredProc; dsraccept_usdtormbDetail: TDataSource; Dsraccept_RmbtousdDetail: TDataSource; p_pay_usdtormbDetail: TADOStoredProc; p_pay_rmbtousdDetail: TADOStoredProc; dsrpay_rmbtousdDetail: TDataSource; dsrpay_usdtormbDetail: TDataSource; dxDBGrid6: TdxDBGrid; dxDBGridMaskColumn4: TdxDBGridMaskColumn; dxDBGridMaskColumn5: TdxDBGridMaskColumn; dxDBGridMaskColumn6: TdxDBGridMaskColumn; dxDBGridMaskColumn7: TdxDBGridMaskColumn; dxDBGridMaskColumn8: TdxDBGridMaskColumn; dxDBGridMaskColumn9: TdxDBGridMaskColumn; dxDBGridColumn4: TdxDBGridColumn; dxDBGridColumn5: TdxDBGridColumn; dxDBGridColumn6: TdxDBGridColumn; dxDBGridColumn7: TdxDBGridColumn; dxDBGridColumn8: TdxDBGridColumn; dxDBGridColumn9: TdxDBGridColumn; dxDBGridColumn10: TdxDBGridColumn; dxDBGrid7: TdxDBGrid; dxDBGridMaskColumn10: TdxDBGridMaskColumn; dxDBGridMaskColumn11: TdxDBGridMaskColumn; dxDBGridMaskColumn12: TdxDBGridMaskColumn; dxDBGridMaskColumn13: TdxDBGridMaskColumn; dxDBGridMaskColumn14: TdxDBGridMaskColumn; dxDBGridMaskColumn15: TdxDBGridMaskColumn; dxDBGridColumn11: TdxDBGridColumn; dxDBGridColumn12: TdxDBGridColumn; dxDBGridColumn13: TdxDBGridColumn; dxDBGridColumn14: TdxDBGridColumn; dxDBGridColumn15: TdxDBGridColumn; dxDBGridColumn16: TdxDBGridColumn; dxDBGridColumn17: TdxDBGridColumn; dxDBGrid8: TdxDBGrid; dxDBGridMaskColumn16: TdxDBGridMaskColumn; dxDBGridMaskColumn17: TdxDBGridMaskColumn; dxDBGridMaskColumn18: TdxDBGridMaskColumn; dxDBGridMaskColumn19: TdxDBGridMaskColumn; dxDBGridMaskColumn20: TdxDBGridMaskColumn; dxDBGridMaskColumn21: TdxDBGridMaskColumn; dxDBGridColumn18: TdxDBGridColumn; dxDBGridColumn19: TdxDBGridColumn; dxDBGridColumn20: TdxDBGridColumn; dxDBGridColumn21: TdxDBGridColumn; dxDBGridColumn22: TdxDBGridColumn; dxDBGridColumn23: TdxDBGridColumn; dxDBGridColumn24: TdxDBGridColumn; dxDBGrid5: TdxDBGrid; dxDBGrid3Column1: TdxDBGridMaskColumn; dxDBGrid3Column2: TdxDBGridMaskColumn; dxDBGrid3Column3: TdxDBGridMaskColumn; dxDBGrid3Column4: TdxDBGridMaskColumn; dxDBGrid3Column5: TdxDBGridMaskColumn; dxDBGrid3Column6: TdxDBGridMaskColumn; dxDBGrid5Column7: TdxDBGridColumn; dxDBGrid5Column8: TdxDBGridColumn; dxDBGrid5Column9: TdxDBGridColumn; dxDBGrid5Column10: TdxDBGridColumn; dxDBGrid5Column11: TdxDBGridColumn; dxDBGrid5Column12: TdxDBGridColumn; dxDBGrid5Column13: TdxDBGridColumn; procedure bsSkinButton1Click(Sender: TObject); procedure bsSkinButton5Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure bsSkinButton9Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var frm_rp_ch_currency_change: Tfrm_rp_ch_currency_change; implementation uses u_main, my_sys_function; {$R *.dfm} procedure Tfrm_rp_ch_currency_change.bsSkinButton1Click(Sender: TObject); var str:widestring; sl:TStrings; begin sl:=TStringList.Create; if wwDBDateTimePicker1.text<>'' then str:=' and v_op_no.业务日期>='+''''+wwDBDateTimePicker1.text+''''; if wwDBDateTimePicker2.text<>'' then begin if str=''then str:=' and v_op_no.业务日期<='+''''+wwDBDateTimePicker2.text+'''' else str:=str+' and v_op_no.业务日期<='+''''+wwDBDateTimePicker2.text+''''; end; if wwDBDateTimePicker3.text<>'' then begin if str=''then str:=' and v_op_no.会计期间>='+''''+wwDBDateTimePicker3.text+'''' else str:=str+' and v_op_no.会计期间>='+''''+wwDBDateTimePicker3.text+''''; end; if wwDBDateTimePicker4.text<>'' then begin if str=''then str:=' and v_op_no.会计期间<='+''''+wwDBDateTimePicker4.text+'''' else str:=str+' and v_op_no.会计期间<='+''''+wwDBDateTimePicker4.text+''''; end; p_accept_usdtormbdetail.close; p_accept_usdtormbdetail.Parameters.ParamByName('SQLStr').Value:= 'SELECT v_op_no.*,t_ch_fee.客户名称, t_ch_fee_do.原始金额 AS USDTORMB '+ 'FROM t_ch_fee_do INNER JOIN '+ 't_ch_fee ON t_ch_fee_do.CH_ID = t_ch_fee.CH_ID '+ ' INNER JOIN v_op_no ON t_ch_fee_do.业务编号 = v_op_no.编号 '+ 'WHERE (t_ch_fee_do.币别 = '+''''+'RMB'+''''+') AND (t_ch_fee.币别 = '+''''+'USD'+''''+') AND '+ '(t_ch_fee_do.类型 = '+''''+'3'+''''+') '+str; p_accept_usdtormbdetail.open; p_accept_rmbtousddetail.close; p_accept_rmbtousddetail.Parameters.ParamByName('SQLStr').Value:= 'SELECT v_op_no.*,t_ch_fee.客户名称, t_ch_fee.费用名称,t_ch_fee.汇率 AS 原始汇率, t_ch_fee_do.原始金额 AS 金额 '+ 'FROM t_ch_fee_do INNER JOIN '+ 't_ch_fee ON t_ch_fee_do.CH_ID = t_ch_fee.CH_ID '+ ' INNER JOIN v_op_no ON t_ch_fee_do.业务编号 = v_op_no.编号 '+ 'WHERE (t_ch_fee_do.币别 = '+''''+'USD'+''''+') AND (t_ch_fee.币别 = '+''''+'RMB'+''''+') AND '+ '(t_ch_fee_do.类型 = '+''''+'3'+''''+') '+str; sl.Add(p_accept_rmbtousddetail.Parameters.ParamByName('SQLStr').Value); p_accept_rmbtousddetail.open; FreeAndNil(sl); p_pay_usdtormbdetail.close; p_pay_usdtormbdetail.Parameters.ParamByName('SQLStr').Value:= 'SELECT v_op_no.*,t_ch_fee.客户名称,t_ch_fee.费用名称,t_ch_fee.汇率 AS 原始汇率, t_ch_fee_do.原始金额 AS 金额 '+ 'FROM t_ch_fee_do INNER JOIN '+ 't_ch_fee ON t_ch_fee_do.CH_ID = t_ch_fee.CH_ID '+ ' INNER JOIN v_op_no ON t_ch_fee_do.业务编号 = v_op_no.编号 '+ 'WHERE (t_ch_fee_do.币别 = '+''''+'RMB'+''''+') AND (t_ch_fee.币别 = '+''''+'USD'+''''+') AND '+ '(t_ch_fee_do.类型 = '+''''+'4'+''''+') '+str; p_pay_usdtormbdetail.open; p_pay_rmbtousddetail.close; p_pay_rmbtousddetail.Parameters.ParamByName('SQLStr').Value:= 'SELECT v_op_no.*,t_ch_fee.客户名称, t_ch_fee.费用名称,t_ch_fee.汇率 AS 原始汇率, t_ch_fee_do.原始金额 AS 金额 '+ 'FROM t_ch_fee_do INNER JOIN '+ 't_ch_fee ON t_ch_fee_do.CH_ID = t_ch_fee.CH_ID '+ ' INNER JOIN v_op_no ON t_ch_fee_do.业务编号 = v_op_no.编号 '+ 'WHERE (t_ch_fee_do.币别 = '+''''+'USD'+''''+') AND (t_ch_fee.币别 = '+''''+'RMB'+''''+') AND '+ '(t_ch_fee_do.类型 = '+''''+'4'+''''+') '+str; p_pay_rmbtousddetail.open; if str<>''then str:=' and t_ch_fee_do.业务编号 in (select 编号 from v_op_no where 1=1 '+str+')'; p_accept_usdtormb.close; p_accept_usdtormb.Parameters.ParamByName('SQLStr').Value:= 'SELECT t_ch_fee.客户名称, SUM(t_ch_fee_do.原始金额) AS USDTORMB '+ 'FROM t_ch_fee_do INNER JOIN '+ 't_ch_fee ON t_ch_fee_do.CH_ID = t_ch_fee.CH_ID '+ 'WHERE (t_ch_fee_do.币别 = '+''''+'RMB'+''''+') AND (t_ch_fee.币别 = '+''''+'USD'+''''+') AND '+ '(t_ch_fee_do.类型 = '+''''+'3'+''''+') '+str+ ' GROUP BY t_ch_fee.客户名称'; p_accept_usdtormb.open; p_accept_rmbtousd.close; p_accept_rmbtousd.Parameters.ParamByName('SQLStr').Value:= 'SELECT t_ch_fee.客户名称, SUM(t_ch_fee_do.原始金额) AS RMBTOUSD '+ 'FROM t_ch_fee_do INNER JOIN '+ 't_ch_fee ON t_ch_fee_do.CH_ID = t_ch_fee.CH_ID '+ 'WHERE (t_ch_fee_do.币别 = '+''''+'USD'+''''+') AND (t_ch_fee.币别 = '+''''+'RMB'+''''+') AND '+ '(t_ch_fee_do.类型 = '+''''+'3'+''''+') '+str+ ' GROUP BY t_ch_fee.客户名称'; p_accept_rmbtousd.open; p_pay_usdtormb.close; p_pay_usdtormb.Parameters.ParamByName('SQLStr').Value:= 'SELECT t_ch_fee.客户名称, SUM(t_ch_fee_do.原始金额) AS USDTORMB '+ 'FROM t_ch_fee_do INNER JOIN '+ 't_ch_fee ON t_ch_fee_do.CH_ID = t_ch_fee.CH_ID '+ 'WHERE (t_ch_fee_do.币别 = '+''''+'RMB'+''''+') AND (t_ch_fee.币别 = '+''''+'USD'+''''+') AND '+ '(t_ch_fee_do.类型 = '+''''+'4'+''''+') '+str+ ' GROUP BY t_ch_fee.客户名称'; p_pay_usdtormb.open; p_pay_rmbtousd.close; p_pay_rmbtousd.Parameters.ParamByName('SQLStr').Value:= 'SELECT t_ch_fee.客户名称, SUM(t_ch_fee_do.原始金额) AS RMBTOUSD '+ 'FROM t_ch_fee_do INNER JOIN '+ 't_ch_fee ON t_ch_fee_do.CH_ID = t_ch_fee.CH_ID '+ 'WHERE (t_ch_fee_do.币别 = '+''''+'USD'+''''+') AND (t_ch_fee.币别 = '+''''+'RMB'+''''+') AND '+ '(t_ch_fee_do.类型 = '+''''+'4'+''''+') '+str+ ' GROUP BY t_ch_fee.客户名称'; p_pay_rmbtousd.open; end; procedure Tfrm_rp_ch_currency_change.bsSkinButton5Click(Sender: TObject); begin close; end; procedure Tfrm_rp_ch_currency_change.FormClose(Sender: TObject; var Action: TCloseAction); begin frm_rp_ch_currency_change.Hide; frm_rp_ch_currency_change.ManualFloat(frm_rp_ch_currency_change.BoundsRect ); frm_main.freeTabs('frm_rp_ch_currency_change'); action:=cafree; frm_rp_ch_currency_change:=nil; end; procedure Tfrm_rp_ch_currency_change.bsSkinButton9Click(Sender: TObject); begin sys_print('币别折算统计',2,nil,nil,nil,nil,p_accept_usdtormb1,p_accept_rmbtousd1,p_pay_usdtormb1,p_pay_rmbtousd1,nil,nil,nil); end; end.