unit u_op_seae_oder_add; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, BusinessSkinForm, bsSkinCtrls, StdCtrls, wwdbdatetimepicker, DB, RxLookup,adodb,my_sys_chat, Mask, DBCtrlsEh,inifiles; type Tfrm_op_seae_order_add = class(TForm) bsBusinessSkinForm1: TbsBusinessSkinForm; bsSkinGroupBox1: TbsSkinGroupBox; Label1: TLabel; wwDBDateTimePicker1: TwwDBDateTimePicker; bsSkinButton1: TbsSkinButton; bsSkinButton2: TbsSkinButton; data1: TDataSource; Label16: TLabel; Label42: TLabel; RxDBLookupCombo30: TRxDBLookupCombo; Label17: TLabel; data2: TDataSource; data3: TDataSource; data4: TDataSource; data5: TDataSource; RxDBLookupCombo1: TRxDBLookupCombo; Label2: TLabel; bsSkinCheckRadioBox1: TbsSkinCheckRadioBox; DBComboBoxEh1: TDBComboBoxEh; DBComboBoxEh2: TDBComboBoxEh; ADOQuery1: TADOQuery; procedure FormShow(Sender: TObject); procedure bsSkinButton3Click(Sender: TObject); procedure RxDBLookupCombo14Change(Sender: TObject); procedure bsSkinButton2Click(Sender: TObject); procedure DBComboBoxEh1DropDown(Sender: TObject); procedure DBComboBoxEh2DropDown(Sender: TObject); procedure DBComboBoxEh1Change(Sender: TObject); procedure DBComboBoxEh2Change(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); private { Private declarations } public { Public declarations } end; var frm_op_seae_order_add: Tfrm_op_seae_order_add; frm_op_seae_add_num:integer; implementation uses u_main, my_sys_function, u_data_share; {$R *.dfm} procedure Tfrm_op_seae_order_add.bsSkinButton2Click(Sender: TObject); begin close; end; procedure Tfrm_op_seae_order_add.FormShow(Sender: TObject); var inifile1:Tinifile; begin inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini'); DBComboBoxEh1.Text:=inifile1.ReadString('seaeorder','op',''); RxDBLookupCombo30.DisplayValue:=inifile1.ReadString('seaeorder','opdept',''); DBComboBoxEh2.Text:=inifile1.ReadString('seaeorder','kf',''); RxDBLookupCombo1.DisplayValue:=inifile1.ReadString('seaeorder','kfdept',''); bsSkinCheckRadioBox1.Checked:=inifile1.Readbool('seaeorder','savecheck',true); inifile1.free; wwDBDateTimePicker1.Date:=date; end; procedure Tfrm_op_seae_order_add.bsSkinButton3Click(Sender: TObject); var i: Integer; bsno,ywno:String; aQuery:TAdoQuery; begin if (DBComboBoxEh1.text='') 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['编号']:=bsno; if Data2.DataSet.FieldByName('装运方式').AsString<>'' then data1.DataSet['装运方式']:=data2.DataSet['装运方式'] else data1.DataSet['装运方式']:='整箱'; data1.DataSet['会计期间']:=wwDBDateTimePicker1.date; data1.DataSet['周次']:=WeekofYear(wwDBDateTimePicker1.date); data1.DataSet['录入人']:=employee; data1.DataSet['录入日期']:=date; data1.DataSet['操作员']:=DBComboBoxEh1.text; // data1.DataSet['报关操作']:=employee; data1.DataSet['揽货人']:=data2.DataSet['揽货人']; data1.DataSet['客服员']:=DBComboBoxEh2.text; data1.DataSet['销售部门']:=data2.DataSet['销售部门']; data1.DataSet['操作部门']:=RxDBLookupCombo30.DisplayValue; data1.DataSet['业务来源']:='自揽货'; data1.DataSet['委托单位']:=data2.DataSet['委托单位']; data1.DataSet['货代公司']:=data2.DataSet['货代公司']; data1.DataSet['船公司']:=data2.DataSet['船公司']; ywno:=get_no(wwDBDateTimePicker1.date,getbsno(Logininfo.SeaExpBsNo,'SE')); data1.DataSet['业务编号']:=ywno; data1.DataSet['主编号']:=bsno; data1.DataSet['委托编号']:=Data2.DataSet['订舱编号']; data1.DataSet['主提单标准']:=bsno; data1.DataSet['分提单标准']:=bsno; data1.DataSet['委托标准']:=bsno; data1.DataSet['报关标准']:=bsno; data1.DataSet['报检标准']:=bsno; data1.DataSet['核销标准']:=bsno; data1.DataSet['计费标准']:=''; data1.DataSet['业务状态']:='接受委托'; data1.DataSet['费用状态']:='录入状态'; data1.DataSet['业务类型']:='普通货'; data1.DataSet['业务来源']:='自揽货'; data1.DataSet['起运港']:=data2.DataSet['装货港']; data1.DataSet['装货港']:=data2.DataSet['装货港']; data1.DataSet['提单份数']:=get_parameters_value(20,'THREE'); data1.DataSet['运输条款']:=data2.DataSet['运输条款']; data1.DataSet['唛头']:=data2.DataSet['唛头']; data1.DataSet['货物描述']:=data2.DataSet['货物描述']; data1.DataSet['发货人']:=data2.DataSet['发货人']; data1.DataSet['收货人']:=data2.DataSet['收货人']; data1.DataSet['通知人']:=data2.DataSet['通知人']; data1.DataSet['发货人代码']:=data2.DataSet['发货人代码']; data1.DataSet['收货人代码']:=data2.DataSet['收货人代码']; data1.DataSet['通知人代码']:=data2.DataSet['通知人代码']; data1.DataSet['付费方式']:=data2.DataSet['付费方式']; data1.DataSet['签单地点']:=data2.DataSet['签单地点']; data1.DataSet['件数包装']:=data2.DataSet['件数包装']; data1.DataSet['货物重量']:=data2.DataSet['货物重量']; data1.DataSet['货物尺码']:=data2.DataSet['货物尺码']; data1.DataSet['件数']:=data2.DataSet['件数']; data1.DataSet['包装']:=data2.DataSet['包装']; data1.DataSet['重量']:=data2.DataSet['重量']; data1.DataSet['尺码']:=data2.DataSet['尺码']; data1.DataSet['件数大写']:=data2.DataSet['件数大写']; data1.DataSet['船名']:=data2.DataSet['船名']; data1.DataSet['航次']:=data2.DataSet['航次']; data1.DataSet['开船日期']:=data2.DataSet['开船日期']; data1.DataSet['卸货港']:=data2.DataSet['卸货港']; data1.DataSet['目的地']:=data2.DataSet['目的地']; data1.DataSet['集装箱']:=data2.DataSet['集装箱']; data1.DataSet['备注']:=data2.DataSet['备注']; data1.DataSet['预付地点']:=get_parameters_value(50,'QINGDAO,CHINA'); data1.DataSet['退税日期']:=null; data1.DataSet['签单日期']:=null; data1.DataSet['派车日期']:=null; data1.DataSet['寄单日期']:=null; data1.DataSet['是否寄单']:=0; data1.DataSet['是否退税']:=0; data1.DataSet['是否通关']:=0; data1.DataSet['是否签单']:=0; data1.DataSet['请求派车']:=0; data1.DataSet['是否派车']:=0; data1.DataSet['是否解锁']:=0; data1.DataSet['解锁日期']:=null; data1.DataSet['解锁人']:=''; data1.DataSet['应收陆运']:=0; data1.DataSet['应付陆运']:=0; data1.DataSet['陆运利润']:=0; data1.DataSet['财务']:=0; data1.DataSet['财务凭证']:=''; data1.DataSet['是否打印']:=0; data1.DataSet['销售订舱']:=1; data1.DataSet['是否退舱']:=0; data1.DataSet.Post; if not data5.DataSet.IsEmpty then begin data5.dataset.First; while not data5.DataSet.Eof do begin if (Data5.DataSet['应收金额']<>0) then begin Data4.DataSet.Insert; Data4.DataSet['客户名称']:=Data5.DataSet['应收客户']; Data4.DataSet['类型']:='收'; Data4.DataSet['费用状态']:='审核通过'; Data4.DataSet['费用名称']:=Data5.DataSet['费用名称']; Data4.DataSet['标准']:=Data5.DataSet['应收标准']; Data4.DataSet['单价']:=Data5.DataSet['应收单价']; Data4.DataSet['数量']:=Data5.DataSet['应收数量']; Data4.DataSet['金额']:=Data5.DataSet['应收金额']; Data4.DataSet['币别']:=Data5.DataSet['应收币别']; Data4.DataSet['汇率']:=Data5.DataSet['应收汇率']; Data4.DataSet['录入人']:=Data2.DataSet['揽货人']; Data4.DataSet['结算金额']:=0; Data4.DataSet['开票金额']:=0; Data4.DataSet['申请开票']:=0; Data4.DataSet['冲抵金额']:=0; Data4.DataSet['申请金额']:=0; Data4.DataSet['录入日期']:=now; Data4.DataSet['是否对帐']:=0; Data4.DataSet['是否垫付']:=0; Data4.DataSet['不开发票']:=0; Data4.DataSet['结算单位']:='委托单位'; Data4.DataSet['顺序']:=0; Data4.DataSet['机密']:=0; Data4.DataSet['编号']:=bsno; Data4.DataSet.post; end; if (Data5.DataSet['应付金额']<>0) then begin Data4.DataSet.Insert; Data4.DataSet['客户名称']:=Data5.DataSet['应付客户']; Data4.DataSet['类型']:='付'; Data4.DataSet['费用状态']:='审核通过'; Data4.DataSet['费用名称']:=Data5.DataSet['费用名称']; Data4.DataSet['标准']:=Data5.DataSet['应付标准']; Data4.DataSet['单价']:=Data5.DataSet['应付单价']; Data4.DataSet['数量']:=Data5.DataSet['应付数量']; Data4.DataSet['金额']:=Data5.DataSet['应付金额']; Data4.DataSet['币别']:=Data5.DataSet['应付币别']; Data4.DataSet['汇率']:=Data5.DataSet['应付汇率']; Data4.DataSet['录入人']:=Data2.DataSet['揽货人']; Data4.DataSet['结算金额']:=0; Data4.DataSet['申请开票']:=0; Data4.DataSet['开票金额']:=0; Data4.DataSet['冲抵金额']:=0; Data4.DataSet['申请金额']:=0; Data4.DataSet['录入日期']:=now; Data4.DataSet['是否对帐']:=0; Data4.DataSet['是否垫付']:=0; Data4.DataSet['不开发票']:=0; Data4.DataSet['结算单位']:='货代公司'; Data4.DataSet['顺序']:=0; Data4.DataSet['机密']:=0; Data4.DataSet['编号']:=bsno; Data4.DataSet.post; end; data5.DataSet.Next; end; end; if (Data2.DataSet.FieldByName('集装箱').AsString<>'') then begin aQuery:=CreateAdoQuery; try with aQuery do begin sql.Add('select * from t_opor_ctn where OR_ID='+Data2.DataSet.fieldbyname('OR_ID').AsString); Open; if recordcount<>0 then begin Data3.DataSet.Insert; Data3.DataSet['代码']:=aQuery['代码']; Data3.DataSet['尺寸']:=aQuery['尺寸']; Data3.DataSet['箱型']:=aQuery['箱型']; Data3.DataSet['数量']:=aQuery['数量']; Data3.DataSet['TEU']:=aQuery['TEU']; Data3.DataSet['表现形式']:=aQuery['表现形式']; Data3.DataSet['箱号']:=aQuery['箱号']; Data3.DataSet['箱型']:=aQuery['箱型']; Data3.DataSet['封号']:=aQuery['封号']; Data3.DataSet['件数']:=aQuery['件数']; Data3.DataSet['包装']:=aQuery['包装']; Data3.DataSet['重量']:=aQuery['重量']; Data3.DataSet['尺码']:=aQuery['尺码']; Data3.DataSet['品名']:=aQuery['品名']; Data3.DataSet['唛头']:=aQuery['唛头']; Data3.DataSet['备注']:=aQuery['备注']; Data3.DataSet['编号']:=bsno; Data3.DataSet.post; end; end; update_ctn(TAdoQuery(Data3.DataSet)); finally freeAndNil(aQuery); end; end; if (Data2.DataSet.fieldbyname('状态').AsString='提交审核') or (Data2.DataSet.fieldbyname('状态').AsString='驳回提交') then begin Data2.DataSet.Edit; Data2.DataSet['状态']:='接受订舱'; Data2.DataSet['编号']:=bsno; Data2.DataSet['业务编号']:=ywno; Data2.DataSet['审核人']:=employee; Data2.DataSet['审核时间']:=date; Data2.DataSet['提交人']:=employee; Data2.DataSet['提交时间']:=date; Data2.DataSet.Post; end else if Data2.DataSet.fieldbyname('状态').AsString='审核通过' then begin Data2.DataSet.Edit; Data2.DataSet['状态']:='接受订舱'; Data2.DataSet['编号']:=bsno; Data2.DataSet['业务编号']:=ywno; Data2.DataSet['提交人']:=employee; Data2.DataSet['提交时间']:=date; Data2.DataSet.Post; end; Send_op_do('销售订舱确认,业务编号:'+ywno +',委托编号:'+Data2.DataSet.fieldbyname('订舱编号').AsString,'72', trim(DBComboBoxEh1.text), trim(DBComboBoxEh2.text), data2.DataSet.fieldbyname('揽货人').AsString); frm_main.db.CommitTrans; finally if frm_main.db.InTransaction then begin frm_main.db.RollbackTrans; end; end; close; end; procedure Tfrm_op_seae_order_add.RxDBLookupCombo14Change(Sender: TObject); begin { if RxDBLookupCombo14.DisplayValue='' then exit; if frm_data_share.t_sys_employee.locate('姓名',RxDBLookupCombo14.DisplayValue,[]) then RxDBLookupCombo30.DisplayValue:=frm_data_share.t_sys_employee['部门名称']; } end; procedure Tfrm_op_seae_order_add.DBComboBoxEh1DropDown(Sender: TObject); begin DBComboBoxEh1.items.clear; if RxDBLookupCombo30.DisplayValue<>'' then begin AdoQuery1.Close; AdoQuery1.sql.Clear; AdoQuery1.SQL.Add('select * from t_sys_employee where 部门名称='''+RxDBLookupCombo30.DisplayValue+''''); AdoQuery1.Open; AdoQuery1.first; while not AdoQuery1.Eof do begin DBComboBoxEh1.Items.Add(AdoQuery1.fieldbyname('姓名').AsString); ADOQuery1.Next; end; end else begin AdoQuery1.Close; AdoQuery1.sql.Clear; AdoQuery1.SQL.Add('select * from t_sys_employee '); AdoQuery1.Open; AdoQuery1.first; while not AdoQuery1.Eof do begin DBComboBoxEh1.Items.Add(AdoQuery1.fieldbyname('姓名').AsString); ADOQuery1.Next; end; end; end; procedure Tfrm_op_seae_order_add.DBComboBoxEh2DropDown(Sender: TObject); begin DBComboBoxEh2.items.clear; if RxDBLookupCombo1.DisplayValue<>'' then begin AdoQuery1.Close; AdoQuery1.sql.Clear; AdoQuery1.SQL.Add('select * from t_sys_employee where 部门名称='''+RxDBLookupCombo1.DisplayValue+''''); AdoQuery1.Open; AdoQuery1.first; while not AdoQuery1.Eof do begin DBComboBoxEh2.Items.Add(AdoQuery1.fieldbyname('姓名').AsString); ADOQuery1.Next; end; end else begin AdoQuery1.Close; AdoQuery1.sql.Clear; AdoQuery1.SQL.Add('select * from t_sys_employee '); AdoQuery1.Open; AdoQuery1.first; while not AdoQuery1.Eof do begin DBComboBoxEh2.Items.Add(AdoQuery1.fieldbyname('姓名').AsString); ADOQuery1.Next; end; end; end; procedure Tfrm_op_seae_order_add.DBComboBoxEh1Change(Sender: TObject); begin if frm_data_share.t_sys_employee.Locate('姓名',DBComboBoxEh1.Text,[]) then RxDBLookupCombo30.DisplayValue:=frm_data_share.t_sys_employee['部门名称']; end; procedure Tfrm_op_seae_order_add.DBComboBoxEh2Change(Sender: TObject); begin if frm_data_share.t_sys_employee.Locate('姓名',DBComboBoxEh2.Text,[]) then RxDBLookupCombo1.DisplayValue:=frm_data_share.t_sys_employee['部门名称']; end; procedure Tfrm_op_seae_order_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('seaeorder','op',DBComboBoxEh1.Text); inifile1.WriteString('seaeorder','opdept',RxDBLookupCombo30.DisplayValue); inifile1.WriteString('seaeorder','kf',DBComboBoxEh2.Text); inifile1.WriteString('seaeorder','kfdept',RxDBLookupCombo1.DisplayValue); inifile1.Writebool('seaeorder','savecheck',bsSkinCheckRadioBox1.Checked); inifile1.free; end; end; end.