unit u_Simpleprint; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, dxExEdtr, bsDialogs, bsSkinShellCtrls, DB, ADODB, BusinessSkinForm, StdCtrls, Mask, bsSkinBoxCtrls, bsdbctrls, bsSkinCtrls, dxTL, dxDBCtrl, dxDBGrid, dxCntner, dxDBTLCl, dxGrClms, DBCtrls, XPMenu, Menus, TXComp, ExtDlgs, ImgList, IdFTP,IdFTPCommon, frxChBox, frxOLE, frxDCtrl, frxCross, frxClass, frxADOComponents, frxRich, frxExportCSV, frxExportImage, frxExportMail, frxGZip, frxCrypt, frxDesgn, frxExportODF, frxExportPDF, frxExportXML, frxExportXLS, frxExportHTML, frxExportText, frxExportRTF, frxDBSet, Grids, DBGrids, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdExplicitTLSClientServerBase, IdMessageClient, IdSMTPBase, IdSMTP, IdMessage,IdAttachmentFile,IdText, ExtCtrls,SoapHTTPClient,u_op_seae_DsWebService,InvokeRegistry; type Tfrm_SimplePrint = class(TForm) bsBusinessSkinForm1: TbsBusinessSkinForm; t_sys_report: TADOQuery; t_sys_report1: TDataSource; bsSkinInputDialog1: TbsSkinInputDialog; bsSkinPanel1: TbsSkinPanel; Label1: TLabel; DBEdit1: TDBEdit; Label2: TLabel; DBEdit2: TDBEdit; Button5: TButton; PopupMenu1: TPopupMenu; XPMenu1: TXPMenu; N1: TMenuItem; N2: TMenuItem; EXCEL1: TMenuItem; N3: TMenuItem; WORD1: TMenuItem; N4: TMenuItem; PDF1: TMenuItem; N5: TMenuItem; RTF1: TMenuItem; ImageList: TImageList; OpenDialog1: TOpenDialog; t_sys_report_employee: TADOQuery; t_sys_report_lei: TADOQuery; t_sys_reportfile: TADOQuery; t_sys_reportfile1: TDataSource; frxBMPExport1: TfrxBMPExport; frxJPEGExport1: TfrxJPEGExport; frxTIFFExport1: TfrxTIFFExport; frxRTFExport1: TfrxRTFExport; frxSimpleTextExport1: TfrxSimpleTextExport; frxHTMLExport1: TfrxHTMLExport; frxXLSExport1: TfrxXLSExport; frxPDFExport1: TfrxPDFExport; frxODSExport1: TfrxODSExport; frxODTExport1: TfrxODTExport; frxDesigner1: TfrxDesigner; frxCrypt1: TfrxCrypt; frxGZipCompressor1: TfrxGZipCompressor; frxMailExport1: TfrxMailExport; frxGIFExport1: TfrxGIFExport; frxCSVExport1: TfrxCSVExport; frxRichObject1: TfrxRichObject; frxReport1: TfrxReport; frxADOComponents1: TfrxADOComponents; frxCrossObject1: TfrxCrossObject; frxDialogControls1: TfrxDialogControls; frxOLEObject1: TfrxOLEObject; frxCheckBoxObject1: TfrxCheckBoxObject; one_table_1: TfrxDBDataset; one_table_2: TfrxDBDataset; one_table_3: TfrxDBDataset; one_table_4: TfrxDBDataset; all_table_4: TfrxDBDataset; all_table_3: TfrxDBDataset; all_table_2: TfrxDBDataset; all_table_1: TfrxDBDataset; all_table_7: TfrxDBDataset; all_table_5: TfrxDBDataset; all_table_6: TfrxDBDataset; print_head: TfrxDBDataset; load_employee: TfrxDBDataset; t_sys_cust: TADOQuery; t_sys_cust1: TDataSource; load_cust: TfrxDBDataset; SaveDialog1: TSaveDialog; ds_sys_reporthead1: TDataSource; t_sys_reporthead: TADOQuery; all_table_8: TfrxDBDataset; all_table_9: TfrxDBDataset; PopupMenu2: TPopupMenu; MenuItem1: TMenuItem; MenuItem2: TMenuItem; MenuItem3: TMenuItem; MenuItem4: TMenuItem; MenuItem5: TMenuItem; MenuItem6: TMenuItem; MenuItem7: TMenuItem; MenuItem8: TMenuItem; MenuItem9: TMenuItem; frxHTMLExport2: TfrxHTMLExport; SMTP1: TIdSMTP; IdMsg: TIdMessage; frxPDFExport2: TfrxPDFExport; frxRTFExport2: TfrxRTFExport; frxJPEGExport2: TfrxJPEGExport; frxXLSExport2: TfrxXLSExport; pnl1: TPanel; dxDBGrid1: TdxDBGrid; dxDBGrid1Column1: TdxDBGridMaskColumn; dxDBGrid1Column2: TdxDBGridCheckColumn; bsSkinPanel3: TbsSkinPanel; bsSkinDBEdit1: TbsSkinDBEdit; bsSkinPanel2: TbsSkinPanel; bsSkinButton12: TbsSkinButton; bsSkinPanel4: TbsSkinPanel; bsSkinButton6: TbsSkinButton; bsSkinButton8: TbsSkinButton; bsSkinButton7: TbsSkinButton; bsSkinButton3: TbsSkinButton; bsSkinButton4: TbsSkinButton; bsSkinButton9: TbsSkinButton; bsSkinButton1: TbsSkinButton; bsSkinButton2: TbsSkinButton; bsSkinButton10: TbsSkinButton; bsSkinButton11: TbsSkinButton; bsSkinButton5: TbsSkinButton; bsSkinButton13: TbsSkinButton; pnl2: TPanel; bsSkinPanel5: TbsSkinPanel; bsSkinNotebook1: TbsSkinNotebook; Label44: TLabel; DBMemo14: TDBMemo; Edit1: TEdit; Edit2: TEdit; bsSkinPanel6: TbsSkinPanel; lbl1: TLabel; mmo1: TMemo; Qry1: TADOQuery; procedure bsSkinButton8Click(Sender: TObject); procedure bsSkinButton2Click(Sender: TObject); procedure bsSkinButton5Click(Sender: TObject); procedure bsSkinButton3Click(Sender: TObject); procedure bsSkinButton4Click(Sender: TObject); procedure bsSkinButton9Click(Sender: TObject); procedure bsSkinButton1Click(Sender: TObject); procedure bsSkinButton6Click(Sender: TObject); procedure FormShow(Sender: TObject); procedure bsSkinButton7Click(Sender: TObject); procedure N1Click(Sender: TObject); procedure EXCEL1Click(Sender: TObject); procedure WORD1Click(Sender: TObject); procedure PDF1Click(Sender: TObject); procedure RTF1Click(Sender: TObject); procedure bsSkinButton10Click(Sender: TObject); procedure t_sys_reportAfterPost(DataSet: TDataSet); procedure bsSkinButton12Click(Sender: TObject); procedure t_sys_reportAfterOpen(DataSet: TDataSet); procedure t_sys_reportBeforeClose(DataSet: TDataSet); procedure t_sys_reportfileAfterInsert(DataSet: TDataSet); procedure t_sys_reportfileAfterPost(DataSet: TDataSet); function frxDesigner1SaveReport(Report: TfrxReport; SaveAs: Boolean): Boolean; function frxReport1UserFunction(const MethodName: String; var Params: Variant): Variant; procedure FormCreate(Sender: TObject); procedure Button5Click(Sender: TObject); procedure MenuItem7Click(Sender: TObject); procedure bsSkinButton13Click(Sender: TObject); procedure MenuItem9Click(Sender: TObject); procedure MenuItem3Click(Sender: TObject); procedure MenuItem5Click(Sender: TObject); procedure MenuItem1Click(Sender: TObject); procedure getwebservice_ds; private mHttpRIO_ds:THTTPRIO; mServiceSoap_Ds:DsWebServiceSoap; function GetFileName(ExtName:string):string; overload; function GetFileName(filename:string;ExtName:string):string; overload; procedure SendMSG(msg:String); public MBLNO:String; Email,SenderName:String; procedure SendEmail(HtmlList:TStringList); procedure SendRHEmail(FileName:String); procedure SendSIEmail(FileName:String); procedure SendSOEmail(FileName:String); procedure SendBLCRepeatEmail(FileName:String); procedure DirectSendEmail(Caption:string) ; end; var frm_SimplePrint: Tfrm_SimplePrint; implementation uses u_main, u_data_share, my_sys_function, u_code_send_head, u_sys_frprint,u_op_letter, u_op_seae, u_sys_progress; {$R *.dfm} procedure Tfrm_SimplePrint.bsSkinButton8Click(Sender: TObject); var template : TStream; begin if t_sys_report.isempty then exit; t_sys_reportfile.Close; t_sys_reportfile.SQL.Clear; t_sys_reportfile.SQL.Add('select * from t_sys_report where CH_ID='+inttostr(t_sys_report['CH_ID'])); t_sys_reportfile.Open; if t_sys_reportfile.isempty then begin showmessage('没有打印格式,不能打印输出!'); exit; end; if t_sys_reportfile.fieldbyname('report').IsNull then begin showmessage('没有要预览的格式!'); exit; end; try try template := t_sys_reportfile.CreateBlobStream(t_sys_reportfile.FieldByName('report'), bmRead); template.Position := 0; frxReport1.LoadFromStream(template); finally template.Free; end; frxReport1.PrepareReport; frxReport1.Print; except showmessage('打印输出失败!'); end; if frm_sys_frprint.caption='海运出口单证' then begin if not t_sys_report_employee.Locate('CH_ID',t_sys_report.fieldbyname('CH_ID').asinteger,[])then begin t_sys_report_employee.insert; t_sys_report_employee['CH_ID']:=t_sys_report['CH_ID']; t_sys_report_employee['报表属性']:=t_sys_report['报表属性']; t_sys_report_employee['姓名']:=employee; t_sys_report_employee['日期']:=date; t_sys_report_employee.post; end else begin t_sys_report_employee.edit; t_sys_report_employee['日期']:=date; t_sys_report_employee.post; end; end; end; procedure Tfrm_SimplePrint.bsSkinButton2Click(Sender: TObject); var book1:Tbookmark; str:string; begin try t_sys_report.DisableControls; book1:=t_sys_report.GetBookmark; str:=t_sys_report.fieldbyname('报表名称').asstring; t_sys_report.First; while not t_sys_report.eof do begin if t_sys_report.fieldbyname('报表名称').asstring=str then begin t_sys_report.edit; t_sys_report['是否默认']:=1; t_sys_report.post; end else begin t_sys_report.edit; t_sys_report['是否默认']:=0; t_sys_report.post; end; t_sys_report.next; end; finally t_sys_report.GotoBookmark(book1); t_sys_report.EnableControls; end; end; procedure Tfrm_SimplePrint.bsSkinButton5Click(Sender: TObject); begin close; end; procedure Tfrm_SimplePrint.bsSkinButton3Click(Sender: TObject); begin if t_sys_report.IsEmpty then begin t_sys_reportfile.Close; t_sys_reportfile.SQL.Clear; t_sys_reportfile.SQL.Add('select top 0 * from t_sys_report '); t_sys_reportfile.Open; end else begin t_sys_reportfile.Close; t_sys_reportfile.SQL.Clear; t_sys_reportfile.SQL.Add('select * from t_sys_report where CH_ID='+inttostr(t_sys_report['CH_ID'])); t_sys_reportfile.Open; end; t_sys_reportfile.Insert; t_sys_reportfile['报表名称']:=bsSkinInputDialog1.InputBox('更改名称','新的名称',t_sys_reportfile.fieldbyname('报表名称').asstring); t_sys_reportfile['报表属性']:='海运出口单证';//frm_SimplePrint.Caption; t_sys_reportfile.post; { if frm_sys_frprint.caption='海运出口单证' then begin if not t_sys_report_employee.Locate('CH_ID',t_sys_reportfile.fieldbyname('CH_ID').asinteger,[])then begin t_sys_report_employee.insert; t_sys_report_employee['CH_ID']:=t_sys_reportfile['CH_ID']; t_sys_report_employee['报表属性']:=t_sys_reportfile['报表属性']; t_sys_report_employee['姓名']:=employee; t_sys_report_employee['日期']:=date; t_sys_report_employee.post; end else begin t_sys_report_employee.edit; t_sys_report_employee['日期']:=date; t_sys_report_employee.post; end; end; } frxReport1.DesignReport; end; procedure Tfrm_SimplePrint.bsSkinButton4Click(Sender: TObject); var template : TStream; begin if t_sys_report.isempty then exit; t_sys_reportfile.Close; t_sys_reportfile.SQL.Clear; t_sys_reportfile.SQL.Add('select * from t_sys_report where CH_ID='+inttostr(t_sys_report['CH_ID'])); t_sys_reportfile.Open; if t_sys_reportfile.isempty then begin showmessage('没有要设计的格式!'); exit; end; try if not t_sys_reportfile.fieldbyname('report').IsNull then begin try template := t_sys_reportfile.CreateBlobStream(t_sys_reportfile.FieldByName('report'), bmRead); template.Position := 0; frxReport1.LoadFromStream(template); finally template.Free; end; end; frxReport1.DesignReport; except showmessage('格式设计失败!'); end; if frm_sys_frprint.caption='海运出口单证' then begin if not t_sys_report_employee.Locate('CH_ID',t_sys_reportfile.fieldbyname('CH_ID').asinteger,[])then begin t_sys_report_employee.insert; t_sys_report_employee['CH_ID']:=t_sys_reportfile['CH_ID']; t_sys_report_employee['报表属性']:=t_sys_reportfile['报表属性']; t_sys_report_employee['姓名']:=employee; t_sys_report_employee['日期']:=date; t_sys_report_employee.post; end else begin t_sys_report_employee.edit; t_sys_report_employee['日期']:=date; t_sys_report_employee.post; end; end; end; procedure Tfrm_SimplePrint.bsSkinButton9Click(Sender: TObject); begin if t_sys_report.isempty then begin showmessage('没有要删除的格式!'); exit; end; if application.MessageBox('您确定要删除格式吗?','警告:',MB_OKCANCEL)=IDOK then t_sys_report.delete; end; procedure Tfrm_SimplePrint.bsSkinButton1Click(Sender: TObject); begin if t_sys_report.isempty then begin showmessage('没有要更改名称的格式!'); exit; end; t_sys_report.edit; t_sys_report['报表名称']:=bsSkinInputDialog1.InputBox('更改名称','新的名称',t_sys_report.fieldbyname('报表名称').asstring); t_sys_report.post; end; procedure Tfrm_SimplePrint.bsSkinButton6Click(Sender: TObject); var template : TStream; begin if t_sys_report.isempty then exit; t_sys_reportfile.Close; t_sys_reportfile.SQL.Clear; t_sys_reportfile.SQL.Add('select * from t_sys_report where CH_ID='+inttostr(t_sys_report['CH_ID'])); t_sys_reportfile.Open; if t_sys_reportfile.isempty then exit; if t_sys_reportfile.fieldbyname('report').IsNull then begin showmessage('没有要预览的格式!'); exit; end; try try template := t_sys_reportfile.CreateBlobStream(t_sys_reportfile.FieldByName('report'), bmRead); template.Position := 0; frxReport1.LoadFromStream(template); finally template.Free; end; frxReport1.ShowReport; except showmessage('打印预览失败!'); end; if frm_sys_frprint.caption='海运出口单证' then begin if not t_sys_report_employee.Locate('CH_ID',t_sys_reportfile.fieldbyname('CH_ID').asinteger,[])then begin t_sys_report_employee.insert; t_sys_report_employee['CH_ID']:=t_sys_reportfile['CH_ID']; t_sys_report_employee['报表属性']:=t_sys_reportfile['报表属性']; t_sys_report_employee['姓名']:=employee; t_sys_report_employee['日期']:=date; t_sys_report_employee.post; end else begin t_sys_report_employee.edit; t_sys_report_employee['日期']:=date; t_sys_report_employee.post; end; end; end; procedure Tfrm_SimplePrint.FormShow(Sender: TObject); begin if not if_open('170') then begin bsSkinButton3.Enabled:=false; bsSkinButton4.Enabled:=false; bsSkinButton9.Enabled:=false; bsSkinButton1.Enabled:=false; bsSkinButton2.Enabled:=false; bsSkinButton10.Enabled:=false; bsSkinButton11.Enabled:=false; end; // frm_data_share.t_sys_report_head.Requery(); // frm_data_share.t_load_employee.Requery(); if not t_sys_reporthead.IsEmpty then begin t_sys_reporthead.edit; t_sys_reporthead['台头TO']:=''; t_sys_reporthead['台头ATTN']:=''; t_sys_reporthead.post; end; if frm_sys_frprint.caption='海运出口单证' then bsSkinPanel2.Visible:=true; // rd.XHD_help:=t_sys_report_lei.fieldbyname('报表说明').asstring; if (frm_simpleprint.Caption='海运出口入货通知')then begin bsSkinNotebook1.PageIndex:=0; //DataSource1.Enabled:=false; edit1.Text:=print_head.DataSource.DataSet.fieldbyname('台头1').asstring; edit2.Text:='"'+SenderName+'"<'+Email+'>'; frm_op_letter.t_op_letter_rh.Edit; DBMemo14.DataSource:=frm_op_letter.t_op_letter_rh1; //dbedt1.DataSource:=frm_op_letter.t_op_letter_rh1; end; if (frm_simpleprint.Caption='提单样本') then begin bsSkinNotebook1.PageIndex:=1; //DataSource1.Enabled:=false; edit1.Text:=print_head.DataSource.DataSet.fieldbyname('台头1').asstring; edit2.Text:='"'+SenderName+'"<'+Email+'>'; { DBMemo14.Enabled:=False; bsSkinButton1.Visible:=True; bsSkinButton4.Visible:=True; bsSkinButton3.Visible:=True; bsSkinButton9.Visible:=True; bsSkinButton7.Visible:=True; } end else begin { DBMemo14.Enabled:=true; bsSkinButton1.Visible:=False; bsSkinButton4.Visible:=False; bsSkinButton3.Visible:=False; bsSkinButton9.Visible:=False; bsSkinButton7.Visible:=False; } end; end; procedure Tfrm_SimplePrint.bsSkinButton7Click(Sender: TObject); var Pnt:Tpoint; begin Pnt:=bsSkinButton7.ClientToScreen(Point(0,bsSkinButton7.Height)); PopupMenu1.Popup(Pnt.x,Pnt.y); if frm_sys_frprint.caption='海运出口单证' then begin if not t_sys_report_employee.Locate('CH_ID',t_sys_report.fieldbyname('CH_ID').asinteger,[])then begin t_sys_report_employee.insert; t_sys_report_employee['CH_ID']:=t_sys_report['CH_ID']; t_sys_report_employee['报表属性']:=t_sys_report['报表属性']; t_sys_report_employee['姓名']:=employee; t_sys_report_employee['日期']:=date; t_sys_report_employee.post; end else begin t_sys_report_employee.edit; t_sys_report_employee['日期']:=date; t_sys_report_employee.post; end; end; end; procedure Tfrm_SimplePrint.N1Click(Sender: TObject); var template : TStream; begin if t_sys_report.isempty then exit; t_sys_reportfile.Close; t_sys_reportfile.SQL.Clear; t_sys_reportfile.SQL.Add('select * from t_sys_report where CH_ID='+inttostr(t_sys_report['CH_ID'])); t_sys_reportfile.Open; if t_sys_reportfile.isempty then begin showmessage('没有打印格式,不能存为文件!'); exit; end; try try template := t_sys_reportfile.CreateBlobStream(t_sys_reportfile.FieldByName('report'), bmRead); template.Position := 0; frxReport1.LoadFromStream(template); finally template.Free; end; frxReport1.PrepareReport; frxReport1.Export(frxJPEGExport1); except showmessage('存为文件失败!'); end; end; procedure Tfrm_SimplePrint.EXCEL1Click(Sender: TObject); var template : TStream; begin if t_sys_report.isempty then exit; t_sys_reportfile.Close; t_sys_reportfile.SQL.Clear; t_sys_reportfile.SQL.Add('select * from t_sys_report where CH_ID='+inttostr(t_sys_report['CH_ID'])); t_sys_reportfile.Open; if t_sys_reportfile.isempty then begin showmessage('没有打印格式,不能存为文件!'); exit; end; try try template := t_sys_reportfile.CreateBlobStream(t_sys_reportfile.FieldByName('report'), bmRead); template.Position := 0; frxReport1.LoadFromStream(template); finally template.Free; end; frxReport1.PrepareReport; frxReport1.Export(frxXLSExport1); except showmessage('存为文件失败!'); end; end; procedure Tfrm_SimplePrint.WORD1Click(Sender: TObject); var template : TStream; begin if t_sys_report.isempty then exit; t_sys_reportfile.Close; t_sys_reportfile.SQL.Clear; t_sys_reportfile.SQL.Add('select * from t_sys_report where CH_ID='+inttostr(t_sys_report['CH_ID'])); t_sys_reportfile.Open; if t_sys_reportfile.isempty then begin showmessage('没有打印格式,不能存为文件!'); exit; end; try try template := t_sys_reportfile.CreateBlobStream(t_sys_reportfile.FieldByName('report'), bmRead); template.Position := 0; frxReport1.LoadFromStream(template); finally template.Free; end; frxReport1.PrepareReport; frxReport1.Export(frxHTMLExport1); except showmessage('存为文件失败!'); end; end; procedure Tfrm_SimplePrint.PDF1Click(Sender: TObject); var template : TStream; begin if t_sys_report.isempty then exit; t_sys_reportfile.Close; t_sys_reportfile.SQL.Clear; t_sys_reportfile.SQL.Add('select * from t_sys_report where CH_ID='+inttostr(t_sys_report['CH_ID'])); t_sys_reportfile.Open; if t_sys_reportfile.isempty then begin showmessage('没有打印格式,不能存为文件!'); exit; end; try try template := t_sys_reportfile.CreateBlobStream(t_sys_reportfile.FieldByName('report'), bmRead); template.Position := 0; frxReport1.LoadFromStream(template); finally template.Free; end; frxReport1.PrepareReport; frxReport1.Export(frxPDFExport1); except showmessage('存为文件失败!'); end; end; procedure Tfrm_SimplePrint.RTF1Click(Sender: TObject); var template : TStream; begin if t_sys_report.isempty then exit; t_sys_reportfile.Close; t_sys_reportfile.SQL.Clear; t_sys_reportfile.SQL.Add('select * from t_sys_report where CH_ID='+inttostr(t_sys_report['CH_ID'])); t_sys_reportfile.Open; if t_sys_reportfile.isempty then begin showmessage('没有打印格式,不能存为文件!'); exit; end; try try template := t_sys_reportfile.CreateBlobStream(t_sys_reportfile.FieldByName('report'), bmRead); template.Position := 0; frxReport1.LoadFromStream(template); finally template.Free; end; frxReport1.PrepareReport; frxReport1.Export(frxRTFExport1); except showmessage('存为文件失败!'); end; end; procedure Tfrm_SimplePrint.bsSkinButton10Click(Sender: TObject); var template : TStream; begin if t_sys_report.isempty then exit; t_sys_reportfile.Close; t_sys_reportfile.SQL.Clear; t_sys_reportfile.SQL.Add('select * from t_sys_report where CH_ID='+inttostr(t_sys_report['CH_ID'])); t_sys_reportfile.Open; if t_sys_reportfile.isempty then begin showmessage('没有打印格式,不能打印输出!'); exit; end; if t_sys_reportfile.fieldbyname('report').IsNull then begin showmessage('没有要预览的格式!'); exit; end; try try template := t_sys_reportfile.CreateBlobStream(t_sys_reportfile.FieldByName('report'), bmRead); template.Position := 0; frxReport1.LoadFromStream(template); finally template.Free; end; if SaveDialog1.Execute then frxReport1.savetofile(SaveDialog1.filename); except showmessage('另存格式失败!'); end; // GetNewData('t_sys_report','CH_ID','',t_sys_reportfile); { try IdFTP1:=TIdFTP.Create(application); with idftp1 do begin Username:='dongsheng'; Password:='zouwenkun'; Host:='218.57.11.18'; Connect; end; idftp1.Disconnect; update_jiandu; try if not assigned(frm_sys_print_down) then frm_sys_print_down:=tfrm_sys_print_down.Create (self); frm_sys_print_down.Caption:=frm_sys_print.Caption; frm_sys_print_down.ShowModal; finally frm_sys_print_down.free; frm_sys_print_down:=NIL; end; except showmessage('与下载服务器联机失败!!'); end; idftp1.free; } end; procedure Tfrm_SimplePrint.t_sys_reportAfterPost(DataSet: TDataSet); begin if frm_sys_frprint.caption='海运出口单证' then begin if not t_sys_report_employee.Locate('CH_ID',t_sys_report.fieldbyname('CH_ID').asinteger,[])then begin t_sys_report_employee.insert; t_sys_report_employee['CH_ID']:=t_sys_report['CH_ID']; t_sys_report_employee['报表属性']:=t_sys_report['报表属性']; t_sys_report_employee['姓名']:=employee; t_sys_report_employee['日期']:=date; t_sys_report_employee.post; end else begin t_sys_report_employee.edit; t_sys_report_employee['日期']:=date; t_sys_report_employee.post; end; end; end; procedure Tfrm_SimplePrint.bsSkinButton12Click(Sender: TObject); var str:widestring; begin if bsSkinButton12.caption='所有格式'then begin bsSkinButton12.caption:='近期格式'; t_sys_reportfile.close; t_sys_report.close; t_sys_report.sql.clear; t_sys_report.sql.add('select 报表名称,报表属性,是否默认,CH_ID from t_sys_report where 报表属性=:报表属性 order by 报表名称'); t_sys_report.Parameters[0].value:=frm_sys_frprint.caption; t_sys_report.open; t_sys_reportfile.Open; end else begin if not t_sys_report_employee.IsEmpty then begin t_sys_report_employee.first; while not t_sys_report_employee.eof do begin if t_sys_report_employee.fieldbyname('日期').AsDateTime>=date-30 then begin if str='' then str:=t_sys_report_employee.fieldbyname('CH_ID').asstring else str:=str+','+t_sys_report_employee.fieldbyname('CH_ID').asstring; end; t_sys_report_employee.next; end; str:=' and CH_ID in ('+str+')'; t_sys_reportfile.close; t_sys_report.close; t_sys_report.sql.clear; t_sys_report.sql.add('select 报表名称,报表属性,是否默认,CH_ID from t_sys_report where 报表属性=:报表属性 '+str+' order by 报表名称'); t_sys_report.Parameters[0].value:=frm_sys_frprint.caption; t_sys_report.open; t_sys_reportfile.Open; end else begin t_sys_reportfile.close; t_sys_report.close; t_sys_report.sql.clear; t_sys_report.sql.add('select 报表名称,报表属性,是否默认,CH_ID from t_sys_report where 报表属性=:报表属性 order by 报表名称'); t_sys_report.Parameters[0].value:=frm_sys_frprint.caption; t_sys_report.open; t_sys_reportfile.Open; end; bsSkinButton12.caption:='所有格式'; end; end; procedure Tfrm_SimplePrint.t_sys_reportAfterOpen(DataSet: TDataSet); begin // t_sys_reportfile.Open; end; procedure Tfrm_SimplePrint.t_sys_reportBeforeClose(DataSet: TDataSet); begin // t_sys_reportfile.Close; end; procedure Tfrm_SimplePrint.t_sys_reportfileAfterInsert(DataSet: TDataSet); begin t_sys_reportfile['报表属性']:=frm_sys_frprint.Caption; t_sys_reportfile['报表名称']:=frm_sys_frprint.Caption; t_sys_reportfile['报表内容']:='12311'; t_sys_reportfile['是否默认']:=false; end; procedure Tfrm_SimplePrint.t_sys_reportfileAfterPost(DataSet: TDataSet); var str:widestring; begin if frm_sys_frprint.caption='海运出口单证' then begin if not t_sys_report_employee.Locate('CH_ID',t_sys_reportfile.fieldbyname('CH_ID').asinteger,[])then begin t_sys_report_employee.insert; t_sys_report_employee['CH_ID']:=t_sys_reportfile['CH_ID']; t_sys_report_employee['报表属性']:=t_sys_reportfile['报表属性']; t_sys_report_employee['姓名']:=employee; t_sys_report_employee['日期']:=date; t_sys_report_employee.post; end else begin t_sys_report_employee.edit; t_sys_report_employee['日期']:=date; t_sys_report_employee.post; end; if bsSkinButton12.caption='所有格式'then begin if not t_sys_report_employee.IsEmpty then begin t_sys_report_employee.first; while not t_sys_report_employee.eof do begin if t_sys_report_employee.fieldbyname('日期').AsDateTime>=date-30 then begin if str='' then str:=t_sys_report_employee.fieldbyname('CH_ID').asstring else str:=str+','+t_sys_report_employee.fieldbyname('CH_ID').asstring; end; t_sys_report_employee.next; end; str:=' and CH_ID in ('+str+')'; t_sys_report.close; t_sys_report.sql.clear; t_sys_report.sql.add('select 报表名称,报表属性,是否默认,CH_ID from t_sys_report where 报表属性=:报表属性 '+str+' order by 报表名称'); t_sys_report.Parameters[0].value:=frm_sys_frprint.caption; t_sys_report.open; end else begin t_sys_report.close; t_sys_report.sql.clear; t_sys_report.sql.add('select 报表名称,报表属性,是否默认,CH_ID from t_sys_report where 报表属性=:报表属性 order by 报表名称'); t_sys_report.Parameters[0].value:=frm_sys_frprint.caption; t_sys_report.open; end; end else begin t_sys_report.close; t_sys_report.sql.clear; t_sys_report.sql.add('select 报表名称,报表属性,是否默认,CH_ID from t_sys_report where 报表属性=:报表属性 order by 报表名称'); t_sys_report.Parameters[0].value:=frm_sys_frprint.caption; t_sys_report.open; end; end else t_sys_report.Requery; t_sys_report.Locate('CH_ID',t_sys_reportfile['CH_ID'],[]); end; function Tfrm_SimplePrint.frxDesigner1SaveReport(Report: TfrxReport; SaveAs: Boolean): Boolean; var template : TStream; begin if saveas then begin try if SaveDialog1.Execute then frxReport1.savetofile(SaveDialog1.filename); except showmessage('另存格式失败!'); end; end else begin template := TMemoryStream.Create; template.Position := 0; frxReport1.SaveToStream(template); t_sys_reportfile.Edit; try t_sys_reportfile.DisableControls; (t_sys_reportfile.FieldByName('Report') as TBlobField).LoadFromStream(template); t_sys_reportfile.Post; finally t_sys_reportfile.EnableControls; template.Free; end; result:=true; end; end; function Tfrm_SimplePrint.frxReport1UserFunction(const MethodName: String; var Params: Variant): Variant; begin // if uppercase(MethodName)='MONEYCN' then Result := MoneyCn(Params[0],Params[1]); if uppercase(MethodName)='ENGDATEFMT' then Result := EngDateFmt(Params[0],Params[1],Params[2],Params[3],Params[4],Params[5],Params[6]); if uppercase(MethodName)='GETCUSTBALDATE' then Result :=formatdatetime('YYYY-MM-DD',getstlDate(Params[0],Params[1],Params[2])); if uppercase(MethodName)='GETCUSTBALDAY' then Result :=inttostr(getstlDay(Params[0],Params[1],Params[2])); if uppercase(MethodName)='MONEYEN' then Result := EWords(Params[0],0); end; procedure Tfrm_SimplePrint.FormCreate(Sender: TObject); begin frxReport1.AddFunction('function MoneyCn(num:real;lx:boolean=false):widestring;','自定义'); frxReport1.AddFunction('function MoneyEn(num:real;):widestring;','自定义'); frxReport1.AddFunction('function EngDateFmt(ADateTime:TDateTime;JX,DX:boolean;MDY:Boolean=true;MD:Boolean=false;DIAN:Boolean=false;MY:Boolean=false):string;','自定义'); frxReport1.AddFunction('function GETCUSTBALDATE(ADateTime:TDateTime;Cust,Sale:String):TDateTime;','自定义'); frxReport1.AddFunction('function GETCUSTBALDAY(ADateTime:TDateTime;Cust,Sale:String):integer;','自定义'); end; procedure Tfrm_SimplePrint.Button5Click(Sender: TObject); begin try frm_code_send_head:=tfrm_code_send_head.Create (self); code_send_head_num:=5; frm_code_send_head.DataSource2:=ds_sys_reporthead1; frm_code_send_head.ShowModal; finally frm_code_send_head.Free; frm_code_send_head:=nil; end; end; procedure Tfrm_SimplePrint.MenuItem7Click(Sender: TObject); var txtFile: TextFile;//作为html正文 template : TStream; filename,temp:string; //str_memo:Tmemo; HtmlList:TStringList; begin if t_sys_report.isempty then exit; t_sys_reportfile.Close; t_sys_reportfile.SQL.Clear; t_sys_reportfile.SQL.Add('select * from t_sys_report where CH_ID='+inttostr(t_sys_report['CH_ID'])); t_sys_reportfile.Open; if t_sys_reportfile.isempty then begin showmessage('没有打印格式,不能存为文件!'); exit; end; try { str_memo:=Tmemo.create(application); str_memo.visible:=false; str_memo.Parent:=frm_sys_frprint; } htmlList:=TStringList.create(); try try template := t_sys_reportfile.CreateBlobStream(t_sys_reportfile.FieldByName('report'), bmRead); template.Position := 0; frxReport1.LoadFromStream(template); finally template.Free; end; frxReport1.PrepareReport; filename:=GetFileName('.file'); frxHTMLExport2.FileName:=filename; frxReport1.Export(frxHTMLExport2); AssignFile(txtFile,filename); Reset(txtFile); //以只读方式打开文件 try while not EOF(txtFile) do begin Readln(txtFile,temp); HtmlList.Add(temp) end; finally CloseFile(txtFile); //关闭文件 DeleteFile(filename); SendEmail(HtmlList) ; end; except showmessage('存为文件失败!'); end; finally end; end; procedure Tfrm_SimplePrint.bsSkinButton13Click(Sender: TObject); var p:TPoint; begin if frm_simpleprint.Caption='海运出口入货通知' then begin //ShowMessage(frm_op_letter.t_op_letter_rh.fieldbyname('备注').asstring); if frm_op_letter.t_op_letter_rh.state in [dsinsert,dsedit] then frm_op_letter.t_op_letter_rh.Post; end; if frm_simpleprint.Caption='提单样本' then begin //提单样本的话 备注增加写入辅助字段3 并调用一次发出沟通消息 并写入邮件文本内容 frm_op_seae.t_op_seae.edit; frm_op_seae.t_op_seae['辅助字段三']:=frm_op_seae.t_op_seae.fieldbyname('辅助字段三').asstring +' '+mmo1.Lines.Text; frm_op_seae.t_op_seae.post; //ShowMessage(frm_op_seae.t_op_seae.fieldbyname('辅助字段三').asstring); end; frm_SimplePrint.MenuItem9Click(Sender); end; procedure Tfrm_SimplePrint.SendEmail(HtmlList:TStringList); var str:widestring; str_file:widestring; IdHtml: TIdText; _i:integer; begin IdMsg.Clear; try if HtmlList.count>0 then begin SMTP1.AuthType := satDefault; //(satNone, satDefault, satSASL); 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; if not SMTP1.Connected then begin Sleep(1000); SMTP1.Connect; end; try with IdMsg do begin body.Clear; // ContentType:='us-ascii'; // CharSet:='GB2312'; IdHtml := TIdText.Create(MessageParts); IdHtml.ContentType := 'text/html;charset=gb2312'; IdHtml.ContentTransfer := '7bit'; for _i:=0 to HtmlList.count-1 do begin IdHtml.Body.Add(HtmlList[_i]); end; From.address :='admin@dongshengsoft.com'; // From.address :='crazymanqd@126.com'; Recipients.EMailAddresses :=DBEdit1.text; Subject:=employee +':'+frm_simpleprint.Caption; t_sys_reporthead.SaveToFile(ExtractFilePath(Application.ExeName)+employee+'.file'); TIdAttachmentFile.Create(MessageParts,ExtractFilePath(Application.ExeName)+employee+'.file'); //TIdAttachment.Create(MessageParts,ExtractFilePath(Application.ExeName)+edit5.text+'.DS'); end; if not SMTP1.Connected then begin Sleep(1000); SMTP1.Connect; end; SMTP1.Send(IdMsg); //MessageDlg('申请订舱发送成功',mtConfirmation,[mbOK],0) finally SMTP1.Disconnect; deletefile(ExtractFilePath(Application.ExeName)+employee+'.file'); end; end; except frm_op_seae.SendedEmail:=false; MessageDlg('邮件发送失败,可能是收件人或公司邮箱不存在,请电话联系:0532-83889257!',mtError,[mbOK],0); end; end; procedure Tfrm_SimplePrint.MenuItem9Click(Sender: TObject); var template : TStream; //作为pdf附件 FileName:String; begin try if not ASSIGNED(frm_sys_progress) then frm_sys_progress := tfrm_sys_progress.Create(application); frm_sys_progress.bsSkinGauge1.ProgressText := '正在获取数据请等候。。。'; frm_sys_progress.bsSkinGauge1.MaxValue := 5; frm_sys_progress.bsSkinGauge1.MinValue := 0; frm_sys_progress.Show; if t_sys_report.isempty then exit; t_sys_reportfile.Close; t_sys_reportfile.SQL.Clear; t_sys_reportfile.SQL.Add('select * from t_sys_report where CH_ID='+inttostr(t_sys_report['CH_ID'])); t_sys_reportfile.Open; if t_sys_reportfile.isempty then begin showmessage('没有打印格式,不能存为文件!'); exit; end; try try template := t_sys_reportfile.CreateBlobStream(t_sys_reportfile.FieldByName('report'), bmRead); template.Position := 0; frxReport1.LoadFromStream(template); finally template.Free; end; frxReport1.PrepareReport; frxPDFExport2.FileName:=GetFileName('.PDF'); frxReport1.Export(frxPDFExport2); if frm_SimplePrint.Caption='海运出口入货通知' then SendRHEmail(frxPDFExport2.FileName); if frm_SimplePrint.Caption='提单样本' then SendBLCRepeatEmail(frxPDFExport2.FileName); except showmessage('存为文件失败!'); end; finally frm_sys_progress.Close; frm_sys_progress.Free; frm_sys_progress := nil; end; end; procedure Tfrm_SimplePrint.DirectSendEmail(Caption:string) ; var template : TStream; //作为pdf附件 FileName:String; begin if t_sys_report.isempty then exit; t_sys_reportfile.Close; t_sys_reportfile.SQL.Clear; t_sys_reportfile.SQL.Add('select * from t_sys_report where CH_ID='+inttostr(t_sys_report['CH_ID'])); t_sys_reportfile.Open; if t_sys_reportfile.isempty then begin showmessage('没有打印格式,不能存为文件!'); exit; end; try try template := t_sys_reportfile.CreateBlobStream(t_sys_reportfile.FieldByName('report'), bmRead); template.Position := 0; frxReport1.LoadFromStream(template); finally template.Free; end; frxReport1.PrepareReport; if Caption='订舱' then frxPDFExport2.FileName:=GetFileName('SPXNO:'+one_table_1.DataSource.DataSet.fieldbyname('订舱序列号').asstring+'_'+Caption,'.PDF'); if Caption='提单确认' then frxPDFExport2.FileName:=GetFileName('_'+Caption+'.PDF'); //one_table_1.DataSource.DataSet.fieldbyname('订舱序列号').asstring frxReport1.Export(frxPDFExport2); if Caption='订舱' then SendSOEmail(frxPDFExport2.FileName); if Caption='提单确认' then SendSIEmail(frxPDFExport2.FileName); except showmessage('存为文件失败!'); end; end; procedure Tfrm_SimplePrint.SendRHEmail(FileName: String); var str:widestring; str_file:widestring; IdHtml,IdFoot: TIdText; _i:integer; begin IdMsg.Clear; try SMTP1.AuthType := satDefault; //(satNone, satDefault, satSASL); 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; if not SMTP1.Connected then begin Sleep(1000); SMTP1.Connect; end; try with IdMsg do begin //body.Clear; IdMsg.From.address :=one_table_4.DataSource.DataSet.fieldbyname('ReceiverEmail').asstring; // From.address :='crazymanqd@126.com'; Recipients.EMailAddresses :=Email; //Subject:=MBLNO +':'+frm_Simpleprint.caption; //body.Add(Subject); if (frm_Simpleprint.caption='海运出口入货通知') then begin Subject:='入货通知:'+one_table_4.DataSource.DataSet.fieldbyname('ReceiverCompany').asstring+'--'+MBLNO +'--'+one_table_1.DataSource.DataSet.fieldbyname('开船日期').asstring +'--'+one_table_1.DataSource.DataSet.fieldbyname('集装箱').asstring +'--'+one_table_1.DataSource.DataSet.fieldbyname('目的地').asstring; IdHtml := TIdText.Create(MessageParts); IdHtml.ContentType := 'text/html'; //IdHtml.ContentTransfer := '7bit'; IdHtml.Body.Add(''); IdHtml.Body.Add(' '); //IdHtml.Body.Add(' ' + Subject + ''); IdHtml.Body.Add(' '); IdHtml.Body.Add(' '); IdHtml.Body.Add(' ' + Subject + ' (摘要)'); IdHtml.Body.Add('
'); IdHtml.Body.Add('
'); IdHtml.Body.Add('
TO:'+one_table_4.DataSource.DataSet.fieldbyname('sendercompany').asstring); IdHtml.Body.Add('
FROM:'+one_table_4.DataSource.DataSet.fieldbyname('ReceiverCompany').asstring+'/' +one_table_4.DataSource.DataSet.fieldbyname('ReceiverName').asstring +'  电话'+one_table_4.DataSource.DataSet.fieldbyname('Mobile').asstring +'  邮箱'+one_table_4.DataSource.DataSet.fieldbyname('ReceiverEmail').asstring ); IdHtml.Body.Add('
'); //IdHtml.Body.Add('
提单号:'+MBLNO); IdHtml.Body.Add('

船名/航次:'+one_table_1.DataSource.DataSet.fieldbyname('船名').asstring+'/'+one_table_1.DataSource.DataSet.fieldbyname('航次').asstring); IdHtml.Body.Add('
提单号:'+MBLNO); IdHtml.Body.Add('
开船日期:'+one_table_1.DataSource.DataSet.fieldbyname('开船日期').asstring); IdHtml.Body.Add('
起运港:'+one_table_1.DataSource.DataSet.fieldbyname('装货港').asstring); IdHtml.Body.Add('
卸货港:'+one_table_1.DataSource.DataSet.fieldbyname('卸货港').asstring); IdHtml.Body.Add('
目的地:'+one_table_1.DataSource.DataSet.fieldbyname('目的地').asstring); IdHtml.Body.Add('
箱型箱量:'+one_table_1.DataSource.DataSet.fieldbyname('集装箱').asstring); IdHtml.Body.Add('
件数:'+one_table_1.DataSource.DataSet.fieldbyname('件数').asstring+' '+one_table_1.DataSource.DataSet.fieldbyname('包装').asstring+'    重量:'+one_table_1.DataSource.DataSet.fieldbyname('重量').asstring+' KGS    尺码:'+one_table_1.DataSource.DataSet.fieldbyname('尺码').asstring+' CBM'); IdHtml.Body.Add('
截港时间:'+one_table_1.DataSource.DataSet.fieldbyname('截港日期').asstring); IdHtml.Body.Add('
截单时间:'+one_table_1.DataSource.DataSet.fieldbyname('截单日期').asstring); IdHtml.Body.Add('
场  站:'+one_table_1.DataSource.DataSet.fieldbyname('场站').asstring); IdHtml.Body.Add('
场站地址:'+one_table_3.DataSource.DataSet.fieldbyname('场站地址').asstring); //IdHtml.Body.Add('
场站地址:'+StringReplace (one_table_3.DataSource.DataSet.fieldbyname('场站地址').asstring, '\n', '
', [rfReplaceAll])); IdHtml.Body.Add('
场站联系人:'+one_table_3.DataSource.DataSet.fieldbyname('场站联系人').asstring +'    电话:'+one_table_3.DataSource.DataSet.fieldbyname('场站联系电话').asstring +'    传真:'+one_table_3.DataSource.DataSet.fieldbyname('场站联系传真').asstring); IdHtml.Body.Add('
货物描述:'+one_table_1.DataSource.DataSet.fieldbyname('货物描述').asstring); IdHtml.Body.Add('
备注:'+StringReplace (one_table_3.DataSource.DataSet.fieldbyname('备注').asstring, #13#10, '
', [rfReplaceAll])); IdHtml.Body.Add('
ShippingBoxNO.:'+one_table_1.DataSource.DataSet.fieldbyname('订舱序列号').asstring); IdHtml.Body.Add('

**********本邮件由ShippingBox订舱平台自动发送 *************'); IdHtml.Body.Add('
本邮件仅提供当前货物部分摘要信息,详情请以双方约定为准!'); IdHtml.Body.Add('
'); IdHtml.Body.Add('
www.shippingbox.cc'); IdHtml.Body.Add('
'); IdHtml.Body.Add(''); IdFoot := TIdText.Create(MessageParts); IdFoot.ContentType := 'text/html'; //IdHtml.ContentTransfer := '7bit'; IdFoot.Body.Add(''); end; TIdAttachmentFile.Create(MessageParts,FileName); //TIdAttachment.Create(MessageParts,ExtractFilePath(Application.ExeName)+edit5.text+'.DS'); end; if not SMTP1.Connected then begin Sleep(1000); SMTP1.Connect; end; SMTP1.Send(IdMsg); //MessageDlg('申请订舱发送成功',mtConfirmation,[mbOK],0) finally SMTP1.Disconnect; deletefile(FileName); end; //showmessage('发送完成'); frm_op_seae.SendedEmail:=True; close; except MessageDlg('邮件发送失败,可能是收件人或公司邮箱不存在,请电话联系:0532-83889257!',mtError,[mbOK],0); frm_op_seae.SendedEmail:=False; end; end; procedure Tfrm_SimplePrint.SendSIEmail(FileName: String); var //提单确认 str:widestring; str_file:widestring; IdHtml,IdFoot: TIdText; _i:integer; begin IdMsg.Clear; try SMTP1.AuthType := satDefault; //(satNone, satDefault, satSASL); 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; if not SMTP1.Connected then begin Sleep(1000); SMTP1.Connect; end; try with IdMsg do begin //body.Clear; IdMsg.From.address :=one_table_4.DataSource.DataSet.fieldbyname('senderEmail').asstring; // From.address :='crazymanqd@126.com'; Recipients.EMailAddresses :=Email; //Subject:=MBLNO +':'+frm_Simpleprint.caption; //body.Add(Subject); Subject:='提单确认:From'+one_table_4.DataSource.DataSet.fieldbyname('SenderCompany').asstring+'--' +'--'+one_table_1.DataSource.DataSet.fieldbyname('主提单号').asstring +'--'+one_table_1.DataSource.DataSet.fieldbyname('开船日期').asstring +'--'+one_table_1.DataSource.DataSet.fieldbyname('集装箱').asstring +'--'+one_table_1.DataSource.DataSet.fieldbyname('目的地').asstring; IdHtml := TIdText.Create(MessageParts); IdHtml.ContentType := 'text/html'; //IdHtml.ContentTransfer := '7bit'; IdHtml.Body.Add(''); IdHtml.Body.Add(' '); //IdHtml.Body.Add(' ' + Subject + ''); IdHtml.Body.Add(' '); IdHtml.Body.Add(' '); IdHtml.Body.Add(' ' + Subject + ' (摘要)'); IdHtml.Body.Add('
'); IdHtml.Body.Add('
'); IdHtml.Body.Add('
TO:'+one_table_4.DataSource.DataSet.fieldbyname('ReceiverCompany').asstring); IdHtml.Body.Add('
FROM:'+one_table_4.DataSource.DataSet.fieldbyname('sendercompany').asstring+'/' +one_table_4.DataSource.DataSet.fieldbyname('senderName').asstring +'  电话'+one_table_4.DataSource.DataSet.fieldbyname('senderMobile').asstring +'  邮箱'+one_table_4.DataSource.DataSet.fieldbyname('senderEmail').asstring ); IdHtml.Body.Add('
'); { Body.Append("
箱型箱量:" + Opseae.CNTR); if (Opseae.ETD != "") Body.Append("
船期:" + Opseae.ETD); if (Opseae.CNTR != "") Body.Append("
目的地:" + Opseae.DESTINATION); if (Opseae.BOOKINGDESCRIPTION != "") Body.Append("
订舱说明:" + Opseae.BOOKINGDESCRIPTION);} IdHtml.Body.Add('

'); IdHtml.Body.Add('
 提单号:'+one_table_1.DataSource.DataSet.fieldbyname('主提单号').asstring); IdHtml.Body.Add('
箱型箱量:'+one_table_1.DataSource.DataSet.fieldbyname('集装箱').asstring); IdHtml.Body.Add('
开船日期:'+one_table_1.DataSource.DataSet.fieldbyname('开船日期').asstring); IdHtml.Body.Add('
 目的地:'+one_table_1.DataSource.DataSet.fieldbyname('目的地').asstring); // IdHtml.Body.Add('
销售订舱说明:'+one_table_1.DataSource.DataSet.fieldbyname('销售订舱说明').asstring); IdHtml.Body.Add('
货物描述:'+one_table_1.DataSource.DataSet.fieldbyname('货物描述').asstring); IdHtml.Body.Add('

ShippingBoxNO.:'+one_table_1.DataSource.DataSet.fieldbyname('订舱序列号').asstring); IdHtml.Body.Add('

**********本邮件由ShippingBox订舱平台自动发送 *************'); IdHtml.Body.Add('
本邮件仅提供当前货物部分摘要信息,详情请以双方约定为准!'); IdHtml.Body.Add('
'); IdHtml.Body.Add('
www.shippingbox.cc'); IdHtml.Body.Add('
'); IdHtml.Body.Add(''); IdFoot := TIdText.Create(MessageParts); IdFoot.ContentType := 'text/html'; //IdHtml.ContentTransfer := '7bit'; IdFoot.Body.Add(''); TIdAttachmentFile.Create(MessageParts,FileName); //TIdAttachment.Create(MessageParts,ExtractFilePath(Application.ExeName)+edit5.text+'.DS'); end; if not SMTP1.Connected then begin Sleep(1000); SMTP1.Connect; end; SMTP1.Send(IdMsg); //MessageDlg('申请订舱发送成功',mtConfirmation,[mbOK],0) finally SMTP1.Disconnect; deletefile(FileName); end; //showmessage('发送完成'); frm_op_seae.SendedEmail:=True; close; except MessageDlg('邮件发送失败,可能是收件人或公司邮箱不存在,请电话联系:0532-83889257!',mtError,[mbOK],0); frm_op_seae.SendedEmail:=False; end; end; procedure Tfrm_SimplePrint.SendSOEmail(FileName: String); var str:widestring; str_file:widestring; IdHtml,IdFoot: TIdText; _i:integer; begin IdMsg.Clear; try SMTP1.AuthType := satDefault; //(satNone, satDefault, satSASL); 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; if not SMTP1.Connected then begin Sleep(1000); SMTP1.Connect; end; try with IdMsg do begin //body.Clear; IdMsg. From.address :=one_table_4.DataSource.DataSet.fieldbyname('senderEmail').asstring; // From.address :='crazymanqd@126.com'; Recipients.EMailAddresses :=one_table_4.DataSource.DataSet.fieldbyname('Email').asstring; //Subject:=MBLNO +':'+frm_Simpleprint.caption; //body.Add(Subject); Subject:='订舱:From'+one_table_4.DataSource.DataSet.fieldbyname('senderCompany').asstring +'--'+one_table_1.DataSource.DataSet.fieldbyname('开船日期').asstring +'--'+one_table_1.DataSource.DataSet.fieldbyname('集装箱').asstring +'--'+one_table_1.DataSource.DataSet.fieldbyname('目的地').asstring; IdHtml := TIdText.Create(MessageParts); IdHtml.ContentType := 'text/html'; //IdHtml.ContentTransfer := '7bit'; IdHtml.Body.Add(''); IdHtml.Body.Add(' '); //IdHtml.Body.Add(' ' + Subject + ''); IdHtml.Body.Add(' '); IdHtml.Body.Add(' '); IdHtml.Body.Add(' ' + Subject + ' (摘要)'); IdHtml.Body.Add('
'); IdHtml.Body.Add('
'); IdHtml.Body.Add('
TO:'+one_table_4.DataSource.DataSet.fieldbyname('ReceiverCompany').asstring); IdHtml.Body.Add('
FROM:'+one_table_4.DataSource.DataSet.fieldbyname('sendercompany').asstring+'/' +one_table_4.DataSource.DataSet.fieldbyname('senderName').asstring +'  电话'+one_table_4.DataSource.DataSet.fieldbyname('senderMobile').asstring +'  邮箱'+one_table_4.DataSource.DataSet.fieldbyname('senderEmail').asstring ); IdHtml.Body.Add('
'); //IdHtml.Body.Add('
提单号:'+MBLNO); IdHtml.Body.Add('
'); IdHtml.Body.Add('
开船日期:'+one_table_1.DataSource.DataSet.fieldbyname('开船日期').asstring); IdHtml.Body.Add('
起运港:'+one_table_1.DataSource.DataSet.fieldbyname('装货港').asstring); IdHtml.Body.Add('
卸货港:'+one_table_1.DataSource.DataSet.fieldbyname('卸货港').asstring); IdHtml.Body.Add('
目的地:'+one_table_1.DataSource.DataSet.fieldbyname('目的地').asstring); IdHtml.Body.Add('
箱型箱量:'+one_table_1.DataSource.DataSet.fieldbyname('集装箱').asstring); IdHtml.Body.Add('
货物描述:'+one_table_1.DataSource.DataSet.fieldbyname('货物描述').asstring); IdHtml.Body.Add('
销售订舱说明:'+one_table_1.DataSource.DataSet.fieldbyname('销售订舱说明').asstring); IdHtml.Body.Add('
ShippingBoxNO.:'+one_table_1.DataSource.DataSet.fieldbyname('订舱序列号').asstring); IdHtml.Body.Add('

**********本邮件由ShippingBox订舱平台自动发送 *************'); IdHtml.Body.Add('
本邮件仅提供当前货物部分摘要信息,详情请以双方约定为准!'); IdHtml.Body.Add('
'); IdHtml.Body.Add('
www.shippingbox.cc'); IdHtml.Body.Add('
'); IdHtml.Body.Add(''); IdFoot := TIdText.Create(MessageParts); IdFoot.ContentType := 'text/html'; //IdHtml.ContentTransfer := '7bit'; IdFoot.Body.Add(''); TIdAttachmentFile.Create(MessageParts,FileName); //TIdAttachment.Create(MessageParts,ExtractFilePath(Application.ExeName)+edit5.text+'.DS'); end; if not SMTP1.Connected then begin Sleep(1000); SMTP1.Connect; end; SMTP1.Send(IdMsg); //MessageDlg('申请订舱发送成功',mtConfirmation,[mbOK],0) finally SMTP1.Disconnect; deletefile(FileName); end; //showmessage('发送完成'); frm_op_seae.SendedEmail:=True; close; except MessageDlg('邮件发送失败,可能是收件人或公司邮箱不存在,请电话联系:0532-83889257!',mtError,[mbOK],0); frm_op_seae.SendedEmail:=False; end; end; function Tfrm_SimplePrint.GetFileName(ExtName:string):string; var DT:Tdatetime; h,m,s,ms:word; begin if MBLNO='' then begin DT:= now; DecodeTime(DT,h,m,s,ms);//分解小时,分钟,秒,毫秒。 result:=ExtractFilePath(Application.ExeName)+inttostr(h)+inttostr(m)+inttostr(s)+inttostr(ms)+ExtName; end else begin result:=MBLNO+ExtName; end; end; function Tfrm_SimplePrint.GetFileName(filename, ExtName: string): string; begin result:=filename+'_'+ExtName; end; procedure Tfrm_SimplePrint.MenuItem3Click(Sender: TObject); var template : TStream; //作为Excel附件 FileName:String; begin if t_sys_report.isempty then exit; t_sys_reportfile.Close; t_sys_reportfile.SQL.Clear; t_sys_reportfile.SQL.Add('select * from t_sys_report where CH_ID='+inttostr(t_sys_report['CH_ID'])); t_sys_reportfile.Open; if t_sys_reportfile.isempty then begin showmessage('没有打印格式,不能存为文件!'); exit; end; try try template := t_sys_reportfile.CreateBlobStream(t_sys_reportfile.FieldByName('report'), bmRead); template.Position := 0; frxReport1.LoadFromStream(template); finally template.Free; end; frxReport1.PrepareReport; frxXLSExport2.FileName:=GetFileName('.xls'); frxReport1.Export(frxXLSExport2); //SendEmail(frxXLSExport2.FileName); except showmessage('存为文件失败!'); end; end; procedure Tfrm_SimplePrint.MenuItem5Click(Sender: TObject); var template : TStream; //作为Word附件 FileName:String; begin if t_sys_report.isempty then exit; t_sys_reportfile.Close; t_sys_reportfile.SQL.Clear; t_sys_reportfile.SQL.Add('select * from t_sys_report where CH_ID='+inttostr(t_sys_report['CH_ID'])); t_sys_reportfile.Open; if t_sys_reportfile.isempty then begin showmessage('没有打印格式,不能存为文件!'); exit; end; try try template := t_sys_reportfile.CreateBlobStream(t_sys_reportfile.FieldByName('report'), bmRead); template.Position := 0; frxReport1.LoadFromStream(template); finally template.Free; end; frxReport1.PrepareReport; frxRTFExport2.FileName:=GetFileName('.doc'); frxReport1.Export(frxRTFExport2); //SendEmail(frxRTFExport2.FileName); except showmessage('存为文件失败!'); end; end; procedure Tfrm_SimplePrint.MenuItem1Click(Sender: TObject); var template : TStream; //作为Word附件 FileName:String; begin if t_sys_report.isempty then exit; t_sys_reportfile.Close; t_sys_reportfile.SQL.Clear; t_sys_reportfile.SQL.Add('select * from t_sys_report where CH_ID='+inttostr(t_sys_report['CH_ID'])); t_sys_reportfile.Open; if t_sys_reportfile.isempty then begin showmessage('没有打印格式,不能存为文件!'); exit; end; try try template := t_sys_reportfile.CreateBlobStream(t_sys_reportfile.FieldByName('report'), bmRead); template.Position := 0; frxReport1.LoadFromStream(template); finally template.Free; end; frxReport1.PrepareReport; frxJPEGExport2.FileName:=GetFileName(''); frxReport1.Export(frxJPEGExport2); //SendEmail(frxJPEGExport2.FileName+'.1.jpg'); except showmessage('存为文件失败!'); end; end; procedure Tfrm_SimplePrint.SendBLCRepeatEmail(FileName: String); var str:widestring; str_file:widestring; IdHtml,IdFoot: TIdText; _i,p1,p2:integer; newemail:string; begin IdMsg.Clear; try SMTP1.AuthType := satDefault; //(satNone, satDefault, satSASL); 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; if not SMTP1.Connected then begin Sleep(1000); SMTP1.Connect; end; try with IdMsg do begin //body.Clear; IdMsg. From.address :=one_table_4.DataSource.DataSet.fieldbyname('ReceiverEmail').asstring; p1:=Pos('<',Edit2.Text); p2:=Pos('>',Edit2.Text); if p1>-1 then begin newemail:=Copy(Edit2.Text,p1+1,p2-p1-1); end else newemail:=Edit2.Text; //Recipients.EMailAddresses :=Email; Recipients.EMailAddresses :=newemail; Subject:='提单样本:'+one_table_4.DataSource.DataSet.fieldbyname('ReceiverCompany').asstring+'--'+MBLNO +'--'+one_table_1.DataSource.DataSet.fieldbyname('开船日期').asstring +'--'+one_table_1.DataSource.DataSet.fieldbyname('集装箱').asstring +'--'+one_table_1.DataSource.DataSet.fieldbyname('目的地').asstring; IdHtml := TIdText.Create(MessageParts); IdHtml.ContentType := 'text/html'; //IdHtml.ContentTransfer := '7bit'; IdHtml.Body.Add(''); IdHtml.Body.Add(' '); //IdHtml.Body.Add(' ' + Subject + ''); IdHtml.Body.Add(' '); IdHtml.Body.Add(' '); IdHtml.Body.Add(' ' + Subject + ' (摘要)'); IdHtml.Body.Add('
'); IdHtml.Body.Add('
'); IdHtml.Body.Add('
TO:'+one_table_4.DataSource.DataSet.fieldbyname('sendercompany').asstring); IdHtml.Body.Add('
FROM:'+one_table_4.DataSource.DataSet.fieldbyname('ReceiverCompany').asstring+'/' +one_table_4.DataSource.DataSet.fieldbyname('ReceiverName').asstring +'  电话'+one_table_4.DataSource.DataSet.fieldbyname('Mobile').asstring +'  邮箱'+one_table_4.DataSource.DataSet.fieldbyname('ReceiverEmail').asstring ); IdHtml.Body.Add('
请下载本邮件附件尽快核对提单信息!'); IdHtml.Body.Add('
'); //IdHtml.Body.Add('
提单号:'+MBLNO); IdHtml.Body.Add('


船名/航次:'+one_table_1.DataSource.DataSet.fieldbyname('船名').asstring+'/'+one_table_1.DataSource.DataSet.fieldbyname('航次').asstring); IdHtml.Body.Add('
提单号:'+MBLNO); IdHtml.Body.Add('
开船日期:'+one_table_1.DataSource.DataSet.fieldbyname('开船日期').asstring); IdHtml.Body.Add('
起运港:'+one_table_1.DataSource.DataSet.fieldbyname('装货港').asstring); IdHtml.Body.Add('
卸货港:'+one_table_1.DataSource.DataSet.fieldbyname('卸货港').asstring); IdHtml.Body.Add('
目的地:'+one_table_1.DataSource.DataSet.fieldbyname('目的地').asstring); IdHtml.Body.Add('
箱型箱量:'+one_table_1.DataSource.DataSet.fieldbyname('集装箱').asstring); IdHtml.Body.Add('
件数:'+one_table_1.DataSource.DataSet.fieldbyname('件数').asstring+' '+one_table_1.DataSource.DataSet.fieldbyname('包装').asstring+'    重量:'+one_table_1.DataSource.DataSet.fieldbyname('重量').asstring+' KGS    尺码:'+one_table_1.DataSource.DataSet.fieldbyname('尺码').asstring+' CBM'); IdHtml.Body.Add('
截港时间:'+one_table_1.DataSource.DataSet.fieldbyname('截港日期').asstring); IdHtml.Body.Add('
截单时间:'+one_table_1.DataSource.DataSet.fieldbyname('截单日期').asstring); IdHtml.Body.Add('
备注:'+mmo1.Lines.Text); IdHtml.Body.Add('
ShippingBoxNO.:'+one_table_1.DataSource.DataSet.fieldbyname('订舱序列号').asstring); IdHtml.Body.Add('

**********本邮件由ShippingBox订舱平台自动发送 *************'); IdHtml.Body.Add('
本邮件仅提供当前货物部分摘要信息,详情请以双方约定为准!'); IdHtml.Body.Add('
'); IdHtml.Body.Add('
www.shippingbox.cc'); IdHtml.Body.Add('
'); IdHtml.Body.Add(''); IdFoot := TIdText.Create(MessageParts); IdFoot.ContentType := 'text/html'; //IdHtml.ContentTransfer := '7bit'; IdFoot.Body.Add(''); TIdAttachmentFile.Create(MessageParts,FileName); end; if not SMTP1.Connected then begin Sleep(1000); SMTP1.Connect; end; SMTP1.Send(IdMsg); //MessageDlg('申请订舱发送成功',mtConfirmation,[mbOK],0) finally SMTP1.Disconnect; deletefile(FileName); end; //showmessage('发送完成'); frm_op_seae.SendedEmail:=True; //发送成功后发送一个沟通消息 SendMSG(Trim(mmo1.Lines.Text)); //记录日志 Booking_add(frm_op_seae.t_op_seae, frm_op_seae.t_op_seae.fieldbyname('编号').AsString , sendername,print_head.DataSource.DataSet.fieldbyname('台头1').asstring , one_table_1.DataSource.DataSet.fieldbyname('订舱序列号').asstring , '发送 提单样本'); close; except MessageDlg('邮件发送失败,可能是收件人或公司邮箱不存在,请电话联系:0532-83889257!',mtError,[mbOK],0); frm_op_seae.SendedEmail:=False; end; end; procedure Tfrm_SimplePrint.SendMSG(msg:String); var _s,BSNO,XML:string; begin getwebservice_ds; BSNO:=frm_op_seae.t_op_seae.fieldbyname('订舱序列号').AsString; _s:=''; _s:=_s+''; _s:=_s+' '; _s:=_s+' '; _s:=_s+' '+frm_data_share.t_load_employee.fieldbyname('订舱系统序列号').asstring+' '; _s:=_s+' 沟通消息 '; _s:=_s+' '+BSNO+' '; _s:=_s+' 信息内容 '; _s:=_s+' '+msg+' '; _s:=_s+' '; _s:=_s+' '; _s:=_s+' '; if Length(msg)>0 then XML:=mServiceSoap_Ds.SendMSG(_s); if (pos('',XML)>0) then begin //此处改为保存 发送 提单样本 日志 end else begin end; end; procedure Tfrm_SimplePrint.getwebservice_ds; var URL:String; begin try URL:=get_WebseviceURL; mHttpRIO_ds:=THTTPRIO.Create(nil); mHttpRIO_ds.WSDLLocation:=URL+'?WSDL'; mHttpRIO_ds.URL:=URL; mHttpRIO_ds.Port:='DsWebServiceSoap'; mHttpRIO_ds.Service:='DsWebService'; mHttpRIO_ds.HTTPWebNode.UseUTF8InHeader:=true; InvRegistry.RegisterInvokeOptions(TypeInfo(DsWebServiceSoap),ioDocument );//就是这一行 mServiceSoap_Ds:=mHttpRIO_ds as DsWebServiceSoap; except on E:Exception do begin ShowMessage(e.Message); exit; end; end; end; end.