unit u_op_fee; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, bsSkinCtrls, dxExEdtr, dxCntner, dxTL, dxDBCtrl, dxDBGrid, DB, ADODB, dxDBTLCl, dxGrClms, ExtCtrls, RxLookup, StdCtrls,DateUtils, wwdbdatetimepicker, Mask, wwdbedit, Wwdotdot, Wwdbcomb, DBCtrls, wwdblook, Menus, DBCtrlsEh, DBLookupEh, dxGrClEx, ComCtrls, bsSkinBoxCtrls; type Tfrm_op_fee = class(TForm) bsSkinPanel1: TbsSkinPanel; dxDBGrid1: TdxDBGrid; t_op_fee: TADOQuery; t_op_fee1: TDataSource; dxDBGrid1Column1: TdxDBGridMaskColumn; dxDBGrid1Column2: TdxDBGridMaskColumn; dxDBGrid1Column3: TdxDBGridDateColumn; dxDBGrid1Column4: TdxDBGridMaskColumn; dxDBGrid1Column5: TdxDBGridMaskColumn; dxDBGrid1Column7: TdxDBGridMaskColumn; dxDBGrid1Column8: TdxDBGridDateColumn; Panel1: TPanel; bsSkinButton1: TbsSkinButton; bsSkinButton2: TbsSkinButton; bsSkinButton4: TbsSkinButton; bsSkinButton3: TbsSkinButton; Label9: TLabel; RxDBLookupCombo2: TRxDBLookupCombo; Label23: TLabel; RxDBLookupCombo7: TRxDBLookupCombo; Label1: TLabel; Label2: TLabel; wwDBDateTimePicker1: TwwDBDateTimePicker; wwDBComboBox1: TwwDBComboBox; Label3: TLabel; wwDBComboBox2: TwwDBComboBox; Label4: TLabel; DBEdit1: TDBEdit; DBMemo1: TDBMemo; Label5: TLabel; dxDBGrid1Column6: TdxDBGridColumn; Label6: TLabel; RxDBLookupCombo9: TRxDBLookupCombo; dxDBGrid1Column9: TdxDBGridColumn; Label91: TLabel; wwDBComboBox4: TwwDBComboBox; Label95: TLabel; RxDBLookupCombo15: TRxDBLookupCombo; dxDBGrid1Column10: TdxDBGridColumn; dxDBGrid1Column11: TdxDBGridColumn; dxDBGrid1Column12: TdxDBGridColumn; bsSkinButton6: TbsSkinButton; bsSkinButton7: TbsSkinButton; bsSkinButton5: TbsSkinButton; DBEdit2: TDBEdit; Label11: TLabel; Label12: TLabel; DBEdit3: TDBEdit; dxDBGrid1Column14: TdxDBGridColumn; dxDBGrid1Column16: TdxDBGridColumn; dxDBGrid1Column15: TdxDBGridColumn; dxDBGrid1Column17: TdxDBGridColumn; dxDBGrid1Column18: TdxDBGridColumn; PopupMenu2: TPopupMenu; N10: TMenuItem; N11: TMenuItem; N14: TMenuItem; N13: TMenuItem; N12: TMenuItem; N15: TMenuItem; N16: TMenuItem; N1: TMenuItem; N3: TMenuItem; N2: TMenuItem; N4: TMenuItem; bsSkinButton9: TbsSkinButton; ADOQuery_bc: TADOQuery; ADOQuery_cost: TADOQuery; Label13: TLabel; ADOQuery_bc1: TDataSource; ADOQuery_cost1: TDataSource; Label14: TLabel; RxDBLookupCombo1: TRxDBLookupCombo; RxDBLookupCombo3: TRxDBLookupCombo; dxDBGrid1Column19: TdxDBGridColumn; dxDBGrid1Column20: TdxDBGridLookupColumn; Label15: TLabel; RxDBLookupCombo5: TRxDBLookupCombo; RxDBLookupCombo6: TRxDBLookupCombo; Label16: TLabel; dxDBGrid1Column21: TdxDBGridCheckColumn; Label36: TLabel; RxDBLookupCombo11: TRxDBLookupCombo; Label19: TLabel; DBEdit4: TDBEdit; dxDBGrid1Column22: TdxDBGridColumn; DBEdit5: TDBEdit; Label20: TLabel; bsSkinPanel10: TbsSkinPanel; Label49: TLabel; wwDBDateTimePicker9: TwwDBDateTimePicker; Label52: TLabel; wwDBDateTimePicker12: TwwDBDateTimePicker; Label7: TLabel; RxDBLookupCombo4: TRxDBLookupCombo; Label17: TLabel; RxDBLookupCombo8: TRxDBLookupCombo; Label18: TLabel; RxDBLookupCombo10: TRxDBLookupCombo; Label8: TLabel; wwDBComboBox31: TwwDBComboBox; Label10: TLabel; wwDBComboBox3: TwwDBComboBox; bsSkinButton8: TbsSkinButton; bsSkinButton10: TbsSkinButton; bsSkinButton11: TbsSkinButton; bsSkinPanel15: TbsSkinPanel; bsSkinButton54: TbsSkinButton; bsSkinButton53: TbsSkinButton; bsSkinDateEdit1: TbsSkinDateEdit; bsSkinLabel1: TbsSkinLabel; dxDBGrid1Column23: TdxDBGridColumn; procedure t_op_feeAfterInsert(DataSet: TDataSet); procedure bsSkinButton1Click(Sender: TObject); procedure bsSkinButton2Click(Sender: TObject); procedure bsSkinButton4Click(Sender: TObject); procedure bsSkinButton3Click(Sender: TObject); procedure bsSkinButton5Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure t_op_feeBeforePost(DataSet: TDataSet); procedure FormShow(Sender: TObject); procedure RxDBLookupCombo9Enter(Sender: TObject); procedure RxDBLookupCombo9Exit(Sender: TObject); procedure t_op_feeBeforeDelete(DataSet: TDataSet); procedure t_op_feeBeforeEdit(DataSet: TDataSet); procedure bsSkinButton8Click(Sender: TObject); procedure bsSkinButton6Click(Sender: TObject); procedure bsSkinButton7Click(Sender: TObject); procedure dxDBGrid1Column10CustomDraw(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 N10Click(Sender: TObject); procedure N14Click(Sender: TObject); procedure N12Click(Sender: TObject); procedure N16Click(Sender: TObject); procedure N3Click(Sender: TObject); procedure N4Click(Sender: TObject); procedure RxDBLookupCombo3Enter(Sender: TObject); procedure RxDBLookupCombo3Exit(Sender: TObject); procedure RxDBLookupCombo3Change(Sender: TObject); procedure RxDBLookupCombo5Enter(Sender: TObject); procedure RxDBLookupCombo5Exit(Sender: TObject); procedure RxDBLookupCombo5Change(Sender: TObject); procedure dxDBGrid1CustomDraw(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 bsSkinButton9Click(Sender: TObject); procedure bsSkinButton10Click(Sender: TObject); procedure bsSkinButton11Click(Sender: TObject); procedure bsSkinButton54Click(Sender: TObject); procedure bsSkinButton53Click(Sender: TObject); private { Private declarations } public { Public declarations } function GetBankAccid(fdataSet:TDataSet):String; function NewDrCrVou(fDataSet:TDataSet):String; function InsertVouItems(fDataSet:TDataSet):String; function GetVouNo:String; function EditFieldVlaueZeros(FieldVlaue:string;len:integer):String; function GetEmpID(EmplName:String):String; function GetDeptID(DeptName:String):String; end; var frm_op_fee: Tfrm_op_fee; implementation uses u_main, u_data_share, my_sys_function, dmAccu; {$R *.dfm} function Tfrm_op_fee.GetEmpID(EmplName:String):String; begin with dmAcc.tempQuery do try Close;SQL.Clear; SQL.Add('select 财务软件代码 from t_sys_employee where 姓名='''+EmplName+''''); Open; if not FieldByName('财务软件代码').IsNull then Result:=FieldByName('财务软件代码').AsString else Result:='0'; finally Close; end; end; function Tfrm_op_fee.GetDeptID(DeptName:String):String; var aQry:TAdoQuery; begin aQry:=CreateadoQuery; try aQry.Close; aQry.SQL.Clear; aQry.sql.add('select 财务软件代码 from t_sys_department where 部门名称='''+DeptName+''''); aQry.Open; result:=aQry.fieldByName('财务软件代码').asstring; finally FreeAndNil(aQry); end; end; function Tfrm_op_fee.EditFieldVlaueZeros(FieldVlaue:string;len:integer):String; begin Result:=''; while Length(FieldVlaue)<3 do FieldVlaue:='0'+FieldVlaue; Result:=FieldVlaue; end; function Tfrm_op_fee.GetVouNo:String; var i :integer; aQuery:TAdoQuery; begin aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add('select vouno from t_op_fee where OF_ID=(select max(OF_ID) from t_op_fee )'); Open; if IsEmpty then begin Close;SQL.Clear; SQL.Add('select vouno from t_op_fee where OF_ID=(select max(OF_ID) from t_op_fee )'); Open; end; try i:=strtoint(aQuery.fieldbyname('vouno').AsString); result:=inttostr(i+1); result:=EditFieldVlaueZeros(result,3); except ; end; end; finally FreeAndNil(aQuery); end; end; procedure Tfrm_op_fee.t_op_feeAfterInsert(DataSet: TDataSet); begin // t_op_fee['发生期间']:=DATE; t_op_fee['收付类别']:='付'; t_op_fee['费用状态']:='录入状态'; t_op_fee['金额']:=0; t_op_fee['币别']:='RMB'; t_op_fee['录入人']:=employee; t_op_fee['录入日期']:=date; t_op_fee['ITEMNO']:=1; t_op_fee['汇率']:=1; t_op_fee['备注']:=''; t_op_fee['相关人员']:=''; t_op_fee['ACCID_COST']:=''; t_op_fee['ACCID_COSTNAME']:=''; t_op_fee['单据类型']:='费用'; t_op_fee.fieldByName('VouNO').value:=GetVouNo; end; procedure Tfrm_op_fee.bsSkinButton1Click(Sender: TObject); begin t_op_fee.insert; end; procedure Tfrm_op_fee.bsSkinButton2Click(Sender: TObject); begin table_post(t_op_fee); end; procedure Tfrm_op_fee.bsSkinButton4Click(Sender: TObject); begin table_delete(t_op_fee); end; procedure Tfrm_op_fee.bsSkinButton3Click(Sender: TObject); begin table_cancel(t_op_fee); end; procedure Tfrm_op_fee.bsSkinButton5Click(Sender: TObject); begin close; end; procedure Tfrm_op_fee.FormClose(Sender: TObject; var Action: TCloseAction); begin ADOQuery_bc.Close; ADOQuery_cost.Close; savereggrid(dxdbgrid1,caption+'1'); frm_op_fee.Hide; frm_op_fee.ManualFloat(frm_op_fee.BoundsRect ); frm_main.freeTabs('frm_op_fee'); action:=cafree; frm_op_fee:=nil; end; procedure Tfrm_op_fee.t_op_feeBeforePost(DataSet: TDataSet); begin if not t_op_fee.FieldByName('发生期间').IsNull then begin t_op_fee.fieldByName('Accyear').value:=Yearof(t_op_fee.fieldByName('发生期间').value); t_op_fee.fieldByName('AccMonth').value:=Monthof(t_op_fee.fieldByName('发生期间').value); end; table_before_post(t_op_fee,'发生期间'); table_before_post(t_op_fee,'收付类别'); table_before_post(t_op_fee,'金额'); table_before_post(t_op_fee,'币别'); if trim(t_op_fee.fieldByName('结算方式').value)='支票' then if trim(t_op_fee.FieldByName('相关号码').asstring)='' then begin showmessage('结算方式为支票支票号不能为空,不能保存!'); abort; end; if 1=1 then // if StrToBool(get_parameters_value(83,'false')) then begin if frm_data_share.t_sys_bank.Locate('代码',RxDBLookupCombo15.Value,[]) then if Trim(t_op_fee.fieldbyname('币别').asstring)='RMB' THEN begin t_op_fee.fieldbyname('银行').asstring:=frm_data_share.t_sys_bank.fieldbyname('银行名称').asstring; t_op_fee.fieldbyname('美元银行').asstring:=''; end else begin t_op_fee.fieldbyname('银行').asstring:=''; t_op_fee.fieldbyname('美元银行').asstring:=frm_data_share.t_sys_bank.fieldbyname('银行名称').asstring; end; if Trim(t_op_fee.fieldbyname('币别').asstring)='RMB' THEN begin t_op_fee.fieldbyname('人民币金额').asFloat:=t_op_fee.fieldbyname('金额').asFloat; t_op_fee.fieldbyname('美元金额').asFloat:=0; end else begin t_op_fee.fieldbyname('人民币金额').asFloat:=0; t_op_fee.fieldbyname('美元金额').asFloat:=t_op_fee.fieldbyname('金额').asFloat; end; end; end; procedure Tfrm_op_fee.FormShow(Sender: TObject); begin bsSkinPanel15.Visible:=false; bsSkinDateEdit1.Date:=Date; loadreggrid(dxdbgrid1,true,caption+'1'); ADOQuery_bc.Open; ADOQuery_cost.Open; t_op_fee.close; t_op_fee.sql.clear; t_op_fee.sql.add('select top 100 * from t_op_fee where 单据类型=''借款'' and 财务=0 and 录入人='+''''+employee+''''+' order by of_id'); t_op_fee.open; wwDBDateTimePicker1.MinDate:=Logininfo.endday+1; RxDBLookupCombo11.value:=Employee; if not if_open('345') then begin bsSkinButton6.Enabled:=false; bsSkinButton7.Enabled:=false; end; end; procedure Tfrm_op_fee.RxDBLookupCombo9Enter(Sender: TObject); begin RxDBLookupCombo9.LookupDisplay:='代码;中文名'; end; procedure Tfrm_op_fee.RxDBLookupCombo9Exit(Sender: TObject); begin RxDBLookupCombo9.LookupDisplay:='中文名'; end; procedure Tfrm_op_fee.t_op_feeBeforeDelete(DataSet: TDataSet); var sdate:tdate; begin if t_op_fee.FieldByName('费用状态').AsString='审核通过' then begin showmessage('费用状态为审核状态,不能删除!'); abort; end; sdate:=EncodeDate(Logininfo.offyear,Logininfo.offmonth,1); if not t_op_fee.FieldByName('发生期间').IsNull then if sdate>t_op_fee['发生期间'] then begin showmessage('已结账不能删除!'); abort; end; end; procedure Tfrm_op_fee.t_op_feeBeforeEdit(DataSet: TDataSet); var sdate:tdate; begin if not modify_all then if t_op_fee.FieldByName('费用状态').AsString='审核通过' then begin showmessage('费用状态为审核状态,不能修改!'); abort; end; sdate:=EncodeDate(Logininfo.offyear,Logininfo.offmonth,1); if not t_op_fee.FieldByName('发生期间').IsNull then if sdate>t_op_fee['发生期间'] then begin showmessage('已结账不能修改!'); abort; end; end; procedure Tfrm_op_fee.bsSkinButton8Click(Sender: TObject); begin with t_op_fee do begin close;sql.Clear; sql.Add('select * from t_op_fee where 1=1 and 单据类型=''费用'''); if wwDBDateTimePicker9.text<>'' then sql.Add(' and 发生期间>='''+wwDBDateTimePicker9.text+''''); if wwDBDateTimePicker12.text<>'' then sql.Add(' and 发生期间<='''+wwDBDateTimePicker12.text+''''); if RxDBLookupCombo4.DisplayValue<>''then sql.Add(' and 相关客户='''+RxDBLookupCombo4.DisplayValues[1]+''''); if RxDBLookupCombo8.DisplayValue<>''then sql.Add(' and 相关部门='''+RxDBLookupCombo8.DisplayValues[1]+''''); if RxDBLookupCombo10.DisplayValue<>''then sql.Add(' and 相关人员='''+RxDBLookupCombo10.DisplayValues[1]+''''); if wwDBComboBox31.text<>'' then sql.Add(' and 收付类别='''+wwDBComboBox31.text+''''); if wwDBComboBox3.text<>'' then begin case wwDBComboBox3.ItemIndex of 0: begin sql.Add(' and 业务还款=0'); end; 1: begin sql.Add(' and 业务还款=1'); end; end; end; open; end; end; procedure Tfrm_op_fee.bsSkinButton6Click(Sender: TObject); var i:Integer; begin if not t_op_fee.Active then exit; if t_op_fee.IsEmpty then exit; if dxDBGrid1.SelectedCount>=1 then for i:=0 to dxDBGrid1.SelectedCount-1 do begin t_op_fee.GotoBookmark(pointer(dxdbgrid1.selectedrows[i])); if t_op_fee['财务'] then begin Showmessage(t_op_fee.FieldByName('VOUNO').AsString+' '+'已经生成凭证,不能修改'); end else begin if t_op_fee.FieldByName('费用状态').AsString<>'审核通过' then begin t_op_fee.Edit; t_op_fee.FieldByName('费用状态').AsString:='审核通过'; t_op_fee.FieldByName('审核人').AsString:=employee; t_op_fee.FieldByName('审核日期').Asdatetime:=date; t_op_fee.post; end; end; end; end; procedure Tfrm_op_fee.bsSkinButton7Click(Sender: TObject); var i:Integer; begin if not t_op_fee.Active then exit; if t_op_fee.IsEmpty then exit; if dxDBGrid1.SelectedCount>=1 then for i:=0 to dxDBGrid1.SelectedCount-1 do begin t_op_fee.GotoBookmark(pointer(dxdbgrid1.selectedrows[I])); if t_op_fee['财务'] then begin Showmessage(t_op_fee.FieldByName('VOUNO').AsString+' '+'已经生成凭证,不能修改'); end else begin if t_op_fee.FieldByName('费用状态').AsString='审核通过' then begin modify_all:=True; t_op_fee.Edit; t_op_fee.FieldByName('费用状态').AsString:='录入状态'; t_op_fee.FieldByName('审核人').AsString:=''; t_op_fee.FieldByName('审核日期').Value:=null; t_op_fee.post; modify_all:=False; end; end; end; end; procedure Tfrm_op_fee.dxDBGrid1Column10CustomDraw(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 AColor:=dxgrid_color_fee(ANode.strings[dxDBGrid1Column10.Index]); AFont.Color:=clblack; end; procedure Tfrm_op_fee.N10Click(Sender: TObject); begin update_grid_view_no(dxdbgrid1); end; procedure Tfrm_op_fee.N14Click(Sender: TObject); begin update_grid_view_all(dxdbgrid1); end; procedure Tfrm_op_fee.N12Click(Sender: TObject); begin update_grid(dxdbgrid1,211); end; procedure Tfrm_op_fee.N16Click(Sender: TObject); begin grid_save_xls(dxdbgrid1); end; procedure Tfrm_op_fee.N3Click(Sender: TObject); begin dxdbgrid1.FullExpand; end; procedure Tfrm_op_fee.N4Click(Sender: TObject); begin dxdbgrid1.FullCollapse; end; procedure Tfrm_op_fee.RxDBLookupCombo3Enter(Sender: TObject); begin RxDBLookupCombo3.LookupDisplay:='ACCID;ACCNAME'; end; procedure Tfrm_op_fee.RxDBLookupCombo3Exit(Sender: TObject); begin RxDBLookupCombo3.LookupDisplay:='accname'; end; procedure Tfrm_op_fee.RxDBLookupCombo3Change(Sender: TObject); begin if t_op_fee1.DataSet=nil then exit; if t_op_fee1.DataSet.State in [dsinsert,dsEdit] then begin if ADOQuery_cost.Locate('accid',trim(t_op_fee.fieldbyname('accid_COST').asstring),[])then begin t_op_fee1.DataSet['accid_COSTname']:=ADOQuery_cost.fieldbyname('Accname').asstring; end; end; end; procedure Tfrm_op_fee.RxDBLookupCombo5Enter(Sender: TObject); begin RxDBLookupCombo5.LookupDisplay:='ACCID;ACCNAME'; end; procedure Tfrm_op_fee.RxDBLookupCombo5Exit(Sender: TObject); begin RxDBLookupCombo5.LookupDisplay:='accname'; end; procedure Tfrm_op_fee.RxDBLookupCombo5Change(Sender: TObject); begin if t_op_fee1.DataSet=nil then exit; if t_op_fee1.DataSet.State in [dsinsert,dsEdit] then begin if ADOQuery_bc.Locate('accid',trim(t_op_fee.fieldbyname('accid_bc').asstring),[])then begin t_op_fee1.DataSet['accid_bcname']:=ADOQuery_bc.fieldbyname('Accname').asstring; end; end; end; procedure Tfrm_op_fee.dxDBGrid1CustomDraw(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 uppercase(ANode.Strings[dxDBGrid1Column21.Index])='TRUE' then begin AColor:=$00FBE8FF; exit; end; end; function Tfrm_op_fee.GetBankAccid(fdataSet:TDataSet):String; var aQuery:TAdoQuery; begin aQuery:=CreateAdoQuery; with aQuery do try Close;sql.Clear; sql.Add('select 财务软件代码 from t_sys_bank'); sql.Add('where 代码='''+fDataSet.fieldbyname('银行代码').AsString+''''); Open; if Recordcount<>0 then result:=fieldbyname('财务软件代码').AsString else result:=''; finally freeAndNil(aQuery); end; end; function Tfrm_op_fee.InsertVouItems(fDataSet:TDataSet):String; begin end; function Tfrm_op_fee.NewDrCrVou(fDataSet:TDataSet):String; var BankAccid,DC:String; amt,Exrate:double; begin Result:=''; try dmAcc.AdotblVou.Insert; dmAcc.AdotblVou.FieldByName('SourceType').AsInteger:=3; dmAcc.AdotblVou.FieldByName('ATTACHS').AsInteger:=AccInfo.ATTACHS; dmAcc.AdotblVou.FieldByName('Voudate').value:=FormatDateTime('YYYY-MM-DD',t_op_fee.fieldByName('发生期间').AsDateTime); dmAcc.AdotblVou.FieldByName('ACCYEAR').value:=yearof(t_op_fee.fieldByName('发生期间').AsDateTime); dmAcc.AdotblVou.FieldByName('ACCMonth').value:=monthof(t_op_fee.fieldByName('发生期间').AsDateTime); VoucherDate:=StrToDate(FormatDateTime('YYYY-MM-DD',t_op_fee.fieldByName('发生期间').AsDateTime)); { if Trim(AccInfo.TransName)<>'' then dmAcc.AdotblVou.FieldByName('VKNO').AsString:=AccInfo.TransName else dmAcc.AdotblVou.FieldByName('VKNO').AsString:='记'; } dmAcc.AdotblVou.FieldByName('VKNO').AsString:='费'; dmAcc.AdotblVou.FieldByName('PREPARED').AsString:=RxDBLookupCombo11.DisplayValues[0]; dmAcc.AdotblVou.Post; dmAcc.AdotblVou.Edit; with fDataSet do begin open;First; while not eof do begin dmAcc.AdotblVouItems.Insert; dmAcc.AdotblVouItems.FieldByName('AccID').AsString:=FieldByName('ACCID_COST').AsString; dmAcc.AdotblVouItems.FieldByName('FCYNO').AsString:=FieldByName('币别').AsString; if trim(FieldByName('收付类别').AsString)='付' then begin if trim(FieldByName('币别').AsString)='RMB' then begin dmAcc.AdotblVouItems.FieldByName('AmtDr').Asstring:=formatFloat('0.00;-0.00;0',FieldByName('金额').AsFloat); dmAcc.AdotblVouItems.FieldByName('AmtCr').AsFloat:=0; dmAcc.AdotblVouItems.FieldByName('FCYDR').AsFloat:=0.0; dmAcc.AdotblVouItems.FieldByName('FCYCr').AsFloat:=0.0; dmAcc.AdotblVouItems.FieldByName('FCYEXRATE').AsFloat:=1; end else begin dmAcc.AdotblVouItems.FieldByName('FCYDR').Asstring:=formatFloat('0.00;-0.00;0',FieldByName('金额').AsFloat); dmAcc.AdotblVouItems.FieldByName('FCYCr').AsFloat:=0.0; dmAcc.AdotblVouItems.FieldByName('FCYEXRATE').AsFloat:=FieldByName('汇率').AsFloat; dmAcc.AdotblVouItems.FieldByName('AmtDr').Asstring:=formatFloat('0.00;-0.00;0',FieldByName('金额').AsFloat*FieldByName('汇率').AsFloat); dmAcc.AdotblVouItems.FieldByName('AmtCr').AsFloat:=0; end; end else begin if trim(FieldByName('币别').AsString)='RMB' then begin dmAcc.AdotblVouItems.FieldByName('AmtDr').Asstring:='0'; dmAcc.AdotblVouItems.FieldByName('AmtCr').Asstring:=formatFloat('0.00;-0.00;0',FieldByName('金额').AsFloat); dmAcc.AdotblVouItems.FieldByName('FCYDR').AsFloat:=0.0; dmAcc.AdotblVouItems.FieldByName('FCYCr').AsFloat:=0.0; dmAcc.AdotblVouItems.FieldByName('FCYEXRATE').AsFloat:=1; end else begin dmAcc.AdotblVouItems.FieldByName('FCYDr').AsFloat:=0.0; dmAcc.AdotblVouItems.FieldByName('FCYCR').Asstring:=formatFloat('0.00;-0.00;0',FieldByName('金额').AsFloat); dmAcc.AdotblVouItems.FieldByName('FCYEXRATE').AsFloat:=FieldByName('汇率').AsFloat; dmAcc.AdotblVouItems.FieldByName('AmtDr').AsFloat:=0; dmAcc.AdotblVouItems.FieldByName('AmtCr').Asstring:=formatFloat('0.00;-0.00;0',FieldByName('金额').AsFloat*FieldByName('汇率').AsFloat); end; end; dmAcc.AdotblVouItems.FieldByName('EXPLAN').AsString:=t_op_fee.FieldByName('备注').AsString+' '+t_op_fee.FieldByName('相关号码').AsString; dmAcc.AdotblVouItems.FieldByName('EmplID').AsString:=GetEmpID(t_op_fee.fieldByName('相关人员').AsString); dmAcc.AdotblVouItems.FieldByName('DeptID').AsString:=GetDEPTID(t_op_fee.fieldByName('相关部门').AsString); dmAcc.AdotblVouItems.Post; amt:=amt+FieldByName('金额').AsFloat; Exrate:=FieldByName('汇率').AsFloat; BankAccid:=GetBankAccid(fdataSet); next; end; dmAcc.AdotblVouItems.Insert; dmAcc.AdotblVouItems.FieldByName('AccID').AsString:=BankAccid; if trim(FieldByName('收付类别').AsString)='付' then begin if trim(FieldByName('币别').AsString)='RMB' then begin dmAcc.AdotblVouItems.FieldByName('AmtDr').AsFloat:=0; dmAcc.AdotblVouItems.FieldByName('AmtCr').Asstring:=formatFloat('0.00;-0.00;0',amt); dmAcc.AdotblVouItems.FieldByName('FCYNO').AsString:='RMB'; dmAcc.AdotblVouItems.FieldByName('FCYDR').AsFloat:=0.0; dmAcc.AdotblVouItems.FieldByName('FCYCr').AsFloat:=0.0; dmAcc.AdotblVouItems.FieldByName('FCYEXRATE').AsFloat:=1; end else begin dmAcc.AdotblVouItems.FieldByName('FCYDR').AsFloat:=0.0; dmAcc.AdotblVouItems.FieldByName('FCYCr').Asstring:=formatFloat('0.00;-0.00;0',amt); dmAcc.AdotblVouItems.FieldByName('FCYEXRATE').AsFloat:=FieldByName('汇率').AsFloat; dmAcc.AdotblVouItems.FieldByName('AmtDr').AsFloat:=0; dmAcc.AdotblVouItems.FieldByName('AmtCr').Asstring:=formatFloat('0.00;-0.00;0',amt*FieldByName('汇率').AsFloat); dmAcc.AdotblVouItems.FieldByName('FCYNO').AsString:='USD'; end; end else begin if trim(FieldByName('币别').AsString)='RMB' then begin dmAcc.AdotblVouItems.FieldByName('AmtDr').Asstring:=formatFloat('0.00;-0.00;0',amt); dmAcc.AdotblVouItems.FieldByName('AmtCr').AsFloat:=0; dmAcc.AdotblVouItems.FieldByName('FCYNO').AsString:='RMB'; dmAcc.AdotblVouItems.FieldByName('FCYDR').AsFloat:=0.0; dmAcc.AdotblVouItems.FieldByName('FCYCr').AsFloat:=0.0; dmAcc.AdotblVouItems.FieldByName('FCYEXRATE').AsFloat:=1; end else begin dmAcc.AdotblVouItems.FieldByName('FCYDr').AsString:=formatFloat('0.00;-0.00;0',amt); dmAcc.AdotblVouItems.FieldByName('FCYCR').AsFloat:=0.0; dmAcc.AdotblVouItems.FieldByName('FCYEXRATE').AsFloat:=FieldByName('汇率').AsFloat; dmAcc.AdotblVouItems.FieldByName('AmtDr').Asstring:=formatFloat('0.00;-0.00;0',amt*FieldByName('汇率').AsFloat); dmAcc.AdotblVouItems.FieldByName('AmtCr').AsFloat:=0; dmAcc.AdotblVouItems.FieldByName('FCYNO').AsString:='USD'; end; end; dmAcc.AdotblVouItems.FieldByName('EXPLAN').AsString:=t_op_fee.FieldByName('备注').AsString+' '+t_op_fee.FieldByName('相关号码').AsString; // dmAcc.AdotblVouItems.FieldByName('EmplID').AsString:=GetEmpID(t_op_fee.fieldByName('相关人员').AsString); // dmAcc.AdotblVouItems.FieldByName('DeptID').AsString:=GetDEPTID(t_op_fee.fieldByName('相关部门').AsString); dmAcc.AdotblVouItems.Post; end; finally end; end; procedure Tfrm_op_fee.bsSkinButton9Click(Sender: TObject); var k:integer; aQuery,aAdoQueryVouItems:TAdoQuery; begin aQuery:=CreateAdoQuery; aAdoQueryVouItems:=CreateAdoQuery; with aAdoQueryVouItems do begin Close;Sql.Clear; Sql.Add('select accid_cost,银行代码,收付类别,币别,汇率,相关部门,相关人员,sum(金额) 金额 from t_op_fee'); Sql.Add('where vouno=:vouno and 财务=0 and 费用状态=''审核通过'' and 单据类型=''费用'' And AccYear=:AccYear and AccMonth=:AccMonth'); Sql.Add('Group by accid_cost,银行代码,收付类别,币别,汇率,相关部门,相关人员'); end; with aQuery do try aVKNO:=1; dmacc:=TdmAcc.Create(self); dmAcc.ADOtblVou.Open; dmAcc.ADOtblVouItems.Open; aQuery.Close; aQuery.SQL.Clear; aQuery.SQL.add('update t_op_fee set 财务=1,财务凭证=:财务凭证 where vouno=:vouno And AccYear=:AccYear and AccMonth=:AccMonth and 费用状态=''审核通过'''); if dxdbgrid1.SelectedCount>0 then begin for k:=0 to dxdbgrid1.SelectedCount-1 do begin t_op_fee.GotoBookmark(pointer(dxdbgrid1.selectedrows[k])); aAdoQueryVouItems.Close; aAdoQueryVouItems.Parameters.ParamByName('vouno').Value:=t_op_fee.fieldbyname('vouno').AsString; aAdoQueryVouItems.Parameters.ParamByName('AccYear').Value:=t_op_fee.fieldbyname('AccYear').AsString; aAdoQueryVouItems.Parameters.ParamByName('AccMonth').Value:=t_op_fee.fieldbyname('AccMonth').AsString; aAdoQueryVouItems.Open; if (not aAdoQueryVouItems.IsEmpty) and (trim(t_op_fee.FieldByName('费用状态').AsString)='审核通过') and (not t_op_fee.FieldByName('财务').AsBoolean) then begin NewDrCrVou(aAdoQueryVouItems); aQuery.Close; aQuery.Parameters.ParamByName('财务凭证').Value:=dmacc.ADOTblVou.fieldbyname('ordno').AsString; aQuery.Parameters.ParamByName('vouno').Value:=t_op_fee.fieldbyname('vouno').AsString; aQuery.Parameters.ParamByName('AccYear').Value:=t_op_fee.fieldbyname('AccYear').AsString; aQuery.Parameters.ParamByName('AccMonth').Value:=t_op_fee.fieldbyname('AccMonth').AsString; aQuery.ExecSQL; end; end end else begin end; finally Free; aAdoQueryVouItems.free; freeAndNil(dmacc); t_op_fee.Requery(); end; end; procedure Tfrm_op_fee.bsSkinButton10Click(Sender: TObject); begin sys_print('其他费用',2,nil,nil,nil,nil,t_op_fee1,nil,nil,nil,nil,nil,nil); end; procedure Tfrm_op_fee.bsSkinButton11Click(Sender: TObject); begin bsSkinPanel15.Visible:=True; end; procedure Tfrm_op_fee.bsSkinButton54Click(Sender: TObject); var aQuery:TAdoQuery; begin aQuery:=CreateAdoQuery; with aQuery do try Close;Sql.Clear; Sql.Add('update t_op_fee set 发生期间=:date1'); Sql.Add('where of_id=:of_id'); Parameters.ParamByName('date1').Value:=FormatDateTime('YYYY-MM-DD',bsSkinDateEdit1.Date); Parameters.ParamByName('of_id').Value:=t_op_fee.fieldbyname('of_id').AsInteger; ExecSQL; finally Free; t_op_fee.Refresh; bsSkinPanel15.Visible:=False; end; end; procedure Tfrm_op_fee.bsSkinButton53Click(Sender: TObject); begin bsSkinPanel15.Visible:=False; end; end.