unit u_rp_no_monthtotal; 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_no_monthtotal = class(TForm) Panel1: TPanel; bsSkinPanel2: TbsSkinPanel; bsSkinButton5: TbsSkinButton; kbmBinaryStreamFormat1: TkbmBinaryStreamFormat; kbmThreadDataSet1: TkbmThreadDataSet; memtblDetail: TkbmMemTable; p_total1: TDataSource; bsSkinPanel1: TbsSkinPanel; bsSkinPageControl1: TbsSkinPageControl; bsSkinTabSheet1: TbsSkinTabSheet; dxDBGrid1: TdxDBGrid; dxDBGrid1Column5: TdxDBGridColumn; dxDBGridMaskColumn95: TdxDBGridMaskColumn; memtotal1: TDataSource; memtotal: TkbmMemTable; memtotalField: TStringField; memtotalField2: TFloatField; bsSkinRadioGroup1: TbsSkinRadioGroup; bsSkinPanel3: TbsSkinPanel; Label3: TLabel; Label13: TLabel; Label14: TLabel; Label4: TLabel; Label1: TLabel; Label2: TLabel; Label5: TLabel; Label6: TLabel; cbmonth: TwwDBComboBox; cbYear: TwwDBComboBox; RxDBLookupCombo5: TRxDBLookupCombo; RxDBLookupCombo3: TRxDBLookupCombo; cbeYear: TwwDBComboBox; cbemonth: TwwDBComboBox; Label68: TLabel; wwDBComboBox31: TwwDBComboBox; bsSkinTabSheet2: TbsSkinTabSheet; dxDBGrid2: TdxDBGrid; dxDBGrid1Column1: TdxDBGridMaskColumn; dxDBGrid2Column59: TdxDBGridColumn; dxDBGrid1Column54: TdxDBGridMaskColumn; dxDBGrid1Column11: TdxDBGridMaskColumn; dxDBGrid1Column13: TdxDBGridMaskColumn; dxDBGrid1Column15: TdxDBGridMaskColumn; dxDBGrid1Column64: TdxDBGridColumn; dxDBGrid1Column67: TdxDBGridColumn; dxDBGrid1Column65: TdxDBGridColumn; dxDBGrid1Column66: TdxDBGridColumn; dxDBGrid1USD: TdxDBGridColumn; dxDBGrid1Column3: TdxDBGridColumn; dxDBGrid1Column4: TdxDBGridColumn; dxDBGrid1RMB: TdxDBGridColumn; dxDBGrid1Column6: TdxDBGridColumn; dxDBGrid1Column7: TdxDBGridColumn; dxDBGrid1Column8: TdxDBGridColumn; dxDBGrid1Column9: TdxDBGridColumn; dxDBGrid1Column10: TdxDBGridColumn; dxDBGrid1Column12: TdxDBGridDateColumn; dxDBGrid1Column63: TdxDBGridColumn; dxDBGrid1Column14: TdxDBGridMaskColumn; dxDBGrid1Column16: TdxDBGridMaskColumn; dxDBGrid1Column18: TdxDBGridMaskColumn; dxDBGrid1Column19: TdxDBGridMaskColumn; dxDBGrid1Column21: TdxDBGridMaskColumn; dxDBGrid1Column20: TdxDBGridMaskColumn; dxDBGrid1Column22: TdxDBGridDateColumn; dxDBGridMaskColumn1: TdxDBGridMaskColumn; dxDBGrid1Column24: TdxDBGridMaskColumn; dxDBGrid1Column25: TdxDBGridMaskColumn; dxDBGrid1Column26: TdxDBGridMaskColumn; dxDBGrid1Column27: TdxDBGridMaskColumn; dxDBGrid1Column28: TdxDBGridColumn; dxDBGrid1Column29: TdxDBGridColumn; dxDBGrid11: TdxDBGridMaskColumn; dxDBGrid12: TdxDBGridMaskColumn; dxDBGrid13: TdxDBGridMaskColumn; dxDBGrid14: TdxDBGridMaskColumn; dxDBGrid15: TdxDBGridMaskColumn; dxDBGrid16: TdxDBGridMaskColumn; dxDBGrid17: TdxDBGridMaskColumn; dxDBGrid18: TdxDBGridMaskColumn; dxDBGrid19: TdxDBGridMaskColumn; dxDBGrid110: TdxDBGridMaskColumn; dxDBGrid1Column50: TdxDBGridMaskColumn; dxDBGrid1TEU: TdxDBGridMaskColumn; dxDBGrid1Column52: TdxDBGridMaskColumn; dxDBGrid1Column53: TdxDBGridMaskColumn; dxDBGrid1Column55: TdxDBGridMaskColumn; dxDBGrid1Column56: TdxDBGridMaskColumn; dxDBGrid1Column57: TdxDBGridMaskColumn; dxDBGrid1Column58: TdxDBGridMaskColumn; dxDBGrid1Column59: TdxDBGridMaskColumn; dxDBGrid1Column60: TdxDBGridMaskColumn; dxDBGrid1Column61: TdxDBGridColumn; dxDBGrid1Column62: TdxDBGridColumn; dxDBGrid1Column68: TdxDBGridColumn; dxDBGrid1Column69: TdxDBGridColumn; dxDBGrid2Column60: TdxDBGridColumn; dxDBGrid2Column61: TdxDBGridColumn; dxDBGrid2Column62: TdxDBGridColumn; dxDBGrid2Column63: TdxDBGridColumn; dxDBGrid2Column64: TdxDBGridColumn; dxDBGrid2Column65: TdxDBGridColumn; dxDBGrid2Column66: TdxDBGridColumn; dxDBGrid2Column67: TdxDBGridColumn; dxDBGrid2Column68: TdxDBGridColumn; p_detail: TADOStoredProc; p_detail1: TDataSource; dxDBGrid2Column69: TdxDBGridColumn; PopupMenu2: TPopupMenu; N10: TMenuItem; N11: TMenuItem; N14: TMenuItem; N13: TMenuItem; N12: TMenuItem; N15: TMenuItem; N16: TMenuItem; PopupMenu1: TPopupMenu; N1: TMenuItem; Label40: TLabel; RxDBLookupCombo15: TRxDBLookupCombo; Label22: TLabel; RxDBLookupCombo10: TRxDBLookupCombo; RxDBLookupCombo12: TRxDBLookupCombo; Label23: TLabel; bsSkinButton10: TbsSkinButton; bsSkinButton2: TbsSkinButton; dxDBGrid2Column70: TdxDBGridColumn; bsSkinRadioGroup2: TbsSkinRadioGroup; bsSkinRadioGroup3: TbsSkinRadioGroup; bsSkinCheckGroup1: TbsSkinCheckGroup; procedure bsSkinButton5Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure bsSkinButton10Click(Sender: TObject); procedure bsSkinButton9Click(Sender: TObject); procedure bsSkinCheckRadioBox3Click(Sender: TObject); procedure bsSkinCheckRadioBox2Click(Sender: TObject); procedure FormShow(Sender: TObject); procedure dxDBGrid1DblClick(Sender: TObject); procedure bsSkinButton2Click(Sender: TObject); procedure N10Click(Sender: TObject); procedure N14Click(Sender: TObject); procedure N12Click(Sender: TObject); procedure N16Click(Sender: TObject); procedure N1Click(Sender: TObject); procedure memtblDetailAfterOpen(DataSet: TDataSet); private procedure GetNoFee; procedure GetsaleNoFee; procedure GetcustsaleNoFee; procedure Creatememtbl; function getleftstr(substr:String;leng:integer;left:boolean=true):String; function getzq(cust:string):string; { Private declarations } public { Public declarations } end; var frm_rp_no_monthtotal: Tfrm_rp_no_monthtotal; FmDate,ToDate:String; sqlstr:WideString; implementation uses u_main, my_sys_function,u_sys_progress, u_data_share; {$R *.dfm} procedure Tfrm_rp_no_monthtotal.bsSkinButton5Click(Sender: TObject); begin close; end; procedure Tfrm_rp_no_monthtotal.FormClose(Sender: TObject; var Action: TCloseAction); begin savereggrid(dxdbgrid2,caption+'2'); frm_rp_no_monthtotal.Hide; frm_rp_no_monthtotal.ManualFloat(frm_rp_no_monthtotal.BoundsRect ); frm_main.freeTabs('frm_rp_no_monthtotal'); action:=cafree; frm_rp_no_monthtotal:=nil; end; procedure Tfrm_rp_no_monthtotal.bsSkinButton10Click(Sender: TObject); begin if cbyear.Text='' then begin MessageDlg('统计年不能为空!',mtWarning,[mbOk],0); exit; end; if cbeyear.Text='' then begin MessageDlg('统计年不能为空!',mtWarning,[mbOk],0); exit; end; if cbmonth.Text='' then begin MessageDlg('统计月不能为空!',mtWarning,[mbOk],0); exit; end; if cbemonth.Text='' then begin MessageDlg('统计月不能为空!',mtWarning,[mbOk],0); exit; end; if EncodeDate(strtoint(cbyear.text),strtoint(cbmonth.Text),1)>EncodeDate(strtoint(cbeyear.text),strtoint(cbemonth.Text),1) then begin MessageDlg('开始日期不能大于结束日期!',mtWarning,[mbOk],0); exit; end; Creatememtbl; if bsSkinRadioGroup1.ItemIndex=0 then GetNoFee else if bsSkinRadioGroup1.ItemIndex=1 then GetsaleNoFee else if bsSkinRadioGroup1.ItemIndex=2 then GetcustsaleNoFee end; procedure Tfrm_rp_no_monthtotal.bsSkinButton9Click(Sender: TObject); begin sys_print('业务综合欠费',2,nil,nil,nil,nil,p_total1,nil,nil,nil,nil,nil,nil); end; procedure Tfrm_rp_no_monthtotal.GetNoFee; var aQuery:TAdoQuery; aDate,aToDate:TDate; strdate,stredate,sDate:String; i:integer; // S:TChartSeries; begin aQuery:=CreateAdoQuery; try with aQuery do begin aDate:=EncodeDate(strtoint(cbYear.Text),strtoint(cbmonth.Text),1); aToDate:=EncodeDate(strtoint(cbeYear.Text),strtoint(cbemonth.Text),2); if not ASSIGNED(frm_sys_progress) then frm_sys_progress:=tfrm_sys_progress.Create(application); frm_sys_progress.Show; if MonthsBetween(aDate,aToDate)=0 then frm_sys_progress.bsSkinGauge1.MaxValue:=1 else frm_sys_progress.bsSkinGauge1.MaxValue:=MonthsBetween(aDate,aToDate); frm_sys_progress.bsSkinGauge1.MinValue:=0; frm_sys_progress.bsSkinGauge1.Value:=0; frm_sys_progress.Update; while not (aDate>aToDate) do begin strdate:=FormatDateTime('YYYY-MM-DD',EncodeDate(strtoint(FormatDateTime('YYYY',aDate)),strtoint(FormatDateTime('MM',aDate)),MonthDays[isLeapYear(strtoint(FormatDateTime('YYYY',aDate))),strtoint(FormatDateTime('MM',aDate))])); stredate:=FormatDateTime('YYYY-MM-DD',aDate); sDate:=FormatDateTime('YYYYMM',aDate); CLOSE; SQL.Clear; SQL.Add('Select t_ch_fee.客户名称, '); SQL.Add('sum(case t_ch_fee.类型 when ''收'' then (case t_ch_fee.币别 when ''USD'' then t_ch_fee.金额-t_ch_fee.结算金额 else 0 end) else 0 end) as 未收USD,'); SQL.Add('sum(case t_ch_fee.类型 when ''收'' then (case t_ch_fee.币别 when ''RMB'' then t_ch_fee.金额-t_ch_fee.结算金额 else 0 end) else 0 end) as 未收RMB,'); SQL.Add('sum(case t_ch_fee.类型 when ''收'' then (t_ch_fee.金额-t_ch_fee.结算金额)*t_ch_fee.汇率 else 0 end) as 未收合计,'); SQL.Add('sum(case t_ch_fee.类型 when ''付'' then (case t_ch_fee.币别 when ''USD'' then t_ch_fee.金额-t_ch_fee.结算金额 else 0 end) else 0 end) as 未付USD,'); SQL.Add('sum(case t_ch_fee.类型 when ''付'' then (case t_ch_fee.币别 when ''RMB'' then t_ch_fee.金额-t_ch_fee.结算金额 else 0 end) else 0 end) as 未付RMB,'); SQL.Add('sum(case t_ch_fee.类型 when ''付'' then (t_ch_fee.金额-t_ch_fee.结算金额)*t_ch_fee.汇率 else 0 end) as 未付合计'); SQL.Add(',sum(case t_ch_fee.类型 when ''收'' then (case when (t_ch_fee.币别<>''USD'') AND (t_ch_fee.币别<>''RMB'') then t_ch_fee.金额-t_ch_fee.结算金额 else 0 end) else 0 end) as 未收其它,'); SQL.Add('sum(case t_ch_fee.类型 when ''付'' then (case when (t_ch_fee.币别<>''USD'') AND (t_ch_fee.币别<>''RMB'') then t_ch_fee.金额-t_ch_fee.结算金额 else 0 end) else 0 end) as 未付其它'); SQL.Add('from t_ch_fee inner join v_op_bscard on t_ch_fee.编号=v_op_bscard.编号 where t_ch_fee.金额<>t_ch_fee.结算金额 and t_ch_fee.金额<>0 and v_op_bscard.开船日期>='''+stredate+''' and v_op_bscard.开船日期<='''+strdate+''''); if RxDBLookupCombo5.DisplayValues[1]<>'' then SQL.Add(' and t_ch_fee.客户名称='''+RxDBLookupCombo5.DisplayValues[1]+''''); if wwDBComboBox31.Text<>'' then begin SQL.Add(' and t_ch_fee.类型='''+wwDBComboBox31.Text+''''); end; if RxDBLookupCombo3.DisplayValues[0]<>'' then begin // if wwDBComboBox14.Text='不等于' then // SQL.Add(' and v_op_bscard.揽货人<>'''+RxDBLookupCombo3.DisplayValues[0]+'''') // else SQL.Add(' and v_op_bscard.揽货人='''+RxDBLookupCombo3.DisplayValues[0]+''''); end; if RxDBLookupCombo15.DisplayValues[0]<>'' then begin // if wwDBComboBox45.Text='不等于' then // SQL.Add(' and v_op_bscard.分部名称<>'''+RxDBLookupCombo15.DisplayValues[0]+'''') // else SQL.Add(' and v_op_bscard.分部名称='''+RxDBLookupCombo15.DisplayValues[0]+''''); end; if RxDBLookupCombo12.DisplayValues[0]<>'' then begin SQL.Add(' and v_op_bscard.操作部门='''+RxDBLookupCombo12.DisplayValues[0]+''''); end; if RxDBLookupCombo10.DisplayValues[0]<>'' then begin SQL.Add(' and v_op_bscard.销售部门='''+RxDBLookupCombo10.DisplayValues[0]+''''); end; case bsSkinRadioGroup3.ItemIndex of 0,1:; 2:begin SQL.Add(' and t_ch_fee.客户名称 in (select 客户简称 from t_crm_client where 代理=1)'); end; end; SQL.Add(' and '+open_data('0033','v_op_bscard.揽货人','v_op_bscard.操作员','no','no','no')); SQL.Add('group by t_ch_fee.客户名称 order by t_ch_fee.客户名称 '); Open; if not IsEmpty then begin first; while not eof do begin if memtblDetail.Locate('统计标准',FieldbyName('客户名称').AsString,[]) then begin memtblDetail.Edit; if (wwDBComboBox31.Text='收') or (wwDBComboBox31.Text='') then begin case bsSkinRadioGroup2.ItemIndex of 0: //all begin memtblDetail.FieldByName(sDate+'未收USD').AsFloat:=memtblDetail.FieldByName(sDate+'未收USD').AsFloat+FieldbyName('未收USD').AsFloat; memtblDetail.FieldByName(sDate+'未收RMB').AsFloat:=memtblDetail.FieldByName(sDate+'未收RMB').AsFloat+FieldbyName('未收RMB').AsFloat; memtblDetail.FieldByName(sDate+'未收其它').AsFloat:=memtblDetail.FieldByName(sDate+'未收其它').AsFloat+FieldbyName('未收其它').AsFloat; memtblDetail.FieldByName(sDate+'未收合计').AsFloat:=memtblDetail.FieldByName(sDate+'未收合计').AsFloat+FieldbyName('未收合计').AsFloat; memtblDetail.FieldByName('合计未收USD').AsFloat:=memtblDetail.FieldByName('合计未收USD').AsFloat+FieldbyName('未收USD').AsFloat; memtblDetail.FieldByName('合计未收RMB').AsFloat:=memtblDetail.FieldByName('合计未收RMB').AsFloat+FieldbyName('未收RMB').AsFloat; memtblDetail.FieldByName('未收合计').AsFloat:=memtblDetail.FieldByName('未收合计').AsFloat+FieldbyName('未收合计').AsFloat; memtblDetail.FieldByName('合计未收其它').AsFloat:=memtblDetail.FieldByName('合计未收其它').AsFloat+FieldbyName('未收其它').AsFloat; end; 1: //rmb begin memtblDetail.FieldByName(sDate+'未收RMB').AsFloat:=memtblDetail.FieldByName(sDate+'未收RMB').AsFloat+FieldbyName('未收RMB').AsFloat; memtblDetail.FieldByName('合计未收RMB').AsFloat:=memtblDetail.FieldByName('合计未收RMB').AsFloat+FieldbyName('未收RMB').AsFloat; end; 2: //usd begin memtblDetail.FieldByName('合计未收USD').AsFloat:=memtblDetail.FieldByName('合计未收USD').AsFloat+FieldbyName('未收USD').AsFloat; memtblDetail.FieldByName(sDate+'未收USD').AsFloat:=memtblDetail.FieldByName(sDate+'未收USD').AsFloat+FieldbyName('未收USD').AsFloat; end; end; end; if (wwDBComboBox31.Text='付') or (wwDBComboBox31.Text='') then begin case bsSkinRadioGroup2.ItemIndex of 0: //all begin memtblDetail.FieldByName(sDate+'未付USD').AsFloat:=memtblDetail.FieldByName(sDate+'未付USD').AsFloat+FieldbyName('未付USD').AsFloat; memtblDetail.FieldByName(sDate+'未付RMB').AsFloat:=memtblDetail.FieldByName(sDate+'未付RMB').AsFloat+FieldbyName('未付RMB').AsFloat; memtblDetail.FieldByName(sDate+'未付其它').AsFloat:=memtblDetail.FieldByName(sDate+'未付其它').AsFloat+FieldbyName('未付其它').AsFloat; memtblDetail.FieldByName(sDate+'未付合计').AsFloat:=memtblDetail.FieldByName(sDate+'未付合计').AsFloat+FieldbyName('未付合计').AsFloat; memtblDetail.FieldByName('合计未付USD').AsFloat:=memtblDetail.FieldByName('合计未付USD').AsFloat+FieldbyName('未付USD').AsFloat; memtblDetail.FieldByName('合计未付RMB').AsFloat:=memtblDetail.FieldByName('合计未付RMB').AsFloat+FieldbyName('未付RMB').AsFloat; memtblDetail.FieldByName('未付合计').AsFloat:=memtblDetail.FieldByName('未付合计').AsFloat+FieldbyName('未付合计').AsFloat; memtblDetail.FieldByName('合计未付其它').AsFloat:=memtblDetail.FieldByName('合计未付其它').AsFloat+FieldbyName('未付其它').AsFloat; end; 1: //rmb begin memtblDetail.FieldByName(sDate+'未付RMB').AsFloat:=memtblDetail.FieldByName(sDate+'未付RMB').AsFloat+FieldbyName('未付RMB').AsFloat; memtblDetail.FieldByName('合计未付RMB').AsFloat:=memtblDetail.FieldByName('合计未付RMB').AsFloat+FieldbyName('未付RMB').AsFloat; end; 2: //usd begin memtblDetail.FieldByName(sDate+'未付USD').AsFloat:=memtblDetail.FieldByName(sDate+'未付USD').AsFloat+FieldbyName('未付USD').AsFloat; memtblDetail.FieldByName('合计未付USD').AsFloat:=memtblDetail.FieldByName('合计未付USD').AsFloat+FieldbyName('未付USD').AsFloat; end; end; end; if (wwDBComboBox31.Text='') then begin case bsSkinRadioGroup2.ItemIndex of 0: //all begin memtblDetail.FieldByName(sDate+'差额USD').AsFloat:=memtblDetail.FieldByName(sDate+'未收USD').AsFloat-memtblDetail.FieldByName(sDate+'未付USD').AsFloat; memtblDetail.FieldByName(sDate+'差额RMB').AsFloat:=memtblDetail.FieldByName(sDate+'未收RMB').AsFloat-memtblDetail.FieldByName(sDate+'未付RMB').AsFloat; // memtblDetail.FieldByName(sDate+'差额其它').AsFloat:=memtblDetail.FieldByName(sDate+'未收其它').AsFloat-memtblDetail.FieldByName(sDate+'未付其它').AsFloat; memtblDetail.FieldByName(sDate+'差额合计').AsFloat:=memtblDetail.FieldByName(sDate+'未收合计').AsFloat-memtblDetail.FieldByName(sDate+'未付合计').AsFloat; memtblDetail.FieldByName('合计差额USD').AsFloat:=memtblDetail.FieldByName('合计未收USD').AsFloat-memtblDetail.FieldByName('合计未付USD').AsFloat; memtblDetail.FieldByName('合计差额RMB').AsFloat:=memtblDetail.FieldByName('合计未收RMB').AsFloat-memtblDetail.FieldByName('合计未付RMB').AsFloat; memtblDetail.FieldByName('差额合计').AsFloat:=memtblDetail.FieldByName('未收合计').AsFloat-memtblDetail.FieldByName('未付合计').AsFloat; // memtblDetail.FieldByName('合计差额其它').AsFloat:=memtblDetail.FieldByName('合计差额其它').AsFloat+memtblDetail.FieldByName(sDate+'未收其它').AsFloat-memtblDetail.FieldByName(sDate+'未付其它').AsFloat; end; 1: //rmb begin memtblDetail.FieldByName(sDate+'差额RMB').AsFloat:=memtblDetail.FieldByName(sDate+'未收RMB').AsFloat-memtblDetail.FieldByName(sDate+'未付RMB').AsFloat; memtblDetail.FieldByName('合计差额RMB').AsFloat:=memtblDetail.FieldByName('合计未收RMB').AsFloat-memtblDetail.FieldByName('合计未付RMB').AsFloat; end; 2: //usd begin memtblDetail.FieldByName(sDate+'差额USD').AsFloat:=memtblDetail.FieldByName(sDate+'未收USD').AsFloat-memtblDetail.FieldByName(sDate+'未付USD').AsFloat; memtblDetail.FieldByName('合计差额USD').AsFloat:=memtblDetail.FieldByName('合计未收USD').AsFloat-memtblDetail.FieldByName('合计未付USD').AsFloat; end; end; end; memtblDetail.Post; end else begin memtblDetail.Insert; for i:=0 to memtbldetail.FieldCount-1 do begin if memtbldetail.Fields[i].FieldName='统计标准' then begin memtbldetail.Fields[i].AsString:=FieldByName('客户名称').AsString end else if memtbldetail.Fields[i].FieldName='客户帐期' then begin memtbldetail.Fields[i].AsString:=getzq(FieldByName('客户名称').AsString); end else if memtbldetail.Fields[i].FieldName='客户全称' then begin if frm_data_share.t_crm_client_all.Locate('客户简称',FieldByName('客户名称').AsString,[])then memtbldetail.Fields[i].AsString:=frm_data_share.t_crm_client_all.FieldByName('客户全称').AsString; end else memtbldetail.Fields[i].AsFloat:=0; end; if (wwDBComboBox31.Text='收') or (wwDBComboBox31.Text='') then begin case bsSkinRadioGroup2.ItemIndex of 0: //all begin memtblDetail.FieldByName(sDate+'未收USD').AsFloat:=memtblDetail.FieldByName(sDate+'未收USD').AsFloat+FieldbyName('未收USD').AsFloat; memtblDetail.FieldByName(sDate+'未收RMB').AsFloat:=memtblDetail.FieldByName(sDate+'未收RMB').AsFloat+FieldbyName('未收RMB').AsFloat; memtblDetail.FieldByName(sDate+'未收其它').AsFloat:=memtblDetail.FieldByName(sDate+'未收其它').AsFloat+FieldbyName('未收其它').AsFloat; memtblDetail.FieldByName(sDate+'未收合计').AsFloat:=memtblDetail.FieldByName(sDate+'未收合计').AsFloat+FieldbyName('未收合计').AsFloat; memtblDetail.FieldByName('合计未收USD').AsFloat:=memtblDetail.FieldByName('合计未收USD').AsFloat+FieldbyName('未收USD').AsFloat; memtblDetail.FieldByName('合计未收RMB').AsFloat:=memtblDetail.FieldByName('合计未收RMB').AsFloat+FieldbyName('未收RMB').AsFloat; memtblDetail.FieldByName('未收合计').AsFloat:=memtblDetail.FieldByName('未收合计').AsFloat+FieldbyName('未收合计').AsFloat; memtblDetail.FieldByName('合计未收其它').AsFloat:=memtblDetail.FieldByName('合计未收其它').AsFloat+FieldbyName('未收其它').AsFloat; end; 1: //rmb begin memtblDetail.FieldByName(sDate+'未收RMB').AsFloat:=memtblDetail.FieldByName(sDate+'未收RMB').AsFloat+FieldbyName('未收RMB').AsFloat; memtblDetail.FieldByName('合计未收RMB').AsFloat:=memtblDetail.FieldByName('合计未收RMB').AsFloat+FieldbyName('未收RMB').AsFloat; end; 2: //usd begin memtblDetail.FieldByName(sDate+'未收USD').AsFloat:=memtblDetail.FieldByName(sDate+'未收USD').AsFloat+FieldbyName('未收USD').AsFloat; memtblDetail.FieldByName('合计未收USD').AsFloat:=memtblDetail.FieldByName('合计未收USD').AsFloat+FieldbyName('未收USD').AsFloat; end; end; end; if (wwDBComboBox31.Text='付') or (wwDBComboBox31.Text='') then begin case bsSkinRadioGroup2.ItemIndex of 0: //all begin memtblDetail.FieldByName(sDate+'未付USD').AsFloat:=memtblDetail.FieldByName(sDate+'未付USD').AsFloat+FieldbyName('未付USD').AsFloat; memtblDetail.FieldByName(sDate+'未付RMB').AsFloat:=memtblDetail.FieldByName(sDate+'未付RMB').AsFloat+FieldbyName('未付RMB').AsFloat; memtblDetail.FieldByName(sDate+'未付其它').AsFloat:=memtblDetail.FieldByName(sDate+'未付其它').AsFloat+FieldbyName('未付其它').AsFloat; memtblDetail.FieldByName(sDate+'未付合计').AsFloat:=memtblDetail.FieldByName(sDate+'未付合计').AsFloat+FieldbyName('未付合计').AsFloat; memtblDetail.FieldByName('合计未付USD').AsFloat:=memtblDetail.FieldByName('合计未付USD').AsFloat+FieldbyName('未付USD').AsFloat; memtblDetail.FieldByName('合计未付RMB').AsFloat:=memtblDetail.FieldByName('合计未付RMB').AsFloat+FieldbyName('未付RMB').AsFloat; memtblDetail.FieldByName('未付合计').AsFloat:=memtblDetail.FieldByName('未付合计').AsFloat+FieldbyName('未付合计').AsFloat; memtblDetail.FieldByName('合计未付其它').AsFloat:=memtblDetail.FieldByName('合计未付其它').AsFloat+FieldbyName('未付其它').AsFloat; end; 1: //rmb begin memtblDetail.FieldByName(sDate+'未付RMB').AsFloat:=memtblDetail.FieldByName(sDate+'未付RMB').AsFloat+FieldbyName('未付RMB').AsFloat; memtblDetail.FieldByName('合计未付RMB').AsFloat:=memtblDetail.FieldByName('合计未付RMB').AsFloat+FieldbyName('未付RMB').AsFloat; end; 2: //usd begin memtblDetail.FieldByName(sDate+'未付USD').AsFloat:=memtblDetail.FieldByName(sDate+'未付USD').AsFloat+FieldbyName('未付USD').AsFloat; memtblDetail.FieldByName('合计未付USD').AsFloat:=memtblDetail.FieldByName('合计未付USD').AsFloat+FieldbyName('未付USD').AsFloat; end; end; end; if (wwDBComboBox31.Text='') then begin case bsSkinRadioGroup2.ItemIndex of 0: //all begin memtblDetail.FieldByName(sDate+'差额USD').AsFloat:=memtblDetail.FieldByName(sDate+'未收USD').AsFloat-memtblDetail.FieldByName(sDate+'未付USD').AsFloat; memtblDetail.FieldByName(sDate+'差额RMB').AsFloat:=memtblDetail.FieldByName(sDate+'未收RMB').AsFloat-memtblDetail.FieldByName(sDate+'未付RMB').AsFloat; memtblDetail.FieldByName(sDate+'差额合计').AsFloat:=memtblDetail.FieldByName(sDate+'未收合计').AsFloat-memtblDetail.FieldByName(sDate+'未付合计').AsFloat; memtblDetail.FieldByName('合计差额USD').AsFloat:=memtblDetail.FieldByName('合计未收USD').AsFloat-memtblDetail.FieldByName('合计未付USD').AsFloat; memtblDetail.FieldByName('合计差额RMB').AsFloat:=memtblDetail.FieldByName('合计未收RMB').AsFloat-memtblDetail.FieldByName('合计未付RMB').AsFloat; memtblDetail.FieldByName('差额合计').AsFloat:=memtblDetail.FieldByName('未收合计').AsFloat-memtblDetail.FieldByName('未付合计').AsFloat; // memtblDetail.FieldByName(sDate+'差额其它').AsFloat:=memtblDetail.FieldByName(sDate+'未收其它').AsFloat-memtblDetail.FieldByName(sDate+'未付其它').AsFloat; // memtblDetail.FieldByName('合计差额其它').AsFloat:=memtblDetail.FieldByName('合计差额其它').AsFloat+memtblDetail.FieldByName(sDate+'未收其它').AsFloat-memtblDetail.FieldByName(sDate+'未付其它').AsFloat; end; 1: //rmb begin memtblDetail.FieldByName(sDate+'差额RMB').AsFloat:=memtblDetail.FieldByName(sDate+'未收RMB').AsFloat-memtblDetail.FieldByName(sDate+'未付RMB').AsFloat; memtblDetail.FieldByName('合计差额RMB').AsFloat:=memtblDetail.FieldByName('合计未收RMB').AsFloat-memtblDetail.FieldByName('合计未付RMB').AsFloat; end; 2: //usd begin memtblDetail.FieldByName(sDate+'差额USD').AsFloat:=memtblDetail.FieldByName(sDate+'未收USD').AsFloat-memtblDetail.FieldByName(sDate+'未付USD').AsFloat; memtblDetail.FieldByName('合计差额USD').AsFloat:=memtblDetail.FieldByName('合计未收USD').AsFloat-memtblDetail.FieldByName('合计未付USD').AsFloat; end; end; end; memtblDetail.Post; end; Next; end; end; frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; aDate:=IncMonth(aDate,1); end; end; finally FreeAndNil(aQuery); freeAndNil(frm_sys_progress); end; end; procedure Tfrm_rp_no_monthtotal.GetsaleNoFee; var aQuery:TAdoQuery; aDate,aToDate:TDate; strdate,stredate,sDate:String; i:integer; // S:TChartSeries; begin aQuery:=CreateAdoQuery; try with aQuery do begin aDate:=EncodeDate(strtoint(cbYear.Text),strtoint(cbmonth.Text),1); aToDate:=EncodeDate(strtoint(cbeYear.Text),strtoint(cbemonth.Text),2); if not ASSIGNED(frm_sys_progress) then frm_sys_progress:=tfrm_sys_progress.Create(application); frm_sys_progress.Show; frm_sys_progress.bsSkinGauge1.MaxValue:=MonthsBetween(aDate,aToDate); frm_sys_progress.bsSkinGauge1.MinValue:=0; frm_sys_progress.bsSkinGauge1.Value:=0; frm_sys_progress.Update; while not (aDate>aToDate) do begin strdate:=FormatDateTime('YYYY-MM-DD',EncodeDate(strtoint(FormatDateTime('YYYY',aDate)),strtoint(FormatDateTime('MM',aDate)),MonthDays[isLeapYear(strtoint(FormatDateTime('YYYY',aDate))),strtoint(FormatDateTime('MM',aDate))])); stredate:=FormatDateTime('YYYY-MM-DD',aDate); sDate:=FormatDateTime('YYYYMM',aDate); CLOSE; SQL.Clear; SQL.Add('Select v_op_bscard.揽货人, '); SQL.Add('sum(case t_ch_fee.类型 when ''收'' then (case t_ch_fee.币别 when ''USD'' then t_ch_fee.金额-t_ch_fee.结算金额 else 0 end) else 0 end) as 未收USD,'); SQL.Add('sum(case t_ch_fee.类型 when ''收'' then (case t_ch_fee.币别 when ''RMB'' then t_ch_fee.金额-t_ch_fee.结算金额 else 0 end) else 0 end) as 未收RMB,'); SQL.Add('sum(case t_ch_fee.类型 when ''收'' then (t_ch_fee.金额-t_ch_fee.结算金额)*t_ch_fee.汇率 else 0 end) as 未收合计,'); SQL.Add('sum(case t_ch_fee.类型 when ''付'' then (case t_ch_fee.币别 when ''USD'' then t_ch_fee.金额-t_ch_fee.结算金额 else 0 end) else 0 end) as 未付USD,'); SQL.Add('sum(case t_ch_fee.类型 when ''付'' then (case t_ch_fee.币别 when ''RMB'' then t_ch_fee.金额-t_ch_fee.结算金额 else 0 end) else 0 end) as 未付RMB,'); SQL.Add('sum(case t_ch_fee.类型 when ''付'' then (t_ch_fee.金额-t_ch_fee.结算金额)*t_ch_fee.汇率 else 0 end) as 未付合计'); SQL.Add(',sum(case t_ch_fee.类型 when ''收'' then (case when (t_ch_fee.币别<>''USD'') AND (t_ch_fee.币别<>''RMB'') then t_ch_fee.金额-t_ch_fee.结算金额 else 0 end) else 0 end) as 未收其它,'); SQL.Add('sum(case t_ch_fee.类型 when ''付'' then (case when (t_ch_fee.币别<>''USD'') AND (t_ch_fee.币别<>''RMB'') then t_ch_fee.金额-t_ch_fee.结算金额 else 0 end) else 0 end) as 未付其它'); SQL.Add('from t_ch_fee inner join v_op_bscard on t_ch_fee.编号=v_op_bscard.编号 where t_ch_fee.金额<>t_ch_fee.结算金额 and v_op_bscard.开船日期>='''+stredate+''' and v_op_bscard.开船日期<='''+strdate+''''); if RxDBLookupCombo5.DisplayValues[1]<>'' then SQL.Add(' and t_ch_fee.客户名称='''+RxDBLookupCombo5.DisplayValues[1]+''''); if (wwDBComboBox31.Text='收') or (wwDBComboBox31.Text='付') then SQL.Add(' and t_ch_fee.类型='''+wwDBComboBox31.Text+''''); if RxDBLookupCombo3.DisplayValues[0]<>'' then begin // if wwDBComboBox14.Text='不等于' then // SQL.Add(' and v_op_bscard.揽货人<>'''+RxDBLookupCombo3.DisplayValues[0]+'''') // else SQL.Add(' and v_op_bscard.揽货人='''+RxDBLookupCombo3.DisplayValues[0]+''''); end; if RxDBLookupCombo15.DisplayValues[0]<>'' then begin // if wwDBComboBox45.Text='不等于' then // SQL.Add(' and v_op_bscard.分部名称<>'''+RxDBLookupCombo15.DisplayValues[0]+'''') // else SQL.Add(' and v_op_bscard.分部名称='''+RxDBLookupCombo15.DisplayValues[0]+''''); end; if RxDBLookupCombo12.DisplayValues[0]<>'' then begin SQL.Add(' and v_op_bscard.操作部门='''+RxDBLookupCombo12.DisplayValues[0]+''''); end; if RxDBLookupCombo10.DisplayValues[0]<>'' then begin SQL.Add(' and v_op_bscard.销售部门='''+RxDBLookupCombo10.DisplayValues[0]+''''); end; SQL.Add(' and '+open_data('0033','v_op_bscard.揽货人','v_op_bscard.操作员','no','no','no')); SQL.Add('group by v_op_bscard.揽货人 order by v_op_bscard.揽货人 '); Open; if not IsEmpty then begin first; while not eof do begin if memtblDetail.Locate('统计标准',FieldbyName('揽货人').AsString,[]) then begin memtblDetail.Edit; if (wwDBComboBox31.Text='收') or (wwDBComboBox31.Text='') then begin memtblDetail.FieldByName(sDate+'未收USD').AsFloat:=memtblDetail.FieldByName(sDate+'未收USD').AsFloat+FieldbyName('未收USD').AsFloat; memtblDetail.FieldByName(sDate+'未收RMB').AsFloat:=memtblDetail.FieldByName(sDate+'未收RMB').AsFloat+FieldbyName('未收RMB').AsFloat; memtblDetail.FieldByName(sDate+'未收合计').AsFloat:=memtblDetail.FieldByName(sDate+'未收合计').AsFloat+FieldbyName('未收合计').AsFloat; memtblDetail.FieldByName('合计未收USD').AsFloat:=memtblDetail.FieldByName('合计未收USD').AsFloat+FieldbyName('未收USD').AsFloat; memtblDetail.FieldByName('合计未收RMB').AsFloat:=memtblDetail.FieldByName('合计未收RMB').AsFloat+FieldbyName('未收RMB').AsFloat; memtblDetail.FieldByName('未收合计').AsFloat:=memtblDetail.FieldByName('未收合计').AsFloat+FieldbyName('未收合计').AsFloat; end; if (wwDBComboBox31.Text='付') or (wwDBComboBox31.Text='') then begin memtblDetail.FieldByName(sDate+'未付USD').AsFloat:=memtblDetail.FieldByName(sDate+'未付USD').AsFloat+FieldbyName('未付USD').AsFloat; memtblDetail.FieldByName(sDate+'未付RMB').AsFloat:=memtblDetail.FieldByName(sDate+'未付RMB').AsFloat+FieldbyName('未付RMB').AsFloat; memtblDetail.FieldByName(sDate+'未付合计').AsFloat:=memtblDetail.FieldByName(sDate+'未付合计').AsFloat+FieldbyName('未付合计').AsFloat; memtblDetail.FieldByName('合计未付USD').AsFloat:=memtblDetail.FieldByName('合计未付USD').AsFloat+FieldbyName('未付USD').AsFloat; memtblDetail.FieldByName('合计未付RMB').AsFloat:=memtblDetail.FieldByName('合计未付RMB').AsFloat+FieldbyName('未付RMB').AsFloat; memtblDetail.FieldByName('未付合计').AsFloat:=memtblDetail.FieldByName('未付合计').AsFloat+FieldbyName('未付合计').AsFloat; end; if (wwDBComboBox31.Text='') then begin memtblDetail.FieldByName(sDate+'差额USD').AsFloat:=memtblDetail.FieldByName(sDate+'未收USD').AsFloat-memtblDetail.FieldByName(sDate+'未付USD').AsFloat; memtblDetail.FieldByName(sDate+'差额RMB').AsFloat:=memtblDetail.FieldByName(sDate+'未收RMB').AsFloat-memtblDetail.FieldByName(sDate+'未付RMB').AsFloat; memtblDetail.FieldByName(sDate+'差额合计').AsFloat:=memtblDetail.FieldByName(sDate+'未收合计').AsFloat-memtblDetail.FieldByName(sDate+'未付合计').AsFloat; memtblDetail.FieldByName('合计差额USD').AsFloat:=memtblDetail.FieldByName('合计未收USD').AsFloat-memtblDetail.FieldByName('合计未付USD').AsFloat; memtblDetail.FieldByName('合计差额RMB').AsFloat:=memtblDetail.FieldByName('合计未收RMB').AsFloat-memtblDetail.FieldByName('合计未付RMB').AsFloat; memtblDetail.FieldByName('差额合计').AsFloat:=memtblDetail.FieldByName('未收合计').AsFloat-memtblDetail.FieldByName('未付合计').AsFloat; end; memtblDetail.Post; end else begin memtblDetail.Insert; for i:=0 to memtbldetail.FieldCount-1 do begin if memtbldetail.Fields[i].FieldName='统计标准' then memtbldetail.Fields[i].AsString:=FieldByName('揽货人').AsString else memtbldetail.Fields[i].AsFloat:=0; end; if (wwDBComboBox31.Text='收') or (wwDBComboBox31.Text='') then begin memtblDetail.FieldByName(sDate+'未收USD').AsFloat:=memtblDetail.FieldByName(sDate+'未收USD').AsFloat+FieldbyName('未收USD').AsFloat; memtblDetail.FieldByName(sDate+'未收RMB').AsFloat:=memtblDetail.FieldByName(sDate+'未收RMB').AsFloat+FieldbyName('未收RMB').AsFloat; memtblDetail.FieldByName(sDate+'未收合计').AsFloat:=memtblDetail.FieldByName(sDate+'未收合计').AsFloat+FieldbyName('未收合计').AsFloat; memtblDetail.FieldByName('合计未收USD').AsFloat:=memtblDetail.FieldByName('合计未收USD').AsFloat+FieldbyName('未收USD').AsFloat; memtblDetail.FieldByName('合计未收RMB').AsFloat:=memtblDetail.FieldByName('合计未收RMB').AsFloat+FieldbyName('未收RMB').AsFloat; memtblDetail.FieldByName('未收合计').AsFloat:=memtblDetail.FieldByName('未收合计').AsFloat+FieldbyName('未收合计').AsFloat; end; if (wwDBComboBox31.Text='付') or (wwDBComboBox31.Text='') then begin memtblDetail.FieldByName(sDate+'未付USD').AsFloat:=memtblDetail.FieldByName(sDate+'未付USD').AsFloat+FieldbyName('未付USD').AsFloat; memtblDetail.FieldByName(sDate+'未付RMB').AsFloat:=memtblDetail.FieldByName(sDate+'未付RMB').AsFloat+FieldbyName('未付RMB').AsFloat; memtblDetail.FieldByName(sDate+'未付合计').AsFloat:=memtblDetail.FieldByName(sDate+'未付合计').AsFloat+FieldbyName('未付合计').AsFloat; memtblDetail.FieldByName('合计未付USD').AsFloat:=memtblDetail.FieldByName('合计未付USD').AsFloat+FieldbyName('未付USD').AsFloat; memtblDetail.FieldByName('合计未付RMB').AsFloat:=memtblDetail.FieldByName('合计未付RMB').AsFloat+FieldbyName('未付RMB').AsFloat; memtblDetail.FieldByName('未付合计').AsFloat:=memtblDetail.FieldByName('未付合计').AsFloat+FieldbyName('未付合计').AsFloat; end; if (wwDBComboBox31.Text='') then begin memtblDetail.FieldByName(sDate+'差额USD').AsFloat:=memtblDetail.FieldByName(sDate+'未收USD').AsFloat-memtblDetail.FieldByName(sDate+'未付USD').AsFloat; memtblDetail.FieldByName(sDate+'差额RMB').AsFloat:=memtblDetail.FieldByName(sDate+'未收RMB').AsFloat-memtblDetail.FieldByName(sDate+'未付RMB').AsFloat; memtblDetail.FieldByName(sDate+'差额合计').AsFloat:=memtblDetail.FieldByName(sDate+'未收合计').AsFloat-memtblDetail.FieldByName(sDate+'未付合计').AsFloat; memtblDetail.FieldByName('合计差额USD').AsFloat:=memtblDetail.FieldByName('合计未收USD').AsFloat-memtblDetail.FieldByName('合计未付USD').AsFloat; memtblDetail.FieldByName('合计差额RMB').AsFloat:=memtblDetail.FieldByName('合计未收RMB').AsFloat-memtblDetail.FieldByName('合计未付RMB').AsFloat; memtblDetail.FieldByName('差额合计').AsFloat:=memtblDetail.FieldByName('未收合计').AsFloat-memtblDetail.FieldByName('未付合计').AsFloat; end; memtblDetail.Post; end; Next; end; end; frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; aDate:=IncMonth(aDate,1); end; end; finally FreeAndNil(aQuery); freeAndNil(frm_sys_progress); end; end; procedure Tfrm_rp_no_monthtotal.GetcustsaleNoFee; var aQuery:TAdoQuery; aDate,aToDate:TDate; strdate,stredate,sDate:String; i:integer; // S:TChartSeries; begin aQuery:=CreateAdoQuery; try with aQuery do begin aDate:=EncodeDate(strtoint(cbYear.Text),strtoint(cbmonth.Text),1); aToDate:=EncodeDate(strtoint(cbeYear.Text),strtoint(cbemonth.Text),2); if not ASSIGNED(frm_sys_progress) then frm_sys_progress:=tfrm_sys_progress.Create(application); frm_sys_progress.Show; frm_sys_progress.bsSkinGauge1.MaxValue:=MonthsBetween(aDate,aToDate); frm_sys_progress.bsSkinGauge1.MinValue:=0; frm_sys_progress.bsSkinGauge1.Value:=0; frm_sys_progress.Update; while not (aDate>aToDate) do begin strdate:=FormatDateTime('YYYY-MM-DD',EncodeDate(strtoint(FormatDateTime('YYYY',aDate)),strtoint(FormatDateTime('MM',aDate)),MonthDays[isLeapYear(strtoint(FormatDateTime('YYYY',aDate))),strtoint(FormatDateTime('MM',aDate))])); stredate:=FormatDateTime('YYYY-MM-DD',aDate); sDate:=FormatDateTime('YYYYMM',aDate); CLOSE; SQL.Clear; SQL.Add('Select t_ch_fee.客户名称,v_op_bscard.揽货人, '); SQL.Add('sum(case t_ch_fee.类型 when ''收'' then (case t_ch_fee.币别 when ''USD'' then t_ch_fee.金额-t_ch_fee.结算金额 else 0 end) else 0 end) as 未收USD,'); SQL.Add('sum(case t_ch_fee.类型 when ''收'' then (case t_ch_fee.币别 when ''RMB'' then t_ch_fee.金额-t_ch_fee.结算金额 else 0 end) else 0 end) as 未收RMB,'); SQL.Add('sum(case t_ch_fee.类型 when ''收'' then (t_ch_fee.金额-t_ch_fee.结算金额)*t_ch_fee.汇率 else 0 end) as 未收合计,'); SQL.Add('sum(case t_ch_fee.类型 when ''付'' then (case t_ch_fee.币别 when ''USD'' then t_ch_fee.金额-t_ch_fee.结算金额 else 0 end) else 0 end) as 未付USD,'); SQL.Add('sum(case t_ch_fee.类型 when ''付'' then (case t_ch_fee.币别 when ''RMB'' then t_ch_fee.金额-t_ch_fee.结算金额 else 0 end) else 0 end) as 未付RMB,'); SQL.Add('sum(case t_ch_fee.类型 when ''付'' then (t_ch_fee.金额-t_ch_fee.结算金额)*t_ch_fee.汇率 else 0 end) as 未付合计'); SQL.Add(',sum(case t_ch_fee.类型 when ''收'' then (case when (t_ch_fee.币别<>''USD'') AND (t_ch_fee.币别<>''RMB'') then t_ch_fee.金额-t_ch_fee.结算金额 else 0 end) else 0 end) as 未收其它,'); SQL.Add('sum(case t_ch_fee.类型 when ''付'' then (case when (t_ch_fee.币别<>''USD'') AND (t_ch_fee.币别<>''RMB'') then t_ch_fee.金额-t_ch_fee.结算金额 else 0 end) else 0 end) as 未付其它'); SQL.Add('from t_ch_fee inner join v_op_bscard on t_ch_fee.编号=v_op_bscard.编号 where t_ch_fee.金额<>t_ch_fee.结算金额 and v_op_bscard.开船日期>='''+stredate+''' and v_op_bscard.开船日期<='''+strdate+''''); if RxDBLookupCombo5.DisplayValues[1]<>'' then SQL.Add(' and t_ch_fee.客户名称='''+RxDBLookupCombo5.DisplayValues[1]+''''); if (wwDBComboBox31.Text='收') or (wwDBComboBox31.Text='付') then SQL.Add(' and t_ch_fee.类型='''+wwDBComboBox31.Text+''''); if RxDBLookupCombo3.DisplayValues[0]<>'' then begin // if wwDBComboBox14.Text='不等于' then // SQL.Add(' and v_op_bscard.揽货人<>'''+RxDBLookupCombo3.DisplayValues[0]+'''') // else SQL.Add(' and v_op_bscard.揽货人='''+RxDBLookupCombo3.DisplayValues[0]+''''); end; if RxDBLookupCombo15.DisplayValues[0]<>'' then begin // if wwDBComboBox45.Text='不等于' then // SQL.Add(' and v_op_bscard.分部名称<>'''+RxDBLookupCombo15.DisplayValues[0]+'''') // else SQL.Add(' and v_op_bscard.分部名称='''+RxDBLookupCombo15.DisplayValues[0]+''''); end; if RxDBLookupCombo12.DisplayValues[0]<>'' then begin SQL.Add(' and v_op_bscard.操作部门='''+RxDBLookupCombo12.DisplayValues[0]+''''); end; if RxDBLookupCombo10.DisplayValues[0]<>'' then begin SQL.Add(' and v_op_bscard.销售部门='''+RxDBLookupCombo10.DisplayValues[0]+''''); end; SQL.Add(' and '+open_data('0033','v_op_bscard.揽货人','v_op_bscard.操作员','no','no','no')); SQL.Add('group by t_ch_fee.客户名称,v_op_bscard.揽货人 order by t_ch_fee.客户名称 '); Open; if not IsEmpty then begin first; while not eof do begin if memtblDetail.Locate('统计标准;统计标准2',vararrayof([fieldbyname('客户名称').asstring,FieldbyName('揽货人').AsString]),[]) then begin memtblDetail.Edit; if (wwDBComboBox31.Text='收') or (wwDBComboBox31.Text='') then begin memtblDetail.FieldByName(sDate+'未收USD').AsFloat:=memtblDetail.FieldByName(sDate+'未收USD').AsFloat+FieldbyName('未收USD').AsFloat; memtblDetail.FieldByName(sDate+'未收RMB').AsFloat:=memtblDetail.FieldByName(sDate+'未收RMB').AsFloat+FieldbyName('未收RMB').AsFloat; memtblDetail.FieldByName(sDate+'未收合计').AsFloat:=memtblDetail.FieldByName(sDate+'未收合计').AsFloat+FieldbyName('未收合计').AsFloat; memtblDetail.FieldByName('合计未收USD').AsFloat:=memtblDetail.FieldByName('合计未收USD').AsFloat+FieldbyName('未收USD').AsFloat; memtblDetail.FieldByName('合计未收RMB').AsFloat:=memtblDetail.FieldByName('合计未收RMB').AsFloat+FieldbyName('未收RMB').AsFloat; memtblDetail.FieldByName('未收合计').AsFloat:=memtblDetail.FieldByName('未收合计').AsFloat+FieldbyName('未收合计').AsFloat; end; if (wwDBComboBox31.Text='付') or (wwDBComboBox31.Text='') then begin memtblDetail.FieldByName(sDate+'未付USD').AsFloat:=memtblDetail.FieldByName(sDate+'未付USD').AsFloat+FieldbyName('未付USD').AsFloat; memtblDetail.FieldByName(sDate+'未付RMB').AsFloat:=memtblDetail.FieldByName(sDate+'未付RMB').AsFloat+FieldbyName('未付RMB').AsFloat; memtblDetail.FieldByName(sDate+'未付合计').AsFloat:=memtblDetail.FieldByName(sDate+'未付合计').AsFloat+FieldbyName('未付合计').AsFloat; memtblDetail.FieldByName('合计未付USD').AsFloat:=memtblDetail.FieldByName('合计未付USD').AsFloat+FieldbyName('未付USD').AsFloat; memtblDetail.FieldByName('合计未付RMB').AsFloat:=memtblDetail.FieldByName('合计未付RMB').AsFloat+FieldbyName('未付RMB').AsFloat; memtblDetail.FieldByName('未付合计').AsFloat:=memtblDetail.FieldByName('未付合计').AsFloat+FieldbyName('未付合计').AsFloat; end; if (wwDBComboBox31.Text='') then begin memtblDetail.FieldByName(sDate+'差额USD').AsFloat:=memtblDetail.FieldByName(sDate+'未收USD').AsFloat-memtblDetail.FieldByName(sDate+'未付USD').AsFloat; memtblDetail.FieldByName(sDate+'差额RMB').AsFloat:=memtblDetail.FieldByName(sDate+'未收RMB').AsFloat-memtblDetail.FieldByName(sDate+'未付RMB').AsFloat; memtblDetail.FieldByName(sDate+'差额合计').AsFloat:=memtblDetail.FieldByName(sDate+'未收合计').AsFloat-memtblDetail.FieldByName(sDate+'未付合计').AsFloat; memtblDetail.FieldByName('合计差额USD').AsFloat:=memtblDetail.FieldByName('合计未收USD').AsFloat-memtblDetail.FieldByName('合计未付USD').AsFloat; memtblDetail.FieldByName('合计差额RMB').AsFloat:=memtblDetail.FieldByName('合计未收RMB').AsFloat-memtblDetail.FieldByName('合计未付RMB').AsFloat; memtblDetail.FieldByName('差额合计').AsFloat:=memtblDetail.FieldByName('未收合计').AsFloat-memtblDetail.FieldByName('未付合计').AsFloat; end; memtblDetail.Post; end else begin memtblDetail.Insert; for i:=0 to memtbldetail.FieldCount-1 do begin if memtbldetail.Fields[i].FieldName='统计标准' then memtbldetail.Fields[i].AsString:=FieldByName('客户名称').AsString else if memtbldetail.Fields[i].FieldName='统计标准2' then memtbldetail.Fields[i].AsString:=FieldByName('揽货人').AsString else if memtbldetail.Fields[i].FieldName='客户帐期' then begin memtbldetail.Fields[i].AsString:=getzq(FieldByName('客户名称').AsString); end else if memtbldetail.Fields[i].FieldName='客户全称' then begin if frm_data_share.t_crm_client_all.Locate('客户简称',FieldByName('客户名称').AsString,[])then memtbldetail.Fields[i].AsString:=frm_data_share.t_crm_client_all.FieldByName('客户全称').AsString; end else memtbldetail.Fields[i].AsFloat:=0; end; if (wwDBComboBox31.Text='收') or (wwDBComboBox31.Text='') then begin memtblDetail.FieldByName(sDate+'未收USD').AsFloat:=memtblDetail.FieldByName(sDate+'未收USD').AsFloat+FieldbyName('未收USD').AsFloat; memtblDetail.FieldByName(sDate+'未收RMB').AsFloat:=memtblDetail.FieldByName(sDate+'未收RMB').AsFloat+FieldbyName('未收RMB').AsFloat; memtblDetail.FieldByName(sDate+'未收合计').AsFloat:=memtblDetail.FieldByName(sDate+'未收合计').AsFloat+FieldbyName('未收合计').AsFloat; memtblDetail.FieldByName('合计未收USD').AsFloat:=memtblDetail.FieldByName('合计未收USD').AsFloat+FieldbyName('未收USD').AsFloat; memtblDetail.FieldByName('合计未收RMB').AsFloat:=memtblDetail.FieldByName('合计未收RMB').AsFloat+FieldbyName('未收RMB').AsFloat; memtblDetail.FieldByName('未收合计').AsFloat:=memtblDetail.FieldByName('未收合计').AsFloat+FieldbyName('未收合计').AsFloat; end; if (wwDBComboBox31.Text='付') or (wwDBComboBox31.Text='') then begin memtblDetail.FieldByName(sDate+'未付USD').AsFloat:=memtblDetail.FieldByName(sDate+'未付USD').AsFloat+FieldbyName('未付USD').AsFloat; memtblDetail.FieldByName(sDate+'未付RMB').AsFloat:=memtblDetail.FieldByName(sDate+'未付RMB').AsFloat+FieldbyName('未付RMB').AsFloat; memtblDetail.FieldByName(sDate+'未付合计').AsFloat:=memtblDetail.FieldByName(sDate+'未付合计').AsFloat+FieldbyName('未付合计').AsFloat; memtblDetail.FieldByName('合计未付USD').AsFloat:=memtblDetail.FieldByName('合计未付USD').AsFloat+FieldbyName('未付USD').AsFloat; memtblDetail.FieldByName('合计未付RMB').AsFloat:=memtblDetail.FieldByName('合计未付RMB').AsFloat+FieldbyName('未付RMB').AsFloat; memtblDetail.FieldByName('未付合计').AsFloat:=memtblDetail.FieldByName('未付合计').AsFloat+FieldbyName('未付合计').AsFloat; end; if (wwDBComboBox31.Text='') then begin memtblDetail.FieldByName(sDate+'差额USD').AsFloat:=memtblDetail.FieldByName(sDate+'未收USD').AsFloat-memtblDetail.FieldByName(sDate+'未付USD').AsFloat; memtblDetail.FieldByName(sDate+'差额RMB').AsFloat:=memtblDetail.FieldByName(sDate+'未收RMB').AsFloat-memtblDetail.FieldByName(sDate+'未付RMB').AsFloat; memtblDetail.FieldByName(sDate+'差额合计').AsFloat:=memtblDetail.FieldByName(sDate+'未收合计').AsFloat-memtblDetail.FieldByName(sDate+'未付合计').AsFloat; memtblDetail.FieldByName('合计差额USD').AsFloat:=memtblDetail.FieldByName('合计未收USD').AsFloat-memtblDetail.FieldByName('合计未付USD').AsFloat; memtblDetail.FieldByName('合计差额RMB').AsFloat:=memtblDetail.FieldByName('合计未收RMB').AsFloat-memtblDetail.FieldByName('合计未付RMB').AsFloat; memtblDetail.FieldByName('差额合计').AsFloat:=memtblDetail.FieldByName('未收合计').AsFloat-memtblDetail.FieldByName('未付合计').AsFloat; end; memtblDetail.Post; end; Next; end; end; frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; aDate:=IncMonth(aDate,1); end; end; finally FreeAndNil(aQuery); freeAndNil(frm_sys_progress); end; end; procedure Tfrm_rp_no_monthtotal.Creatememtbl; var aDate,aToDate:TDate; sDate,aYear,aMonth:String; aColumn:TdxDBTreeListColumn; aBand:TdxTreeListBand; i:integer; begin dxDBGrid1.Bands.Clear; while dxDBGrid1.columncount>0 do begin dxDBGrid1.Columns[0].Destroy; end; memtblDetail.Close; memtblDetail.EmptyTable; memtblDetail.Fields.Clear; memtblDetail.FieldDefs.Clear; memtblDetail.FieldDefs.Add('统计标准', ftString, 20, false); aBand:=dxDBGrid1.Bands.Add; aBand.Caption:='基本信息'; aBand.Fixed:=BFLEFT; aColumn:=dxDBGrid1.CreateColumn(TdxDBGridColumn); if not (bsSkinRadioGroup1.ItemIndex=2) then aColumn.Caption:=bsSkinRadioGroup1.Items[bsSkinRadioGroup1.Itemindex] else aColumn.Caption:='客户名称'; aColumn.BandIndex:=0; aColumn.FieldName:='统计标准'; if bsSkinRadioGroup1.ItemIndex=2 then begin aColumn:=dxDBGrid1.CreateColumn(TdxDBGridColumn); aColumn.Caption:='揽货人'; aColumn.BandIndex:=0; aColumn.FieldName:='统计标准2'; memtblDetail.FieldDefs.Add('统计标准2', ftString, 20, false); end; if (bsSkinRadioGroup1.ItemIndex=0) or (bsSkinRadioGroup1.ItemIndex=2) then begin aColumn:=dxDBGrid1.CreateColumn(TdxDBGridColumn); aColumn.Caption:='客户帐期描述'; aColumn.BandIndex:=0; aColumn.FieldName:='客户帐期'; memtblDetail.FieldDefs.Add('客户帐期', ftString, 60, false); aColumn:=dxDBGrid1.CreateColumn(TdxDBGridColumn); aColumn.Caption:='客户全称'; aColumn.BandIndex:=0; aColumn.FieldName:='客户全称'; memtblDetail.FieldDefs.Add('客户全称', ftString, 60, false); end; // aColumn.SummaryFooterText:='双击查看明细'; aDate:=EncodeDate(strtoint(cbyear.text),strtoint(cbmonth.Text),1); aToDate:=EncodeDate(strtoint(cbeyear.text),strtoint(cbemonth.Text),2); i:=1; while aDate=leng then begin result:=str; exit; end; while length(str)'' then str_bill:=str_bill+' and t_ch_fee.客户名称='''+RxDBLookupCombo5.DisplayValues[1]+''''; str_bill:=str_bill+' and t_ch_fee.客户名称='''+salename+''''; if (wwDBComboBox31.Text='收') or (wwDBComboBox31.Text='付') then str_bill:=str_bill+' and t_ch_fee.类型='''+wwDBComboBox31.Text+''''; if RxDBLookupCombo3.DisplayValues[0]<>'' then begin // if wwDBComboBox14.Text='不等于' then // str_bill:=str_bill+' and v_op_bscard.揽货人<>'''+RxDBLookupCombo3.DisplayValues[0]+'''' // else str_bill:=str_bill+' and v_op_bscard.揽货人='''+RxDBLookupCombo3.DisplayValues[0]+''''; end; if RxDBLookupCombo15.DisplayValues[0]<>'' then begin // if wwDBComboBox45.Text='不等于' then // str_bill:=str_bill+' and v_op_bscard.分部名称<>'''+RxDBLookupCombo15.DisplayValues[0]+'''' // else str_bill:=str_bill+' and v_op_bscard.分部名称='''+RxDBLookupCombo15.DisplayValues[0]+''''; end; if RxDBLookupCombo12.DisplayValues[0]<>'' then begin str_bill:=str_bill+' and v_op_bscard.操作部门='''+RxDBLookupCombo12.DisplayValues[0]+''''; end; if RxDBLookupCombo10.DisplayValues[0]<>'' then begin str_bill:=str_bill+' and v_op_bscard.销售部门='''+RxDBLookupCombo10.DisplayValues[0]+''''; end; p_detail.close; p_detail.Parameters.ParamByName('SQLStr').value:= 'SELECT t_ch_fee.编号, t_ch_fee.客户名称 as 统计标准,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'收'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then t_ch_fee.金额 else 0 end) ELSE 0 END) as 应收USD,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'收'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then t_ch_fee.结算金额 else 0 end) ELSE 0 END) as 已收USD,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'收'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then t_ch_fee.金额-t_ch_fee.结算金额 else 0 end) ELSE 0 END) as 未收USD,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'收'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then 0 else t_ch_fee.金额*t_ch_fee.汇率 end) ELSE 0 END) as 应收RMB,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'收'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then 0 else t_ch_fee.结算金额*t_ch_fee.汇率 end) ELSE 0 END) as 已收RMB,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'收'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then 0 else (t_ch_fee.金额-t_ch_fee.结算金额)*t_ch_fee.汇率 end) ELSE 0 END) as 未收RMB,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'收'+'''' +' THEN t_ch_fee.金额*t_ch_fee.汇率 ELSE 0 END) as 应收合计,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'收'+'''' +' THEN t_ch_fee.结算金额*t_ch_fee.汇率 ELSE 0 END) as 已收合计,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'收'+'''' +' THEN (t_ch_fee.金额-t_ch_fee.结算金额)*t_ch_fee.汇率 ELSE 0 END) as 未收合计,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'付'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then t_ch_fee.金额 else 0 end) ELSE 0 END) as 应付USD,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'付'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then t_ch_fee.结算金额 else 0 end) ELSE 0 END) as 已付USD,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'付'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then t_ch_fee.金额-t_ch_fee.结算金额 else 0 end) ELSE 0 END) as 未付USD,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'付'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then 0 else t_ch_fee.金额*t_ch_fee.汇率 end) ELSE 0 END) as 应付RMB,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'付'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then 0 else t_ch_fee.结算金额*t_ch_fee.汇率 end) ELSE 0 END) as 已付RMB,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'付'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then 0 else (t_ch_fee.金额-t_ch_fee.结算金额)*t_ch_fee.汇率 end) ELSE 0 END) as 未付RMB,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'付'+'''' +' THEN t_ch_fee.金额*t_ch_fee.汇率 ELSE 0 END) as 应付合计,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'付'+'''' +' THEN t_ch_fee.结算金额*t_ch_fee.汇率 ELSE 0 END) as 已付合计,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'付'+'''' +' THEN (t_ch_fee.金额-t_ch_fee.结算金额)*t_ch_fee.汇率 ELSE 0 END) as 未付合计,' +'v_op_bscard.业务编号, v_op_bscard.会计期间, v_op_bscard.主提单号,' +'v_op_bscard.分提单号, v_op_bscard.委托编号, v_op_bscard.装运方式,' +'v_op_bscard.委托单位, v_op_bscard.业务类型, ' +'v_op_bscard.航次, v_op_bscard.船名, v_op_bscard.开船日期,' +'v_op_bscard.装货港, v_op_bscard.卸货港, ' +'v_op_bscard.件数, v_op_bscard.重量, v_op_bscard.尺码,v_op_bscard.货物名称,' +'v_op_bscard.箱型1, v_op_bscard.箱型2, v_op_bscard.箱型3,' +'v_op_bscard.箱型4, v_op_bscard.箱型5, v_op_bscard.箱型6,' +'v_op_bscard.箱型7, v_op_bscard.箱型8, v_op_bscard.箱型9,' +'v_op_bscard.箱型10, v_op_bscard.其他箱型,' +'v_op_bscard.箱TEU, v_op_bscard.集装箱, v_op_bscard.操作员,' +'v_op_bscard.揽货人, v_op_bscard.客服员, v_op_bscard.航线,' +'v_op_bscard.船公司, v_op_bscard.货代公司, v_op_bscard.报关行,v_op_bscard.报关单号,v_op_bscard.报检单号,v_op_bscard.发票号,' +'(case when round((case when v_op_bscard.重量/1000>v_op_bscard.尺码 then v_op_bscard.重量/1000 ' +'else v_op_bscard.尺码 end),4)>1 then ' +'round((case when v_op_bscard.重量/1000>v_op_bscard.尺码 then v_op_bscard.重量/1000 else ' +'v_op_bscard.尺码 end),4) else ' +'1 end) as 计费吨' +' FROM t_ch_fee inner join v_op_bscard on v_op_bscard.编号=t_ch_fee.编号 ' +str_bill +' GROUP BY t_ch_fee.编号, t_ch_fee.客户名称,' +'v_op_bscard.业务编号, v_op_bscard.会计期间, v_op_bscard.主提单号,' +'v_op_bscard.分提单号, v_op_bscard.委托编号, v_op_bscard.装运方式,' +'v_op_bscard.委托单位, v_op_bscard.业务类型,' +'v_op_bscard.航次, v_op_bscard.船名, v_op_bscard.开船日期,' +'v_op_bscard.装货港, v_op_bscard.卸货港, ' +'v_op_bscard.件数, v_op_bscard.重量, v_op_bscard.尺码,v_op_bscard.货物名称,' +'v_op_bscard.箱型1, v_op_bscard.箱型2, v_op_bscard.箱型3,' +'v_op_bscard.箱型4, v_op_bscard.箱型5, v_op_bscard.箱型6,' +'v_op_bscard.箱型7, v_op_bscard.箱型8, v_op_bscard.箱型9,' +'v_op_bscard.箱型10,v_op_bscard.其他箱型,' +'v_op_bscard.箱TEU, v_op_bscard.集装箱, v_op_bscard.操作员,' +'v_op_bscard.揽货人, v_op_bscard.客服员, v_op_bscard.航线,' +'v_op_bscard.船公司, v_op_bscard.货代公司, v_op_bscard.报关行,v_op_bscard.报关单号,v_op_bscard.报检单号,v_op_bscard.发票号,' +'(case when round((case when v_op_bscard.重量/1000>v_op_bscard.尺码 then v_op_bscard.重量/1000 ' +'else v_op_bscard.尺码 end),4)>1 then ' +'round((case when v_op_bscard.重量/1000>v_op_bscard.尺码 then v_op_bscard.重量/1000 else ' +'v_op_bscard.尺码 end),4) else 1 end)' +default_sort_two(53,'v_op_bscard','v_op_bscard.业务编号','',''); // sl.Add(p_detail.Parameters.ParamByName('SQLStr').value); // sl.SaveToFile('d:\1.txt'); p_detail.Open; end else begin aDate:=EncodeDate(strtoint(cbeyear.text),strtoint(cbemonth.Text),1); stredate:=FormatDateTime('YYYY-MM-DD',EncodeDate(strtoint(FormatDateTime('YYYY',aDate)),strtoint(FormatDateTime('MM',aDate)),MonthDays[isLeapYear(strtoint(FormatDateTime('YYYY',aDate))),strtoint(FormatDateTime('MM',aDate))])); strdate:=FormatDateTime('YYYY-MM-DD',EncodeDate(strtoint(cbyear.text),strtoint(cbmonth.Text),1)); str_bill:=' where t_ch_fee.金额<>t_ch_fee.结算金额 and v_op_bscard.开船日期>='''+strdate+''' and v_op_bscard.开船日期<='''+stredate+''''; if RxDBLookupCombo5.DisplayValues[1]<>'' then str_bill:=str_bill+' and t_ch_fee.客户名称='''+RxDBLookupCombo5.DisplayValues[1]+''''; str_bill:=str_bill+' and v_op_bscard.揽货人='''+salename+''''; if (wwDBComboBox31.Text='收') or (wwDBComboBox31.Text='付') then str_bill:=str_bill+' and t_ch_fee.类型='''+wwDBComboBox31.Text+''''; if RxDBLookupCombo3.DisplayValues[0]<>'' then begin // if wwDBComboBox14.Text='不等于' then // str_bill:=str_bill+' and v_op_bscard.揽货人<>'''+RxDBLookupCombo3.DisplayValues[0]+'''' // else str_bill:=str_bill+' and v_op_bscard.揽货人='''+RxDBLookupCombo3.DisplayValues[0]+''''; end; if RxDBLookupCombo15.DisplayValues[0]<>'' then begin // if wwDBComboBox45.Text='不等于' then // str_bill:=str_bill+' and v_op_bscard.分部名称<>'''+RxDBLookupCombo15.DisplayValues[0]+'''' // else str_bill:=str_bill+' and v_op_bscard.分部名称='''+RxDBLookupCombo15.DisplayValues[0]+''''; end; if RxDBLookupCombo12.DisplayValues[0]<>'' then begin str_bill:=str_bill+' and v_op_bscard.操作部门='''+RxDBLookupCombo12.DisplayValues[0]+''''; end; if RxDBLookupCombo10.DisplayValues[0]<>'' then begin str_bill:=str_bill+' and v_op_bscard.销售部门='''+RxDBLookupCombo10.DisplayValues[0]+''''; end; p_detail.close; p_detail.Parameters.ParamByName('SQLStr').value:= 'SELECT t_ch_fee.编号, v_op_bscard.揽货人 as 统计标准,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'收'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then t_ch_fee.金额 else 0 end) ELSE 0 END) as 应收USD,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'收'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then t_ch_fee.结算金额 else 0 end) ELSE 0 END) as 已收USD,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'收'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then t_ch_fee.金额-t_ch_fee.结算金额 else 0 end) ELSE 0 END) as 未收USD,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'收'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then 0 else t_ch_fee.金额*t_ch_fee.汇率 end) ELSE 0 END) as 应收RMB,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'收'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then 0 else t_ch_fee.结算金额*t_ch_fee.汇率 end) ELSE 0 END) as 已收RMB,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'收'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then 0 else (t_ch_fee.金额-t_ch_fee.结算金额)*t_ch_fee.汇率 end) ELSE 0 END) as 未收RMB,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'收'+'''' +' THEN t_ch_fee.金额*t_ch_fee.汇率 ELSE 0 END) as 应收合计,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'收'+'''' +' THEN t_ch_fee.结算金额*t_ch_fee.汇率 ELSE 0 END) as 已收合计,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'收'+'''' +' THEN (t_ch_fee.金额-t_ch_fee.结算金额)*t_ch_fee.汇率 ELSE 0 END) as 未收合计,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'付'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then t_ch_fee.金额 else 0 end) ELSE 0 END) as 应付USD,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'付'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then t_ch_fee.结算金额 else 0 end) ELSE 0 END) as 已付USD,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'付'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then t_ch_fee.金额-t_ch_fee.结算金额 else 0 end) ELSE 0 END) as 未付USD,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'付'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then 0 else t_ch_fee.金额*t_ch_fee.汇率 end) ELSE 0 END) as 应付RMB,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'付'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then 0 else t_ch_fee.结算金额*t_ch_fee.汇率 end) ELSE 0 END) as 已付RMB,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'付'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then 0 else (t_ch_fee.金额-t_ch_fee.结算金额)*t_ch_fee.汇率 end) ELSE 0 END) as 未付RMB,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'付'+'''' +' THEN t_ch_fee.金额*t_ch_fee.汇率 ELSE 0 END) as 应付合计,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'付'+'''' +' THEN t_ch_fee.结算金额*t_ch_fee.汇率 ELSE 0 END) as 已付合计,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'付'+'''' +' THEN (t_ch_fee.金额-t_ch_fee.结算金额)*t_ch_fee.汇率 ELSE 0 END) as 未付合计,' +'v_op_bscard.业务编号, v_op_bscard.会计期间, v_op_bscard.主提单号,' +'v_op_bscard.分提单号, v_op_bscard.委托编号, v_op_bscard.装运方式,' +'v_op_bscard.委托单位, v_op_bscard.业务类型, ' +'v_op_bscard.航次, v_op_bscard.船名, v_op_bscard.开船日期,' +'v_op_bscard.装货港, v_op_bscard.卸货港, ' +'v_op_bscard.件数, v_op_bscard.重量, v_op_bscard.尺码,v_op_bscard.货物名称,' +'v_op_bscard.箱型1, v_op_bscard.箱型2, v_op_bscard.箱型3,' +'v_op_bscard.箱型4, v_op_bscard.箱型5, v_op_bscard.箱型6,' +'v_op_bscard.箱型7, v_op_bscard.箱型8, v_op_bscard.箱型9,' +'v_op_bscard.箱型10, v_op_bscard.其他箱型,' +'v_op_bscard.箱TEU, v_op_bscard.集装箱, v_op_bscard.操作员,' +'v_op_bscard.揽货人, v_op_bscard.客服员, v_op_bscard.航线,' +'v_op_bscard.船公司, v_op_bscard.货代公司, v_op_bscard.报关行,v_op_bscard.报关单号,v_op_bscard.报检单号,' +'(case when round((case when v_op_bscard.重量/1000>v_op_bscard.尺码 then v_op_bscard.重量/1000 ' +'else v_op_bscard.尺码 end),4)>1 then ' +'round((case when v_op_bscard.重量/1000>v_op_bscard.尺码 then v_op_bscard.重量/1000 else ' +'v_op_bscard.尺码 end),4) else ' +'1 end) as 计费吨' +' FROM t_ch_fee inner join v_op_bscard on v_op_bscard.编号=t_ch_fee.编号 ' +str_bill +' GROUP BY t_ch_fee.编号, v_op_bscard.揽货人,' +'v_op_bscard.业务编号, v_op_bscard.会计期间, v_op_bscard.主提单号,' +'v_op_bscard.分提单号, v_op_bscard.委托编号, v_op_bscard.装运方式,' +'v_op_bscard.委托单位, v_op_bscard.业务类型,' +'v_op_bscard.航次, v_op_bscard.船名, v_op_bscard.开船日期,' +'v_op_bscard.装货港, v_op_bscard.卸货港, ' +'v_op_bscard.件数, v_op_bscard.重量, v_op_bscard.尺码,v_op_bscard.货物名称,' +'v_op_bscard.箱型1, v_op_bscard.箱型2, v_op_bscard.箱型3,' +'v_op_bscard.箱型4, v_op_bscard.箱型5, v_op_bscard.箱型6,' +'v_op_bscard.箱型7, v_op_bscard.箱型8, v_op_bscard.箱型9,' +'v_op_bscard.箱型10,v_op_bscard.其他箱型,' +'v_op_bscard.箱TEU, v_op_bscard.集装箱, v_op_bscard.操作员,' +'v_op_bscard.揽货人, v_op_bscard.客服员, v_op_bscard.航线,' +'v_op_bscard.船公司, v_op_bscard.货代公司, v_op_bscard.报关行,v_op_bscard.报关单号,v_op_bscard.报检单号,' +'(case when round((case when v_op_bscard.重量/1000>v_op_bscard.尺码 then v_op_bscard.重量/1000 ' +'else v_op_bscard.尺码 end),4)>1 then ' +'round((case when v_op_bscard.重量/1000>v_op_bscard.尺码 then v_op_bscard.重量/1000 else ' +'v_op_bscard.尺码 end),4) else 1 end)' +default_sort_two(53,'v_op_bscard','v_op_bscard.业务编号','',''); // sl.Add(p_detail.Parameters.ParamByName('SQLStr').value); // sl.SaveToFile('d:\1.txt'); p_detail.Open; end; end else begin if bsSkinRadioGroup1.ItemIndex=0 then begin aDate:=EncodeDate(strtoint(copy(str,1,4)),strtoint(copy(str,5,2)),1); stredate:=FormatDateTime('YYYY-MM-DD',EncodeDate(strtoint(FormatDateTime('YYYY',aDate)),strtoint(FormatDateTime('MM',aDate)),MonthDays[isLeapYear(strtoint(FormatDateTime('YYYY',aDate))),strtoint(FormatDateTime('MM',aDate))])); strdate:=FormatDateTime('YYYY-MM-DD',aDate); str_bill:=' where t_ch_fee.金额<>t_ch_fee.结算金额 and v_op_bscard.开船日期>='''+strdate+''' and v_op_bscard.开船日期<='''+stredate+''''; if RxDBLookupCombo5.DisplayValues[1]<>'' then str_bill:=str_bill+' and t_ch_fee.客户名称='''+RxDBLookupCombo5.DisplayValues[1]+''''; str_bill:=str_bill+' and t_ch_fee.客户名称='''+salename+''''; if (wwDBComboBox31.Text='收') or (wwDBComboBox31.Text='付') then str_bill:=str_bill+' and t_ch_fee.类型='''+wwDBComboBox31.Text+''''; if RxDBLookupCombo3.DisplayValues[0]<>'' then begin // if wwDBComboBox14.Text='不等于' then // str_bill:=str_bill+' and v_op_bscard.揽货人<>'''+RxDBLookupCombo3.DisplayValues[0]+'''' // else str_bill:=str_bill+' and v_op_bscard.揽货人='''+RxDBLookupCombo3.DisplayValues[0]+''''; end; if RxDBLookupCombo15.DisplayValues[0]<>'' then begin // if wwDBComboBox45.Text='不等于' then // str_bill:=str_bill+' and v_op_bscard.分部名称<>'''+RxDBLookupCombo15.DisplayValues[0]+'''' // else str_bill:=str_bill+' and v_op_bscard.分部名称='''+RxDBLookupCombo15.DisplayValues[0]+''''; end; if RxDBLookupCombo12.DisplayValues[0]<>'' then begin str_bill:=str_bill+' and v_op_bscard.操作部门='''+RxDBLookupCombo12.DisplayValues[0]+''''; end; if RxDBLookupCombo10.DisplayValues[0]<>'' then begin str_bill:=str_bill+' and v_op_bscard.销售部门='''+RxDBLookupCombo10.DisplayValues[0]+''''; end; p_detail.close; p_detail.Parameters.ParamByName('SQLStr').value:= 'SELECT t_ch_fee.编号, t_ch_fee.客户名称 as 统计标准,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'收'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then t_ch_fee.金额 else 0 end) ELSE 0 END) as 应收USD,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'收'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then t_ch_fee.结算金额 else 0 end) ELSE 0 END) as 已收USD,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'收'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then t_ch_fee.金额-t_ch_fee.结算金额 else 0 end) ELSE 0 END) as 未收USD,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'收'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then 0 else t_ch_fee.金额*t_ch_fee.汇率 end) ELSE 0 END) as 应收RMB,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'收'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then 0 else t_ch_fee.结算金额*t_ch_fee.汇率 end) ELSE 0 END) as 已收RMB,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'收'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then 0 else (t_ch_fee.金额-t_ch_fee.结算金额)*t_ch_fee.汇率 end) ELSE 0 END) as 未收RMB,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'收'+'''' +' THEN t_ch_fee.金额*t_ch_fee.汇率 ELSE 0 END) as 应收合计,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'收'+'''' +' THEN t_ch_fee.结算金额*t_ch_fee.汇率 ELSE 0 END) as 已收合计,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'收'+'''' +' THEN (t_ch_fee.金额-t_ch_fee.结算金额)*t_ch_fee.汇率 ELSE 0 END) as 未收合计,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'付'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then t_ch_fee.金额 else 0 end) ELSE 0 END) as 应付USD,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'付'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then t_ch_fee.结算金额 else 0 end) ELSE 0 END) as 已付USD,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'付'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then t_ch_fee.金额-t_ch_fee.结算金额 else 0 end) ELSE 0 END) as 未付USD,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'付'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then 0 else t_ch_fee.金额*t_ch_fee.汇率 end) ELSE 0 END) as 应付RMB,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'付'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then 0 else t_ch_fee.结算金额*t_ch_fee.汇率 end) ELSE 0 END) as 已付RMB,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'付'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then 0 else (t_ch_fee.金额-t_ch_fee.结算金额)*t_ch_fee.汇率 end) ELSE 0 END) as 未付RMB,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'付'+'''' +' THEN t_ch_fee.金额*t_ch_fee.汇率 ELSE 0 END) as 应付合计,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'付'+'''' +' THEN t_ch_fee.结算金额*t_ch_fee.汇率 ELSE 0 END) as 已付合计,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'付'+'''' +' THEN (t_ch_fee.金额-t_ch_fee.结算金额)*t_ch_fee.汇率 ELSE 0 END) as 未付合计,' +'v_op_bscard.业务编号, v_op_bscard.会计期间, v_op_bscard.主提单号,' +'v_op_bscard.分提单号, v_op_bscard.委托编号, v_op_bscard.装运方式,' +'v_op_bscard.委托单位, v_op_bscard.业务类型, ' +'v_op_bscard.航次, v_op_bscard.船名, v_op_bscard.开船日期,' +'v_op_bscard.装货港, v_op_bscard.卸货港, ' +'v_op_bscard.件数, v_op_bscard.重量, v_op_bscard.尺码,v_op_bscard.货物名称,' +'v_op_bscard.箱型1, v_op_bscard.箱型2, v_op_bscard.箱型3,' +'v_op_bscard.箱型4, v_op_bscard.箱型5, v_op_bscard.箱型6,' +'v_op_bscard.箱型7, v_op_bscard.箱型8, v_op_bscard.箱型9,' +'v_op_bscard.箱型10, v_op_bscard.其他箱型,' +'v_op_bscard.箱TEU, v_op_bscard.集装箱, v_op_bscard.操作员,' +'v_op_bscard.揽货人, v_op_bscard.客服员, v_op_bscard.航线,' +'v_op_bscard.船公司, v_op_bscard.货代公司, v_op_bscard.报关行,v_op_bscard.报关单号,v_op_bscard.报检单号,v_op_bscard.发票号,' +'(case when round((case when v_op_bscard.重量/1000>v_op_bscard.尺码 then v_op_bscard.重量/1000 ' +'else v_op_bscard.尺码 end),4)>1 then ' +'round((case when v_op_bscard.重量/1000>v_op_bscard.尺码 then v_op_bscard.重量/1000 else ' +'v_op_bscard.尺码 end),4) else ' +'1 end) as 计费吨' +' FROM t_ch_fee inner join v_op_bscard on v_op_bscard.编号=t_ch_fee.编号 ' +str_bill +' GROUP BY t_ch_fee.编号, t_ch_fee.客户名称,' +'v_op_bscard.业务编号, v_op_bscard.会计期间, v_op_bscard.主提单号,' +'v_op_bscard.分提单号, v_op_bscard.委托编号, v_op_bscard.装运方式,' +'v_op_bscard.委托单位, v_op_bscard.业务类型,' +'v_op_bscard.航次, v_op_bscard.船名, v_op_bscard.开船日期,' +'v_op_bscard.装货港, v_op_bscard.卸货港, ' +'v_op_bscard.件数, v_op_bscard.重量, v_op_bscard.尺码,v_op_bscard.货物名称,' +'v_op_bscard.箱型1, v_op_bscard.箱型2, v_op_bscard.箱型3,' +'v_op_bscard.箱型4, v_op_bscard.箱型5, v_op_bscard.箱型6,' +'v_op_bscard.箱型7, v_op_bscard.箱型8, v_op_bscard.箱型9,' +'v_op_bscard.箱型10,v_op_bscard.其他箱型,' +'v_op_bscard.箱TEU, v_op_bscard.集装箱, v_op_bscard.操作员,' +'v_op_bscard.揽货人, v_op_bscard.客服员, v_op_bscard.航线,' +'v_op_bscard.船公司, v_op_bscard.货代公司, v_op_bscard.报关行,v_op_bscard.报关单号,v_op_bscard.报检单号,v_op_bscard.发票号,' +'(case when round((case when v_op_bscard.重量/1000>v_op_bscard.尺码 then v_op_bscard.重量/1000 ' +'else v_op_bscard.尺码 end),4)>1 then ' +'round((case when v_op_bscard.重量/1000>v_op_bscard.尺码 then v_op_bscard.重量/1000 else ' +'v_op_bscard.尺码 end),4) else 1 end)' +default_sort_two(53,'v_op_bscard','v_op_bscard.业务编号','',''); // sl.Add(p_detail.Parameters.ParamByName('SQLStr').value); // sl.SaveToFile('d:\1.txt'); p_detail.Open; end else begin aDate:=EncodeDate(strtoint(copy(str,1,4)),strtoint(copy(str,5,2)),1); stredate:=FormatDateTime('YYYY-MM-DD',EncodeDate(strtoint(FormatDateTime('YYYY',aDate)),strtoint(FormatDateTime('MM',aDate)),MonthDays[isLeapYear(strtoint(FormatDateTime('YYYY',aDate))),strtoint(FormatDateTime('MM',aDate))])); strdate:=FormatDateTime('YYYY-MM-DD',aDate); str_bill:=' where t_ch_fee.金额<>t_ch_fee.结算金额 and v_op_bscard.开船日期>='''+strdate+''' and v_op_bscard.开船日期<='''+stredate+''''; if RxDBLookupCombo5.DisplayValues[1]<>'' then str_bill:=str_bill+' and t_ch_fee.客户名称='''+RxDBLookupCombo5.DisplayValues[1]+''''; str_bill:=str_bill+' and v_op_bscard.揽货人='''+salename+''''; if (wwDBComboBox31.Text='收') or (wwDBComboBox31.Text='付') then str_bill:=str_bill+' and t_ch_fee.类型='''+wwDBComboBox31.Text+''''; if RxDBLookupCombo3.DisplayValues[0]<>'' then begin // if wwDBComboBox14.Text='不等于' then // str_bill:=str_bill+' and v_op_bscard.揽货人<>'''+RxDBLookupCombo3.DisplayValues[0]+'''' // else str_bill:=str_bill+' and v_op_bscard.揽货人='''+RxDBLookupCombo3.DisplayValues[0]+''''; end; if RxDBLookupCombo15.DisplayValues[0]<>'' then begin // if wwDBComboBox45.Text='不等于' then // str_bill:=str_bill+' and v_op_bscard.分部名称<>'''+RxDBLookupCombo15.DisplayValues[0]+'''' // else str_bill:=str_bill+' and v_op_bscard.分部名称='''+RxDBLookupCombo15.DisplayValues[0]+''''; end; if RxDBLookupCombo12.DisplayValues[0]<>'' then begin str_bill:=str_bill+' and v_op_bscard.操作部门='''+RxDBLookupCombo12.DisplayValues[0]+''''; end; if RxDBLookupCombo10.DisplayValues[0]<>'' then begin str_bill:=str_bill+' and v_op_bscard.销售部门='''+RxDBLookupCombo10.DisplayValues[0]+''''; end; p_detail.close; p_detail.Parameters.ParamByName('SQLStr').value:= 'SELECT t_ch_fee.编号, v_op_bscard.揽货人 as 统计标准,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'收'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then t_ch_fee.金额 else 0 end) ELSE 0 END) as 应收USD,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'收'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then t_ch_fee.结算金额 else 0 end) ELSE 0 END) as 已收USD,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'收'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then t_ch_fee.金额-t_ch_fee.结算金额 else 0 end) ELSE 0 END) as 未收USD,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'收'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then 0 else t_ch_fee.金额*t_ch_fee.汇率 end) ELSE 0 END) as 应收RMB,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'收'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then 0 else t_ch_fee.结算金额*t_ch_fee.汇率 end) ELSE 0 END) as 已收RMB,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'收'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then 0 else (t_ch_fee.金额-t_ch_fee.结算金额)*t_ch_fee.汇率 end) ELSE 0 END) as 未收RMB,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'收'+'''' +' THEN t_ch_fee.金额*t_ch_fee.汇率 ELSE 0 END) as 应收合计,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'收'+'''' +' THEN t_ch_fee.结算金额*t_ch_fee.汇率 ELSE 0 END) as 已收合计,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'收'+'''' +' THEN (t_ch_fee.金额-t_ch_fee.结算金额)*t_ch_fee.汇率 ELSE 0 END) as 未收合计,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'付'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then t_ch_fee.金额 else 0 end) ELSE 0 END) as 应付USD,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'付'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then t_ch_fee.结算金额 else 0 end) ELSE 0 END) as 已付USD,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'付'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then t_ch_fee.金额-t_ch_fee.结算金额 else 0 end) ELSE 0 END) as 未付USD,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'付'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then 0 else t_ch_fee.金额*t_ch_fee.汇率 end) ELSE 0 END) as 应付RMB,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'付'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then 0 else t_ch_fee.结算金额*t_ch_fee.汇率 end) ELSE 0 END) as 已付RMB,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'付'+'''' +' THEN (case t_ch_fee.币别 when '+''''+'USD'+'''' +' then 0 else (t_ch_fee.金额-t_ch_fee.结算金额)*t_ch_fee.汇率 end) ELSE 0 END) as 未付RMB,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'付'+'''' +' THEN t_ch_fee.金额*t_ch_fee.汇率 ELSE 0 END) as 应付合计,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'付'+'''' +' THEN t_ch_fee.结算金额*t_ch_fee.汇率 ELSE 0 END) as 已付合计,' +'SUM(CASE t_ch_fee.类型 WHEN '+''''+'付'+'''' +' THEN (t_ch_fee.金额-t_ch_fee.结算金额)*t_ch_fee.汇率 ELSE 0 END) as 未付合计,' +'v_op_bscard.业务编号, v_op_bscard.会计期间, v_op_bscard.主提单号,' +'v_op_bscard.分提单号, v_op_bscard.委托编号, v_op_bscard.装运方式,' +'v_op_bscard.委托单位, v_op_bscard.业务类型, ' +'v_op_bscard.航次, v_op_bscard.船名, v_op_bscard.开船日期,' +'v_op_bscard.装货港, v_op_bscard.卸货港, ' +'v_op_bscard.件数, v_op_bscard.重量, v_op_bscard.尺码,v_op_bscard.货物名称,' +'v_op_bscard.箱型1, v_op_bscard.箱型2, v_op_bscard.箱型3,' +'v_op_bscard.箱型4, v_op_bscard.箱型5, v_op_bscard.箱型6,' +'v_op_bscard.箱型7, v_op_bscard.箱型8, v_op_bscard.箱型9,' +'v_op_bscard.箱型10, v_op_bscard.其他箱型,' +'v_op_bscard.箱TEU, v_op_bscard.集装箱, v_op_bscard.操作员,' +'v_op_bscard.揽货人, v_op_bscard.客服员, v_op_bscard.航线,' +'v_op_bscard.船公司, v_op_bscard.货代公司, v_op_bscard.报关行,v_op_bscard.报关单号,v_op_bscard.报检单号,v_op_bscard.发票号,' +'(case when round((case when v_op_bscard.重量/1000>v_op_bscard.尺码 then v_op_bscard.重量/1000 ' +'else v_op_bscard.尺码 end),4)>1 then ' +'round((case when v_op_bscard.重量/1000>v_op_bscard.尺码 then v_op_bscard.重量/1000 else ' +'v_op_bscard.尺码 end),4) else ' +'1 end) as 计费吨' +' FROM t_ch_fee inner join v_op_bscard on v_op_bscard.编号=t_ch_fee.编号 ' +str_bill +' GROUP BY t_ch_fee.编号, v_op_bscard.揽货人,' +'v_op_bscard.业务编号, v_op_bscard.会计期间, v_op_bscard.主提单号,' +'v_op_bscard.分提单号, v_op_bscard.委托编号, v_op_bscard.装运方式,' +'v_op_bscard.委托单位, v_op_bscard.业务类型,' +'v_op_bscard.航次, v_op_bscard.船名, v_op_bscard.开船日期,' +'v_op_bscard.装货港, v_op_bscard.卸货港, ' +'v_op_bscard.件数, v_op_bscard.重量, v_op_bscard.尺码,v_op_bscard.货物名称,' +'v_op_bscard.箱型1, v_op_bscard.箱型2, v_op_bscard.箱型3,' +'v_op_bscard.箱型4, v_op_bscard.箱型5, v_op_bscard.箱型6,' +'v_op_bscard.箱型7, v_op_bscard.箱型8, v_op_bscard.箱型9,' +'v_op_bscard.箱型10,v_op_bscard.其他箱型,' +'v_op_bscard.箱TEU, v_op_bscard.集装箱, v_op_bscard.操作员,' +'v_op_bscard.揽货人, v_op_bscard.客服员, v_op_bscard.航线,' +'v_op_bscard.船公司, v_op_bscard.货代公司, v_op_bscard.报关行,v_op_bscard.报关单号,v_op_bscard.报检单号,v_op_bscard.发票号,' +'(case when round((case when v_op_bscard.重量/1000>v_op_bscard.尺码 then v_op_bscard.重量/1000 ' +'else v_op_bscard.尺码 end),4)>1 then ' +'round((case when v_op_bscard.重量/1000>v_op_bscard.尺码 then v_op_bscard.重量/1000 else ' +'v_op_bscard.尺码 end),4) else 1 end)' +default_sort_two(53,'v_op_bscard','v_op_bscard.业务编号','',''); // sl.Add(p_detail.Parameters.ParamByName('SQLStr').value); // sl.SaveToFile('d:\1.txt'); p_detail.Open; end; end; bsSkinPageControl1.ActivePageindex:=1; end; procedure Tfrm_rp_no_monthtotal.bsSkinButton2Click(Sender: TObject); begin cbyear.Text:=''; cbeyear.Text:=''; cbmonth.Text:=''; cbemonth.Text:=''; wwDBComboBox31.Text:=''; RxDBLookupCombo5.ClearValue; RxDBLookupCombo3.ClearValue; end; procedure Tfrm_rp_no_monthtotal.N10Click(Sender: TObject); begin update_grid_view_no(dxdbgrid2); end; procedure Tfrm_rp_no_monthtotal.N14Click(Sender: TObject); begin update_grid_view_all(dxdbgrid2); end; procedure Tfrm_rp_no_monthtotal.N12Click(Sender: TObject); begin update_grid(dxdbgrid2,130); end; procedure Tfrm_rp_no_monthtotal.N16Click(Sender: TObject); begin grid_save_xls(dxdbgrid2); end; procedure Tfrm_rp_no_monthtotal.N1Click(Sender: TObject); begin grid_save_xls(dxdbgrid1); end; procedure Tfrm_rp_no_monthtotal.memtblDetailAfterOpen(DataSet: TDataSet); begin AdoFormatdxDBGrid(DataSet); end; function Tfrm_rp_no_monthtotal.getzq(cust: string): string; var aQuery:TAdoQuery; str:string; begin aQuery:=CreateAdoQuery; try with aQuery do begin close;sql.Clear; sql.Add('select * from t_crm_client_sales where 客户简称='''+cust+''''); open; if IsEmpty then result:='无帐期' else begin str:='结费类型:'+fieldbyname('结费类型').AsString+','; if fieldbyname('结费类型').AsString='约定时间' then begin str:=str+'间隔月数:'+fieldbyname('类型模式').asstring+'月,'; str:=str+'结费日期:'+fieldbyname('日期模式').asstring+','; str:=str+'每月结费日期:'+fieldbyname('结费日期').asstring+''; end else if fieldbyname('结费类型').AsString='约定天数' then begin str:=str+'间隔天数:'+fieldbyname('结费期限').asstring+'天'; end; result:=str; end; end; finally FreeAndNil(aQuery); end; end; end.