unit u_fee_baoganadd; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, BusinessSkinForm, bsSkinCtrls, DB, ADODB, StdCtrls, Mask, DBCtrls, wwdblook, RxLookup; type Tfrm_fee_baoganadd = class(TForm) bsBusinessSkinForm1: TbsBusinessSkinForm; bsSkinGroupBox1: TbsSkinGroupBox; Label1: TLabel; Label7: TLabel; Label8: TLabel; Label9: TLabel; bsSkinGroupBox2: TbsSkinGroupBox; Label10: TLabel; bsSkinButton1: TbsSkinButton; bsSkinButton2: TbsSkinButton; wwDBLookupCombo1: TwwDBLookupCombo; wwDBLookupCombo2: TwwDBLookupCombo; wwDBLookupCombo4: TwwDBLookupCombo; Edit1: TEdit; Edit2: TEdit; Label2: TLabel; Edit3: TEdit; table1: TDataSource; procedure bsSkinButton1Click(Sender: TObject); procedure bsSkinButton2Click(Sender: TObject); procedure Edit1Change(Sender: TObject); private procedure t_ch_acceptdjoncharge(Sender: TField);//收费金额计算 { Private declarations } public CFFeeName,CFCURR:string; CFAMOUNT,CFEXCHANGE:Double; { Public declarations } end; var frm_fee_baoganadd: Tfrm_fee_baoganadd; implementation uses u_main, u_data_share, my_sys_function; {$R *.dfm} procedure Tfrm_fee_baoganadd.bsSkinButton1Click(Sender: TObject); var afield : variant; i: Integer; amount:double; begin if (table1.DataSet.FieldByName('币别').AsString='USD') THEN BEGIN amount:=StrToFloat(Edit1.Text); table1.DataSet.Edit; table1.DataSet['费用名称']:=wwDBLookupCombo1.Text; table1.DataSet['币别']:=wwDBLookupCombo4.Text; table1.DataSet['汇率']:=StrToFloat(Edit2.Text); table1.DataSet['单价']:=amount/table1.DataSet.fieldbyname('数量').AsFloat; table1.DataSet['不含税金额']:=amount; table1.DataSet['拆分费用名称']:=CFFeeName; table1.DataSet['拆分币别']:=CFCURR; if (table1.DataSet.FieldByName('币别').AsString=CFCURR) then begin table1.DataSet['拆分金额']:=StrToFloat(Edit1.Text); table1.DataSet['拆分汇率']:=StrToFloat(Edit2.Text); end else begin table1.DataSet['拆分金额']:=StrToFloat(Edit1.Text)*StrToFloat(Edit2.Text); table1.DataSet['拆分汇率']:=StrToFloat(Edit2.Text); end; table1.DataSet['金额']:=amount; table1.DataSet.post; afield := vararraycreate([0,table1.DataSet.fieldcount-1],varvariant); for i := 0 to (table1.DataSet.fieldcount-1) do begin afield[i] :=table1.DataSet.fields[i].value ; end; table1.DataSet.append; for i := 1 to (table1.DataSet.fieldcount-1) do begin if table1.DataSet.fields[i].FieldName<>'CH_ID' then table1.DataSet.fields[i].value := afield[i] ; end; table1.DataSet['录入人']:=employee; table1.DataSet['录入日期']:=now; table1.DataSet['顺序']:=table1.DataSet.RecordCount+1; table1.DataSet['费用名称']:=wwDBLookupCombo2.Text; table1.DataSet['币别']:='RMB'; amount:=StrToFloat(Edit3.Text); table1.DataSet['单价']:=amount/table1.DataSet.fieldbyname('数量').AsFloat; table1.DataSet['不含税金额']:=amount; table1.DataSet['金额']:=amount; table1.DataSet['汇率']:=1; table1.DataSet['拆分费用名称']:=CFFeeName; table1.DataSet['拆分币别']:=CFCURR; table1.DataSet['拆分金额']:=CFAMOUNT-StrToFloat(Edit1.Text); table1.DataSet['拆分汇率']:=StrToFloat(Edit2.Text); table1.DataSet.post; end else begin amount:=StrToFloat(Edit3.Text); table1.DataSet.Edit; table1.DataSet['费用名称']:=wwDBLookupCombo2.Text; table1.DataSet['单价']:=amount/table1.DataSet.fieldbyname('数量').AsFloat; table1.DataSet['不含税金额']:=amount; table1.DataSet['金额']:=StrToFloat(Edit3.Text); table1.DataSet['汇率']:=1; table1.DataSet['拆分费用名称']:=CFFeeName; table1.DataSet['拆分币别']:=CFCURR; table1.DataSet['拆分金额']:=StrToFloat(Edit3.Text); table1.DataSet['拆分汇率']:=1; table1.DataSet.post; afield := vararraycreate([0,table1.DataSet.fieldcount-1],varvariant); for i := 0 to (table1.DataSet.fieldcount-1) do begin afield[i] :=table1.DataSet.fields[i].value ; end; table1.DataSet.append; for i := 1 to (table1.DataSet.fieldcount-1) do begin if table1.DataSet.fields[i].FieldName<>'CH_ID' then table1.DataSet.fields[i].value := afield[i] ; end; amount:=StrToFloat(Edit1.Text); table1.DataSet['录入人']:=employee; table1.DataSet['录入日期']:=now; table1.DataSet['顺序']:=table1.DataSet.RecordCount+1; table1.DataSet['费用名称']:=wwDBLookupCombo1.Text; table1.DataSet['币别']:=wwDBLookupCombo4.Text; table1.DataSet['单价']:=amount/table1.DataSet.fieldbyname('数量').AsFloat; table1.DataSet['不含税金额']:=amount; table1.DataSet['金额']:=StrToFloat(Edit1.Text); table1.DataSet['汇率']:=StrToFloat(Edit2.Text); table1.DataSet['拆分费用名称']:=CFFeeName; table1.DataSet['拆分币别']:=CFCURR; table1.DataSet['拆分金额']:=CFAMOUNT-StrToFloat(Edit3.Text); table1.DataSet['拆分汇率']:=StrToFloat(Edit2.Text); table1.DataSet.post; end; close; end; procedure Tfrm_fee_baoganadd.bsSkinButton2Click(Sender: TObject); begin close; end; procedure Tfrm_fee_baoganadd.t_ch_acceptdjoncharge(Sender: TField); begin end; procedure Tfrm_fee_baoganadd.Edit1Change(Sender: TObject); VAR amount:Double; begin if (CFCURR='USD') THEN begin amount:=CFAMOUNT-strtofloatdef(Edit1.Text,0); amount:=amount*strtofloatdef(Edit2.Text,0); Edit3.Text:=FloatToStr(amount); end ELSE BEGIN amount:=strtofloatdef(Edit1.Text,0)*strtofloatdef(Edit2.Text,0); Edit3.Text:= FloatToStr(CFAMOUNT-amount); end; end; end.