unit u_op_railway_batchfee; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, BusinessSkinForm, bsSkinCtrls, StdCtrls, Mask, wwdbedit, Wwdotdot, Wwdbcomb, wwdbdatetimepicker, RxLookup, wwdblook, ComCtrls, bsSkinTabs, ExtCtrls, DB, ADODB; type Tfrm_op_railway_batchfee = class(TForm) bsBusinessSkinForm1: TbsBusinessSkinForm; bsSkinButton3: TbsSkinButton; bsSkinButton2: TbsSkinButton; bsSkinRadioGroup1: TbsSkinRadioGroup; Label38: TLabel; RxDBLookupCombo16: TRxDBLookupCombo; Label25: TLabel; wwDBComboBox31: TwwDBComboBox; Label13: TLabel; RxDBLookupCombo5: TRxDBLookupCombo; wwDBComboBox13: TwwDBComboBox; Label1: TLabel; Edit7: TEdit; Edit1: TEdit; Edit2: TEdit; Label37: TLabel; RxDBLookupCombo1: TRxDBLookupCombo; Label2: TLabel; Label3: TLabel; Label4: TLabel; Label5: TLabel; Edit3: TEdit; bsSkinBevel1: TbsSkinBevel; Label6: TLabel; Edit4: TEdit; Label7: TLabel; wwDBComboBox1: TwwDBComboBox; bsSkinBevel2: TbsSkinBevel; Label8: TLabel; Edit5: TEdit; Label9: TLabel; Edit6: TEdit; Label10: TLabel; Edit8: TEdit; Label11: TLabel; Edit9: TEdit; Label12: TLabel; Edit10: TEdit; Edit11: TEdit; Edit12: TEdit; bsSkinCheckRadioBox1: TbsSkinCheckRadioBox; bsSkinCheckRadioBox2: TbsSkinCheckRadioBox; procedure bsSkinButton2Click(Sender: TObject); procedure FormShow(Sender: TObject); procedure Edit7Change(Sender: TObject); procedure RxDBLookupCombo1Change(Sender: TObject); procedure Edit5Change(Sender: TObject); procedure bsSkinButton3Click(Sender: TObject); private { Private declarations } public { Public declarations } yelx:string; procedure MasterFee; procedure HblFee; end; var frm_op_railway_batchfee: Tfrm_op_railway_batchfee; implementation uses u_main, u_data_share, my_sys_function, u_op_railway; {$R *.dfm} procedure Tfrm_op_railway_batchfee.bsSkinButton2Click( Sender: TObject); begin close; end; procedure Tfrm_op_railway_batchfee.MasterFee; var i:integer; yjid:array of string ; val,fenbsno:string ; procedure edidataset; begin frm_op_railway.t_ch_fee.Insert; frm_op_railway.t_ch_fee['编号']:=frm_op_railway.t_ch_fee.DataSource.DataSet['编号']; frm_op_railway.t_ch_fee['类型']:=wwDBComboBox31.Text; if bsSkinCheckRadioBox1.checked then begin frm_op_railway.t_ch_fee['费用状态']:='提交审核'; frm_op_railway.t_ch_fee['提交日期']:=now; end else if bsSkinCheckRadioBox2.checked then begin frm_op_railway.t_ch_fee.FieldByName('费用状态').AsString:='审核通过'; frm_op_railway.t_ch_fee['提交日期']:=now; end else frm_op_railway.t_ch_fee['费用状态']:='录入状态'; frm_op_railway.t_ch_fee['录入人']:=employee; frm_op_railway.t_ch_fee['结算金额']:=0; frm_op_railway.t_ch_fee['费用名称']:=RxDBLookupCombo16.DisplayValues[1]; frm_op_railway.t_ch_fee['单价']:=StrToFloatdef(Edit5.Text,0); frm_op_railway.t_ch_fee['数量']:=StrToIntDef(Edit1.Text,0); frm_op_railway.t_ch_fee['金额']:=StrToFloatdef(Edit8.Text,0); frm_op_railway.t_ch_fee['币别']:=RxDBLookupCombo1.DisplayValues[0]; frm_op_railway.t_ch_fee['汇率']:=StrToFloatdef(Edit3.Text,0); frm_op_railway.t_ch_fee['标准']:=wwDBComboBox13.Text; frm_op_railway.t_ch_fee['开票金额']:=0; frm_op_railway.t_ch_fee['冲抵金额']:=0; frm_op_railway.t_ch_fee['申请金额']:=0; frm_op_railway.t_ch_fee['申请开票']:=0; frm_op_railway.t_ch_fee['录入日期']:=now; frm_op_railway.t_ch_fee['是否对帐']:=0; frm_op_railway.t_ch_fee['是否垫付']:=0; frm_op_railway.t_ch_fee['不开发票']:=0; frm_op_railway.t_ch_fee['预提成本']:=0; frm_op_railway.t_ch_fee['冲抵成本']:=0; frm_op_railway.t_ch_fee['不含税价']:=StrToFloatdef(Edit7.Text,0); frm_op_railway.t_ch_fee['税率']:=StrToFloatdef(Edit6.Text,0); frm_op_railway.t_ch_fee['税额']:=StrToFloatdef(Edit10.Text,0); frm_op_railway.t_ch_fee['不含税金额']:=StrToFloatdef(Edit2.Text,0); frm_op_railway.t_ch_fee['财务税率']:=StrToFloatdef(Edit9.Text,0);; frm_op_railway.t_ch_fee['财务税额']:=StrToFloatdef(Edit11.Text,0);; frm_op_railway.t_ch_fee['财务不含税价']:=StrToFloatdef(Edit12.Text,0);; if wwDBComboBox1.Text<>'' then frm_op_railway.t_ch_fee['结算单位']:=wwDBComboBox1.Text; frm_op_railway.t_ch_fee['顺序']:=1; frm_op_railway.t_ch_fee['机密']:=0; if RxDBLookupCombo5.DisplayValue<>'' then frm_op_railway.t_ch_fee['客户名称']:=RxDBLookupCombo5.DisplayValues[1] else frm_op_railway.t_ch_fee['客户名称']:=frm_op_railway.t_op_railway.fieldbyname(wwDBComboBox1.Text).AsString; frm_op_railway.t_ch_fee['备注']:=trim(Edit4.Text); frm_op_railway.t_ch_fee.Post; frm_op_railway.p_op_gain.Close; frm_op_railway.p_op_gain.Parameters.ParamByName('编号').Value:=frm_op_railway.t_ch_fee.DataSource.DataSet['编号']; frm_op_railway.p_op_gain.ExecSQL; end; begin if frm_op_railway.t_op_railway.IsEmpty then exit; if wwDBComboBox31.Text='' then begin ShowMessage('收付类别不能为空!'); exit; end; if RxDBLookupCombo16.DisplayValue='' then begin ShowMessage('费用名称不能为空!'); exit; end; if (wwDBComboBox1.Text='') and (RxDBLookupCombo5.DisplayValue='') then begin ShowMessage('结算单位和客户名称不能同时为空!'); exit; end; if wwDBComboBox13.Text='' then begin ShowMessage('费用标准不能为空!'); exit; end; if Edit7.Text='' then begin ShowMessage('费用单价不能为空!'); exit; end; if Edit1.Text='' then begin ShowMessage('费用数量不能为空!'); exit; end; if Edit2.Text='' then begin ShowMessage('费用金额不能为空!'); exit; end; if Edit3.Text='' then begin ShowMessage('费用汇率不能为空!'); exit; end; if RxDBLookupCombo1.DisplayValue='' then begin ShowMessage('费用币别不能为空!'); exit; end; frm_op_railway.t_ch_fee.close; frm_op_railway.t_ch_fee.DataSource:=frm_op_railway.t_op_railway1; frm_op_railway.t_ch_fee.open; frm_op_railway.cxGrid1DBTableView1.BeginUpdate ; setlength(yjid,frm_op_railway.cxGrid1DBTableView1.Controller.SelectedRowCount); if bsSkinRadioGroup1.ItemIndex=0 then begin if frm_op_railway.cxGrid1DBTableView1.Controller.SelectedRowCount<=0 then begin edidataset; end else try frm_op_railway.t_op_railway.DisableControls; try for i:=0 to frm_op_railway.cxGrid1DBTableView1.Controller.SelectedRowCount-1 do begin //焦点移到选中列 val:=frm_op_railway.cxGrid1DBTableView1.DataController.GetDisplayText(frm_op_railway.cxGrid1DBTableView1.Controller.SelectedRows[I].RecordIndex,0) ; yjid[i]:=val ; end; //得到选中列的值 for i:=0 to high(yjid) do begin if frm_op_railway.t_op_railway.Locate('业务编号',yjid[i],[]) then begin if frm_op_railway.t_op_railway.FieldByName('费用状态').AsString='费用封帐' then begin ShowMessage('箱号:'+frm_op_railway.t_op_railway.fieldbyname('箱号').asstring+',已财务封帐,不允许添加费用!'); end else edidataset; end ; end ; finally frm_op_railway.cxGrid1DBTableView1.EndUpdate ; end; finally frm_op_railway.t_op_railway.EnableControls; end; { frm_op_railway.cxGrid1DBTableView3.BeginUpdate ; // frm_op_railway.cxGrid1DBTableView3.Controller.SelectedRowCount; setlength(yjid,frm_op_railway.cxGrid1DBTableView3.Controller.SelectedRowCount); if frm_op_railway.cxGrid1DBTableView3.Controller.SelectedRowCount<=0 then begin edidataset; end else try frm_op_railway.t_op_railway_fen.DisableControls; try for i:=0 to frm_op_railway.cxGrid1DBTableView3.Controller.SelectedRowCount-1 do begin //焦点移到选中列 val:=frm_op_railway.cxGrid1DBTableView3.DataController.GetDisplayText(frm_op_railway.cxGrid1DBTableView3.Controller.SelectedRows[I].RecordIndex,0) ; yjid[i]:=val ; end; //得到选中列的值 for i:=0 to high(yjid) do begin if frm_op_railway.t_op_railway_fen.Locate('业务编号',yjid[i],[]) then begin if frm_op_railway.t_op_railway_fen.FieldByName('费用状态').AsString='费用封帐' then begin ShowMessage('箱号:'+frm_op_railway.t_op_railway_fen.fieldbyname('箱号').asstring+',已财务封帐,不允许添加费用!'); end else edidataset; end ; end ; finally frm_op_railway.cxGrid1DBTableView3.EndUpdate ; end; finally frm_op_railway.t_op_railway_fen.EnableControls; end; } end else if bsSkinRadioGroup1.itemindex=1 then begin frm_op_railway.t_op_railway.First; while not frm_op_railway.t_op_railway.Eof do begin if frm_op_railway.t_op_railway.FieldByName('费用状态').AsString='费用封帐' then begin ShowMessage('箱号:'+frm_op_railway.t_op_railway.fieldbyname('箱号').asstring+',已财务封帐,不允许添加费用!'); end else edidataset; frm_op_railway.t_op_railway.next; end; end; ShowMessage('费用添加完成!'); end; procedure Tfrm_op_railway_batchfee.HBLFee; var i:integer; procedure edidataset; begin frm_op_railway.t_ch_fee.Insert; frm_op_railway.t_ch_fee['编号']:=frm_op_railway.t_op_railway_fen['编号']; frm_op_railway.t_ch_fee['类型']:=wwDBComboBox31.Text; if bsSkinCheckRadioBox1.checked then begin frm_op_railway.t_ch_fee.FieldByName('费用状态').AsString:='提交审核'; frm_op_railway.t_ch_fee['提交日期']:=now; end else if bsSkinCheckRadioBox2.checked then begin frm_op_railway.t_ch_fee.FieldByName('费用状态').AsString:='审核通过'; frm_op_railway.t_ch_fee['提交日期']:=now; end else frm_op_railway.t_ch_fee['费用状态']:='录入状态'; frm_op_railway.t_ch_fee['录入人']:=employee; frm_op_railway.t_ch_fee['结算金额']:=0; frm_op_railway.t_ch_fee['费用名称']:=RxDBLookupCombo16.DisplayValues[1]; frm_op_railway.t_ch_fee['单价']:=StrToFloatdef(Edit5.Text,0); frm_op_railway.t_ch_fee['数量']:=StrToIntDef(Edit1.Text,0); frm_op_railway.t_ch_fee['金额']:=StrToFloatdef(Edit8.Text,0); frm_op_railway.t_ch_fee['币别']:=RxDBLookupCombo1.DisplayValues[0]; frm_op_railway.t_ch_fee['汇率']:=StrToFloatdef(Edit3.Text,0); frm_op_railway.t_ch_fee['标准']:=wwDBComboBox13.Text; frm_op_railway.t_ch_fee['开票金额']:=0; frm_op_railway.t_ch_fee['冲抵金额']:=0; frm_op_railway.t_ch_fee['申请金额']:=0; frm_op_railway.t_ch_fee['申请开票']:=0; frm_op_railway.t_ch_fee['录入日期']:=now; frm_op_railway.t_ch_fee['是否对帐']:=0; frm_op_railway.t_ch_fee['是否垫付']:=0; frm_op_railway.t_ch_fee['不开发票']:=0; frm_op_railway.t_ch_fee['预提成本']:=0; frm_op_railway.t_ch_fee['冲抵成本']:=0; frm_op_railway.t_ch_fee['不含税价']:=StrToFloatdef(Edit7.Text,0); frm_op_railway.t_ch_fee['税率']:=StrToFloatdef(Edit6.Text,0); frm_op_railway.t_ch_fee['税额']:=StrToFloatdef(Edit10.Text,0); frm_op_railway.t_ch_fee['不含税金额']:=StrToFloatdef(Edit2.Text,0); frm_op_railway.t_ch_fee['财务税率']:=StrToFloatdef(Edit9.Text,0);; frm_op_railway.t_ch_fee['财务税额']:=StrToFloatdef(Edit11.Text,0);; frm_op_railway.t_ch_fee['财务不含税价']:=StrToFloatdef(Edit12.Text,0);; if wwDBComboBox1.Text<>'' then frm_op_railway.t_ch_fee['结算单位']:=wwDBComboBox1.Text; frm_op_railway.t_ch_fee['顺序']:=1; frm_op_railway.t_ch_fee['机密']:=0; if RxDBLookupCombo5.DisplayValue<>'' then frm_op_railway.t_ch_fee['客户名称']:=RxDBLookupCombo5.DisplayValues[1] else frm_op_railway.t_ch_fee['客户名称']:=frm_op_railway.t_op_railway_fen.fieldbyname(wwDBComboBox1.Text).AsString; frm_op_railway.t_ch_fee['备注']:=trim(Edit4.Text); frm_op_railway.t_ch_fee.Post; end; begin if wwDBComboBox31.Text='' then begin ShowMessage('收付类别不能为空!'); exit; end; if RxDBLookupCombo16.DisplayValue='' then begin ShowMessage('费用名称不能为空!'); exit; end; if (wwDBComboBox1.Text='') and (RxDBLookupCombo5.DisplayValue='') then begin ShowMessage('结算单位和客户名称不能同时为空!'); exit; end; if wwDBComboBox13.Text='' then begin ShowMessage('费用标准不能为空!'); exit; end; if Edit7.Text='' then begin ShowMessage('费用单价不能为空!'); exit; end; if Edit1.Text='' then begin ShowMessage('费用数量不能为空!'); exit; end; if Edit2.Text='' then begin ShowMessage('费用金额不能为空!'); exit; end; if Edit3.Text='' then begin ShowMessage('费用汇率不能为空!'); exit; end; if RxDBLookupCombo1.DisplayValue='' then begin ShowMessage('费用币别不能为空!'); exit; end; frm_op_railway.t_ch_fee.close; frm_op_railway.t_ch_fee.DataSource:=frm_op_railway.t_op_railway_fen1; frm_op_railway.t_ch_fee.open; if bsSkinRadioGroup1.ItemIndex=0 then begin if frm_op_railway.dxDBGrid2.SelectedCount<1 then begin edidataset; end else try frm_op_railway.t_op_railway_fen.DisableControls; for i:=0 to frm_op_railway.dxDBGrid2.SelectedCount-1 do begin frm_op_railway.t_op_railway_fen.GotoBookmark(pointer(frm_op_railway.dxDBGrid2.selectedrows[i])); if frm_op_railway.t_op_railway_fen.FieldByName('费用状态').AsString='费用封帐' then begin ShowMessage('箱号:'+frm_op_railway.t_op_railway_fen.fieldbyname('箱号').asstring+',已财务封帐,不允许添加费用!'); end else edidataset; end; finally frm_op_railway.t_op_railway_fen.EnableControls; end; end else if bsSkinRadioGroup1.itemindex=1 then begin frm_op_railway.t_op_railway_fen.First; while not frm_op_railway.t_op_railway_fen.Eof do begin if frm_op_railway.t_op_railway_fen.FieldByName('费用状态').AsString='费用封帐' then begin ShowMessage('箱号:'+frm_op_railway.t_op_railway_fen.fieldbyname('箱号').asstring+',已财务封帐,不允许添加费用!'); end else edidataset; frm_op_railway.t_op_railway_fen.next; end; end; ShowMessage('费用添加完成!'); close; end; procedure Tfrm_op_railway_batchfee.FormShow(Sender: TObject); begin RxDBLookupCombo1.Value:='RMB'; end; procedure Tfrm_op_railway_batchfee.Edit7Change(Sender: TObject); begin if (StrToFloatDef(Trim(Edit7.Text),0)<>0) and (StrToFloatDef(Trim(Edit1.Text),0)<>0) then begin Edit2.Text:=FormatFloat('0.00;-0.00;0.0',StrToFloatDef(Trim(Edit7.Text),0)*StrToFloatDef(Trim(Edit1.Text),0)); if (StrToFloatDef(Trim(Edit6.Text),0)<>0) then begin Edit5.Text:=FormatFloat('0.00;-0.00;0.0',StrToFloatDef(Trim(Edit7.Text),0)*(1+StrToFloatDef(Trim(Edit6.Text),0)/100)); Edit8.Text:=FormatFloat('0.00;-0.00;0.0',StrToFloatDef(Trim(Edit5.Text),0)*StrToFloatDef(Trim(Edit1.Text),0)); Edit10.Text:=FormatFloat('0.00;-0.00;0.0',StrToFloatDef(Trim(Edit8.Text),0)-StrToFloatDef(Trim(Edit2.Text),0)); if (StrToFloatDef(Trim(Edit9.Text),0)<>0) then begin Edit11.Text:=FormatFloat('0.00;-0.00;0.0',StrToFloatDef(Trim(Edit8.Text),0)/(1+(StrToFloatDef(Trim(Edit9.Text),0)/100))*(StrToFloatDef(Trim(Edit9.Text),0)/100)); Edit12.Text:=FormatFloat('0.00;-0.00;0.0',StrToFloatDef(Trim(Edit8.Text),0)-StrToFloatDef(Trim(Edit11.Text),0)); end; end; end; end; procedure Tfrm_op_railway_batchfee.RxDBLookupCombo1Change( Sender: TObject); begin if RxDBLookupCombo1.DisplayValues[0]<>'' then begin IF frm_data_share.t_code_currency.Locate('币别',RxDBLookupCombo1.DisplayValues[0],[])THEN begin if RxDBLookupCombo1.DisplayValues[0]='USD' then begin Edit3.Text:=FloatToStr(getUsdExRate(DateToStr(Date),'USD')); end else Edit3.Text:=FloatToStr(frm_data_share.t_code_currency.fieldbyname('汇率').asfloat); end; end; end; procedure Tfrm_op_railway_batchfee.Edit5Change(Sender: TObject); begin if (StrToFloatDef(Trim(Edit5.Text),0)<>0) and (StrToFloatDef(Trim(Edit1.Text),0)<>0) then begin Edit8.Text:=FormatFloat('0.00;-0.00;0.0',StrToFloatDef(Trim(Edit5.Text),0)*StrToFloatDef(Trim(Edit1.Text),0)); // if (StrToFloatDef(Trim(Edit6.Text),0)<>0) then begin // end; Edit7.Text:=FormatFloat('0.00;-0.00;0.0',StrToFloatDef(Trim(Edit5.Text),0)/(1+(StrToFloatDef(Trim(Edit6.Text),0)/100))); Edit2.Text:=FormatFloat('0.00;-0.00;0.0',StrToFloatDef(Trim(Edit7.Text),0)*StrToFloatDef(Trim(Edit1.Text),0)); Edit10.Text:=FormatFloat('0.00;-0.00;0.0',StrToFloatDef(Trim(Edit8.Text),0)-StrToFloatDef(Trim(Edit2.Text),0)); if (StrToFloatDef(Trim(Edit9.Text),0)<>0) then begin Edit11.Text:=FormatFloat('0.00;-0.00;0.0',StrToFloatDef(Trim(Edit8.Text),0)/(1+(StrToFloatDef(Trim(Edit9.Text),0)/100))*(StrToFloatDef(Trim(Edit9.Text),0)/100)); Edit12.Text:=FormatFloat('0.00;-0.00;0.0',StrToFloatDef(Trim(Edit8.Text),0)-StrToFloatDef(Trim(Edit11.Text),0)); end; end; end; procedure Tfrm_op_railway_batchfee.bsSkinButton3Click(Sender: TObject); begin if yelx='M' then MasterFee else HblFee; end; end.