unit u_code_fee_project_add; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DB, ADODB, dxExEdtr, dxDBTLCl, dxGrClms, dxTL, dxDBCtrl, dxDBGrid, dxCntner, BusinessSkinForm, ExtCtrls, bsSkinCtrls, StdCtrls, Mask, DBCtrls; type Tfrm_code_fee_project_add = class(TForm) t_ch_project: TADOQuery; t_ch_project1: TDataSource; t_ch_project_fee: TADOQuery; t_ch_project_fee1: TDataSource; t_ch_project_standard: TADOQuery; t_ch_project_standard1: TDataSource; dxDBGrid1: TdxDBGrid; dxDBGrid1Column1: TdxDBGridMaskColumn; dxDBGrid1Column2: TdxDBGridMaskColumn; dxDBGrid1Column3: TdxDBGridDateColumn; dxDBGrid1Column4: TdxDBGridMaskColumn; bsBusinessSkinForm1: TbsBusinessSkinForm; Panel1: TPanel; dxDBGrid2: TdxDBGrid; dxDBGrid2Column1: TdxDBGridMaskColumn; dxDBGrid2Column2: TdxDBGridMaskColumn; dxDBGrid2Column3: TdxDBGridMaskColumn; dxDBGrid2Column4: TdxDBGridMaskColumn; dxDBGrid2Column5: TdxDBGridColumn; dxDBGrid2Column6: TdxDBGridMaskColumn; dxDBGrid3: TdxDBGrid; dxDBGrid3Column1: TdxDBGridColumn; dxDBGrid3Column2: TdxDBGridColumn; dxDBGrid3Column4: TdxDBGridColumn; bsSkinPanel1: TbsSkinPanel; bsSkinButton3: TbsSkinButton; bsSkinButton2: TbsSkinButton; op_type: TEdit; fee_type: TEdit; t_op_bill1: TDataSource; t_ch_fee1: TDataSource; t_op_ctn: TADOQuery; dxDBGrid2Column7: TdxDBGridColumn; dxDBGrid2Column8: TdxDBGridColumn; DBEdit1: TDBEdit; dxDBGrid2Column9: TdxDBGridCheckColumn; dxDBGrid2Column10: TdxDBGridColumn; dxDBGrid2Column11: TdxDBGridColumn; procedure bsSkinButton2Click(Sender: TObject); procedure FormShow(Sender: TObject); procedure bsSkinButton3Click(Sender: TObject); function fee_get_client(str:string):string; function fee_get_num:real; procedure DBEdit1Change(Sender: TObject); private { Private declarations } public { Public declarations } end; var frm_code_fee_project_add: Tfrm_code_fee_project_add; implementation uses u_main, my_sys_function, u_data_share; {$R *.dfm} function Tfrm_code_fee_project_add.fee_get_num:real; begin ; end; function Tfrm_code_fee_project_add.fee_get_client(str:string):string; begin if str='' then result:='' else begin if (op_type.text='1')OR(op_type.text='2') OR (op_type.text='7') then begin if str='委托单位'then result:=t_op_bill1.DataSet.fieldbyname('委托单位').asstring; if str='船公司'then result:=t_op_bill1.DataSet.fieldbyname('船公司').asstring; if str='场站'then result:=t_op_bill1.DataSet.fieldbyname('场站').asstring; if str='车队'then result:=t_op_bill1.DataSet.fieldbyname('承运车队').asstring; if str='报关行'then result:=t_op_bill1.DataSet.fieldbyname('报关行').asstring; if str='代理'then result:=t_op_bill1.DataSet.fieldbyname('代理').asstring; if str='货代'then result:=t_op_bill1.DataSet.fieldbyname('货代公司').asstring; if str='发货人'then result:=t_op_bill1.DataSet.fieldbyname('发货人').asstring; if str='收货人'then result:=t_op_bill1.DataSet.fieldbyname('收货人').asstring; if str='通知人'then result:=t_op_bill1.DataSet.fieldbyname('通知人').asstring; end else if (op_type.text='3')OR(op_type.text='4') then begin if str='委托单位'then result:=t_op_bill1.DataSet.fieldbyname('委托单位').asstring; if str='航空公司'then result:=t_op_bill1.DataSet.fieldbyname('航空公司').asstring; if str='报关行'then result:=t_op_bill1.DataSet.fieldbyname('报关行').asstring; if str='代理'then result:=t_op_bill1.DataSet.fieldbyname('代理').asstring; end else if (op_type.text='6') then begin if str='委托单位'then result:=t_op_bill1.DataSet.fieldbyname('委托单位').asstring; if str='承运人'then result:=t_op_bill1.DataSet.fieldbyname('承运人').asstring; if str='发货人'then result:=t_op_bill1.DataSet.fieldbyname('发货人').asstring; if str='收货人'then result:=t_op_bill1.DataSet.fieldbyname('收货人').asstring; else if (op_type.text='5') then begin if str='委托单位'then result:=t_op_bill1.DataSet.fieldbyname('委托单位').asstring; end end; end; procedure Tfrm_code_fee_project_add.bsSkinButton2Click(Sender: TObject); begin close; end; procedure Tfrm_code_fee_project_add.FormShow(Sender: TObject); begin t_ch_project.SQL.clear; t_ch_project.sql.add('select * from t_ch_project '); t_ch_project.SQL.Add(' where '+open_data('8005','录入人','no','no','no','no')); t_ch_project.sql.add(' and 费用类型='+''''+fee_type.text+''''); if op_type.text='1'then begin t_ch_project.sql.add(' and 业务种类='+''''+'海运出口'+''''); end; if (op_type.text='2') OR (op_type.text='7')then begin t_ch_project.sql.add(' and 业务种类='+''''+'海运进口'+''''); end; if op_type.text='3'then begin t_ch_project.sql.add(' and 业务种类='+''''+'空运出口'+''''); end; if op_type.text='4'then begin t_ch_project.sql.add(' and 业务种类='+''''+'空运进口'+''''); end; if op_type.text='5'then begin t_ch_project.sql.add(' and 业务种类='+''''+'监管车'+''''); end; if op_type.text='6'then begin t_ch_project.sql.add(' and 业务种类='+''''+'铁路运输'+''''); end; t_ch_project.sql.add(' order by 方案名称'); t_ch_project.open; t_ch_project_fee.open; t_ch_project_standard.open; end; procedure Tfrm_code_fee_project_add.bsSkinButton3Click(Sender: TObject); var i,price,Exrate:real; s_bz,CorpsName:string; if_do:boolean; function GetFeeCodeStd(feeName:string):Boolean; var aAdoQuery:TAdoQuery; begin Result:=False; aAdoQuery:=CreateAdoQuery; with aAdoQuery do try Close;SQL.Clear; sql.Add('Select * from t_code_fee'); sql.Add('where 中文名=:FeeName and 标准=''箱量'''); Parameters.ParamByName('FeeName').Value:=feeName; Open; Result:=not IsEmpty; finally Free; end; end; begin if t_op_bill1.DataSet.IsEmpty then exit; if t_ch_project_fee.IsEmpty then exit; if (op_type.text='1')OR(op_type.text='2') OR (op_type.text='7')then begin if not t_op_ctn.Active then begin t_op_ctn.Parameters[0].value:=t_op_bill1.DataSet.fieldbyname('编号').AsString; t_op_ctn.open; end; end; t_ch_project_fee.first; while not t_ch_project_fee.eof do begin if t_ch_project_fee.FieldByName('标准').asstring<>'箱型'then begin t_ch_fee1.DataSet.Append; t_ch_fee1.DataSet['费用名称']:=t_ch_project_fee.fieldbyname('费用名称').asstring; t_ch_fee1.DataSet['结算单位']:=t_ch_project_fee.fieldbyname('结算单位').asstring; t_ch_fee1.DataSet['币别']:=t_ch_project_fee.fieldbyname('币别').asstring; if t_ch_project_fee.fieldbyname('币别').asstring='RMB' then t_ch_fee1.DataSet['汇率']:=1 else begin if t_ch_project_fee.fieldbyname('汇率').asfloat<>0 then // if t_ch_fee1.DataSet.FieldByName('汇率').AsFloat<>0 then begin t_ch_fee1.DataSet['汇率']:=t_ch_project_fee.fieldbyname('汇率').asfloat; end else begin if not frm_data_share.t_code_currency.Locate('币别',Trim(t_ch_project_fee.fieldbyname('币别').asstring),[])THEN begin showmessage('对不起,费用币别不正确!'); abort; end else begin if not strtobool(get_parameters_value(38,'true')) then begin if t_ch_fee1.DataSet.FieldByName('币别').AsString<>'RMB' then begin if strtobool(get_parameters_value(145,'true')) then begin if op_type.text='1' then t_ch_fee1.DataSet['汇率']:=getUsdExRate(t_ch_fee1.DataSet.datasource.dataset.fieldbyname('开船日期').asstring,t_ch_fee1.DataSet.FieldByName('币别').AsString) else if (op_type.text='2') OR (op_type.text='7') then t_ch_fee1.DataSet['汇率']:=getUsdExRate(t_ch_fee1.DataSet.datasource.dataset.fieldbyname('进口日期').asstring,t_ch_fee1.DataSet.FieldByName('币别').AsString) else if op_type.text='3' then t_ch_fee1.DataSet['汇率']:=getUsdExRate(t_ch_fee1.DataSet.datasource.dataset.fieldbyname('一程开航日期').asstring,t_ch_fee1.DataSet.FieldByName('币别').AsString) else if op_type.text='4' then t_ch_fee1.DataSet['汇率']:=getUsdExRate(t_ch_fee1.DataSet.datasource.dataset.fieldbyname('进口日期').asstring,t_ch_fee1.DataSet.FieldByName('币别').AsString) else if op_type.text='6' then t_ch_fee1.DataSet['汇率']:=getUsdExRate(t_ch_fee1.DataSet.datasource.dataset.fieldbyname('接单日期').asstring,t_ch_fee1.DataSet.FieldByName('币别').AsString); end else begin t_ch_fee1.DataSet['汇率']:=getUsdExRate(t_ch_fee1.DataSet.datasource.dataset.fieldbyname('会计期间').asstring,t_ch_fee1.DataSet.FieldByName('币别').AsString) end; end else t_ch_fee1.DataSet['汇率']:=frm_data_share.t_code_currency.fieldbyname('汇率').asfloat; end; end; end; end; if t_ch_project_fee.fieldbyname('客户名称').asstring=''then begin t_ch_fee1.DataSet['客户名称']:=fee_get_client(t_ch_project_fee.fieldbyname('结算单位').asstring); end else begin t_ch_fee1.DataSet['客户名称']:=t_ch_project_fee.fieldbyname('客户名称').asstring; end; t_ch_fee1.DataSet['标准']:=t_ch_project_fee.fieldbyname('标准').asstring; if t_ch_project_fee.fieldbyname('标准').asstring='单票' then begin t_ch_fee1.DataSet['数量']:=1; end else if t_ch_project_fee.fieldbyname('标准').asstring='重量' then begin if (op_type.text='1')OR(op_type.text='2') OR (op_type.text='7')then begin if s_w(4,t_op_bill1.DataSet.fieldbyname('重量').asfloat/1000)>1 then t_ch_fee1.DataSet['数量']:=s_w(4,t_op_bill1.DataSet.fieldbyname('重量').asfloat/1000) else t_ch_fee1.DataSet['数量']:=1; end else begin t_ch_fee1.DataSet['数量']:=t_op_bill1.DataSet.fieldbyname('重量').asfloat; end; end else if t_ch_project_fee.fieldbyname('标准').asstring='毛重' then begin if (op_type.text='1')OR(op_type.text='2') OR (op_type.text='7')then begin if s_w(4,t_op_bill1.DataSet.fieldbyname('毛重').asfloat/1000)>1 then t_ch_fee1.DataSet['数量']:=s_w(4,t_op_bill1.DataSet.fieldbyname('毛重').asfloat/1000) else t_ch_fee1.DataSet['数量']:=1; end else begin t_ch_fee1.DataSet['数量']:=t_op_bill1.DataSet.fieldbyname('毛重').asfloat; end; end else if t_ch_project_fee.fieldbyname('标准').asstring='尺码' then begin if t_op_bill1.DataSet.fieldbyname('尺码').asfloat>1 then t_ch_fee1.DataSet['数量']:=t_op_bill1.DataSet.fieldbyname('尺码').asfloat else t_ch_fee1.DataSet['数量']:=1;; end else if t_ch_project_fee.fieldbyname('标准').asstring='计费吨' then begin if t_op_bill1.DataSet.fieldbyname('尺码').asfloat>=s_w(4,t_op_bill1.DataSet.fieldbyname('重量').asfloat/1000)then begin if t_op_bill1.DataSet.fieldbyname('尺码').asfloat>1 then t_ch_fee1.DataSet['数量']:=t_op_bill1.DataSet.fieldbyname('尺码').asfloat else t_ch_fee1.DataSet['数量']:=1;; end else begin if s_w(4,t_op_bill1.DataSet.fieldbyname('重量').asfloat/1000)>1 then t_ch_fee1.DataSet['数量']:=s_w(4,t_op_bill1.DataSet.fieldbyname('重量').asfloat/1000) else t_ch_fee1.DataSet['数量']:=1; end; end else if t_ch_project_fee.fieldbyname('标准').asstring='计价重量' then begin t_ch_fee1.DataSet['数量']:=t_op_bill1.DataSet.fieldbyname('计价重量').asfloat; end else if t_ch_project_fee.fieldbyname('标准').asstring='件数' then begin t_ch_fee1.DataSet['数量']:=t_op_bill1.DataSet.fieldbyname('件数').asfloat; end; if (op_type.text='1')OR(op_type.text='2') OR (op_type.text='7')then if t_ch_project_fee.fieldbyname('标准').asstring='TEU' then begin t_ch_fee1.DataSet['数量']:=t_op_bill1.DataSet.fieldbyname('箱TEU').asfloat; end; if not t_ch_project_fee.FieldByName('是否含税').AsBoolean then begin t_ch_fee1.DataSet['不含税价']:=t_ch_project_fee.fieldbyname('单价').asfloat; if t_ch_project_fee.fieldbyname('税率').asfloat>0 then t_ch_fee1.DataSet['税率']:=t_ch_project_fee.fieldbyname('税率').asfloat; if t_ch_project_fee.fieldbyname('财务税率').asfloat>0 then t_ch_fee1.DataSet['财务税率']:=t_ch_project_fee.fieldbyname('财务税率').asfloat; end else begin if t_ch_project_fee.fieldbyname('税率').asfloat>0 then t_ch_fee1.DataSet['税率']:=t_ch_project_fee.fieldbyname('税率').asfloat; t_ch_fee1.DataSet['单价']:=t_ch_project_fee.fieldbyname('单价').asfloat; if t_ch_project_fee.fieldbyname('财务税率').asfloat>0 then t_ch_fee1.DataSet['财务税率']:=t_ch_project_fee.fieldbyname('财务税率').asfloat; end; t_ch_fee1.DataSet.fieldbyname('备注').asstring:=t_ch_project_fee.fieldbyname('费用备注').asstring; t_ch_fee1.DataSet['顺序']:=t_ch_project_fee['顺序']; t_ch_fee1.DataSet.post; end else //箱型 begin if (op_type.text='1')OR(op_type.text='2') OR (op_type.text='7')then begin if t_op_ctn.IsEmpty then begin t_ch_fee1.DataSet.Append; t_ch_fee1.DataSet['费用名称']:=t_ch_project_fee.fieldbyname('费用名称').asstring; t_ch_fee1.DataSet['结算单位']:=t_ch_project_fee.fieldbyname('结算单位').asstring; t_ch_fee1.DataSet['币别']:=t_ch_project_fee.fieldbyname('币别').asstring; if t_ch_project_fee.fieldbyname('币别').asstring='RMB' then t_ch_fee1.DataSet['汇率']:=1 else begin if t_ch_project_fee.fieldbyname('汇率').asfloat<>0 then // if t_ch_fee1.DataSet.FieldByName('汇率').AsFloat<>0 then t_ch_fee1.DataSet['汇率']:=t_ch_project_fee.fieldbyname('汇率').asfloat else begin IF not frm_data_share.t_code_currency.Locate('币别',t_ch_project_fee.fieldbyname('币别').asstring,[])THEN begin showmessage('对不起,费用币别不正确!'); abort; end else begin if not strtobool(get_parameters_value(38,'true')) then begin if t_ch_fee1.DataSet.FieldByName('币别').AsString<>'RMB' then begin if strtobool(get_parameters_value(145,'true')) then begin if op_type.text='1' then t_ch_fee1.DataSet['汇率']:=getUsdExRate(t_ch_fee1.DataSet.datasource.dataset.fieldbyname('开船日期').asstring,t_ch_fee1.DataSet.FieldByName('币别').AsString) else if (op_type.text='2') OR (op_type.text='7') then t_ch_fee1.DataSet['汇率']:=getUsdExRate(t_ch_fee1.DataSet.datasource.dataset.fieldbyname('进口日期').asstring,t_ch_fee1.DataSet.FieldByName('币别').AsString) else if op_type.text='3' then t_ch_fee1.DataSet['汇率']:=getUsdExRate(t_ch_fee1.DataSet.datasource.dataset.fieldbyname('一程开航日期').asstring,t_ch_fee1.DataSet.FieldByName('币别').AsString) else if op_type.text='4' then t_ch_fee1.DataSet['汇率']:=getUsdExRate(t_ch_fee1.DataSet.datasource.dataset.fieldbyname('进口日期').asstring,t_ch_fee1.DataSet.FieldByName('币别').AsString) else if op_type.text='6' then t_ch_fee1.DataSet['汇率']:=getUsdExRate(t_ch_fee1.DataSet.datasource.dataset.fieldbyname('接单日期').asstring,t_ch_fee1.DataSet.FieldByName('币别').AsString); end else begin t_ch_fee1.DataSet['汇率']:=getUsdExRate(t_ch_fee1.DataSet.datasource.dataset.fieldbyname('会计期间').asstring,t_ch_fee1.DataSet.FieldByName('币别').AsString) end; end else t_ch_fee1.DataSet['汇率']:=frm_data_share.t_code_currency.fieldbyname('汇率').asfloat; end; end; end; end; if t_ch_project_fee.fieldbyname('客户名称').asstring=''then begin t_ch_fee1.DataSet['客户名称']:=fee_get_client(t_ch_project_fee.fieldbyname('结算单位').asstring); end else begin t_ch_fee1.DataSet['客户名称']:=t_ch_project_fee.fieldbyname('客户名称').asstring; end; t_ch_fee1.DataSet['数量']:=0; t_ch_fee1.DataSet['不含税价']:=0; if t_ch_project_fee['顺序']<>null then t_ch_fee1.DataSet['顺序']:=t_ch_project_fee['顺序']; t_ch_fee1.DataSet.post; end else //集装箱不为空 begin if t_ch_project_standard.IsEmpty then //方案费用箱型为空 begin t_ch_fee1.DataSet.Append; t_ch_fee1.DataSet['费用名称']:=t_ch_project_fee.fieldbyname('费用名称').asstring; t_ch_fee1.DataSet['结算单位']:=t_ch_project_fee.fieldbyname('结算单位').asstring; t_ch_fee1.DataSet['币别']:=t_ch_project_fee.fieldbyname('币别').asstring; if t_ch_project_fee.fieldbyname('币别').asstring='RMB' then t_ch_fee1.DataSet['汇率']:=1 else begin if t_ch_project_fee.fieldbyname('汇率').asfloat<>0 then // if t_ch_fee1.DataSet.FieldByName('汇率').AsFloat<>0 then t_ch_fee1.DataSet['汇率']:=t_ch_project_fee.fieldbyname('汇率').asfloat else begin IF not frm_data_share.t_code_currency.Locate('币别',t_ch_project_fee.fieldbyname('币别').asstring,[])THEN begin showmessage('对不起,费用币别不正确!'); abort; end else begin if not strtobool(get_parameters_value(38,'true')) then begin if t_ch_fee1.DataSet.FieldByName('币别').AsString<>'RMB' then begin if strtobool(get_parameters_value(145,'true')) then begin if op_type.text='1' then t_ch_fee1.DataSet['汇率']:=getUsdExRate(t_ch_fee1.DataSet.datasource.dataset.fieldbyname('开船日期').asstring,t_ch_fee1.DataSet.FieldByName('币别').AsString) else if (op_type.text='2') OR (op_type.text='7') then t_ch_fee1.DataSet['汇率']:=getUsdExRate(t_ch_fee1.DataSet.datasource.dataset.fieldbyname('进口日期').asstring,t_ch_fee1.DataSet.FieldByName('币别').AsString) else if op_type.text='3' then t_ch_fee1.DataSet['汇率']:=getUsdExRate(t_ch_fee1.DataSet.datasource.dataset.fieldbyname('一程开航日期').asstring,t_ch_fee1.DataSet.FieldByName('币别').AsString) else if op_type.text='4' then t_ch_fee1.DataSet['汇率']:=getUsdExRate(t_ch_fee1.DataSet.datasource.dataset.fieldbyname('进口日期').asstring,t_ch_fee1.DataSet.FieldByName('币别').AsString) else if op_type.text='6' then t_ch_fee1.DataSet['汇率']:=getUsdExRate(t_ch_fee1.DataSet.datasource.dataset.fieldbyname('接单日期').asstring,t_ch_fee1.DataSet.FieldByName('币别').AsString); end else begin t_ch_fee1.DataSet['汇率']:=getUsdExRate(t_ch_fee1.DataSet.datasource.dataset.fieldbyname('会计期间').asstring,t_ch_fee1.DataSet.FieldByName('币别').AsString) end; end else t_ch_fee1.DataSet['汇率']:=frm_data_share.t_code_currency.fieldbyname('汇率').asfloat; end; end; end; end; if t_ch_project_fee.fieldbyname('客户名称').asstring=''then begin t_ch_fee1.DataSet['客户名称']:=fee_get_client(t_ch_project_fee.fieldbyname('结算单位').asstring); end else begin t_ch_fee1.DataSet['客户名称']:=t_ch_project_fee.fieldbyname('客户名称').asstring; end; t_ch_fee1.DataSet['数量']:=0; t_ch_fee1.DataSet['不含税价']:=0; t_ch_fee1.DataSet.post; end else //方案费用箱型不为空 begin // if not GetFeeCodeStd(t_ch_project_fee.fieldbyname('费用名称').asstring) then begin //箱型 t_ch_project_standard.first; while not t_ch_project_standard.eof do begin if t_op_ctn.Locate('代码',t_ch_project_standard.fieldbyname('箱型代码').asstring,[])then begin t_ch_fee1.DataSet.Append; t_ch_fee1.DataSet['费用名称']:=t_ch_project_fee.fieldbyname('费用名称').asstring; t_ch_fee1.DataSet['结算单位']:=t_ch_project_fee.fieldbyname('结算单位').asstring; t_ch_fee1.DataSet['币别']:=t_ch_project_fee.fieldbyname('币别').asstring; if t_ch_project_fee.fieldbyname('币别').asstring='RMB' then t_ch_fee1.DataSet['汇率']:=1 else begin if t_ch_project_fee.fieldbyname('汇率').asfloat<>0 then t_ch_fee1.DataSet['汇率']:=t_ch_project_fee.fieldbyname('汇率').asfloat else begin IF not frm_data_share.t_code_currency.Locate('币别',t_ch_project_fee.fieldbyname('币别').asstring,[])THEN begin showmessage('对不起,费用币别不正确!'); abort; end else begin if not strtobool(get_parameters_value(38,'true')) then begin if t_ch_fee1.DataSet.FieldByName('币别').AsString<>'RMB' then begin if strtobool(get_parameters_value(145,'true')) then begin if op_type.text='1' then t_ch_fee1.DataSet['汇率']:=getUsdExRate(t_ch_fee1.DataSet.datasource.dataset.fieldbyname('开船日期').asstring,t_ch_fee1.DataSet.FieldByName('币别').AsString) else if (op_type.text='2') OR (op_type.text='7') then t_ch_fee1.DataSet['汇率']:=getUsdExRate(t_ch_fee1.DataSet.datasource.dataset.fieldbyname('进口日期').asstring,t_ch_fee1.DataSet.FieldByName('币别').AsString) else if op_type.text='3' then t_ch_fee1.DataSet['汇率']:=getUsdExRate(t_ch_fee1.DataSet.datasource.dataset.fieldbyname('一程开航日期').asstring,t_ch_fee1.DataSet.FieldByName('币别').AsString) else if op_type.text='4' then t_ch_fee1.DataSet['汇率']:=getUsdExRate(t_ch_fee1.DataSet.datasource.dataset.fieldbyname('进口日期').asstring,t_ch_fee1.DataSet.FieldByName('币别').AsString) else if op_type.text='6' then t_ch_fee1.DataSet['汇率']:=getUsdExRate(t_ch_fee1.DataSet.datasource.dataset.fieldbyname('接单日期').asstring,t_ch_fee1.DataSet.FieldByName('币别').AsString); end else begin t_ch_fee1.DataSet['汇率']:=getUsdExRate(t_ch_fee1.DataSet.datasource.dataset.fieldbyname('会计期间').asstring,t_ch_fee1.DataSet.FieldByName('币别').AsString) end; end else t_ch_fee1.DataSet['汇率']:=frm_data_share.t_code_currency.fieldbyname('汇率').asfloat; end; end; end; end; if t_ch_project_fee.fieldbyname('客户名称').asstring=''then begin t_ch_fee1.DataSet['客户名称']:=fee_get_client(t_ch_project_fee.fieldbyname('结算单位').asstring); end else begin t_ch_fee1.DataSet['客户名称']:=t_ch_project_fee.fieldbyname('客户名称').asstring; end; t_ch_fee1.DataSet['标准']:=t_ch_project_standard.fieldbyname('标准').asstring; t_ch_fee1.DataSet['数量']:=t_op_ctn.fieldbyname('数量').asfloat; if not t_ch_project_fee.FieldByName('是否含税').AsBoolean then begin t_ch_fee1.DataSet['不含税价']:=t_ch_project_standard.fieldbyname('单价').asfloat; if t_ch_project_fee.fieldbyname('税率').asfloat>0 then t_ch_fee1.DataSet['税率']:=t_ch_project_fee.fieldbyname('税率').asfloat; if t_ch_project_fee.fieldbyname('财务税率').asfloat>0 then t_ch_fee1.DataSet['财务税率']:=t_ch_project_fee.fieldbyname('财务税率').asfloat; end else begin if t_ch_project_fee.fieldbyname('税率').asfloat>0 then t_ch_fee1.DataSet['税率']:=t_ch_project_fee.fieldbyname('税率').asfloat; t_ch_fee1.DataSet['单价']:=t_ch_project_standard.fieldbyname('单价').asfloat; if t_ch_project_fee.fieldbyname('财务税率').asfloat>0 then t_ch_fee1.DataSet['财务税率']:=t_ch_project_fee.fieldbyname('财务税率').asfloat; end; t_ch_fee1.DataSet.fieldbyname('备注').asstring:=t_ch_project_fee.fieldbyname('费用备注').asstring; t_ch_fee1.DataSet.post; if_do:=true; end; t_ch_project_standard.Next; end; end else //箱量 begin if t_op_ctn.RecordCount<=1 then //只有一个箱型 begin t_ch_project_standard.first; while not t_ch_project_standard.eof do begin if t_op_ctn.Locate('代码',t_ch_project_standard.fieldbyname('箱型代码').asstring,[])then begin t_ch_fee1.DataSet.Append; t_ch_fee1.DataSet['费用名称']:=t_ch_project_fee.fieldbyname('费用名称').asstring; t_ch_fee1.DataSet['结算单位']:=t_ch_project_fee.fieldbyname('结算单位').asstring; t_ch_fee1.DataSet['币别']:=t_ch_project_fee.fieldbyname('币别').asstring; if t_ch_project_fee.fieldbyname('币别').asstring='RMB' then t_ch_fee1.DataSet['汇率']:=1 else begin if t_ch_project_fee.fieldbyname('汇率').asfloat<>0 then t_ch_fee1.DataSet['汇率']:=t_ch_project_fee.fieldbyname('汇率').asfloat else begin IF not frm_data_share.t_code_currency.Locate('币别',t_ch_project_fee.fieldbyname('币别').asstring,[])THEN begin showmessage('对不起,费用币别不正确!'); abort; end else begin if not strtobool(get_parameters_value(38,'true')) then begin if t_ch_fee1.DataSet.FieldByName('币别').AsString<>'RMB' then begin if strtobool(get_parameters_value(145,'true')) then begin if op_type.text='1' then t_ch_fee1.DataSet['汇率']:=getUsdExRate(t_ch_fee1.DataSet.datasource.dataset.fieldbyname('开船日期').asstring,t_ch_fee1.DataSet.FieldByName('币别').AsString) else if (op_type.text='2') OR (op_type.text='7') then t_ch_fee1.DataSet['汇率']:=getUsdExRate(t_ch_fee1.DataSet.datasource.dataset.fieldbyname('进口日期').asstring,t_ch_fee1.DataSet.FieldByName('币别').AsString) else if op_type.text='3' then t_ch_fee1.DataSet['汇率']:=getUsdExRate(t_ch_fee1.DataSet.datasource.dataset.fieldbyname('一程开航日期').asstring,t_ch_fee1.DataSet.FieldByName('币别').AsString) else if op_type.text='4' then t_ch_fee1.DataSet['汇率']:=getUsdExRate(t_ch_fee1.DataSet.datasource.dataset.fieldbyname('进口日期').asstring,t_ch_fee1.DataSet.FieldByName('币别').AsString) else if op_type.text='6' then t_ch_fee1.DataSet['汇率']:=getUsdExRate(t_ch_fee1.DataSet.datasource.dataset.fieldbyname('接单日期').asstring,t_ch_fee1.DataSet.FieldByName('币别').AsString); end else begin t_ch_fee1.DataSet['汇率']:=getUsdExRate(t_ch_fee1.DataSet.datasource.dataset.fieldbyname('会计期间').asstring,t_ch_fee1.DataSet.FieldByName('币别').AsString) end; end else t_ch_fee1.DataSet['汇率']:=frm_data_share.t_code_currency.fieldbyname('汇率').asfloat; end; end; end; end; if t_ch_project_fee.fieldbyname('客户名称').asstring=''then begin t_ch_fee1.DataSet['客户名称']:=fee_get_client(t_ch_project_fee.fieldbyname('结算单位').asstring); end else begin t_ch_fee1.DataSet['客户名称']:=t_ch_project_fee.fieldbyname('客户名称').asstring; end; t_ch_fee1.DataSet['标准']:=t_ch_project_standard.fieldbyname('标准').asstring; t_ch_fee1.DataSet['数量']:=t_op_ctn.fieldbyname('数量').asfloat; if not t_ch_project_fee.FieldByName('是否含税').AsBoolean then begin t_ch_fee1.DataSet['不含税价']:=t_ch_project_standard.fieldbyname('单价').asfloat; if t_ch_project_fee.fieldbyname('税率').asfloat>0 then t_ch_fee1.DataSet['税率']:=t_ch_project_fee.fieldbyname('税率').asfloat; if t_ch_project_fee.fieldbyname('财务税率').asfloat>0 then t_ch_fee1.DataSet['财务税率']:=t_ch_project_fee.fieldbyname('财务税率').asfloat; end else begin if t_ch_project_fee.fieldbyname('税率').asfloat>0 then t_ch_fee1.DataSet['税率']:=t_ch_project_fee.fieldbyname('税率').asfloat; t_ch_fee1.DataSet['单价']:=t_ch_project_standard.fieldbyname('单价').asfloat; if t_ch_project_fee.fieldbyname('财务税率').asfloat>0 then t_ch_fee1.DataSet['财务税率']:=t_ch_project_fee.fieldbyname('财务税率').asfloat; end; t_ch_fee1.DataSet.fieldbyname('备注').asstring:=t_ch_project_fee.fieldbyname('费用备注').asstring; t_ch_fee1.DataSet.post; if_do:=true; end; t_ch_project_standard.Next; end; end else //多个箱型 begin s_bz:=''; CorpsName:=''; price:=0; Exrate:=1; t_ch_project_standard.first; while not t_ch_project_standard.eof do begin if t_op_ctn.Locate('代码',t_ch_project_standard.fieldbyname('箱型代码').asstring,[])then begin price:=price+t_ch_project_standard.fieldbyname('单价').asfloat*t_op_ctn.fieldbyname('数量').asfloat; if trim(s_bz)='' then s_bz:=t_op_ctn.fieldbyname('数量').AsString+'*'+t_ch_project_standard.fieldbyname('单价').AsString else s_bz:=s_bz+' '+t_op_ctn.fieldbyname('数量').AsString+'*'+t_ch_project_standard.fieldbyname('单价').AsString; if t_ch_project_fee.fieldbyname('币别').asstring='RMB' then Exrate:=1 else begin if Exrate<>0 then Exrate:=t_ch_project_fee.fieldbyname('汇率').asfloat else begin IF not frm_data_share.t_code_currency.Locate('币别',t_ch_project_fee.fieldbyname('币别').asstring,[])THEN begin showmessage('对不起,费用币别不正确!'); abort; end else begin if not strtobool(get_parameters_value(38,'true')) then begin if t_ch_project_fee.FieldByName('币别').AsString<>'RMB' then begin if strtobool(get_parameters_value(145,'true')) then begin if op_type.text='1' then Exrate:=getUsdExRate(t_ch_fee1.DataSet.datasource.dataset.fieldbyname('开船日期').asstring,t_ch_project_fee.FieldByName('币别').AsString) else if (op_type.text='2') OR (op_type.text='7') then Exrate:=getUsdExRate(t_ch_fee1.DataSet.datasource.dataset.fieldbyname('进口日期').asstring,t_ch_project_fee.FieldByName('币别').AsString) else if op_type.text='3' then Exrate:=getUsdExRate(t_ch_fee1.DataSet.datasource.dataset.fieldbyname('一程开航日期').asstring,t_ch_project_fee.FieldByName('币别').AsString) else if op_type.text='4' then Exrate:=getUsdExRate(t_ch_fee1.DataSet.datasource.dataset.fieldbyname('进口日期').asstring,t_ch_project_fee.FieldByName('币别').AsString) else if op_type.text='6' then Exrate:=getUsdExRate(t_ch_fee1.DataSet.datasource.dataset.fieldbyname('接单日期').asstring,t_ch_project_fee.FieldByName('币别').AsString); end else begin Exrate:=getUsdExRate(t_ch_fee1.DataSet.datasource.dataset.fieldbyname('会计期间').asstring,t_ch_project_fee.FieldByName('币别').AsString) end; end else Exrate:=frm_data_share.t_code_currency.fieldbyname('汇率').asfloat; end; end; end; end; if t_ch_project_fee.fieldbyname('客户名称').asstring=''then begin CorpsName:=fee_get_client(t_ch_project_fee.fieldbyname('结算单位').asstring); end else begin CorpsName:=t_ch_project_fee.fieldbyname('客户名称').asstring; end; if_do:=true; end; t_ch_project_standard.Next; end; if Trim(s_bz)<>'' then begin t_ch_fee1.DataSet.Append; t_ch_fee1.DataSet['费用名称']:=t_ch_project_fee.fieldbyname('费用名称').asstring; t_ch_fee1.DataSet['结算单位']:=t_ch_project_fee.fieldbyname('结算单位').asstring; t_ch_fee1.DataSet['客户名称']:=CorpsName; t_ch_fee1.DataSet['币别']:=t_ch_project_fee.fieldbyname('币别').asstring; t_ch_fee1.DataSet['标准']:=s_bz; t_ch_fee1.DataSet['汇率']:=Exrate; t_ch_fee1.DataSet['数量']:=1; if not t_ch_project_fee.FieldByName('是否含税').AsBoolean then begin t_ch_fee1.DataSet['不含税价']:=price; if t_ch_project_fee.fieldbyname('税率').asfloat>0 then t_ch_fee1.DataSet['税率']:=t_ch_project_fee.fieldbyname('税率').asfloat; if t_ch_project_fee.fieldbyname('财务税率').asfloat>0 then t_ch_fee1.DataSet['财务税率']:=t_ch_project_fee.fieldbyname('财务税率').asfloat; end else begin if t_ch_project_fee.fieldbyname('税率').asfloat>0 then t_ch_fee1.DataSet['税率']:=t_ch_project_fee.fieldbyname('税率').asfloat; t_ch_fee1.DataSet['单价']:=price; if t_ch_project_fee.fieldbyname('财务税率').asfloat>0 then t_ch_fee1.DataSet['财务税率']:=t_ch_project_fee.fieldbyname('财务税率').asfloat; end; t_ch_fee1.DataSet.fieldbyname('备注').asstring:=t_ch_project_fee.fieldbyname('费用备注').asstring; t_ch_fee1.DataSet.post; end; end; end; if not if_do then begin t_ch_fee1.DataSet.Append; t_ch_fee1.DataSet['费用名称']:=t_ch_project_fee.fieldbyname('费用名称').asstring; t_ch_fee1.DataSet['结算单位']:=t_ch_project_fee.fieldbyname('结算单位').asstring; t_ch_fee1.DataSet['币别']:=t_ch_project_fee.fieldbyname('币别').asstring; if t_ch_project_fee.fieldbyname('币别').asstring='RMB' then t_ch_fee1.DataSet['汇率']:=1 else begin if t_ch_project_fee.fieldbyname('汇率').asfloat<>0 then // if t_ch_fee1.DataSet.FieldByName('汇率').AsFloat<>0 then t_ch_fee1.DataSet['汇率']:=t_ch_project_fee.fieldbyname('汇率').asfloat else begin IF not frm_data_share.t_code_currency.Locate('币别',t_ch_project_fee.fieldbyname('币别').asstring,[])THEN begin showmessage('对不起,费用币别不正确!'); abort; end else begin if not strtobool(get_parameters_value(38,'true')) then begin if t_ch_fee1.DataSet.FieldByName('币别').AsString<>'RMB' then begin if strtobool(get_parameters_value(145,'true')) then begin if op_type.text='1' then t_ch_fee1.DataSet['汇率']:=getUsdExRate(t_ch_fee1.DataSet.datasource.dataset.fieldbyname('开船日期').asstring,t_ch_fee1.DataSet.FieldByName('币别').AsString) else if (op_type.text='2') OR (op_type.text='7') then t_ch_fee1.DataSet['汇率']:=getUsdExRate(t_ch_fee1.DataSet.datasource.dataset.fieldbyname('进口日期').asstring,t_ch_fee1.DataSet.FieldByName('币别').AsString) else if op_type.text='3' then t_ch_fee1.DataSet['汇率']:=getUsdExRate(t_ch_fee1.DataSet.datasource.dataset.fieldbyname('一程开航日期').asstring,t_ch_fee1.DataSet.FieldByName('币别').AsString) else if op_type.text='4' then t_ch_fee1.DataSet['汇率']:=getUsdExRate(t_ch_fee1.DataSet.datasource.dataset.fieldbyname('进口日期').asstring,t_ch_fee1.DataSet.FieldByName('币别').AsString) else if op_type.text='6' then t_ch_fee1.DataSet['汇率']:=getUsdExRate(t_ch_fee1.DataSet.datasource.dataset.fieldbyname('接单日期').asstring,t_ch_fee1.DataSet.FieldByName('币别').AsString); end else begin t_ch_fee1.DataSet['汇率']:=getUsdExRate(t_ch_fee1.DataSet.datasource.dataset.fieldbyname('会计期间').asstring,t_ch_fee1.DataSet.FieldByName('币别').AsString) end; end else t_ch_fee1.DataSet['汇率']:=frm_data_share.t_code_currency.fieldbyname('汇率').asfloat; end; end; end; end; if t_ch_project_fee.fieldbyname('客户名称').asstring=''then begin t_ch_fee1.DataSet['客户名称']:=fee_get_client(t_ch_project_fee.fieldbyname('结算单位').asstring); end else begin t_ch_fee1.DataSet['客户名称']:=t_ch_project_fee.fieldbyname('客户名称').asstring; end; t_ch_fee1.DataSet['数量']:=0; t_ch_fee1.DataSet['不含税价']:=0; if t_ch_project_fee['顺序']<>null then t_ch_fee1.DataSet['顺序']:=t_ch_project_fee['顺序']; t_ch_fee1.DataSet.post; end; end; end; end; end; t_ch_project_fee.next; end; close; end; procedure Tfrm_code_fee_project_add.DBEdit1Change(Sender: TObject); begin if DBEdit1.Text<>'箱型' then begin dxDBGrid3.Visible:=false; end else begin dxDBGrid3.Visible:=true; end; end; end.