unit u_rp_in_fenlei; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, dxExEdtr, DB, ADODB, dxDBTLCl, dxGrClms, dxDBGrid, dxTL, dxDBCtrl, dxCntner, ComCtrls, bsSkinTabs, StdCtrls, Mask, wwdbedit, Wwdotdot, Wwdbcomb, RxLookup, wwdbdatetimepicker, bsSkinCtrls, ExtCtrls; type Tfrm_rp_in_fenlei = class(TForm) Panel1: TPanel; bsSkinPanel2: TbsSkinPanel; Label10: TLabel; Label5: TLabel; Label9: TLabel; wwDBDateTimePicker1: TwwDBDateTimePicker; wwDBDateTimePicker2: TwwDBDateTimePicker; RxDBLookupCombo2: TRxDBLookupCombo; p_shikai: TADOStoredProc; p_daikai: TADOStoredProc; p_daikai1: TDataSource; p_chongxiao: TADOStoredProc; p_chongxiao1: TDataSource; p_shikai1: TDataSource; bsSkinButton10: TbsSkinButton; bsSkinButton9: TbsSkinButton; bsSkinButton5: TbsSkinButton; bsSkinGroupBox1: TbsSkinGroupBox; dxDBGrid1: TdxDBGrid; dxDBGrid1Column1: TdxDBGridMaskColumn; dxDBGrid1USD: TdxDBGridColumn; dxDBGrid1RMB: TdxDBGridColumn; bsSkinGroupBox2: TbsSkinGroupBox; dxDBGrid2: TdxDBGrid; dxDBGridMaskColumn1: TdxDBGridMaskColumn; dxDBGridColumn1: TdxDBGridColumn; dxDBGridColumn2: TdxDBGridColumn; bsSkinGroupBox3: TbsSkinGroupBox; dxDBGrid3: TdxDBGrid; dxDBGridMaskColumn2: TdxDBGridMaskColumn; dxDBGridColumn3: TdxDBGridColumn; dxDBGridColumn4: TdxDBGridColumn; procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure bsSkinButton9Click(Sender: TObject); procedure bsSkinButton5Click(Sender: TObject); procedure bsSkinButton10Click(Sender: TObject); procedure bsSkinPanel2Resize(Sender: TObject); private { Private declarations } public { Public declarations } end; var frm_rp_in_fenlei: Tfrm_rp_in_fenlei; implementation uses u_main, u_data_share, my_sys_function; {$R *.dfm} procedure Tfrm_rp_in_fenlei.FormClose(Sender: TObject; var Action: TCloseAction); begin frm_rp_in_fenlei.Hide; frm_rp_in_fenlei.ManualFloat(frm_rp_in_fenlei.BoundsRect ); frm_main.freeTabs('frm_rp_in_fenlei'); action:=cafree; frm_rp_in_fenlei:=nil; end; procedure Tfrm_rp_in_fenlei.bsSkinButton9Click(Sender: TObject); begin sys_print('发票分类统计',2,nil,nil,nil,nil,p_shikai1,p_daikai1,p_chongxiao1,nil,nil,nil,nil); end; procedure Tfrm_rp_in_fenlei.bsSkinButton5Click(Sender: TObject); begin close; end; procedure Tfrm_rp_in_fenlei.bsSkinButton10Click(Sender: TObject); var str:widestring; begin str:='SELECT 客户名称, SUM(CASE 币别 WHEN '+''''+'USD'+''''+' THEN 合计金额 ELSE 0 END) ' +'AS USD金额, SUM(CASE 币别 WHEN '+''''+'USD'+''''+' THEN 0 ELSE 合计金额 END) ' +'AS RMB金额 FROM t_ch_invoice WHERE 是否废除 = 0 '; if wwDBDateTimePicker1.text<>'' then str:=str+' and 开票日期>='+''''+wwDBDateTimePicker1.text+''''; if wwDBDateTimePicker2.text<>'' then str:=str+' and 开票日期<='+''''+wwDBDateTimePicker2.text+''''; if RxDBLookupCombo2.DisplayValue<>'' then str:=str+' and 客户名称='+''''+RxDBLookupCombo2.DisplayValues[1]+''''; str:=str+' GROUP BY 客户名称 order by 客户名称'; p_shikai.Close; p_shikai.Parameters.ParamByName('SQLStr').value:=str; p_shikai.open; str:='SELECT 客户名称, SUM(CASE 币别 WHEN '+''''+'USD'+''''+' THEN 申请金额 ELSE 0 END) ' +'AS USD金额, SUM(CASE 币别 WHEN '+''''+'USD'+''''+' THEN 0 ELSE 申请金额 END) ' +'AS RMB金额 FROM t_ch_invoice_shen WHERE 申请类别 = ' +''''+'代开发票'+''''+' AND 申请状态 = '+''''+'开出发票'+''''+' '; if wwDBDateTimePicker1.text<>'' then str:=str+' and 申请日期>='+''''+wwDBDateTimePicker1.text+''''; if wwDBDateTimePicker2.text<>'' then str:=str+' and 申请日期<='+''''+wwDBDateTimePicker2.text+''''; if RxDBLookupCombo2.DisplayValue<>'' then str:=str+' and 客户名称='+''''+RxDBLookupCombo2.DisplayValues[1]+''''; str:=str+' GROUP BY 客户名称 order by 客户名称'; p_daikai.Close; p_daikai.Parameters.ParamByName('SQLStr').value:=str; p_daikai.open; str:='SELECT 客户名称, SUM(CASE 币别 WHEN '+''''+'USD'+''''+' THEN 申请金额 ELSE 0 END) ' +'AS USD金额, SUM(CASE 币别 WHEN '+''''+'USD'+''''+' THEN 0 ELSE 申请金额 END) ' +'AS RMB金额 FROM t_ch_invoice_shen WHERE 申请类别 = ' +''''+'冲销发票'+''''+' AND 申请状态 = '+''''+'开出发票'+''''+' '; if wwDBDateTimePicker1.text<>'' then str:=str+' and 申请日期>='+''''+wwDBDateTimePicker1.text+''''; if wwDBDateTimePicker2.text<>'' then str:=str+' and 申请日期<='+''''+wwDBDateTimePicker2.text+''''; if RxDBLookupCombo2.DisplayValue<>'' then str:=str+' and 客户名称='+''''+RxDBLookupCombo2.DisplayValues[1]+''''; str:=str+' GROUP BY 客户名称 order by 客户名称'; p_chongxiao.Close; p_chongxiao.Parameters.ParamByName('SQLStr').value:=str; p_chongxiao.open; end; procedure Tfrm_rp_in_fenlei.bsSkinPanel2Resize(Sender: TObject); var i:integer; begin i:=ROUND(bsSkinPanel2.Width/3); bsSkinGroupBox1.Width:=i; bsSkinGroupBox2.Width:=i; end; end.