unit u_rp_ch_balance_accept; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DB, ADODB, dxExEdtr, dxCntner, dxTL, dxDBCtrl, dxDBGrid, dxDBTLCl, dxGrClms, ComCtrls, bsSkinTabs, bsSkinCtrls, Menus, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, cxDBData, cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGridLevel, cxClasses, cxControls, cxGridCustomView, cxGrid; type Tfrm_rp_ch_balance_accept = class(TForm) p_detail: TADOStoredProc; p_detail1: TDataSource; bsSkinPageControl1: TbsSkinPageControl; bsSkinTabSheet1: TbsSkinTabSheet; bsSkinTabSheet2: TbsSkinTabSheet; bsSkinTabSheet3: TbsSkinTabSheet; p_total: TADOStoredProc; p_total1: TDataSource; dxDBGrid2: TdxDBGrid; dxDBGridMaskColumn3: TdxDBGridMaskColumn; dxDBGridMaskColumn6: TdxDBGridMaskColumn; dxDBGridColumn1: TdxDBGridColumn; dxDBGridColumn2: TdxDBGridColumn; dxDBGridColumn3: TdxDBGridColumn; RadioGroup1: TbsSkinRadioGroup; p_currency: TADOStoredProc; p_currency1: TDataSource; dxDBGrid3: TdxDBGrid; dxDBGridMaskColumn2: TdxDBGridMaskColumn; dxDBGridColumn4: TdxDBGridColumn; dxDBGridColumn5: TdxDBGridColumn; dxDBGridColumn6: TdxDBGridColumn; dxDBGrid2Column6: TdxDBGridColumn; dxDBGrid3Column5: TdxDBGridColumn; bsSkinPanel1: TbsSkinPanel; bsSkinButton10: TbsSkinButton; bsSkinButton9: TbsSkinButton; bsSkinButton5: TbsSkinButton; dxDBGrid4: TdxDBGrid; dxDBGridMaskColumn1: TdxDBGridMaskColumn; dxDBGridColumn7: TdxDBGridColumn; dxDBGridColumn8: TdxDBGridColumn; dxDBGrid5: TdxDBGrid; dxDBGridMaskColumn5: TdxDBGridMaskColumn; dxDBGridColumn11: TdxDBGridColumn; dxDBGridColumn12: TdxDBGridColumn; dxDBGridColumn13: TdxDBGridColumn; dxDBGridColumn14: TdxDBGridColumn; p_sales: TADOStoredProc; p_sales1: TDataSource; bsSkinButton1: TbsSkinButton; PopupMenu2: TPopupMenu; N10: TMenuItem; N11: TMenuItem; N14: TMenuItem; N15: TMenuItem; N16: TMenuItem; bsSkinPageControl2: TbsSkinPageControl; tabsheet1: TbsSkinTabSheet; dxDBGrid1: TdxDBGrid; dxDBGrid1Column1: TdxDBGridMaskColumn; dxDBGrid1Column3: TdxDBGridMaskColumn; dxDBGrid1Column6: TdxDBGridMaskColumn; dxDBGrid1Column2: TdxDBGridMaskColumn; dxDBGrid1Column4: TdxDBGridMaskColumn; dxDBGrid1Column5: TdxDBGridMaskColumn; dxDBGrid1Column7: TdxDBGridColumn; dxDBGrid1Column8: TdxDBGridColumn; dxDBGrid1Column9: TdxDBGridColumn; dxDBGrid1Column10: TdxDBGridMaskColumn; dxDBGrid1Column21: TdxDBGridMaskColumn; dxDBGrid1Column11: TdxDBGridMaskColumn; dxDBGrid1Column12: TdxDBGridMaskColumn; dxDBGrid1Column13: TdxDBGridDateColumn; dxDBGrid1Column19: TdxDBGridMaskColumn; dxDBGrid1Column20: TdxDBGridDateColumn; dxDBGrid1Column16: TdxDBGridMaskColumn; dxDBGrid1Column17: TdxDBGridDateColumn; tabsheet2: TbsSkinTabSheet; tabsheet3: TbsSkinTabSheet; p_detail_bill1: TDataSource; p_detail_bill: TADOStoredProc; p_detail_fee1: TDataSource; p_detail_fee: TADOStoredProc; dxDBGrid9: TdxDBGrid; dxDBGridMaskColumn43: TdxDBGridMaskColumn; dxDBGridMaskColumn44: TdxDBGridMaskColumn; dxDBGridMaskColumn45: TdxDBGridMaskColumn; dxDBGridMaskColumn46: TdxDBGridMaskColumn; dxDBGridMaskColumn47: TdxDBGridMaskColumn; dxDBGridColumn17: TdxDBGridColumn; dxDBGridColumn18: TdxDBGridColumn; dxDBGridMaskColumn48: TdxDBGridMaskColumn; dxDBGridColumn19: TdxDBGridColumn; dxDBGridDateColumn10: TdxDBGridDateColumn; dxDBGridDateColumn11: TdxDBGridDateColumn; dxDBGridMaskColumn49: TdxDBGridMaskColumn; dxDBGridMaskColumn50: TdxDBGridMaskColumn; dxDBGridMaskColumn51: TdxDBGridMaskColumn; dxDBGridMaskColumn52: TdxDBGridMaskColumn; dxDBGridMaskColumn53: TdxDBGridMaskColumn; dxDBGridColumn20: TdxDBGridColumn; dxDBGridColumn21: TdxDBGridColumn; dxDBGridMaskColumn54: TdxDBGridMaskColumn; dxDBGridMaskColumn55: TdxDBGridMaskColumn; dxDBGridMaskColumn56: TdxDBGridMaskColumn; dxDBGridMaskColumn57: TdxDBGridMaskColumn; dxDBGrid6: TdxDBGrid; dxDBGridMaskColumn4: TdxDBGridMaskColumn; dxDBGridMaskColumn7: TdxDBGridMaskColumn; dxDBGridMaskColumn8: TdxDBGridMaskColumn; dxDBGridMaskColumn9: TdxDBGridMaskColumn; dxDBGridDateColumn1: TdxDBGridDateColumn; dxDBGridDateColumn2: TdxDBGridDateColumn; dxDBGridMaskColumn12: TdxDBGridMaskColumn; dxDBGridMaskColumn13: TdxDBGridMaskColumn; dxDBGridMaskColumn14: TdxDBGridMaskColumn; dxDBGridMaskColumn15: TdxDBGridMaskColumn; dxDBGridMaskColumn16: TdxDBGridMaskColumn; dxDBGridColumn16: TdxDBGridColumn; dxDBGridColumn22: TdxDBGridColumn; dxDBGridMaskColumn17: TdxDBGridMaskColumn; dxDBGridMaskColumn18: TdxDBGridMaskColumn; dxDBGridMaskColumn19: TdxDBGridMaskColumn; dxDBGridMaskColumn20: TdxDBGridMaskColumn; dxDBGrid6Column18: TdxDBGridColumn; dxDBGrid6Column19: TdxDBGridColumn; dxDBGrid6Column20: TdxDBGridColumn; dxDBGrid9Column23: TdxDBGridColumn; dxDBGrid6Column21: TdxDBGridColumn; dxDBGrid6Column22: TdxDBGridColumn; dxDBGrid6Column23: TdxDBGridColumn; dxDBGrid9Column24: TdxDBGridColumn; dxDBGrid9Column25: TdxDBGridColumn; dxDBGrid9Column26: TdxDBGridColumn; dxDBGrid6Column24: TdxDBGridColumn; dxDBGrid9Column27: TdxDBGridColumn; dxDBGrid6Column25: TdxDBGridColumn; dxDBGrid6Column26: TdxDBGridColumn; dxDBGrid1Column22: TdxDBGridColumn; dxDBGrid1Column23: TdxDBGridColumn; dxDBGrid1Column24: TdxDBGridColumn; dxDBGrid2Column7: TdxDBGridColumn; dxDBGrid2Column8: TdxDBGridColumn; dxDBGrid3Column6: TdxDBGridColumn; dxDBGrid3Column7: TdxDBGridColumn; dxDBGrid5Column6: TdxDBGridColumn; dxDBGrid5Column7: TdxDBGridColumn; dxDBGrid6Column27: TdxDBGridColumn; dxDBGrid6Column28: TdxDBGridColumn; dxDBGrid6Column29: TdxDBGridColumn; dxDBGrid6Column30: TdxDBGridColumn; dxDBGrid1Column25: TdxDBGridColumn; dxDBGrid6Column31: TdxDBGridColumn; dxDBGrid9Column28: TdxDBGridColumn; cxGrid1DBTableView1: TcxGridDBTableView; cxGrid1Level1: TcxGridLevel; cxGrid1: TcxGrid; cxGrid1DBTableView1DBColumn1: TcxGridDBColumn; cxGrid1DBTableView1DBColumn2: TcxGridDBColumn; cxGrid1DBTableView1DBColumn3: TcxGridDBColumn; cxGrid1DBTableView1DBColumn4: TcxGridDBColumn; cxGrid1DBTableView1DBColumn5: TcxGridDBColumn; cxGrid1DBTableView1DBColumn6: TcxGridDBColumn; cxGrid1DBTableView1DBColumn7: TcxGridDBColumn; cxGrid1DBTableView1DBColumn8: TcxGridDBColumn; cxGrid1DBTableView1DBColumn9: TcxGridDBColumn; cxGrid1DBTableView1DBColumn10: TcxGridDBColumn; cxGrid1DBTableView1DBColumn11: TcxGridDBColumn; cxGrid1DBTableView1DBColumn12: TcxGridDBColumn; cxGrid1DBTableView1DBColumn13: TcxGridDBColumn; cxGrid1DBTableView1DBColumn14: TcxGridDBColumn; cxGrid1DBTableView1DBColumn15: TcxGridDBColumn; cxGrid1DBTableView1DBColumn16: TcxGridDBColumn; cxGrid1DBTableView1DBColumn17: TcxGridDBColumn; cxGrid1DBTableView1DBColumn18: TcxGridDBColumn; cxGrid1DBTableView1DBColumn19: TcxGridDBColumn; cxGrid1DBTableView1DBColumn20: TcxGridDBColumn; cxGrid1DBTableView1DBColumn21: TcxGridDBColumn; cxGrid1DBTableView1DBColumn22: TcxGridDBColumn; cxGrid1DBTableView1DBColumn23: TcxGridDBColumn; cxGrid1DBTableView1DBColumn24: TcxGridDBColumn; cxGrid1DBTableView1DBColumn25: TcxGridDBColumn; cxGrid1DBTableView1DBColumn26: TcxGridDBColumn; cxGrid1DBTableView1DBColumn27: TcxGridDBColumn; cxGrid1DBTableView1DBColumn28: TcxGridDBColumn; cxGrid1DBTableView1DBColumn29: TcxGridDBColumn; cxGrid1DBTableView1DBColumn30: TcxGridDBColumn; cxGrid1DBTableView1DBColumn31: TcxGridDBColumn; procedure bsSkinButton5Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormShow(Sender: TObject); procedure bsSkinPageControl1Resize(Sender: TObject); procedure bsSkinButton10Click(Sender: TObject); procedure bsSkinPageControl1Change(Sender: TObject); procedure RadioGroup1Click(Sender: TObject); procedure bsSkinButton9Click(Sender: TObject); procedure bsSkinButton1Click(Sender: TObject); procedure N16Click(Sender: TObject); procedure N10Click(Sender: TObject); procedure N14Click(Sender: TObject); procedure dxDBGrid6DblClick(Sender: TObject); private { Private declarations } public { Public declarations } end; var frm_rp_ch_balance_accept: Tfrm_rp_ch_balance_accept; frm_rp_ch_balance_accept_open:boolean; frm_rp_ch_balance_accept_str:widestring; implementation uses u_main, u_ch_balance_query, my_sys_function, u_rp_ch_balance_view; {$R *.dfm} procedure Tfrm_rp_ch_balance_accept.bsSkinButton5Click(Sender: TObject); begin close; end; procedure Tfrm_rp_ch_balance_accept.FormClose(Sender: TObject; var Action: TCloseAction); begin savereggrid(dxdbgrid1,caption+'1'); savereggrid(dxdbgrid6,caption+'2'); savereggrid(dxdbgrid9,caption+'3'); frm_rp_ch_balance_accept_open:=false; frm_rp_ch_balance_accept.Hide; frm_rp_ch_balance_accept.ManualFloat(frm_rp_ch_balance_accept.BoundsRect ); frm_main.freeTabs('frm_rp_ch_balance_accept'); action:=cafree; frm_rp_ch_balance_accept:=nil; end; procedure Tfrm_rp_ch_balance_accept.FormShow(Sender: TObject); begin loadreggrid(dxdbgrid1,false,caption+'1'); loadreggrid(dxdbgrid6,false,caption+'2'); loadreggrid(dxdbgrid9,false,caption+'3'); frm_rp_ch_balance_accept_open:=true; if StrToBool(get_parameters_value(83,'false')) then begin dxdbgrid1.ColumnByFieldName('币别').Visible:=false; dxdbgrid1.ColumnByFieldName('结算金额').Visible:=False; dxdbgrid1.ColumnByFieldName('实结金额').Visible:=false; dxdbgrid1.ColumnByFieldName('虚结金额').Visible:=False; dxdbgrid1.ColumnByFieldName('美元金额').Visible:=True; dxdbgrid1.ColumnByFieldName('人民币金额').Visible:=True; dxdbgrid1.ColumnByFieldName('美元银行').Visible:=True; dxdbgrid2.ColumnByFieldName('币别').Visible:=false; dxdbgrid2.ColumnByFieldName('结算金额').Visible:=False; dxdbgrid2.ColumnByFieldName('实结金额').Visible:=false; dxdbgrid2.ColumnByFieldName('虚结金额').Visible:=False; dxdbgrid2.ColumnByFieldName('美元金额').Visible:=True; dxdbgrid2.ColumnByFieldName('人民币金额').Visible:=True; dxdbgrid3.ColumnByFieldName('币别').Visible:=false; dxdbgrid3.ColumnByFieldName('结算金额').Visible:=False; dxdbgrid3.ColumnByFieldName('实结金额').Visible:=false; dxdbgrid3.ColumnByFieldName('虚结金额').Visible:=False; dxdbgrid3.ColumnByFieldName('美元金额').Visible:=True; dxdbgrid3.ColumnByFieldName('人民币金额').Visible:=True; dxdbgrid5.ColumnByFieldName('币别').Visible:=false; dxdbgrid5.ColumnByFieldName('结算金额').Visible:=False; dxdbgrid5.ColumnByFieldName('实结金额').Visible:=false; dxdbgrid5.ColumnByFieldName('虚结金额').Visible:=False; dxdbgrid5.ColumnByFieldName('美元金额').Visible:=True; dxdbgrid5.ColumnByFieldName('人民币金额').Visible:=True; end else begin dxdbgrid1.ColumnByFieldName('币别').Visible:=True; dxdbgrid1.ColumnByFieldName('结算金额').Visible:=True; dxdbgrid1.ColumnByFieldName('实结金额').Visible:=True; dxdbgrid1.ColumnByFieldName('虚结金额').Visible:=True; dxdbgrid1.ColumnByFieldName('美元金额').Visible:=False; dxdbgrid1.ColumnByFieldName('人民币金额').Visible:=False; dxdbgrid1.ColumnByFieldName('美元银行').Visible:=false; dxdbgrid2.ColumnByFieldName('币别').Visible:=True; dxdbgrid2.ColumnByFieldName('结算金额').Visible:=True; dxdbgrid2.ColumnByFieldName('实结金额').Visible:=True; dxdbgrid2.ColumnByFieldName('虚结金额').Visible:=True; dxdbgrid2.ColumnByFieldName('美元金额').Visible:=False; dxdbgrid2.ColumnByFieldName('人民币金额').Visible:=False; dxdbgrid3.ColumnByFieldName('币别').Visible:=True; dxdbgrid3.ColumnByFieldName('结算金额').Visible:=True; dxdbgrid3.ColumnByFieldName('实结金额').Visible:=True; dxdbgrid3.ColumnByFieldName('虚结金额').Visible:=True; dxdbgrid3.ColumnByFieldName('美元金额').Visible:=False; dxdbgrid3.ColumnByFieldName('人民币金额').Visible:=False; dxdbgrid5.ColumnByFieldName('币别').Visible:=True; dxdbgrid5.ColumnByFieldName('结算金额').Visible:=True; dxdbgrid5.ColumnByFieldName('实结金额').Visible:=True; dxdbgrid5.ColumnByFieldName('虚结金额').Visible:=True; dxdbgrid5.ColumnByFieldName('美元金额').Visible:=False; dxdbgrid5.ColumnByFieldName('人民币金额').Visible:=False; end; end; procedure Tfrm_rp_ch_balance_accept.bsSkinPageControl1Resize( Sender: TObject); begin bsSkinPanel1.Left:=bsSkinPageControl1.Width-bsSkinPanel1.Width-5; end; procedure Tfrm_rp_ch_balance_accept.bsSkinButton10Click(Sender: TObject); begin try frm_ch_balance_query:=tfrm_ch_balance_query.Create (self); balance_query_type:=6; frm_ch_balance_query.ShowModal; finally frm_ch_balance_query.Free; end; end; procedure Tfrm_rp_ch_balance_accept.bsSkinPageControl1Change( Sender: TObject); begin if frm_rp_ch_balance_accept_open then begin if bsSkinTabSheet2.Showing then frm_rp_ch_balance_accept.RadioGroup1Click(Sender); end; end; procedure Tfrm_rp_ch_balance_accept.RadioGroup1Click(Sender: TObject); var str:widestring; begin if p_detail.Active then begin if StrToBool(get_parameters_value(83,'false')) then begin str:='select '+RadioGroup1.Items[RadioGroup1.ItemIndex] +' as 统计标准,'+''''+RadioGroup1.Items[RadioGroup1.ItemIndex]+'''' +' as base,sum(人民币金额) as 人民币金额,sum(美元金额) as 美元金额' +',count(帐单编号) as 笔数' +' from t_ch_balance '+frm_rp_ch_balance_accept_str +' group by '+RadioGroup1.Items[RadioGroup1.ItemIndex] +',币别' +' order by '+RadioGroup1.Items[RadioGroup1.ItemIndex]; end else begin str:='select '+RadioGroup1.Items[RadioGroup1.ItemIndex] +' as 统计标准,'+''''+RadioGroup1.Items[RadioGroup1.ItemIndex]+'''' +' as base,币别,sum(结算金额) as 结算金额,sum(实结金额) as 实结金额,sum(虚结金额) as 虚结金额' +',count(帐单编号) as 笔数' +' from t_ch_balance '+frm_rp_ch_balance_accept_str +' group by '+RadioGroup1.Items[RadioGroup1.ItemIndex] +',币别' +' order by '+RadioGroup1.Items[RadioGroup1.ItemIndex]; end; p_total.close; p_total.Parameters.ParamByName('SQLStr').value:=str; p_total.open; dxDBGridMaskColumn3.Caption:=RadioGroup1.Items[RadioGroup1.ItemIndex]; end; end; procedure Tfrm_rp_ch_balance_accept.bsSkinButton9Click(Sender: TObject); begin sys_print('应收结算统计',2,nil,nil,nil,nil,p_detail1,p_total1,p_sales1,p_currency1,p_detail_bill1,p_detail_fee1,nil); end; procedure Tfrm_rp_ch_balance_accept.bsSkinButton1Click(Sender: TObject); begin if (not p_detail.active)or(p_detail.IsEmpty)then begin showmessage('没有帐单信息!'); exit; end; try if not assigned(frm_rp_ch_balance_view) then frm_rp_ch_balance_view:=tfrm_rp_ch_balance_view.Create (self); with frm_rp_ch_balance_view do begin v_fee_do_seae.Parameters.ParamByName('帐单编号').value:= p_detail.fieldbyname('帐单编号').asstring; v_fee_do_seae.open; v_fee_do_seai.Parameters.ParamByName('帐单编号').value:= p_detail.fieldbyname('帐单编号').asstring; v_fee_do_seai.open; v_fee_do_aire.Parameters.ParamByName('帐单编号').value:= p_detail.fieldbyname('帐单编号').asstring; v_fee_do_aire.open; v_fee_do_airi.Parameters.ParamByName('帐单编号').value:= p_detail.fieldbyname('帐单编号').asstring; v_fee_do_airi.open; v_fee_do_seae_sum.Parameters.ParamByName('帐单编号').value:= p_detail.fieldbyname('帐单编号').asstring; v_fee_do_seae_sum.open; v_fee_do_seai_sum.Parameters.ParamByName('帐单编号').value:= p_detail.fieldbyname('帐单编号').asstring; v_fee_do_seai_sum.open; v_fee_do_aire_sum.Parameters.ParamByName('帐单编号').value:= p_detail.fieldbyname('帐单编号').asstring; v_fee_do_aire_sum.open; v_fee_do_airi_sum.Parameters.ParamByName('帐单编号').value:= p_detail.fieldbyname('帐单编号').asstring; v_fee_do_airi_sum.open; end; frm_rp_ch_balance_view.ShowModal; finally frm_rp_ch_balance_view.free; frm_rp_ch_balance_view:=nil; end; end; procedure Tfrm_rp_ch_balance_accept.N16Click(Sender: TObject); begin if bsSkinTabSheet1.showing then begin if tabsheet1.Showing then grid_save_xls(dxdbgrid1); if tabsheet2.Showing then grid_save_xls(dxdbgrid6); if tabsheet3.Showing then grid_save_xls(dxdbgrid9); exit; end; if bsSkinTabSheet2.showing then begin grid_save_xls(dxdbgrid2); exit; end; if bsSkinTabSheet3.showing then begin grid_save_xls(dxdbgrid4); exit; end; end; procedure Tfrm_rp_ch_balance_accept.N10Click(Sender: TObject); begin if bsSkinTabSheet1.showing then begin if tabsheet1.Showing then update_grid_view_no(dxdbgrid1); if tabsheet2.Showing then update_grid_view_no(dxdbgrid6); if tabsheet3.Showing then update_grid_view_no(dxdbgrid9); exit; end; if bsSkinTabSheet2.showing then begin update_grid_view_no(dxdbgrid2); exit; end; if bsSkinTabSheet3.showing then begin update_grid_view_no(dxdbgrid4); exit; end; end; procedure Tfrm_rp_ch_balance_accept.N14Click(Sender: TObject); begin if bsSkinTabSheet1.showing then begin if tabsheet1.Showing then update_grid_view_all(dxdbgrid1); if tabsheet2.Showing then update_grid_view_all(dxdbgrid6); if tabsheet3.Showing then update_grid_view_all(dxdbgrid9); exit; end; if bsSkinTabSheet2.showing then begin update_grid_view_all(dxdbgrid2); exit; end; if bsSkinTabSheet3.showing then begin update_grid_view_all(dxdbgrid4); exit; end; end; procedure Tfrm_rp_ch_balance_accept.dxDBGrid6DblClick(Sender: TObject); begin // fee_view(p_detail_bill1.DataSet.fieldbyname('编号').asstring); end; end.