unit u_op_seai_oder_add; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, BusinessSkinForm, bsSkinCtrls, StdCtrls, wwdbdatetimepicker, DB, RxLookup,adodb; type Tfrm_op_seai_order_add = class(TForm) bsBusinessSkinForm1: TbsBusinessSkinForm; bsSkinGroupBox1: TbsSkinGroupBox; Label1: TLabel; wwDBDateTimePicker1: TwwDBDateTimePicker; bsSkinButton1: TbsSkinButton; bsSkinButton2: TbsSkinButton; data1: TDataSource; Label16: TLabel; RxDBLookupCombo14: TRxDBLookupCombo; Label42: TLabel; RxDBLookupCombo30: TRxDBLookupCombo; Label17: TLabel; RxDBLookupCombo13: TRxDBLookupCombo; data2: TDataSource; Label19: TLabel; RxDBLookupCombo12: TRxDBLookupCombo; Label20: TLabel; RxDBLookupCombo29: TRxDBLookupCombo; data3: TDataSource; procedure FormShow(Sender: TObject); procedure bsSkinButton3Click(Sender: TObject); procedure RxDBLookupCombo14Change(Sender: TObject); procedure bsSkinButton2Click(Sender: TObject); procedure RxDBLookupCombo29Change(Sender: TObject); private { Private declarations } public { Public declarations } end; var frm_op_seai_order_add: Tfrm_op_seai_order_add; frm_op_seae_add_num:integer; implementation uses u_main, my_sys_function, u_data_share; {$R *.dfm} procedure Tfrm_op_seai_order_add.bsSkinButton2Click(Sender: TObject); begin close; end; procedure Tfrm_op_seai_order_add.FormShow(Sender: TObject); begin wwDBDateTimePicker1.Date:=date; end; procedure Tfrm_op_seai_order_add.bsSkinButton3Click(Sender: TObject); var i: Integer; bsno,ywno:String; aQuery:TAdoQuery; begin if (RxDBLookupCombo14.DisplayValue='') or (RxDBLookupCombo14.DisplayValue='') or (RxDBLookupCombo14.DisplayValue='') or (RxDBLookupCombo14.DisplayValue='') or (RxDBLookupCombo14.DisplayValue='') then begin MessageDlg('所有项目都不为空!', mtConfirmation, [mbYes],0); exit; end; if not data1.DataSet.Active then data1.DataSet.Open; if not data3.DataSet.Active then data3.DataSet.Open; bsno:=get_id; data1.DataSet.Insert; data1.DataSet['编号']:=bsno; if Data2.DataSet['是否拼箱']=1 then data1.DataSet['装运方式']:='拼箱单票' else data1.DataSet['装运方式']:='整箱'; data1.DataSet['会计期间']:=wwDBDateTimePicker1.date; data1.DataSet['周次']:=WeekofYear(wwDBDateTimePicker1.date); data1.DataSet['录入人']:=employee; data1.DataSet['录入日期']:=date; data1.DataSet['操作员']:=RxDBLookupCombo14.DisplayValue; data1.DataSet['揽货人']:=RxDBLookupCombo29.DisplayValue; data1.DataSet['客服员']:=RxDBLookupCombo13.DisplayValue; data1.DataSet['销售部门']:=RxDBLookupCombo12.DisplayValue; data1.DataSet['操作部门']:=RxDBLookupCombo30.DisplayValue; data1.DataSet['委托单位']:=data2.DataSet['委托单位']; data1.DataSet['业务类型']:='普通货'; ywno:=get_no(data1.DataSet.fieldbyname('会计期间').AsDateTime,getbsno(Logininfo.SeaImpBsNo,'SI')); data1.DataSet['业务编号']:=ywno; data1.DataSet['主编号']:=bsno; 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['发货人代码']:=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['件数大写'] :='SAY:'+ntoc(data1.DataSet.FieldByName('件数').asfloat,true) +data1.DataSet.FieldByName('包装').asstring+' ONLY.'; data1.DataSet['备注']:=data2.DataSet['备注']; data1.DataSet['财务']:=0; data1.DataSet['财务凭证']:=''; data1.DataSet['业务来源']:='自揽货'; data1.DataSet['来源明细']:=''; data1.DataSet.Post; if (Data2.DataSet['箱型1']<>'') and (Data2.DataSet['箱量1']<>0) then begin aQuery:=CreateAdoQuery; try with aQuery do begin sql.Add('select * from t_code_ctn where 代码='''+Data2.DataSet['箱型1']+''''); Open; if recordcount<>0 then begin Data3.DataSet.Insert; Data3.DataSet['代码']:=Data2.DataSet['箱型1']; Data3.DataSet['数量']:=Data2.DataSet['箱量1']; Data3.DataSet['表现形式']:=aQuery['表现形式']; if aQuery.FieldByName('尺寸').asstring='20'then Data3.DataSet['TEU']:=1*Data3.DataSet.FieldByName('数量').asinteger; if (aQuery.FieldByName('尺寸').asstring='40')OR (aQuery.FieldByName('尺寸').asstring='45')then Data3.DataSet['TEU']:=2*Data3.DataSet.FieldByName('数量').asinteger; Data3.DataSet.post; end; end; finally freeAndNil(aQuery); end; end; if (Data2.DataSet['箱型2']<>'') and (Data2.DataSet['箱量2']<>0) then begin aQuery:=CreateAdoQuery; try with aQuery do begin sql.Add('select * from t_code_ctn where 代码='''+Data2.DataSet['箱型2']+''''); Open; if recordcount<>0 then begin Data3.DataSet.Insert; Data3.DataSet['代码']:=Data2.DataSet['箱型2']; Data3.DataSet['数量']:=Data2.DataSet['箱量2']; Data3.DataSet['表现形式']:=aQuery['表现形式']; if aQuery.FieldByName('尺寸').asstring='20'then Data3.DataSet['TEU']:=1*Data3.DataSet.FieldByName('数量').asinteger; if (aQuery.FieldByName('尺寸').asstring='40')OR (aQuery.FieldByName('尺寸').asstring='45')then Data3.DataSet['TEU']:=2*Data3.DataSet.FieldByName('数量').asinteger; Data3.DataSet.post; end; end; finally freeAndNil(aQuery); end; end; if (Data2.DataSet['箱型3']<>'') and (Data2.DataSet['箱量3']<>0) then begin aQuery:=CreateAdoQuery; try with aQuery do begin sql.Add('select * from t_code_ctn where 代码='''+Data2.DataSet['箱型3']+''''); Open; if recordcount<>0 then begin Data3.DataSet.Insert; Data3.DataSet['代码']:=Data2.DataSet['箱型3']; Data3.DataSet['数量']:=Data2.DataSet['箱量3']; Data3.DataSet['表现形式']:=aQuery['表现形式']; if aQuery.FieldByName('尺寸').asstring='20'then Data3.DataSet['TEU']:=1*Data3.DataSet.FieldByName('数量').asinteger; if (aQuery.FieldByName('尺寸').asstring='40')OR (aQuery.FieldByName('尺寸').asstring='45')then Data3.DataSet['TEU']:=2*Data3.DataSet.FieldByName('数量').asinteger; Data3.DataSet.post; end; end; finally freeAndNil(aQuery); end; end; Data2.DataSet.Edit; Data2.DataSet['订舱状态']:=1; Data2.DataSet['业务编号']:=ywno; Data2.DataSet.Post; close; end; procedure Tfrm_op_seai_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_seai_order_add.RxDBLookupCombo29Change(Sender: TObject); begin if RxDBLookupCombo29.DisplayValue='' then exit; if frm_data_share.t_sys_employee.locate('姓名',RxDBLookupCombo29.DisplayValue,[]) then RxDBLookupCombo12.DisplayValue:=frm_data_share.t_sys_employee['部门名称']; end; end.