unit u_rp_rp_seai; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, dxExEdtr, DB, ADODB, Menus, XPMenu, bsSkinCtrls, dxDBGrid, dxDBTLCl, dxGrClms, dxTL, dxDBCtrl, dxCntner, ComCtrls, bsSkinTabs, ExtCtrls, RxMemDS; type Tfrm_rp_rp_seai = class(TForm) Panel1: TPanel; aa: TbsSkinPageControl; bsSkinTabSheet1: TbsSkinTabSheet; dxDBGrid1: 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; dxDBGrid1Column29: TdxDBGridMaskColumn; dxDBGrid1Column31: 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; bsSkinTabSheet2: TbsSkinTabSheet; dxDBGrid2: TdxDBGrid; dxDBGrid2Column1: TdxDBGridMaskColumn; dxDBGrid2Column2: TdxDBGridMaskColumn; dxDBGrid21: TdxDBGridMaskColumn; dxDBGrid22: TdxDBGridMaskColumn; dxDBGrid23: TdxDBGridMaskColumn; dxDBGrid24: TdxDBGridMaskColumn; dxDBGrid25: TdxDBGridMaskColumn; dxDBGrid26: TdxDBGridMaskColumn; dxDBGrid27: TdxDBGridMaskColumn; dxDBGrid28: TdxDBGridMaskColumn; dxDBGrid29: TdxDBGridMaskColumn; dxDBGrid210: TdxDBGridMaskColumn; dxDBGrid2Column23: TdxDBGridMaskColumn; dxDBGrid2TEU: TdxDBGridMaskColumn; dxDBGrid2Column25: TdxDBGridMaskColumn; dxDBGrid2Column26: TdxDBGridColumn; dxDBGrid2Column27: TdxDBGridColumn; dxDBGrid2USD: TdxDBGridColumn; dxDBGrid2Column29: TdxDBGridColumn; dxDBGrid2Column30: TdxDBGridColumn; dxDBGrid2RMB: TdxDBGridColumn; dxDBGrid2Column32: TdxDBGridColumn; dxDBGrid2Column33: TdxDBGridColumn; dxDBGrid2Column34: TdxDBGridColumn; dxDBGrid2Column35: TdxDBGridColumn; dxDBGrid2Column36: TdxDBGridColumn; dxDBGrid2Column37: TdxDBGridColumn; bsSkinTabSheet3: TbsSkinTabSheet; bsSkinTabSheet4: TbsSkinTabSheet; bsSkinTabSheet5: TbsSkinTabSheet; bsSkinTabSheet6: TbsSkinTabSheet; bsSkinTabSheet8: TbsSkinTabSheet; bsSkinTabSheet7: TbsSkinTabSheet; bsSkinPanel2: TbsSkinPanel; bsSkinButton10: TbsSkinButton; bsSkinButton9: TbsSkinButton; bsSkinButton5: TbsSkinButton; p_detail: TADOStoredProc; p_detail1: TDataSource; t_sum1: TDataSource; dxDBGrid1Column65: TdxDBGridColumn; dxDBGrid1Column66: TdxDBGridColumn; dxDBGrid1Column67: TdxDBGridColumn; dxDBGrid1Column68: TdxDBGridColumn; p_sum: TADOStoredProc; PopupMenu2: TPopupMenu; N10: TMenuItem; N11: TMenuItem; N14: TMenuItem; N13: TMenuItem; N12: TMenuItem; N15: TMenuItem; N16: TMenuItem; XPMenu2: TXPMenu; bsSkinTabSheet9: TbsSkinTabSheet; bskntbsht1: TbsSkinTabSheet; bsSkinTabSheet11: TbsSkinTabSheet; dxDBGrid1Column59: TdxDBGridColumn; dxDBGrid1Column60: TdxDBGridColumn; procedure bsSkinButton5Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure Panel1Resize(Sender: TObject); procedure bsSkinButton10Click(Sender: TObject); procedure FormShow(Sender: TObject); procedure aaChange(Sender: TObject); procedure bsSkinButton9Click(Sender: TObject); procedure N10Click(Sender: TObject); procedure N14Click(Sender: TObject); procedure N12Click(Sender: TObject); procedure N16Click(Sender: TObject); procedure dxDBGrid1ColumnSorting(Sender: TObject; Column: TdxDBTreeListColumn; var Allow: Boolean); procedure dxDBGrid2ColumnSorting(Sender: TObject; Column: TdxDBTreeListColumn; var Allow: Boolean); procedure dxDBGrid1DblClick(Sender: TObject); procedure dxDBGrid1Column116CustomDraw(Sender: TObject; ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxDBTreeListColumn; const AText: String; AFont: TFont; var AColor: TColor; ASelected, AFocused: Boolean; var ADone: Boolean); procedure dxDBGrid2Column34CustomDraw(Sender: TObject; ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxDBTreeListColumn; const AText: String; AFont: TFont; var AColor: TColor; ASelected, AFocused: Boolean; var ADone: Boolean); private { Private declarations } public { Public declarations } end; var frm_rp_rp_seai: Tfrm_rp_rp_seai; rp_rp_seai_open:boolean; implementation uses u_main, my_sys_function, u_data_share; {$R *.dfm} procedure Tfrm_rp_rp_seai.bsSkinButton5Click(Sender: TObject); begin close; end; procedure Tfrm_rp_rp_seai.FormClose(Sender: TObject; var Action: TCloseAction); begin savereggrid(dxdbgrid1,caption+'11'); savereggrid(dxdbgrid2,caption+'12'); rp_rp_seai_open:=false; frm_rp_rp_seai.Hide; frm_rp_rp_seai.ManualFloat(frm_rp_rp_seai.BoundsRect ); frm_main.freeTabs('frm_rp_rp_seai'); action:=cafree; frm_rp_rp_seai:=nil; end; procedure Tfrm_rp_rp_seai.Panel1Resize(Sender: TObject); begin bsSkinPanel2.Left:=Panel1.Width-bsSkinPanel2.Width; end; procedure Tfrm_rp_rp_seai.bsSkinButton10Click(Sender: TObject); begin bsSkinTabSheet1.show; query_seai(6,'0037'); end; procedure Tfrm_rp_rp_seai.FormShow(Sender: TObject); begin loadreggrid(dxdbgrid1,true,caption+'11'); loadreggrid(dxdbgrid2,true,caption+'12'); if frm_data_share.t_load_employee.FieldByName('应收').asboolean then begin dxDBGrid1.Bands[2].Visible:=true; dxDBGrid2.Bands[2].Visible:=true; end else begin dxDBGrid1.Bands[2].Visible:=false; dxDBGrid2.Bands[2].Visible:=false; end; if frm_data_share.t_load_employee.FieldByName('应付').asboolean then begin dxDBGrid1.Bands[3].Visible:=true; dxDBGrid2.Bands[3].Visible:=true; end else begin dxDBGrid1.Bands[3].Visible:=false; dxDBGrid2.Bands[3].Visible:=false; end; if frm_data_share.t_load_employee.FieldByName('利润').asboolean then begin dxDBGrid1.Bands[4].Visible:=true; dxDBGrid2.Bands[4].Visible:=true; end else begin dxDBGrid1.Bands[4].Visible:=false; dxDBGrid2.Bands[4].Visible:=false; end; rp_rp_seai_open:=true; end; procedure Tfrm_rp_rp_seai.aaChange(Sender: TObject); var str:widestring; begin if not rp_rp_seai_open then exit; IF bsSkinTabSheet1.Showing then exit; dxDBGrid2.Parent:=aa.ActivePage; dxDBGrid2Column1.Caption:=aa.ActivePage.Caption; try if not p_detail.Active then exit; if p_detail.IsEmpty then exit; str:=new_query(p_detail); if str<>'no'then begin p_sum.close; p_sum.Parameters.ParamByName('SQLStr').Value:= 'SELECT COUNT(t_op_seai.编号) as 票数, sum(t_op_seai.箱型1) as 箱型1, sum(t_op_seai.箱型2) as 箱型2' +', sum(t_op_seai.箱型3) as 箱型3, sum(t_op_seai.箱型4) as 箱型4, sum(t_op_seai.箱型5) as 箱型5' +', sum(t_op_seai.箱型6) as 箱型6, sum( t_op_seai.箱型7) as 箱型7, sum(t_op_seai.箱型8) as 箱型8' +', sum(t_op_seai.箱型9) as 箱型9, sum(t_op_seai.箱型10) as 箱型10' +', sum(t_op_seai.其他箱型) as 其他箱型, sum( t_op_seai.箱TEU) as 箱TEU, sum(t_op_seai.件数) as 件数' +', sum(t_op_seai.重量) as 重量, sum( t_op_seai.尺码) as 尺码, sum(t_op_gain.利润USD) as 利润USD' +', sum(t_op_gain.应收USD) as 应收USD, sum( t_op_gain.应付USD) as 应付USD, sum(t_op_gain.利润RMB) as 利润RMB' +', sum(t_op_gain.应收RMB) as 应收RMB, sum( t_op_gain.应付RMB) as 应付RMB, sum(t_op_gain.毛利润) as 毛利润' +', sum(t_op_gain.合计应收) as 合计应收, sum( t_op_gain.合计应付) as 合计应付' +',(case when isnull(sum(t_op_gain.合计应付),0)=0 then '+''''+'无法计算'+''''+' else ' +'ltrim(str(sum(t_op_gain.毛利润)/sum(t_op_gain.合计应付)*100,10,2))+'+''''+'%'+''''+' end) as 利润率' +',t_op_seai.'+aa.ActivePage.Caption+' as base' +','+''''+aa.ActivePage.Caption+''''+' as 统计标准' +' FROM t_op_seai LEFT JOIN' +' t_op_gain ON t_op_seai.编号 = t_op_gain.编号 ' +str+' group by '+'t_op_seai.'+aa.ActivePage.Caption +' order by '+'t_op_seai.'+aa.ActivePage.Caption; p_sum.open; end; except ; end; end; procedure Tfrm_rp_rp_seai.bsSkinButton9Click(Sender: TObject); begin sys_print('海运进口业务统计',2,nil,nil,nil,nil,p_detail1,t_sum1,nil,nil,nil,nil,nil); end; procedure Tfrm_rp_rp_seai.N10Click(Sender: TObject); begin if bsSkinTabSheet1.showing then begin update_grid_view_no(dxdbgrid1); end else begin update_grid_view_no(dxdbgrid2); end; end; procedure Tfrm_rp_rp_seai.N14Click(Sender: TObject); begin if bsSkinTabSheet1.showing then begin update_grid_view_all(dxdbgrid1); end else begin update_grid_view_all(dxdbgrid2); end; end; procedure Tfrm_rp_rp_seai.N12Click(Sender: TObject); begin if bsSkinTabSheet1.showing then begin update_grid(dxdbgrid1,47); end else begin update_grid(dxdbgrid2,48); end; end; procedure Tfrm_rp_rp_seai.N16Click(Sender: TObject); begin if bsSkinTabSheet1.showing then begin grid_save_xls(dxdbgrid1); end else begin grid_save_xls(dxdbgrid2); end; end; procedure Tfrm_rp_rp_seai.dxDBGrid1ColumnSorting(Sender: TObject; Column: TdxDBTreeListColumn; var Allow: Boolean); begin Column_sort_pro(Column,p_detail,'业务编号'); end; procedure Tfrm_rp_rp_seai.dxDBGrid2ColumnSorting(Sender: TObject; Column: TdxDBTreeListColumn; var Allow: Boolean); begin Column_sort_pro(Column,p_sum,'base'); end; procedure Tfrm_rp_rp_seai.dxDBGrid1DblClick(Sender: TObject); begin fee_view(p_detail.fieldbyname('编号').asstring); end; procedure Tfrm_rp_rp_seai.dxDBGrid1Column116CustomDraw(Sender: TObject; ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxDBTreeListColumn; const AText: String; AFont: TFont; var AColor: TColor; ASelected, AFocused: Boolean; var ADone: Boolean); begin if strtofloatdef(AText,0)<=0 then AColor:=clRed; end; procedure Tfrm_rp_rp_seai.dxDBGrid2Column34CustomDraw(Sender: TObject; ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxDBTreeListColumn; const AText: String; AFont: TFont; var AColor: TColor; ASelected, AFocused: Boolean; var ADone: Boolean); begin if strtofloatdef(AText,0)<=0 then AColor:=clRed; end; end.