unit u_rp_in_ch; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, dxExEdtr, ADODB, DB, bsSkinCtrls, dxDBTLCl, dxGrClms, dxDBGrid, dxTL, dxDBCtrl, dxCntner, ComCtrls, bsSkinTabs, ExtCtrls, RxLookup, wwdbdatetimepicker, StdCtrls, Mask, wwdbedit, Wwdotdot, Wwdbcomb; type Tfrm_rp_in_ch = class(TForm) Panel1: TPanel; bsSkinPanel2: TbsSkinPanel; bsSkinButton10: TbsSkinButton; bsSkinButton9: TbsSkinButton; bsSkinButton5: TbsSkinButton; p_detail: TADOStoredProc; p_client: TADOStoredProc; p_client1: TDataSource; p_shen: TADOStoredProc; p_shen1: TDataSource; p_detail1: TDataSource; Label10: TLabel; wwDBDateTimePicker1: TwwDBDateTimePicker; Label5: TLabel; wwDBDateTimePicker2: TwwDBDateTimePicker; Label9: TLabel; RxDBLookupCombo2: TRxDBLookupCombo; Label14: TLabel; RxDBLookupCombo3: TRxDBLookupCombo; Label16: TLabel; RxDBLookupCombo6: TRxDBLookupCombo; Label7: TLabel; wwDBComboBox1: TwwDBComboBox; Label1: TLabel; wwDBComboBox3: TwwDBComboBox; Label2: TLabel; RxDBLookupCombo1: TRxDBLookupCombo; Label3: TLabel; RxDBLookupCombo4: TRxDBLookupCombo; bsSkinPageControl1: TbsSkinPageControl; bsSkinTabSheet1: TbsSkinTabSheet; bsSkinTabSheet2: TbsSkinTabSheet; bsSkinTabSheet3: TbsSkinTabSheet; dxDBGrid1: TdxDBGrid; dxDBGrid1Column1: TdxDBGridMaskColumn; dxDBGrid1Column2: TdxDBGridMaskColumn; dxDBGrid1Column3: TdxDBGridMaskColumn; dxDBGrid1Column4: TdxDBGridMaskColumn; dxDBGrid1Column10: TdxDBGridDateColumn; dxDBGrid1Column22: TdxDBGridMaskColumn; dxDBGrid1Column19: TdxDBGridColumn; dxDBGrid1Column20: TdxDBGridColumn; dxDBGrid1Column21: TdxDBGridColumn; dxDBGrid1Column28: TdxDBGridMaskColumn; dxDBGrid1Column32: TdxDBGridCheckColumn; dxDBGrid1Column29: TdxDBGridCheckColumn; dxDBGrid1Column35: TdxDBGridMaskColumn; dxDBGrid1Column36: TdxDBGridDateColumn; dxDBGrid1Column33: TdxDBGridMaskColumn; dxDBGrid1Column34: TdxDBGridDateColumn; dxDBGrid6: TdxDBGrid; dxDBGrid6Column1: TdxDBGridMaskColumn; dxDBGrid6Column2: TdxDBGridColumn; dxDBGrid6USD: TdxDBGridColumn; dxDBGrid6RMB: TdxDBGridColumn; dxDBGrid6Column5: TdxDBGridColumn; dxDBGrid6Column6: TdxDBGridColumn; dxDBGrid6Column7: TdxDBGridColumn; dxDBGrid6Column8: TdxDBGridColumn; dxDBGrid6Column9: TdxDBGridColumn; dxDBGrid6Column10: TdxDBGridColumn; dxDBGrid2: TdxDBGrid; dxDBGridMaskColumn1: TdxDBGridMaskColumn; dxDBGridColumn1: TdxDBGridColumn; dxDBGridColumn2: TdxDBGridColumn; dxDBGridColumn3: TdxDBGridColumn; dxDBGridColumn4: TdxDBGridColumn; dxDBGridColumn5: TdxDBGridColumn; dxDBGridColumn6: TdxDBGridColumn; dxDBGridColumn7: TdxDBGridColumn; dxDBGridColumn8: TdxDBGridColumn; dxDBGridColumn9: TdxDBGridColumn; Edit1: TEdit; Label4: TLabel; Edit2: TEdit; Label6: TLabel; Label8: TLabel; Edit3: TEdit; procedure bsSkinButton5Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure bsSkinButton10Click(Sender: TObject); procedure bsSkinButton9Click(Sender: TObject); procedure dxDBGrid1ColumnSorting(Sender: TObject; Column: TdxDBTreeListColumn; var Allow: Boolean); procedure dxDBGrid6ColumnSorting(Sender: TObject; Column: TdxDBTreeListColumn; var Allow: Boolean); procedure dxDBGrid2ColumnSorting(Sender: TObject; Column: TdxDBTreeListColumn; var Allow: Boolean); private { Private declarations } public { Public declarations } end; var frm_rp_in_ch: Tfrm_rp_in_ch; implementation uses u_main, my_sys_function; {$R *.dfm} procedure Tfrm_rp_in_ch.bsSkinButton5Click(Sender: TObject); begin close; end; procedure Tfrm_rp_in_ch.FormClose(Sender: TObject; var Action: TCloseAction); begin frm_rp_in_ch.Hide; frm_rp_in_ch.ManualFloat(frm_rp_in_ch.BoundsRect ); frm_main.freeTabs('frm_rp_in_ch'); action:=cafree; frm_rp_in_ch:=nil; end; procedure Tfrm_rp_in_ch.bsSkinButton10Click(Sender: TObject); var str:widestring; begin str:='where '+open_data('0035','制单人','申请人','no','no','no'); if wwDBDateTimePicker1.TEXT<>''then begin str:=str+' and 开票日期>='+''''+wwDBDateTimePicker1.TEXT+''''; end; if wwDBDateTimePicker2.TEXT<>''then begin str:=str+' and 开票日期<='+''''+wwDBDateTimePicker2.TEXT+''''; end; if (Edit1.TEXT<>'')and(Edit2.TEXT<>'')then begin str:=str+' and (发票号码 between '+''''+Edit1.TEXT+'''' +' and '+''''+Edit2.TEXT+''''+')'; end else begin if Edit1.TEXT<>''then begin str:=str+' and 发票号码 like '+''''+'%'+Edit1.TEXT+'%'+''''; end; if Edit2.TEXT<>''then begin str:=str+' and 发票号码 like '+''''+'%'+Edit2.TEXT+'%'+''''; end; end; if RxDBLookupCombo2.DisplayValues[1]<>''then begin str:=str+' and 客户名称='+''''+RxDBLookupCombo2.DisplayValues[1]+''''; end; if wwDBComboBox1.text<>''then begin str:=str+' and 发票类别='+''''+wwDBComboBox1.text+''''; end; if RxDBLookupCombo3.DisplayValues[0]<>''then begin str:=str+' and 申请人='+''''+RxDBLookupCombo3.DisplayValues[0]+''''; end; if RxDBLookupCombo4.DisplayValues[0]<>''then begin str:=str+' and 废除人='+''''+RxDBLookupCombo4.DisplayValues[0]+''''; end; if RxDBLookupCombo6.DisplayValues[0]<>''then begin str:=str+' and 制单人='+''''+RxDBLookupCombo6.DisplayValues[0]+''''; end; if RxDBLookupCombo1.DisplayValues[0]<>''then begin str:=str+' and 币别='+''''+RxDBLookupCombo1.DisplayValues[0]+''''; end; if wwDBComboBox3.ItemIndex<>-1 then begin str:=str+' and 是否废除='+inttostr(wwDBComboBox3.ItemIndex); end; if Edit3.TEXT<>''then begin str:=str+' and 合计金额='+Edit3.TEXT; end; p_detail.close; p_detail.Parameters.ParamByName('SQLStr').value:= 'select * from t_ch_invoice '+str+' order by 发票号码'; p_detail.open; p_client.close; p_client.Parameters.ParamByName('SQLStr').value:= 'select 客户名称,count(发票号码) as 发票总数' +',sum(case 币别 when '+''''+'USD'+''''+' THEN 1 ELSE 0 END) AS USD张数' +',sum(case 币别 when '+''''+'USD'+''''+' THEN 0 ELSE 1 END) AS RMB张数' +',sum(case 币别 when '+''''+'USD'+''''+' THEN 合计金额 ELSE 0 END) AS USD发票金额' +',sum(case 币别 when '+''''+'USD'+''''+' THEN 实际金额 ELSE 0 END) AS USD实际金额' +',sum(case 币别 when '+''''+'USD'+''''+' THEN 虚开金额 ELSE 0 END) AS USD虚开金额' +',sum(case 币别 when '+''''+'USD'+''''+' THEN 0 ELSE 合计金额 END) AS RMB发票金额' +',sum(case 币别 when '+''''+'USD'+''''+' THEN 0 ELSE 实际金额 END) AS RMB实际金额' +',sum(case 币别 when '+''''+'USD'+''''+' THEN 0 ELSE 虚开金额 END) AS RMB虚开金额' +' FROM T_CH_INVOICE '+str+' GROUP BY 客户名称 ORDER BY 客户名称 '; p_client.open; p_shen.close; p_shen.Parameters.ParamByName('SQLStr').value:= 'select 申请人,count(发票号码) as 发票总数' +',sum(case 币别 when '+''''+'USD'+''''+' THEN 1 ELSE 0 END) AS USD张数' +',sum(case 币别 when '+''''+'USD'+''''+' THEN 0 ELSE 1 END) AS RMB张数' +',sum(case 币别 when '+''''+'USD'+''''+' THEN 合计金额 ELSE 0 END) AS USD发票金额' +',sum(case 币别 when '+''''+'USD'+''''+' THEN 实际金额 ELSE 0 END) AS USD实际金额' +',sum(case 币别 when '+''''+'USD'+''''+' THEN 虚开金额 ELSE 0 END) AS USD虚开金额' +',sum(case 币别 when '+''''+'USD'+''''+' THEN 0 ELSE 合计金额 END) AS RMB发票金额' +',sum(case 币别 when '+''''+'USD'+''''+' THEN 0 ELSE 实际金额 END) AS RMB实际金额' +',sum(case 币别 when '+''''+'USD'+''''+' THEN 0 ELSE 虚开金额 END) AS RMB虚开金额' +' FROM T_CH_INVOICE '+str+' GROUP BY 申请人 ORDER BY 申请人 '; p_shen.open; end; procedure Tfrm_rp_in_ch.bsSkinButton9Click(Sender: TObject); begin sys_print('财务发票统计',2,nil,nil,nil,nil,p_detail1,p_client1,p_shen1,nil,nil,nil,nil); end; procedure Tfrm_rp_in_ch.dxDBGrid1ColumnSorting(Sender: TObject; Column: TdxDBTreeListColumn; var Allow: Boolean); begin Column_sort_pro(Column,p_detail,'发票号码'); end; procedure Tfrm_rp_in_ch.dxDBGrid6ColumnSorting(Sender: TObject; Column: TdxDBTreeListColumn; var Allow: Boolean); begin Column_sort_pro(Column,p_client,'客户名称'); end; procedure Tfrm_rp_in_ch.dxDBGrid2ColumnSorting(Sender: TObject; Column: TdxDBTreeListColumn; var Allow: Boolean); begin Column_sort_pro(Column,p_shen,'申请人'); end; end.