unit u_fee_check; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, DB, ADODB, StdCtrls, Mask, bsSkinBoxCtrls, bsdbctrls, bsSkinCtrls, ExtCtrls, DBCtrls, Grids, Wwdbigrd, Wwdbgrid, Menus, XPMenu; type Tfra_fee_check = class(TFrame) bsSkinPanel1: TbsSkinPanel; bsSkinPanel3: TbsSkinPanel; Panel1: TPanel; bsSkinButton1: TbsSkinButton; bsSkinButton11: TbsSkinButton; bsSkinButton2: TbsSkinButton; bsSkinButton4: TbsSkinButton; bsSkinButton3: TbsSkinButton; bsSkinPanel4: TbsSkinPanel; a_bo: TbsSkinGroupBox; DBMemo1: TDBMemo; a_delete: TbsSkinGroupBox; DBMemo2: TDBMemo; a_modify_old: TbsSkinGroupBox; Label8: TLabel; Label9: TLabel; Label10: TLabel; Label11: TLabel; Label12: TLabel; Label13: TLabel; Label14: TLabel; Label15: TLabel; DBEdit1: TDBEdit; DBEdit2: TDBEdit; DBEdit3: TDBEdit; DBEdit4: TDBEdit; DBEdit5: TDBEdit; DBEdit6: TDBEdit; DBEdit7: TDBEdit; DBEdit8: TDBEdit; a_modify_new: TbsSkinGroupBox; Label16: TLabel; Label17: TLabel; Label18: TLabel; Label19: TLabel; Label20: TLabel; Label21: TLabel; Label22: TLabel; Label23: TLabel; Label24: TLabel; DBEdit9: TDBEdit; DBEdit10: TDBEdit; DBEdit11: TDBEdit; DBEdit12: TDBEdit; DBEdit13: TDBEdit; DBEdit14: TDBEdit; DBEdit15: TDBEdit; DBEdit16: TDBEdit; DBMemo3: TDBMemo; wwDBGrid1: TwwDBGrid; DBEdit17: TDBEdit; bsSkinPanel5: TbsSkinPanel; bsSkinPanel6: TbsSkinPanel; p_bo: TbsSkinGroupBox; DBMemo4: TDBMemo; p_delete: TbsSkinGroupBox; DBMemo5: TDBMemo; p_modify_old: TbsSkinGroupBox; Label25: TLabel; Label26: TLabel; Label27: TLabel; Label28: TLabel; Label29: TLabel; Label30: TLabel; Label31: TLabel; Label32: TLabel; DBEdit19: TDBEdit; DBEdit20: TDBEdit; DBEdit21: TDBEdit; DBEdit22: TDBEdit; DBEdit23: TDBEdit; DBEdit24: TDBEdit; DBEdit25: TDBEdit; DBEdit26: TDBEdit; p_modify_new: TbsSkinGroupBox; Label33: TLabel; Label34: TLabel; Label35: TLabel; Label36: TLabel; Label37: TLabel; Label38: TLabel; Label39: TLabel; Label40: TLabel; DBEdit27: TDBEdit; DBEdit28: TDBEdit; DBEdit29: TDBEdit; DBEdit30: TDBEdit; DBEdit31: TDBEdit; DBEdit32: TDBEdit; DBEdit33: TDBEdit; DBEdit34: TDBEdit; wwDBGrid2: TwwDBGrid; DBEdit18: TDBEdit; Panel2: TPanel; bsSkinButton5: TbsSkinButton; bsSkinButton6: TbsSkinButton; bsSkinButton7: TbsSkinButton; bsSkinButton8: TbsSkinButton; bsSkinButton9: TbsSkinButton; t_ch_accept: TADOQuery; t_ch_accept1: TDataSource; t_ch_pay: TADOQuery; t_ch_pay1: TDataSource; t_op_gain: TADOQuery; t_op_gain1: TDataSource; a_shen_delete: TADOQuery; a_shen_modify_old: TADOQuery; a_shen_modify_new: TADOQuery; a_shen_modify_new1: TDataSource; a_shen_modify_old1: TDataSource; a_shen_delete1: TDataSource; p_shen_delete: TADOQuery; p_shen_delete1: TDataSource; p_shen_modify_old: TADOQuery; p_shen_modify_old1: TDataSource; p_shen_modify_new: TADOQuery; p_shen_modify_new1: TDataSource; PopupMenu4: TPopupMenu; N82: TMenuItem; N83: TMenuItem; N84: TMenuItem; N85: TMenuItem; N86: TMenuItem; N87: TMenuItem; N88: TMenuItem; PopupMenu5: TPopupMenu; MenuItem5: TMenuItem; MenuItem6: TMenuItem; MenuItem10: TMenuItem; MenuItem11: TMenuItem; MenuItem12: TMenuItem; MenuItem13: TMenuItem; MenuItem14: TMenuItem; XPMenu1: TXPMenu; bsSkinButton10: TbsSkinButton; bsSkinButton12: TbsSkinButton; Label1: TLabel; DBEdit35: TDBEdit; Label2: TLabel; DBEdit36: TDBEdit; DBEdit37: TDBEdit; DBEdit38: TDBEdit; Label4: TLabel; Label3: TLabel; bsSkinPanel7: TbsSkinPanel; Label5: TLabel; Label6: TLabel; DBEdit39: TDBEdit; DBEdit40: TDBEdit; bsSkinPanel8: TbsSkinPanel; Label7: TLabel; Label42: TLabel; DBEdit41: TDBEdit; DBEdit42: TDBEdit; Panel3: TPanel; bsSkinPanel2: TbsSkinPanel; bsSkinStdLabel1: TbsSkinStdLabel; bsSkinStdLabel2: TbsSkinStdLabel; bsSkinStdLabel3: TbsSkinStdLabel; bsSkinStdLabel4: TbsSkinStdLabel; bsSkinStdLabel5: TbsSkinStdLabel; bsSkinStdLabel6: TbsSkinStdLabel; bsSkinStdLabel7: TbsSkinStdLabel; bsSkinStdLabel8: TbsSkinStdLabel; bsSkinStdLabel9: TbsSkinStdLabel; bsSkinStdLabel10: TbsSkinStdLabel; bsSkinDBEdit1: TbsSkinDBEdit; bsSkinDBEdit2: TbsSkinDBEdit; bsSkinDBEdit3: TbsSkinDBEdit; bsSkinDBEdit4: TbsSkinDBEdit; bsSkinDBEdit5: TbsSkinDBEdit; bsSkinDBEdit6: TbsSkinDBEdit; bsSkinDBEdit7: TbsSkinDBEdit; bsSkinDBEdit8: TbsSkinDBEdit; bsSkinDBEdit9: TbsSkinDBEdit; bsSkinDBEdit10: TbsSkinDBEdit; bsSkinPanel9: TbsSkinPanel; bsSkinStdLabel11: TbsSkinStdLabel; bsSkinStdLabel12: TbsSkinStdLabel; bsSkinStdLabel13: TbsSkinStdLabel; bsSkinStdLabel14: TbsSkinStdLabel; bsSkinStdLabel15: TbsSkinStdLabel; bsSkinStdLabel16: TbsSkinStdLabel; bsSkinStdLabel17: TbsSkinStdLabel; bsSkinStdLabel18: TbsSkinStdLabel; bsSkinStdLabel19: TbsSkinStdLabel; bsSkinStdLabel20: TbsSkinStdLabel; bsSkinDBEdit11: TbsSkinDBEdit; bsSkinDBEdit12: TbsSkinDBEdit; bsSkinDBEdit13: TbsSkinDBEdit; bsSkinDBEdit14: TbsSkinDBEdit; bsSkinDBEdit15: TbsSkinDBEdit; bsSkinDBEdit16: TbsSkinDBEdit; bsSkinDBEdit17: TbsSkinDBEdit; bsSkinDBEdit18: TbsSkinDBEdit; bsSkinDBEdit19: TbsSkinDBEdit; bsSkinDBEdit20: TbsSkinDBEdit; t_op_gain_main: TADOQuery; t_op_gain_main1: TDataSource; DBEdit43: TDBEdit; Label43: TLabel; DBEdit44: TDBEdit; Label44: TLabel; DBEdit45: TDBEdit; Label45: TLabel; DBEdit46: TDBEdit; Label41: TLabel; DBEdit47: TDBEdit; Label46: TLabel; DBMemo6: TDBMemo; limited_str: TEdit; bsSkinButton13: TbsSkinButton; bsSkinButton14: TbsSkinButton; Label47: TLabel; DBEdit48: TDBEdit; Label48: TLabel; DBEdit49: TDBEdit; Label49: TLabel; DBEdit50: TDBEdit; Label50: TLabel; DBEdit51: TDBEdit; Label51: TLabel; DBEdit52: TDBEdit; Label52: TLabel; DBEdit53: TDBEdit; Label53: TLabel; DBEdit54: TDBEdit; Label54: TLabel; DBEdit55: TDBEdit; Label55: TLabel; DBEdit56: TDBEdit; Label56: TLabel; DBEdit57: TDBEdit; Label57: TLabel; DBEdit58: TDBEdit; Label58: TLabel; DBEdit59: TDBEdit; bsSkinPanel10: TbsSkinPanel; DBEdit60: TDBEdit; bsSkinExPanel1: TbsSkinExPanel; Memo1: TMemo; N1: TMenuItem; N2: TMenuItem; bsSkinCheckRadioBox1: TbsSkinCheckRadioBox; bsSkinCheckRadioBox2: TbsSkinCheckRadioBox; procedure DBEdit17Change(Sender: TObject); procedure DBEdit18Change(Sender: TObject); procedure bsSkinButton1Click(Sender: TObject); procedure bsSkinButton5Click(Sender: TObject); procedure bsSkinButton2Click(Sender: TObject); procedure bsSkinButton7Click(Sender: TObject); procedure wwDBGrid1DrawDataCell(Sender: TObject; const Rect: TRect; Field: TField; State: TGridDrawState); procedure wwDBGrid2DrawDataCell(Sender: TObject; const Rect: TRect; Field: TField; State: TGridDrawState); procedure bsSkinButton4Click(Sender: TObject); procedure bsSkinButton8Click(Sender: TObject); procedure bsSkinButton3Click(Sender: TObject); procedure bsSkinButton9Click(Sender: TObject); procedure bsSkinButton11Click(Sender: TObject); procedure bsSkinButton6Click(Sender: TObject); procedure bsSkinPanel2Resize(Sender: TObject); procedure Panel1Resize(Sender: TObject); procedure Panel2Resize(Sender: TObject); procedure t_ch_acceptBeforePost(DataSet: TDataSet); procedure t_ch_payBeforePost(DataSet: TDataSet); procedure N82Click(Sender: TObject); procedure N84Click(Sender: TObject); procedure N86Click(Sender: TObject); procedure N88Click(Sender: TObject); procedure MenuItem5Click(Sender: TObject); procedure MenuItem10Click(Sender: TObject); procedure MenuItem12Click(Sender: TObject); procedure bsSkinButton10Click(Sender: TObject); procedure bsSkinButton12Click(Sender: TObject); procedure DBEdit43Change(Sender: TObject); procedure bsSkinPanel1Resize(Sender: TObject); procedure bsSkinPanel9Resize(Sender: TObject); procedure bsSkinButton13Click(Sender: TObject); procedure bsSkinButton14Click(Sender: TObject); procedure DBEdit60Change(Sender: TObject); procedure t_op_gainAfterOpen(DataSet: TDataSet); procedure N2Click(Sender: TObject); procedure bsSkinCheckRadioBox1Click(Sender: TObject); procedure bsSkinCheckRadioBox2Click(Sender: TObject); private { Private declarations } public procedure getsumstr;//合计字符生成 { Public declarations } end; implementation uses my_sys_function, u_fee_check_shen, u_main; {$R *.dfm} procedure Tfra_fee_check.DBEdit17Change(Sender: TObject); begin if t_ch_accept.IsEmpty then begin a_bo.Visible:=false; a_bo.Align:=alNone; a_delete.Visible:=false; a_delete.Align:=alNone; a_modify_old.Visible:=false; a_modify_old.Align:=alNone; a_modify_new.Visible:=false; a_modify_new.Align:=alNone; exit; end; if t_ch_accept.FieldByName('费用状态').asstring='驳回提交'then begin a_delete.Visible:=false; a_delete.Align:=alNone; a_modify_old.Visible:=false; a_modify_old.Align:=alNone; a_modify_new.Visible:=false; a_modify_new.Align:=alNone; a_bo.Visible:=true; a_bo.Align:=alRight; exit; end; if t_ch_accept.FieldByName('费用状态').asstring='申请删除'then begin a_bo.Visible:=false; a_bo.Align:=alNone; a_modify_old.Visible:=false; a_modify_old.Align:=alNone; a_modify_new.Visible:=false; a_modify_new.Align:=alNone; a_delete.Visible:=true; a_delete.Align:=alRight; exit; end; if t_ch_accept.FieldByName('费用状态').asstring='申请修改'then begin a_bo.Visible:=false; a_bo.Align:=alNone; a_delete.Visible:=false; a_delete.Align:=alNone; a_modify_new.Visible:=true; a_modify_new.Align:=alRight; a_modify_old.Visible:=true; a_modify_old.Align:=alRight; exit; end; a_bo.Visible:=false; a_bo.Align:=alNone; a_delete.Visible:=false; a_delete.Align:=alNone; a_modify_old.Visible:=false; a_modify_old.Align:=alNone; a_modify_new.Visible:=false; a_modify_new.Align:=alNone; end; procedure Tfra_fee_check.DBEdit18Change(Sender: TObject); begin if t_ch_pay.IsEmpty then begin p_bo.Visible:=false; p_bo.Align:=alNone; p_delete.Visible:=false; p_delete.Align:=alNone; p_modify_old.Visible:=false; p_modify_old.Align:=alNone; p_modify_new.Visible:=false; p_modify_new.Align:=alNone; exit; end; if t_ch_pay.FieldByName('费用状态').asstring='驳回提交'then begin p_delete.Visible:=false; p_delete.Align:=alNone; p_modify_old.Visible:=false; p_modify_old.Align:=alNone; p_modify_new.Visible:=false; p_modify_new.Align:=alNone; p_bo.Visible:=true; p_bo.Align:=alRight; exit; end; if t_ch_pay.FieldByName('费用状态').asstring='申请删除'then begin p_bo.Visible:=false; p_bo.Align:=alNone; p_modify_old.Visible:=false; p_modify_old.Align:=alNone; p_modify_new.Visible:=false; p_modify_new.Align:=alNone; p_delete.Visible:=true; p_delete.Align:=alRight; exit; end; if t_ch_pay.FieldByName('费用状态').asstring='申请修改'then begin p_bo.Visible:=false; p_bo.Align:=alNone; p_delete.Visible:=false; p_delete.Align:=alNone; p_modify_new.Visible:=true; p_modify_new.Align:=alRight; p_modify_old.Visible:=true; p_modify_old.Align:=alRight; exit; end; p_bo.Visible:=false; p_bo.Align:=alNone; p_delete.Visible:=false; p_delete.Align:=alNone; p_modify_old.Visible:=false; p_modify_old.Align:=alNone; p_modify_new.Visible:=false; p_modify_new.Align:=alNone; end; procedure Tfra_fee_check.bsSkinButton1Click(Sender: TObject); begin fee_check_part(limited_str.text,t_ch_accept,wwDBGrid1); end; procedure Tfra_fee_check.bsSkinButton5Click(Sender: TObject); begin fee_check_part(limited_str.text,t_ch_pay,wwDBGrid2); end; procedure Tfra_fee_check.bsSkinButton2Click(Sender: TObject); begin fee_back(limited_str.text,t_ch_accept,wwDBGrid1); end; procedure Tfra_fee_check.bsSkinButton7Click(Sender: TObject); begin fee_back(limited_str.text,t_ch_pay,wwDBGrid2); end; procedure Tfra_fee_check.wwDBGrid1DrawDataCell(Sender: TObject; const Rect: TRect; Field: TField; State: TGridDrawState); begin fee_color(t_ch_accept,wwDBGrid1,Rect,Field); end; procedure Tfra_fee_check.wwDBGrid2DrawDataCell(Sender: TObject; const Rect: TRect; Field: TField; State: TGridDrawState); begin fee_color(t_ch_pay,wwDBGrid2,Rect,Field); end; procedure Tfra_fee_check.bsSkinButton4Click(Sender: TObject); begin fee_shen_check_ok(limited_str.text,t_ch_accept,a_shen_delete,a_shen_modify_old,a_shen_modify_new); if Panel3.Visible then t_op_gain.Requery(); if bsSkinPanel9.Visible then t_op_gain_main.Requery(); getsumstr; end; procedure Tfra_fee_check.bsSkinButton8Click(Sender: TObject); begin fee_shen_check_ok(limited_str.text,t_ch_pay,p_shen_delete,p_shen_modify_old,p_shen_modify_new); if Panel3.Visible then t_op_gain.Requery(); if bsSkinPanel9.Visible then t_op_gain_main.Requery(); getsumstr; end; procedure Tfra_fee_check.bsSkinButton3Click(Sender: TObject); begin fee_shen_check_back(limited_str.text,t_ch_accept,a_shen_delete,a_shen_modify_old,a_shen_modify_new); end; procedure Tfra_fee_check.bsSkinButton9Click(Sender: TObject); begin fee_shen_check_back(limited_str.text,t_ch_pay,p_shen_delete,p_shen_modify_old,p_shen_modify_new); end; procedure Tfra_fee_check.bsSkinButton11Click(Sender: TObject); begin try frm_fee_check_shen:=tfrm_fee_check_shen.Create(self); frm_fee_check_shen.t_ch_fee.Parameters.ParamByName('类型').value:='收'; frm_fee_check_shen.t_ch_fee.Parameters.ParamByName('编号').value:=t_ch_accept.DataSource.DataSet.fieldbyname('编号').Value; frm_fee_check_shen.t_ch_fee.open; frm_fee_check_shen.t_ch_fee_new.open; frm_fee_check_shen.ShowModal; finally frm_fee_check_shen.Free; end; end; procedure Tfra_fee_check.bsSkinButton6Click(Sender: TObject); begin try frm_fee_check_shen:=tfrm_fee_check_shen.Create(self); frm_fee_check_shen.t_ch_fee.Parameters.ParamByName('类型').value:='付'; frm_fee_check_shen.t_ch_fee.Parameters.ParamByName('编号').value:=t_ch_pay.DataSource.DataSet.fieldbyname('编号').Value; frm_fee_check_shen.t_ch_fee.open; frm_fee_check_shen.t_ch_fee_new.open; frm_fee_check_shen.ShowModal; finally frm_fee_check_shen.Free; end; end; procedure Tfra_fee_check.bsSkinPanel2Resize(Sender: TObject); var i:integer; begin i:=round((bsSkinPanel2.Width-196)/10); bsSkinDBEdit1.Width:=i; bsSkinDBEdit2.Width:=i; bsSkinDBEdit3.Width:=i; bsSkinDBEdit4.Width:=i; bsSkinDBEdit5.Width:=i; bsSkinDBEdit6.Width:=i; bsSkinDBEdit7.Width:=i; bsSkinDBEdit8.Width:=i; bsSkinDBEdit9.Width:=i; end; procedure Tfra_fee_check.Panel1Resize(Sender: TObject); var i:integer; begin i:=round(Panel1.Width/8); bsSkinButton1.Width:=i; bsSkinButton10.Width:=i; bsSkinButton2.Width:=i; bsSkinButton3.Width:=i; bsSkinButton4.Width:=i; bsSkinButton13.Width:=i; bsSkinButton14.Width:=i; end; procedure Tfra_fee_check.Panel2Resize(Sender: TObject); var i:integer; begin i:=round(Panel2.Width/6); bsSkinButton5.Width:=i; bsSkinButton12.Width:=i; bsSkinButton9.Width:=i; bsSkinButton7.Width:=i; bsSkinButton8.Width:=i; end; procedure Tfra_fee_check.t_ch_acceptBeforePost(DataSet: TDataSet); begin t_ch_accept['费用状态']:=t_ch_accept['费用状态']; t_ch_accept['开票金额']:=t_ch_accept['开票金额']; t_ch_accept['结算金额']:=t_ch_accept['结算金额']; end; procedure Tfra_fee_check.t_ch_payBeforePost(DataSet: TDataSet); begin t_ch_pay['费用状态']:=t_ch_pay['费用状态']; t_ch_pay['开票金额']:=t_ch_pay['开票金额']; t_ch_pay['结算金额']:=t_ch_pay['结算金额']; end; procedure Tfra_fee_check.N82Click(Sender: TObject); begin fee_balance_view(t_ch_accept); end; procedure Tfra_fee_check.N84Click(Sender: TObject); begin fee_invoice_view(t_ch_accept); end; procedure Tfra_fee_check.N86Click(Sender: TObject); begin fee_modify_view(t_ch_accept); end; procedure Tfra_fee_check.N88Click(Sender: TObject); begin price_person_view; end; procedure Tfra_fee_check.MenuItem5Click(Sender: TObject); begin fee_balance_view(t_ch_pay); end; procedure Tfra_fee_check.MenuItem10Click(Sender: TObject); begin fee_check_view(t_ch_pay); end; procedure Tfra_fee_check.MenuItem12Click(Sender: TObject); begin fee_modify_view(t_ch_pay); end; procedure Tfra_fee_check.bsSkinButton10Click(Sender: TObject); begin fee_check_all(limited_str.text,t_ch_accept); end; procedure Tfra_fee_check.bsSkinButton12Click(Sender: TObject); begin fee_check_all(limited_str.text,t_ch_pay); end; procedure Tfra_fee_check.DBEdit43Change(Sender: TObject); begin if Panel3.Visible then begin if (DBEdit43.Text='拼箱主票')then begin bsSkinPanel9.Visible:=true; Panel3.Height:=40; end else begin bsSkinPanel9.Visible:=false; Panel3.Height:=20; end; end; end; procedure Tfra_fee_check.bsSkinPanel1Resize(Sender: TObject); begin bsSkinPanel3.Height:=round((bsSkinPanel1.height-bsSkinPanel10.height)/2); end; procedure Tfra_fee_check.bsSkinPanel9Resize(Sender: TObject); var i:integer; begin i:=round((bsSkinPanel9.Width-196)/10); bsSkinDBEdit11.Width:=i; bsSkinDBEdit12.Width:=i; bsSkinDBEdit13.Width:=i; bsSkinDBEdit14.Width:=i; bsSkinDBEdit15.Width:=i; bsSkinDBEdit16.Width:=i; bsSkinDBEdit17.Width:=i; bsSkinDBEdit18.Width:=i; bsSkinDBEdit19.Width:=i; end; procedure Tfra_fee_check.bsSkinButton13Click(Sender: TObject); var aQuery:TADOQuery; i:Integer; begin aQuery:=CreateAdoQuery; try if wwDBGrid1.SelectedList.Count>=1 then begin for i:=0 to wwDBGrid1.SelectedList.Count-1 do begin t_ch_accept.GotoBookmark(pointer(wwDBGrid1.SelectedList[i])); with aQuery do begin Close;SQL.Clear; SQL.Add('update t_ch_fee set 不开发票=1 where CH_ID='+inttostr(t_ch_accept.FieldbyName('CH_ID').asinteger)); ExecSQL; end; end; end else begin with aQuery do begin Close;SQL.Clear; SQL.Add('update t_ch_fee set 不开发票=1 where CH_ID='+inttostr(t_ch_accept.FieldbyName('CH_ID').asinteger)); ExecSQL; end; end; finally FreeAndNil(aQuery); end; t_ch_accept.Requery(); end; procedure Tfra_fee_check.bsSkinButton14Click(Sender: TObject); var aQuery:TADOQuery; i:Integer; begin aQuery:=CreateAdoQuery; try if wwDBGrid1.SelectedList.Count>=1 then begin for i:=0 to wwDBGrid1.SelectedList.Count-1 do begin t_ch_accept.GotoBookmark(pointer(wwDBGrid1.SelectedList[i])); with aQuery do begin Close;SQL.Clear; SQL.Add('update t_ch_fee set 不开发票=0 where CH_ID='+inttostr(t_ch_accept.FieldbyName('CH_ID').asinteger)); ExecSQL; end; end; end else begin with aQuery do begin Close;SQL.Clear; SQL.Add('update t_ch_fee set 不开发票=0 where CH_ID='+inttostr(t_ch_accept.FieldbyName('CH_ID').asinteger)); ExecSQL; end; end; finally FreeAndNil(aQuery); end; t_ch_accept.Requery(); end; procedure Tfra_fee_check.getsumstr; var aQuery1,aQuery2:TAdoQuery; str1,str2:string; acceptstr,paystr:widestring; accepteof,payeof:boolean; armb,ausd,aot,atotal,prmb,pusd,pot,ptotal,rarmb,rausd,raot,ratotal,rprmb,rpusd,rpot,rptotal:double; begin //费用下部合计字符串生成 if not bsSkinPanel3.Visible then exit; memo1.Lines.Clear; if (t_ch_accept.IsEmpty or (not t_ch_accept.Active)) and (t_ch_pay.IsEmpty or (not t_ch_pay.Active)) then exit; aQuery1:=CreateAdoQuery; aQuery2:=CreateAdoQuery; armb:=0; ausd:=0; aot:=0; atotal:=0; prmb:=0; pusd:=0; pot:=0; ptotal:=0; rarmb:=0; rausd:=0; raot:=0; ratotal:=0; rprmb:=0; rpusd:=0; rpot:=0; rptotal:=0; try accepteof:=false; payeof:=false; if (t_ch_accept.IsEmpty or (not t_ch_accept.Active)) then aQuery1.SQL.Text:='select 客户名称,sum(case 币别 when ''RMB'' then 金额 else 0 end) as 人民币金额,' +'sum(case 币别 when ''USD'' then 金额 else 0 end) as 美元金额,' +'sum(case 币别 when ''USD'' then 0 else (case 币别 when ''RMB'' then 0 else 金额 end) end) as 其他金额,' +'sum(金额*汇率) as 合计金额' +',sum(case 币别 when ''RMB'' then 税额 else 0 end) as 人民币税额,' +'sum(case 币别 when ''USD'' then 税额 else 0 end) as 美元税额,' +'sum(case 币别 when ''USD'' then 0 else (case 币别 when ''RMB'' then 0 else 税额 end) end) as 其他税额,' +'sum(税额*汇率) as 合计税额' +' from t_ch_fee where 1=2 group by 客户名称' else begin acceptstr:=new_query(t_ch_accept); aQuery1.SQL.Text:='select 客户名称,sum(case 币别 when ''RMB'' then 金额 else 0 end) as 人民币金额,' +'sum(case 币别 when ''USD'' then 金额 else 0 end) as 美元金额,' +'sum(case 币别 when ''USD'' then 0 else (case 币别 when ''RMB'' then 0 else 金额 end) end) as 其他金额,' +'sum(金额*汇率) as 合计金额' +',sum(case 币别 when ''RMB'' then 税额 else 0 end) as 人民币税额,' +'sum(case 币别 when ''USD'' then 税额 else 0 end) as 美元税额,' +'sum(case 币别 when ''USD'' then 0 else (case 币别 when ''RMB'' then 0 else 税额 end) end) as 其他税额,' +'sum(税额*汇率) as 合计税额' +' from t_ch_fee '+acceptstr+' group by 客户名称'; aQuery1.DataSource:=t_ch_accept.DataSource; end; aQuery1.Open; aQuery1.first; if (t_ch_pay.IsEmpty or (not t_ch_pay.Active)) then aQuery2.SQL.Text:='select 客户名称,sum(case 币别 when ''RMB'' then 金额 else 0 end) as 人民币金额,' +'sum(case 币别 when ''USD'' then 金额 else 0 end) as 美元金额,' +'sum(case 币别 when ''USD'' then 0 else (case 币别 when ''RMB'' then 0 else 金额 end) end) as 其他金额,' +'sum(金额*汇率) as 合计金额' +',sum(case 币别 when ''RMB'' then 税额 else 0 end) as 人民币税额,' +'sum(case 币别 when ''USD'' then 税额 else 0 end) as 美元税额,' +'sum(case 币别 when ''USD'' then 0 else (case 币别 when ''RMB'' then 0 else 税额 end) end) as 其他税额,' +'sum(税额*汇率) as 合计税额' +' from t_ch_fee where 1=2 group by 客户名称' else begin paystr:=new_query(t_ch_pay); aQuery2.SQL.Text:='select 客户名称,sum(case 币别 when ''RMB'' then 金额 else 0 end) as 人民币金额,' +'sum(case 币别 when ''USD'' then 金额 else 0 end) as 美元金额,' +'sum(case 币别 when ''USD'' then 0 else (case 币别 when ''RMB'' then 0 else 金额 end) end) as 其他金额,' +'sum(金额*汇率) as 合计金额' +',sum(case 币别 when ''RMB'' then 税额 else 0 end) as 人民币税额,' +'sum(case 币别 when ''USD'' then 税额 else 0 end) as 美元税额,' +'sum(case 币别 when ''USD'' then 0 else (case 币别 when ''RMB'' then 0 else 税额 end) end) as 其他税额,' +'sum(税额*汇率) as 合计税额' +' from t_ch_fee '+paystr+' group by 客户名称'; aQuery2.DataSource:=t_ch_pay.DataSource; end; aQuery2.Open; aQuery2.first; while (not aQuery1.Eof) or (not aQuery2.Eof) do begin if aQuery1.Eof then begin str1:=FixLenStr('',120); end else begin str1:=FixLenStr(aQuery1.fieldbyname('客户名称').AsString,20)+' '+FixLenStr(FormatFloat('#,##0.00',aQuery1.fieldbyname('人民币金额').Asfloat),12,' ',false); if aQuery1.fieldbyname('人民币税额').Asfloat<>0 then str1:=str1+'(税'+FixLenStr(FormatFloat('#,##0.00',aQuery1.fieldbyname('人民币税额').Asfloat),8,' ',false)+')'+' '+FixLenStr(FormatFloat('#,##0.00',aQuery1.fieldbyname('美元金额').Asfloat),12,' ',false) else str1:=str1+' '+' '+FixLenStr(FormatFloat('#,##0.00',aQuery1.fieldbyname('美元金额').Asfloat),12,' ',false); if aQuery1.fieldbyname('美元税额').Asfloat<>0 then str1:=str1+'(税'+FixLenStr(FormatFloat('#,##0.00',aQuery1.fieldbyname('美元税额').Asfloat),8,' ',false)+')'+' '+FixLenStr(FormatFloat('#,##0.00',aQuery1.fieldbyname('其他金额').Asfloat),12,' ',false) else str1:=str1+' '+' '+FixLenStr(FormatFloat('#,##0.00',aQuery1.fieldbyname('其他金额').Asfloat),12,' ',false); if aQuery1.fieldbyname('其他税额').Asfloat<>0 then str1:=str1+'(税'+FixLenStr(FormatFloat('#,##0.00',aQuery1.fieldbyname('其他税额').Asfloat),8,' ',false)+')'+' '+FixLenStr(FormatFloat('#,##0.00',aQuery1.fieldbyname('合计金额').Asfloat),12,' ',false) else str1:=str1+' '+' '+FixLenStr(FormatFloat('#,##0.00',aQuery1.fieldbyname('合计金额').Asfloat),12,' ',false); if aQuery1.fieldbyname('合计税额').Asfloat<>0 then str1:=str1+'(税'+FixLenStr(FormatFloat('#,##0.00',aQuery1.fieldbyname('合计税额').Asfloat),8,' ',false)+')' else str1:=str1+' '; armb:=armb+aquery1.fieldbyname('人民币金额').AsFloat; ausd:=ausd+aquery1.fieldbyname('美元金额').AsFloat; aot:=aot+aquery1.fieldbyname('其他金额').AsFloat; atotal:=atotal+aquery1.fieldbyname('合计金额').AsFloat; rarmb:=rarmb+aquery1.fieldbyname('人民币税额').AsFloat; rausd:=rausd+aquery1.fieldbyname('美元税额').AsFloat; raot:=raot+aquery1.fieldbyname('其他税额').AsFloat; ratotal:=ratotal+aquery1.fieldbyname('合计税额').AsFloat; aQuery1.Next; end; if aQuery2.Eof then begin str2:=FixLenStr('',120); end else begin str2:=FixLenStr(aQuery2.fieldbyname('客户名称').AsString,20)+' '+FixLenStr(FormatFloat('#,##0.00',aQuery2.fieldbyname('人民币金额').Asfloat),12,' ',false); if aQuery2.fieldbyname('人民币税额').Asfloat<>0 then str2:=str2+'(税'+FixLenStr(FormatFloat('#,##0.00',aQuery2.fieldbyname('人民币税额').Asfloat),8,' ',false)+')'+' '+FixLenStr(FormatFloat('#,##0.00',aQuery2.fieldbyname('美元金额').Asfloat),12,' ',false) else str2:=str2+' '+' '+FixLenStr(FormatFloat('#,##0.00',aQuery2.fieldbyname('美元金额').Asfloat),12,' ',false); if aQuery2.fieldbyname('美元税额').Asfloat<>0 then str2:=str2+'(税'+FixLenStr(FormatFloat('#,##0.00',aQuery2.fieldbyname('美元税额').Asfloat),8,' ',false)+')'+' '+FixLenStr(FormatFloat('#,##0.00',aQuery2.fieldbyname('其他金额').Asfloat),12,' ',false) else str2:=str2+' '+' '+FixLenStr(FormatFloat('#,##0.00',aQuery2.fieldbyname('其他金额').Asfloat),12,' ',false); if aQuery2.fieldbyname('其他税额').Asfloat<>0 then str2:=str2+'(税'+FixLenStr(FormatFloat('#,##0.00',aQuery2.fieldbyname('其他税额').Asfloat),8,' ',false)+')'+' '+FixLenStr(FormatFloat('#,##0.00',aQuery2.fieldbyname('合计金额').Asfloat),12,' ',false) else str2:=str2+' '+' '+FixLenStr(FormatFloat('#,##0.00',aQuery2.fieldbyname('合计金额').Asfloat),12,' ',false); if aQuery2.fieldbyname('合计税额').Asfloat<>0 then str2:=str2+'(税'+FixLenStr(FormatFloat('#,##0.00',aQuery2.fieldbyname('合计税额').Asfloat),8,' ',false)+')' else str2:=str2+' '; prmb:=prmb+aquery2.fieldbyname('人民币金额').AsFloat; pusd:=pusd+aquery2.fieldbyname('美元金额').AsFloat; pot:=pot+aquery2.fieldbyname('其他金额').AsFloat; ptotal:=ptotal+aquery2.fieldbyname('合计金额').AsFloat; rprmb:=rprmb+aquery2.fieldbyname('人民币税额').AsFloat; rpusd:=rpusd+aquery2.fieldbyname('美元税额').AsFloat; rpot:=rpot+aquery2.fieldbyname('其他税额').AsFloat; rptotal:=rptotal+aquery2.fieldbyname('合计税额').AsFloat; aQuery2.Next; end; memo1.Lines.Add(str1+'|'+str2); end; str1:=FixLenStr('-',120,'-'); str2:=FixLenStr('-',120,'-'); memo1.Lines.Add(str1+'|'+str2); str1:=FixLenStr('应收合计',20)+' '+FixLenStr(FormatFloat('#,##0.00',armb),12,' ',false); if rarmb<>0 then str1:=str1+'(税'+FixLenStr(FormatFloat('#,##0.00',rarmb),8,' ',false)+')'+' '+FixLenStr(FormatFloat('#,##0.00',ausd),12,' ',false) else str1:=str1+' '+' '+FixLenStr(FormatFloat('#,##0.00',ausd),12,' ',false); if rausd<>0 then str1:=str1+'(税'+FixLenStr(FormatFloat('#,##0.00',rausd),8,' ',false)+')'+' '+FixLenStr(FormatFloat('#,##0.00',aot),12,' ',false) else str1:=str1+' '+' '+FixLenStr(FormatFloat('#,##0.00',aot),12,' ',false); if raot<>0 then str1:=str1+'(税'+FixLenStr(FormatFloat('#,##0.00',raot),8,' ',false)+')'+' '+FixLenStr(FormatFloat('#,##0.00',atotal),12,' ',false) else str1:=str1+' '+' '+FixLenStr(FormatFloat('#,##0.00',atotal),12,' ',false); if ratotal<>0 then str1:=str1+'(税'+FixLenStr(FormatFloat('#,##0.00',ratotal),8,' ',false)+')' else str1:=str1+' '; str2:=FixLenStr('应付合计',20)+' '+FixLenStr(FormatFloat('#,##0.00',prmb),12,' ',false); if rprmb<>0 then str2:=str2+'(税'+FixLenStr(FormatFloat('#,##0.00',rprmb),8,' ',false)+')'+' '+FixLenStr(FormatFloat('#,##0.00',pusd),12,' ',false) else str2:=str2+' '+' '+FixLenStr(FormatFloat('#,##0.00',pusd),12,' ',false); if rpusd<>0 then str2:=str2+'(税'+FixLenStr(FormatFloat('#,##0.00',rpusd),8,' ',false)+')'+' '+FixLenStr(FormatFloat('#,##0.00',pot),12,' ',false) else str2:=str2+' '+' '+FixLenStr(FormatFloat('#,##0.00',pot),12,' ',false); if rpot<>0 then str2:=str2+'(税'+FixLenStr(FormatFloat('#,##0.00',rpot),8,' ',false)+')'+' '+FixLenStr(FormatFloat('#,##0.00',ptotal),12,' ',false) else str2:=str2+' '+' '+FixLenStr(FormatFloat('#,##0.00',ptotal),12,' ',false); if rptotal<>0 then str2:=str2+'(税'+FixLenStr(FormatFloat('#,##0.00',rptotal),8,' ',false)+')' else str2:=str2+' '; memo1.Lines.Add(str1+'|'+str2); str1:=FixLenStr('-',120,'-'); str2:=FixLenStr('-',120,'-'); memo1.Lines.Add(str1+'|'+str2); str1:=FixLenStr('利润合计:',20)+' '+FixLenStr('人民币利润:',12,' ',false) +' '+FixLenStr(FormatFloat('#,##0.00',armb-prmb),12,' ',false) +' '+FixLenStr('美元利润:',12,' ',false)+' '+FixLenStr(FormatFloat('#,##0.00',ausd-pusd),12,' ',false)+FixLenStr('',48); str2:=FixLenStr('',19)+' '+FixLenStr('其他币别利润:',13,' ',false)+' '+FixLenStr(FormatFloat('#,##0.00',aot-pot),12,' ',false) +' '+FixLenStr('合计利润:',12,' ',false)+' '+FixLenStr(FormatFloat('#,##0.00',atotal-ptotal),12,' ',false); memo1.Lines.Add(str1+'|'+str2); finally freeandnil(aQuery1); freeandnil(aQuery2); end; if memo1.Lines.Count>0 then begin str1:=FixLenStr('应收客户',20)+' '+FixLenStr('应收人民币 ',24,' ',false)+' '+FixLenStr('应收美元 ',24,' ',false)+' '+FixLenStr('应收其他 ',24,' ',false)+' '+FixLenStr('应收合计 ',24,' ',false); str2:=FixLenStr('应付客户',20)+' '+FixLenStr('应付人民币 ',24,' ',false)+' '+FixLenStr('应付美元 ',24,' ',false)+' '+FixLenStr('应付其他 ',24,' ',false)+' '+FixLenStr('应付合计 ',24,' ',false); Memo1.Lines.Insert(0,str1+'|'+str2); end; end; procedure Tfra_fee_check.DBEdit60Change(Sender: TObject); begin getsumstr; end; procedure Tfra_fee_check.t_op_gainAfterOpen(DataSet: TDataSet); begin getsumstr; end; procedure Tfra_fee_check.N2Click(Sender: TObject); begin fee_invoicecr_view(t_ch_pay); end; procedure Tfra_fee_check.bsSkinCheckRadioBox1Click(Sender: TObject); begin if (bsSkinCheckRadioBox1.Checked) then begin wwDBGrid1.SelectAll; end else begin wwDBGrid1.SelectedList.Clear; wwDBGrid1.Refresh; end; end; procedure Tfra_fee_check.bsSkinCheckRadioBox2Click(Sender: TObject); begin if (bsSkinCheckRadioBox2.Checked) then begin wwDBGrid2.SelectAll; end else begin wwDBGrid2.SelectedList.Clear; wwDBGrid2.Refresh; end; end; end.