unit u_op_seae_invoice_sign; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, bsSkinCtrls, dxExEdtr, dxCntner, dxTL, dxDBCtrl, dxDBGrid, DB, ADODB, dxDBTLCl, dxGrClms, StdCtrls, DBCtrls, Mask, wwdblook, ComCtrls, bsSkinTabs, bsdbctrls, RxLookup, u_ch_add_do, u_ch_delete_do, wwdbdatetimepicker, Menus, XPMenu, wwdbedit, Wwdotdot, Wwdbcomb, kbmMemTable, DBCtrlsEh, ExtCtrls, cxControls, cxContainer, cxEdit, cxLabel, OleCtrls, iWebPDFEditorLib_TLB,EncdDecd,ShellAPI, bsSkinBoxCtrls, cxTextEdit, cxDBEdit; type Tfrm_op_seae_invoice_sign = class(TForm) bsknpnl1_toolbar1: TbsSkinPanel; btn3_delSign: TbsSkinButton; bsSkinButton5: TbsSkinButton; btn2_sign: TbsSkinButton; btn1_newSign: TbsSkinButton; btn4_viewSign: TbsSkinButton; bsSkinNotebook1: TbsSkinNotebook; t_ch_invoice_shen1: TDataSource; XPMenu1: TXPMenu; PopupMenu2: TPopupMenu; N10: TMenuItem; N11: TMenuItem; N14: TMenuItem; N13: TMenuItem; N12: TMenuItem; N15: TMenuItem; N16: TMenuItem; PopupMenu3: TPopupMenu; N17: TMenuItem; N18: TMenuItem; N34: TMenuItem; N35: TMenuItem; N36: TMenuItem; N1: TMenuItem; N6: TMenuItem; N4: TMenuItem; N5: TMenuItem; bsSkinButton38: TbsSkinButton; memtblprint: TkbmMemTable; memtblprint1: TDataSource; bsknpnl1: TbsSkinPanel; bsknpnl2: TbsSkinPanel; Edit1_fph0: TEdit; bsknpnl3: TbsSkinPanel; lbl1: TLabel; kbmMemTable1: TkbmMemTable; lbl2: TLabel; Edit2_fph: TEdit; bsknpnl4: TbsSkinPanel; bsknpnl8: TbsSkinPanel; shp7: TShape; shp6: TShape; shp5: TShape; shp4: TShape; bskndbtxt5_czr: TbsSkinDBText; bskndbtxtd: TbsSkinDBText; bskndbtxt6: TbsSkinDBText; lbl1_signtip: TLabel; cxlbl9: TcxLabel; cxlbl10: TcxLabel; cxlbl11: TcxLabel; cxlbl13: TcxLabel; cxlbl15: TcxLabel; bsknspltr1: TbsSkinSplitter; qry1_fpm: TADOQuery; qry2_fpd: TADOQuery; ds1_fpm: TDataSource; ds2_fpd: TDataSource; qry_ch_invoice: TADOQuery; iwbpdfdtr1: TiWebPDFEditor; btn8_confirmsign: TbsSkinButton; btn3_custprint: TbsSkinButton; bsknpgcntrl1: TbsSkinPageControl; bskntbsht1: TbsSkinTabSheet; bskntbsht2: TbsSkinTabSheet; bsknpnl5: TbsSkinPanel; btn3_searchReturn: TbsSkinButton; btn2: TbsSkinButton; bsknpnl6: TbsSkinPanel; btn4_searchNew: TbsSkinButton; edt1_khmch: TbsSkinDBEdit; lbl6: TLabel; lbl3: TLabel; lbl4: TLabel; lbl5: TLabel; Edit1_seach_fpqsbh: TEdit; Edit2_seach_khmch: TEdit; wdbdtmpckr1_seach_lu: TwwDBDateTimePicker; wdbdtmpckr2_seach_lu: TwwDBDateTimePicker; dxdbgrd3: TdxDBGrid; dxdbgrdclmn5: TdxDBGridColumn; dxdbgrdmskclmn1: TdxDBGridMaskColumn; dxdbgrdmskclmn4: TdxDBGridMaskColumn; dxdbgrdclmn6: TdxDBGridColumn; dxdbgrdmskclmn5: TdxDBGridMaskColumn; bsknpnl7: TbsSkinPanel; shp2: TShape; shp3: TShape; shp8: TShape; shp9: TShape; shp10: TShape; cxlbl1: TcxLabel; cxlbl2: TcxLabel; cxlbl3: TcxLabel; cxlbl4: TcxLabel; cxlbl5: TcxLabel; bsknpnl9: TbsSkinPanel; img2: TImage; dxdbgrd4: TdxDBGrid; dxdbgrdclmn7: TdxDBGridColumn; dxdbgrdclmn8: TdxDBGridColumn; dxdbgrdclmn9: TdxDBGridColumn; dxdbgrdclmn10: TdxDBGridColumn; dxdbgrdclmn11: TdxDBGridColumn; cxlbl6: TcxLabel; cxlbl7: TcxLabel; qry1_sear_fpm: TADOQuery; ds1_sear_fpm: TDataSource; ds2_sear_fpd: TDataSource; qry2_sear_fpd: TADOQuery; btn10_viewsign: TbsSkinButton; cxlbl18: TcxLabel; cxlbl19: TcxLabel; img1: TImage; cxlbl12: TcxLabel; btn3_clearConditon: TbsSkinButton; shp11: TShape; cxdbtxtdt1: TcxDBTextEdit; cxdbtxtdt2: TcxDBTextEdit; cxdbtxtdt3: TcxDBTextEdit; dxdbgrd2: TdxDBGrid; dxdbgrdclmn2: TdxDBGridColumn; dxdbgrdclmn1: TdxDBGridColumn; dxdbgrdclmn3: TdxDBGridColumn; dxdbgrdclmn4: TdxDBGridColumn; dxdbgrdclmndxdbgrd2Column5: TdxDBGridColumn; shp1: TShape; procedure bsSkinButton5Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); procedure btn2_signClick(Sender: TObject); procedure btn1_newSignClick(Sender: TObject); procedure bsknpnl1_toolbar1Resize(Sender: TObject); procedure bsSkinButton7Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure Edit1_fph0KeyPress(Sender: TObject; var Key: Char); procedure bsknpnl2Click(Sender: TObject); procedure FormShow(Sender: TObject); procedure iwbpdfdtr1SignFinish(Sender: TObject; const bSucceed: WideString); procedure btn8_confirmsignClick(Sender: TObject); procedure btn3_custprintClick(Sender: TObject); procedure btn4_viewSignClick(Sender: TObject); procedure bsSkinButton38Click(Sender: TObject); procedure btn4_searchNewClick(Sender: TObject); procedure btn3_searchReturnClick(Sender: TObject); procedure btn10_viewsignClick(Sender: TObject); procedure dxdbgrd3DblClick(Sender: TObject); procedure dxdbgrd4DblClick(Sender: TObject); procedure btn3_delSignClick(Sender: TObject); procedure btn3_clearConditonClick(Sender: TObject); procedure Edit2_seach_khmchKeyPress(Sender: TObject; var Key: Char); procedure qry2_fpdBeforePost(DataSet: TDataSet); procedure edt1_khmchKeyPress(Sender: TObject; var Key: Char); procedure dxdbgrd3ChangeNode(Sender: TObject; OldNode, Node: TdxTreeListNode); private { Private declarations } m_isNewSign:Boolean; m_newfilename:string; m_blhastranse:Boolean; m_op_state:string;//操作状态 m_invoceno:string;//开票申请编号 m_custname:string;//委托单位 m_custname m_dbTime:TDateTime; ch_invoice_shen_open:boolean; function check_invoiceNo(strbh:string):boolean; //检查编号 有效性 function checkinvocenoScaned(invoceno:string):Boolean; //是否扫描过 procedure displayInvoiceinfo(strfpbh:string); procedure intialNewSign(); procedure clearNouseSign(); procedure showHisSign(); //procedure bindDetail(); public { Public declarations } MblNo:string; end; var frm_op_seae_invoice_sign: Tfrm_op_seae_invoice_sign; implementation uses u_main, my_sys_function, u_ch_shen_query, u_data_share, u_op_seae_invoice_sign_detail; {$R *.dfm} /// /// 临时目录 /// function GetWinTempPath: string; var TempDir: array[0..255] of char; begin GetTempPath(255, @TempDir); Result := strPas(TempDir); 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 stringfindCount(s1,s2:string):integer ; begin result:=0; while pos(s1,s2)>0 do begin s2:=copy(s2,pos(s1,s2)+1,100); //假设s2最大长度为100个字符 result:=result+1; end; end; /// /// 按逗号位置取值 /// function GetPosString(S1:string;m:integer):String; var z:integer; begin Result:=''; if pos(',',S1)=0 then exit; for z:=1 to m-1 do begin if Pos(',',S1)=0 then exit; if Pos(',',S1)=1 then S1:=Copy(S1,Pos(',',S1)+1,(length(s1)-Pos(',',S1))) else S1:=Copy(S1,Pos(',',S1)+1,(length(s1)-Pos(',',S1))); end; if pos(',',S1)=1 then exit; if Pos(',',S1)=0 then Result:=Copy(S1,1,length(S1)-1) else Result:=Copy(S1,1,Pos(',',S1)-1); end; procedure Tfrm_op_seae_invoice_sign.bsSkinButton5Click(Sender: TObject); begin close; end; procedure Tfrm_op_seae_invoice_sign.FormClose(Sender: TObject; var Action: TCloseAction); begin ch_invoice_shen_open:=false; frm_op_seae_invoice_sign.Hide; frm_op_seae_invoice_sign.ManualFloat(frm_op_seae_invoice_sign.BoundsRect); frm_main.freeTabs('frm_op_seae_invoice_sign'); action:=cafree; frm_op_seae_invoice_sign:=nil; end; procedure Tfrm_op_seae_invoice_sign.FormCloseQuery(Sender: TObject; var CanClose: Boolean); begin if( m_blhastranse=True) then begin if( qry2_fpd.Recordset<>nil) and ( qry2_fpd.Recordset.RecordCount>0) then begin if( Application.MessageBox(PChar('此前的操作未完成,是否放弃保存?'),PChar('信息提示') ,MB_YESNO+MB_ICONQUESTION)=IDYES) then begin // qry1_fpm.Cancel; qry2_fpd.Cancel; //frm_main.db.RollbackTrans; m_blhastranse:=False; end else CanClose:=false; end; qry1_fpm.Cancel; qry2_fpd.Cancel; //frm_main.db.RollbackTrans; m_blhastranse:=False;//CanClose:=frm_close_query(qry2_fpd); end; //清理 clearNouseSign(); end; procedure Tfrm_op_seae_invoice_sign.btn2_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 // m_invoceno:='fpqz'+ aQuery.FieldByName('qdtbh').AsString; if(qry2_fpd.IsEmpty) or (qry2_fpd.Recordset.RecordCount< 1) then begin Application.MessageBox('发票记录不能为空!','信息提示',MB_ICONINFORMATION); Exit; end; strpath:= GetWinTempPath() ; oldfilename:= strpath+ 'cwsgn222.PDF' ; m_newfilename := strpath+m_invoceno+'_'+ IntToStr(Random(10))+ '.PDF' ; sys_frprintFile('发票签收单','PDF',ds1_fpm,ds2_fpd,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.intialNewSign(); var str,bsno:widestring; i:integer; aQuery:TAdoQuery; strwtdw1,strwtdw2:string; dbTime:TDateTime; sqldelete:string; begin //end check // m_blhastranse:=True; //if( m_blhastranse:=True; // frm_main.db.BeginTrans; aQuery:=CreateAdoQuery(); //先清理 sqldelete:=' delete from t_ch_invoice_sign_detail where 发票签收编号 ' +' not in (select 发票签收编号 from t_ch_invoice_sign_main);'; aQuery.SQL.Add(sqldelete); aQuery.ExecSQL(); //qdm_Query:=CreateAdoQuery(); //qdd_Query:=CreateAdoQuery(); m_custname:=''; str:= 'INSERT INTO t_sys_sign_invoice_id (mainorderno) VALUES (''开发票'');'; aQuery.SQL.Add(str) ; aQuery.ExecSQL(); aQuery.sql.Clear(); str:= 'select MAX(signid) as invoceno,GETDATE()as FDate from t_sys_sign_invoice_id; '; aQuery.sql.add(str); aQuery.OPEN; aQuery.First; m_invoceno:= aQuery.FieldByName('invoceno').AsString; m_dbTime:=aQuery.FieldByName('FDate').AsDateTime; m_op_state:='新票'; qry1_fpm.Close(); qry1_fpm.SQL.Clear; qry1_fpm.SQL.Add('SELECT * FROM [t_ch_invoice_sign_main] where 1=2'); qry1_fpm.Open; qry2_fpd.Close(); qry2_fpd.SQL.Clear; qry2_fpd.SQL.Add('SELECT * FROM [t_ch_invoice_sign_detail] where 1=2'); qry2_fpd.Open; end; procedure Tfrm_op_seae_invoice_sign.btn1_newSignClick(Sender: TObject); begin intialNewSign(); Edit1_fph0.Focused(); end; procedure Tfrm_op_seae_invoice_sign.bsknpnl1_toolbar1Resize(Sender: TObject); var i:integer; begin i:=round(bsknpnl1_toolbar1.Width/14); end; procedure Tfrm_op_seae_invoice_sign.bsSkinButton7Click(Sender: TObject); var Pnt:Tpoint; begin end; procedure Tfrm_op_seae_invoice_sign.FormCreate(Sender: TObject); begin m_blhastranse:=False; // bsSkinNotebook1.PageIndex:=0; { hen_open:=true; t_ch_invoice_shen.Close; t_ch_invoice_shen.SQL.clear; t_ch_invoice_shen.SQL.Add('select * from t_ch_invoice_shen where 申请状态 not in ('+''''+'批准开票'+'''' +','+''''+'开出发票'+''''+') and ' +open_data('1001','申请人','no','no','no','no') +'order by 申请编号 desc'); } end; /// /// 检查发票号是否重复输入 /// function Tfrm_op_seae_invoice_sign.checkinvocenoScaned(invoceno:string):Boolean; var a:OleVariant; i,j:integer; b:string; begin Result:=False; if(qry2_fpd.Recordset=nil) then Exit; qry2_fpd.Last; if (qry2_fpd.Recordset.RecordCount<1 ) then Exit; a:=Self.qry2_fpd.Recordset.GetRows(-1,1,emptyparam); if Varisarray(a) then begin for i:=0 to qry2_fpd.RecordCount-1 do begin if(a[3,i]=null) then Continue; b:=a[3,i]; if(b=invoceno) then begin result:=True; Application.MessageBox(PChar('发票号重复!'),PChar('信息提示') ,MB_ICONINFORMATION); Break; end; end; end; end; function Tfrm_op_seae_invoice_sign.check_invoiceNo(strbh:string):boolean; var strtmp,mainorder,custname0,sqlcheck:string; invocemoney:Double; aquery:TADOQuery; begin result:=false; if Length(strbh)<=3 then Exit; if Length(strbh)<=10 then Edit2_fph.Text:=strbh else if (Length(strbh)>10) and (pos(',',strbh)>0 ) and ( stringfindCount(',',strbh)>5) then begin // Edit2_fph.Text:=GetPosString(strbh,4); try invocemoney:=StrToFloat( GetPosString(strbh,5)); except on E: Exception do begin Application.MessageBox(PChar('发票格式不能识别!'),pchar('信息提示'),MB_ICONWARNING); Exit; end; end; end; //检查是否已经扫描 if (checkinvocenoScaned(Edit2_fph.Text) ) then Exit; //检查发票号系统中是否存在 aquery:=CreateAdoQuery(); sqlcheck:= 'select ' + ' (select COUNT(1) as qfcount from t_ch_invoice_sign_detail where 发票号码='''+Edit2_fph.Text+''') as fpbhcount ,' + ' v2.* from (select v.fph,chv.申请编号,chv.发票号码,chv.提单号,chv.客户名称,chv.币别,chv.合计金额 ' + ' from (select ''' +Edit2_fph.Text + ''' as fph) v left join t_ch_invoice chv on v.fph=chv.发票号码 ' + ' ) v2 '; With aquery do begin SQL.add(sqlcheck); OPen; First; if (fieldbyname('fpbhcount').AsInteger>0 ) then begin // MessageBox(self.WindowHandle,PChar('发票号'+Edit2_fph.Text+'已签发!'),pchar('信息提示'),mb_ok); Close; Exit; end; end; //如果已经签发则提示用户 if(not aquery.FieldByName('发票号码').IsNull) then begin // invocemoney := aquery.fieldbyname('合计金额').asfloat; with qry2_fpd do begin Insert; FieldByName('发票签收编号').AsString:=m_invoceno; if( aquery.fieldbyname('客户名称').IsNull) then custname0:='' else custname0:= aquery.fieldbyname('客户名称').AsString; //m_custname FieldByName('申请编号').AsString:=aquery.fieldbyname('申请编号').AsString; FieldByName('发票号码').AsString:=aquery.fieldbyname('发票号码').AsString; FieldByName('提单号').AsString:=aquery.fieldbyname('提单号').AsString; FieldByName('币别').AsString :=aquery.fieldbyname('币别').AsString; FieldByName('金额').AsString :=aquery.fieldbyname('合计金额').AsString; end; end else begin // with qry2_fpd do begin Insert; FieldByName('发票签收编号').AsString:=m_invoceno; FieldByName('申请编号').AsString:='无'; FieldByName('发票号码').AsString:=Edit2_fph.Text; FieldByName('提单号').AsString:='无'; FieldByName('币别').AsString :='RMB'; FieldByName('金额').AsFloat :=invocemoney; end; end; // qry1_fpm.Last; qry2_fpd.Last; if (qry2_fpd.FieldByName('发票号码').isnull) or (qry2_fpd.FieldByName('发票号码').AsString='') then qry2_fpd.delete; if(qry2_fpd.recordset.recordcount=1) and (qry1_fpm.Recordset.recordcount<1 ) then begin qry1_fpm.Insert; qry1_fpm.fieldbyname('发票签收编号').asstring:=m_invoceno; qry1_fpm.fieldbyname('录入人').asstring:=employee; qry1_fpm.fieldbyname('录入日期').AsDateTime:=m_dbtime; qry1_fpm.fieldbyname('客户名称').asstring:=m_custname; end; //在初始化主表 if( custname0<>'' ) then begin m_custname:=custname0; if (qry1_fpm.recordset.recordcount>0) and (qry1_fpm.fieldbyname('客户名称').IsNull or (Trim(qry1_fpm.fieldbyname('客户名称').AsString) ='')) then begin qry1_fpm.Edit; qry1_fpm.fieldbyname('客户名称').asstring:=m_custname; end; end; end; procedure Tfrm_op_seae_invoice_sign.displayInvoiceinfo(strfpbh:string); var str: string; strtmp:string; begin str:=' where 发票编号 '; str:=str+ ' in('''+ m_invoceno + ''') '; //未签字 //已签字 qry_ch_invoice.Close; qry_ch_invoice.sql.clear; qry_ch_invoice.sql.add('select * from t_ch_invoice '''+str +''' '); qry_ch_invoice.open; end; procedure Tfrm_op_seae_invoice_sign.Edit1_fph0KeyPress(Sender: TObject; var Key: Char); var strkey:string; blOk:Boolean; begin // if key=#13 then begin if( m_op_state='' ) then intialNewSign(); strkey:= Edit1_fph0.Text; Edit1_fph0.Clear(); blOk:=check_invoiceNo(strkey); if(blOk) then Exit; //已存在则 退出 //验证发票号 //m_op_state.Text:=str; //show_qdtxx(str,0); end; end; procedure Tfrm_op_seae_invoice_sign.bsknpnl2Click(Sender: TObject); begin //frm_main.db. end; procedure Tfrm_op_seae_invoice_sign.FormShow(Sender: TObject); begin intialNewSign(); bsSkinNotebook1.ActivePage :='list'; Edit1_fph0.Focused(); end; procedure Tfrm_op_seae_invoice_sign.iwbpdfdtr1SignFinish(Sender: TObject; const bSucceed: WideString); begin img1.Picture.Bitmap:= StringToBitmap(iwbpdfdtr1.GetTouchMonitorImageBASE64()); img1.Visible:=True; iwbpdfdtr1.Save(); iwbpdfdtr1.CloseRead(); m_isNewSign:=True; btn8_confirmsign.Enabled:=True; //默认是前台 lbl1_signtip.Caption:='签字完毕,请确认签字!'; img1.Visible:=true; application.MessageBox(PChar('签字完毕,请确认签字进行保存!'),'信息提示',MB_ICONINFORMATION) ; end; procedure Tfrm_op_seae_invoice_sign.btn8_confirmsignClick(Sender: TObject); var pdffile,picfile:string; remotePath:string; begin if m_newfilename='' then begin application.MessageBox(PChar('请先签名!'),'信息提示') ; exit; end; remotePath:=get_parameters_value(175,'\\223.223.95.160\data')+'\custsign'; //remotePath:='\\dev000\custsign'; //remotePath:='\\X6x8-20170109nn\测试存储文件区域'; try picfile:= copy(m_newfilename,0, length(m_newfilename) - 3)+'bmp'; img1.Picture.SaveToFile(picfile); UpLoadCustFPSignFile(m_newfilename,picfile ,remotePath,'user','user',m_invoceno); application.MessageBox(PChar('确认签字成功,签字已保存!'),'信息提示',MB_ICONINFORMATION) ; m_isNewSign:=False; intialNewSign(); Edit1_fph0.Focused(); m_blhastranse:=False; btn8_confirmsign.Enabled:=False; img1.Visible:=False; lbl1_signtip.Caption:=''; except on Ex:Exception do begin Application.MessageBox(PChar('确认签字时发生异常:'+ex.Message),PChar('信息提示'),MB_ICONINFORMATION); end; end; end; procedure Tfrm_op_seae_invoice_sign.btn3_custprintClick(Sender: TObject); begin sys_print('发票签收单',2,ds1_fpm,ds2_fpd,nil,nil,nil,nil,nil,nil,nil,nil,nil); end; procedure Tfrm_op_seae_invoice_sign.btn4_viewSignClick(Sender: TObject); begin if(m_newfilename='') or (not FileExists(m_newfilename)) then Exit; ShellExecute(Handle, nil, pchar(m_newfilename), nil, nil, SW_NORMAL); end; procedure Tfrm_op_seae_invoice_sign.bsSkinButton38Click(Sender: TObject); begin bsSkinNotebook1.ActivePage :='page1'; end; procedure Tfrm_op_seae_invoice_sign.btn4_searchNewClick(Sender: TObject); var str:string; begin str:=' where 1=1 ' ; if Edit1_seach_fpqsbh.text<>''then str:=str+' and 发票签收编号 like '+''''+'%' +Edit1_seach_fpqsbh.text+'%'+''''; if Edit2_seach_khmch.text<>''then str:=str+' and 客户名称 like '+''''+'%' + StringReplace(trim(Edit2_seach_khmch.text),'''','''''',[rfReplaceall])+'%'+''''; if wdbdtmpckr1_seach_lu.text<>''then str:=str+' and 录入日期>='+''''+wdbdtmpckr1_seach_lu.text+''''; if wdbdtmpckr2_seach_lu.text<>''then str:=str+' and 录入日期<='+''''+wdbdtmpckr2_seach_lu.text+' 23:59:59'''; str:='select * from t_ch_invoice_sign_main ' + str; qry1_sear_fpm.SQL.Add(str); qry1_sear_fpm.Open; with qry1_sear_fpm do begin close;sql.clear; sql.add(str); open;First; end; qry2_sear_fpd.Close(); qry2_sear_fpd.Open; showHisSign(); if qry1_sear_fpm.IsEmpty then begin showmessage('没有检索出要查找的记录!!'); //exit; end; bsknpgcntrl1.ActivePageIndex:=0; end; procedure Tfrm_op_seae_invoice_sign.btn3_searchReturnClick( Sender: TObject); begin bsSkinNotebook1.ActivePage :='list'; end; procedure Tfrm_op_seae_invoice_sign.btn10_viewsignClick(Sender: TObject); var tmpfile:string; begin if qry1_sear_fpm.IsEmpty then Exit; if(qry1_sear_fpm.fieldbyname('客户签字').IsNull) then Exit; try tmpfile:=qry1_sear_fpm.fieldbyname('客户签字').asstring; if(tmpfile='') or (not FileExists(tmpfile)) then Exit; ShellExecute(Handle, nil, pchar(tmpfile), nil, nil, SW_NORMAL); except showmessage('不能打开文件,请检查!'); end ; end; procedure Tfrm_op_seae_invoice_sign.dxdbgrd3DblClick(Sender: TObject); begin bsknpgcntrl1.ActivePageIndex:=1; end; procedure Tfrm_op_seae_invoice_sign.dxdbgrd4DblClick(Sender: TObject); begin bsknpgcntrl1.ActivePageIndex:=0; end; procedure Tfrm_op_seae_invoice_sign.clearNouseSign(); var aquey:TADOQuery; sqldelete:string; begin //清理 sqldelete:='delete from t_ch_invoice_sign_main where 客户签字 is null ' +' and 录入人='''+ employee +'''; ' +' delete from t_ch_invoice_sign_detail where 发票签收编号 ' +' not in (select 发票签收编号 from t_ch_invoice_sign_main);'; aquey:=CreateAdoQuery(); aquey.SQL.Add(sqldelete); aquey.ExecSQL(); // end; procedure Tfrm_op_seae_invoice_sign.btn3_delSignClick(Sender: TObject); begin if qry2_fpd.Recordset.RecordCount=1 then qry2_fpd.First; if not qry2_fpd.eof then qry2_fpd.Delete(); end; procedure Tfrm_op_seae_invoice_sign.btn3_clearConditonClick( Sender: TObject); begin Edit2_seach_khmch.text :=''; wdbdtmpckr1_seach_lu.text :=''; wdbdtmpckr2_seach_lu.text :=''; Edit1_seach_fpqsbh.text :=''; end; procedure Tfrm_op_seae_invoice_sign.Edit2_seach_khmchKeyPress( Sender: TObject; var Key: Char); begin if key=#13 then begin btn4_searchNewClick(Self.btn4_searchNew); end; end; procedure Tfrm_op_seae_invoice_sign.qry2_fpdBeforePost(DataSet: TDataSet); begin // end; procedure Tfrm_op_seae_invoice_sign.edt1_khmchKeyPress(Sender: TObject; var Key: Char); begin // if cxdbtxtdt1.Text='' then Key:= #0; end; procedure Tfrm_op_seae_invoice_sign.showHisSign() ; var tmpfile:string; begin img2.Visible:=False; if qry1_sear_fpm.IsEmpty then Exit; if(qry1_sear_fpm.fieldbyname('客户签字图片').IsNull) then Exit; try tmpfile:=qry1_sear_fpm.fieldbyname('客户签字图片').asstring; if(tmpfile='') or (not FileExists(tmpfile)) then Exit; img2.Picture.LoadFromFile(tmpfile); img2.Visible :=True; except end end; procedure Tfrm_op_seae_invoice_sign.dxdbgrd3ChangeNode(Sender: TObject; OldNode, Node: TdxTreeListNode); begin showHisSign(); end; end.