unit u_rp_no_zou; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, TeEngine, Series, ExtCtrls, TeeProcs, Chart, DbChart, bsSkinCtrls, StdCtrls, wwdbdatetimepicker, RxLookup, Mask, wwdbedit, Wwdotdot, Wwdbcomb,teeprevi, DB, ADODB, RxMemDS, Menus, XPMenu, ComCtrls; type Tfrm_rp_no_zou = class(TForm) bsSkinPanel1: TbsSkinPanel; bsSkinButton10: TbsSkinButton; bsSkinButton9: TbsSkinButton; bsSkinButton5: TbsSkinButton; Label16: TLabel; RxDBLookupCombo6: TRxDBLookupCombo; Label14: TLabel; RxDBLookupCombo3: TRxDBLookupCombo; RxDBLookupCombo12: TRxDBLookupCombo; Label23: TLabel; Label22: TLabel; RxDBLookupCombo10: TRxDBLookupCombo; Label10: TLabel; Label5: TLabel; wwDBComboBox1: TwwDBComboBox; Label7: TLabel; Label9: TLabel; RxDBLookupCombo2: TRxDBLookupCombo; bsSkinButton1: TbsSkinButton; p_no_accept: TADOStoredProc; bsSkinCheckRadioBox2: TbsSkinCheckRadioBox; bsSkinCheckRadioBox1: TbsSkinCheckRadioBox; wwDBComboBox2: TwwDBComboBox; wwDBComboBox3: TwwDBComboBox; wwDBComboBox4: TwwDBComboBox; wwDBComboBox5: TwwDBComboBox; bsSkinPanel2: TbsSkinPanel; bsSkinCheckRadioBox3: TbsSkinCheckRadioBox; bsSkinCheckRadioBox4: TbsSkinCheckRadioBox; bsSkinPanel3: TbsSkinPanel; bsSkinPanel4: TbsSkinPanel; DBChart1: TDBChart; Series1: TLineSeries; DBChart2: TDBChart; LineSeries1: TBarSeries; bsSkinPanel5: TbsSkinPanel; DBChart3: TDBChart; LineSeries2: TLineSeries; DBChart4: TDBChart; BarSeries1: TBarSeries; p_no_pay: TADOStoredProc; PopupMenu1: TPopupMenu; N5: TMenuItem; N1: TMenuItem; N2: TMenuItem; XPMenu1: TXPMenu; t_sum: TRxMemoryData; bsSkinCheckRadioBox5: TbsSkinCheckRadioBox; procedure bsSkinButton5Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure bsSkinButton10Click(Sender: TObject); procedure bsSkinButton9Click(Sender: TObject); procedure bsSkinButton1Click(Sender: TObject); procedure bsSkinCheckRadioBox4Click(Sender: TObject); procedure bsSkinCheckRadioBox3Click(Sender: TObject); procedure N2Click(Sender: TObject); procedure bsSkinPanel3Resize(Sender: TObject); procedure N5Click(Sender: TObject); procedure FormShow(Sender: TObject); private { Private declarations } public { Public declarations } end; var frm_rp_no_zou: Tfrm_rp_no_zou; implementation uses u_main, my_sys_function, u_data_share; {$R *.dfm} procedure Tfrm_rp_no_zou.bsSkinButton5Click(Sender: TObject); begin close; end; procedure Tfrm_rp_no_zou.FormClose(Sender: TObject; var Action: TCloseAction); begin frm_rp_no_zou.Hide; frm_rp_no_zou.ManualFloat(frm_rp_no_zou.BoundsRect ); frm_main.freeTabs('frm_rp_no_zou'); action:=cafree; frm_rp_no_zou:=nil; end; procedure Tfrm_rp_no_zou.bsSkinButton10Click(Sender: TObject); begin wwDBComboBox2.text:=''; wwDBComboBox3.text:=''; wwDBComboBox4.text:=''; wwDBComboBox5.text:=''; wwDBComboBox1.text:=''; RxDBLookupCombo2.ClearValue; RxDBLookupCombo6.ClearValue; RxDBLookupCombo12.ClearValue; RxDBLookupCombo3.ClearValue; RxDBLookupCombo10.ClearValue; end; procedure Tfrm_rp_no_zou.bsSkinButton9Click(Sender: TObject); var Pnt:Tpoint; begin Pnt:=bsSkinButton9.ClientToScreen(Point(0,bsSkinButton9.Height)); PopupMenu1.Popup(Pnt.x,Pnt.y); end; procedure Tfrm_rp_no_zou.bsSkinButton1Click(Sender: TObject); var str_op:widestring; str_start,str_end:string; str_date:string; i,j,f,h:integer; begin if (wwDBComboBox2.ItemIndex=-1)or(wwDBComboBox3.ItemIndex=-1)or (wwDBComboBox4.ItemIndex=-1)or(wwDBComboBox5.ItemIndex=-1) then begin showmessage('请将开始年月和结束年月输入完整!!'); exit; end; try if strtoint(wwDBComboBox2.text)>strtoint(wwDBComboBox5.text) then begin showmessage('开始年月不能大于结束年月!!'); exit; end; if strtoint(wwDBComboBox2.text)=strtoint(wwDBComboBox5.text) then begin if strtoint(wwDBComboBox3.text)>strtoint(wwDBComboBox4.text) then begin showmessage('开始年月不能大于结束年月!!'); exit; end; end; except showmessage('请将开始年月和结束年月输入完整!!'); exit; end; if bsSkinCheckRadioBox2.Checked then str_date:='业务日期' else if bsSkinCheckRadioBox3.Checked then str_date:='预抵日期' else str_date:='会计期间'; str_start:=wwDBComboBox2.text+'/'+wwDBComboBox3.text; str_end:=wwDBComboBox5.text+'/'+wwDBComboBox4.text; str_op:=' where '+open_data('0033','v_no_ying.揽货人','v_no_ying.操作员','v_no_ying.客服员','no','no'); if wwDBComboBox1.ItemIndex<>-1 then str_op:=str_op+' and v_no_ying.业务种类='+''''+wwDBComboBox1.text+''''; if RxDBLookupCombo6.DisplayValue<>''then str_op:=str_op+' and v_no_ying.操作员='+''''+RxDBLookupCombo6.DisplayValue+''''; if RxDBLookupCombo12.DisplayValue<>''then str_op:=str_op+' and v_no_ying.操作部门='+''''+RxDBLookupCombo12.DisplayValue+''''; if RxDBLookupCombo3.DisplayValue<>''then str_op:=str_op+' and v_no_ying.揽货人='+''''+RxDBLookupCombo3.DisplayValue+''''; if RxDBLookupCombo10.DisplayValue<>''then str_op:=str_op+' and v_no_ying.销售部门='+''''+RxDBLookupCombo10.DisplayValue+''''; if RxDBLookupCombo2.DisplayValues[1]<>''then str_op:=str_op+' and v_no_ying.客户名称='+''''+RxDBLookupCombo2.DisplayValues[1]+''''; str_op:='select sum(应收金额) as 应收金额,sum(应付金额) as 应付金额,年月 from v_no_ying ' +str_op+' and (年月 between '+''''+str_start+''''+' and '+''''+str_end+'''' +') group by 年月'; p_no_accept.close; p_no_accept.Parameters.ParamByName('SQLStr').value:=str_op; p_no_accept.Open; str_op:=' where '+open_data('0033','v_no_jie.揽货人','v_no_jie.操作员','v_no_jie.客服员','no','no'); if wwDBComboBox1.ItemIndex<>-1 then str_op:=str_op+' and v_no_jie.业务种类='+''''+wwDBComboBox1.text+''''; if RxDBLookupCombo6.DisplayValue<>''then str_op:=str_op+' and v_no_jie.操作员='+''''+RxDBLookupCombo6.DisplayValue+''''; if RxDBLookupCombo12.DisplayValue<>''then str_op:=str_op+' and v_no_jie.操作部门='+''''+RxDBLookupCombo12.DisplayValue+''''; if RxDBLookupCombo3.DisplayValue<>''then str_op:=str_op+' and v_no_jie.揽货人='+''''+RxDBLookupCombo3.DisplayValue+''''; if RxDBLookupCombo10.DisplayValue<>''then str_op:=str_op+' and v_no_jie.销售部门='+''''+RxDBLookupCombo10.DisplayValue+''''; if RxDBLookupCombo2.DisplayValues[1]<>''then str_op:=str_op+' and v_no_jie.客户名称='+''''+RxDBLookupCombo2.DisplayValues[1]+''''; str_op:='select sum(已收金额) as 已收金额,sum(已付金额) as 已付金额,年月 from v_no_jie ' +str_op+' and (年月 between '+''''+str_start+''''+' and '+''''+str_end+'''' +') group by 年月'; p_no_pay.close; p_no_pay.Parameters.ParamByName('SQLStr').value:=str_op; p_no_pay.Open; t_sum.close; t_sum.open; i:=strtoint(wwDBComboBox5.text)-strtoint(wwDBComboBox2.text); if i=0 then begin for j:=strtoint(wwDBComboBox3.text) to strtoint(wwDBComboBox4.text) do begin t_sum.append; if j<10 then t_sum['年月']:=wwDBComboBox5.text+'/0'+inttostr(j) else t_sum['年月']:=wwDBComboBox5.text+'/'+inttostr(j); t_sum['应收欠款']:=0; t_sum['应付欠款']:=0; t_sum.Post; end; end else begin for j:=0 to i do begin if j=0 then begin for f:=strtoint(wwDBComboBox3.text) to 12 do begin t_sum.append; if f<10 then t_sum['年月']:=wwDBComboBox2.text+'/0'+inttostr(f) else t_sum['年月']:=wwDBComboBox2.text+'/'+inttostr(f); t_sum['应收欠款']:=0; t_sum['应付欠款']:=0; t_sum.Post; end; end else if j=i then begin for f:=1 to strtoint(wwDBComboBox4.text) do begin t_sum.append; if f<10 then t_sum['年月']:=wwDBComboBox5.text+'/0'+inttostr(f) else t_sum['年月']:=wwDBComboBox5.text+'/'+inttostr(f); t_sum['应收欠款']:=0; t_sum['应付欠款']:=0; t_sum.Post; end; end else begin for f:=1 to 12 do begin t_sum.append; if f<10 then t_sum['年月']:=inttostr(strtoint(wwDBComboBox2.text)+j)+'/0'+inttostr(f) else t_sum['年月']:=inttostr(strtoint(wwDBComboBox2.text)+j)+'/'+inttostr(f); t_sum['应收欠款']:=0; t_sum['应付欠款']:=0; t_sum.Post; end; end; end; end; p_no_accept.First; while not p_no_accept.eof do begin t_sum.first; while not t_sum.eof do begin if p_no_accept.FieldByName('年月').asstring<=t_sum.FieldByName('年月').asstring then begin t_sum.edit; t_sum['应收欠款']:=t_sum['应收欠款']+p_no_accept['应收金额']; t_sum['应付欠款']:=t_sum['应付欠款']+p_no_accept['应付金额']; t_sum.Post; end; t_sum.next; end; p_no_accept.next; end; p_no_pay.First; while not p_no_pay.eof do begin t_sum.first; while not t_sum.eof do begin if p_no_pay.FieldByName('年月').asstring<=t_sum.FieldByName('年月').asstring then begin t_sum.edit; t_sum['应收欠款']:=t_sum['应收欠款']-p_no_pay['已收金额']; t_sum['应付欠款']:=t_sum['应付欠款']-p_no_pay['已付金额']; t_sum.Post; end; t_sum.next; end; p_no_pay.next; end; t_sum.SortOnFields('年月'); end; procedure Tfrm_rp_no_zou.bsSkinCheckRadioBox4Click(Sender: TObject); begin DBChart1.Visible:=true; DBChart2.Visible:=false; DBChart3.Visible:=true; DBChart4.Visible:=false; frm_rp_no_zou.FormShow(Sender); end; procedure Tfrm_rp_no_zou.bsSkinCheckRadioBox3Click(Sender: TObject); begin DBChart2.Visible:=true; DBChart1.Visible:=false; DBChart4.Visible:=true; DBChart3.Visible:=false; frm_rp_no_zou.FormShow(Sender); end; procedure Tfrm_rp_no_zou.N2Click(Sender: TObject); begin if DBChart3.Visible=true then chartpreview(frm_rp_no_zou,dbchart3) else chartpreview(frm_rp_no_zou,dbchart4); end; procedure Tfrm_rp_no_zou.bsSkinPanel3Resize(Sender: TObject); begin bsSkinPanel4.Height:=round(bsSkinPanel3.Height/2); end; procedure Tfrm_rp_no_zou.N5Click(Sender: TObject); begin if DBChart1.Visible=true then chartpreview(frm_rp_no_zou,dbchart1) else chartpreview(frm_rp_no_zou,dbchart2); end; procedure Tfrm_rp_no_zou.FormShow(Sender: TObject); begin if frm_data_share.t_load_employee.FieldByName('应收').asboolean then begin DBChart2.Visible:=true; DBChart1.Visible:=true; end else begin DBChart2.Visible:=false; DBChart1.Visible:=false; end; if frm_data_share.t_load_employee.FieldByName('应付').asboolean then begin DBChart3.Visible:=true; DBChart4.Visible:=true; end else begin DBChart3.Visible:=false; DBChart4.Visible:=false; end; end; end.