unit u_code_fee_cargomainfest_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_cargomainfest_add = class(TForm) t_ch_project: TADOQuery; t_ch_project1: TDataSource; t_ch_project_fee: TADOQuery; t_ch_project_fee1: TDataSource; dxDBGrid1: TdxDBGrid; dxDBGrid1Column1: TdxDBGridMaskColumn; dxDBGrid1Column2: TdxDBGridMaskColumn; dxDBGrid1Column3: TdxDBGridDateColumn; dxDBGrid1Column4: TdxDBGridMaskColumn; bsBusinessSkinForm1: TbsBusinessSkinForm; Panel1: TPanel; dxDBGrid2: TdxDBGrid; dxDBGrid2Column1: TdxDBGridMaskColumn; dxDBGrid2Column2: TdxDBGridMaskColumn; dxDBGrid2Column3: TdxDBGridMaskColumn; bsSkinPanel1: TbsSkinPanel; bsSkinButton3: TbsSkinButton; bsSkinButton2: TbsSkinButton; op_type: TEdit; t_op_bill1: TDataSource; t_ch_fee1: TDataSource; dxDBGrid2Column7: TdxDBGridColumn; dxDBGrid2Column5: TdxDBGridColumn; t_op_fenzhang1: TDataSource; procedure bsSkinButton2Click(Sender: TObject); procedure FormShow(Sender: TObject); procedure bsSkinButton3Click(Sender: TObject); function fee_get_num:real; private { Private declarations } public { Public declarations } end; var frm_code_fee_cargomainfest_add: Tfrm_code_fee_cargomainfest_add; implementation uses u_main, my_sys_function; {$R *.dfm} function Tfrm_code_fee_cargomainfest_add.fee_get_num:real; begin ; end; procedure Tfrm_code_fee_cargomainfest_add.bsSkinButton2Click(Sender: TObject); begin close; end; procedure Tfrm_code_fee_cargomainfest_add.FormShow(Sender: TObject); begin t_ch_project.SQL.clear; t_ch_project.sql.add('select * from t_ch_project_cargomainfest '); t_ch_project.SQL.Add(' where 1=1'); if op_type.text='1'then begin t_ch_project.sql.add(' and 业务种类='+''''+'海运出口'+''''); end; if op_type.text='2'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; t_ch_project.sql.add(' order by 方案名称'); t_ch_project.open; t_ch_project_fee.open; end; procedure Tfrm_code_fee_cargomainfest_add.bsSkinButton3Click(Sender: TObject); var i:real; if_do:boolean; aQuery:TADOQuery; j:integer; begin if t_op_bill1.DataSet.IsEmpty then exit; if t_ch_project_fee.IsEmpty then exit; if t_ch_project.IsEmpty then exit; t_op_fenzhang1.DataSet.Edit; t_op_fenzhang1.DataSet['结算代理']:=t_ch_project['结算代理']; t_op_fenzhang1.DataSet['费用名称']:=t_ch_project['费用名称']; t_op_fenzhang1.DataSet['币别']:=t_ch_project['币别']; t_op_fenzhang1.DataSet['OT币别']:=t_ch_project['OT币别']; t_op_fenzhang1.DataSet['方案代码']:=t_ch_project['方案代码']; t_op_fenzhang1.DataSet.post; aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; if t_op_bill1.DataSet.FieldByName('装运方式').AsString='拼箱主票' then begin sql.Add('select * from t_op_seae where 主编号='''+t_op_bill1.DataSet.fieldByName('编号').AsString+''' and 主编号<>编号 and 编号 not in (select 分票编号 from t_ch_fee_cargomainfast where 编号='''+t_op_bill1.DataSet.fieldByName('编号').AsString+''') order by 分提单号'); end else begin sql.Add('select * from t_op_seae where 主编号='''+t_op_bill1.DataSet.fieldByName('编号').AsString+''' and 编号 not in (select 分票编号 from t_ch_fee_cargomainfast where 编号='''+t_op_bill1.DataSet.fieldByName('编号').AsString+''') order by 分提单号'); end; Open; end; j:=1; aQuery.first; while not aQuery.eof do begin t_ch_fee1.DataSet.Append; t_ch_fee1.DataSet['序号']:=j; j:=j+1; t_ch_fee1.DataSet['模板名称']:=t_ch_project_fee.fieldbyname('方案代码').asstring; t_ch_fee1.DataSet['编号']:=t_op_bill1.DataSet['编号']; t_ch_fee1.DataSet['分票编号']:=aQuery['编号']; if aQuery.FieldByName('签单方式').AsString='电放' then t_ch_fee1.DataSet['是否电放']:=1 else t_ch_fee1.DataSet['是否电放']:=0; t_ch_fee1.DataSet['发货人']:=aQuery['发货人代码']; t_ch_fee1.DataSet['收货人']:=aQuery['收货人代码']; t_ch_fee1.DataSet['主提单号']:=aQuery['主提单号']; t_ch_fee1.DataSet['分提单号']:=aQuery['分提单号']; t_ch_fee1.DataSet['付费方式']:=aQuery['付费方式']; t_ch_fee1.DataSet['件数']:=aQuery['件数']; t_ch_fee1.DataSet['包装']:=aQuery['包装']; t_ch_fee1.DataSet['唛头']:=aQuery['唛头']; t_ch_fee1.DataSet['重量']:=aQuery['重量']; t_ch_fee1.DataSet['尺码']:=aQuery['尺码']; t_ch_fee1.DataSet['货物描述']:=aQuery['货物描述']; t_ch_fee1.DataSet['是否生成']:=0; if s_w(4,aQuery.fieldbyname('重量').asfloat/1000)>aQuery.fieldbyname('尺码').asfloat then begin if s_w(4,aQuery.fieldbyname('重量').asfloat/1000)>1 then t_ch_fee1.DataSet['计费吨']:=s_w(4,aQuery.fieldbyname('重量').asfloat/1000) else t_ch_fee1.DataSet['计费吨']:=1; end else begin if aQuery.fieldbyname('尺码').asfloat>1 then t_ch_fee1.DataSet['计费吨']:=aQuery.fieldbyname('尺码').asfloat else t_ch_fee1.DataSet['计费吨']:=1; end; t_ch_fee1.DataSet['CFSCHARGE']:=0; t_ch_fee1.DataSet['CHC']:=0; t_ch_fee1.DataSet['DOFEE']:=0; t_ch_fee1.DataSet['YASEBS']:=0; t_ch_fee1.DataSet['SYSTEMCHARGE']:=0; t_ch_fee1.DataSet['OCEANHT']:=0; t_ch_fee1.DataSet['RECFSCHARGE']:=0; t_ch_fee1.DataSet['RECHC']:=0; t_ch_fee1.DataSet['REDOFEE']:=0; t_ch_fee1.DataSet['REYASEBS']:=0; t_ch_fee1.DataSet['RESYSTEMCHARGE']:=0; t_ch_fee1.DataSet['REOCEANHT']:=0; t_ch_fee1.DataSet['REFUNDCBM']:=0; t_ch_fee1.DataSet['REFUNDBL']:=0; t_ch_fee1.DataSet['合计']:=0; t_ch_fee1.DataSet['OT合计']:=0; t_ch_fee1.DataSet['OTFEE1']:=0; t_ch_fee1.DataSet['OTFEE2']:=0; t_ch_fee1.DataSet['OTFEE3']:=0; t_ch_fee1.DataSet['OTFEE4']:=0; t_ch_fee1.DataSet['OTFEE5']:=0; t_ch_fee1.DataSet['OTFEE6']:=0; t_ch_fee1.DataSet['OTFEE7']:=0; t_ch_fee1.DataSet['OTFEE8']:=0; t_ch_project_fee.first; while not t_ch_project_fee.eof do begin if t_ch_project_fee.FieldByName('字段名').AsString<>'' then begin if t_ch_fee1.DataSet.FindField(trim(t_ch_project_fee.FieldByName('字段名').AsString))<>nil then begin if trim(t_ch_project_fee.FieldByName('字段类型').AsString)='默认' then begin t_ch_fee1.DataSet[t_ch_project_fee.FieldByName('字段名').AsString]:=t_ch_project_fee['默认值']; end; end; end; t_ch_project_fee.Next; end; t_ch_fee1.DataSet.post; aQuery.next; end; finally FreeAndNil(aQuery); end; close; end; end.