unit u_op_seae_dg; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,IdFTP,IdFTPCommon, Dialogs, bsSkinCtrls, ExtCtrls, DB, ADODB, dxExEdtr, dxCntner, dxTL, dxDBCtrl, dxDBGrid, ComCtrls, bsSkinTabs, RxLookup, StdCtrls, Mask,inifiles, DBCtrls, wwdbdatetimepicker, wwdblook, u_op_sate, u_fee, u_op_card, Menus, dxDBTLCl, dxGrClms, bsdbctrls, XPMenu, wwdbedit, Wwdotdot, Wwdbcomb, Grids, Wwdbigrd, Wwdbgrid, FtpCli, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdIntercept, IdLogBase, IdLogEvent, IdAntiFreezeBase, IdAntiFreeze, dxEditor, dxEdLib, dxDBELib, DBCtrlsEh,ComObj, bsSkinBoxCtrls, IdExplicitTLSClientServerBase,ShellAPI, IdMessageClient, IdSMTPBase, IdSMTP, IdMessage; type Tfrm_op_seae_dg = class(TForm) Panel2: TPanel; bsSkinButton7: TbsSkinButton; bsSkinButton6: TbsSkinButton; bsSkinButton11: TbsSkinButton; bsSkinButton2: TbsSkinButton; bsSkinButton4: TbsSkinButton; bsSkinButton3: TbsSkinButton; bsSkinButton5: TbsSkinButton; bsSkinButton38: TbsSkinButton; Notebook1: TNotebook; t_op_seae: TADOQuery; t_op_seae1: TDataSource; dxDBGrid1: TdxDBGrid; bsSkinPageControl1: TbsSkinPageControl; bsSkinTabSheet1: TbsSkinTabSheet; bsSkinPanel1: TbsSkinPanel; Label5: TLabel; Label38: TLabel; DBEdit4: TDBEdit; DBEdit9: TDBEdit; PopupMenu3: TPopupMenu; N37: TMenuItem; N38: TMenuItem; N62: TMenuItem; N25: TMenuItem; N64: TMenuItem; N63: TMenuItem; N17: TMenuItem; N18: TMenuItem; N34: TMenuItem; N35: TMenuItem; N36: TMenuItem; dxDBGrid1Column1: TdxDBGridMaskColumn; dxDBGrid1Column6: TdxDBGridMaskColumn; dxDBGrid1Column8: TdxDBGridMaskColumn; dxDBGrid1Column10: TdxDBGridMaskColumn; dxDBGrid1Column11: TdxDBGridMaskColumn; dxDBGrid1Column12: TdxDBGridDateColumn; dxDBGrid1Column13: TdxDBGridMaskColumn; dxDBGrid1Column14: TdxDBGridMaskColumn; dxDBGrid1Column15: TdxDBGridMaskColumn; dxDBGrid1Column16: TdxDBGridMaskColumn; dxDBGrid1Column18: TdxDBGridMaskColumn; dxDBGrid1Column19: TdxDBGridDateColumn; dxDBGrid1Column17: TdxDBGridColumn; XPMenu1: TXPMenu; PopupMenu2: TPopupMenu; N10: TMenuItem; N11: TMenuItem; N14: TMenuItem; N13: TMenuItem; N12: TMenuItem; N15: TMenuItem; N16: TMenuItem; bsSkinPanel2: TbsSkinPanel; Label47: TLabel; Label49: TLabel; Label51: TLabel; wwDBDateTimePicker9: TwwDBDateTimePicker; wwDBDateTimePicker11: TwwDBDateTimePicker; Edit3: TEdit; wwDBDateTimePicker12: TwwDBDateTimePicker; Label52: TLabel; wwDBDateTimePicker13: TwwDBDateTimePicker; Label53: TLabel; bsSkinButton8: TbsSkinButton; bsSkinButton12: TbsSkinButton; bsSkinButton14: TbsSkinButton; PopupMenu1: TPopupMenu; N1: TMenuItem; dxDBGrid1Column65: TdxDBGridColumn; dxDBGrid1Column67: TdxDBGridColumn; bsSkinPanel3: TbsSkinPanel; Label36: TLabel; DBEdit38: TDBEdit; Label37: TLabel; DBEdit39: TDBEdit; Label40: TLabel; Label44: TLabel; DBEdit42: TDBEdit; t_op_ctn1: TDataSource; t_op_ctn: TADOQuery; Label43: TLabel; DBEdit18: TDBEdit; bsSkinPanel5: TbsSkinPanel; SaveDialog1: TSaveDialog; dxDBGrid1Column20: TdxDBGridColumn; dxDBGrid1Column21: TdxDBGridColumn; dxDBGrid1Column22: TdxDBGridColumn; Label217: TLabel; wwDBLookupCombo26: TwwDBLookupCombo; Label218: TLabel; Edit8: TEdit; Label81: TLabel; Edit2: TEdit; Label58: TLabel; wwDBComboBoxOP: TwwDBComboBox; OpenDialog1: TOpenDialog; bsSkinTabSheet2: TbsSkinTabSheet; dxDBGrid4: TdxDBGrid; dxDBGrid4Column2: TdxDBGridColumn; dxDBGridColumn10: TdxDBGridColumn; dxDBGrid4Column3: TdxDBGridColumn; bsSkinGroupBox13: TbsSkinGroupBox; bsSkinPanel14: TbsSkinPanel; bsSkinButton48: TbsSkinButton; bsSkinButton49: TbsSkinButton; bsSkinButton50: TbsSkinButton; bsSkinButton51: TbsSkinButton; bsSkinButton66: TbsSkinButton; dxDBGrid3: TdxDBGrid; dxDBGrid2fid: TdxDBGridMaskColumn; dxDBGrid2rl_id: TdxDBGridMaskColumn; dxDBGridColumn1: TdxDBGridColumn; dxDBGridColumn2: TdxDBGridColumn; dxDBGridColumn3: TdxDBGridColumn; dxDBGridDateColumn1: TdxDBGridDateColumn; dxDBGridColumn4: TdxDBGridColumn; dxDBGridColumn5: TdxDBGridColumn; t_op_file_data: TADOQuery; dsrFuJian: TDataSource; t_op_file_items_data1: TDataSource; t_op_file_items_data: TADOQuery; dxDBGrid1Column23: TdxDBGridColumn; dxDBGrid1Column24: TdxDBGridColumn; dxDBGrid1Column25: TdxDBGridColumn; bsSkinButton29: TbsSkinButton; bsSkinButton30: TbsSkinButton; dxDBGrid1Column26: TdxDBGridColumn; dxDBGrid1Column27: TdxDBGridColumn; dxDBGrid1Column28: TdxDBGridColumn; dxDBGrid1Column29: TdxDBGridColumn; dxDBGrid1Column30: TdxDBGridColumn; dxDBGrid1Column32: TdxDBGridColumn; Label19: TLabel; RxDBLookupCombo12: TRxDBLookupCombo; Label16: TLabel; RxDBLookupCombo49: TRxDBLookupCombo; Label134: TLabel; RxDBLookupCombo14: TRxDBLookupCombo; RxDBLookupCombo6: TRxDBLookupCombo; Label9: TLabel; Label2: TLabel; DBEdit2: TDBEdit; DBEdit3: TDBEdit; bsSkinGroupBox1: TbsSkinGroupBox; Label3: TLabel; DBEdit5: TDBEdit; Label4: TLabel; DBEdit6: TDBEdit; Label6: TLabel; DBEdit7: TDBEdit; Label7: TLabel; DBEdit8: TDBEdit; Label8: TLabel; Label10: TLabel; DBEdit11: TDBEdit; Label11: TLabel; DBEdit12: TDBEdit; Label12: TLabel; DBEdit13: TDBEdit; Label13: TLabel; DBEdit14: TDBEdit; Label14: TLabel; DBEdit15: TDBEdit; Label15: TLabel; DBEdit16: TDBEdit; Label20: TLabel; DBEdit20: TDBEdit; DBEdit21: TDBEdit; Label21: TLabel; Label22: TLabel; DBEdit22: TDBEdit; bsSkinGroupBox2: TbsSkinGroupBox; Label23: TLabel; DBEdit23: TDBEdit; Label24: TLabel; DBEdit24: TDBEdit; Label25: TLabel; DBEdit25: TDBEdit; DBEdit26: TDBEdit; Label26: TLabel; Label27: TLabel; DBEdit27: TDBEdit; Label17: TLabel; DBEdit17: TDBEdit; Label18: TLabel; Label28: TLabel; Label29: TLabel; DBEdit29: TDBEdit; Label30: TLabel; Label31: TLabel; DBEdit31: TDBEdit; bsSkinGroupBox3: TbsSkinGroupBox; Label33: TLabel; DBEdit33: TDBEdit; bsSkinButton77: TbsSkinButton; Label34: TLabel; DBEdit34: TDBEdit; bsSkinButton1: TbsSkinButton; DBEdit35: TDBEdit; Label35: TLabel; bsSkinButton9: TbsSkinButton; bsSkinButton10: TbsSkinButton; bsSkinGroupBox6: TbsSkinGroupBox; wwDBGrid1: TwwDBGrid; bsSkinPanel9: TbsSkinPanel; btnMarks: TbsSkinButton; btnDesc: TbsSkinButton; bsSkinTabSheet3: TbsSkinTabSheet; dxDBGrid2: TdxDBGrid; dxDBGridMaskColumn1: TdxDBGridMaskColumn; dxDBGrid1Column2: TdxDBGridMaskColumn; bsSkinPanel4: TbsSkinPanel; bsSkinPanel6: TbsSkinPanel; bsSkinButton17: TbsSkinButton; bsSkinButton16: TbsSkinButton; bsSkinButton15: TbsSkinButton; bsSkinButton13: TbsSkinButton; t_op_seae_dg_except1: TDataSource; t_op_seae_dg_except: TADOQuery; dxDBGrid2Column3: TdxDBGridColumn; dxDBGrid2Column4: TdxDBGridColumn; dxDBGrid2Column5: TdxDBGridColumn; dxDBGrid2Column6: TdxDBGridColumn; dxDBGrid2Column7: TdxDBGridColumn; dxDBGrid2Column8: TdxDBGridColumn; Label32: TLabel; DBEdit32: TDBEdit; wwDBComboBox1: TwwDBComboBox; wwDBDateTimePicker2: TwwDBDateTimePicker; Label39: TLabel; Label41: TLabel; Label42: TLabel; DBMemo1: TDBMemo; Label45: TLabel; DBMemo2: TDBMemo; IdMsg: TIdMessage; SMTP1: TIdSMTP; bsSkinDBCheckRadioBox23: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox1: TbsSkinDBCheckRadioBox; wwDBComboBox2: TwwDBComboBox; wwDBComboBox3: TwwDBComboBox; wwDBComboBox4: TwwDBComboBox; wwDBComboBox5: TwwDBComboBox; dxDBGrid1Column33: TdxDBGridColumn; bsSkinButton27: TbsSkinButton; t_sys_dgemployee: TADOQuery; t_sys_dgemployee1: TDataSource; RxDBLookupCombo60: TRxDBLookupCombo; Label1: TLabel; DBEdit1: TDBEdit; bsSkinDBCheckRadioBox2: TbsSkinDBCheckRadioBox; dxDBGrid1Column31: TdxDBGridColumn; DBEdit10: TDBEdit; Label46: TLabel; dxDBGrid1Column34: TdxDBGridColumn; bsSkinButton18: TbsSkinButton; dxDBGrid1Column35: TdxDBGridColumn; dxDBGrid1Column36: TdxDBGridColumn; dxDBGrid1Column37: TdxDBGridColumn; bsSkinGroupBox4: TbsSkinGroupBox; DBMemo3: TDBMemo; dxDBGrid1Column38: TdxDBGridColumn; bsSkinPanel7: TbsSkinPanel; bsSkinButton19: TbsSkinButton; t_ch_project: TADOQuery; t_ch_project1: TDataSource; t_ch_project_fee1: TDataSource; t_ch_project_fee: TADOQuery; t_ch_fee: TADOQuery; t_op_seae_fee: TADOQuery; dxDBGrid1Column39: TdxDBGridColumn; dxDBGrid1Column40: TdxDBGridColumn; RxDBLookupCombo1: TRxDBLookupCombo; DBEdit19: TDBEdit; Label48: TLabel; RxDBLookupCombo15: TRxDBLookupCombo; Label50: TLabel; dxDBGrid1Column41: TdxDBGridCheckColumn; procedure bsSkinButton5Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure Panel2Resize(Sender: TObject); procedure bsSkinButton7Click(Sender: TObject); procedure bsSkinButton6Click(Sender: TObject); procedure bsSkinButton2Click(Sender: TObject); procedure bsSkinButton11Click(Sender: TObject); procedure bsSkinButton4Click(Sender: TObject); procedure bsSkinButton3Click(Sender: TObject); procedure bsSkinButton38Click(Sender: TObject); procedure FormShow(Sender: TObject); procedure N10Click(Sender: TObject); procedure N14Click(Sender: TObject); procedure N12Click(Sender: TObject); procedure N16Click(Sender: TObject); procedure bsSkinButton8Click(Sender: TObject); procedure bsSkinButton12Click(Sender: TObject); procedure bsSkinButton14Click(Sender: TObject); procedure bsSkinButton56Click(Sender: TObject); procedure bsSkinButton57Click(Sender: TObject); procedure bsSkinButton58Click(Sender: TObject); procedure bsSkinButton59Click(Sender: TObject); procedure bsSkinButton48Click(Sender: TObject); procedure bsSkinButton18Click(Sender: TObject); procedure bsSkinButton22Click(Sender: TObject); procedure btnSealClick(Sender: TObject); procedure wwDBComboBoxOPDropDown(Sender: TObject); procedure N23Click(Sender: TObject); procedure dxDBGrid4Click(Sender: TObject); procedure t_op_file_items_dataAfterDelete(DataSet: TDataSet); procedure t_op_file_items_dataAfterInsert(DataSet: TDataSet); procedure t_op_file_items_dataAfterPost(DataSet: TDataSet); procedure bsSkinButton66Click(Sender: TObject); procedure bsSkinButton49Click(Sender: TObject); procedure bsSkinButton50Click(Sender: TObject); procedure bsSkinButton51Click(Sender: TObject); procedure bsSkinButton27Click(Sender: TObject); procedure dxDBGrid1CustomDraw(Sender: TObject; ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxDBTreeListColumn; const AText: String; AFont: TFont; var AColor: TColor; ASelected, AFocused: Boolean; var ADone: Boolean); procedure t_op_file_dataAfterPost(DataSet: TDataSet); procedure bsSkinPageControl1Change(Sender: TObject); procedure DBEdit1Change(Sender: TObject); procedure N27Click(Sender: TObject); procedure bsSkinButton29Click(Sender: TObject); procedure bsSkinButton30Click(Sender: TObject); procedure bsSkinButton13Click(Sender: TObject); procedure bsSkinButton17Click(Sender: TObject); procedure bsSkinButton15Click(Sender: TObject); procedure bsSkinButton16Click(Sender: TObject); procedure t_op_seae_dg_exceptBeforePost(DataSet: TDataSet); procedure N1Click(Sender: TObject); procedure bsSkinButton77Click(Sender: TObject); procedure bsSkinButton1Click(Sender: TObject); procedure btnMarksClick(Sender: TObject); procedure btnDescClick(Sender: TObject); procedure dxDBGrid1Column31GetText(Sender: TObject; ANode: TdxTreeListNode; var AText: String); procedure dxDBGrid1ColumnSorting(Sender: TObject; Column: TdxDBTreeListColumn; var Allow: Boolean); procedure bsSkinButton19Click(Sender: TObject); procedure Edit3KeyPress(Sender: TObject; var Key: Char); procedure RxDBLookupCombo1Enter(Sender: TObject); procedure RxDBLookupCombo1Exit(Sender: TObject); private { Private declarations } AbortTransfer: Boolean; TransferrignData: Boolean; BytesToTransfer: LongWord; STime: TDateTime; procedure setconcolor; //设置控件的颜色 function istrueAFR(Dataset:TDataSet):Boolean; procedure createAFR(bltype:string;filepath:string); function getCtnAfr(code:string):string; function getPkgAfr(code:string):string; function formatAfrstr(str:string):string; procedure PutToDebugLog(Operation, S1: String); public { Public declarations } naspath:widestring; procedure UpdateCTN(BSNO:STRING); procedure UpLoadPro(fname: string); procedure UpLoadProFile(fname,RemotePathName,Users,pw,mblNo: string); //fname包含完整路径、文件名 procedure DownLoadPro(fname: string); procedure DownLoadProFils(RemotePathName,Users,pw,fname: string); //从数据库的表中下载 procedure SendMail(sendto,subjectstr:string;bodylist:TStringList); function fee_get_client(str:string):string; end; var frm_op_seae_dg: Tfrm_op_seae_dg; AverageSpeed: Double = 0; frm_op_seae_dg_create:boolean; opsqlstr,opsumsqlstr:string; implementation uses u_main,u_data_share, my_sys_function, u_sys_progress, u_op_seae; {$R *.dfm} procedure Tfrm_op_seae_dg.setconcolor; begin end; procedure Tfrm_op_seae_dg.bsSkinButton5Click(Sender: TObject); begin close; end; procedure Tfrm_op_seae_dg.FormClose(Sender: TObject; var Action: TCloseAction); begin savereggrid(dxdbgrid1,caption); frm_op_seae_dg.Hide; frm_op_seae_dg.ManualFloat(frm_op_seae_dg.BoundsRect ); frm_main.freeTabs('frm_op_seae_dg'); frm_op_seae_dg_create:=false; action:=cafree; frm_op_seae_dg:=nil; end; procedure Tfrm_op_seae_dg.Panel2Resize(Sender: TObject); var i:integer; begin i:=round(Panel2.Width/14); bsSkinButton7.Width:=i; bsSkinButton6.Width:=i; bsSkinButton11.Width:=i; bsSkinButton14.Width:=i; bsSkinButton2.Width:=i; bsSkinButton4.Width:=i; bsSkinButton3.Width:=i; bsSkinButton38.Width:=i; end; procedure Tfrm_op_seae_dg.bsSkinButton7Click(Sender: TObject); begin table_Prior(t_op_seae); end; procedure Tfrm_op_seae_dg.bsSkinButton6Click(Sender: TObject); begin table_next(t_op_seae); end; procedure Tfrm_op_seae_dg.bsSkinButton2Click(Sender: TObject); var aQuery:TADOQuery; begin table_post(t_op_seae); aQuery:=CreateAdoQuery; try with aQuery do begin close;sql.clear; SQL.Text:='update t_op_seae set 危品申报员='''+t_op_seae.fieldbyname('申报员').asstring+''' where 编号='''+t_op_seae.fieldbyname('主编号').AsString+''''; ExecSQL; end; finally FreeAndNil(aQuery); end; end; procedure Tfrm_op_seae_dg.bsSkinButton11Click(Sender: TObject); var answer:TModalResult; begin if bsSkinButton11.Caption='编辑修改' then begin Notebook1.PageIndex:=1; bsSkinButton11.Caption:='返回列表'; DBEdit3.OnChange(Sender); end else begin if (t_op_seae.State=dsinsert)or(t_op_seae.State=dsedit) then BEGIN answer:=messagedlg( '数据已经修改,是否保存?',mtWarning,mbYesNoCancel,0); if answer=mrYes then begin t_op_seae.post; end; if answer=mrNo then begin t_op_seae.cancel; end; if answer=mrCancel then begin exit; end; END; Notebook1.PageIndex:=0; bsSkinButton11.Caption:='编辑修改'; end; end; procedure Tfrm_op_seae_dg.bsSkinButton4Click(Sender: TObject); var i,j:Integer; strno:string; aQuery:TADOQuery; begin j:=dxDBGrid1.SelectedCount; strno:=' where 1=2 '; for i:=0 to j-1 do begin t_op_seae.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); strno:=strno+' or 编号='''+t_op_seae.fieldbyname('编号').asstring+''''; end; if MessageDlg('确定要删除选中的'+inttostr(j)+'票业务数据吗?',mtWarning,[mbyes,mbno],0)=mryes then begin aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add(' delete from t_op_seae_dg_ctn '+strno); ExecSQL; Close;SQL.Clear; SQL.Add(' delete from t_op_seae_dg_except '+strno); ExecSQL; Close;SQL.Clear; SQL.Add(' delete from t_op_seae_dg '+strno); ExecSQL; end; finally FreeAndNil(aQuery); end; t_op_seae.Refresh; end; end; procedure Tfrm_op_seae_dg.bsSkinButton3Click(Sender: TObject); begin table_cancel(t_op_seae); end; procedure Tfrm_op_seae_dg.bsSkinButton38Click(Sender: TObject); var book1:Tbookmark; begin book1:=t_op_seae.GetBookmark; t_op_seae.Refresh; t_op_seae.GotoBookmark(book1); end; procedure Tfrm_op_seae_dg.FormShow(Sender: TObject); begin Notebook1.PageIndex:=0; 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.bsSkinGauge1.MaxValue:=28; frm_sys_progress.bsSkinGauge1.MinValue:=0; frm_sys_progress.bsSkinGauge1.Value:=0; frm_sys_progress.Update; //委托编号处理 naspath:=get_parameters_value(175,'\\223.223.95.160\data'); t_op_seae.Close; t_op_seae.SQL.clear; t_op_seae.SQL.Add('select top 100 * from t_op_seae_dg where ' +'(申报员='+''''+employee+''''+') order by 录入日期 desc '); t_op_seae.open; opsqlstr:=t_op_seae.sql.Text; t_op_ctn.Open; t_op_file_data.Open; t_sys_dgemployee.Open; frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; loadreggrid(dxdbgrid1,false,caption); frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; frm_op_seae_dg_create:=true; frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; frm_sys_progress.close; frm_sys_progress:=nil; end; procedure Tfrm_op_seae_dg.N10Click(Sender: TObject); begin update_grid_view_no(dxdbgrid1); end; procedure Tfrm_op_seae_dg.N14Click(Sender: TObject); begin update_grid_view_all(dxdbgrid1); end; procedure Tfrm_op_seae_dg.N12Click(Sender: TObject); begin update_grid(dxdbgrid1,212); end; procedure Tfrm_op_seae_dg.N16Click(Sender: TObject); begin grid_save_xls(dxdbgrid1); end; procedure Tfrm_op_seae_dg.bsSkinButton8Click(Sender: TObject); VAR str:widestring; ini:TIniFile; s1,s2:string; begin str:='where 1=1 AND '+open_data('0001','录入人','no','no','no','no'); if Edit3.text<>''then str:=str+' and 主提单号 like '+''''+'%'+Edit3.text+'%'+''''; if wwDBDateTimePicker9.text<>''then str:=str+' and 录入日期>='+''''+wwDBDateTimePicker9.text+''''; if wwDBDateTimePicker12.text<>''then str:=str+' and 录入日期<='+''''+wwDBDateTimePicker12.text+''''; if wwDBDateTimePicker11.text<>''then str:=str+' and 开船日期>='+''''+wwDBDateTimePicker11.text+''''; if wwDBDateTimePicker13.text<>''then str:=str+' and 开船日期<='+''''+wwDBDateTimePicker13.text+''''; if wwDBComboBoxOP.text<>''then str:=str+' and 录入人='+''''+wwDBComboBoxOP.text+''''; str:=query_tiaojian(1,str,'船名','模糊',wwDBLookupCombo26.text); str:=query_tiaojian(1,str,'航次','模糊',Edit8.text); t_op_seae.close; t_op_seae.sql.clear; t_op_seae.sql.add('select * from t_op_seae_dg '+str+' order by 录入日期 desc'); t_op_seae.open; //if opsqlstr<>t_op_seae.sql.Text then opsqlstr:=t_op_seae.sql.Text; ini:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini'); s1:=Ini.ReadString('EDI_DATA','t_op_seae',''); if opsqlstr<>s1 then begin Ini.WriteString('EDI_DATA','t_op_seae',t_op_seae.SQL.CommaText); opsqlstr:=s1; end; Ini.Free; end; procedure Tfrm_op_seae_dg.bsSkinButton12Click(Sender: TObject); begin Edit3.text:=''; Edit8.text:=''; Edit2.text:=''; wwDBDateTimePicker9.text:=''; wwDBDateTimePicker12.text:=''; wwDBDateTimePicker11.text:=''; wwDBDateTimePicker13.text:=''; wwDBLookupCombo26.Clear; end; procedure Tfrm_op_seae_dg.bsSkinButton14Click(Sender: TObject); var Pnt:Tpoint; begin Pnt:=bsSkinButton14.ClientToScreen(Point(0,bsSkinButton14.Height)); PopupMenu1.Popup(Pnt.x,Pnt.y); end; procedure Tfrm_op_seae_dg.bsSkinButton56Click(Sender: TObject); begin t_op_ctn.insert; end; procedure Tfrm_op_seae_dg.bsSkinButton57Click(Sender: TObject); begin table_post(t_op_ctn); end; procedure Tfrm_op_seae_dg.bsSkinButton58Click(Sender: TObject); begin table_delete(t_op_ctn); end; procedure Tfrm_op_seae_dg.bsSkinButton59Click(Sender: TObject); begin table_cancel(t_op_ctn); end; procedure Tfrm_op_seae_dg.bsSkinButton48Click(Sender: TObject); var FileStream:TFileStream; fsize:double; begin { if t_op_file.RecordCount <=0 then begin ShowMessage('请点<提取类型>按钮'); Exit; end; } if t_op_file_data.RecordCount<=0 then begin t_op_file_data.Append; t_op_file_data.FieldByName('文件类型').AsString:='申报信息'; t_op_file_data.FieldByName('备注').AsString:='是'; t_op_file_data.Post; t_op_file_data.Append; t_op_file_data.FieldByName('文件类型').AsString:='保函'; t_op_file_data.FieldByName('备注').AsString:='否'; t_op_file_data.Post; t_op_file_data.First; end; with t_op_file_items_data do begin Close;SQL.Clear; sql.Add('select * from t_op_file_items'); sql.Add('where PID=:PID and 编号=:编号'); Parameters.ParamByName('PID').Value:=t_op_file_data.FieldByName('fid').AsInteger; Parameters.ParamByName('编号').Value:=t_op_file_data.FieldByName('编号').AsString; Open; end; //上传附件 if OpenDialog1.Execute then begin if Length(Opendialog1.FileName)<=95 then begin FileStream:=TFileStream.Create(Opendialog1.FileName,fmopenRead); //打开文件 try fsize:=FileStream.size; finally freeandnil(FileStream); end; if fsize>5000000 then begin MessageDlg('文件不能超过5M!!',mtWarning,[mbyes],0); end else UpLoadProFile(Opendialog1.FileName,naspath,'user','user',frm_op_seae_dg.t_op_seae.fieldbyname('主提单号').AsString); end else begin MessageDlg('文件名太长,不能超过95个字符!!',mtWarning,[mbyes],0); exit ; end; end else exit ; end; {procedure Tfrm_op_seae_edi_data.bsSkinButton48Click(Sender: TObject); var FileStream:TFileStream; fsize:double; begin if t_op_file_data.RecordCount<=0 then begin t_op_file_data.Append; t_op_file_data.FieldByName('文件类型').AsString:='舱单'; t_op_file_data.FieldByName('备注').AsString:='是'; t_op_file_data.Post; t_op_file_data.Append; t_op_file_data.FieldByName('文件类型').AsString:='海关数据'; t_op_file_data.FieldByName('备注').AsString:='是'; t_op_file_data.Post; t_op_file_data.First; end; with t_op_file_items_data do begin Close;SQL.Clear; sql.Add('select * from t_op_file_items'); sql.Add('where PID=:PID and 编号=:编号'); Parameters.ParamByName('PID').Value:=t_op_file_data.FieldByName('fid').AsInteger; Parameters.ParamByName('编号').Value:=t_op_file_data.FieldByName('编号').AsString; Open; end; //上传附件 if OpenDialog1.Execute then begin if Length(Opendialog1.FileName)<=95 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 begin MessageDlg('文件名太长,不能超过95个字符!!',mtWarning,[mbyes],0); exit ; end; end else exit ; end; } procedure Tfrm_op_seae_dg.createAFR(bltype:string;filepath:string); begin end; function Tfrm_op_seae_dg.istrueAFR(Dataset: TDataSet): Boolean; begin end; function Tfrm_op_seae_dg.getCtnAfr(code: string): string; begin end; function Tfrm_op_seae_dg.getPkgAfr(code: string): string; begin end; function Tfrm_op_seae_dg.formatAfrstr(str: string): string; begin Result:=Trim(str); Result:=StringReplace(Result,'&','&',[rfReplaceAll]); Result:=StringReplace(Result,'<','<',[rfReplaceAll]); Result:=StringReplace(Result,'"','"',[rfReplaceAll]); Result:=StringReplace(Result,'>','>',[rfReplaceAll]); Result:=StringReplace(Result,'''',''',[rfReplaceAll]); end; procedure Tfrm_op_seae_dg.bsSkinButton18Click(Sender: TObject); var inifile1:Tinifile; begin if t_op_ctn.isempty then exit; if application.MessageBox('您确定要删除数据吗?','警告:',MB_OKCANCEL)<>IDOK then exit; t_op_ctn.delete; end; procedure Tfrm_op_seae_dg.PutToDebugLog(Operation, S1: String); begin end; procedure Tfrm_op_seae_dg.bsSkinButton22Click(Sender: TObject); var Pnt:Tpoint; begin if t_op_seae1.DataSet=nil then exit; if (t_op_seae1.DataSet.State=dsinsert)or(t_op_seae1.DataSet.State=dsedit) then t_op_seae1.DataSet.post; end; procedure Tfrm_op_seae_dg.btnSealClick(Sender: TObject); begin frm_main.view_momo(t_op_ctn1,'封号'); end; procedure Tfrm_op_seae_dg.wwDBComboBoxOPDropDown(Sender: TObject); var AdoQuery1:TAdoQuery; begin wwDBComboBoxOP.items.clear; AdoQuery1:=CreateAdoQuery; with AdoQuery1 do try Close;sql.Clear; SQL.Add('select * from t_sys_employee where 状态=''在职'''); SQL.Add('Order by 姓名'); Open;first; while not Eof do begin wwDBComboBoxOP.Items.Add(AdoQuery1.fieldbyname('姓名').AsString); Next; end; finally Free; end; end; procedure Tfrm_op_seae_dg.UpdateCTN(BSNO:STRING); begin end; procedure Tfrm_op_seae_dg.N23Click(Sender: TObject); var id:string; begin end; procedure Tfrm_op_seae_dg.dxDBGrid4Click(Sender: TObject); begin with t_op_file_items_data do begin Close;SQL.Clear; sql.Add('select * from t_op_file_items'); sql.Add('where PID=:PID and 编号=:编号'); Parameters.ParamByName('PID').Value:=t_op_file_data.FieldByName('fid').AsInteger; Parameters.ParamByName('编号').Value:=t_op_file_data.FieldByName('编号').AsString; Open; end; end; procedure Tfrm_op_seae_dg.t_op_file_items_dataAfterDelete( DataSet: TDataSet); begin t_op_file_data.Edit; t_op_file_data.FieldByName('大小').AsInteger:=t_op_file_items_data.RecordCount; t_op_file_data.Post; end; procedure Tfrm_op_seae_dg.t_op_file_items_dataAfterInsert( DataSet: TDataSet); begin t_op_file_items_data.FieldByName('PID').AsInteger:=t_op_file_data.FieldByName('fID').AsInteger; t_op_file_items_data.FieldByName('编号').AsString:=t_op_file_data.FieldByName('编号').AsString; end; procedure Tfrm_op_seae_dg.t_op_file_items_dataAfterPost( DataSet: TDataSet); begin t_op_file_data.Edit; t_op_file_data.FieldByName('大小').AsInteger:=t_op_file_items_data.RecordCount; t_op_file_data.Post; end; procedure Tfrm_op_seae_dg.bsSkinButton66Click(Sender: TObject); begin if t_op_file_data.RecordCount<=0 then begin t_op_file_data.Append; t_op_file_data.FieldByName('文件类型').AsString:='申报信息'; t_op_file_data.FieldByName('备注').AsString:='是'; t_op_file_data.Post; t_op_file_data.Append; t_op_file_data.FieldByName('文件类型').AsString:='保函'; t_op_file_data.FieldByName('备注').AsString:='否'; t_op_file_data.Post; { t_op_file_data.Append; t_op_file_data.FieldByName('文件类型').AsString:='海关数据'; t_op_file_data.FieldByName('备注').AsString:='是'; t_op_file_data.Post; } t_op_file_data.First; end; end; procedure Tfrm_op_seae_dg.bsSkinButton49Click(Sender: TObject); begin if t_op_file_data.IsEmpty then exit; //下载附件 if t_op_file_items_data.fieldbyname('文件存储').AsBoolean then begin DownLoadProFils(naspath,'user','user',t_op_file_items_data.fieldbyname('名称').asstring); end else begin if SaveDialog1.Execute then begin DownLoadPro(Savedialog1.FileName+t_op_file_items_data.fieldbyname('类型').asstring); end else exit ; end; { if t_op_file_data.IsEmpty then exit; //下载附件 if SaveDialog1.Execute then begin DownLoadPro(Savedialog1.FileName+t_op_file_data.fieldbyname('类型').asstring); end else exit ; } end; procedure Tfrm_op_seae_dg.bsSkinButton50Click(Sender: TObject); var arr: array[0..MAX_PATH] of Char; num: DWORD; tmpfile:string ; begin if t_op_file_data.IsEmpty then exit; //打开文件 try GetTempPath(MAX_PATH, arr); tmpfile:=arr+t_op_file_items_data.fieldbyname('名称').asstring ; DownLoadPro(tmpfile) ; ShellExecute(Handle, nil, pchar(tmpfile), nil, nil, SW_NORMAL); except showmessage('不能打开文件,请检查!'); end ; end; procedure Tfrm_op_seae_dg.bsSkinButton51Click(Sender: TObject); begin if t_op_file_data.IsEmpty then exit; //删除附件 if application.MessageBox('您确定要删除附件吗?','警告:',MB_OKCANCEL)=IDOK then t_op_file_items_data.delete ; end; procedure Tfrm_op_seae_dg.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_items_data 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; // frm_sys_progress.close; //frm_sys_progress:=nil; //frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; frm_sys_progress.close; frm_sys_progress:=nil; end; end; end; procedure Tfrm_op_seae_dg.DownLoadProFils(RemotePathName,Users,pw,fname: string); var path,newpath,Filters:string; NetSource :TNetResource; begin with NetSource do begin dwType := RESOURCETYPE_ANY; lpLocalName :=''; // 将远程资源映射到此驱动器 lpRemoteName:=pChar(RemotePathName); // 远程网络资源 lpProvider :=''; end; WnetAddConnection2(NetSource, pChar(Users),pChar(pw),CONNECT_UPDATE_PROFILE); with SaveDialog1 do begin FileName:=ExtractFileName(fname); Filters:=ExtractFileExt(fname); Filter:='*'+ExtractFileExt(fname); if Execute then begin path:=fname; newpath:=SaveDialog1.FileName+Filters; if CopyFile(pChar(path),pChar(newpath),false) then //showmessage('下载成功') else showmessage('下载失败'); end; end; try finally WNetCancelConnection2(pChar(RemotePathName),CONNECT_UPDATE_PROFILE,True); end; end; procedure Tfrm_op_seae_dg.UpLoadProFile(fname,RemotePathName,Users,pw,mblNo: string); var path,newpath:string; NetSource :TNetResource; filename,fileExt,filePath: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) ; with NetSource do begin dwType := RESOURCETYPE_ANY; lpLocalName :=''; // 将远程资源映射到此驱动器 lpRemoteName:=pChar(RemotePathName); // 远程网络资源 lpProvider :=''; end; WnetAddConnection2(NetSource, pChar(Users),pChar(pw),CONNECT_UPDATE_PROFILE); filePath:=FormatDateTime('YYYYMM',DatabaseDateTime); if not DirectoryExists(RemotePathName+'\'+filePath) then MkDir(RemotePathName+'\'+filePath); if not DirectoryExists(RemotePathName+'\'+filePath+'\'+mblNo) then MkDir(RemotePathName+'\'+filePath+'\'+mblNo); newpath:=RemotePathName+'\'+filePath+'\'+mblNo+'\'+filename; if CopyFile(pChar(fname),pChar(newpath),false) then // showmessage('备份成功') else showmessage('备份失败'); { if not DirectoryExists(RemotePathName+'\'+mblNo) then MkDir(RemotePathName+'\'+mblNo); newpath:=RemotePathName+'\'+mblNo+'\'+filename; if CopyFile(pChar(fname),pChar(newpath),false) then // showmessage('备份成功') else showmessage('备份失败'); } try finally WNetCancelConnection2(pChar(RemotePathName),CONNECT_UPDATE_PROFILE,True); end; with t_op_file_items_data do begin Open; append; try FieldByName('名称').AsString:=newpath; FieldByName('上传日期').AsDateTime:=now(); FieldByName('所有者').Asstring:=employee; FieldByName('类型').Asstring:=fileExt; FieldByName('文件存储').AsBoolean:=true; 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; end; end; end; procedure Tfrm_op_seae_dg.UpLoadPro(fname: string); const BufSize=$F000; var Counter, N: Integer; Buffer: PAnsiChar; FieldStrm: TStream; ExeFileStream:TFileStream; //ExeFileStream:TMemoryStream; 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); //打开文件 // ExeFileStream:=TCompressionStream.Create(clMax,TStream(ExeFileStream)); with t_op_file_items_data 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_seae_dg.bsSkinButton27Click(Sender: TObject); begin if not assigned(frm_op_seae) then frm_op_seae:=tfrm_op_seae.Create (self); frm_op_seae.ManualDock(frm_main.SearchTabs('frm_op_seae',frm_op_seae.caption,'101'),nil,alClient); frm_op_seae.show; frm_op_seae.Edit2.Text:=t_op_seae.FieldByName('主提单号').AsString; frm_op_seae.bsSkinButton44.OnClick(Sender); end; procedure Tfrm_op_seae_dg.dxDBGrid1CustomDraw(Sender: TObject; ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxDBTreeListColumn; const AText: String; AFont: TFont; var AColor: TColor; ASelected, AFocused: Boolean; var ADone: Boolean); begin if uppercase(ANode.Strings[dxDBGrid1Column23.Index])='TRUE' then begin AColor:=clSkyBlue; exit; end; end; procedure Tfrm_op_seae_dg.t_op_file_dataAfterPost(DataSet: TDataSet); var aAdoQuery:TAdoQuery; begin // if t_op_seae.FieldByName('编号').AsString<>'' then begin aAdoQuery:=CreateAdoQuery; with aAdoQuery do try Close;SQL.Clear; SQL.Add('select sum(大小) sums from t_op_file_data where 编号=:编号'); Parameters.ParamByName('编号').Value:=t_op_seae.FieldByName('编号').AsString; Open; if FieldByName('sums').AsInteger>=2 then begin t_op_seae.Edit; t_op_seae.FieldByName('上传文件').AsBoolean:=True; t_op_seae.Post; end; finally Free; end; end; end; procedure Tfrm_op_seae_dg.bsSkinPageControl1Change(Sender: TObject); begin if frm_op_seae_dg_create=false then exit; if bsSkinPageControl1.ActivePage=bsSkinTabSheet2 then begin t_op_file_data.Close; t_op_file_data.Parameters.ParamByName('编号').Value:=t_op_seae.FieldByName('编号').asstring; if not t_op_file_data.Active then t_op_file_data.open; end else begin if t_op_file_data.State in [dsedit,dsinsert] then t_op_file_data.Post; t_op_file_data.close; end; if bsSkinPageControl1.ActivePage=bsSkinTabSheet3 then begin t_op_seae_dg_except.Close; t_op_seae_dg_except.Parameters.ParamByName('编号').Value:=t_op_seae.FieldByName('编号').asstring; if not t_op_seae_dg_except.Active then t_op_seae_dg_except.open; end else begin if t_op_seae_dg_except.State in [dsedit,dsinsert] then t_op_seae_dg_except.Post; t_op_seae_dg_except.close; end; end; procedure Tfrm_op_seae_dg.DBEdit1Change(Sender: TObject); begin t_op_file_items_data.Close; end; procedure Tfrm_op_seae_dg.N27Click(Sender: TObject); var i:integer; str:widestring; aAdoQuery:TAdoQuery; aDataSource:TDataSource; begin if t_op_seae.IsEmpty then exit; if dxDBGrid1.SelectedCount>0 then begin for i:=0 to dxDBGrid1.SelectedCount-1 do begin t_op_seae.GotoBookmark(pointer(dxDBGrid1.selectedrows[i])); if i=0 then str:='('+''''+t_op_seae.fieldbyname('编号').asstring+'''' else str:=str+','+''''+t_op_seae.fieldbyname('编号').asstring+''''; t_op_seae.Edit; t_op_seae.FieldByName('EDI状态').AsString:='已发送'; t_op_seae.Post; end; end else begin str:='('+''''+t_op_seae.fieldbyname('编号').asstring+''''; end; str:=str+')'; aDataSource:=TDataSource.Create(nil); aAdoQuery:=CreateAdoQuery; aDataSource.DataSet:=aAdoQuery; with aAdoQuery do try close; sql.clear; sql.add('select t_op_ctn_edi.*,t_op_seae_edi.* from t_op_ctn_edi left Join t_op_seae_edi on t_op_ctn_edi.编号=t_op_seae_edi.编号 ' +' where t_op_ctn_edi.编号 in '+str +' order by t_op_ctn_edi.编号'); open; sys_print('青港舱单',2,aDataSource,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil); finally aDataSource.Free; Free; end; end; procedure Tfrm_op_seae_dg.bsSkinButton29Click(Sender: TObject); begin t_op_seae.close; t_op_seae.sql.clear; t_op_seae.sql.add(opsqlstr); t_op_seae.Open; {t_op_seae_sum.close; t_op_seae_sum.sql.clear; t_op_seae_sum.sql.add(opsumsqlstr); t_op_seae_sum.Open;} end; procedure Tfrm_op_seae_dg.bsSkinButton30Click(Sender: TObject); begin if t_op_seae1.DataSet=nil then exit; if (t_op_seae1.DataSet.State=dsinsert)or(t_op_seae1.DataSet.State=dsedit) then t_op_seae1.DataSet.post; sys_print('舱单申报',2,t_op_seae1,t_op_ctn1,nil,nil,nil,nil,nil,nil,nil,nil,nil); end; procedure Tfrm_op_seae_dg.bsSkinButton13Click(Sender: TObject); begin t_op_seae_dg_except.Insert; end; procedure Tfrm_op_seae_dg.bsSkinButton17Click(Sender: TObject); begin table_cancel(t_op_seae_dg_except); end; procedure Tfrm_op_seae_dg.bsSkinButton15Click(Sender: TObject); begin table_post(t_op_seae_dg_except); end; procedure Tfrm_op_seae_dg.bsSkinButton16Click(Sender: TObject); begin if not if_open('518') then begin ShowMessage('没有删除的权限!'); Exit; end; table_delete(t_op_seae_dg_except); end; procedure Tfrm_op_seae_dg.t_op_seae_dg_exceptBeforePost(DataSet: TDataSet); begin t_op_seae_dg_except['修改人']:=employee; t_op_seae_dg_except['修改时间']:=Now; end; procedure Tfrm_op_seae_dg.N1Click(Sender: TObject); var Ext,tmpstr,strtmpmblno,strunno,ispx:String; ExcelTemplet:Variant; TempstrList:Tstringlist; i,excelline,ctnnum:Integer; aQuery,aQuery2:TADOQuery; FileStream:TFileStream; fsize:double; begin OpenDialog1.FileName:=''; if t_op_file_data.RecordCount<=0 then begin t_op_file_data.Append; t_op_file_data.FieldByName('文件类型').AsString:='申报信息'; t_op_file_data.FieldByName('备注').AsString:='是'; t_op_file_data.Post; t_op_file_data.Append; t_op_file_data.FieldByName('文件类型').AsString:='保函'; t_op_file_data.FieldByName('备注').AsString:='否'; t_op_file_data.Post; t_op_file_data.First; end; with t_op_file_items_data do begin Close;SQL.Clear; sql.Add('select * from t_op_file_items'); sql.Add('where PID=:PID and 编号=:编号'); Parameters.ParamByName('PID').Value:=t_op_file_data.FieldByName('fid').AsInteger; Parameters.ParamByName('编号').Value:=t_op_file_data.FieldByName('编号').AsString; Open; end; //上传附件 if OpenDialog1.Execute then begin if Length(Opendialog1.FileName)<=95 then begin FileStream:=TFileStream.Create(Opendialog1.FileName,fmopenRead); //打开文件 try fsize:=FileStream.size; finally freeandnil(FileStream); end; if fsize>5000000 then begin MessageDlg('文件不能超过5M!!',mtWarning,[mbyes],0); end else UpLoadProFile(Opendialog1.FileName,naspath,'user','user',frm_op_seae_dg.t_op_seae.fieldbyname('主提单号').AsString); end else begin MessageDlg('文件名太长,不能超过95个字符!!',mtWarning,[mbyes],0); exit ; end; strtmpmblno:=''; Ext:=lowercase(ExtractFileExt(OpenDialog1.FileName)); if (Ext='.xlsx') or (Ext='.xls') then begin ExcelTemplet:= CreateOleObject('Excel.Application'); TempstrList:=Tstringlist.Create; aQuery:=createAdoQuery; aQuery2:=createAdoQuery; try ExcelTemplet.Workbooks.Open(OpenDialog1.FileName); for excelline:=2 to 100 do begin tmpstr:=VartoStr(ExcelTemplet.WorkSheets[1].Cells[excelline,1].Value); if tmpstr<>'' then begin aQuery.Close; aQuery.SQL.Clear; aQuery.SQL.Text:='select * from t_op_seae_dg where 主提单号='''+tmpstr+''''; aQuery.Open; aQuery2.Close; aQuery2.SQL.Clear; aQuery2.SQL.Text:='select * from t_op_seae where 主提单号='''+tmpstr+''''; aQuery2.Open; if not aQuery.IsEmpty then begin aQuery.Edit; ispx:=VartoStr(ExcelTemplet.WorkSheets[1].Cells[excelline,2].Value); if aQuery2.FieldByName('是否混装').AsBoolean then begin if ((ispx='否') or (ispx='')) then ShowMessage('是否混装和原业务不一致!'); end else begin if (ispx='是') then ShowMessage('是否混装和原业务不一致!'); end; aQuery['是否拼箱']:=ispx; aQuery['场站']:=VartoStr(ExcelTemplet.WorkSheets[1].Cells[excelline,3].Value); aQuery['生产企业']:=VartoStr(ExcelTemplet.WorkSheets[1].Cells[excelline,4].Value); strunno:=VartoStr(ExcelTemplet.WorkSheets[1].Cells[excelline,5].Value); if (strunno<>aQuery2.FieldByName('危险品编号').AsString) then begin ShowMessage('UNNO和原业务不一致!'); end; aQuery['UNNO']:=VartoStr(ExcelTemplet.WorkSheets[1].Cells[excelline,5].Value); aQuery['中文品名']:=VartoStr(ExcelTemplet.WorkSheets[1].Cells[excelline,6].Value); strunno:=VartoStr(ExcelTemplet.WorkSheets[1].Cells[excelline,7].Value); if (strunno<>aQuery2.FieldByName('危险品分类').AsString) then begin ShowMessage('危险品类别和原业务不一致!'); end; aQuery['危险品类别']:=VartoStr(ExcelTemplet.WorkSheets[1].Cells[excelline,7].Value); aQuery['包装类']:=VartoStr(ExcelTemplet.WorkSheets[1].Cells[excelline,8].Value); // aQuery['是否拼箱']:=VartoStr(ExcelTemplet.WorkSheets[1].Cells[excelline,9].Value); aQuery['目的港英文名称']:=VartoStr(ExcelTemplet.WorkSheets[1].Cells[excelline,10].Value); aQuery['船靠时间']:=VartoStr(ExcelTemplet.WorkSheets[1].Cells[excelline,11].Value); // aQuery['是否拼箱']:=VartoStr(ExcelTemplet.WorkSheets[1].Cells[excelline,12].Value); // aQuery['箱型箱量']:=VartoStr(ExcelTemplet.WorkSheets[1].Cells[excelline,13].Value); aQuery['件数']:=StrToIntDef(VartoStr(ExcelTemplet.WorkSheets[1].Cells[excelline,14].Value),0); aQuery['闪点']:=VartoStr(ExcelTemplet.WorkSheets[1].Cells[excelline,15].Value); aQuery['副危1']:=VartoStr(ExcelTemplet.WorkSheets[1].Cells[excelline,16].Value); aQuery['副危2']:=VartoStr(ExcelTemplet.WorkSheets[1].Cells[excelline,17].Value); aQuery2.Close; aQuery2.SQL.Clear; aQuery2.SQL.Text:='Select * from t_code_stowgoods where UNNO='''+aQuery.fieldbyname('UNNO').AsString+''' and 危险品类别='''+aQuery.fieldbyname('危险品类别').AsString+''' and 闪点='''+aQuery.fieldbyname('闪点').AsString+''''; aQuery2.Open; if not aQuery2.IsEmpty then aQuery['车船直装货物']:=True; aQuery.Post; end else begin strtmpmblno:=strtmpmblno+','+tmpstr; end; end; end; for excelline:=2 to 30 do begin tmpstr:=VartoStr(ExcelTemplet.WorkSheets[2].Cells[excelline,1].Value); if tmpstr<>'' then begin aQuery.Close; aQuery.SQL.Clear; aQuery.SQL.Text:='select * from t_op_seae_dg where 主提单号='''+tmpstr+''''; aQuery.Open; if not aQuery.IsEmpty then begin aQuery2.Close; aQuery2.SQL.Clear; aQuery2.SQL.Text:='select * from t_op_seae_dg_ctn where 箱号='''+VartoStr(ExcelTemplet.WorkSheets[2].Cells[excelline,2].Value)+''' and 编号='''+aQuery.fieldbyname('编号').asstring+''''; aQuery2.Open; if aQuery2.IsEmpty then begin aQuery2.Insert; aQuery2['编号']:=aQuery['编号']; aQuery2['箱号']:=VartoStr(ExcelTemplet.WorkSheets[2].Cells[excelline,2].Value); aQuery2['总毛重']:=StrToFloatDef(VartoStr(ExcelTemplet.WorkSheets[2].Cells[excelline,7].Value),0); aQuery2['总净重']:=StrToFloatDef(VartoStr(ExcelTemplet.WorkSheets[2].Cells[excelline,8].Value),0); aQuery2.Post; end else begin aQuery2.Edit; aQuery2['箱号']:=VartoStr(ExcelTemplet.WorkSheets[2].Cells[excelline,2].Value); aQuery2['总毛重']:=StrToFloatDef(VartoStr(ExcelTemplet.WorkSheets[2].Cells[excelline,7].Value),0); aQuery2['总净重']:=StrToFloatDef(VartoStr(ExcelTemplet.WorkSheets[2].Cells[excelline,8].Value),0); aQuery2.Post; end; aQuery2.Close; aQuery2.SQL.Clear; aQuery2.SQL.Text:='select sum(总毛重) 总毛重,sum(总净重) 总净重 from t_op_seae_dg_ctn where 编号='''+aQuery.fieldbyname('编号').asstring+''''; aQuery2.Open; aQuery.Edit; aQuery['总毛重']:=aQuery2['总毛重']; aQuery['总净重']:=aQuery2['总净重']; aQuery['危险品标识']:=VartoStr(ExcelTemplet.WorkSheets[2].Cells[excelline,3].Value); aQuery['特殊货物标志']:=VartoStr(ExcelTemplet.WorkSheets[2].Cells[excelline,4].Value); aQuery['申报单类型']:=VartoStr(ExcelTemplet.WorkSheets[2].Cells[excelline,5].Value); aQuery['审核类型']:=VartoStr(ExcelTemplet.WorkSheets[2].Cells[excelline,6].Value); aQuery['组件类型']:=VartoStr(ExcelTemplet.WorkSheets[2].Cells[excelline,9].Value); aQuery['是否开敞']:=VartoStr(ExcelTemplet.WorkSheets[2].Cells[excelline,10].Value); aQuery['包件种类']:=VartoStr(ExcelTemplet.WorkSheets[2].Cells[excelline,11].Value); aQuery['货物装运形式']:=VartoStr(ExcelTemplet.WorkSheets[2].Cells[excelline,12].Value); aQuery['是否海洋污染物']:=VartoStr(ExcelTemplet.WorkSheets[2].Cells[excelline,13].Value); aQuery.Post; end else begin strtmpmblno:=strtmpmblno+','+tmpstr; end; end; end; finally ExcelTemplet.DisplayAlerts := false;//是否提示存盘 ExcelTemplet.Quit;//如果出错则退出 FreeAndNil(TempstrList); FreeAndNil(aQuery); FreeAndNil(aQuery2); end; end; t_op_seae.Refresh(); if trim(strtmpmblno)<>'' then begin MessageDlg('已导入,但提单号'+strtmpmblno+' 系统中不存在,不能导入!',mtWarning, [mbYes],0); end else MessageDlg('导入完成!', mtConfirmation, [mbYes],0); end else exit ; end; procedure Tfrm_op_seae_dg.bsSkinButton77Click(Sender: TObject); var aQuery:TAdoQuery; str,strsjr,subject:string; sl:TStringList; begin str:=' select d.*,c.客户名称 from t_code_cust_mailproject_detail d left join t_code_cust_mailproject c ' +' on (c.方案代码=d.方案代码) where 单据类型=''危险品申报'' and ' +' d.方案代码 in ' +'( SELECT distinct 客户邮件方案 from t_op_seae where isnull(客户邮件方案,'''')<>'''' ' +'and 编号='''+ t_op_seae.fieldbyname('主编号').AsString+''' )'; subject:=t_op_seae.fieldbyname('主提单号').AsString+'空箱申报已发送成功'; aQuery:=CreateAdoQuery; sl:=TStringList.Create; try with aQuery do begin close;sql.clear; SQL.Text:=str; Open; if not IsEmpty then begin while not eof do begin if strsjr='' then strsjr := fieldbyname('收件人').AsString else strsjr := strsjr +',' +fieldbyname('收件人').AsString; Next; end; end; end; sl.Add('尊敬的客户'); sl.Add(' 您好!'); sl.Add(t_op_seae.fieldbyname('主提单号').AsString+'空箱申报已按照贵司提供的信息上传至VGS网站,如果信息有变更请第一时间'); sl.Add('联系我司订舱操作,以免因此影响后序工作。'); // if (strsjr<>'') then // SendMail(strsjr,subject,sl); // strsjr:=''; if (strsjr='') then begin with aQuery do begin close;sql.clear; SQL.Text:='select (select top 1 邮箱 from t_sys_employee where 姓名=t_op_seae.操作员) as opmail,(select top 1 邮箱 from t_sys_employee where 姓名=t_op_seae.客服员) as custservicemail from t_op_seae where 编号='''+t_op_seae.fieldbyname('主编号').AsString+''''; Open; if not IsEmpty then begin if (FieldByName('opmail').AsString<>'') then begin if strsjr='' then strsjr := fieldbyname('opmail').AsString else strsjr := strsjr +',' +fieldbyname('opmail').AsString; end; { if (FieldByName('custservicemail').AsString<>'') then begin if strsjr='' then strsjr := fieldbyname('custservicemail').AsString else strsjr := strsjr +',' +fieldbyname('custservicemail').AsString; end; } end; end; end; if (strsjr<>'') then SendMail(strsjr,subject,sl); if (t_op_seae.fieldbyname('车船直装货物').AsBoolean) then begin subject:=t_op_seae.fieldbyname('主提单号').AsString+'车船直装提醒'; sl.Clear; sl.Add('尊敬的客户'); sl.Add(' 您好!'); sl.Add('1.'+t_op_seae.fieldbyname('主提单号').AsString+'此票危险品属于车船直装货物,请合理安排时间。'); sl.Add('2.若此票货危险品等级是4.3类或者5.2类危险品,请在装箱之前将<直装直取危险货物信息报告表>'); sl.Add('发给我司操作,待危险品库审核后方可允许出运'); if (strsjr<>'') then SendMail(strsjr,subject,sl); end; t_op_seae.Edit; t_op_seae.FieldByName('空箱申报状态').AsString:='已发送'; t_op_seae.Post; with aQuery do begin close;sql.clear; SQL.Text:='update t_op_seae set 空箱申报状态=''已发送'' where 编号='''+t_op_seae.fieldbyname('主编号').AsString+''''; ExecSQL; end; finally FreeAndNil(aQuery); FreeAndNil(sl); end; end; procedure Tfrm_op_seae_dg.SendMail(sendto, subjectstr: string;bodylist:TStringList); var aQuery:TAdoQuery; str_memo:Tmemo; OPMailPw,OPMailAddress,OPMailSignName:string; begin aQuery:=CreateAdoQuery; try with aQuery do begin close;sql.clear; SQL.Text:='select * from t_sys_employee where 姓名='''+t_op_seae.fieldbyname('操作员').AsString+''''; Open; OPMailPw:=fieldbyname('msn帐号').asstring; OPMailAddress:=fieldbyname('邮箱').asstring; OPMailSignName:=fieldbyname('邮件签名').asstring; //缓存邮件签名 cjb 2017-12-28 end; finally FreeAndNil(aQuery); end; str_memo:=Tmemo.create(application); str_memo.Parent:=frm_op_seae_dg; str_memo.visible:=False; try SMTP1.AuthType := satDefault; //(satNone, satDefault, satSASL); SMTP1.username:=OPMailAddress; SMTP1.Password :=OPMailPw; SMTP1.Host:='mail.sdsmartlogistics.com'; { SMTP1.username:='admin@dongshengsoft.com'; SMTP1.Password :='ds!@#)(*'; SMTP1.Host :='smtpcom.263xmail.com'; } SMTP1.Port:=25; try SMTP1.Connect; except on e : Exception do begin ShowMessage('连接邮箱出错:'+E.Message); end; end; str_memo.Lines.Clear; str_memo.Lines.Assign(bodylist); str_memo.Lines.Add(''); str_memo.Lines.Add(OPMailSignName); if not SMTP1.Connected then begin Sleep(1000); SMTP1.Connect; end; try with IdMsg do begin CharSet :='GB2312'; // 不设置这个中文会乱码 // CharSet :='UTF-8'; // 不设置这个中文会乱码 // Encoding:=mmeMIME; body.Clear; Body.Text :=str_memo.lines.Text; From.address :=OPMailAddress; Recipients.EMailAddresses :=sendto; Subject:=subjectstr; end; if not SMTP1.Connected then begin Sleep(1000); SMTP1.Connect; end; SMTP1.Send(IdMsg); finally SMTP1.Disconnect; end; except MessageDlg('发送失败!',mtError,[mbOK],0); end; Insert_mail_Log(t_op_seae.fieldbyname('主编号').AsString,'危品申报',sendto,subjectstr,bodylist.CommaText,''); MessageDlg('发送成功!',mtConfirmation,[mbOK],0); str_memo.free; if SMTP1.Connected then SMTP1.Disconnect; end; procedure Tfrm_op_seae_dg.bsSkinButton1Click(Sender: TObject); var aQuery:TAdoQuery; str,strsjr,subject:string; sl:TStringList; begin str:=' select d.*,c.客户名称 from t_code_cust_mailproject_detail d left join t_code_cust_mailproject c ' +' on (c.方案代码=d.方案代码) where 单据类型=''危险品申报'' and ' +' d.方案代码 in ' +'( SELECT distinct 客户邮件方案 from t_op_seae where isnull(客户邮件方案,'''')<>'''' ' +'and 编号='''+ t_op_seae.fieldbyname('主编号').AsString+''' )'; subject:=t_op_seae.fieldbyname('主提单号').AsString+'重箱申报已发送成功'; aQuery:=CreateAdoQuery; sl:=TStringList.Create; try with aQuery do begin close;sql.clear; SQL.Text:=str; Open; if not IsEmpty then begin while not eof do begin if strsjr='' then strsjr := fieldbyname('收件人').AsString else strsjr := strsjr +',' +fieldbyname('收件人').AsString; Next; end; end; end; sl.Add('尊敬的客户'); sl.Add(' 您好!'); sl.Add(t_op_seae.fieldbyname('主提单号').AsString+'重箱申报已按照贵司提供的信息上传至VGS网站,如果信息有变更请第一时间'); sl.Add('联系我司订舱操作,以免因此影响后序工作。'); sl.Add('特别提示'); sl.Add('1. 怕水湿或与水反应的货物在拍摄半箱、满箱视频时,需拍摄温湿度计且湿度需小于75%。'); sl.Add('2. 每年6月1日-9月30日期间,怕高温货物在拍摄半箱、满箱视频时,需拍摄温湿度计且温度要求小于40摄氏度。'); sl.Add('3. 工厂将入场、装箱、满箱视频和装箱证明上传完毕后请第一时间通知我司,以便我司审核后确认视频。'); sl.Add('4.如需我司上传装箱证明,请在通知我司确认视频时,将装箱证明发给我司,装箱证明请用JPG、JPEG、GIF、PNG系统识别的格式。'); { sl.Add('5. 随视频一并提供清晰的装箱证明扫描件,要求装箱证明上的企业公章必须跟入场视频厂'); sl.Add('名、装箱地点一致。'); sl.Add('6. 大列货无需提供视频,只需提供一张带箱号的照片即可;TANK箱无需提供视频和照片。'); sl.Add('7. 请严格按照危品库要求拍摄危险品视频,如贵司对视频拍摄要求有任何疑惑,请致我司'); sl.Add('申报人员进行咨询。'); } // if (strsjr<>'') then // SendMail(strsjr,subject,sl); // strsjr:=''; if (strsjr='') then begin with aQuery do begin close;sql.clear; SQL.Text:='select (select top 1 邮箱 from t_sys_employee where 姓名=t_op_seae.操作员) as opmail,(select top 1 邮箱 from t_sys_employee where 姓名=t_op_seae.客服员) as custservicemail from t_op_seae where 编号='''+t_op_seae.fieldbyname('主编号').AsString+''''; Open; if not IsEmpty then begin if (FieldByName('opmail').AsString<>'') then begin if strsjr='' then strsjr := fieldbyname('opmail').AsString else strsjr := strsjr +',' +fieldbyname('opmail').AsString; end; { if (FieldByName('custservicemail').AsString<>'') then begin if strsjr='' then strsjr := fieldbyname('custservicemail').AsString else strsjr := strsjr +',' +fieldbyname('custservicemail').AsString; end; } end; end; end; if (strsjr<>'') then SendMail(strsjr,subject,sl); t_op_seae.Edit; t_op_seae.FieldByName('重箱申报状态').AsString:='已发送'; { if (Pos('TK',t_op_seae.FieldByName('箱型箱量').asstring)>0) THEN t_op_seae.FieldByName('视频审核状态').AsString:='已审核'; } t_op_seae.Post; with aQuery do begin close;sql.clear; SQL.Text:='update t_op_seae set 重箱申报状态=''已发送'' where 编号='''+t_op_seae.fieldbyname('主编号').AsString+''''; ExecSQL; end; finally FreeAndNil(aQuery); FreeAndNil(sl); end; end; procedure Tfrm_op_seae_dg.btnMarksClick(Sender: TObject); var aQuery:TAdoQuery; str,strsjr,subject,strctn,statusstr:string; sl:TStringList; isall:Boolean; i:Integer; begin if t_op_ctn.IsEmpty then exit; if wwDBGrid1.SelectedList.Count>=1 then begin for i:=0 to wwDBGrid1.SelectedList.Count-1 do begin t_op_ctn.GotoBookmark(pointer(wwDBGrid1.SelectedList[i])); if i=0 then strctn:=t_op_ctn.fieldbyname('箱号').asstring else strctn:=strctn+','+t_op_ctn.fieldbyname('箱号').asstring; end; end else begin strctn:=t_op_ctn.fieldbyname('箱号').asstring; end; str:=' select d.*,c.客户名称 from t_code_cust_mailproject_detail d left join t_code_cust_mailproject c ' +' on (c.方案代码=d.方案代码) where 单据类型=''危险品申报'' and ' +' d.方案代码 in ' +'( SELECT distinct 客户邮件方案 from t_op_seae where isnull(客户邮件方案,'''')<>'''' ' +'and 编号='''+ t_op_seae.fieldbyname('主编号').AsString+''' )'; subject:=t_op_seae.fieldbyname('主提单号').AsString+'项下'+strctn+'箱子视频已上传'; aQuery:=CreateAdoQuery; sl:=TStringList.Create; try with aQuery do begin close;sql.clear; SQL.Text:=str; Open; if not IsEmpty then begin while not eof do begin if strsjr='' then strsjr := fieldbyname('收件人').AsString else strsjr := strsjr +',' +fieldbyname('收件人').AsString; Next; end; end; end; sl.Add('尊敬的客户'); sl.Add(' 您好!'); sl.Add(t_op_seae.fieldbyname('主提单号').AsString+'项下'+strctn+'箱子视频已上传至VGS网站,危险品库中心正在审核视频内容,'); sl.Add(',审核时间预计需要一个工作日,待危险品中心审核通过后,我司会以邮件回执的方式告知贵司,如遇周末及节假邮件回执将会顺延'); sl.Add(',如有需要可单独询问操作视频审核状态。'); // if (strsjr<>'') then // SendMail(strsjr,subject,sl); // strsjr:=''; if (strsjr='') then begin with aQuery do begin close;sql.clear; SQL.Text:='select (select top 1 邮箱 from t_sys_employee where 姓名=t_op_seae.操作员) as opmail from t_op_seae where 编号='''+t_op_seae.fieldbyname('主编号').AsString+''''; Open; if not IsEmpty then begin if (FieldByName('opmail').AsString<>'') then begin if strsjr='' then strsjr := fieldbyname('opmail').AsString else strsjr := strsjr +',' +fieldbyname('opmail').AsString; end; { if (FieldByName('custservicemail').AsString<>'') then begin if strsjr='' then strsjr := fieldbyname('custservicemail').AsString else strsjr := strsjr +',' +fieldbyname('custservicemail').AsString; end; } end; end; end; if (strsjr<>'') then SendMail(strsjr,subject,sl); if (t_op_seae.FieldByName('视频审核状态').AsString)='已审核' then statusstr:='重新上传' else statusstr:='已上传'; if wwDBGrid1.SelectedList.Count>=1 then begin for i:=0 to wwDBGrid1.SelectedList.Count-1 do begin t_op_ctn.GotoBookmark(pointer(wwDBGrid1.SelectedList[i])); t_op_ctn.Edit; t_op_ctn.FieldByName('视频上传状态').AsString:=statusstr; t_op_ctn.Post; end; end else begin t_op_ctn.Edit; t_op_ctn.FieldByName('视频上传状态').AsString:=statusstr; t_op_ctn.Post; end; if (t_op_seae.FieldByName('视频审核状态').AsString)<>statusstr then begin isall:=True; t_op_ctn.First; while not t_op_ctn.Eof do begin if t_op_ctn.FieldByName('视频上传状态').AsString<>statusstr then isall:=false; t_op_ctn.Next; end; if (isall) then begin // if (t_op_seae.FieldByName('视频审核状态').AsString)='已审核' then statusstr:='重新上传' else statusstr:='已上传'; t_op_seae.Edit; t_op_seae.FieldByName('视频审核状态').AsString:=statusstr; t_op_seae.Post; with aQuery do begin close;sql.clear; SQL.Text:='update t_op_seae set 视频审核状态='''+statusstr+''' where 编号='''+t_op_seae.fieldbyname('主编号').AsString+''''; ExecSQL; end; end; end; finally FreeAndNil(aQuery); FreeAndNil(sl); end; end; procedure Tfrm_op_seae_dg.btnDescClick(Sender: TObject); var aQuery:TAdoQuery; str,strsjr,subject,strctn:string; sl:TStringList; isall:Boolean; i:Integer; begin if t_op_ctn.IsEmpty then exit; if wwDBGrid1.SelectedList.Count>=1 then begin for i:=0 to wwDBGrid1.SelectedList.Count-1 do begin t_op_ctn.GotoBookmark(pointer(wwDBGrid1.SelectedList[i])); if i=0 then strctn:=t_op_ctn.fieldbyname('箱号').asstring else strctn:=strctn+','+t_op_ctn.fieldbyname('箱号').asstring; end; end else begin strctn:=t_op_ctn.fieldbyname('箱号').asstring; end; str:=' select d.*,c.客户名称 from t_code_cust_mailproject_detail d left join t_code_cust_mailproject c ' +' on (c.方案代码=d.方案代码) where 单据类型=''危险品申报'' and ' +' d.方案代码 in ' +'( SELECT distinct 客户邮件方案 from t_op_seae where isnull(客户邮件方案,'''')<>'''' ' +'and 编号='''+ t_op_seae.fieldbyname('主编号').AsString+''' )'; subject:=t_op_seae.fieldbyname('主提单号').AsString+'项下'+strctn+'箱子视频已审核通过'; aQuery:=CreateAdoQuery; sl:=TStringList.Create; try with aQuery do begin close;sql.clear; SQL.Text:=str; Open; if not IsEmpty then begin while not eof do begin if strsjr='' then strsjr := fieldbyname('收件人').AsString else strsjr := strsjr +',' +fieldbyname('收件人').AsString; Next; end; end; end; sl.Add('尊敬的客户'); sl.Add(' 您好!'); sl.Add(t_op_seae.fieldbyname('主提单号').AsString+'项下'+strctn+'箱子视频已审核通过,请通知车队及时绑定信息并安排入库。'); // if (strsjr<>'') then // SendMail(strsjr,subject,sl); // strsjr:=''; if (strsjr='') then begin with aQuery do begin close;sql.clear; SQL.Text:='select (select top 1 邮箱 from t_sys_employee where 姓名=t_op_seae.操作员) as opmail,(select top 1 邮箱 from t_sys_employee where 姓名=t_op_seae.客服员) as custservicemail from t_op_seae where 编号='''+t_op_seae.fieldbyname('主编号').AsString+''''; Open; if not IsEmpty then begin if (FieldByName('opmail').AsString<>'') then begin if strsjr='' then strsjr := fieldbyname('opmail').AsString else strsjr := strsjr +',' +fieldbyname('opmail').AsString; end; { if (FieldByName('custservicemail').AsString<>'') then begin if strsjr='' then strsjr := fieldbyname('custservicemail').AsString else strsjr := strsjr +',' +fieldbyname('custservicemail').AsString; end; } end; end; end; if (strsjr<>'') then SendMail(strsjr,subject,sl); if wwDBGrid1.SelectedList.Count>=1 then begin for i:=0 to wwDBGrid1.SelectedList.Count-1 do begin t_op_ctn.GotoBookmark(pointer(wwDBGrid1.SelectedList[i])); t_op_ctn.Edit; t_op_ctn.FieldByName('视频审核状态').AsString:='已审核'; t_op_ctn.Post; end; end else begin t_op_ctn.Edit; t_op_ctn.FieldByName('视频审核状态').AsString:='已审核'; t_op_ctn.Post; end; if (t_op_seae.FieldByName('视频审核状态').AsString)<>'已审核' then begin isall:=True; t_op_ctn.First; while not t_op_ctn.Eof do begin if t_op_ctn.FieldByName('视频审核状态').AsString<>'已审核' then isall:=false; t_op_ctn.Next; end; if (isall) then begin t_op_seae.Edit; t_op_seae.FieldByName('视频审核状态').AsString:='已审核'; t_op_seae.Post; with aQuery do begin close;sql.clear; SQL.Text:='update t_op_seae set 视频审核状态=''已审核'' where 编号='''+t_op_seae.fieldbyname('主编号').AsString+''''; ExecSQL; end; end; end; finally FreeAndNil(aQuery); FreeAndNil(sl); end; end; procedure Tfrm_op_seae_dg.dxDBGrid1Column31GetText(Sender: TObject; ANode: TdxTreeListNode; var AText: String); begin if AText='True' then AText:='是' else AText:=''; end; procedure Tfrm_op_seae_dg.dxDBGrid1ColumnSorting(Sender: TObject; Column: TdxDBTreeListColumn; var Allow: Boolean); begin Column_sort(Column,t_op_seae,'编号'); end; procedure Tfrm_op_seae_dg.bsSkinButton19Click(Sender: TObject); var aQuery:TADOQuery; aQueryctn:TADOQuery; feecount:Integer; samestr:string; issame:Boolean; feepkgs:Double; function createsql(FA:string):string; var aQuery:TADOQuery; begin Result:=' 1=1 '; aQuery:=CreateAdoQuery; try With aQuery do begin close;SQL.Clear; SQL.Add('SELECT * FROM t_ch_project_Condition WHERE 方案代码='+FA); Open; First; while not eof do begin if ((fieldbyname('条件名称').AsString='业务来源') or (fieldbyname('条件名称').AsString='来源明细')) then begin Result:=query_tiaojian(1,Result,'b.'+fieldbyname('条件名称').AsString,fieldbyname('条件关系').AsString,fieldbyname('条件值').AsString); end else begin if (fieldbyname('条件名称').AsString='车船直装货物') then Result:=query_tiaojian(3,Result,'d.'+fieldbyname('条件名称').AsString,fieldbyname('条件关系').AsString,fieldbyname('条件值').AsString) else Result:=query_tiaojian(1,Result,'d.'+fieldbyname('条件名称').AsString,fieldbyname('条件关系').AsString,fieldbyname('条件值').AsString); end; Next; end; end; finally FreeAndNil(aQuery); end; end; function issamestr(bsno:string):string; begin result:=''; if (aQuery.FieldByName('船名').AsString<>t_op_seae.FieldByName('船名').AsString) then Result:='船名信息不一致!'; if (aQuery.FieldByName('航次').AsString<>t_op_seae.FieldByName('航次').AsString) then Result:=Result+' 航次信息不一致!'; if (aQuery.FieldByName('箱TEU').AsString<>t_op_seae.FieldByName('箱TEU').AsString) then Result:=Result+' 箱TEU信息不一致!'; InsertSysLog('危品费用','提单号:'+t_op_seae.FieldByName('主提单号').AsString+' ,业务箱TEU:'+t_op_seae.FieldByName('箱TEU').AsString+',危品箱TEU'+aQuery.FieldByName('箱TEU').AsString); end; function getfeepkg():Double; begin result:=0; if t_ch_project_fee.fieldbyname('标准').asstring='单票' then begin result:=1; end else if t_ch_project_fee.fieldbyname('标准').asstring='件数' then begin result:=t_op_seae.fieldbyname('件数').asfloat; end else if t_ch_project_fee.fieldbyname('标准').asstring='TEU' then begin result:=t_op_seae.fieldbyname('箱TEU').asfloat; end else if t_ch_project_fee.fieldbyname('标准').asstring='箱数' then begin result:=t_op_seae.fieldbyname('箱量').asfloat; end else begin if (aQueryctn.Locate('表现形式',t_ch_project_fee.fieldbyname('标准').asstring,[])) then begin result:=aQueryctn.fieldbyname('数量').asfloat; end; end; end; begin if (t_ch_project_fee.Active) then t_ch_project_fee.Close; if (not t_ch_project.Active) then t_ch_project.open; if (not t_ch_fee.Active) then t_ch_fee.Open; 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.bsSkinGauge1.MaxValue:=t_ch_project.RecordCount; frm_sys_progress.bsSkinGauge1.MinValue:=0; frm_sys_progress.bsSkinGauge1.Value:=0; frm_sys_progress.Update; feecount:=0; aQuery:=CreateAdoQuery; aQueryctn:=CreateAdoQuery; try aQuery.Close;aQuery.SQL.Clear; aQuery.SQL.Text:='select * from t_op_seae where 编号='''+t_op_seae.fieldbyname('主编号').AsString+''''; aQuery.Open; aQueryctn.Close;aQueryctn.SQL.Clear; aQueryctn.SQL.Add('select 表现形式,sum(数量) 数量 from t_op_ctn'); aQueryctn.SQL.Add('where 编号=:编号'); aQueryctn.SQL.Add('Group by 表现形式'); aQueryctn.Parameters.ParamByName('编号').Value:=t_op_seae.fieldbyname('主编号').AsString; aQueryctn.open; if aQuery.IsEmpty then begin ShowMessage('海运出口无此业务!'); end else begin issame:=true; samestr:=issamestr(t_op_seae.fieldbyname('主编号').AsString); if samestr<>'' then begin if MessageDlg(samestr+',确定要生成费用吗?',mtWarning,[mbyes,mbno],0)<>mryes then issame:=False; end; if (issame) then begin t_ch_project.first; while not t_ch_project.Eof do begin if (not t_op_seae_fee.Active) then t_op_seae_fee.Open; if (not t_op_seae_fee.IsEmpty) and ((t_op_seae_fee.FieldByName('危险品申报收费').AsBoolean AND (not t_ch_project.FieldByName('独立方案').AsBoolean) and ((t_ch_project.FieldByName('收付类型').AsString='收费') or (t_ch_project.FieldByName('收付类型').AsString='全部'))) or (t_op_seae_fee.FieldByName('危险品申报付费').AsBoolean AND (not t_ch_project.FieldByName('独立方案').AsBoolean) and ((t_ch_project.FieldByName('收付类型').AsString='付费') or (t_ch_project.FieldByName('收付类型').AsString='全部'))) or (t_ch_project.FieldByName('独立方案').AsBoolean and (Pos('('+t_ch_project.fieldbyname('方案代码').AsString+')',t_op_seae_fee.FieldByName('独立方案').AsString)>0) ))then begin end else begin aQuery.Close;aQuery.SQL.Clear; aQuery.SQL.Text:='select d.* from t_op_seae_dg d left join t_op_seae b on (b.编号=d.主编号) where d.编号='''+t_op_seae.fieldbyname('编号').AsString+''' and '+createsql(t_ch_project.fieldbyname('方案代码').AsString); aQuery.Open; if not aQuery.IsEmpty then begin t_ch_project_fee.Open; t_ch_project_fee.First; while not t_ch_project_fee.Eof do begin feepkgs:=getfeepkg(); if (t_ch_project_fee.fieldbyname('单价').asfloat<>0) and (feepkgs<>0) then begin t_ch_fee.Insert; t_ch_fee['编号']:=t_op_seae.fieldbyname('主编号').AsString; t_ch_fee['类型']:=t_ch_project_fee.fieldbyname('类型').AsString; t_ch_fee['费用状态']:='审核通过'; t_ch_fee['结算金额']:=0; t_ch_fee['开票金额']:=0; t_ch_fee['申请金额']:=0; t_ch_fee['不开发票']:=0; t_ch_fee['申请开票']:=0; t_ch_fee['冲抵金额']:=0; t_ch_fee['是否垫付']:=0; t_ch_fee['税率']:=0; t_ch_fee['税额']:=0; t_ch_fee['提交']:=0; t_ch_fee['是否对帐']:=0; t_ch_fee['费用名称']:=t_ch_project_fee.fieldbyname('费用名称').AsString; t_ch_fee['币别']:=t_ch_project_fee.fieldbyname('币别').AsString; t_ch_fee['结算单位']:=t_ch_project_fee.fieldbyname('结算单位').AsString; if frm_data_share.t_code_currency.Locate('币别',t_ch_project_fee.fieldbyname('币别').asstring,[])THEN begin if t_ch_fee.FieldByName('币别').AsString='USD' then begin if strtobool(get_parameters_value(145,'true')) then begin t_ch_fee['汇率']:=getUsdExRate(t_op_seae.fieldbyname('开船日期').asstring) end else begin t_ch_fee['汇率']:=getUsdExRate(t_op_seae.fieldbyname('会计期间').asstring) end; end else t_ch_fee['汇率']:=frm_data_share.t_code_currency.fieldbyname('汇率').asfloat; end; if t_ch_project_fee.fieldbyname('客户名称').asstring=''then begin t_ch_fee['客户名称']:=fee_get_client(t_ch_project_fee.fieldbyname('结算单位').asstring); end else begin t_ch_fee['客户名称']:=t_ch_project_fee.fieldbyname('客户名称').asstring; end; t_ch_fee['标准']:=t_ch_project_fee.fieldbyname('标准').asstring; t_ch_fee['数量']:=feepkgs; { if t_ch_project_fee.fieldbyname('标准').asstring='单票' then begin end else if t_ch_project_fee.fieldbyname('标准').asstring='件数' then begin t_ch_fee['数量']:=t_op_seae.fieldbyname('件数').asfloat; end else if t_ch_project_fee.fieldbyname('标准').asstring='TEU' then begin t_ch_fee['数量']:=t_op_seae.fieldbyname('箱TEU').asfloat; end else begin if (aQueryctn.Locate('表现形式',t_ch_project_fee.fieldbyname('标准').asstring,[])) then begin t_ch_fee['数量']:=aQueryctn.fieldbyname('数量').asfloat; end; end; } t_ch_fee['不含税价']:=t_ch_project_fee.fieldbyname('单价').asfloat; t_ch_fee['单价']:=t_ch_project_fee.fieldbyname('单价').asfloat; t_ch_fee['金额']:=s_w(strtoint(apointnum),t_ch_fee.fieldbyname('单价').asfloat*t_ch_fee.fieldbyname('数量').asfloat); t_ch_fee['顺序']:=t_ch_project_fee['顺序']; t_ch_fee['PROJECTFEEID']:=t_ch_project.fieldbyname('方案代码').AsString; t_ch_fee['录入人']:=employee; t_ch_fee['录入日期']:=now; t_ch_fee.Post; feecount:=feecount+1; end; t_ch_project_fee.Next; end; if (t_op_seae_fee.IsEmpty) then begin t_op_seae_fee.Insert; t_op_seae_fee['编号']:=t_op_seae['主编号']; if (t_ch_project.FieldByName('独立方案').AsBoolean) then begin t_op_seae_fee.FieldByName('独立方案').AsString:=t_op_seae_fee.FieldByName('独立方案').AsString+'('+t_ch_project.fieldbyname('方案代码').AsString+')'; end else begin if t_ch_project.FieldByName('收付类型').AsString='收费' then t_op_seae_fee['危险品申报收费']:=1; if t_ch_project.FieldByName('收付类型').AsString='付费' then t_op_seae_fee['危险品申报付费']:=1; if t_ch_project.FieldByName('收付类型').AsString='全部' then begin t_op_seae_fee['危险品申报收费']:=1; t_op_seae_fee['危险品申报付费']:=1; end; end; t_op_seae_fee.Post; end else begin t_op_seae_fee.Edit; t_op_seae_fee['编号']:=t_op_seae['主编号']; if (t_ch_project.FieldByName('独立方案').AsBoolean) then begin t_op_seae_fee.FieldByName('独立方案').AsString:=t_op_seae_fee.FieldByName('独立方案').AsString+'('+t_ch_project.fieldbyname('方案代码').AsString+')'; end else begin if t_ch_project.FieldByName('收付类型').AsString='收费' then t_op_seae_fee['危险品申报收费']:=1; if t_ch_project.FieldByName('收付类型').AsString='付费' then t_op_seae_fee['危险品申报付费']:=1; if t_ch_project.FieldByName('收付类型').AsString='全部' then begin t_op_seae_fee['危险品申报收费']:=1; t_op_seae_fee['危险品申报付费']:=1; end; end; t_op_seae_fee.Post; end; t_op_seae.Edit; t_op_seae['生成费用']:=1; t_op_seae.Post; end; end; frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; t_ch_project.Next; end; ShowMessage('生成'+IntToStr(feecount)+'条费用!'); end; end; finally frm_sys_progress.close; frm_sys_progress:=nil; FreeAndNil(aQuery); FreeAndNil(aQueryctn); t_ch_fee.close; t_ch_project_fee.close; t_ch_project.Close; end; end; function Tfrm_op_seae_dg.fee_get_client(str: string): string; begin if str='' then result:='' else begin if str='委托单位'then result:=t_op_seae.fieldbyname('委托单位').asstring; if str='船公司'then result:=t_op_seae.fieldbyname('船公司').asstring; if str='场站'then result:=t_op_seae.fieldbyname('场站').asstring; if str='车队'then result:=t_op_seae.fieldbyname('承运车队').asstring; if str='报关行'then result:=t_op_seae.fieldbyname('报关行').asstring; if str='代理'then result:=t_op_seae.fieldbyname('代理').asstring; if str='货代'then result:=t_op_seae.fieldbyname('货代公司').asstring; if str='发货人'then result:=t_op_seae.fieldbyname('发货人').asstring; if str='收货人'then result:=t_op_seae.fieldbyname('收货人').asstring; if str='通知人'then result:=t_op_seae.fieldbyname('通知人').asstring; end; end; procedure Tfrm_op_seae_dg.Edit3KeyPress(Sender: TObject; var Key: Char); begin if Key=#13 then bsSkinButton8.OnClick(Sender); end; procedure Tfrm_op_seae_dg.RxDBLookupCombo1Enter(Sender: TObject); begin RxLookupComboEnter(RxDBLookupCombo1); end; procedure Tfrm_op_seae_dg.RxDBLookupCombo1Exit(Sender: TObject); begin RxLookupComboExit(RxDBLookupCombo1); end; end.