unit u_rp_wl_total; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, bsSkinCtrls, ExtCtrls, ComCtrls, bsSkinTabs, DB, ADODB,DateUtils, dxExEdtr, dxDBTLCl, dxGrClms, dxDBGrid, dxTL, dxDBCtrl, dxCntner, kbmMemTable, kbmMemBinaryStreamFormat, Menus, StdCtrls, wwdbdatetimepicker, Grids, DBGridEh, Mask, wwdbedit, Wwdotdot, Wwdbcomb, RxLookup, DBGrids; type Tfrm_rp_wl_total = class(TForm) Panel1: TPanel; bsSkinPanel2: TbsSkinPanel; bsSkinButton10: TbsSkinButton; bsSkinButton9: TbsSkinButton; bsSkinButton1: TbsSkinButton; bsSkinButton5: TbsSkinButton; SaveDialog: TSaveDialog; bsSkinPanel1: TbsSkinPanel; bsSkinPageControl1: TbsSkinPageControl; bsSkinTabSheet1: TbsSkinTabSheet; bsSkinRadioGroup1: TbsSkinRadioGroup; Label2: TLabel; cbmonth: TwwDBComboBox; Label1: TLabel; cbYear: TwwDBComboBox; t_ch_custbalance: TADOQuery; dxDBGrid1: TdxDBGrid; dxDBGrid1Column1: TdxDBGridColumn; dxDBGrid1Column2: TdxDBGridColumn; dxDBGrid1Column6: TdxDBGridColumn; dxDBGrid1Column8: TdxDBGridColumn; dxDBGrid1Column9: TdxDBGridColumn; dxDBGrid1Column10: TdxDBGridColumn; bsSkinPanel3: TbsSkinPanel; bsSkinCheckRadioBox1: TbsSkinCheckRadioBox; bsSkinCheckRadioBox2: TbsSkinCheckRadioBox; bsSkinCheckRadioBox3: TbsSkinCheckRadioBox; t_ch_custbalance1: TDataSource; dxDBGrid1Column7: 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; dxDBGrid1Column23: TdxDBGridColumn; dxDBGrid1Column24: TdxDBGridColumn; dxDBGrid1Column25: TdxDBGridColumn; dxDBGrid1Column26: TdxDBGridColumn; dxDBGrid1Column27: TdxDBGridColumn; dxDBGrid1Column28: TdxDBGridColumn; dxDBGrid1Column29: TdxDBGridColumn; dxDBGrid1Column30: TdxDBGridColumn; RxDBLookupCombo12: TRxDBLookupCombo; Label22: TLabel; Label14: TLabel; RxDBLookupCombo3: TRxDBLookupCombo; Label40: TLabel; RxDBLookupCombo15: TRxDBLookupCombo; procedure bsSkinButton5Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure Panel1Resize(Sender: TObject); procedure bsSkinButton10Click(Sender: TObject); procedure bsSkinButton9Click(Sender: TObject); procedure FormShow(Sender: TObject); procedure bsSkinButton1Click(Sender: TObject); procedure bsSkinCheckRadioBox3Click(Sender: TObject); procedure bsSkinRadioGroup1Checked(Sender: TObject); private { Private declarations } public { Public declarations } end; var frm_rp_wl_total: Tfrm_rp_wl_total; FmDate,ToDate:String; sqlstr:WideString; implementation uses u_main, my_sys_function,u_sys_progress, u_data_share; {$R *.dfm} procedure Tfrm_rp_wl_total.bsSkinButton5Click(Sender: TObject); begin close; end; procedure Tfrm_rp_wl_total.FormClose(Sender: TObject; var Action: TCloseAction); begin frm_rp_wl_total.Hide; frm_rp_wl_total.ManualFloat(frm_rp_wl_total.BoundsRect ); frm_main.freeTabs('frm_rp_wl_total'); action:=cafree; frm_rp_wl_total:=nil; end; procedure Tfrm_rp_wl_total.Panel1Resize(Sender: TObject); var i:integer; begin i:=round(bsSkinPanel2.Width/7); bsSkinButton10.Width:=i; bsSkinButton9.Width:=i; bsSkinButton1.Width:=i; end; procedure Tfrm_rp_wl_total.bsSkinButton10Click(Sender: TObject); var objname:string; begin if cbyear.Text='' then begin MessageDlg('统计年不能为空!',mtWarning,[mbOk],0); exit; end; if cbmonth.Text='' then begin MessageDlg('统计月份不能为空!',mtWarning,[mbOk],0); exit; end; with t_ch_custbalance,sql do begin close;sql.Clear; objname:=bsSkinRadioGroup1.Items.Strings[bsSkinRadioGroup1.ItemIndex]; dxDBGrid1Column6.Caption:=objname; Add('select 年,月,'+objname+' as 客户名称'); Add(',sum(上月应收结余) as 上月应收结余,sum(本月应收发生) as 本月应收发生,sum(本月应收核销) as 本月应收核销,sum(本月应收结余) as 本月应收结余,sum(上月应收结余USD) as 上月应收结余USD,sum(本月应收发生USD) as 本月应收发生USD'); Add(',sum(本月应收核销USD) as 本月应收核销USD,sum(本月应收结余USD) as 本月应收结余USD,sum(上月应付结余) as 上月应付结余,sum(本月应付发生) as 本月应付发生,sum(本月应付核销) as 本月应付核销,sum(本月应付结余) as 本月应付结余'); Add(',sum(上月应付结余USD) as 上月应付结余USD,sum(本月应付发生USD) as 本月应付发生USD,sum(本月应付核销USD) as 本月应付核销USD,sum(本月应付结余USD) as 本月应付结余USD'); Add(',sum(上月应收结余合计) as 上月应收结余合计,sum(本月应收发生合计) as 本月应收发生合计,sum(本月应收核销合计) as 本月应收核销合计,sum(本月应收结余合计) as 本月应收结余合计'); Add(',sum(上月应付结余合计) as 上月应付结余合计,sum(本月应付发生合计) as 本月应付发生合计,sum(本月应付核销合计) as 本月应付核销合计,sum(本月应付结余合计) as 本月应付结余合计'); Add(' from t_ch_custbalance where 年='+cbyear.text+' and 月='+cbmonth.text); if bsSkinCheckRadioBox3.Checked then Add(' and (本月应收结余合计<>0 or 上月应收结余合计<>0 or 本月应收发生合计<>0 or 本月应收核销合计<>0)'); if bsSkinCheckRadioBox2.Checked then Add(' and (本月应付结余合计<>0 or 上月应付结余合计<>0 or 本月应付发生合计<>0 or 本月应付核销合计<>0)'); if RxDBLookupCombo12.DisplayValue<>'' then Add(' and 销售部门='''+RxDBLookupCombo12.DisplayValue+''''); if RxDBLookupCombo3.DisplayValue<>'' then Add(' and 揽货人='''+RxDBLookupCombo3.DisplayValue+''''); if RxDBLookupCombo15.DisplayValue<>'' then Add(' and 分部名称='''+RxDBLookupCombo15.DisplayValue+''''); Add(' group by 年,月,'+objname); open; end; t_ch_custbalance.open; end; procedure Tfrm_rp_wl_total.bsSkinButton9Click(Sender: TObject); begin sys_print('往来总帐报表',2,t_ch_custbalance1,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil); end; procedure Tfrm_rp_wl_total.FormShow(Sender: TObject); begin cbYear.ItemIndex:=cbYear.Items.IndexOf(inttostr(Logininfo.offyear)); cbmonth.ItemIndex:=cbmonth.Items.IndexOf(inttostr(Logininfo.offmonth)); bsSkinCheckRadioBox3.OnClick(sender); end; procedure Tfrm_rp_wl_total.bsSkinButton1Click(Sender: TObject); begin grid_save_xls(dxdbgrid1); end; procedure Tfrm_rp_wl_total.bsSkinCheckRadioBox3Click(Sender: TObject); begin if bsSkinCheckRadioBox3.Checked then begin dxDBGrid1Column8.Visible:=true; dxDBGrid1Column9.Visible:=true; dxDBGrid1Column10.Visible:=true; dxDBGrid1Column7.Visible:=false; dxDBGrid1Column11.Visible:=false; dxDBGrid1Column12.Visible:=false; dxDBGrid1Column13.Visible:=true; dxDBGrid1Column14.Visible:=true; dxDBGrid1Column15.Visible:=true; dxDBGrid1Column16.Visible:=false; dxDBGrid1Column17.Visible:=false; dxDBGrid1Column18.Visible:=false; dxDBGrid1Column19.Visible:=true; dxDBGrid1Column20.Visible:=true; dxDBGrid1Column21.Visible:=true; dxDBGrid1Column22.Visible:=false; dxDBGrid1Column23.Visible:=false; dxDBGrid1Column24.Visible:=false; dxDBGrid1Column25.Visible:=true; dxDBGrid1Column26.Visible:=true; dxDBGrid1Column27.Visible:=true; dxDBGrid1Column28.Visible:=false; dxDBGrid1Column29.Visible:=false; dxDBGrid1Column30.Visible:=false; end; if bsSkinCheckRadioBox2.Checked then begin dxDBGrid1Column8.Visible:=false; dxDBGrid1Column9.Visible:=false; dxDBGrid1Column10.Visible:=false; dxDBGrid1Column7.Visible:=true; dxDBGrid1Column11.Visible:=true; dxDBGrid1Column12.Visible:=true; dxDBGrid1Column13.Visible:=false; dxDBGrid1Column14.Visible:=false; dxDBGrid1Column15.Visible:=false; dxDBGrid1Column16.Visible:=true; dxDBGrid1Column17.Visible:=true; dxDBGrid1Column18.Visible:=true; dxDBGrid1Column19.Visible:=false; dxDBGrid1Column20.Visible:=false; dxDBGrid1Column21.Visible:=false; dxDBGrid1Column22.Visible:=true; dxDBGrid1Column23.Visible:=true; dxDBGrid1Column24.Visible:=true; dxDBGrid1Column25.Visible:=false; dxDBGrid1Column26.Visible:=false; dxDBGrid1Column27.Visible:=false; dxDBGrid1Column28.Visible:=true; dxDBGrid1Column29.Visible:=true; dxDBGrid1Column30.Visible:=true; end; if bsSkinCheckRadioBox1.Checked then begin dxDBGrid1Column8.Visible:=true; dxDBGrid1Column9.Visible:=true; dxDBGrid1Column10.Visible:=true; dxDBGrid1Column7.Visible:=true; dxDBGrid1Column11.Visible:=true; dxDBGrid1Column12.Visible:=true; dxDBGrid1Column13.Visible:=true; dxDBGrid1Column14.Visible:=true; dxDBGrid1Column15.Visible:=true; dxDBGrid1Column16.Visible:=true; dxDBGrid1Column17.Visible:=true; dxDBGrid1Column18.Visible:=true; dxDBGrid1Column19.Visible:=true; dxDBGrid1Column20.Visible:=true; dxDBGrid1Column21.Visible:=true; dxDBGrid1Column22.Visible:=true; dxDBGrid1Column23.Visible:=true; dxDBGrid1Column24.Visible:=true; dxDBGrid1Column25.Visible:=true; dxDBGrid1Column26.Visible:=true; dxDBGrid1Column27.Visible:=true; dxDBGrid1Column28.Visible:=true; dxDBGrid1Column29.Visible:=true; dxDBGrid1Column30.Visible:=true; end; end; procedure Tfrm_rp_wl_total.bsSkinRadioGroup1Checked(Sender: TObject); begin bsSkinButton10.OnClick(sender); end; end.