unit u_op_ctn_piliangfee; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, BusinessSkinForm, bsSkinCtrls, StdCtrls, Mask, wwdbedit, Wwdotdot, Wwdbcomb, wwdbdatetimepicker, RxLookup, wwdblook, ComCtrls, bsSkinTabs, ExtCtrls; type Tfrm_op_ctn_piliangfee = 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; procedure bsSkinButton2Click(Sender: TObject); procedure bsSkinButton3Click(Sender: TObject); procedure FormShow(Sender: TObject); procedure Edit7Change(Sender: TObject); procedure RxDBLookupCombo1Change(Sender: TObject); procedure Edit5Change(Sender: TObject); private { Private declarations } public { Public declarations } end; var frm_op_ctn_piliangfee: Tfrm_op_ctn_piliangfee; implementation uses u_main, u_data_share, my_sys_function, u_op_ctn_detail, u_op_railway_shencode; {$R *.dfm} procedure Tfrm_op_ctn_piliangfee.bsSkinButton2Click( Sender: TObject); begin close; end; procedure Tfrm_op_ctn_piliangfee.bsSkinButton3Click( Sender: TObject); var i:integer; procedure edidataset; begin frm_op_ctn_detail.t_ch_fee.Insert; frm_op_ctn_detail.t_ch_fee['编号']:=frm_op_ctn_detail.t_ch_fee.DataSource.DataSet['编号']; frm_op_ctn_detail.t_ch_fee['类型']:=wwDBComboBox31.Text; if bsSkinCheckRadioBox1.checked then begin if (Trim(wwDBComboBox31.Text)='收') then begin if strtobool(get_parameters_value(133,'false')) then frm_op_ctn_detail.t_ch_fee.FieldByName('费用状态').AsString:='审核通过' else frm_op_ctn_detail.t_ch_fee.FieldByName('费用状态').AsString:='提交审核'; end; if (Trim(wwDBComboBox31.Text)='付') then begin if strtobool(get_parameters_value(135,'false')) then frm_op_ctn_detail.t_ch_fee.FieldByName('费用状态').AsString:='审核通过' else frm_op_ctn_detail.t_ch_fee.FieldByName('费用状态').AsString:='提交审核'; end; frm_op_ctn_detail.t_ch_fee['提交日期']:=now; end else frm_op_ctn_detail.t_ch_fee['费用状态']:='录入状态'; frm_op_ctn_detail.t_ch_fee['录入人']:=employee; frm_op_ctn_detail.t_ch_fee['结算金额']:=0; frm_op_ctn_detail.t_ch_fee['费用名称']:=RxDBLookupCombo16.DisplayValues[1]; frm_op_ctn_detail.t_ch_fee['单价']:=StrToFloatdef(Edit5.Text,0); frm_op_ctn_detail.t_ch_fee['数量']:=StrToIntDef(Edit1.Text,0); frm_op_ctn_detail.t_ch_fee['金额']:=StrToFloatdef(Edit8.Text,0); frm_op_ctn_detail.t_ch_fee['币别']:=RxDBLookupCombo1.DisplayValues[0]; frm_op_ctn_detail.t_ch_fee['汇率']:=StrToFloatdef(Edit3.Text,0); frm_op_ctn_detail.t_ch_fee['标准']:=wwDBComboBox13.Text; frm_op_ctn_detail.t_ch_fee['开票金额']:=0; frm_op_ctn_detail.t_ch_fee['冲抵金额']:=0; frm_op_ctn_detail.t_ch_fee['申请金额']:=0; frm_op_ctn_detail.t_ch_fee['申请开票']:=0; frm_op_ctn_detail.t_ch_fee['录入日期']:=now; frm_op_ctn_detail.t_ch_fee['是否对帐']:=0; frm_op_ctn_detail.t_ch_fee['是否垫付']:=0; frm_op_ctn_detail.t_ch_fee['不开发票']:=0; frm_op_ctn_detail.t_ch_fee['预提成本']:=0; frm_op_ctn_detail.t_ch_fee['冲抵成本']:=0; frm_op_ctn_detail.t_ch_fee['不含税价']:=StrToFloatdef(Edit7.Text,0); frm_op_ctn_detail.t_ch_fee['税率']:=StrToFloatdef(Edit6.Text,0); frm_op_ctn_detail.t_ch_fee['税额']:=StrToFloatdef(Edit10.Text,0); frm_op_ctn_detail.t_ch_fee['不含税金额']:=StrToFloatdef(Edit2.Text,0); frm_op_ctn_detail.t_ch_fee['财务税率']:=StrToFloatdef(Edit9.Text,0);; frm_op_ctn_detail.t_ch_fee['财务税额']:=StrToFloatdef(Edit11.Text,0);; frm_op_ctn_detail.t_ch_fee['财务不含税价']:=StrToFloatdef(Edit12.Text,0);; if wwDBComboBox1.Text<>'' then frm_op_ctn_detail.t_ch_fee['结算单位']:=wwDBComboBox1.Text; frm_op_ctn_detail.t_ch_fee['顺序']:=1; frm_op_ctn_detail.t_ch_fee['机密']:=0; if RxDBLookupCombo5.DisplayValue<>'' then frm_op_ctn_detail.t_ch_fee['客户名称']:=RxDBLookupCombo5.DisplayValues[1] else frm_op_ctn_detail.t_ch_fee['客户名称']:=frm_op_ctn_detail.t_op_ctn_detail.fieldbyname(wwDBComboBox1.Text).AsString; frm_op_ctn_detail.t_ch_fee.Post; end; begin if frm_op_ctn_detail.t_op_ctn_detail.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_ctn_detail.t_ch_fee.close; frm_op_ctn_detail.t_ch_fee.DataSource:=frm_op_ctn_detail.t_op_ctn_detail1; frm_op_ctn_detail.t_ch_fee.open; if bsSkinRadioGroup1.ItemIndex=0 then begin if frm_op_ctn_detail.dxDBGrid1.SelectedCount<1 then begin edidataset; end else try frm_op_ctn_detail.t_op_ctn_detail.DisableControls; for i:=0 to frm_op_ctn_detail.dxDBGrid1.SelectedCount-1 do begin frm_op_ctn_detail.t_op_ctn_detail.GotoBookmark(pointer(frm_op_ctn_detail.dxDBGrid1.selectedrows[i])); if frm_op_ctn_detail.t_op_ctn_detail.FieldByName('费用状态').AsString='费用封帐' then begin ShowMessage('箱号:'+frm_op_ctn_detail.t_op_ctn_detail.fieldbyname('箱号').asstring+',已财务封帐,不允许添加费用!'); end else edidataset; end; finally frm_op_ctn_detail.t_op_ctn_detail.EnableControls; end; end else if bsSkinRadioGroup1.itemindex=1 then begin frm_op_ctn_detail.t_op_ctn_detail.First; while not frm_op_ctn_detail.t_op_ctn_detail.Eof do begin if frm_op_ctn_detail.t_op_ctn_detail.FieldByName('费用状态').AsString='费用封帐' then begin ShowMessage('箱号:'+frm_op_ctn_detail.t_op_ctn_detail.fieldbyname('箱号').asstring+',已财务封帐,不允许添加费用!'); end else edidataset; frm_op_ctn_detail.t_op_ctn_detail.next; end; end; ShowMessage('费用添加完成!'); end; procedure Tfrm_op_ctn_piliangfee.FormShow(Sender: TObject); begin RxDBLookupCombo1.Value:='RMB'; end; procedure Tfrm_op_ctn_piliangfee.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_ctn_piliangfee.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_ctn_piliangfee.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; end.