unit u_rp_no_selfno; 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; type Tfrm_rp_no_selfno = class(TForm) Panel1: TPanel; bsSkinPanel2: TbsSkinPanel; bsSkinButton10: TbsSkinButton; bsSkinButton9: TbsSkinButton; bsSkinButton1: TbsSkinButton; bsSkinButton5: TbsSkinButton; p_total_client1: TDataSource; p_total_sales1: TDataSource; SaveDialog: TSaveDialog; bsSkinPageControl4: TbsSkinPageControl; bsSkinTabSheet1: TbsSkinTabSheet; bsSkinTabSheet3: TbsSkinTabSheet; dxDBGrid3: TdxDBGrid; dxDBGrid3Column22: TdxDBGridColumn; dxDBGridColumn59: TdxDBGridColumn; dxDBGridColumn60: TdxDBGridColumn; dxDBGridColumn61: TdxDBGridColumn; dxDBGridColumn62: TdxDBGridColumn; dxDBGridColumn63: TdxDBGridColumn; dxDBGridColumn64: TdxDBGridColumn; dxDBGridColumn65: TdxDBGridColumn; dxDBGridColumn66: TdxDBGridColumn; dxDBGridColumn67: TdxDBGridColumn; dxDBGridColumn68: TdxDBGridColumn; dxDBGridColumn69: TdxDBGridColumn; dxDBGridColumn70: TdxDBGridColumn; dxDBGridColumn71: TdxDBGridColumn; dxDBGridColumn72: TdxDBGridColumn; dxDBGridColumn73: TdxDBGridColumn; dxDBGridColumn74: TdxDBGridColumn; dxDBGridColumn75: TdxDBGridColumn; dxDBGridColumn76: TdxDBGridColumn; dxDBGridColumn77: TdxDBGridColumn; dxDBGridColumn78: TdxDBGridColumn; dxDBGridColumn79: TdxDBGridColumn; p_accept_bill: TADOStoredProc; p_accept_bill1: TDataSource; kbmBinaryStreamFormat1: TkbmBinaryStreamFormat; kbmThreadDataSet1: TkbmThreadDataSet; memtblrpt_total: TkbmMemTable; PopupMenu1: TPopupMenu; N1: TMenuItem; N2: TMenuItem; N1101: TMenuItem; memtblrpt_total1: TDataSource; bsSkinCheckRadioBox1: TbsSkinCheckRadioBox; memtblDetail: TkbmMemTable; dxDBGrid1: TdxDBGrid; dxDBGrid1Column5: TdxDBGridColumn; dxDBGridMaskColumn95: TdxDBGridMaskColumn; memtblField: TkbmMemTable; memtblFieldFieldName: TStringField; memtblFieldDisplayName: TStringField; memtblFieldlength: TIntegerField; memtblFieldFooterSum: TSmallintField; bstab1: TbsSkinTabSheet; bsSkinPanel1: TbsSkinPanel; bsSkinPageControl1: TbsSkinPageControl; tab1: TbsSkinTabSheet; bsSkinTabSheet2: TbsSkinTabSheet; tab3: TbsSkinTabSheet; tab4: TbsSkinTabSheet; bsSkinCheckRadioBox2: TbsSkinCheckRadioBox; bsSkinCheckRadioBox3: TbsSkinCheckRadioBox; dxDBGrid2: TdxDBGrid; dxDBGridColumn18: TdxDBGridColumn; dxDBGridColumn22: TdxDBGridColumn; dxDBGrid4: TdxDBGrid; dxDBGridColumn1: TdxDBGridColumn; dxDBGridColumn2: TdxDBGridColumn; dxDBGrid4Column3: TdxDBGridColumn; dxDBGrid6: TdxDBGrid; dxDBGridColumn3: TdxDBGridColumn; dxDBGridColumn4: TdxDBGridColumn; dxDBGridColumn5: TdxDBGridColumn; dxDBGrid6Column4: TdxDBGridColumn; dxDBGrid7: TdxDBGrid; dxDBGridColumn6: TdxDBGridColumn; dxDBGridMaskColumn2: TdxDBGridMaskColumn; dxDBGridMaskColumn3: TdxDBGridMaskColumn; dxDBGridColumn7: TdxDBGridColumn; dxDBGridColumn8: TdxDBGridColumn; dxDBGridMaskColumn4: TdxDBGridMaskColumn; dxDBGridMaskColumn5: TdxDBGridMaskColumn; dxDBGridMaskColumn6: TdxDBGridMaskColumn; dxDBGridColumn9: TdxDBGridColumn; dxDBGridColumn10: TdxDBGridColumn; dxDBGridColumn11: TdxDBGridColumn; dxDBGridColumn12: TdxDBGridColumn; dxDBGridColumn13: TdxDBGridColumn; dxDBGridColumn14: TdxDBGridColumn; dxDBGridColumn15: TdxDBGridColumn; dxDBGridColumn16: TdxDBGridColumn; dxDBGridColumn17: TdxDBGridColumn; dxDBGridColumn19: TdxDBGridColumn; dxDBGridColumn20: TdxDBGridColumn; dxDBGridColumn21: TdxDBGridColumn; dxDBGridColumn23: TdxDBGridColumn; dxDBGridColumn24: TdxDBGridColumn; dxDBGridColumn25: TdxDBGridColumn; dxDBGridDateColumn1: TdxDBGridDateColumn; dxDBGridColumn26: TdxDBGridColumn; dxDBGridMaskColumn7: TdxDBGridMaskColumn; dxDBGridMaskColumn8: TdxDBGridMaskColumn; dxDBGridMaskColumn9: TdxDBGridMaskColumn; dxDBGridMaskColumn10: TdxDBGridMaskColumn; dxDBGridMaskColumn11: TdxDBGridMaskColumn; dxDBGridMaskColumn12: TdxDBGridMaskColumn; dxDBGridDateColumn2: TdxDBGridDateColumn; dxDBGridMaskColumn13: TdxDBGridMaskColumn; dxDBGridMaskColumn14: TdxDBGridMaskColumn; dxDBGridMaskColumn15: TdxDBGridMaskColumn; dxDBGridMaskColumn16: TdxDBGridMaskColumn; dxDBGridMaskColumn17: TdxDBGridMaskColumn; dxDBGridColumn27: TdxDBGridColumn; dxDBGridColumn28: TdxDBGridColumn; dxDBGridMaskColumn18: TdxDBGridMaskColumn; dxDBGridMaskColumn19: TdxDBGridMaskColumn; dxDBGridMaskColumn20: TdxDBGridMaskColumn; dxDBGridMaskColumn21: TdxDBGridMaskColumn; dxDBGridMaskColumn22: TdxDBGridMaskColumn; dxDBGridMaskColumn23: TdxDBGridMaskColumn; dxDBGridMaskColumn24: TdxDBGridMaskColumn; dxDBGridMaskColumn25: TdxDBGridMaskColumn; dxDBGridMaskColumn26: TdxDBGridMaskColumn; dxDBGridMaskColumn27: TdxDBGridMaskColumn; dxDBGridMaskColumn28: TdxDBGridMaskColumn; dxDBGridMaskColumn29: TdxDBGridMaskColumn; dxDBGridMaskColumn30: TdxDBGridMaskColumn; dxDBGridMaskColumn31: TdxDBGridMaskColumn; dxDBGridMaskColumn32: TdxDBGridMaskColumn; dxDBGridMaskColumn33: TdxDBGridMaskColumn; dxDBGridMaskColumn34: TdxDBGridMaskColumn; dxDBGridMaskColumn35: TdxDBGridMaskColumn; dxDBGridMaskColumn36: TdxDBGridMaskColumn; dxDBGridMaskColumn37: TdxDBGridMaskColumn; dxDBGridColumn29: TdxDBGridColumn; dxDBGridColumn30: TdxDBGridColumn; dxDBGridColumn31: TdxDBGridColumn; dxDBGridColumn32: TdxDBGridColumn; mem_total_sales: TkbmMemTable; mem_total_client: TkbmMemTable; mem_total_dept: TkbmMemTable; p_total_dept1: TDataSource; p_total1: TDataSource; mem_total_deptField: TStringField; mem_total_deptField2: TFloatField; mem_total_salesField: TStringField; mem_total_salesField2: TStringField; mem_total_salesField3: TFloatField; mem_total_clientField: TStringField; mem_total_clientField2: TStringField; mem_total_clientField3: TFloatField; mem_total_clientField4: TStringField; mem_total_salesField4: TBooleanField; mem_total_clientField5: TBooleanField; mem_total_deptField3: TBooleanField; dxDBGrid2Column3: TdxDBGridColumn; dxDBGrid4Column4: TdxDBGridColumn; dxDBGrid6Column5: TdxDBGridColumn; mem_client: TkbmMemTable; StringField1: TStringField; StringField2: TStringField; FloatField1: TFloatField; mem_clientField: TFloatField; dxDBGrid7Column64: TdxDBGridColumn; mem_total_clientUSD: TFloatField; mem_total_clientRMB: TFloatField; mem_total_salesUSD: TFloatField; mem_total_salesRMB: TFloatField; dxDBGrid4Column5: TdxDBGridColumn; dxDBGrid4Column6: TdxDBGridColumn; dxDBGrid6Column6: TdxDBGridColumn; dxDBGrid6Column7: TdxDBGridColumn; mem_total_clientField6: TStringField; dxDBGrid6Column8: TdxDBGridColumn; dxDBGrid7Column65: TdxDBGridColumn; memtblrpt_totalField: TStringField; memtblrpt_totalField2: TStringField; memtblrpt_totalField3: TStringField; memtblrpt_totalField4: TIntegerField; memtblrpt_totalField5: TIntegerField; memtblrpt_totalField6: TStringField; memtblrpt_totalField7: TStringField; memtblrpt_totalField8: TStringField; memtblrpt_totalField9: TDateTimeField; memtblrpt_totalUSD: TFloatField; memtblrpt_totalUSD2: TFloatField; memtblrpt_totalUSD3: TFloatField; memtblrpt_totalRMB: TFloatField; memtblrpt_totalRMB2: TFloatField; memtblrpt_totalRMB3: TFloatField; memtblrpt_totalField11: TFloatField; memtblrpt_totalField12: TFloatField; memtblrpt_totalField13: TFloatField; memtblrpt_totalField14: TFloatField; memtblrpt_totalField15: TFloatField; memtblrpt_totalField16: TFloatField; memtblrpt_totalField17: TFloatField; memtblrpt_totalUSD4: TFloatField; memtblrpt_totalRMB4: TFloatField; memtblrpt_totalField19: TIntegerField; memtblrpt_totalField20: TStringField; memtblrpt_totalField21: TStringField; memtblrpt_totalField22: TStringField; memtblrpt_totalField23: TStringField; memtblrpt_totalField24: TStringField; memtblrpt_totalField25: TStringField; memtblrpt_totalField26: TStringField; memtblrpt_totalField27: TStringField; memtblrpt_totalField28: TStringField; memtblrpt_totalField29: TIntegerField; memtblrpt_totalField30: TStringField; memtblrpt_totalField31: TFloatField; memtblrpt_totalField32: TFloatField; memtblrpt_totalField1: TIntegerField; memtblrpt_totalField210: TIntegerField; memtblrpt_totalField33: TIntegerField; memtblrpt_totalField42: TIntegerField; memtblrpt_totalField52: TIntegerField; memtblrpt_totalField62: TIntegerField; memtblrpt_totalField72: TIntegerField; memtblrpt_totalField82: TIntegerField; memtblrpt_totalField92: TIntegerField; memtblrpt_totalField102: TIntegerField; memtblrpt_totalField34: TIntegerField; memtblrpt_totalTEU: TIntegerField; memtblrpt_totalField35: TStringField; memtblrpt_totalField36: TStringField; memtblrpt_totalField37: TStringField; memtblrpt_totalField38: TStringField; memtblrpt_totalField39: TStringField; memtblrpt_totalField40: TStringField; memtblrpt_totalField41: TStringField; memtblrpt_totalField43: TStringField; memtblrpt_totalField44: TStringField; memtblrpt_totalField45: TStringField; memtblrpt_totalField46: TStringField; memtblrpt_totalField47: TStringField; memtblrpt_totalField48: TStringField; memtblrpt_totalField50: TStringField; memtblrpt_totalField49: TSmallintField; memtblrpt_totalField10: TDateField; memtblrpt_totalField18: TDateField; bsSkinButton12: TbsSkinButton; PopupMenu2: TPopupMenu; N10: TMenuItem; N11: TMenuItem; N14: TMenuItem; N13: TMenuItem; N12: TMenuItem; N15: TMenuItem; N16: TMenuItem; mem_clientUSD: TFloatField; mem_clientRMB: TFloatField; mem_clientFloatField: TFloatField; mem_clientFloatField2: TFloatField; mem_clientmonth: TkbmMemTable; StringField3: TStringField; StringField4: TStringField; FloatField2: TFloatField; FloatField3: TFloatField; FloatField4: TFloatField; FloatField5: TFloatField; FloatField6: TFloatField; FloatField7: TFloatField; mem_clientmonthStringField: TStringField; mem_clientsum: TkbmMemTable; StringField5: TStringField; StringField6: TStringField; FloatField8: TFloatField; FloatField9: TFloatField; FloatField10: TFloatField; FloatField11: TFloatField; FloatField12: TFloatField; FloatField13: TFloatField; memtblrpt_totalField51: TStringField; memtblrpt_totalStringField: TStringField; mem_sum: TkbmMemTable; StringField7: TStringField; StringField8: TStringField; FloatField14: TFloatField; FloatField15: TFloatField; FloatField16: TFloatField; FloatField17: TFloatField; FloatField18: TFloatField; FloatField19: TFloatField; mem_clientField2: TStringField; dxDBGrid7Column66: TdxDBGridColumn; mem_clientsumField: TStringField; memtblrpt_totalField53: TStringField; dxDBGrid7Column67: TdxDBGridColumn; memtblrpt_totalField54: TStringField; memtblrpt_totalField55: TFloatField; memtblrpt_totalField56: TFloatField; mem_total_salesStringField: TStringField; mem_total_salesFloatField: TFloatField; mem_total_salesFloatField2: TFloatField; mem_total_clientStringField: TStringField; mem_total_clientFloatField: TFloatField; mem_total_clientFloatField2: TFloatField; mem_total_deptStringField: TStringField; mem_total_deptFloatField: TFloatField; mem_total_deptFloatField2: TFloatField; dxDBGrid2Column4: TdxDBGridColumn; dxDBGrid4Column7: TdxDBGridColumn; dxDBGrid6Column9: TdxDBGridColumn; bsSkinTabSheet5: TbsSkinTabSheet; mem_clientmonth1: TDataSource; dxDBGrid5: TdxDBGrid; dxDBGridMaskColumn1: TdxDBGridMaskColumn; dxDBGridColumn35: TdxDBGridColumn; dxDBGridColumn39: TdxDBGridColumn; dxDBGridColumn40: TdxDBGridColumn; dxDBGridColumn41: TdxDBGridColumn; dxDBGridColumn42: TdxDBGridColumn; dxDBGridColumn43: TdxDBGridColumn; dxDBGridColumn44: TdxDBGridColumn; dxDBGridColumn45: TdxDBGridColumn; dxDBGridColumn46: TdxDBGridColumn; dxDBGridColumn47: TdxDBGridColumn; dxDBGridColumn48: TdxDBGridColumn; dxDBGridColumn49: TdxDBGridColumn; dxDBGridColumn50: TdxDBGridColumn; dxDBGridColumn51: TdxDBGridColumn; mem_clientmonthUSD: TFloatField; mem_clientmonthUSD2: TFloatField; mem_clientmonthRMB: TFloatField; mem_clientmonthRMB2: TFloatField; mem_clientmonthFloatField: TFloatField; mem_clientmonthFloatField2: TFloatField; mem_clientmonthFloatField3: TFloatField; mem_clientmonthFloatField4: TFloatField; mem_clientmonthFloatField5: TFloatField; mem_clientmonthFloatField6: TFloatField; mem_clientmonthIntegerField: TIntegerField; mem_clientmonthDateTimeField: TDateTimeField; dxDBGrid5Column17: TdxDBGridColumn; dxDBGrid5Column18: TdxDBGridColumn; memtblrpt_totalField57: TDateField; dxDBGrid7Column68: TdxDBGridColumn; mem_clientmonthStringField2: TStringField; dxDBGrid5Column19: TdxDBGridColumn; PopupMenu3: TPopupMenu; MenuItem1: TMenuItem; MenuItem2: TMenuItem; MenuItem3: TMenuItem; MenuItem4: TMenuItem; MenuItem5: TMenuItem; MenuItem6: TMenuItem; MenuItem7: TMenuItem; mem_total_clientField7: TStringField; memtblrpt_totalField58: TStringField; dxDBGrid6Column10: TdxDBGridColumn; dxDBGrid7Column69: TdxDBGridColumn; bsSkinCheckRadioBox4: TbsSkinCheckRadioBox; mem_total_clientField8: TStringField; dxDBGrid6Column11: TdxDBGridColumn; memtblrpt_totalField59: TStringField; dxDBGrid7Column70: TdxDBGridColumn; mem_clientmonthField: TStringField; mem_clientmonthField2: TStringField; dxDBGrid5Column20: TdxDBGridColumn; dxDBGrid5Column21: TdxDBGridColumn; mem_clientmonthField3: TStringField; dxDBGrid5Column22: TdxDBGridColumn; dxDBGrid5Column23: TdxDBGridColumn; procedure bsSkinButton5Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure Panel1Resize(Sender: TObject); procedure bsSkinButton10Click(Sender: TObject); procedure bsSkinButton1Click(Sender: TObject); procedure bsSkinButton9Click(Sender: TObject); procedure dxDBGrid5DblClick(Sender: TObject); procedure dxDBGrid6DblClick(Sender: TObject); procedure dxDBGrid7DblClick(Sender: TObject); procedure dxDBGrid8DblClick(Sender: TObject); procedure bsSkinButton15Click(Sender: TObject); procedure bsSkinCheckRadioBox3Click(Sender: TObject); procedure bsSkinCheckRadioBox2Click(Sender: TObject); procedure bsSkinButton12Click(Sender: TObject); procedure N10Click(Sender: TObject); procedure N14Click(Sender: TObject); procedure N12Click(Sender: TObject); procedure N16Click(Sender: TObject); procedure dxDBGridColumn7CustomDraw(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 MenuItem1Click(Sender: TObject); procedure MenuItem3Click(Sender: TObject); procedure MenuItem5Click(Sender: TObject); procedure MenuItem7Click(Sender: TObject); procedure FormShow(Sender: TObject); private procedure do_1(str_bill:widestring); procedure GetNoFee; procedure Creatememtbl; function GetZhangQi(SaleID,Cust:String):String; function isChaoQi(SaleID,Cust:String):Boolean; function GetZhangQiNum(SaleID,Cust:String;aetd:TDateTime;out zqstr:string):Double; function GetZhangQiStr(SaleID,Cust:String):String; function GetBetwMonth(aBe, aEe: TDate): Integer; { Private declarations } public { Public declarations } end; var frm_rp_no_selfno: Tfrm_rp_no_selfno; FmDate,ToDate,zhangdate:String; sqlstr:WideString; implementation uses u_main, u_rp_no_seae_query,my_sys_function, u_rp_total_query, u_rp_no_total, u_sys_progress; {$R *.dfm} function Tfrm_rp_no_selfno.GetBetwMonth(aBe, aEe: TDate): Integer; var bYear,bMonth,bDate,eYear,eMonth,eDate:Word; begin DecodeDate(aBe,bYear,bMonth,bDate); DecodeDate(aEe,eYear,eMonth,eDate); if bYear=eYear then Result:=Abs(bMonth-eMonth) else begin if bYear>eYear then begin Result:=bMonth+(12-eMonth); end else begin Result:=eMonth+(12-bMonth); end; end; end; function Tfrm_rp_no_selfno.GetZhangQi(SaleID,Cust:String):String; var aQuery:TADOQuery; S,sub:String; begin if (FmDate='') then begin FmDate:='2006-01-01'; end; aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; // SQL.Add('Select * from t_crm_client_sales where 状态=''审核'' and 开始日期<='''+FmDate+''' and 结束日期>='''+ToDate+''' and 客户简称='''+Cust+''' and 揽货人='''+SaleID+''''); SQL.Add('Select * from t_crm_client_sales where 状态=''审核'' and 结束日期>'''+FmDate+''' and 客户简称='''+Cust+''' and 揽货人='''+SaleID+''''); Open; if not IsEmpty then begin first; S:=''; while not eof do begin // S:=S+'开始日期:'+FormatDateTime('YYYY-MM-DD',FieldByName('开始日期').AsDateTime)+',结束日期'+FormatDateTime('YYYY-MM-DD',FieldByName('结束日期').AsDateTime); if FieldByName('结费类型').AsString='现结买单' then begin S:=S+'当月结算;'; end else if FieldByName('结费类型').AsString='约定天数' then begin S:=S+'约定天数,['+fieldByName('结费期限').AsString+']天'; end else if FieldByName('结费类型').AsString='约定时间' then begin if StrToIntDef(FieldByName('类型模式').AsString,0)=0 then sub:='当月' else if StrToIntDef(FieldByName('类型模式').AsString,0)=1 then sub:='次1月' else if StrToIntDef(FieldByName('类型模式').AsString,0)=2 then sub:='次2月' else if StrToIntDef(FieldByName('类型模式').AsString,0)=3 then sub:='次3月' else sub:='次'+inttostr(StrToIntDef(FieldByName('类型模式').AsString,0))+'月'; if FieldByName('日期模式').AsString='固定' then S:=sub+FieldByName('结费日期').AsString+'日' else S:=sub; end else if FieldByName('结费类型').AsString='分阶段付费' then begin S:=S+'分阶段付费;'; end; Next; end; result:=S; end else begin Result:='无账期'; end; end; finally FreeAndNil(aQuery); end; end; procedure Tfrm_rp_no_selfno.do_1(str_bill:widestring); begin end; procedure Tfrm_rp_no_selfno.bsSkinButton5Click(Sender: TObject); begin close; end; procedure Tfrm_rp_no_selfno.FormClose(Sender: TObject; var Action: TCloseAction); begin savereggrid(dxdbgrid1,caption+'1'); savereggrid(dxdbgrid7,caption+'7'); savereggrid(dxdbgrid5,caption+'5'); frm_rp_no_selfno.Hide; frm_rp_no_selfno.ManualFloat(frm_rp_no_selfno.BoundsRect ); frm_main.freeTabs('frm_rp_no_selfno'); action:=cafree; frm_rp_no_selfno:=nil; end; procedure Tfrm_rp_no_selfno.Panel1Resize(Sender: TObject); var i:integer; begin i:=round(bsSkinPanel2.Width/7); bsSkinCheckRadioBox1.Width:=i; bsSkinButton10.Width:=i; bsSkinButton9.Width:=i; bsSkinButton1.Width:=i; end; procedure Tfrm_rp_no_selfno.bsSkinButton10Click(Sender: TObject); var zdate:Tdate; num:double; j:integer; zqstr:string; Protocolrec:TProtocolrec; function getstlDate(Cust,SaleID:String;aetdDate:TDatetime):TDateTime; var aQuery2:TADOQuery; aYear,aMonth,aDay,bDay:word; aStlDate:TDateTime; begin aQuery2:=CreateAdoQuery; aStlDate:=aetdDate; try with aQuery2 do begin Close;SQL.Clear; SQL.Add('Select * from t_crm_client_sales where 状态=''审核'' and 开始日期<='''+FormatDateTime('YYYY-MM-DD',aStlDate)+''' and 结束日期>='''+FormatDateTime('YYYY-MM-DD',aStlDate)+''' and 客户简称='''+Cust+''' and 揽货人='''+SaleID+''''); Open; if not IsEmpty then begin if FieldByName('结费类型').AsString='现结买单' then begin Result:=aStlDate; end else if FieldByName('结费类型').AsString='约定天数' then begin result:=aStlDate+fieldByName('结费期限').AsInteger; end else if FieldByName('结费类型').AsString='约定时间' then begin if FieldByName('日期模式').AsString='固定' then begin DecodeDate(IncMonth(aStlDate,StrToIntDef(FieldByName('类型模式').AsString,0)),aYear,aMonth,aDay); bDay:=DaysInMonth(EncodeDate(aYear,aMonth,1)); if fieldByName('结费日期').AsInteger>bDay then result:=EncodeDate(aYear,aMonth,bDay) else if fieldByName('结费日期').AsInteger>0 then result:=EncodeDate(aYear,aMonth,fieldByName('结费日期').AsInteger) else result:=EncodeDate(aYear,aMonth,1); end else result:=IncMonth(aStlDate,StrToIntDef(FieldByName('类型模式').AsString,0)); end else if FieldByName('结费类型').AsString='分阶段付费' then begin DecodeDate(IncMonth(aStlDate,StrToIntDef(FieldByName('类型模式').AsString,0)),aYear,aMonth,aDay); if aDay>fieldByName('结束日期').AsInteger then begin bDay:=DaysInMonth(EncodeDate(aYear,aMonth,1)); if fieldByName('结费日期2').AsInteger>bDay then result:=EncodeDate(aYear,aMonth,bDay) else if fieldByName('结费日期2').AsInteger>0 then result:=EncodeDate(aYear,aMonth,fieldByName('结费日期2').AsInteger) else result:=EncodeDate(aYear,aMonth,1) end else begin bDay:=DaysInMonth(EncodeDate(aYear,aMonth,1)); if fieldByName('结费日期').AsInteger>bDay then result:=EncodeDate(aYear,aMonth,bDay) else if fieldByName('结费日期').AsInteger>0 then result:=EncodeDate(aYear,aMonth,fieldByName('结费日期').AsInteger) else result:=EncodeDate(aYear,aMonth,1); end; end else begin Result:=aStlDate; end; end else begin Result:=aStlDate; end; end; finally FreeAndNil(aQuery2); end; end; begin try frm_rp_total_query:=tfrm_rp_total_query.Create (self); rp_seae_query_num:=1; if bsSkinCheckRadioBox1.Checked then rp_seae_query_type:=1; rp_seae_query_limited:='0033'; rp_seae_query_str:='业务综合欠费'; frm_rp_total_query.ShowModal; finally frm_rp_total_query.Free; end; if not p_accept_bill.Active then Exit; if p_accept_bill.IsEmpty then Exit; zdate:=date; { if zhangdate='' then zdate:=date else zdate:=StrToDateDef(zhangdate,date); } memtblrpt_total.DisableControls; memtblrpt_total.LoadFromDataSet(p_accept_bill,[mtcpostructure,mtcpoProperties,mtcpoFieldIndex]); p_accept_bill.Close; { memtblrpt_total.open; p_accept_bill.First; while not p_accept_bill.eof do begin if (p_accept_bill.FieldByName('应收合计').AsFloat=0.00) or p_accept_bill.FieldByName('应收合计').IsNull then else begin memtblrpt_total.insert; for j:=0 to p_accept_bill.FieldCount-1 do begin if memtblrpt_total.FindField(p_accept_bill.Fields[j].FieldName)<>nil then begin memtblrpt_total.FieldByName(p_accept_bill.Fields[j].FieldName).Value:=p_accept_bill.Fields[j].Value; end; end; memtblrpt_total.post; end; p_accept_bill.next; end; } memtblrpt_total.SortOn('开船日期',[]); memtblrpt_total.FieldByName('超期月数').ReadOnly:=false; memtblrpt_total.FieldByName('超期天数').ReadOnly:=false; memtblrpt_total.FieldByName('是否超期').ReadOnly:=false; memtblrpt_total.FieldByName('应结日期').ReadOnly:=false; memtblrpt_total.FieldByName('客户合计').ReadOnly:=false; memtblrpt_total.FieldByName('月份合计').ReadOnly:=false; memtblrpt_total.FieldByName('客户账期').ReadOnly:=false; memtblrpt_total.First; mem_client.Close; mem_client.EmptyTable; mem_client.Open; mem_clientsum.Close; mem_clientsum.EmptyTable; mem_clientsum.Open; mem_clientmonth.Close; mem_clientmonth.EmptyTable; mem_clientmonth.Open; if not ASSIGNED(frm_sys_progress) then frm_sys_progress:=tfrm_sys_progress.Create(application); frm_sys_progress.Show; frm_sys_progress.bsSkinGauge1.MaxValue:=memtblrpt_total.RecordCount; frm_sys_progress.bsSkinGauge1.MinValue:=0; frm_sys_progress.bsSkinGauge1.Value:=0; frm_sys_progress.Update; memtblrpt_total.First; while not memtblrpt_total.eof do begin frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; memtblrpt_total.Edit; Protocolrec:=getProtocol(trim(memtblrpt_total.FieldByName('客户名称').asstring),trim(memtblrpt_total.FieldByName('揽货人').AsStRING),memtblrpt_total.FieldByName('预抵日期').AsDateTime); if (Protocolrec.protocolDate<>null) and (Protocolrec.protocolDate<>0) then memtblrpt_total.FieldByName('应结日期').AsDateTime:=Protocolrec.protocolDate else memtblrpt_total.FieldByName('应结日期').AsDateTime:=memtblrpt_total.FieldByName('预抵日期').AsDateTime; memtblrpt_total.Post; if memtblrpt_total.FieldByName('应结日期').AsDateTime<=zDate then begin memtblrpt_total.Edit; memtblrpt_total.FieldByName('是否超期').AsInteger:=1; memtblrpt_total.FieldByName('超期月数').AsInteger:=MonthsBetween(zdate,memtblrpt_total.FieldByName('应结日期').AsDateTime); memtblrpt_total.FieldByName('超期天数').AsInteger:=DaysBetween(ZDate,memtblrpt_total.FieldByName('应结日期').AsDatetime); memtblrpt_total.Post; end else begin if mem_client.Locate('客户名称;揽货人',VarArrayOf([memtblrpt_total.FieldByName('客户名称').asstring,memtblrpt_total.FieldByName('揽货人').AsStRING]),[]) then begin if mem_client.FieldByName('帐期额度').AsFloat<=0 then begin memtblrpt_total.Edit; memtblrpt_total.FieldByName('是否超期').AsInteger:=0; memtblrpt_total.FieldByName('超期月数').AsInteger:=0; memtblrpt_total.FieldByName('超期天数').AsInteger:=0; memtblrpt_total.Post; end else if mem_client.FieldByName('帐期额度').AsFloat=-1 then begin { if memtblrpt_total.FieldByName('开船日期').AsDateTime<=zdate then begin memtblrpt_total.Edit; memtblrpt_total.FieldByName('是否超期').AsInteger:=1; memtblrpt_total.Post; end; } end else begin if (mem_client.FieldByName('欠费合计').AsFloat+memtblrpt_total.FieldByName('差额合计').AsFloat)>mem_client.FieldByName('帐期额度').AsFloat then begin memtblrpt_total.Edit; memtblrpt_total.FieldByName('是否超期').AsInteger:=1; memtblrpt_total.Post; end else begin mem_client.Edit; mem_client.FieldByName('欠费合计').AsFloat:=mem_client.FieldByName('欠费合计').AsFloat+memtblrpt_total.FieldByName('差额合计').AsFloat; mem_client.FieldByName('未收USD').AsFloat:=mem_client.FieldByName('未收USD').AsFloat+memtblrpt_total.FieldByName('未收USD').AsFloat; mem_client.FieldByName('未收RMB').AsFloat:=mem_client.FieldByName('未收RMB').AsFloat+memtblrpt_total.FieldByName('未收RMB').AsFloat; mem_client.FieldByName('未收合计').AsFloat:=mem_client.FieldByName('未收合计').AsFloat+memtblrpt_total.FieldByName('未收合计').AsFloat; mem_client.FieldByName('未付合计').AsFloat:=mem_client.FieldByName('未付合计').AsFloat+memtblrpt_total.FieldByName('未付合计').AsFloat; mem_client.Post; end; end; end else begin mem_client.Insert; mem_client.FieldByName('揽货人').AsString:=memtblrpt_total.FieldByName('揽货人').AsString; mem_client.FieldByName('客户名称').AsString:=memtblrpt_total.FieldByName('客户名称').AsString; mem_client.FieldByName('欠费合计').AsFloat:=memtblrpt_total.FieldByName('差额合计').AsFloat; mem_client.FieldByName('未收USD').AsFloat:=memtblrpt_total.FieldByName('未收USD').AsFloat; mem_client.FieldByName('未收RMB').AsFloat:=memtblrpt_total.FieldByName('未收RMB').AsFloat; mem_client.FieldByName('未收合计').AsFloat:=memtblrpt_total.FieldByName('未收合计').AsFloat; mem_client.FieldByName('未付合计').AsFloat:=memtblrpt_total.FieldByName('未付合计').AsFloat; num:=GetZhangQiNum(memtblrpt_total.FieldByName('揽货人').AsString,memtblrpt_total.FieldByName('客户名称').AsString,memtblrpt_total.FieldByName('预抵日期').AsDateTime,zqstr); mem_client.FieldByName('帐期额度').AsFloat:=num; mem_client.FieldByName('客户账期').AsString:=zqstr; mem_client.Post; if mem_client.FieldByName('帐期额度').AsFloat<=0 then begin memtblrpt_total.Edit; memtblrpt_total.FieldByName('是否超期').AsInteger:=0; memtblrpt_total.FieldByName('超期月数').AsInteger:=0; memtblrpt_total.FieldByName('超期天数').AsInteger:=0; memtblrpt_total.Post; end else if mem_client.FieldByName('欠费合计').AsFloat>mem_client.FieldByName('帐期额度').AsFloat then begin memtblrpt_total.Edit; memtblrpt_total.FieldByName('是否超期').AsInteger:=1; memtblrpt_total.Post; end; end; end; if mem_clientmonth.Locate('客户名称;月份',VarArrayOf([memtblrpt_total.FieldByName('客户名称').asstring,memtblrpt_total.FieldByName('月份').AsStRING]),[]) then begin mem_clientmonth.Edit; mem_clientmonth.FieldByName('欠费合计').AsFloat:=mem_clientmonth.FieldByName('欠费合计').AsFloat+memtblrpt_total.FieldByName('差额合计').AsFloat; mem_clientmonth.FieldByName('未收USD').AsFloat:=mem_clientmonth.FieldByName('未收USD').AsFloat+memtblrpt_total.FieldByName('未收USD').AsFloat; mem_clientmonth.FieldByName('未收RMB').AsFloat:=mem_clientmonth.FieldByName('未收RMB').AsFloat+memtblrpt_total.FieldByName('未收RMB').AsFloat; mem_clientmonth.FieldByName('未收合计').AsFloat:=mem_clientmonth.FieldByName('未收合计').AsFloat+memtblrpt_total.FieldByName('未收合计').AsFloat; mem_clientmonth.FieldByName('未付合计').AsFloat:=mem_clientmonth.FieldByName('未付合计').AsFloat+memtblrpt_total.FieldByName('未付合计').AsFloat; mem_clientmonth.FieldByName('应收USD').AsFloat:=mem_clientmonth.FieldByName('应收USD').AsFloat+memtblrpt_total.FieldByName('应收USD').AsFloat; mem_clientmonth.FieldByName('已收USD').AsFloat:=mem_clientmonth.FieldByName('已收USD').AsFloat+memtblrpt_total.FieldByName('已收USD').AsFloat; mem_clientmonth.FieldByName('应收RMB').AsFloat:=mem_clientmonth.FieldByName('应收RMB').AsFloat+memtblrpt_total.FieldByName('应收RMB').AsFloat; mem_clientmonth.FieldByName('已收RMB').AsFloat:=mem_clientmonth.FieldByName('已收RMB').AsFloat+memtblrpt_total.FieldByName('已收RMB').AsFloat; mem_clientmonth.FieldByName('应收合计').AsFloat:=mem_clientmonth.FieldByName('应收合计').AsFloat+memtblrpt_total.FieldByName('应收合计').AsFloat; mem_clientmonth.FieldByName('已收合计').AsFloat:=mem_clientmonth.FieldByName('已收合计').AsFloat+memtblrpt_total.FieldByName('已收合计').AsFloat; mem_clientmonth.FieldByName('应付合计').AsFloat:=mem_clientmonth.FieldByName('应付合计').AsFloat+memtblrpt_total.FieldByName('应付合计').AsFloat; mem_clientmonth.FieldByName('已付合计').AsFloat:=mem_clientmonth.FieldByName('已付合计').AsFloat+memtblrpt_total.FieldByName('已付合计').AsFloat; if (Pos(memtblrpt_total.FieldByName('操作员').AsString, mem_clientmonth.FieldByName('操作员').AsString)=0) then mem_clientmonth.FieldByName('操作员').AsString:=mem_clientmonth.FieldByName('操作员').AsString+','+memtblrpt_total.FieldByName('操作员').AsString; mem_clientmonth.Post; end else begin mem_clientmonth.Insert; mem_clientmonth.FieldByName('揽货人').AsString:=memtblrpt_total.FieldByName('揽货人').AsString; mem_clientmonth.FieldByName('客户名称').AsString:=memtblrpt_total.FieldByName('客户名称').AsString; mem_clientmonth.FieldByName('客户全称').AsString:=memtblrpt_total.FieldByName('客户全称').AsString; mem_clientmonth.FieldByName('客商编码').AsString:=memtblrpt_total.FieldByName('客商编码').AsString; mem_clientmonth.FieldByName('月份').AsString:=memtblrpt_total.FieldByName('月份').AsString; mem_clientmonth.FieldByName('客户账期').AsString:=GetZhangQi(memtblrpt_total.FieldByName('揽货人').AsString,memtblrpt_total.FieldByName('客户名称').asstring); mem_clientmonth.FieldByName('欠费合计').AsFloat:=memtblrpt_total.FieldByName('差额合计').AsFloat; mem_clientmonth.FieldByName('未收USD').AsFloat:=memtblrpt_total.FieldByName('未收USD').AsFloat; mem_clientmonth.FieldByName('未收RMB').AsFloat:=memtblrpt_total.FieldByName('未收RMB').AsFloat; mem_clientmonth.FieldByName('未收合计').AsFloat:=memtblrpt_total.FieldByName('未收合计').AsFloat; mem_clientmonth.FieldByName('未付合计').AsFloat:=memtblrpt_total.FieldByName('未付合计').AsFloat; mem_clientmonth.FieldByName('应收USD').AsFloat:=memtblrpt_total.FieldByName('应收USD').AsFloat; mem_clientmonth.FieldByName('已收USD').AsFloat:=memtblrpt_total.FieldByName('已收USD').AsFloat; mem_clientmonth.FieldByName('应收RMB').AsFloat:=memtblrpt_total.FieldByName('应收RMB').AsFloat; mem_clientmonth.FieldByName('已收RMB').AsFloat:=memtblrpt_total.FieldByName('已收RMB').AsFloat; mem_clientmonth.FieldByName('应收合计').AsFloat:=memtblrpt_total.FieldByName('应收合计').AsFloat; mem_clientmonth.FieldByName('已收合计').AsFloat:=memtblrpt_total.FieldByName('已收合计').AsFloat; mem_clientmonth.FieldByName('应付合计').AsFloat:=memtblrpt_total.FieldByName('应付合计').AsFloat; mem_clientmonth.FieldByName('已付合计').AsFloat:=memtblrpt_total.FieldByName('已付合计').AsFloat; mem_clientmonth.FieldByName('超期天数').AsString:=memtblrpt_total.FieldByName('超期天数').AsString; mem_clientmonth.FieldByName('应结日期').AsString:=memtblrpt_total.FieldByName('应结日期').AsString; mem_clientmonth.FieldByName('操作员').AsString:=memtblrpt_total.FieldByName('操作员').AsString; mem_clientmonth.Post; end; if mem_clientsum.Locate('客户名称',VarArrayOf([memtblrpt_total.FieldByName('客户名称').asstring]),[]) then begin mem_clientsum.Edit; mem_clientsum.FieldByName('欠费合计').AsFloat:=mem_clientsum.FieldByName('欠费合计').AsFloat+memtblrpt_total.FieldByName('差额合计').AsFloat; mem_clientsum.FieldByName('未收USD').AsFloat:=mem_clientsum.FieldByName('未收USD').AsFloat+memtblrpt_total.FieldByName('未收USD').AsFloat; mem_clientsum.FieldByName('未收RMB').AsFloat:=mem_clientsum.FieldByName('未收RMB').AsFloat+memtblrpt_total.FieldByName('未收RMB').AsFloat; mem_clientsum.FieldByName('未收合计').AsFloat:=mem_clientsum.FieldByName('未收合计').AsFloat+memtblrpt_total.FieldByName('未收合计').AsFloat; mem_clientsum.FieldByName('未付合计').AsFloat:=mem_clientsum.FieldByName('未付合计').AsFloat+memtblrpt_total.FieldByName('未付合计').AsFloat; mem_clientsum.Post; end else begin // num:=GetZhangQiNum(memtblrpt_total.FieldByName('揽货人').AsString,memtblrpt_total.FieldByName('客户名称').AsString,memtblrpt_total.FieldByName('开船日期').AsDateTime,zqstr); mem_clientsum.Insert; mem_clientsum.FieldByName('揽货人').AsString:=memtblrpt_total.FieldByName('揽货人').AsString; mem_clientsum.FieldByName('客户名称').AsString:=memtblrpt_total.FieldByName('客户名称').AsString; mem_clientsum.FieldByName('客户账期').AsString:=GetZhangQi(memtblrpt_total.FieldByName('揽货人').AsString,memtblrpt_total.FieldByName('客户名称').asstring); mem_clientsum.FieldByName('欠费合计').AsFloat:=memtblrpt_total.FieldByName('差额合计').AsFloat; mem_clientsum.FieldByName('未收USD').AsFloat:=memtblrpt_total.FieldByName('未收USD').AsFloat; mem_clientsum.FieldByName('未收RMB').AsFloat:=memtblrpt_total.FieldByName('未收RMB').AsFloat; mem_clientsum.FieldByName('未收合计').AsFloat:=memtblrpt_total.FieldByName('未收合计').AsFloat; mem_clientsum.FieldByName('未付合计').AsFloat:=memtblrpt_total.FieldByName('未付合计').AsFloat; mem_clientsum.Post; end; memtblrpt_total.Next; end; freeAndNil(frm_sys_progress); GetNoFee; mem_clientmonth.SortOn('客户名称;月份',[]); end; procedure Tfrm_rp_no_selfno.bsSkinButton1Click(Sender: TObject); begin with SaveDialog do begin DefaultExt :='xls'; Filter := '(*.xls)|*.xls'; if Execute then begin if tab1.Showing then dxDBGrid2.SaveToXLS(FileName,true) else if bsSkinTabSheet2.Showing then dxDBGrid4.SaveToXLS(FileName,true) else if tab3.Showing then dxDBGrid6.SaveToXLS(FileName,true) else if tab4.Showing then dxDBGrid7.SaveToXLS(FileName,true) else if bsSkinTabSheet5.Showing then dxDBGrid5.SaveToXLS(FileName,true); end; end; end; procedure Tfrm_rp_no_selfno.bsSkinButton9Click(Sender: TObject); begin sys_print('业务综合欠费',2,nil,nil,nil,nil,p_total_dept1,p_total_sales1,p_total_client1,memtblrpt_total1,p_total1,nil,nil); end; procedure Tfrm_rp_no_selfno.dxDBGrid5DblClick(Sender: TObject); begin fee_view(p_accept_bill.fieldbyname('编号').asstring); end; procedure Tfrm_rp_no_selfno.dxDBGrid6DblClick(Sender: TObject); begin // fee_view(p_accept_fee.fieldbyname('编号').asstring); end; procedure Tfrm_rp_no_selfno.dxDBGrid7DblClick(Sender: TObject); begin // fee_view(p_pay_bill.fieldbyname('编号').asstring); end; procedure Tfrm_rp_no_selfno.dxDBGrid8DblClick(Sender: TObject); begin // fee_view(p_pay_fee.fieldbyname('编号').asstring); end; procedure Tfrm_rp_no_selfno.bsSkinButton15Click(Sender: TObject); var str_bill:widestring; begin str_bill:=''; if trim(str_bill)='' then begin str_bill:='where '+open_data('0033','v_op_bscard.揽货人','v_op_bscard.操作员','v_op_bscard.客服员','no','no'); end else begin str_bill:=str_bill+' and '+open_data('0033','v_op_bscard.揽货人','v_op_bscard.操作员','v_op_bscard.客服员','no','no'); end; if str_bill='' then str_bill:='where t_ch_fee.金额<>t_ch_fee.结算金额 ' else str_bill:=str_bill+' and t_ch_fee.金额<>t_ch_fee.结算金额 '; do_1(str_bill); GetNoFee; end; procedure Tfrm_rp_no_selfno.GetNoFee; var aQuery,aQuery2:TAdoQuery; sumbal:Double; hvcg:Boolean; aYear,aMonth,aDay,bDay:word; sDate,S:string; begin aQuery:=CreateAdoQuery; aQuery2:=CreateAdoQuery; try if memtblrpt_total.IsEmpty then exit; Creatememtbl; mem_total_sales.Close; mem_total_sales.EmptyTable; mem_total_sales.Open; mem_total_client.Close; mem_total_client.EmptyTable; mem_total_client.Open; mem_total_dept.Close; mem_total_dept.EmptyTable; mem_total_dept.Open; if not ASSIGNED(frm_sys_progress) then frm_sys_progress:=tfrm_sys_progress.Create(application); frm_sys_progress.Show; frm_sys_progress.bsSkinGauge1.MaxValue:=memtblrpt_total.RecordCount; frm_sys_progress.bsSkinGauge1.MinValue:=0; frm_sys_progress.bsSkinGauge1.Value:=0; frm_sys_progress.Update; memtblrpt_total.First; with memtblrpt_total do begin while not eof do begin frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; edit; memtblrpt_total.FieldByName('超期月数').AsInteger:=MonthsBetween(memtblrpt_total.FieldByName('应结日期').AsDateTime,now); if mem_clientmonth.Locate('客户名称;月份',VarArrayOf([memtblrpt_total.FieldByName('客户名称').asstring,memtblrpt_total.FieldByName('月份').AsStRING]),[]) then begin memtblrpt_total.FieldByName('月份合计').asstring:=memtblrpt_total.FieldByName('月份').AsStRING+' 超期天数:'+memtblrpt_total.FieldByName('超期天数').asstring +' 应结日期:'+memtblrpt_total.FieldByName('应结日期').asstring +' 未收USD:'+ mem_clientmonth.FieldByName('未收USD').asstring+' 未收RMB:'+ mem_clientmonth.FieldByName('未收RMB').asstring +' 未收合计:'+ mem_clientmonth.FieldByName('未收合计').asstring+' 未付合计:'+ mem_clientmonth.FieldByName('未付合计').asstring; end; if mem_clientsum.Locate('客户名称',VarArrayOf([memtblrpt_total.FieldByName('客户名称').asstring]),[]) then begin memtblrpt_total.FieldByName('客户合计').asstring:=memtblrpt_total.FieldByName('客户名称').AsStRING+' 超期天数:'+memtblrpt_total.FieldByName('超期天数').asstring +' 应结日期:'+memtblrpt_total.FieldByName('应结日期').asstring +' 未收USD:'+ mem_clientsum.FieldByName('未收USD').asstring+' 未收RMB:'+ mem_clientsum.FieldByName('未收RMB').asstring +' 未收合计:'+ mem_clientsum.FieldByName('未收合计').asstring+' 未付合计:'+ mem_clientsum.FieldByName('未付合计').asstring; memtblrpt_total.FieldByName('客户账期').asstring:=mem_clientsum.FieldByName('客户账期').asstring; end; post; if bsSkinCheckRadioBox3.Checked then begin if memtblrpt_total.FieldByName('是否超期').AsInteger=1 then begin if mem_total_sales.Locate('销售部门;揽货人;是否到期',VarArrayOf([memtblrpt_total.FieldByName('销售部门').asstring,memtblrpt_total.FieldByName('揽货人').AsStRING,true]),[]) then begin mem_total_sales.Edit; mem_total_sales.FieldByName('欠费合计').AsFloat:=mem_total_sales.FieldByName('欠费合计').AsFloat+memtblrpt_total.FieldByName('差额合计').AsFloat; mem_total_sales.FieldByName('欠费USD').AsFloat:=mem_total_sales.FieldByName('欠费USD').AsFloat+memtblrpt_total.FieldByName('差额USD').AsFloat; mem_total_sales.FieldByName('欠费RMB').AsFloat:=mem_total_sales.FieldByName('欠费RMB').AsFloat+memtblrpt_total.FieldByName('差额RMB').AsFloat; mem_total_sales.FieldByName('合计应收').AsFloat:=mem_total_sales.FieldByName('合计应收').AsFloat+memtblrpt_total.FieldByName('合计应收').AsFloat; mem_total_sales.FieldByName('合计应付').AsFloat:=mem_total_sales.FieldByName('合计应付').AsFloat+memtblrpt_total.FieldByName('合计应付').AsFloat; if (mem_total_sales.FieldByName('合计应付').AsFloat=0) then mem_total_sales.FieldByName('利润率').AsString:='无法结算' else mem_total_sales.FieldByName('利润率').AsString:=FormatFloat('0.00;-0.00;0',(mem_total_sales.FieldByName('合计应收').AsFloat-mem_total_sales.FieldByName('合计应付').AsFloat)/mem_total_sales.FieldByName('合计应付').AsFloat*100)+'%'; mem_total_sales.Post; end else begin mem_total_sales.Insert; mem_total_sales.FieldByName('揽货人').AsString:=memtblrpt_total.FieldByName('揽货人').AsString; mem_total_sales.FieldByName('销售部门').AsString:=memtblrpt_total.FieldByName('销售部门').AsString; mem_total_sales.FieldByName('欠费合计').AsFloat:=memtblrpt_total.FieldByName('差额合计').AsFloat; mem_total_sales.FieldByName('是否到期').Asboolean:=true; mem_total_sales.FieldByName('欠费USD').AsFloat:=memtblrpt_total.FieldByName('差额USD').AsFloat; mem_total_sales.FieldByName('欠费RMB').AsFloat:=memtblrpt_total.FieldByName('差额RMB').AsFloat; mem_total_sales.FieldByName('合计应收').AsFloat:=memtblrpt_total.FieldByName('合计应收').AsFloat; mem_total_sales.FieldByName('合计应付').AsFloat:=memtblrpt_total.FieldByName('合计应付').AsFloat; if (mem_total_sales.FieldByName('合计应付').AsFloat=0) then mem_total_sales.FieldByName('利润率').AsString:='无法结算' else mem_total_sales.FieldByName('利润率').AsString:=FormatFloat('0.00;-0.00;0',(mem_total_sales.FieldByName('合计应收').AsFloat-mem_total_sales.FieldByName('合计应付').AsFloat)/mem_total_sales.FieldByName('合计应付').AsFloat*100)+'%'; mem_total_sales.Post; end; if mem_total_dept.Locate('销售部门;是否到期',VarArrayOf([memtblrpt_total.FieldByName('销售部门').asstring,true]),[]) then begin mem_total_dept.Edit; mem_total_dept.FieldByName('欠费合计').AsFloat:=mem_total_dept.FieldByName('欠费合计').AsFloat+memtblrpt_total.FieldByName('差额合计').AsFloat; mem_total_dept.FieldByName('合计应收').AsFloat:=mem_total_dept.FieldByName('合计应收').AsFloat+memtblrpt_total.FieldByName('合计应收').AsFloat; mem_total_dept.FieldByName('合计应付').AsFloat:=mem_total_dept.FieldByName('合计应付').AsFloat+memtblrpt_total.FieldByName('合计应付').AsFloat; if (mem_total_dept.FieldByName('合计应付').AsFloat=0) then mem_total_dept.FieldByName('利润率').AsString:='无法结算' else mem_total_dept.FieldByName('利润率').AsString:=FormatFloat('0.00;-0.00;0',(mem_total_dept.FieldByName('合计应收').AsFloat-mem_total_dept.FieldByName('合计应付').AsFloat)/mem_total_dept.FieldByName('合计应付').AsFloat*100)+'%'; mem_total_dept.Post; end else begin mem_total_dept.Insert; mem_total_dept.FieldByName('销售部门').AsString:=memtblrpt_total.FieldByName('销售部门').AsString; mem_total_dept.FieldByName('欠费合计').AsFloat:=memtblrpt_total.FieldByName('差额合计').AsFloat; mem_total_dept.FieldByName('是否到期').Asboolean:=true; mem_total_dept.FieldByName('合计应收').AsFloat:=mem_total_dept.FieldByName('合计应收').AsFloat+memtblrpt_total.FieldByName('合计应收').AsFloat; mem_total_dept.FieldByName('合计应付').AsFloat:=mem_total_dept.FieldByName('合计应付').AsFloat+memtblrpt_total.FieldByName('合计应付').AsFloat; if (mem_total_dept.FieldByName('合计应付').AsFloat=0) then mem_total_dept.FieldByName('利润率').AsString:='无法结算' else mem_total_dept.FieldByName('利润率').AsString:=FormatFloat('0.00;-0.00;0',(mem_total_dept.FieldByName('合计应收').AsFloat-mem_total_dept.FieldByName('合计应付').AsFloat)/mem_total_dept.FieldByName('合计应付').AsFloat*100)+'%'; mem_total_dept.Post; end; if mem_total_client.Locate('客户名称;揽货人;是否到期',VarArrayOf([memtblrpt_total.FieldByName('客户名称').asstring,memtblrpt_total.FieldByName('揽货人').AsStRING,true]),[]) then begin mem_total_client.Edit; mem_total_client.FieldByName('欠费合计').AsFloat:=mem_total_client.FieldByName('欠费合计').AsFloat+memtblrpt_total.FieldByName('差额合计').AsFloat; mem_total_client.FieldByName('欠费USD').AsFloat:=mem_total_client.FieldByName('欠费USD').AsFloat+memtblrpt_total.FieldByName('差额USD').AsFloat; mem_total_client.FieldByName('欠费RMB').AsFloat:=mem_total_client.FieldByName('欠费RMB').AsFloat+memtblrpt_total.FieldByName('差额RMB').AsFloat; if (bsSkinCheckRadioBox4.Checked) then begin S:=mem_total_client.FieldByName('欠费说明').AsString; if Pos(memtblrpt_total.FieldByName('会计月份').AsString,S)=0 then mem_total_client.FieldByName('欠费说明').AsString:=mem_total_client.FieldByName('欠费说明').AsString+','+memtblrpt_total.FieldByName('会计月份').AsString; end else begin S:=mem_total_client.FieldByName('欠费说明').AsString; if Pos(memtblrpt_total.FieldByName('月份').AsString,S)=0 then mem_total_client.FieldByName('欠费说明').AsString:=mem_total_client.FieldByName('欠费说明').AsString+','+memtblrpt_total.FieldByName('月份').AsString; end; mem_total_client.FieldByName('合计应收').AsFloat:=mem_total_client.FieldByName('合计应收').AsFloat+memtblrpt_total.FieldByName('合计应收').AsFloat; mem_total_client.FieldByName('合计应付').AsFloat:=mem_total_client.FieldByName('合计应付').AsFloat+memtblrpt_total.FieldByName('合计应付').AsFloat; if (mem_total_client.FieldByName('合计应付').AsFloat=0) then mem_total_client.FieldByName('利润率').AsString:='无法结算' else mem_total_client.FieldByName('利润率').AsString:=FormatFloat('0.00;-0.00;0',(mem_total_client.FieldByName('合计应收').AsFloat-mem_total_client.FieldByName('合计应付').AsFloat)/mem_total_client.FieldByName('合计应付').AsFloat*100)+'%'; mem_total_client.Post; end else begin mem_total_client.Insert; mem_total_client.FieldByName('揽货人').AsString:=memtblrpt_total.FieldByName('揽货人').AsString; mem_total_client.FieldByName('客户名称').AsString:=memtblrpt_total.FieldByName('客户名称').AsString; mem_total_client.FieldByName('客户全称').AsString:=memtblrpt_total.FieldByName('客户全称').AsString; mem_total_client.FieldByName('客商编码').AsString:=memtblrpt_total.FieldByName('客商编码').AsString; mem_total_client.FieldByName('欠费合计').AsFloat:=memtblrpt_total.FieldByName('差额合计').AsFloat; mem_total_client.FieldByName('是否到期').Asboolean:=true; if (bsSkinCheckRadioBox4.Checked) then begin mem_total_client.FieldByName('欠费说明').AsString:=memtblrpt_total.FieldByName('会计月份').AsString; end else mem_total_client.FieldByName('欠费说明').AsString:=memtblrpt_total.FieldByName('月份').AsString; mem_total_client.FieldByName('欠费USD').AsFloat:=memtblrpt_total.FieldByName('差额USD').AsFloat; mem_total_client.FieldByName('欠费RMB').AsFloat:=memtblrpt_total.FieldByName('差额RMB').AsFloat; mem_total_client.FieldByName('客户帐期').AsString:=GetZhangQi(memtblrpt_total.FieldByName('揽货人').AsString,memtblrpt_total.FieldByName('客户名称').asstring); mem_total_client.FieldByName('合计应收').AsFloat:=mem_total_client.FieldByName('合计应收').AsFloat+memtblrpt_total.FieldByName('合计应收').AsFloat; mem_total_client.FieldByName('合计应付').AsFloat:=mem_total_client.FieldByName('合计应付').AsFloat+memtblrpt_total.FieldByName('合计应付').AsFloat; if (mem_total_client.FieldByName('合计应付').AsFloat=0) then mem_total_client.FieldByName('利润率').AsString:='无法结算' else mem_total_client.FieldByName('利润率').AsString:=FormatFloat('0.00;-0.00;0',(mem_total_client.FieldByName('合计应收').AsFloat-mem_total_client.FieldByName('合计应付').AsFloat)/mem_total_client.FieldByName('合计应付').AsFloat*100)+'%'; mem_total_client.Post; end; end else begin if mem_total_sales.Locate('销售部门;揽货人;是否到期',VarArrayOf([memtblrpt_total.FieldByName('销售部门').asstring,memtblrpt_total.FieldByName('揽货人').AsStRING,false]),[]) then begin mem_total_sales.Edit; mem_total_sales.FieldByName('欠费合计').AsFloat:=mem_total_sales.FieldByName('欠费合计').AsFloat+memtblrpt_total.FieldByName('差额合计').AsFloat; mem_total_sales.FieldByName('欠费USD').AsFloat:=mem_total_sales.FieldByName('欠费USD').AsFloat+memtblrpt_total.FieldByName('差额USD').AsFloat; mem_total_sales.FieldByName('欠费RMB').AsFloat:=mem_total_sales.FieldByName('欠费RMB').AsFloat+memtblrpt_total.FieldByName('差额RMB').AsFloat; mem_total_sales.FieldByName('合计应收').AsFloat:=mem_total_sales.FieldByName('合计应收').AsFloat+memtblrpt_total.FieldByName('合计应收').AsFloat; mem_total_sales.FieldByName('合计应付').AsFloat:=mem_total_sales.FieldByName('合计应付').AsFloat+memtblrpt_total.FieldByName('合计应付').AsFloat; if (mem_total_sales.FieldByName('合计应付').AsFloat=0) then mem_total_sales.FieldByName('利润率').AsString:='无法结算' else mem_total_sales.FieldByName('利润率').AsString:=FormatFloat('0.00;-0.00;0',(mem_total_sales.FieldByName('合计应收').AsFloat-mem_total_sales.FieldByName('合计应付').AsFloat)/mem_total_sales.FieldByName('合计应付').AsFloat*100)+'%'; mem_total_sales.Post; end else begin mem_total_sales.Insert; mem_total_sales.FieldByName('揽货人').AsString:=memtblrpt_total.FieldByName('揽货人').AsString; mem_total_sales.FieldByName('销售部门').AsString:=memtblrpt_total.FieldByName('销售部门').AsString; mem_total_sales.FieldByName('欠费合计').AsFloat:=memtblrpt_total.FieldByName('差额合计').AsFloat; mem_total_sales.FieldByName('是否到期').Asboolean:=false; mem_total_sales.FieldByName('欠费USD').AsFloat:=memtblrpt_total.FieldByName('差额USD').AsFloat; mem_total_sales.FieldByName('欠费RMB').AsFloat:=memtblrpt_total.FieldByName('差额RMB').AsFloat; mem_total_sales.FieldByName('合计应收').AsFloat:=mem_total_sales.FieldByName('合计应收').AsFloat+memtblrpt_total.FieldByName('合计应收').AsFloat; mem_total_sales.FieldByName('合计应付').AsFloat:=mem_total_sales.FieldByName('合计应付').AsFloat+memtblrpt_total.FieldByName('合计应付').AsFloat; if (mem_total_sales.FieldByName('合计应付').AsFloat=0) then mem_total_sales.FieldByName('利润率').AsString:='无法结算' else mem_total_sales.FieldByName('利润率').AsString:=FormatFloat('0.00;-0.00;0',(mem_total_sales.FieldByName('合计应收').AsFloat-mem_total_sales.FieldByName('合计应付').AsFloat)/mem_total_sales.FieldByName('合计应付').AsFloat*100)+'%'; mem_total_sales.Post; end; if mem_total_dept.Locate('销售部门;是否到期',VarArrayOf([memtblrpt_total.FieldByName('销售部门').asstring,false]),[]) then begin mem_total_dept.Edit; mem_total_dept.FieldByName('欠费合计').AsFloat:=mem_total_dept.FieldByName('欠费合计').AsFloat+memtblrpt_total.FieldByName('差额合计').AsFloat; mem_total_dept.FieldByName('合计应收').AsFloat:=mem_total_dept.FieldByName('合计应收').AsFloat+memtblrpt_total.FieldByName('合计应收').AsFloat; mem_total_dept.FieldByName('合计应付').AsFloat:=mem_total_dept.FieldByName('合计应付').AsFloat+memtblrpt_total.FieldByName('合计应付').AsFloat; if (mem_total_dept.FieldByName('合计应付').AsFloat=0) then mem_total_dept.FieldByName('利润率').AsString:='无法结算' else mem_total_dept.FieldByName('利润率').AsString:=FormatFloat('0.00;-0.00;0',(mem_total_dept.FieldByName('合计应收').AsFloat-mem_total_dept.FieldByName('合计应付').AsFloat)/mem_total_dept.FieldByName('合计应付').AsFloat*100)+'%'; mem_total_dept.Post; end else begin mem_total_dept.Insert; mem_total_dept.FieldByName('销售部门').AsString:=memtblrpt_total.FieldByName('销售部门').AsString; mem_total_dept.FieldByName('欠费合计').AsFloat:=memtblrpt_total.FieldByName('差额合计').AsFloat; mem_total_dept.FieldByName('是否到期').Asboolean:=false; mem_total_dept.FieldByName('合计应收').AsFloat:=mem_total_dept.FieldByName('合计应收').AsFloat+memtblrpt_total.FieldByName('合计应收').AsFloat; mem_total_dept.FieldByName('合计应付').AsFloat:=mem_total_dept.FieldByName('合计应付').AsFloat+memtblrpt_total.FieldByName('合计应付').AsFloat; if (mem_total_dept.FieldByName('合计应付').AsFloat=0) then mem_total_dept.FieldByName('利润率').AsString:='无法结算' else mem_total_dept.FieldByName('利润率').AsString:=FormatFloat('0.00;-0.00;0',(mem_total_dept.FieldByName('合计应收').AsFloat-mem_total_dept.FieldByName('合计应付').AsFloat)/mem_total_dept.FieldByName('合计应付').AsFloat*100)+'%'; mem_total_dept.Post; end; if mem_total_client.Locate('客户名称;揽货人;是否到期',VarArrayOf([memtblrpt_total.FieldByName('客户名称').asstring,memtblrpt_total.FieldByName('揽货人').AsStRING,false]),[]) then begin mem_total_client.Edit; mem_total_client.FieldByName('欠费合计').AsFloat:=mem_total_client.FieldByName('欠费合计').AsFloat+memtblrpt_total.FieldByName('差额合计').AsFloat; mem_total_client.FieldByName('欠费USD').AsFloat:=mem_total_client.FieldByName('欠费USD').AsFloat+memtblrpt_total.FieldByName('差额USD').AsFloat; mem_total_client.FieldByName('欠费RMB').AsFloat:=mem_total_client.FieldByName('欠费RMB').AsFloat+memtblrpt_total.FieldByName('差额RMB').AsFloat; if (bsSkinCheckRadioBox4.Checked) then begin S:=mem_total_client.FieldByName('欠费说明').AsString; if Pos(memtblrpt_total.FieldByName('会计月份').AsString,S)=0 then mem_total_client.FieldByName('欠费说明').AsString:=mem_total_client.FieldByName('欠费说明').AsString+','+memtblrpt_total.FieldByName('会计月份').AsString; end else begin S:=mem_total_client.FieldByName('欠费说明').AsString; if Pos(memtblrpt_total.FieldByName('月份').AsString,S)=0 then mem_total_client.FieldByName('欠费说明').AsString:=mem_total_client.FieldByName('欠费说明').AsString+','+memtblrpt_total.FieldByName('月份').AsString; end; mem_total_client.FieldByName('合计应收').AsFloat:=mem_total_client.FieldByName('合计应收').AsFloat+memtblrpt_total.FieldByName('合计应收').AsFloat; mem_total_client.FieldByName('合计应付').AsFloat:=mem_total_client.FieldByName('合计应付').AsFloat+memtblrpt_total.FieldByName('合计应付').AsFloat; if (mem_total_client.FieldByName('合计应付').AsFloat=0) then mem_total_client.FieldByName('利润率').AsString:='无法结算' else mem_total_client.FieldByName('利润率').AsString:=FormatFloat('0.00;-0.00;0',(mem_total_client.FieldByName('合计应收').AsFloat-mem_total_client.FieldByName('合计应付').AsFloat)/mem_total_client.FieldByName('合计应付').AsFloat*100)+'%'; mem_total_client.Post; end else begin mem_total_client.Insert; mem_total_client.FieldByName('揽货人').AsString:=memtblrpt_total.FieldByName('揽货人').AsString; mem_total_client.FieldByName('客户名称').AsString:=memtblrpt_total.FieldByName('客户名称').AsString; mem_total_client.FieldByName('客户全称').AsString:=memtblrpt_total.FieldByName('客户全称').AsString; mem_total_client.FieldByName('客商编码').AsString:=memtblrpt_total.FieldByName('客商编码').AsString; mem_total_client.FieldByName('欠费合计').AsFloat:=memtblrpt_total.FieldByName('差额合计').AsFloat; mem_total_client.FieldByName('是否到期').Asboolean:=false; mem_total_client.FieldByName('欠费USD').AsFloat:=memtblrpt_total.FieldByName('差额USD').AsFloat; mem_total_client.FieldByName('欠费RMB').AsFloat:=memtblrpt_total.FieldByName('差额RMB').AsFloat; if (bsSkinCheckRadioBox4.Checked) then begin mem_total_client.FieldByName('欠费说明').AsString:=memtblrpt_total.FieldByName('会计月份').AsString; end else begin mem_total_client.FieldByName('欠费说明').AsString:=memtblrpt_total.FieldByName('月份').AsString; end; mem_total_client.FieldByName('客户帐期').AsString:=GetZhangQi(memtblrpt_total.FieldByName('揽货人').AsString,memtblrpt_total.FieldByName('客户名称').asstring); mem_total_client.FieldByName('合计应收').AsFloat:=mem_total_client.FieldByName('合计应收').AsFloat+memtblrpt_total.FieldByName('合计应收').AsFloat; mem_total_client.FieldByName('合计应付').AsFloat:=mem_total_client.FieldByName('合计应付').AsFloat+memtblrpt_total.FieldByName('合计应付').AsFloat; if (mem_total_client.FieldByName('合计应付').AsFloat=0) then mem_total_client.FieldByName('利润率').AsString:='无法结算' else mem_total_client.FieldByName('利润率').AsString:=FormatFloat('0.00;-0.00;0',(mem_total_client.FieldByName('合计应收').AsFloat-mem_total_client.FieldByName('合计应付').AsFloat)/mem_total_client.FieldByName('合计应付').AsFloat*100)+'%'; mem_total_client.Post; end; end; end else begin if mem_total_sales.Locate('销售部门;揽货人',VarArrayOf([memtblrpt_total.FieldByName('销售部门').asstring,memtblrpt_total.FieldByName('揽货人').AsStRING]),[]) then begin mem_total_sales.Edit; mem_total_sales.FieldByName('欠费合计').AsFloat:=mem_total_sales.FieldByName('欠费合计').AsFloat+memtblrpt_total.FieldByName('差额合计').AsFloat; mem_total_sales.FieldByName('欠费USD').AsFloat:=mem_total_sales.FieldByName('欠费USD').AsFloat+memtblrpt_total.FieldByName('差额USD').AsFloat; mem_total_sales.FieldByName('欠费RMB').AsFloat:=mem_total_sales.FieldByName('欠费RMB').AsFloat+memtblrpt_total.FieldByName('差额RMB').AsFloat; mem_total_sales.FieldByName('合计应收').AsFloat:=mem_total_sales.FieldByName('合计应收').AsFloat+memtblrpt_total.FieldByName('合计应收').AsFloat; mem_total_sales.FieldByName('合计应付').AsFloat:=mem_total_sales.FieldByName('合计应付').AsFloat+memtblrpt_total.FieldByName('合计应付').AsFloat; if (mem_total_sales.FieldByName('合计应付').AsFloat=0) then mem_total_sales.FieldByName('利润率').AsString:='无法结算' else mem_total_sales.FieldByName('利润率').AsString:=FormatFloat('0.00;-0.00;0',(mem_total_sales.FieldByName('合计应收').AsFloat-mem_total_sales.FieldByName('合计应付').AsFloat)/mem_total_sales.FieldByName('合计应付').AsFloat*100)+'%'; mem_total_sales.Post; end else begin mem_total_sales.Insert; mem_total_sales.FieldByName('揽货人').AsString:=memtblrpt_total.FieldByName('揽货人').AsString; mem_total_sales.FieldByName('销售部门').AsString:=memtblrpt_total.FieldByName('销售部门').AsString; mem_total_sales.FieldByName('欠费合计').AsFloat:=memtblrpt_total.FieldByName('差额合计').AsFloat; mem_total_sales.FieldByName('是否到期').Asboolean:=false; mem_total_sales.FieldByName('欠费USD').AsFloat:=memtblrpt_total.FieldByName('差额USD').AsFloat; mem_total_sales.FieldByName('欠费RMB').AsFloat:=memtblrpt_total.FieldByName('差额RMB').AsFloat; mem_total_sales.FieldByName('合计应收').AsFloat:=mem_total_sales.FieldByName('合计应收').AsFloat+memtblrpt_total.FieldByName('合计应收').AsFloat; mem_total_sales.FieldByName('合计应付').AsFloat:=mem_total_sales.FieldByName('合计应付').AsFloat+memtblrpt_total.FieldByName('合计应付').AsFloat; if (mem_total_sales.FieldByName('合计应付').AsFloat=0) then mem_total_sales.FieldByName('利润率').AsString:='无法结算' else mem_total_sales.FieldByName('利润率').AsString:=FormatFloat('0.00;-0.00;0',(mem_total_sales.FieldByName('合计应收').AsFloat-mem_total_sales.FieldByName('合计应付').AsFloat)/mem_total_sales.FieldByName('合计应付').AsFloat*100)+'%'; mem_total_sales.Post; end; if mem_total_dept.Locate('销售部门',VarArrayOf([memtblrpt_total.FieldByName('销售部门').asstring]),[]) then begin mem_total_dept.Edit; mem_total_dept.FieldByName('欠费合计').AsFloat:=mem_total_dept.FieldByName('欠费合计').AsFloat+memtblrpt_total.FieldByName('差额合计').AsFloat; mem_total_dept.FieldByName('合计应收').AsFloat:=mem_total_dept.FieldByName('合计应收').AsFloat+memtblrpt_total.FieldByName('合计应收').AsFloat; mem_total_dept.FieldByName('合计应付').AsFloat:=mem_total_dept.FieldByName('合计应付').AsFloat+memtblrpt_total.FieldByName('合计应付').AsFloat; if (mem_total_dept.FieldByName('合计应付').AsFloat=0) then mem_total_dept.FieldByName('利润率').AsString:='无法结算' else mem_total_dept.FieldByName('利润率').AsString:=FormatFloat('0.00;-0.00;0',(mem_total_dept.FieldByName('合计应收').AsFloat-mem_total_dept.FieldByName('合计应付').AsFloat)/mem_total_dept.FieldByName('合计应付').AsFloat*100)+'%'; mem_total_dept.Post; end else begin mem_total_dept.Insert; mem_total_dept.FieldByName('销售部门').AsString:=memtblrpt_total.FieldByName('销售部门').AsString; mem_total_dept.FieldByName('欠费合计').AsFloat:=memtblrpt_total.FieldByName('差额合计').AsFloat; mem_total_dept.FieldByName('是否到期').Asboolean:=false; mem_total_dept.FieldByName('合计应收').AsFloat:=mem_total_dept.FieldByName('合计应收').AsFloat+memtblrpt_total.FieldByName('合计应收').AsFloat; mem_total_dept.FieldByName('合计应付').AsFloat:=mem_total_dept.FieldByName('合计应付').AsFloat+memtblrpt_total.FieldByName('合计应付').AsFloat; if (mem_total_dept.FieldByName('合计应付').AsFloat=0) then mem_total_dept.FieldByName('利润率').AsString:='无法结算' else mem_total_dept.FieldByName('利润率').AsString:=FormatFloat('0.00;-0.00;0',(mem_total_dept.FieldByName('合计应收').AsFloat-mem_total_dept.FieldByName('合计应付').AsFloat)/mem_total_dept.FieldByName('合计应付').AsFloat*100)+'%'; mem_total_dept.Post; end; if mem_total_client.Locate('客户名称;揽货人',VarArrayOf([memtblrpt_total.FieldByName('客户名称').asstring,memtblrpt_total.FieldByName('揽货人').AsStRING]),[]) then begin mem_total_client.Edit; mem_total_client.FieldByName('欠费合计').AsFloat:=mem_total_client.FieldByName('欠费合计').AsFloat+memtblrpt_total.FieldByName('差额合计').AsFloat; mem_total_client.FieldByName('欠费USD').AsFloat:=mem_total_client.FieldByName('欠费USD').AsFloat+memtblrpt_total.FieldByName('差额USD').AsFloat; mem_total_client.FieldByName('欠费RMB').AsFloat:=mem_total_client.FieldByName('欠费RMB').AsFloat+memtblrpt_total.FieldByName('差额RMB').AsFloat; if (bsSkinCheckRadioBox4.Checked) then begin S:=mem_total_client.FieldByName('欠费说明').AsString; if Pos(memtblrpt_total.FieldByName('会计月份').AsString,S)=0 then mem_total_client.FieldByName('欠费说明').AsString:=mem_total_client.FieldByName('欠费说明').AsString+','+memtblrpt_total.FieldByName('会计月份').AsString; end else begin S:=mem_total_client.FieldByName('欠费说明').AsString; if Pos(memtblrpt_total.FieldByName('月份').AsString,S)=0 then mem_total_client.FieldByName('欠费说明').AsString:=mem_total_client.FieldByName('欠费说明').AsString+','+memtblrpt_total.FieldByName('月份').AsString; end; mem_total_client.FieldByName('合计应收').AsFloat:=mem_total_client.FieldByName('合计应收').AsFloat+memtblrpt_total.FieldByName('合计应收').AsFloat; mem_total_client.FieldByName('合计应付').AsFloat:=mem_total_client.FieldByName('合计应付').AsFloat+memtblrpt_total.FieldByName('合计应付').AsFloat; if (mem_total_client.FieldByName('合计应付').AsFloat=0) then mem_total_client.FieldByName('利润率').AsString:='无法结算' else mem_total_client.FieldByName('利润率').AsString:=FormatFloat('0.00;-0.00;0',(mem_total_client.FieldByName('合计应收').AsFloat-mem_total_client.FieldByName('合计应付').AsFloat)/mem_total_client.FieldByName('合计应付').AsFloat*100)+'%'; mem_total_client.Post; end else begin mem_total_client.Insert; mem_total_client.FieldByName('揽货人').AsString:=memtblrpt_total.FieldByName('揽货人').AsString; mem_total_client.FieldByName('客户名称').AsString:=memtblrpt_total.FieldByName('客户名称').AsString; mem_total_client.FieldByName('客户全称').AsString:=memtblrpt_total.FieldByName('客户全称').AsString; mem_total_client.FieldByName('客商编码').AsString:=memtblrpt_total.FieldByName('客商编码').AsString; mem_total_client.FieldByName('欠费合计').AsFloat:=memtblrpt_total.FieldByName('差额合计').AsFloat; mem_total_client.FieldByName('欠费USD').AsFloat:=memtblrpt_total.FieldByName('差额USD').AsFloat; mem_total_client.FieldByName('欠费RMB').AsFloat:=memtblrpt_total.FieldByName('差额RMB').AsFloat; mem_total_client.FieldByName('是否到期').Asboolean:=false; if (bsSkinCheckRadioBox4.Checked) then begin mem_total_client.FieldByName('欠费说明').AsString:=memtblrpt_total.FieldByName('会计月份').AsString; end else begin mem_total_client.FieldByName('欠费说明').AsString:=memtblrpt_total.FieldByName('月份').AsString; end; mem_total_client.FieldByName('客户帐期').AsString:=GetZhangQi(memtblrpt_total.FieldByName('揽货人').AsString,memtblrpt_total.FieldByName('客户名称').asstring); mem_total_client.FieldByName('合计应收').AsFloat:=mem_total_client.FieldByName('合计应收').AsFloat+memtblrpt_total.FieldByName('合计应收').AsFloat; mem_total_client.FieldByName('合计应付').AsFloat:=mem_total_client.FieldByName('合计应付').AsFloat+memtblrpt_total.FieldByName('合计应付').AsFloat; if (mem_total_client.FieldByName('合计应付').AsFloat=0) then mem_total_client.FieldByName('利润率').AsString:='无法结算' else mem_total_client.FieldByName('利润率').AsString:=FormatFloat('0.00;-0.00;0',(mem_total_client.FieldByName('合计应收').AsFloat-mem_total_client.FieldByName('合计应付').AsFloat)/mem_total_client.FieldByName('合计应付').AsFloat*100)+'%'; mem_total_client.Post; end; end; { sDate:=FormatDateTime('YYYYMM',memtblrpt_total.FieldByName('开船日期').AsDateTime); if memtblDetail.Locate('揽货人;客户名称',VarArrayOf([memtblrpt_total.FieldByName('揽货人').asstring,memtblrpt_total.FieldByName('客户名称').AsStRING]),[]) THEN begin memtblDetail.edit; memtblDetail.FieldByName(sDate+'USD').AsFloat:=memtblDetail.FieldByName(sDate+'USD').AsFloat+memtblrpt_total.FieldByName('未收USD').AsFloat; memtblDetail.FieldByName(sDate+'RMB').AsFloat:=memtblDetail.FieldByName(sDate+'RMB').AsFloat+memtblrpt_total.FieldByName('未收RMB').AsFloat; memtblDetail.FieldByName(sDate+'合计').AsFloat:=memtblDetail.FieldByName(sDate+'合计').AsFloat+memtblrpt_total.FieldByName('未收合计').AsFloat; memtblDetail.FieldByName('合计USD').AsFloat:=memtblDetail.FieldByName('合计USD').AsFloat+memtblrpt_total.FieldByName('未收USD').AsFloat; memtblDetail.FieldByName('合计RMB').AsFloat:=memtblDetail.FieldByName('合计RMB').AsFloat+memtblrpt_total.FieldByName('未收RMB').AsFloat; memtblDetail.FieldByName('合计未收').AsFloat:=memtblDetail.FieldByName('合计未收').AsFloat+memtblrpt_total.FieldByName('未收合计').AsFloat; memtblDetail.Post; end else begin memtblDetail.Insert; memtblDetail.FieldByName('揽货人').AsString:=memtblrpt_total.FieldByName('揽货人').AsString; memtblDetail.FieldByName('客户名称').AsString:=memtblrpt_total.FieldByName('客户名称').AsString; memtblDetail.FieldByName('帐期描述').AsString:=GetZhangQi(memtblrpt_total.FieldByName('揽货人').AsString,memtblrpt_total.FieldByName('客户名称').AsString); memtblDetail.FieldByName(sDate+'USD').AsFloat:=memtblrpt_total.FieldByName('未收USD').AsFloat; memtblDetail.FieldByName(sDate+'RMB').AsFloat:=memtblrpt_total.FieldByName('未收RMB').AsFloat; memtblDetail.FieldByName(sDate+'合计').AsFloat:=memtblrpt_total.FieldByName('未收合计').AsFloat; memtblDetail.FieldByName('合计USD').AsFloat:=memtblrpt_total.FieldByName('未收USD').AsFloat; memtblDetail.FieldByName('合计RMB').AsFloat:=memtblrpt_total.FieldByName('未收RMB').AsFloat; memtblDetail.FieldByName('合计未收').AsFloat:=memtblrpt_total.FieldByName('未收合计').AsFloat; memtblDetail.Post; end; } next; end; end; dxDBGrid2.FullExpand; dxDBGrid4.FullExpand; dxDBGrid6.FullExpand; dxDBGrid7.FullExpand; // memtblDetail.SortOn('揽货人;客户名称',[mtcoDescending]); finally freeAndNil(aQuery); freeAndNil(aQuery2); freeAndNil(frm_sys_progress); memtblrpt_total.EnableControls; end; end; procedure Tfrm_rp_no_selfno.Creatememtbl; var aDate,aToDate:TDate; sDate,aYear,aMonth:String; aColumn:TdxDBTreeListColumn; aBand:TdxTreeListBand; i:integer; begin if (fmDate='') or (ToDate='') then exit; dxDBGrid1.Bands.Clear; // dxDBGrid1.DestroyColumns; 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); memtblDetail.FieldDefs.Add('揽货人', ftString, 10, false); memtblDetail.FieldDefs.Add('帐期描述', ftString, 100, false); aBand:=dxDBGrid1.Bands.Add; aBand.Caption:='基本信息'; aColumn:=dxDBGrid1.CreateColumn(TdxDBGridColumn); aColumn.Caption:='客户名称'; aColumn.BandIndex:=0; aColumn.FieldName:='客户名称'; aColumn:=dxDBGrid1.CreateColumn(TdxDBGridColumn); aColumn.Caption:='帐期描述'; aColumn.BandIndex:=0; aColumn.FieldName:='帐期描述'; aColumn:=dxDBGrid1.CreateColumn(TdxDBGridColumn); aColumn.Caption:='揽货人'; aColumn.FieldName:='揽货人'; aColumn.BandIndex:=0; i:=1; aDate:=strtodate(FmDate); aToDate:=strtodate(ToDate); while not (aDate>aToDate) do begin sDate:=FormatDateTime('YYYYMM',aDate); aYear:=FormatDateTime('YYYY',aDate); aMonth:=FormatDateTime('MM',aDate); aBand:=dxDBGrid1.Bands.Add; aBand.Caption:=aYear+'年'+aMonth+'月'; aColumn:=dxDBGrid1.CreateColumn(TdxDBGridColumn); aColumn.Caption:='未收USD'; aColumn.FieldName:=sDate+'USD'; aColumn.SummaryFooterType:=cstSum; aColumn.BandIndex:=i; aColumn:=dxDBGrid1.CreateColumn(TdxDBGridColumn); aColumn.Caption:='未收RMB'; aColumn.FieldName:=sDate+'RMB'; aColumn.SummaryFooterType:=cstSum; aColumn.BandIndex:=i; aColumn:=dxDBGrid1.CreateColumn(TdxDBGridColumn); aColumn.Caption:='未收合计'; aColumn.FieldName:=sDate+'合计'; aColumn.SummaryFooterType:=cstSum; aColumn.BandIndex:=i; memtblDetail.FieldDefs.Add(sDate+'USD',ftFloat, 0, false); memtblDetail.FieldDefs.Add(sDate+'RMB',ftFloat, 0, false); memtblDetail.FieldDefs.Add(sDate+'合计',ftFloat, 0, false); aDate:=IncMonth(aDate,1); Inc(i); end; aBand:=dxDBGrid1.Bands.Add; aBand.Caption:='合计'; aColumn:=dxDBGrid1.CreateColumn(TdxDBGridColumn); aColumn.Caption:='未收USD'; aColumn.FieldName:='合计USD'; aColumn.SummaryFooterType:=cstSum; aColumn.BandIndex:=i; aColumn:=dxDBGrid1.CreateColumn(TdxDBGridColumn); aColumn.Caption:='未收RMB'; aColumn.FieldName:='合计RMB'; aColumn.SummaryFooterType:=cstSum; aColumn.BandIndex:=i; aColumn:=dxDBGrid1.CreateColumn(TdxDBGridColumn); aColumn.Caption:='未收合计'; aColumn.FieldName:='合计未收'; aColumn.SummaryFooterType:=cstSum; aColumn.BandIndex:=i; memtblDetail.FieldDefs.Add('合计USD',ftFloat, 0, false); memtblDetail.FieldDefs.Add('合计RMB',ftFloat, 0, false); memtblDetail.FieldDefs.Add('合计未收',ftFloat, 0, false); memtblDetail.CreateTable; memtblDetail.Open; end; function Tfrm_rp_no_selfno.GetZhangQiNum(SaleID, Cust: String; aetd: TDateTime;out zqstr:string): Double; var aQuery:TAdoQuery; sub:string; begin aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add('Select * from t_crm_client_sales where 状态=''审核'' and 开始日期<='''+FormatDateTime('YYYY-MM-DD',aetd)+''' and 结束日期>='''+FormatDateTime('YYYY-MM-DD',aetd)+''' and 客户简称='''+Cust+''' and 揽货人='''+SaleID+''''); Open; if not IsEmpty then begin if FieldByName('结费金额').IsNull or (FieldByName('结费金额').AsFloat<=0) then begin Result:=0; end else begin Result:=FieldByName('结费金额').AsFloat; end; if FieldByName('结费类型').AsString='现结买单' then begin zqstr:=zqstr+'当月结算;'; end else if FieldByName('结费类型').AsString='约定天数' then begin zqstr:=zqstr+'约定天数,['+fieldByName('结费期限').AsString+']天'; end else if FieldByName('结费类型').AsString='约定时间' then begin if StrToIntDef(FieldByName('类型模式').AsString,0)=0 then sub:='当月' else if StrToIntDef(FieldByName('类型模式').AsString,0)=1 then sub:='次1月' else if StrToIntDef(FieldByName('类型模式').AsString,0)=2 then sub:='次2月' else if StrToIntDef(FieldByName('类型模式').AsString,0)=3 then sub:='次3月' else sub:='次'+inttostr(StrToIntDef(FieldByName('类型模式').AsString,0))+'月'; if FieldByName('日期模式').AsString='固定' then zqstr:=sub+FieldByName('结费日期').AsString+'日' else zqstr:=sub; end else if FieldByName('结费类型').AsString='分阶段付费' then begin zqstr:=zqstr+'分阶段付费;'; end; end else begin Result:=-1; end; end; finally FreeAndNil(aQuery); end; end; function Tfrm_rp_no_selfno.isChaoQi(SaleID, Cust: String): Boolean; begin end; procedure Tfrm_rp_no_selfno.bsSkinCheckRadioBox3Click(Sender: TObject); begin GetNoFee; end; procedure Tfrm_rp_no_selfno.bsSkinCheckRadioBox2Click(Sender: TObject); begin GetNoFee; end; function Tfrm_rp_no_selfno.GetZhangQiStr(SaleID, Cust: String): String; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; Result:=''; try with aQuery do begin Close;SQL.Clear; sql.Add(' select distinct SUBSTRING(CONVERT(char(15), dbo.v_op_bscard.开船日期, 111), 1, 7) from v_op_bscard left join t_ch_fee on t_ch_fee.编号=v_op_bscard.编号 '); sql.Add(sqlstr); sql.Add(' and t_ch_fee.客户名称='''+Cust+''' and v_op_bscard.揽货人='''+SaleID+''''); Open; if not IsEmpty then begin first; while not eof do begin if Result='' then result:=Fields[0].value else Result:=Result+','+Fields[0].value; Next; end; Result:=Result+'的欠费' end else result:=''; end; finally FreeAndNil(aQuery); end; end; procedure Tfrm_rp_no_selfno.bsSkinButton12Click(Sender: TObject); begin if bsSkinButton12.Caption='展开' then begin dxdbgrid2.FullExpand; dxdbgrid4.FullExpand; dxdbgrid6.FullExpand; dxdbgrid7.FullExpand; bsSkinButton12.Caption:='合并'; end else begin dxdbgrid2.FullCollapse; dxdbgrid4.FullCollapse; dxdbgrid6.FullCollapse; dxdbgrid7.FullCollapse; bsSkinButton12.Caption:='展开'; end; end; procedure Tfrm_rp_no_selfno.N10Click(Sender: TObject); begin update_grid_view_no(dxDBGrid7); exit; end; procedure Tfrm_rp_no_selfno.N14Click(Sender: TObject); begin update_grid_view_all(dxdbgrid7); exit; end; procedure Tfrm_rp_no_selfno.N12Click(Sender: TObject); begin update_grid(dxdbgrid7,200); exit; end; procedure Tfrm_rp_no_selfno.N16Click(Sender: TObject); begin grid_save_xls(dxdbgrid7); exit; end; procedure Tfrm_rp_no_selfno.dxDBGridColumn7CustomDraw(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(ANode.strings[dxDBGridColumn7.Index],0)>0 then AColor:=clRed else AColor:=clWhite; AFont.Color:=clblack; end; procedure Tfrm_rp_no_selfno.MenuItem1Click(Sender: TObject); begin update_grid_view_no(dxDBGrid5); exit; end; procedure Tfrm_rp_no_selfno.MenuItem3Click(Sender: TObject); begin update_grid_view_all(dxdbgrid5); exit; end; procedure Tfrm_rp_no_selfno.MenuItem5Click(Sender: TObject); begin update_grid(dxdbgrid5,201); exit; end; procedure Tfrm_rp_no_selfno.MenuItem7Click(Sender: TObject); begin grid_save_xls(dxdbgrid5); exit; end; procedure Tfrm_rp_no_selfno.FormShow(Sender: TObject); begin loadreggrid(dxdbgrid1,false,caption+'1'); loadreggrid(dxdbgrid7,false,caption+'7'); loadreggrid(dxdbgrid5,false,caption+'5'); end; end.