unit u_op_custom; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, bsSkinCtrls, ExtCtrls, wwdblook, Mask, wwdbedit, Wwdotdot, Wwdbcomb, StdCtrls, wwdbdatetimepicker, dxExEdtr, dxCntner, dxTL, dxDBCtrl, dxDBGrid, DB, ADODB, dxDBTLCl, dxGrClms, ComCtrls, bsSkinTabs, u_fee, Grids, DBGrids, DBCtrlsEh,ShellAPI; type TBSITEMS = Record PONO,BSNO,YWBH,sales :String; Etd :Tdate; end; Tfrm_op_custom = class(TForm) Panel2: TPanel; bsSkinButton7: TbsSkinButton; bsSkinButton6: TbsSkinButton; bsSkinButton2: TbsSkinButton; bsSkinButton4: TbsSkinButton; bsSkinButton3: TbsSkinButton; bsSkinButton5: TbsSkinButton; bsSkinButton38: TbsSkinButton; bsSkinPanel2: TbsSkinPanel; Label47: TLabel; Label80: TLabel; Edit3: TEdit; bsSkinButton8: TbsSkinButton; bsSkinButton12: TbsSkinButton; Edit1: TEdit; Label51: TLabel; Label53: TLabel; wwDBDateTimePicker11: TwwDBDateTimePicker; wwDBDateTimePicker13: TwwDBDateTimePicker; Label1: TLabel; Edit2: TEdit; t_op_custom1: TDataSource; t_op_custom_items1: TDataSource; t_op_custom: TADOQuery; t_op_custom_items: TADOQuery; bsSkinButton1: TbsSkinButton; bsSkinPageControl1: TbsSkinPageControl; bsSkinTabSheet1: TbsSkinTabSheet; dxDBGrid1: TdxDBGrid; dxDBGrid1Column1: TdxDBGridColumn; dxDBGrid1Column2: TdxDBGridDateColumn; dxDBGrid1Column3: TdxDBGridColumn; dxDBGrid1Column4: TdxDBGridPickColumn; dxDBGrid1Column5: TdxDBGridColumn; dxDBGrid1Column6: TdxDBGridColumn; dxDBGrid1Column7: TdxDBGridColumn; dxDBGrid1Column8: TdxDBGridColumn; dxDBGrid1Column9: TdxDBGridColumn; dxDBGrid1Column10: TdxDBGridColumn; dxDBGrid1Column11: TdxDBGridColumn; dxDBGrid1Column12: TdxDBGridDateColumn; dxDBGrid1Column13: TdxDBGridColumn; dxDBGrid1Column14: TdxDBGridColumn; bsSkinExPanel1: TbsSkinExPanel; dxDBGrid2: TdxDBGrid; dxDBGridColumn1: TdxDBGridColumn; bsSkinTabSheet2: TbsSkinTabSheet; fra_fee1: Tfra_fee; Label2: TLabel; Edit4: TEdit; Label3: TLabel; Edit5: TEdit; dxDBGrid2Column2: TdxDBGridColumn; dxDBGrid1Column16: TdxDBGridCheckColumn; dxDBGrid1Column15: TdxDBGridPickColumn; DBComboBoxEh1: TDBComboBoxEh; bsSkinButton9: TbsSkinButton; bsSkinButton10: TbsSkinButton; bsSkinButton11: TbsSkinButton; SaveDialog: TSaveDialog; DBComboBoxEh2: TDBComboBoxEh; DBComboBoxEh3: TDBComboBoxEh; Label4: TLabel; Label5: TLabel; wwDBDateTimePicker1: TwwDBDateTimePicker; wwDBDateTimePicker2: TwwDBDateTimePicker; Label6: TLabel; Edit6: TEdit; Label7: TLabel; Edit7: TEdit; Label8: TLabel; Edit8: TEdit; dxDBGrid1Column17: TdxDBGridColumn; Label9: TLabel; Edit9: TEdit; bsSkinTabSheet3: TbsSkinTabSheet; dsrFuJian: TDataSource; t_op_file: TADOQuery; bsSkinGroupBox13: TbsSkinGroupBox; bsSkinPanel14: TbsSkinPanel; bsSkinButton48: TbsSkinButton; bsSkinButton49: TbsSkinButton; bsSkinButton50: TbsSkinButton; bsSkinButton51: TbsSkinButton; dxDBGrid3: TdxDBGrid; dxDBGrid2fid: TdxDBGridMaskColumn; dxDBGrid2rl_id: TdxDBGridMaskColumn; dxDBGridColumn2: TdxDBGridColumn; dxDBGridColumn3: TdxDBGridColumn; dxDBGridColumn4: TdxDBGridColumn; dxDBGridDateColumn1: TdxDBGridDateColumn; dxDBGridColumn5: TdxDBGridColumn; dxDBGridColumn6: TdxDBGridColumn; OpenDialog1: TOpenDialog; SaveDialog1: TSaveDialog; procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure Panel2Resize(Sender: TObject); procedure bsSkinButton7Click(Sender: TObject); procedure bsSkinButton6Click(Sender: TObject); procedure bsSkinButton2Click(Sender: TObject); procedure bsSkinButton4Click(Sender: TObject); procedure bsSkinButton38Click(Sender: TObject); procedure bsSkinButton5Click(Sender: TObject); procedure FormShow(Sender: TObject); procedure t_op_customBeforePost(DataSet: TDataSet); procedure dxDBGrid2DblClick(Sender: TObject); procedure t_op_customAfterInsert(DataSet: TDataSet); procedure dxDBGrid1DblClick(Sender: TObject); procedure bsSkinButton8Click(Sender: TObject); procedure bsSkinButton1Click(Sender: TObject); procedure bsSkinPageControl1Change(Sender: TObject); procedure DBComboBoxEh1Change(Sender: TObject); procedure bsSkinButton9Click(Sender: TObject); procedure bsSkinButton10Click(Sender: TObject); procedure bsSkinButton11Click(Sender: TObject); procedure DBComboBoxEh2Change(Sender: TObject); procedure DBComboBoxEh3Change(Sender: TObject); procedure Edit3KeyPress(Sender: TObject; var Key: Char); procedure Edit1KeyPress(Sender: TObject; var Key: Char); procedure wwDBDateTimePicker11KeyPress(Sender: TObject; var Key: Char); procedure wwDBDateTimePicker13KeyPress(Sender: TObject; var Key: Char); procedure Edit5KeyPress(Sender: TObject; var Key: Char); procedure Edit6KeyPress(Sender: TObject; var Key: Char); procedure Edit2KeyPress(Sender: TObject; var Key: Char); procedure Edit4KeyPress(Sender: TObject; var Key: Char); procedure wwDBDateTimePicker1KeyPress(Sender: TObject; var Key: Char); procedure wwDBDateTimePicker2KeyPress(Sender: TObject; var Key: Char); procedure Edit7KeyPress(Sender: TObject; var Key: Char); procedure Edit8KeyPress(Sender: TObject; var Key: Char); procedure fra_fee1bsSkinButton11Click(Sender: TObject); procedure fra_fee1bsSkinButton1Click(Sender: TObject); procedure fra_fee1bsSkinButton2Click(Sender: TObject); procedure fra_fee1bsSkinButton4Click(Sender: TObject); procedure fra_fee1bsSkinButton6Click(Sender: TObject); procedure fra_fee1bsSkinButton7Click(Sender: TObject); procedure fra_fee1bsSkinButton10Click(Sender: TObject); procedure fra_fee1bsSkinButton15Click(Sender: TObject); procedure fra_fee1bsSkinButton12Click(Sender: TObject); procedure fra_fee1bsSkinButton17Click(Sender: TObject); procedure fra_fee1bsSkinButton18Click(Sender: TObject); procedure bsSkinButton48Click(Sender: TObject); procedure bsSkinButton49Click(Sender: TObject); procedure bsSkinButton50Click(Sender: TObject); procedure bsSkinButton51Click(Sender: TObject); private { Private declarations } public { Public declarations } function GetWTNO(mblno:string):TBSITEMS; function BSStatus(bsNo:string):Boolean; procedure UpLoadPro(fname:string); //fname包含完整路径、文件名 procedure DownLoadPro(fname:string); //从数据库的表中下载 procedure WMDROPFILES(var Msg: TMessage);message WM_DROPFILES; end; var frm_op_custom: Tfrm_op_custom; implementation uses u_main, my_sys_function, u_op_seae_apply, u_sys_progress; {$R *.dfm} procedure Tfrm_op_custom.DownLoadPro(fname: string); const MaxBufSize=$F000; var myfilename:string;//保存文件的路径和文件名 myfileStream,exeBlobStream:TStream; Count,BufSize,N: Integer; Buffer:PChar; begin //下载文件 if not ASSIGNED(frm_sys_progress) then frm_sys_progress:=tfrm_sys_progress.Create(self); frm_sys_progress.bsSkinGauge1.ProgressText:='加载数据请等候。。。'; frm_sys_progress.Show; frm_sys_progress.Update; myfilename:=FName ; with t_op_file do begin myfilename:=myfilename ; //+fieldbyname('类型').asstring ; myfileStream :=TFileStream.Create(myfilename,fmCreate);//创建文件 try //SaveToStream(Stream); ExeBlobStream:=CreateBlobStream(FieldByName('内容'),bmRead); //从数据库中取得记录 Count:=0; try if Count=0 then begin ExeBlobStream.Position:=0; Count:=ExeBlobStream.Size;//showmessage(inttostr(count)); end; if Count>MaxBufSize then BufSize:=MaxBufSize else BufSize:=Count; GetMem(Buffer,BufSize); frm_sys_progress.bsSkinGauge1.MaxValue:=(Count div BufSize)+2; frm_sys_progress.bsSkinGauge1.MinValue:=0; frm_sys_progress.bsSkinGauge1.Value:=0; try while Count<>0 do begin if Count>BufSize then N:=BufSize else N:=Count; ExeBlobStream.ReadBuffer(Buffer^,N);//从数据库表中取数据流 MyFileStream.WriteBuffer(Buffer^,N);//将数据流写入文件 Dec(Count,N); frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; end; finally FreeMem(Buffer,BufSize); end; finally ExeBlobStream.Free; end; finally myfileStream.Free; end; end; frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; frm_sys_progress.close; frm_sys_progress:=nil; end; procedure Tfrm_op_custom.UpLoadPro(fname: string); const BufSize=$F000; var Counter, N: Integer; Buffer: PAnsiChar; FieldStrm: TStream; ExeFileStream:TFileStream; size_tmp: Double; filename,fileExt:string ; begin //上传文件 if not ASSIGNED(frm_sys_progress) then frm_sys_progress:=tfrm_sys_progress.Create(self); frm_sys_progress.bsSkinGauge1.ProgressText:='加载数据请等候。。。'; frm_sys_progress.Show; frm_sys_progress.Update; filename:=ExtractFileName(fname) ; fileExt:=ExtractFileExt(filename) ; ExeFileStream:=TFileStream.Create(fname,fmopenRead); //打开文件 with t_op_file do begin Open; append; try FieldStrm := CreateBlobStream(FieldByName('内容'),bmWrite); GetMem(Buffer,BufSize); try Counter := ExeFileStream.Size; size_tmp :=ExeFileStream.Size; frm_sys_progress.bsSkinGauge1.MaxValue:=(Counter div BufSize)+2; frm_sys_progress.bsSkinGauge1.MinValue:=0; frm_sys_progress.bsSkinGauge1.Value:=0; while Counter<>0 do begin if Counter>BufSize then N :=BufSize else N:=Counter; ExeFileStream.ReadBuffer(Buffer^,N); FieldStrm.WriteBuffer(Buffer^, N); Dec(Counter, N); frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; // Application.ProcessMessages; end; finally FreeMem(Buffer,BufSize); FieldStrm.Free; end; FieldByName('名称').AsString:=filename; FieldByName('大小').AsFloat:=size_tmp; FieldByName('上传日期').AsDateTime:=now(); FieldByName('所有者').Asstring:=employee; FieldByName('类型').Asstring:=fileExt; Post; Application.MessageBox('程序上传至服务器成功!','提示',MB_OK+MB_IconInformation); finally frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; frm_sys_progress.close; frm_sys_progress:=nil; ExeFileStream.Free; end; end; end; procedure Tfrm_op_custom.WMDROPFILES(var Msg: TMessage); var FilesCount: Integer; // 文件总数 i: Integer; FileName: array[0..255] of Char; begin // 获取文件总数 FilesCount := DragQueryFile(Msg.WParam, $FFFFFFFF, nil, 0); // 获取文件名 for i := 0 to FilesCount - 1 do begin DragQueryFile(Msg.WParam, i, FileName, 256); ShowMessage(FileName); end; // 释放 DragFinish(Msg.WParam); end; function Tfrm_op_custom.BSStatus(bsNo:string):Boolean; var aAdoQuery:TADOQuery; begin Result:=False; aAdoQuery:=CreateAdoQuery; with aAdoQuery do try Close;SQL.Clear; SQL.Add('select 费用状态 from v_op_bscard_all '); SQL.Add('Where 编号=:编号 and 编号<>'''' and 费用状态=''费用封帐'''); Parameters.ParamByName('编号').Value:=bsNo; Open;First; if not IsEmpty then begin Result:=True; end; finally Free; end; end; function Tfrm_op_custom.GetWTNO(mblno:string):TBSITEMS; var aQuery:TADOQuery; begin Result.PONO:=''; Result.BSNO:=''; Result.YWBH:=''; Result.sales:=''; if Trim(mblno)<>'' then begin aQuery:=CreateAdoQuery; with aQuery do try Close;SQL.Clear; SQL.Add('Select top 1 委托编号,编号,开船日期,业务编号,揽货人 from V_op_bscard_All where 主提单号=:主提单号 and 业务种类=''普通货'''); Parameters.ParamByName('主提单号').Value:=mblno; Open;First; if not IsEmpty then begin Result.PONO:=fieldbyname('委托编号').AsString; Result.BSNO:=fieldbyname('编号').AsString;; Result.Etd:=fieldbyname('开船日期').Value; Result.ywbh:=fieldbyname('业务编号').AsString; Result.sales:=fieldbyname('揽货人').AsString; end; finally Free; end; end; end; procedure Tfrm_op_custom.FormClose(Sender: TObject; var Action: TCloseAction); begin savereggrid(dxdbgrid1,caption); savewwgrid(fra_fee1.wwDBGrid1,'商检应收'); savewwgrid(fra_fee1.wwDBGrid2,'商检应付'); frm_op_custom.Hide; frm_op_custom.ManualFloat(frm_op_custom.BoundsRect ); frm_main.freeTabs('frm_op_custom'); action:=cafree; frm_op_custom:=nil; end; procedure Tfrm_op_custom.Panel2Resize(Sender: TObject); var i:integer; begin i:=round(Panel2.Width/11); bsSkinButton1.Width:=i; bsSkinButton7.Width:=i; bsSkinButton6.Width:=i; bsSkinButton2.Width:=i; bsSkinButton4.Width:=i; bsSkinButton3.Width:=i; bsSkinButton9.Width:=i; bsSkinButton10.Width:=i; bsSkinButton11.Width:=i; bsSkinButton38.Width:=i; end; procedure Tfrm_op_custom.bsSkinButton7Click(Sender: TObject); begin table_Prior(t_op_custom); end; procedure Tfrm_op_custom.bsSkinButton6Click(Sender: TObject); begin table_next(t_op_custom); end; procedure Tfrm_op_custom.bsSkinButton2Click(Sender: TObject); begin table_post(t_op_custom); end; procedure Tfrm_op_custom.bsSkinButton4Click(Sender: TObject); begin if application.MessageBox('您确定要删除数据吗?','警告:',MB_OKCANCEL)=IDOK then begin if not t_op_custom.fieldbyname('录入费用').AsBoolean then begin t_op_custom.delete; while t_op_custom_items.Eof do t_op_custom_items.Delete; end else begin ShowMessage('已经录入费用,不能删除'); end; end; end; procedure Tfrm_op_custom.bsSkinButton38Click(Sender: TObject); var book1:Tbookmark; begin if t_op_custom.IsEmpty then exit; book1:=t_op_custom.GetBookmark; t_op_custom.Requery; t_op_custom.GotoBookmark(book1); end; procedure Tfrm_op_custom.bsSkinButton5Click(Sender: TObject); begin close; end; procedure Tfrm_op_custom.FormShow(Sender: TObject); begin t_op_custom.Close; t_op_custom.SQL.clear; t_op_custom.SQL.Add('select * from t_op_custom where 1=1 and ' //and 录入费用=0 +' SUBSTRING(CONVERT(char(15),报关日期,111),1,7)='''+FormatDateTime('YYYY',Date)+'/'+FormatDateTime('MM',Date)+''' and ' +open_data('0017','录入人','no','no','no','no') +' order by 报关日期,序号'); t_op_custom.open; t_op_custom_items.Open; loadreggrid(dxdbgrid1,false,caption); if if_open('293') or if_open('294') then begin fra_fee1.edit_type.text:='1'; fra_fee1.baoguan.text:='1'; fra_fee1.edit_data.text:='0001'; fra_fee1.edit_report.text:='海运出口'; fra_fee1.t_ch_accept.DataSource:=t_op_custom1; if strtobool(get_parameters_value(150,'false')) then fra_fee1.bsSkinPanel3.Visible:=true; fra_fee1.DBEdit48.DataSource:=t_op_custom1; if if_open('293') then begin fra_fee1.t_ch_accept.DataSource:=t_op_custom1; if (strtobool(get_parameters_value(153,'false'))=true) then begin if (strtobool(get_parameters_value(64,'false'))=true) and (if_open('206')=false) then begin fra_fee1.t_ch_accept.close; fra_fee1.t_ch_accept.SQL.Clear; fra_fee1.t_ch_accept.SQL.Add('select * from t_ch_fee where 类型=' +''''+'收'+''''+' and 编号=:编号 and (录入人=' +''''+employee+''''+' or (录入人<>'+''''+employee+'''' +' and 机密<>1) ) and '+open_data('7000','录入人','no','no','no','no') +' order by 顺序,CH_ID'); end else begin fra_fee1.t_ch_accept.close; fra_fee1.t_ch_accept.SQL.Clear; fra_fee1.t_ch_accept.SQL.Add('select * from t_ch_fee where 类型=' +''''+'收'+''''+' and 编号=:编号 and ' +open_data('7000','录入人','no','no','no','no') +' order by 顺序,CH_ID'); end; fra_fee1.t_ch_accept.open; end else begin if (strtobool(get_parameters_value(64,'false'))=true) and (if_open('206')=false) then begin fra_fee1.t_ch_accept.close; fra_fee1.t_ch_accept.SQL.Clear; fra_fee1.t_ch_accept.SQL.Add('select * from t_ch_fee where 类型=' +''''+'收'+''''+' and 编号=:编号 and (录入人=' +''''+employee+''''+' or (录入人<>'+''''+employee+'''' +' and 机密<>1) ) order by 顺序,CH_ID'); end; fra_fee1.t_ch_accept.open; end; fra_fee1.a_shen_delete.open; fra_fee1.a_shen_modify_old.open; fra_fee1.a_shen_modify_new.open; fra_fee1.Panel3.visible:=true; end else fra_fee1.Panel3.visible:=false; if if_open('294') then begin fra_fee1.t_ch_pay.DataSource:=t_op_custom1; if (strtobool(get_parameters_value(153,'false'))=true) then begin if (strtobool(get_parameters_value(64,'false'))=true) and (if_open('206')=false) then begin fra_fee1.t_ch_pay.close; fra_fee1.t_ch_pay.SQL.Clear; fra_fee1.t_ch_pay.SQL.Add('select * from t_ch_fee where 类型=' +''''+'付'+''''+' and 编号=:编号 and (录入人=' +''''+employee+''''+' or (录入人<>'+''''+employee+'''' +' and 机密<>1) ) and '+open_data('7000','录入人','no','no','no','no') +' order by 顺序,CH_ID'); end else begin fra_fee1.t_ch_pay.close; fra_fee1.t_ch_pay.SQL.Clear; fra_fee1.t_ch_pay.SQL.Add('select * from t_ch_fee where 类型=' +''''+'付'+''''+' and 编号=:编号 and ' +open_data('7000','录入人','no','no','no','no') +' order by 顺序,CH_ID'); end; fra_fee1.t_ch_pay.open; end else begin if (strtobool(get_parameters_value(64,'false'))=true) and (if_open('206')=false) then begin fra_fee1.t_ch_pay.close; fra_fee1.t_ch_pay.SQL.Clear; fra_fee1.t_ch_pay.SQL.Add('select * from t_ch_fee where 类型=' +''''+'付'+''''+' and 编号=:编号 and (录入人=' +''''+employee+''''+' or (录入人<>'+''''+employee+'''' +' and 机密<>1) ) order by 顺序,CH_ID'); end; fra_fee1.t_ch_pay.open; end; fra_fee1.p_shen_delete.open; fra_fee1.p_shen_modify_old.open; fra_fee1.p_shen_modify_new.open; fra_fee1.Panel1.visible:=true; end else fra_fee1.Panel1.visible:=false; if fra_fee1.Panel1.visible and fra_fee1.Panel3.visible then begin if if_open('253') then begin fra_fee1.Panel8.Visible:=true; fra_fee1.Panel8.Height:=20; end else fra_fee1.Panel8.Visible:=false; fra_fee1.t_op_gain.DataSource:=t_op_custom1; fra_fee1.t_op_gain.open; fra_fee1.Panel9.Visible:=false; end else begin fra_fee1.Panel8.Visible:=false; end; end else begin fra_fee1.Visible:=false; end; if not t_op_file.Active then t_op_file.open; loadwwgrid(fra_fee1.wwDBGrid1,'商检应收'); loadwwgrid(fra_fee1.wwDBGrid2,'商检应付'); end; procedure Tfrm_op_custom.t_op_customBeforePost(DataSet: TDataSet); begin table_before_post(t_op_custom,'序号'); table_before_post(t_op_custom,'报关日期'); table_before_post(t_op_custom,'主提单号'); table_before_post(t_op_custom,'业务类型'); t_op_custom['年月']:=FormatDateTime('YYMM', t_op_custom.fieldbyname('报关日期').AsDateTime); end; procedure Tfrm_op_custom.dxDBGrid2DblClick(Sender: TObject); begin frm_main.view_momo(t_op_custom_items1,'品名'); end; procedure Tfrm_op_custom.t_op_customAfterInsert(DataSet: TDataSet); begin t_op_custom.fieldbyname('业务类型').AsString:='海运出口'; t_op_custom['录入人']:=employee; t_op_custom['报关操作']:=employee; t_op_custom['录入日期']:=date; t_op_custom['分部名称']:=subComp; t_op_custom['操作员']:=employee; t_op_custom['客服员']:=employee; t_op_custom['选择']:=0; t_op_custom['录入费用']:=0; t_op_custom['业务来源']:='青办'; end; procedure Tfrm_op_custom.dxDBGrid1DblClick(Sender: TObject); begin if t_op_custom.fieldbyname('委托编号').AsString<>'' then bsSkinTabSheet2.Show; end; procedure Tfrm_op_custom.bsSkinButton8Click(Sender: TObject); VAR str:widestring; begin str:='where '+open_data('0017','录入人','no','no','no','no'); if wwDBDateTimePicker11.text<>''then str:=str+' and 报关日期>='+''''+wwDBDateTimePicker11.text+''''; if wwDBDateTimePicker13.text<>''then str:=str+' and 报关日期<='+''''+wwDBDateTimePicker13.text+''''; if wwDBDateTimePicker1.text<>''then str:=str+' and 返单日期>='+''''+wwDBDateTimePicker1.text+''''; if wwDBDateTimePicker2.text<>''then str:=str+' and 返单日期<='+''''+wwDBDateTimePicker2.text+''''; str:=query_tiaojian(1,str,'主提单号','模糊', Edit3.text); str:=query_tiaojian(1,str,'报关单号','模糊', Edit1.text); str:=query_tiaojian(1,str,'企业名称','模糊', Edit2.text); str:=query_tiaojian(1,str,'录入人','模糊', Edit4.text); str:=query_tiaojian(1,str,'年月','模糊', Edit5.text); str:=query_tiaojian(1,str,'委托编号','模糊', Edit7.text); str:=query_tiaojian(1,str,'其他单证','模糊', Edit9.text); str:=query_tiaojian(1,str,'品名','模糊', Edit6.text); if Edit8.text<>''then str:=str+' and c_id in ( select c_id from t_op_custom_items where 品名 like '+''''+'%'+Edit8.text+'%'+''')'; t_op_custom.close; t_op_custom.sql.clear; t_op_custom.sql.add('select * from t_op_custom '+str+' order by 报关日期,序号'); t_op_custom.open; t_op_custom.open; t_op_custom_items.Open; end; procedure Tfrm_op_custom.bsSkinButton1Click(Sender: TObject); var i:Integer; BSITEMS:TBSITEMS; begin //获取运抵报关信息 if application.MessageBox('您确定要提取工号吗?','警告:',MB_OKCANCEL)=IDOK then begin if dxdbgrid1.SelectedCount>=1 then begin for i:=0 to dxdbgrid1.SelectedCount-1 do begin t_op_custom.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); t_op_custom.Edit; BSITEMS:=GetWTNO(t_op_custom.fieldbyname('主提单号').AsString); if Trim(BSITEMS.PONO)<>'' then begin t_op_custom['委托编号']:=BSITEMS.PONO; t_op_custom['编号']:=BSITEMS.BSNO; t_op_custom['开船日期']:=BSITEMS.Etd; t_op_custom['业务编号']:=BSITEMS.ywbh; t_op_custom['揽货人']:=BSITEMS.sales; end; t_op_custom.Post; end; end; showmessage('提起完毕!'); end; end; procedure Tfrm_op_custom.bsSkinPageControl1Change(Sender: TObject); begin { if t_op_custom.fieldbyname('委托编号').AsString<>'' then bsSkinPageControl1.ActivePageIndex:=1 else bsSkinPageControl1.ActivePageIndex:=0; } end; procedure Tfrm_op_custom.DBComboBoxEh1Change(Sender: TObject); var BSITEMS:TBSITEMS; begin if t_op_custom=nil then exit; if trim(t_op_custom.fieldbyname('委托编号').AsString)<>'' then begin if (t_op_custom.state=dsinsert)or(t_op_custom.state=dsedit)then begin showmessage('已经存在工号,不能手工修改,请点放弃修改'); t_op_custom.Cancel; end; end else begin if (t_op_custom.state=dsinsert)or(t_op_custom.state=dsedit)then begin BSITEMS:=GetWTNO(t_op_custom.fieldbyname('主提单号').AsString); if Trim(BSITEMS.PONO)<>'' then begin t_op_custom['委托编号']:=BSITEMS.PONO; t_op_custom['编号']:=BSITEMS.BSNO; t_op_custom['开船日期']:=BSITEMS.Etd; t_op_custom['业务编号']:=BSITEMS.ywbh; t_op_custom['揽货人']:=BSITEMS.sales; end; end; end; end; procedure Tfrm_op_custom.bsSkinButton9Click(Sender: TObject); begin t_op_custom.Append; end; procedure Tfrm_op_custom.bsSkinButton10Click(Sender: TObject); begin if not if_open('190') then begin showmessage('对不起你没有此模块的操作权限!'); exit; end; if not assigned(frm_op_seae_apply) then frm_op_seae_apply:=tfrm_op_seae_apply.Create (self); frm_op_seae_apply.ManualDock(frm_main.SearchTabs('frm_op_seae_apply',frm_op_seae_apply.caption,'151'),nil,alClient); frm_op_seae_apply.show; end; procedure Tfrm_op_custom.bsSkinButton11Click(Sender: TObject); begin with SaveDialog do begin DefaultExt :='xls'; Filter := '(*.xls)|*.xls'; if Execute then begin dxDBGrid1.SaveToXLS(FileName,true); end; end; end; procedure Tfrm_op_custom.DBComboBoxEh2Change(Sender: TObject); var aAdoQuery:TAdoQuery; begin if t_op_custom=nil then exit; if (t_op_custom.state=dsinsert)or(t_op_custom.state=dsedit)then begin aAdoQuery:=CreateAdoQuery; with aAdoQuery do try Close;SQL.Clear; SQL.Add('Select top 1 海关代码,企业名称 from t_op_custom where 企业名称<>'''' and 海关代码=:海关代码'); Parameters.ParamByName('海关代码').Value:=DBComboBoxEh2.Text; Open;First; if not IsEmpty then begin if DBComboBoxEh2.Text='' then exit; t_op_custom['企业名称']:=fieldbyname('企业名称').AsString; end; finally Free; end; end; end; procedure Tfrm_op_custom.DBComboBoxEh3Change(Sender: TObject); var aAdoQuery:TAdoQuery; begin if t_op_custom=nil then exit; if (t_op_custom.state=dsinsert)or(t_op_custom.state=dsedit)then begin aAdoQuery:=CreateAdoQuery; with aAdoQuery do try Close;SQL.Clear; SQL.Add('Select top 1 商品编码,品名 from t_op_custom where 品名<>'''' and 商品编码=:商品编码'); Parameters.ParamByName('商品编码').Value:=DBComboBoxEh3.Text; Open;First; if not IsEmpty then begin if DBComboBoxEh3.Text='' then exit; t_op_custom['品名']:=fieldbyname('品名').AsString; end; finally Free; end; end; end; procedure Tfrm_op_custom.Edit3KeyPress(Sender: TObject; var Key: Char); begin if Key=#13 then bsSkinButton8.OnClick(Sender); end; procedure Tfrm_op_custom.Edit1KeyPress(Sender: TObject; var Key: Char); begin if Key=#13 then bsSkinButton8.OnClick(Sender); end; procedure Tfrm_op_custom.wwDBDateTimePicker11KeyPress(Sender: TObject; var Key: Char); begin if Key=#13 then bsSkinButton8.OnClick(Sender); end; procedure Tfrm_op_custom.wwDBDateTimePicker13KeyPress(Sender: TObject; var Key: Char); begin if Key=#13 then bsSkinButton8.OnClick(Sender); end; procedure Tfrm_op_custom.Edit5KeyPress(Sender: TObject; var Key: Char); begin if Key=#13 then bsSkinButton8.OnClick(Sender); end; procedure Tfrm_op_custom.Edit6KeyPress(Sender: TObject; var Key: Char); begin if Key=#13 then bsSkinButton8.OnClick(Sender); end; procedure Tfrm_op_custom.Edit2KeyPress(Sender: TObject; var Key: Char); begin if Key=#13 then bsSkinButton8.OnClick(Sender); end; procedure Tfrm_op_custom.Edit4KeyPress(Sender: TObject; var Key: Char); begin if Key=#13 then bsSkinButton8.OnClick(Sender); end; procedure Tfrm_op_custom.wwDBDateTimePicker1KeyPress(Sender: TObject; var Key: Char); begin if Key=#13 then bsSkinButton8.OnClick(Sender); end; procedure Tfrm_op_custom.wwDBDateTimePicker2KeyPress(Sender: TObject; var Key: Char); begin if Key=#13 then bsSkinButton8.OnClick(Sender); end; procedure Tfrm_op_custom.Edit7KeyPress(Sender: TObject; var Key: Char); begin if Key=#13 then bsSkinButton8.OnClick(Sender); end; procedure Tfrm_op_custom.Edit8KeyPress(Sender: TObject; var Key: Char); begin if Key=#13 then bsSkinButton8.OnClick(Sender); end; procedure Tfrm_op_custom.fra_fee1bsSkinButton11Click(Sender: TObject); begin if BSStatus(t_op_custom.fieldbyname('编号').AsString) then begin ShowMessage('已经费用封账,不能添加或修改'); exit; end; if t_op_custom.fieldbyname('编号').AsString='' then begin ShowMessage('不能输入费用'); exit; end; fra_fee1.bsSkinButton11Click(Sender); end; procedure Tfrm_op_custom.fra_fee1bsSkinButton1Click(Sender: TObject); begin if BSStatus(t_op_custom.fieldbyname('编号').AsString) then begin ShowMessage('已经费用封账,不能添加或修改'); exit; end; if t_op_custom.fieldbyname('编号').AsString='' then begin ShowMessage('不能输入费用'); exit; end; fra_fee1.bsSkinButton1Click(Sender); end; procedure Tfrm_op_custom.fra_fee1bsSkinButton2Click(Sender: TObject); begin fra_fee1.bsSkinButton2Click(Sender); end; procedure Tfrm_op_custom.fra_fee1bsSkinButton4Click(Sender: TObject); begin if BSStatus(t_op_custom.fieldbyname('编号').AsString) then begin ShowMessage('已经费用封账,不能添加或修改'); exit; end; if t_op_custom.fieldbyname('编号').AsString='' then begin ShowMessage('不能输入费用'); exit; end; fra_fee1.bsSkinButton4Click(Sender); end; procedure Tfrm_op_custom.fra_fee1bsSkinButton6Click(Sender: TObject); begin if BSStatus(t_op_custom.fieldbyname('编号').AsString) then begin ShowMessage('已经费用封账,不能添加或修改'); exit; end; if t_op_custom.fieldbyname('编号').AsString='' then begin ShowMessage('不能输入费用'); exit; end; fra_fee1.bsSkinButton6Click(Sender); end; procedure Tfrm_op_custom.fra_fee1bsSkinButton7Click(Sender: TObject); begin if BSStatus(t_op_custom.fieldbyname('编号').AsString) then begin ShowMessage('已经费用封账,不能添加或修改'); exit; end; if t_op_custom.fieldbyname('编号').AsString='' then begin ShowMessage('不能输入费用'); exit; end; fra_fee1.bsSkinButton7Click(Sender); end; procedure Tfrm_op_custom.fra_fee1bsSkinButton10Click(Sender: TObject); begin if BSStatus(t_op_custom.fieldbyname('编号').AsString) then begin ShowMessage('已经费用封账,不能添加或修改'); exit; end; if t_op_custom.fieldbyname('编号').AsString='' then begin ShowMessage('不能输入费用'); exit; end; fra_fee1.bsSkinButton10Click(Sender); end; procedure Tfrm_op_custom.fra_fee1bsSkinButton15Click(Sender: TObject); begin if BSStatus(t_op_custom.fieldbyname('编号').AsString) then begin ShowMessage('已经费用封账,不能添加或修改'); exit; end; if t_op_custom.fieldbyname('编号').AsString='' then begin ShowMessage('不能输入费用'); exit; end; fra_fee1.bsSkinButton15Click(Sender); end; procedure Tfrm_op_custom.fra_fee1bsSkinButton12Click(Sender: TObject); begin if BSStatus(t_op_custom.fieldbyname('编号').AsString) then begin ShowMessage('已经费用封账,不能添加或修改'); exit; end; if t_op_custom.fieldbyname('编号').AsString='' then begin ShowMessage('不能输入费用'); exit; end; fra_fee1.bsSkinButton12Click(Sender); end; procedure Tfrm_op_custom.fra_fee1bsSkinButton17Click(Sender: TObject); begin if BSStatus(t_op_custom.fieldbyname('编号').AsString) then begin ShowMessage('已经费用封账,不能添加或修改'); exit; end; if t_op_custom.fieldbyname('编号').AsString='' then begin ShowMessage('不能输入费用'); exit; end; fra_fee1.bsSkinButton17Click(Sender); end; procedure Tfrm_op_custom.fra_fee1bsSkinButton18Click(Sender: TObject); begin if BSStatus(t_op_custom.fieldbyname('编号').AsString) then begin ShowMessage('已经费用封账,不能添加或修改'); exit; end; if t_op_custom.fieldbyname('编号').AsString='' then begin ShowMessage('不能输入费用'); exit; end; fra_fee1.bsSkinButton18Click(Sender); end; procedure Tfrm_op_custom.bsSkinButton48Click(Sender: TObject); var FileStream:TFileStream; fsize:double; begin //上传附件 if OpenDialog1.Execute then begin FileStream:=TFileStream.Create(Opendialog1.FileName,fmopenRead); //打开文件 try fsize:=FileStream.size; finally freeandnil(FileStream); end; if fsize>500000 then begin MessageDlg('文件不能超过500K!!',mtWarning,[mbyes],0); end else UpLoadPro(Opendialog1.FileName); end else exit ; end; procedure Tfrm_op_custom.bsSkinButton49Click(Sender: TObject); begin //下载附件 if SaveDialog1.Execute then begin DownLoadPro(Savedialog1.FileName+t_op_file.fieldbyname('类型').asstring); end else exit ; end; procedure Tfrm_op_custom.bsSkinButton50Click(Sender: TObject); var arr: array[0..MAX_PATH] of Char; num: DWORD; tmpfile:string ; begin //打开文件 try GetTempPath(MAX_PATH, arr); tmpfile:=arr+t_op_file.fieldbyname('名称').asstring ; DownLoadPro(tmpfile) ; ShellExecute(Handle, nil, pchar(tmpfile), nil, nil, SW_NORMAL); except showmessage('不能打开文件,请检查网络连接等错误!'); end ; end; procedure Tfrm_op_custom.bsSkinButton51Click(Sender: TObject); begin //删除附件 if application.MessageBox('您确定要删除附件吗?','警告:',MB_OKCANCEL)=IDOK then t_op_file.delete ; end; end.