unit u_op_seae_web_add; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, BusinessSkinForm, bsSkinCtrls, StdCtrls, wwdbdatetimepicker, DB, RxLookup,adodb, Mask, DBCtrlsEh,inifiles, DBCtrls; type Tfrm_op_seae_web_add = class(TForm) bsBusinessSkinForm1: TbsBusinessSkinForm; bsSkinGroupBox1: TbsSkinGroupBox; Label1: TLabel; wwDBDateTimePicker1: TwwDBDateTimePicker; bsSkinButton2: TbsSkinButton; data1: TDataSource; Label16: TLabel; Label42: TLabel; RxDBLookupCombo30: TRxDBLookupCombo; Label17: TLabel; data2: TDataSource; data3: TDataSource; data4: TDataSource; RxDBLookupCombo1: TRxDBLookupCombo; Label2: TLabel; bsSkinCheckRadioBox1: TbsSkinCheckRadioBox; ADOQuery1: TADOQuery; data7: TDataSource; Data8: TDataSource; t_sys_employee: TADOQuery; t_sys_employee1: TDataSource; t_sys_employee2: TADOQuery; t_sys_employee21: TDataSource; RxDBLookupCombo12: TRxDBLookupCombo; RxDBLookupCombo2: TRxDBLookupCombo; bsSkinButton1: TbsSkinButton; procedure FormShow(Sender: TObject); procedure bsSkinButton2Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure RxDBLookupCombo30Change(Sender: TObject); procedure RxDBLookupCombo12Enter(Sender: TObject); procedure RxDBLookupCombo12Exit(Sender: TObject); procedure RxDBLookupCombo1Change(Sender: TObject); procedure RxDBLookupCombo12Change(Sender: TObject); procedure RxDBLookupCombo2Change(Sender: TObject); procedure bsSkinButton1Click(Sender: TObject); private { Private declarations } public { Public declarations } function GetLoadPortEdiID(Port:String): String; function GetPortEdiID(Port:String): String; function GetDeptname(Port:String): String; function checkctn(aOR_ID:integer):Boolean; end; var frm_op_seae_web_add: Tfrm_op_seae_web_add; frm_op_seae_add_num:integer; implementation uses u_main, my_sys_function, u_data_share; {$R *.dfm} function Tfrm_op_seae_web_add.GetLoadPortEdiID(Port:String): String; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add('Select EDI代码 from t_code_loaport where 英文名='''+Port+''''); Open; if not IsEmpty then Result:=Trim(FieldByName('EDI代码').asstring) else Result:=''; end; finally FreeAndNil(aQuery); end; end; function Tfrm_op_seae_web_add.GetPortEdiID(Port:String): String; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add('Select EDI代码 from t_code_disport where 英文名='''+Port+''''); Open; if not IsEmpty then Result:=Trim(FieldByName('EDI代码').asstring) else Result:=''; end; finally FreeAndNil(aQuery); end; end; procedure Tfrm_op_seae_web_add.bsSkinButton2Click(Sender: TObject); begin close; end; procedure Tfrm_op_seae_web_add.FormShow(Sender: TObject); var inifile1:Tinifile; begin t_sys_employee.Open; t_sys_employee2.Open; inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini'); RxDBLookupCombo12.Value:=inifile1.ReadString('seaeweborder','op',''); RxDBLookupCombo30.DisplayValue:=inifile1.ReadString('seaeweborder','opdept',''); RxDBLookupCombo2.Value:=inifile1.ReadString('seaeweborder','kf',''); RxDBLookupCombo1.DisplayValue:=inifile1.ReadString('seaeweborder','kfdept',''); bsSkinCheckRadioBox1.Checked:=inifile1.Readbool('seaeweborder','savecheck',true); inifile1.free; wwDBDateTimePicker1.Date:=date; end; function Tfrm_op_seae_web_add.checkctn(aOR_ID:integer):Boolean; var aQuery:TAdoQuery; begin Result:=True; aQuery:=CreateAdoQuery; with aQuery do begin close;sql.clear; sql.Add('select a.表现形式 as opor表现 ,b.表现形式 from t_opor_ctn a inner join t_code_ctn b on a.代码=b.代码 where a.OR_ID='+inttostr(aOR_ID)); open; end; aQuery.First; while not aQuery.Eof do begin if aQuery.FieldByName('opor表现').AsString<> aQuery.FieldByName('表现形式').AsString then begin Result:=False; Break; end; aQuery.Next; end; end; procedure Tfrm_op_seae_web_add.FormClose(Sender: TObject; var Action: TCloseAction); var inifile1:Tinifile; begin if bsSkinCheckRadioBox1.Checked then begin inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini'); inifile1.WriteString('seaeweborder','op',RxDBLookupCombo12.DisplayValue); inifile1.WriteString('seaeweborder','opdept',RxDBLookupCombo30.DisplayValue); inifile1.WriteString('seaeweborder','kf',RxDBLookupCombo2.DisplayValue); inifile1.WriteString('seaeweborder','kfdept',RxDBLookupCombo1.DisplayValue); inifile1.Writebool('seaeweborder','savecheck',bsSkinCheckRadioBox1.Checked); inifile1.free; end; end; procedure Tfrm_op_seae_web_add.RxDBLookupCombo30Change(Sender: TObject); begin if (RxDBLookupCombo30.DisplayValue<>'') then begin t_sys_employee.Close; t_sys_employee.sql.Clear; t_sys_employee.SQL.Add('select * from t_sys_employee where 部门名称='''+RxDBLookupCombo30.DisplayValue+''''); t_sys_employee.Open; end; end; procedure Tfrm_op_seae_web_add.RxDBLookupCombo12Enter(Sender: TObject); begin TRxDBLookupCombo(Sender).LookupDisplay:='代码;姓名' end; procedure Tfrm_op_seae_web_add.RxDBLookupCombo12Exit(Sender: TObject); begin // TRxDBLookupCombo(Sender).LookupDisplay:='姓名' end; procedure Tfrm_op_seae_web_add.RxDBLookupCombo1Change(Sender: TObject); begin if (RxDBLookupCombo1.DisplayValue<>'') then begin t_sys_employee2.Close; t_sys_employee2.sql.Clear; t_sys_employee2.SQL.Add('select * from t_sys_employee where 部门名称='''+RxDBLookupCombo1.DisplayValue+''''); t_sys_employee2.Open; end; end; procedure Tfrm_op_seae_web_add.RxDBLookupCombo12Change(Sender: TObject); begin RxDBLookupCombo30.DisplayValue:=t_sys_employee['部门名称']; end; procedure Tfrm_op_seae_web_add.RxDBLookupCombo2Change(Sender: TObject); begin RxDBLookupCombo1.DisplayValue:=t_sys_employee2['部门名称']; end; function Tfrm_op_seae_web_add.GetDeptname(Port: String): String; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add('Select 部门名称 from t_sys_employee where 姓名='''+Port+''''); Open; if not IsEmpty then Result:=Trim(FieldByName('部门名称').asstring) else Result:=''; end; finally FreeAndNil(aQuery); end; end; procedure Tfrm_op_seae_web_add.bsSkinButton1Click(Sender: TObject); var i: Integer; bsno,ywno:String; aQuery:TAdoQuery; begin if (RxDBLookupCombo12.DisplayValue='') or (wwDBDateTimePicker1.text='') then begin MessageDlg('操作员和会计期间不能为空!', mtConfirmation, [mbYes],0); exit; end; frm_main.db.BeginTrans; try if not data1.DataSet.Active then data1.DataSet.Open; //主表 if not data3.DataSet.Active then data3.DataSet.Open; // if not data4.DataSet.Active then data4.DataSet.Open; data1.DataSet.Insert; bsno:=get_id; data1.DataSet.FieldByName('编号').AsString:=bsno; data1.DataSet.FieldByName('装运方式').AsString:='整箱'; data1.DataSet.FieldByName('会计期间').Value:=wwDBDateTimePicker1.date; data1.DataSet.FieldByName('周次').AsInteger:=WeekofYear(wwDBDateTimePicker1.date); data1.DataSet.FieldByName('录入人').AsString:=employee; data1.DataSet.FieldByName('录入日期').Value:=date; data1.DataSet.FieldByName('操作员').AsString:=RxDBLookupCombo12.Value; // data1.DataSet['报关操作']:=employee; data1.DataSet.FieldByName('揽货人').AsString:=data2.DataSet.FieldByName('SALEID').AsString; data1.DataSet.FieldByName('客服员').AsString:=RxDBLookupCombo2.Value; data1.DataSet.FieldByName('销售部门').AsString:=GetDeptname(data2.DataSet.FieldByName('SALEID').AsString); data1.DataSet.FieldByName('操作部门').AsString:=RxDBLookupCombo30.DisplayValue; data1.DataSet.FieldByName('委托单位').AsString:=data2.DataSet.FieldByName('委托单位').AsString; data1.DataSet.FieldByName('船公司').AsString:=data2.DataSet.FieldByName('CARRIER').AsString; ywno:=get_no(wwDBDateTimePicker1.date,getbsno(Logininfo.SeaExpBsNo,'SE')); data1.DataSet.FieldByName('业务编号').AsString:=ywno; data1.DataSet.FieldByName('主编号').AsString:=bsno; data1.DataSet.FieldByName('委托编号').AsString:=Data2.DataSet.FieldByName('ORDERNO').AsString; data1.DataSet.FieldByName('主提单标准').AsString:=bsno; data1.DataSet.FieldByName('分提单标准').AsString:=bsno; data1.DataSet.FieldByName('委托标准').AsString:=bsno; data1.DataSet.FieldByName('报关标准').AsString:=bsno; data1.DataSet.FieldByName('报检标准').AsString:=bsno; data1.DataSet.FieldByName('核销标准').AsString:=bsno; data1.DataSet.FieldByName('计费标准').AsString:=''; data1.DataSet.FieldByName('业务状态').AsString:='接受委托'; data1.DataSet.FieldByName('封帐前状态').AsString:='接受委托'; data1.DataSet.FieldByName('费用状态').AsString:='录入状态'; data1.DataSet.FieldByName('业务类型').AsString:='普通货'; data1.DataSet.FieldByName('装货港').AsString:=data2.DataSet.FieldByName('PORTLOAD').AsString; data1.DataSet.FieldByName('装港代码').AsString:=data2.DataSet.FieldByName('PORTLOADID').AsString; //////?????? data1.DataSet.FieldByName('提单份数').AsString:=data2.DataSet.FieldByName('NOBILL').AsString; data1.DataSet.FieldByName('运输条款').AsString:=data2.DataSet.FieldByName('SERVICE').AsString; data1.DataSet.FieldByName('唛头').AsString:=data2.DataSet.FieldByName('MARKS').AsString; data1.DataSet.FieldByName('货物描述').AsString:=data2.DataSet.FieldByName('DESCRIPTION').AsString; data1.DataSet.FieldByName('发货人代码').AsString:=data2.DataSet.FieldByName('SHIPPER').AsString; data1.DataSet.FieldByName('收货人代码').AsString:=data2.DataSet.FieldByName('CONSIGNEE').AsString; data1.DataSet.FieldByName('通知人代码').AsString:=data2.DataSet.FieldByName('NOTIFYPARTY').AsString; data1.DataSet.FieldByName('付费方式').AsString:=data2.DataSet.FieldByName('BLFRT').AsString; data1.DataSet.FieldByName('签单地点').AsString:=data2.DataSet.FieldByName('ISSUEPLACE').AsString; data1.DataSet.FieldByName('件数包装').AsString:=data2.DataSet.FieldByName('PKGS').AsString+data2.DataSet.FieldByName('KINDPKGS').AsString; data1.DataSet.FieldByName('货物重量').AsString:=data2.DataSet.FieldByName('KGS').AsString+'KGS'; data1.DataSet.FieldByName('货物尺码').AsString:=data2.DataSet.FieldByName('CBM').AsString+'CBM'; data1.DataSet.FieldByName('件数').AsInteger:=data2.DataSet.FieldByName('PKGS').AsInteger; data1.DataSet.FieldByName('包装').AsString:=data2.DataSet.FieldByName('KINDPKGS').AsString; data1.DataSet.FieldByName('重量').AsFloat:=data2.DataSet.FieldByName('KGS').AsFloat; data1.DataSet.FieldByName('尺码').AsFloat:=data2.DataSet.FieldByName('CBM').AsFloat; data1.DataSet.FieldByName('件数大写').AsString:='SAY:'+ntoc(data2.DataSet.FieldByName('PKGS').asfloat,true) +data2.DataSet.FieldByName('KINDPKGS').asstring+' ONLY.'; data1.DataSet.FieldByName('危险品分类').AsString:=data2.DataSet.FieldByName('DCLASS').AsString; data1.DataSet.FieldByName('危险品编号').AsString:=data2.DataSet.FieldByName('DUNNO').AsString; data1.DataSet.FieldByName('运费协议号').AsString:=data2.DataSet.FieldByName('SERVICECONTRACTNO').AsString; data1.DataSet.FieldByName('船名').AsString:=data2.DataSet.FieldByName('VESSEL').AsString; data1.DataSet.FieldByName('航次').AsString:=data2.DataSet.FieldByName('VOYNO').AsString; data1.DataSet.FieldByName('开船日期').Value:=data2.DataSet.FieldByName('ETD').Value; data1.DataSet.FieldByName('卸货港').AsString:=data2.DataSet.FieldByName('PORTDISCHARGE').AsString; data1.DataSet.FieldByName('卸货代码').AsString:=data2.DataSet.FieldByName('PORTDISCHARGEID').AsString; data1.DataSet.FieldByName('目的地').AsString:=data2.DataSet.FieldByName('DESTINATION').AsString; data1.DataSet.FieldByName('目的地代码').AsString:=data2.DataSet.FieldByName('DESTINATIONID').AsString; data1.DataSet.FieldByName('集装箱').AsString:=data2.DataSet.FieldByName('CNTRTOTAL').AsString; data1.DataSet.FieldByName('销售订舱说明').AsString:=data2.DataSet.FieldByName('REMARK').AsString; data1.DataSet.FieldByName('预付地点').AsString:=data2.DataSet.FieldByName('PREPARDAT').AsString; data1.DataSet.FieldByName('退税日期').Value:=null; data1.DataSet.FieldByName('签单日期').Value:=null; data1.DataSet.FieldByName('派车日期').Value:=null; data1.DataSet.FieldByName('寄单日期').Value:=null; data1.DataSet.FieldByName('是否寄单').Value:=0; data1.DataSet.FieldByName('是否退税').Value:=0; data1.DataSet.FieldByName('是否通关').Value:=0; data1.DataSet.FieldByName('是否签单').Value:=0; data1.DataSet.FieldByName('请求派车').Value:=0; data1.DataSet.FieldByName('是否派车').Value:=0; data1.DataSet.FieldByName('是否解锁').Value:=0; data1.DataSet.FieldByName('解锁日期').Value:=null; data1.DataSet.FieldByName('解锁人').Value:=''; data1.DataSet.FieldByName('应收陆运').Value:=0; data1.DataSet.FieldByName('应付陆运').Value:=0; data1.DataSet.FieldByName('陆运利润').Value:=0; data1.DataSet.FieldByName('财务').Value:=0; data1.DataSet.FieldByName('财务凭证').Value:=''; data1.DataSet.FieldByName('是否打印').Value:=0; data1.DataSet.FieldByName('销售订舱').Value:=0; data1.DataSet.FieldByName('是否退舱').Value:=0; data1.DataSet['VGM']:=1; data1.DataSet.FieldByName('报关服务').Value:=0; data1.DataSet.FieldByName('报验服务').Value:=0; data1.DataSet.FieldByName('拖车服务').Value:=0; data1.DataSet.FieldByName('签单方式').AsString:=data2.DataSet.FieldByName('ISSUETYPE').AsString; data1.DataSet.FieldByName('付费方式').AsString:=data2.DataSet.FieldByName('BLFRT').AsString; // data1.DataSet.FieldByName('货代公司联系人').AsString:=data2.DataSet.FieldByName('CUSTATTN').AsString; data1.DataSet.FieldByName('应收海运费').AsFloat:=0; data1.DataSet.FieldByName('应付海运费').AsFloat:=0; data1.DataSet.FieldByName('船公司代理费').AsFloat:=0; data1.DataSet.FieldByName('捷丰代理费').AsFloat:=0; data1.DataSet.Post; if (not Data4.DataSet.IsEmpty) then begin try Data3.DataSet.Close; Data3.DataSet.Open; with data4.DataSet do begin First; while not Eof do begin Data3.DataSet.Insert; Data3.DataSet['表现形式']:=Data4.DataSet['CTNALL']; Data3.DataSet['数量']:=Data4.DataSet['CTNNUM']; if frm_data_share.t_code_ctn.Locate('表现形式',Data4.DataSet['CTNALL'],[]) then begin Data3.DataSet['代码']:=frm_data_share.t_code_ctn['代码']; Data3.DataSet['箱型']:=frm_data_share.t_code_ctn['箱型']; Data3.DataSet['尺寸']:=frm_data_share.t_code_ctn['尺寸']; if frm_data_share.t_code_ctn.FieldByName('尺寸').asstring='20'then Data3.DataSet['TEU']:=1*Data3.DataSet.FieldByName('数量').asinteger; if (frm_data_share.t_code_ctn.FieldByName('尺寸').asstring='40')OR (frm_data_share.t_code_ctn.FieldByName('尺寸').asstring='45')then Data3.DataSet['TEU']:=2*Data3.DataSet.FieldByName('数量').asinteger; end else begin Data3.DataSet['表现形式']:=''; Data3.DataSet['箱型']:=''; Data3.DataSet['尺寸']:=''; Data3.DataSet['TEU']:=0; end; Data3.DataSet['编号']:=bsno; Data3.DataSet.post; Next; end; end; finally end; end; Data2.DataSet.Edit; Data2.DataSet.fieldbyname('BSSTATUS').AsString:='Confirm'; Data2.DataSet.fieldbyname('BSNO').AsString:=ywno; Data2.DataSet.Post; frm_main.db.CommitTrans; finally if frm_main.db.InTransaction then begin frm_main.db.RollbackTrans; end; close; end; end; end.