unit u_rp_fen_seae; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, RxMemDS, bsSkinCtrls, TeEngine, Series, TeeProcs, Chart, DbChart, DB, ADODB, Menus, XPMenu, ExtCtrls,teeprevi, StdCtrls, Dialogs, ExtDlgs, Mask, wwdbedit, Wwdotdot, Wwdbcomb, dxExEdtr, dxTL, dxDBCtrl, dxDBGrid, dxCntner, ComCtrls, bsSkinTabs, dxDBTLCl, dxGrClms; type Tfrm_rp_fen_seae = class(TForm) Panel1: TPanel; bsSkinPanel2: TbsSkinPanel; p_client: TADOStoredProc; bsSkinCheckRadioBox1: TbsSkinCheckRadioBox; bsSkinCheckRadioBox2: TbsSkinCheckRadioBox; bsSkinCheckRadioBox3: TbsSkinCheckRadioBox; bsSkinCheckRadioBox4: TbsSkinCheckRadioBox; bsSkinCheckRadioBox5: TbsSkinCheckRadioBox; bsSkinCheckRadioBox6: TbsSkinCheckRadioBox; bsSkinCheckRadioBox7: TbsSkinCheckRadioBox; bsSkinCheckRadioBox8: TbsSkinCheckRadioBox; bsSkinPanel1: TbsSkinPanel; bsSkinButton10: TbsSkinButton; bsSkinButton9: TbsSkinButton; bsSkinButton5: TbsSkinButton; bsSkinPanel3: TbsSkinPanel; Label1: TLabel; Edit1: TEdit; Label2: TLabel; wwDBComboBox1: TwwDBComboBox; p_client1: TDataSource; bsSkinButton1: TbsSkinButton; SaveDialog1: TSaveDialog; bsSkinCheckRadioBox11: TbsSkinCheckRadioBox; bsSkinCheckRadioBox12: TbsSkinCheckRadioBox; bsSkinCheckRadioBox13: TbsSkinCheckRadioBox; bsSkinPanel4: TbsSkinPanel; bsSkinPanel5: TbsSkinPanel; bsSkinCheckRadioBox10: TbsSkinCheckRadioBox; bsSkinCheckRadioBox9: TbsSkinCheckRadioBox; bsSkinCheckRadioBox14: TbsSkinCheckRadioBox; bsSkinCheckRadioBox15: TbsSkinCheckRadioBox; PopupMenu1: TPopupMenu; EXCEL1: TMenuItem; bsSkinPageControl1: TbsSkinPageControl; bsSkinTabSheet1: TbsSkinTabSheet; bsSkinTabSheet2: TbsSkinTabSheet; dxDBGrid1: TdxDBGrid; dxDBGrid1Column1: TdxDBGridColumn; dxDBGrid1Column2: TdxDBGridColumn; p_seae: TADOStoredProc; p_seae1: TDataSource; dxDBGrid2: TdxDBGrid; dxDBGrid1Column5: TdxDBGridMaskColumn; dxDBGrid1Column3: TdxDBGridMaskColumn; dxDBGrid1Column4: TdxDBGridMaskColumn; dxDBGrid1Column6: TdxDBGridDateColumn; dxDBGrid1Column7: TdxDBGridMaskColumn; dxDBGrid1Column8: TdxDBGridMaskColumn; dxDBGrid1Column9: TdxDBGridMaskColumn; dxDBGrid1Column10: TdxDBGridMaskColumn; dxDBGrid1Column11: TdxDBGridMaskColumn; dxDBGrid1Column21: TdxDBGridMaskColumn; dxDBGrid1Column23: TdxDBGridMaskColumn; dxDBGrid1Column24: TdxDBGridMaskColumn; dxDBGrid1Column25: TdxDBGridMaskColumn; dxDBGrid1Column26: TdxDBGridDateColumn; dxDBGrid1Column27: TdxDBGridDateColumn; dxDBGrid1Column28: TdxDBGridDateColumn; dxDBGrid1Column29: TdxDBGridMaskColumn; dxDBGrid1Column31: TdxDBGridMaskColumn; dxDBGrid1Column43: TdxDBGridMaskColumn; dxDBGrid1Column51: TdxDBGridMaskColumn; dxDBGrid1Column54: TdxDBGridMaskColumn; dxDBGrid1Column55: TdxDBGridMaskColumn; dxDBGrid1Column56: TdxDBGridColumn; dxDBGrid1Column57: TdxDBGridColumn; dxDBGrid11: TdxDBGridMaskColumn; dxDBGrid12: TdxDBGridMaskColumn; dxDBGrid13: TdxDBGridMaskColumn; dxDBGrid14: TdxDBGridMaskColumn; dxDBGrid15: TdxDBGridMaskColumn; dxDBGrid16: TdxDBGridMaskColumn; dxDBGrid17: TdxDBGridMaskColumn; dxDBGrid18: TdxDBGridMaskColumn; dxDBGrid19: TdxDBGridMaskColumn; dxDBGrid110: TdxDBGridMaskColumn; dxDBGrid1Column80: TdxDBGridMaskColumn; dxDBGrid1TEU: TdxDBGridMaskColumn; dxDBGrid1Column82: TdxDBGridMaskColumn; dxDBGrid1Column83: TdxDBGridMaskColumn; dxDBGrid1Column84: TdxDBGridDateColumn; dxDBGrid1Column88: TdxDBGridMaskColumn; dxDBGrid1Column89: TdxDBGridMaskColumn; dxDBGrid1Column90: TdxDBGridMaskColumn; dxDBGrid1Column92: TdxDBGridMaskColumn; dxDBGrid1Column93: TdxDBGridMaskColumn; dxDBGrid1Column85: TdxDBGridMaskColumn; dxDBGrid1Column87: TdxDBGridMaskColumn; dxDBGrid1Column86: TdxDBGridMaskColumn; dxDBGrid1USD: TdxDBGridColumn; dxDBGrid1RMB: TdxDBGridColumn; dxDBGrid1Column102: TdxDBGridColumn; dxDBGrid1Column105: TdxDBGridColumn; dxDBGrid1Column108: TdxDBGridColumn; dxDBGrid1Column111: TdxDBGridColumn; dxDBGrid1Column114: TdxDBGridColumn; dxDBGrid1Column115: TdxDBGridColumn; dxDBGrid1Column116: TdxDBGridColumn; dxDBGrid1Column117: TdxDBGridMaskColumn; dxDBGrid1Column68: TdxDBGridColumn; dxDBGrid1Column69: TdxDBGridColumn; PopupMenu2: TPopupMenu; N10: TMenuItem; N11: TMenuItem; N14: TMenuItem; N13: TMenuItem; N12: TMenuItem; N15: TMenuItem; N16: TMenuItem; bsSkinPanel6: TbsSkinPanel; bsSkinPageControl2: TbsSkinPageControl; tab1: TbsSkinTabSheet; tab2: TbsSkinTabSheet; DBChart1: TDBChart; LineSeries2: TBarSeries; DBChart2: TDBChart; BarSeries1: TBarSeries; DBChart3: TDBChart; BarSeries2: TBarSeries; dxDBGrid1Column12: TdxDBGridColumn; dxDBGrid1Column13: TdxDBGridColumn; bsSkinCheckRadioBox16: TbsSkinCheckRadioBox; procedure bsSkinButton5Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure bsSkinButton9Click(Sender: TObject); procedure bsSkinButton10Click(Sender: TObject); procedure Panel1Resize(Sender: TObject); procedure bsSkinCheckRadioBox1Click(Sender: TObject); procedure bsSkinPanel1Resize(Sender: TObject); procedure bsSkinButton1Click(Sender: TObject); procedure bsSkinCheckRadioBox13Click(Sender: TObject); procedure bsSkinPanel4Resize(Sender: TObject); procedure bsSkinPanel5Resize(Sender: TObject); procedure EXCEL1Click(Sender: TObject); procedure dxDBGrid1DblClick(Sender: TObject); procedure N10Click(Sender: TObject); procedure N14Click(Sender: TObject); procedure N12Click(Sender: TObject); procedure N16Click(Sender: TObject); procedure FormShow(Sender: TObject); private { Private declarations } public { Public declarations } end; var frm_rp_fen_seae: Tfrm_rp_fen_seae; fen_seae_str:widestring; implementation uses u_main, my_sys_function, u_sys_progress; {$R *.dfm} procedure Tfrm_rp_fen_seae.bsSkinButton5Click(Sender: TObject); begin close; end; procedure Tfrm_rp_fen_seae.FormClose(Sender: TObject; var Action: TCloseAction); begin savereggrid(dxdbgrid2,caption+'2'); frm_rp_fen_seae.Hide; frm_rp_fen_seae.ManualFloat(frm_rp_fen_seae.BoundsRect ); frm_main.freeTabs('frm_rp_fen_seae'); action:=cafree; frm_rp_fen_seae:=nil; end; procedure Tfrm_rp_fen_seae.bsSkinButton9Click(Sender: TObject); begin chartpreview(frm_rp_fen_seae,dbchart1); end; procedure Tfrm_rp_fen_seae.bsSkinButton10Click(Sender: TObject); VAR i:integer; begin try i:=strtoint(Edit1.text); if i<1 then begin showmessage('名次必须大于0!!'); exit; end; except showmessage('请正确输入名次!!'); exit; end; query_seae(8,'0037'); if bsSkinCheckRadioBox13.Checked then frm_rp_fen_seae.bsSkinCheckRadioBox13Click(Sender) else frm_rp_fen_seae.bsSkinCheckRadioBox1Click(Sender); end; procedure Tfrm_rp_fen_seae.Panel1Resize(Sender: TObject); var i:integer; begin i:=round(bsSkinPanel2.Width/12); bsSkinCheckRadioBox1.Width:=i; bsSkinCheckRadioBox2.Width:=i; bsSkinCheckRadioBox3.Width:=i; bsSkinCheckRadioBox4.Width:=i; bsSkinCheckRadioBox5.Width:=i; bsSkinCheckRadioBox6.Width:=i; bsSkinCheckRadioBox7.Width:=i; bsSkinCheckRadioBox8.Width:=i; bsSkinCheckRadioBox11.Width:=i; bsSkinCheckRadioBox12.Width:=i; bsSkinCheckRadioBox13.Width:=i; bsSkinCheckRadioBox16.Width:=i; end; procedure Tfrm_rp_fen_seae.bsSkinCheckRadioBox1Click(Sender: TObject); var str,tongji,paixu:string; i:integer; begin if bsSkinCheckRadioBox13.Checked then begin frm_rp_fen_seae.bsSkinCheckRadioBox13Click(Sender); exit; end; if not bsSkinCheckRadioBox9.Checked then tab2.TabVisible:=false; bsSkinPanel4.Visible:=true; bsSkinPanel5.Visible:=false; try i:=strtoint(Edit1.text); if i<1 then begin showmessage('名次必须大于0!!'); exit; end; except showmessage('请正确输入名次!!'); exit; end; if wwDBComboBox1.ItemIndex=-1 then begin showmessage('请正确排序方式!!'); exit; end; if wwDBComboBox1.ItemIndex=0 then paixu:='desc' else paixu:=''; if fen_seae_str='' then exit; if bsSkinCheckRadioBox1.Checked then str:=bsSkinCheckRadioBox1.Caption; if bsSkinCheckRadioBox2.Checked then str:=bsSkinCheckRadioBox2.Caption; if bsSkinCheckRadioBox3.Checked then str:=bsSkinCheckRadioBox3.Caption; if bsSkinCheckRadioBox4.Checked then str:=bsSkinCheckRadioBox4.Caption; if bsSkinCheckRadioBox5.Checked then str:=bsSkinCheckRadioBox5.Caption; if bsSkinCheckRadioBox6.Checked then str:=bsSkinCheckRadioBox6.Caption; if bsSkinCheckRadioBox7.Checked then str:=bsSkinCheckRadioBox7.Caption; if bsSkinCheckRadioBox8.Checked then str:=bsSkinCheckRadioBox8.Caption; if bsSkinCheckRadioBox11.Checked then str:=bsSkinCheckRadioBox11.Caption; if bsSkinCheckRadioBox12.Checked then str:=bsSkinCheckRadioBox12.Caption; if bsSkinCheckRadioBox16.Checked then str:=bsSkinCheckRadioBox16.Caption; if bsSkinCheckRadioBox9.checked then begin tongji:='t_op_gain_main.毛利润'; DBChart1.Title.Text.Clear; DBChart1.Title.Text.add('出口业务应得毛利润前'+edit1.text+'名'); p_client.close; p_client.Parameters.ParamByName('SQLStr').value:= 'SELECT top ' +Edit1.text+' sum(t_op_gain_main.毛利润) as 数量,'+'sum(t_op_gain_main.利润RMB) as 数量2,'+'sum(t_op_gain_main.利润USD) as 数量3' +',t_op_seae.'+str+' as 标准' +' FROM t_op_seae inner JOIN t_op_gain_main ON ' +'t_op_seae.编号 =t_op_gain_main.编号 ' +fen_seae_str +' group by t_op_seae.'+str +' order by sum('+tongji+') '+paixu; p_client.Open; dxDBGrid1Column12.Visible:=true; dxDBGrid1Column13.Visible:=true; dxDBGrid1Column12.Caption:='人民币金额'; dxDBGrid1Column13.Caption:='美元金额'; end else begin tongji:='t_op_seae.箱TEU'; DBChart1.Title.Text.Clear; DBChart1.Title.Text.add('出口业务箱TEU前'+edit1.text+'名'); p_client.close; p_client.Parameters.ParamByName('SQLStr').value:= 'SELECT top ' +Edit1.text+' sum('+tongji+') as 数量,'+'sum('+tongji+') as 数量2,'+'sum('+tongji+') as 数量3' +',t_op_seae.'+str+' as 标准' +' FROM t_op_seae inner JOIN t_op_gain_main ON ' +'t_op_seae.编号 =t_op_gain_main.编号 ' +fen_seae_str +' group by t_op_seae.'+str +' order by sum('+tongji+') '+paixu; p_client.Open; dxDBGrid1Column12.Visible:=false; dxDBGrid1Column13.Visible:=false; end; end; procedure Tfrm_rp_fen_seae.bsSkinPanel1Resize(Sender: TObject); var i:integer; begin i:=round((bsSkinPanel1.Width-bsSkinPanel3.Width)/6); if bsSkinCheckRadioBox13.Checked then begin bsSkinPanel5.Width:=2*i; end else begin bsSkinPanel4.Width:=2*i; end; bsSkinButton10.Width:=i; bsSkinButton9.Width:=i; bsSkinButton1.Width:=i; wwDBComboBox1.ItemIndex:=0; end; procedure Tfrm_rp_fen_seae.bsSkinButton1Click(Sender: TObject); begin if SaveDialog1.Execute then frm_rp_fen_seae.GetFormImage.SaveToFile(SaveDialog1.FileName+'.bmp'); end; procedure Tfrm_rp_fen_seae.bsSkinCheckRadioBox13Click(Sender: TObject); var str,tongji,paixu:string; i:integer; sl:tstrings; begin i:=round((bsSkinPanel1.Width-bsSkinPanel3.Width)/6); if bsSkinCheckRadioBox13.Checked then begin bsSkinPanel4.Visible:=false; bsSkinPanel5.Visible:=true; bsSkinPanel5.Width:=2*i; bsSkinButton10.Width:=i; bsSkinButton9.Width:=i; bsSkinButton1.Width:=i; end else begin bsSkinPanel4.Visible:=true; bsSkinPanel5.Visible:=false; bsSkinPanel4.Width:=2*i; bsSkinButton10.Width:=i; bsSkinButton9.Width:=i; bsSkinButton1.Width:=i; end; TAB2.TabVisible:=true; try i:=strtoint(Edit1.text); if i<1 then begin showmessage('名次必须大于0!!'); exit; end; except showmessage('请正确输入名次!!'); exit; end; if wwDBComboBox1.ItemIndex=-1 then begin showmessage('请正确排序方式!!'); exit; end; if wwDBComboBox1.ItemIndex=0 then paixu:='desc' else paixu:=''; if fen_seae_str='' then exit; str:=bsSkinCheckRadioBox13.Caption; sl:=TStringList.Create; if bsSkinCheckRadioBox14.checked then begin if fen_seae_str='' then tongji:=' where t_ch_fee.类型=''收''' else tongji:=fen_seae_str+' and t_ch_fee.类型=''收'''; p_client.close; p_client.Parameters.ParamByName('SQLStr').value:= 'SELECT top ' +Edit1.text+' sum(t_ch_fee.金额*t_ch_fee.汇率) as 数量'+', sum(case t_ch_fee.币别 when '+''''+'RMB'+''''+' then t_ch_fee.金额 else 0 end) as 数量2'+', sum(case t_ch_fee.币别 when '+''''+'USD'+''''+' then t_ch_fee.金额 else 0 end) as 数量3' +',t_ch_fee.客户名称 as 标准' +' FROM t_ch_fee inner JOIN t_op_seae ON ' +'t_ch_fee.编号 =t_op_seae.编号 ' +tongji +' group by t_ch_fee.客户名称' +' order by sum(t_ch_fee.金额*t_ch_fee.汇率) '+paixu; p_client.Open; DBChart1.Title.Text.Clear; DBChart1.Title.Text.add('出口业务应收帐款前'+edit1.text+'名'); dxDBGrid1Column12.Visible:=true; dxDBGrid1Column13.Visible:=true; dxDBGrid1Column12.Caption:='人民币金额'; dxDBGrid1Column13.Caption:='美元金额'; end else begin if fen_seae_str='' then tongji:=' where t_ch_fee.类型=''付''' else tongji:=fen_seae_str+' and t_ch_fee.类型=''付'''; p_client.close; p_client.Parameters.ParamByName('SQLStr').value:= 'SELECT top ' +Edit1.text+' sum(t_ch_fee.金额*t_ch_fee.汇率) as 数量'+', sum(case t_ch_fee.币别 when '+''''+'RMB'+''''+' then t_ch_fee.金额 else 0 end) as 数量2'+', sum(case t_ch_fee.币别 when '+''''+'USD'+''''+' then t_ch_fee.金额 else 0 end) as 数量3' +',t_ch_fee.客户名称 as 标准' +' FROM t_ch_fee inner JOIN t_op_seae ON ' +'t_ch_fee.编号 =t_op_seae.编号 ' +tongji +' group by t_ch_fee.客户名称' +' order by sum(t_ch_fee.金额*t_ch_fee.汇率) '+paixu; p_client.Open; DBChart1.Title.Text.Clear; DBChart1.Title.Text.add('出口业务应收帐款前'+edit1.text+'名'); dxDBGrid1Column12.Visible:=true; dxDBGrid1Column13.Visible:=true; dxDBGrid1Column12.Caption:='人民币金额'; dxDBGrid1Column13.Caption:='美元金额'; end; FreeAndNil(sl); end; procedure Tfrm_rp_fen_seae.bsSkinPanel4Resize(Sender: TObject); var i:integer; begin i:=round(bsSkinPanel4.Width/2); bsSkinCheckRadioBox9.Width:=i; bsSkinCheckRadioBox10.Width:=i; end; procedure Tfrm_rp_fen_seae.bsSkinPanel5Resize(Sender: TObject); var i:integer; begin i:=round(bsSkinPanel5.Width/2); bsSkinCheckRadioBox14.Width:=i; bsSkinCheckRadioBox15.Width:=i; end; procedure Tfrm_rp_fen_seae.EXCEL1Click(Sender: TObject); begin grid_save_xls(dxdbgrid1); end; procedure Tfrm_rp_fen_seae.dxDBGrid1DblClick(Sender: TObject); var str,tongji,paixu:string; i:integer; begin if not p_client.Active then exit; if p_client.IsEmpty then exit; if bsSkinCheckRadioBox13.Checked then begin end else begin if bsSkinCheckRadioBox1.Checked then str:=bsSkinCheckRadioBox1.Caption; if bsSkinCheckRadioBox2.Checked then str:=bsSkinCheckRadioBox2.Caption; if bsSkinCheckRadioBox3.Checked then str:=bsSkinCheckRadioBox3.Caption; if bsSkinCheckRadioBox4.Checked then str:=bsSkinCheckRadioBox4.Caption; if bsSkinCheckRadioBox5.Checked then str:=bsSkinCheckRadioBox5.Caption; if bsSkinCheckRadioBox6.Checked then str:=bsSkinCheckRadioBox6.Caption; if bsSkinCheckRadioBox7.Checked then str:=bsSkinCheckRadioBox7.Caption; if bsSkinCheckRadioBox8.Checked then str:=bsSkinCheckRadioBox8.Caption; if bsSkinCheckRadioBox11.Checked then str:=bsSkinCheckRadioBox11.Caption; if bsSkinCheckRadioBox12.Checked then str:=bsSkinCheckRadioBox12.Caption; if bsSkinCheckRadioBox16.Checked then str:=bsSkinCheckRadioBox16.Caption; p_seae.close; p_seae.Parameters.ParamByName('SQLStr').value:= 'SELECT t_op_seae.*,t_op_gain_main.利润USD,t_op_gain_main.应收USD,t_op_gain_main.应收RMB,t_op_gain_main.合计应收,t_op_gain_main.利润RMB,t_op_gain_main.应付USD, t_op_gain_main.应付RMB,t_op_gain_main.合计应付,t_op_gain_main.毛利润,t_op_gain_main.利润率 ' +' FROM t_op_seae inner JOIN t_op_gain_main ON ' +'t_op_seae.编号 =t_op_gain_main.编号 ' +fen_seae_str +' and t_op_seae.'+str+'='+''''+p_client.fieldbyname('标准').AsString+''''; p_seae.Open; bsSkinPageControl1.ActivePage:=bsSkinTabSheet2; end; // frm_rp_fen_seae.bsSkinCheckRadioBox1Click(Sender); end; procedure Tfrm_rp_fen_seae.N10Click(Sender: TObject); begin update_grid_view_no(dxdbgrid2); end; procedure Tfrm_rp_fen_seae.N14Click(Sender: TObject); begin update_grid_view_all(dxdbgrid2); end; procedure Tfrm_rp_fen_seae.N12Click(Sender: TObject); begin update_grid(dxdbgrid2,122); end; procedure Tfrm_rp_fen_seae.N16Click(Sender: TObject); begin grid_save_xls(dxdbgrid2); end; procedure Tfrm_rp_fen_seae.FormShow(Sender: TObject); begin loadreggrid(dxdbgrid2,true,caption+'2'); end; end.