unit u_op_seae_invoice_sign_detail; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, bsSkinCtrls, ExtCtrls, StdCtrls, dxExEdtr, DB, dxTL, dxDBCtrl, dxDBGrid, dxCntner, ADODB, bsdbctrls, cxDBLabel, cxControls, cxContainer, cxEdit, cxLabel, dxDBTLCl, dxGrClms, Mask, DBCtrlsEh, wwdblook, RxLookup, wwdbdatetimepicker, ComCtrls, bsSkinTabs, OleCtrls, iWebPDFEditorLib_TLB,EncdDecd,ShellAPI, Menus, kbmMemTable; type Tfrm_op_seae_invoice_sign_detail = class(TForm) bsknpnl5: TbsSkinPanel; dxdbgrd_mx: TdxDBGrid; dxdbgrdclmndxdbgrd2Column1: TdxDBGridColumn; dxdbgrdclmn_mxColumn3: TdxDBGridColumn; dxdbgrdclmn_mxColumn4: TdxDBGridColumn; dxdbgrdclmn_mxColumn5: TdxDBGridColumn; dxdbgrdclmn_mxColumn6: TdxDBGridColumn; dxdbgrdchckclmndxdbgrd2Column2: TdxDBGridCheckColumn; bsknpnl7: TbsSkinPanel; cxlbl1: TcxLabel; cxlbl2: TcxLabel; cxlbl3: TcxLabel; cxlbl4: TcxLabel; cxlbl5: TcxLabel; cxlbl7: TcxLabel; cxlbl8: TcxLabel; cxdblbl1: TcxDBLabel; cxdblbl2: TcxDBLabel; cxdblbl3: TcxDBLabel; cxdblbl4: TcxDBLabel; cxdblbl5: TcxDBLabel; cxdblbl6: TcxDBLabel; bsknpnl3: TbsSkinPanel; btn8: TbsSkinButton; btn5_sign: TbsSkinButton; btn11: TbsSkinButton; btn3_custprint: TbsSkinButton; btn9_exit: TbsSkinButton; btn8_confirmsign: TbsSkinButton; btn10_viewsign: TbsSkinButton; btn2_CancelSignItem: TbsSkinButton; bsknpnl8: TbsSkinPanel; shp7: TShape; shp6: TShape; shp5: TShape; shp4: TShape; shp1: TShape; bskndbtxt1: TbsSkinDBText; bskndbtxt2: TbsSkinDBText; bskndbtxt5_czr: TbsSkinDBText; bskndbtxtd: TbsSkinDBText; bskndbtxt6: TbsSkinDBText; lbl1_signtip: TLabel; cxlbl9: TcxLabel; cxlbl10: TcxLabel; cxlbl11: TcxLabel; cxlbl13: TcxLabel; cxlbl15: TcxLabel; dxdbgrd1: TdxDBGrid; dxdbgrdclmn1: TdxDBGridColumn; dxdbgrdclmn2: TdxDBGridColumn; dxdbgrdclmn3: TdxDBGridColumn; dxdbgrdclmn4: TdxDBGridColumn; dxdbgrdclmn5: TdxDBGridColumn; bsknpnl6: TbsSkinPanel; img1: TImage; cxlbl6: TcxLabel; cxlbl18: TcxLabel; cxlbl19: TcxLabel; qry1_qdtm: TADOQuery; ds1_qdtm: TDataSource; ds2_qdtd: TDataSource; qry2_qdtd: TADOQuery; iwbpdfdtr1: TiWebPDFEditor; procedure btn5_signClick(Sender: TObject); procedure btn8Click(Sender: TObject); procedure btn11Click(Sender: TObject); procedure btn3_custprintClick(Sender: TObject); procedure btn8_confirmsignClick(Sender: TObject); procedure iwbpdfdtr1SignFinish(Sender: TObject; const bSucceed: WideString); procedure FormShow(Sender: TObject); private { Private declarations } m_newfilename:string; m_qry_qdm,m_qry_qdd:TADOQuery; m_isNewSign:Boolean; m_fpqz:string; public { Public declarations } procedure SetSignDatasource(qrym:TADOQuery;qryd:TADOQuery); end; var frm_op_seae_invoice_sign_detail: Tfrm_op_seae_invoice_sign_detail; implementation uses my_sys_function; {$R *.dfm} procedure Tfrm_op_seae_invoice_sign_detail.SetSignDatasource(qrym:TADOQuery;qryd:TADOQuery); begin // // qry1_qdtm:= qrym; // qry2_qdtd:=qryd; m_qry_qdm:=qrym; m_qry_qdd:=qryd; ds1_qdtm.DataSet:=m_qry_qdm; ds2_qdtd.DataSet:=m_qry_qdd; end; ///将Bitmap位图转化为base64字符串 function BitmapToString(img:TBitmap):string ; var ms:TMemoryStream; ss:TStringStream; s:string; begin ms := TMemoryStream.Create; img.SaveToStream(ms); ss := TStringStream.Create(''); ms.Position:=0; EncodeStream(ms,ss);//将内存流编码为base64字符流 s:=ss.DataString; ms.Free; ss.Free; result:=s; end; function StringToBitmap(imgStr:string):TBitmap; var ss:TStringStream; ms:TMemoryStream; bitmap:TBitmap; begin ss := TStringStream.Create(imgStr); ms := TMemoryStream.Create; DecodeStream(ss,ms);//将base64字符流还原为内存流 ms.Position:=0; bitmap := TBitmap.Create; bitmap.LoadFromStream(ms); ss.Free; ms.Free; result :=bitmap; end; function GetWinTempPath: string; var TempDir: array[0..255] of char; begin GetTempPath(255, @TempDir); Result := strPas(TempDir); end; procedure Tfrm_op_seae_invoice_sign_detail.btn5_signClick(Sender: TObject); var strpath:string; oldfilename:string; msg:Integer; pzt:WideString; i1:Integer; i2:Integer; i3:Integer; i4:Integer; i5:Integer; str :string; aQuery:TADOQuery; begin // str:= 'INSERT INTO t_sys_signid (mainorderno) VALUES (''222'');'; aQuery.SQL.Add(str) ; aQuery.ExecSQL(); aQuery.sql.Clear(); str:= 'select MAX(signid) as qdtbh,GETDATE()as FDate from t_sys_signid; '; aQuery.sql.add(str); str:= 'select MAX(signid) as qdtbh,GETDATE()as FDate from t_sys_signid; '; aQuery.sql.add(str); aQuery.Open; aQuery.First; m_fpqz:='fpqz'+ aQuery.FieldByName('qdtbh').AsString; strpath:= GetWinTempPath() ; oldfilename:= strpath+ 'cwsgn222.PDF' ; m_newfilename := strpath+m_fpqz+'_'+ IntToStr(Random(10))+ '.PDF' ; sys_frprintFile('发票签发','PDF',ds1_qdtm,ds2_qdtd,nil,nil,nil,nil,nil,nil,nil,nil,nil,True,'',nil,nil,oldfilename); deletefile(m_newfilename); CopyFile(pchar(oldfilename), PChar(m_newfilename),true); iwbpdfdtr1.LoadFromFile(m_newfilename); pzt:= '598*94' ; i1:=1; i2:=1; i3:=0; i4:=50; i5:=30; msg := iwbpdfdtr1.HandSignAtTouchMonitor(i1,i2,i3,pzt, i4, i5); end; procedure Tfrm_op_seae_invoice_sign_detail.btn8Click(Sender: TObject); begin try sys_print('发票签发',1,ds1_qdtm,ds2_qdtd,nil,nil,nil,nil,nil,nil,nil,nil,nil); //qry1_qdtm.Edit; //qry1_qdtm.FieldByName('打印日期').AsDateTime:=GetDbDatetime(); //qry1_qdtm.Post; except //qry1_qdtm.Cancel; end; end; procedure Tfrm_op_seae_invoice_sign_detail.btn11Click(Sender: TObject); begin sys_print('发票签发',3,ds1_qdtm,ds2_qdtd,nil,nil,nil,nil,nil,nil,nil,nil,nil); end; procedure Tfrm_op_seae_invoice_sign_detail.btn3_custprintClick( Sender: TObject); begin sys_print('发票签发',2,ds1_qdtm,ds2_qdtd,nil,nil,nil,nil,nil,nil,nil,nil,nil); end; procedure Tfrm_op_seae_invoice_sign_detail.btn8_confirmsignClick( Sender: TObject); var picfile:string; remotePath:string; begin if m_newfilename='' then begin application.MessageBox(PChar('请先签字!'),'信息提示') ; exit; end; remotePath:='\\223.223.95.160\data\custsign'; //remotePath:='\\dev000\custsign\invsgn'; //remotePath:='\\X6x8-20170109nn\测试存储文件区域'; //signletterSateDeal(); // picfile:= copy(m_newfilename,0, length(m_newfilename) - 3)+'bmp'; img1.Picture.SaveToFile(picfile); UpLoadCustFPSignFile(m_newfilename,picfile ,remotePath,'user','user',m_fpqz); application.MessageBox(PChar('确认签字成功,签字已保存!'),'信息提示',MB_ICONINFORMATION) ; close(); // 根据 申请编号更新记录 end; procedure Tfrm_op_seae_invoice_sign_detail.iwbpdfdtr1SignFinish( Sender: TObject; const bSucceed: WideString); begin img1.Picture.Bitmap:= StringToBitmap(iwbpdfdtr1.GetTouchMonitorImageBASE64()); img1.Visible:=True; iwbpdfdtr1.CloseRead(); m_isNewSign:=True; lbl1_signtip.Caption:='签字完毕,请确认签字!'; application.MessageBox(PChar('签字完毕,请确认签字进行保存!'),'信息提示',MB_ICONINFORMATION) ; end; procedure Tfrm_op_seae_invoice_sign_detail.FormShow(Sender: TObject); begin // end; end.