unit u_ch_balance_truck_pay; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, dxExEdtr, XPMenu, Menus, DB, ADODB, dxDBTLCl, dxGrClms, dxDBCtrl, dxDBGrid, StdCtrls, DBCtrls, bsSkinCtrls, bsdbctrls, dxTL, dxCntner, wwdbdatetimepicker, RxLookup, Mask, wwdbedit, Wwdotdot, Wwdbcomb; type Tfrm_ch_balance_truck_pay = class(TForm) bsSkinPanel2: TbsSkinPanel; bsSkinButton1: TbsSkinButton; bsSkinButton2: TbsSkinButton; bsSkinButton4: TbsSkinButton; bsSkinButton3: TbsSkinButton; bsSkinButton5: TbsSkinButton; bsSkinButton8: TbsSkinButton; bsSkinButton9: TbsSkinButton; bsSkinButton11: TbsSkinButton; bsSkinButton6: TbsSkinButton; bsSkinNotebook1: TbsSkinNotebook; bsSkinPanel6: TbsSkinPanel; Label21: TLabel; Label65: TLabel; Label22: TLabel; Label23: TLabel; Label24: TLabel; Label26: TLabel; Label28: TLabel; Label29: TLabel; Label30: TLabel; Label31: TLabel; Label32: TLabel; Label33: TLabel; Label34: TLabel; Label35: TLabel; Label36: TLabel; Label2: TLabel; bsSkinButton10: TbsSkinButton; Edit2: TEdit; Edit21: TEdit; Edit4: TEdit; wwDBComboBox2: TwwDBComboBox; RxDBLookupCombo5: TRxDBLookupCombo; Edit3: TEdit; wwDBDateTimePicker1: TwwDBDateTimePicker; wwDBDateTimePicker2: TwwDBDateTimePicker; wwDBDateTimePicker3: TwwDBDateTimePicker; wwDBDateTimePicker4: TwwDBDateTimePicker; RxDBLookupCombo7: TRxDBLookupCombo; RxDBLookupCombo8: TRxDBLookupCombo; Edit7: TEdit; Edit8: TEdit; Edit9: TEdit; bsSkinButton12: TbsSkinButton; wwDBDateTimePicker9: TwwDBDateTimePicker; dxDBGrid4: TdxDBGrid; dxDBGrid4Column1: TdxDBGridColumn; dxDBGrid4Column2: TdxDBGridColumn; dxDBGrid4Column3: TdxDBGridColumn; dxDBGrid4Column4: TdxDBGridColumn; dxDBGrid4Column6: TdxDBGridColumn; dxDBGrid4Column7: TdxDBGridColumn; dxDBGrid4Column8: TdxDBGridColumn; dxDBGrid4Column9: TdxDBGridColumn; dxDBGrid4Column10: TdxDBGridColumn; dxDBGrid4Column11: TdxDBGridColumn; dxDBGrid4Column12: TdxDBGridColumn; dxDBGrid4Column13: TdxDBGridColumn; dxDBGrid4Column14: TdxDBGridColumn; bsSkinPanel1: TbsSkinPanel; bsSkinPanel3: TbsSkinPanel; Label25: TLabel; Label17: TLabel; Label12: TLabel; Label1: TLabel; Label3: TLabel; Label4: TLabel; Label5: TLabel; Label6: TLabel; Label7: TLabel; Label8: TLabel; Label9: TLabel; Label10: TLabel; DBEdit14: TDBEdit; DBEdit1: TDBEdit; RxDBLookupCombo1: TRxDBLookupCombo; bsSkinDBCheckRadioBox1: TbsSkinDBCheckRadioBox; DBEdit4: TDBEdit; DBEdit5: TDBEdit; DBEdit6: TDBEdit; DBEdit8: TDBEdit; DBEdit9: TDBEdit; DBEdit10: TDBEdit; DBMemo1: TDBMemo; wwDBComboBox1: TwwDBComboBox; RxDBLookupCombo3: TRxDBLookupCombo; dxDBGrid1: TdxDBGrid; dxDBGrid1Column1: TdxDBGridColumn; dxDBGrid1Column2: TdxDBGridColumn; dxDBGrid1Column3: TdxDBGridColumn; dxDBGrid1Column4: TdxDBGridColumn; dxDBGrid1Column5: TdxDBGridColumn; dxDBGrid1Column7: TdxDBGridColumn; dxDBGrid1Column8: TdxDBGridColumn; dxDBGrid1Column9: TdxDBGridColumn; dxDBGrid1Column10: TdxDBGridColumn; dxDBGrid1Column11: TdxDBGridColumn; dxDBGrid1Column12: TdxDBGridColumn; bsSkinPanel4: TbsSkinPanel; Label11: TLabel; Label13: TLabel; Label14: TLabel; Label15: TLabel; Label16: TLabel; Label18: TLabel; Label19: TLabel; Label20: TLabel; Edit1: TEdit; Edit5: TEdit; Edit6: TEdit; wwDBDateTimePicker5: TwwDBDateTimePicker; wwDBDateTimePicker6: TwwDBDateTimePicker; wwDBDateTimePicker7: TwwDBDateTimePicker; wwDBDateTimePicker8: TwwDBDateTimePicker; RxDBLookupCombo4: TRxDBLookupCombo; bsSkinButton7: TbsSkinButton; bsSkinButton13: TbsSkinButton; bsSkinPanel5: TbsSkinPanel; dxDBGrid2: TdxDBGrid; dxDBGrid2Column1: TdxDBGridColumn; dxDBGrid2Column2: TdxDBGridColumn; dxDBGrid2Column3: TdxDBGridColumn; dxDBGrid2Column4: TdxDBGridColumn; dxDBGrid3: TdxDBGrid; dxDBGrid3Column1: TdxDBGridMaskColumn; dxDBGrid3Column2: TdxDBGridMaskColumn; dxDBGrid3Column3: TdxDBGridMaskColumn; dxDBGrid3Column4: TdxDBGridMaskColumn; dxDBGrid3Column5: TdxDBGridMaskColumn; dxDBGrid3Column6: TdxDBGridMaskColumn; dxDBGrid3Column7: TdxDBGridDateColumn; dxDBGrid3Column8: TdxDBGridDateColumn; dxDBGrid3Column9: TdxDBGridMaskColumn; dxDBGrid3Column10: TdxDBGridMaskColumn; dxDBGrid3Column11: TdxDBGridMaskColumn; dxDBGrid3Column12: TdxDBGridMaskColumn; dxDBGrid3Column13: TdxDBGridMaskColumn; dxDBGrid3Column14: TdxDBGridMaskColumn; dxDBGrid3Column15: TdxDBGridMaskColumn; t_ch_balance: TADOQuery; t_ch_balance1: TDataSource; t_ch_fee_do: TADOQuery; t_bill: TADOQuery; t_bill1: TDataSource; t_ch_fee: TADOQuery; t_ch_fee1: TDataSource; t_ch_balance_fee: TADOQuery; t_ch_balance_fee1: TDataSource; PopupMenu1: TPopupMenu; N1: TMenuItem; PopupMenu2: TPopupMenu; MenuItem1: TMenuItem; PopupMenu3: TPopupMenu; MenuItem2: TMenuItem; XPMenu1: TXPMenu; procedure FormShow(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure bsSkinButton9Click(Sender: TObject); procedure bsSkinButton1Click(Sender: TObject); procedure bsSkinButton2Click(Sender: TObject); procedure bsSkinButton3Click(Sender: TObject); procedure bsSkinButton11Click(Sender: TObject); procedure bsSkinButton6Click(Sender: TObject); procedure bsSkinButton8Click(Sender: TObject); procedure bsSkinButton5Click(Sender: TObject); procedure bsSkinButton12Click(Sender: TObject); procedure bsSkinButton10Click(Sender: TObject); procedure bsSkinButton4Click(Sender: TObject); procedure RxDBLookupCombo1Enter(Sender: TObject); procedure bsSkinButton7Click(Sender: TObject); procedure bsSkinButton13Click(Sender: TObject); procedure MenuItem1Click(Sender: TObject); procedure N1Click(Sender: TObject); procedure MenuItem2Click(Sender: TObject); procedure bsSkinPanel2Resize(Sender: TObject); procedure t_ch_balanceAfterDelete(DataSet: TDataSet); procedure t_ch_balanceAfterInsert(DataSet: TDataSet); procedure t_ch_balanceBeforeEdit(DataSet: TDataSet); procedure t_ch_balanceBeforePost(DataSet: TDataSet); private { Private declarations } public { Public declarations } end; var frm_ch_balance_truck_pay: Tfrm_ch_balance_truck_pay; implementation uses u_main, my_sys_function; {$R *.dfm} procedure Tfrm_ch_balance_truck_pay.FormShow(Sender: TObject); begin t_ch_balance.Close; t_ch_balance.SQL.clear; t_ch_balance.SQL.Add('select * from t_ch_balance_truck where 帐单状态<>'+''''+'审核通过'+'''' +' and 类型='+''''+'付'+'''' +' order by 帐单编号 desc'); t_ch_balance.open; t_ch_fee_do.open; t_ch_balance_fee.open; loadreggrid(dxdbgrid4,false,caption); end; procedure Tfrm_ch_balance_truck_pay.FormClose(Sender: TObject; var Action: TCloseAction); begin savereggrid(dxdbgrid4,caption); frm_ch_balance_truck_pay.Hide; frm_ch_balance_truck_pay.ManualFloat(frm_ch_balance_truck_pay.BoundsRect ); frm_main.freeTabs('frm_ch_balance_truck_pay'); action:=cafree; frm_ch_balance_truck_pay:=nil; end; procedure Tfrm_ch_balance_truck_pay.bsSkinButton9Click(Sender: TObject); begin sys_print('派车应付结算',2,t_ch_balance1,nil,nil,nil, t_ch_balance_fee1,nil,nil,nil,nil,nil,nil); end; procedure Tfrm_ch_balance_truck_pay.bsSkinButton1Click(Sender: TObject); begin t_ch_balance.insert; bsSkinNotebook1.PageIndex:=1; bsSkinButton11.Caption:='返回列表'; end; procedure Tfrm_ch_balance_truck_pay.bsSkinButton2Click(Sender: TObject); begin table_post(t_ch_balance); end; procedure Tfrm_ch_balance_truck_pay.bsSkinButton3Click(Sender: TObject); begin table_cancel(t_ch_balance); end; procedure Tfrm_ch_balance_truck_pay.bsSkinButton11Click(Sender: TObject); var answer:TModalResult; begin if bsSkinButton11.Caption='编辑修改' then begin if t_ch_balance.IsEmpty then exit; bsSkinNotebook1.PageIndex:=1; bsSkinButton11.Caption:='返回列表'; end else begin if (t_ch_balance.State=dsinsert)or(t_ch_balance.State=dsedit) then BEGIN answer:=messagedlg( '数据已经修改,是否保存?',mtWarning,mbYesNoCancel,0); if answer=mrYes then begin t_ch_balance.post; end; if answer=mrNo then begin t_ch_balance.cancel; end; if answer=mrCancel then begin exit; end; END; bsSkinNotebook1.PageIndex:=0; bsSkinButton11.Caption:='编辑修改'; end; end; procedure Tfrm_ch_balance_truck_pay.bsSkinButton6Click(Sender: TObject); begin if t_ch_balance.IsEmpty then exit; if t_ch_balance.FieldByName('帐单状态').asstring='审核通过'then begin showmessage('帐单已经审核!!'); end else begin try modify_all:=true; t_ch_balance.edit; t_ch_balance['帐单状态']:='审核通过'; t_ch_balance['审核人']:=employee; t_ch_balance['审核日期']:=now; t_ch_balance.post; modify_all:=false; except modify_all:=false; showmessage('审核失败!!'); end; t_ch_balance.Refresh; end; end; procedure Tfrm_ch_balance_truck_pay.bsSkinButton8Click(Sender: TObject); begin if t_ch_balance.IsEmpty then exit; if t_ch_balance.FieldByName('帐单状态').asstring='录入状态'then begin showmessage('帐单没有必要取消审核!!'); end else begin try modify_all:=true; t_ch_balance.edit; t_ch_balance['帐单状态']:='录入状态'; t_ch_balance['审核人']:=''; t_ch_balance['审核日期']:=null; t_ch_balance.post; modify_all:=false; except modify_all:=false; showmessage('审核失败!!'); end; t_ch_balance.Refresh; end; end; procedure Tfrm_ch_balance_truck_pay.bsSkinButton5Click(Sender: TObject); begin close; end; procedure Tfrm_ch_balance_truck_pay.bsSkinButton12Click(Sender: TObject); begin Edit2.text:=''; Edit21.text:=''; Edit4.text:=''; wwDBComboBox2.text:=''; RxDBLookupCombo5.ClearValue; Edit3.text:=''; RxDBLookupCombo8.ClearValue; RxDBLookupCombo7.ClearValue; wwDBDateTimePicker1.text:=''; wwDBDateTimePicker2.text:=''; wwDBDateTimePicker3.text:=''; wwDBDateTimePicker4.text:=''; Edit7.text:=''; Edit8.text:=''; Edit9.text:=''; wwDBDateTimePicker9.text:=''; end; procedure Tfrm_ch_balance_truck_pay.bsSkinButton10Click(Sender: TObject); var str,str_bill:widestring; begin str:='where 类型='+''''+'付'+''''; if (Edit2.text<>'')and(Edit21.text<>'')then begin str:=str+' and 帐单编号 between '+''''+Edit2.text+''''+' and '+''''+Edit21.text+''''; end else begin if Edit2.text<>''then str:=str+' and 结算单号 like '+''''+Edit2.text+''''; if Edit21.text<>''then str:=str+' and 结算单号 like '+''''+Edit21.text+''''; end; if Edit4.text<>''then str:=str+' and 凭证号码 like '+''''+Edit4.text+''''; if wwDBComboBox2.text<>''then str:=str+' and 帐单状态='+''''+wwDBComboBox2.text+''''; if RxDBLookupCombo5.DisplayValue<>''then str:=str+' and 客户名称='+''''+RxDBLookupCombo5.DisplayValues[1]+''''; if Edit3.text<>''then begin try strtoint(Edit3.text); except showmessage('结算金额只能为数字!!'); exit; end; str:=str+' and 结算金额='+Edit3.text; end; if RxDBLookupCombo8.DisplayValue<>''then str:=str+' and 审核人='+''''+RxDBLookupCombo8.DisplayValues[0]+''''; if RxDBLookupCombo7.DisplayValue<>''then str:=str+' and 结算人='+''''+RxDBLookupCombo7.DisplayValues[0]+''''; if wwDBDateTimePicker1.text<>''then str:=str+' and 结算日期>='+''''+wwDBDateTimePicker1.text+''''; if wwDBDateTimePicker2.text<>''then str:=str+' and 结算日期<='+''''+wwDBDateTimePicker2.text+''''; if wwDBDateTimePicker3.text<>''then str:=str+' and 审核日期>='+''''+wwDBDateTimePicker3.text+''''; if wwDBDateTimePicker4.text<>''then str:=str+' and 审核日期<='+''''+wwDBDateTimePicker4.text+''''; if Edit7.text<>''then str_bill:='where 业务编号 like '+''''+Edit7.text+''''; if Edit8.text<>''then begin if str_bill=''then str_bill:='where 主提单号 like '+''''+Edit8.text+'''' else str_bill:=str_bill+' and 主提单号 like '+''''+Edit8.text+''''; end; if Edit9.text<>''then begin if str_bill=''then str_bill:='where 委托编号 like '+''''+Edit9.text+'''' else str_bill:=str_bill+' and 委托编号 like '+''''+Edit9.text+''''; end; if wwDBDateTimePicker9.text<>''then begin if str_bill=''then str_bill:='where 船期='+''''+wwDBDateTimePicker9.text+'''' else str_bill:=str_bill+' and 船期='+''''+wwDBDateTimePicker9.text+''''; end; if str_bill<>''then str:=str+' and 帐单编号 in (select distinct 工作编号 from v_fee_do_truck_pay ' +str_bill+')'; t_ch_balance.close; t_ch_balance.sql.clear; t_ch_balance.sql.add('select * from t_ch_balance_truck '+str+' order by 帐单编号'); t_ch_balance.open; end; procedure Tfrm_ch_balance_truck_pay.bsSkinButton4Click(Sender: TObject); begin if t_ch_balance.IsEmpty then exit; if (t_ch_balance.FieldByName('帐单状态').asstring='审核通过')then begin showmessage('当前业务操作的状态不允许删除!!'); exit; end; if application.MessageBox('您确定要删除数据吗?','警告:',MB_OKCANCEL)=IDOK then begin t_ch_fee_do.requery; while not t_ch_fee_do.eof do t_ch_fee_do.delete; t_ch_balance.Delete; t_ch_balance_fee.requery; if t_bill.active then t_bill.requery; end; end; procedure Tfrm_ch_balance_truck_pay.RxDBLookupCombo1Enter(Sender: TObject); begin if t_ch_balance_fee.IsEmpty then begin RxDBLookupCombo1.ReadOnly:=false; end else begin RxDBLookupCombo1.ReadOnly:=true; end; end; procedure Tfrm_ch_balance_truck_pay.bsSkinButton7Click(Sender: TObject); var str,str_fee:widestring; begin str_fee:='where 费用状态 in ('+''''+'审核通过'+''''+','+''''+'禁止修改'+''''+')' +' and isnull(付费金额,0)<>isnull(付费结算,0)'; if RxDBLookupCombo4.DisplayValue<>''then str_fee:=str_fee+' and 付费客户='+''''+RxDBLookupCombo4.DisplayValues[1]+''''; str:='where 编号 in (select 编号 from t_ch_fee_truck '+str_fee+')'; if Edit1.text<>''then str:=str+' and 委托编号 like '+''''+Edit1.text+''''; if Edit5.text<>''then str:=str+' and 主提单号 like '+''''+Edit5.text+''''; if Edit6.text<>''then str:=str+' and 分提单号 like '+''''+Edit6.text+''''; if wwDBDateTimePicker5.text<>''then str:=str+' and 船期>='+''''+wwDBDateTimePicker5.text+''''; if wwDBDateTimePicker7.text<>''then str:=str+' and 船期<='+''''+wwDBDateTimePicker7.text+''''; if wwDBDateTimePicker6.text<>''then str:=str+' and 会计期间>='+''''+wwDBDateTimePicker6.text+''''; if wwDBDateTimePicker8.text<>''then str:=str+' and 会计期间<='+''''+wwDBDateTimePicker8.text+''''; t_ch_fee.close; t_bill.close; t_bill.sql.clear; t_bill.sql.add('select * from v_sea '+str+' order by 业务编号'); t_bill.open; t_ch_fee.sql.Clear; t_ch_fee.sql.add('select *,(isnull(付费金额,0)-isnull(付费结算,0)) as 未结金额 from t_ch_fee_truck ' +str_fee+' and 编号=:编号 order by TF_ID'); t_ch_fee.open; end; procedure Tfrm_ch_balance_truck_pay.bsSkinButton13Click(Sender: TObject); begin RxDBLookupCombo1.ClearValue; Edit1.text:=''; Edit5.Text:=''; Edit6.text:=''; wwDBDateTimePicker5.Clear; wwDBDateTimePicker6.clear; wwDBDateTimePicker7.clear; wwDBDateTimePicker8.clear; end; procedure Tfrm_ch_balance_truck_pay.MenuItem1Click(Sender: TObject); var do_num:real; i:integer; jia_num:real; begin if (t_ch_balance.FieldByName('帐单状态').asstring='审核通过')then begin showmessage('当前业务操作的状态不允许更改'); exit; end; if t_ch_fee.IsEmpty then exit; if (t_ch_balance.State=dsinsert)or(t_ch_balance.State=dsedit)then begin if t_ch_balance.FieldByName('客户名称').asstring=''then t_ch_balance['客户名称']:=t_ch_fee['付费客户']; t_ch_balance.post; end; if not t_ch_balance.FieldByName('自动').asboolean then begin do_num:=t_ch_balance.FieldByName('虚结金额').asfloat; if do_num=0 then exit; end; jia_num:=0; if dxDBGrid2.SelectedCount>=1 then begin for i:=0 to dxDBGrid2.SelectedCount-1 do begin t_ch_fee.GotoBookmark(pointer(dxDBGrid2.selectedrows[i])); if t_ch_balance.FieldByName('客户名称').asstring=t_ch_fee.FieldByName('付费客户').asstring then begin if t_ch_balance.FieldByName('自动').asboolean then begin t_ch_fee_do.Insert; t_ch_fee_do['币别']:='RMB'; t_ch_fee_do['工作编号']:=t_ch_balance.fieldbyname('帐单编号').asstring; t_ch_fee_do['原始金额']:=t_ch_fee.fieldbyname('未结金额').asfloat; t_ch_fee_do['金额']:=t_ch_fee.fieldbyname('未结金额').asfloat; t_ch_fee_do['CH_ID']:=t_ch_fee.fieldbyname('TF_ID').asinteger; t_ch_fee_do['类型']:='2'; t_ch_fee_do['业务编号']:=t_ch_fee.fieldbyname('编号').asstring; t_ch_fee_do.post; jia_num:=jia_num+t_ch_fee.fieldbyname('未结金额').asfloat; end else begin t_ch_fee_do.Insert; t_ch_fee_do['币别']:='RMB'; t_ch_fee_do['工作编号']:=t_ch_balance.fieldbyname('帐单编号').asstring; if do_num<>0 then begin if t_ch_fee.fieldbyname('未结金额').asfloat<0 then begin if t_ch_fee.fieldbyname('未结金额').asfloat>do_num then begin t_ch_fee_do['原始金额']:=t_ch_fee.fieldbyname('未结金额').asfloat; t_ch_fee_do['金额']:=t_ch_fee.fieldbyname('未结金额').asfloat; jia_num:=jia_num+t_ch_fee.fieldbyname('未结金额').asfloat; do_num:=do_num-t_ch_fee.fieldbyname('未结金额').asfloat; end else begin t_ch_fee_do['原始金额']:=do_num; t_ch_fee_do['金额']:=do_num; jia_num:=jia_num+do_num; do_num:=0; end; end else begin if t_ch_fee.fieldbyname('未结金额').asfloat0 then begin t_ch_balance.edit; if t_ch_balance.FieldByName('自动').asboolean then begin t_ch_balance['实结金额']:=t_ch_balance['实结金额']+jia_num; t_ch_balance['结算金额']:=t_ch_balance['实结金额']; end else begin t_ch_balance['实结金额']:=t_ch_balance['实结金额']+jia_num; end; t_ch_balance.post; end; t_ch_fee.requery; t_ch_balance_fee.requery; end; procedure Tfrm_ch_balance_truck_pay.N1Click(Sender: TObject); var do_num:real; i:integer; jia_num:real; begin if (t_ch_balance.FieldByName('帐单状态').asstring='审核通过')then begin showmessage('当前业务操作的状态不允许更改'); exit; end; if t_ch_fee.IsEmpty then exit; if (t_ch_balance.State=dsinsert)or(t_ch_balance.State=dsedit)then begin if t_ch_balance.FieldByName('客户名称').asstring=''then t_ch_balance['客户名称']:=t_ch_fee['付费客户']; t_ch_balance.post; end; if not t_ch_balance.FieldByName('自动').asboolean then begin do_num:=t_ch_balance.FieldByName('虚结金额').asfloat; if do_num=0 then exit; end; jia_num:=0; if dxDBGrid3.SelectedCount>=1 then begin for i:=0 to dxDBGrid3.SelectedCount-1 do begin t_bill.GotoBookmark(pointer(dxDBGrid3.selectedrows[i])); t_ch_fee.first; while not t_ch_fee.eof do begin if t_ch_balance.FieldByName('客户名称').asstring=t_ch_fee.FieldByName('付费客户').asstring then begin if t_ch_balance.FieldByName('自动').asboolean then begin t_ch_fee_do.Insert; t_ch_fee_do['币别']:='RMB'; t_ch_fee_do['工作编号']:=t_ch_balance.fieldbyname('帐单编号').asstring; t_ch_fee_do['原始金额']:=t_ch_fee.fieldbyname('未结金额').asfloat; t_ch_fee_do['金额']:=t_ch_fee.fieldbyname('未结金额').asfloat; t_ch_fee_do['CH_ID']:=t_ch_fee.fieldbyname('TF_ID').asinteger; t_ch_fee_do['类型']:='2'; t_ch_fee_do['业务编号']:=t_ch_fee.fieldbyname('编号').asstring; t_ch_fee_do.post; jia_num:=jia_num+t_ch_fee.fieldbyname('未结金额').asfloat; end else begin t_ch_fee_do.Insert; t_ch_fee_do['币别']:='RMB'; t_ch_fee_do['工作编号']:=t_ch_balance.fieldbyname('帐单编号').asstring; if do_num<>0 then begin if t_ch_fee.fieldbyname('未结金额').asfloat<0 then begin if t_ch_fee.fieldbyname('未结金额').asfloat>do_num then begin t_ch_fee_do['原始金额']:=t_ch_fee.fieldbyname('未结金额').asfloat; t_ch_fee_do['金额']:=t_ch_fee.fieldbyname('未结金额').asfloat; jia_num:=jia_num+t_ch_fee.fieldbyname('未结金额').asfloat; do_num:=do_num-t_ch_fee.fieldbyname('未结金额').asfloat; end else begin t_ch_fee_do['原始金额']:=do_num; t_ch_fee_do['金额']:=do_num; jia_num:=jia_num+do_num; do_num:=0; end; end else begin if t_ch_fee.fieldbyname('未结金额').asfloat0 then begin t_ch_balance.edit; if t_ch_balance.FieldByName('自动').asboolean then begin t_ch_balance['实结金额']:=t_ch_balance['实结金额']+jia_num; t_ch_balance['结算金额']:=t_ch_balance['实结金额']; end else begin t_ch_balance['实结金额']:=t_ch_balance['实结金额']+jia_num; end; t_ch_balance.post; end; t_bill.Requery(); t_ch_balance_fee.Requery(); end; procedure Tfrm_ch_balance_truck_pay.MenuItem2Click(Sender: TObject); var i:integer; delete_num:real; begin if (t_ch_balance.FieldByName('帐单状态').asstring='审核通过')then begin showmessage('当前业务操作的状态不允许更改'); exit; end; if t_ch_balance_fee.IsEmpty then exit; delete_num:=0; if dxDBGrid1.SelectedCount>=1 then begin for i:=0 to dxDBGrid1.SelectedCount-1 do begin t_ch_balance_fee.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); if t_ch_fee_do.Locate('CH_ID',t_ch_balance_fee.fieldbyname('TF_ID').asinteger,[])then begin t_ch_fee_do.delete; delete_num:=delete_num+t_ch_balance_fee.fieldbyname('金额').asfloat; end; end end; if delete_num<>0 then begin t_ch_balance.edit; if t_ch_balance.FieldByName('自动').asboolean then begin t_ch_balance['实结金额']:=t_ch_balance['实结金额']-delete_num; t_ch_balance['结算金额']:=t_ch_balance['实结金额']; end else begin t_ch_balance['实结金额']:=t_ch_balance['实结金额']-delete_num; end; t_ch_balance.post; end; t_ch_balance_fee.requery; if t_ch_fee.Active then t_ch_fee.Requery(); end; procedure Tfrm_ch_balance_truck_pay.bsSkinPanel2Resize(Sender: TObject); var i:integer; begin i:=round(bsSkinPanel2.Width/9); bsSkinButton9.Width:=i; bsSkinButton1.Width:=i; bsSkinButton2.Width:=i; bsSkinButton4.Width:=i; bsSkinButton3.Width:=i; bsSkinButton11.Width:=i; bsSkinButton6.Width:=i; bsSkinButton8.Width:=i; end; procedure Tfrm_ch_balance_truck_pay.t_ch_balanceAfterDelete( DataSet: TDataSet); begin if t_bill.Active then t_bill.Requery(); end; procedure Tfrm_ch_balance_truck_pay.t_ch_balanceAfterInsert( DataSet: TDataSet); begin t_ch_balance['帐单状态']:='录入状态'; t_ch_balance['结算人']:=employee; t_ch_balance['结算日期']:=now; t_ch_balance['自动']:=1; t_ch_balance['结算金额']:=0; t_ch_balance['实结金额']:=0; t_ch_balance['虚结金额']:=0; t_ch_balance['类型']:='付'; end; procedure Tfrm_ch_balance_truck_pay.t_ch_balanceBeforeEdit( DataSet: TDataSet); begin if not modify_all then begin if (t_ch_balance.FieldByName('帐单状态').asstring='审核通过')then begin showmessage('当前业务操作的状态不允许更改'); abort; end; end; end; procedure Tfrm_ch_balance_truck_pay.t_ch_balanceBeforePost( DataSet: TDataSet); begin table_before_post(t_ch_balance,'客户名称'); if t_ch_balance.FieldByName('自动').asboolean then begin t_ch_balance['结算金额']:=t_ch_balance['实结金额']; end; if t_ch_balance.state=dsinsert then t_ch_balance['帐单编号']:=get_no(date,'TP'); t_ch_balance['帐单状态']:=t_ch_balance['帐单状态']; t_ch_balance['虚结金额']:=t_ch_balance['结算金额']-t_ch_balance['实结金额']; end; end.