unit u_op_seae_sign_info;
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, bsSkinBoxCtrls,DateUtils, cxTextEdit, cxDBEdit,
cxMaskEdit, cxDropDownEdit, cxCalendar, cxCheckBox;
type
Tfrm_op_seae_sign_info = 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;
bsknpnl6: TbsSkinPanel;
cxlbl6: TcxLabel;
dxdbgrdclmndxdbgrd1dxdbgrdclmn1: TdxDBGridColumn;
dxdbgrdclmndxdbgrd1dxdbgrdclmn2: TdxDBGridColumn;
dxdbgrdclmndxdbgrd1dxdbgrdclmn3: TdxDBGridColumn;
dxdbgrdclmndxdbgrd1dxdbgrdclmn4: TdxDBGridColumn;
dxdbgrdclmndxdbgrd1dxdbgrdclmn5: TdxDBGridColumn;
bsknpnl3: TbsSkinPanel;
btn8: TbsSkinButton;
btn9_mailSend: TbsSkinButton;
btn5_sign: TbsSkinButton;
btn11: TbsSkinButton;
ds1_qdtm: TDataSource;
ds2_qdtd: TDataSource;
qry2_qdtd: TADOQuery;
qry1_qdtm: TADOQuery;
btn3_custprint: TbsSkinButton;
btn9_exit: TbsSkinButton;
btn3_notify: TbsSkinButton;
btn5_signout: TbsSkinButton;
img1: TImage;
cxlbl18: TcxLabel;
cxlbl19: TcxLabel;
btn8_confirmsign: TbsSkinButton;
btn10_viewsign: TbsSkinButton;
bsknpnl8: TbsSkinPanel;
shp7: TShape;
shp6: TShape;
shp5: TShape;
shp4: TShape;
shp3: TShape;
shp2: TShape;
shp1: TShape;
bskndbtxt3: TbsSkinDBText;
bskndbtxt4: TbsSkinDBText;
bskndbtxt5: TbsSkinDBText;
bskndbtxtd: TbsSkinDBText;
bskndbtxt6: TbsSkinDBText;
cxlbl9: TcxLabel;
cxlbl10: TcxLabel;
cxlbl11: TcxLabel;
cxlbl12: TcxLabel;
cxlbl13: TcxLabel;
cxlbl14: TcxLabel;
cxlbl15: TcxLabel;
iwbpdfdtr1: TiWebPDFEditor;
lbl1_signtip: TLabel;
btn2_CancelSignItem: TbsSkinButton;
dxdbgrdchckclmndxdbgrd1dxdbgrdchckclmn6: TdxDBGridCheckColumn;
pm1: TPopupMenu;
mniN1ViewCustSign: TMenuItem;
mniN2_ViewInvoceSign: TMenuItem;
kbmMemTable1: TkbmMemTable;
strngfldMemTable1Field: TStringField;
strngfldMemTable1Field3: TStringField;
strngfldMemTable1Field4: TStringField;
strngfldMemTable1Field5: TStringField;
strngfldMemTable1Field6: TStringField;
strngfldMemTable1Field7: TStringField;
strngfldMemTable1Field2: TStringField;
strngfldMemTable1Field9: TStringField;
strngfldMemTable1Field10: TStringField;
strngfldMemTable1Field11: TStringField;
strngfldMemTable1Field8: TStringField;
strngfldMemTable1Field12: TStringField;
strngfldMemTable1Field13: TStringField;
strngfldMemTable1Field15: TStringField;
strngfldMemTable1Field14: TStringField;
strngfldMemTable1Field16: TStringField;
strngfldMemTable1Field17: TStringField;
kbmMemTable1Field18: TBooleanField;
strngfldMemTable1Field19: TStringField;
kbmMemTable1RMB: TFloatField;
kbmMemTable1USD: TFloatField;
mailSend: TkbmMemTable;
strngfldSendStringField: TStringField;
strngfldSendField: TStringField;
strngfldSendField2: TStringField;
strngfldSendField3: TStringField;
strngfldSendField4: TStringField;
strngfldSendField5: TStringField;
strngfldSendField6: TStringField;
strngfldSendField7: TStringField;
btn8_confirmSignout: TbsSkinButton;
dxdbgrd1: TdxDBGrid;
shp8: TShape;
cxdbtxtdt1: TcxDBTextEdit;
cxlbl17: TcxLabel;
cxdbtxtdt2: TcxDBTextEdit;
cxlbl16_tf: TcxLabel;
cxdbchckbx1_tf: TcxDBCheckBox;
cxdbdtdt1_tf: TcxDBDateEdit;
lbl1: TLabel;
cxlbl16: TcxLabel;
cxlbl20: TcxLabel;
dxdbgrdclmndxdbgrd1Column7: TdxDBGridColumn;
cxlbl21: TcxLabel;
bskndbtxt1: TbsSkinDBText;
dxdbgrdclmndxdbgrd1Column8: TdxDBGridColumn;
dxdbgrdclmn9_usd: TdxDBGridColumn;
dxdbgrdclmn10_rmb: TdxDBGridColumn;
cxlbl22: TcxLabel;
bskndbtxt7: TbsSkinDBText;
dxdbgrd1Column11: TdxDBGridColumn;
dxdbgrd1Column12: TdxDBGridColumn;
bsSkinDBText1: TbsSkinDBText;
cxLabel1: TcxLabel;
procedure bsSkinButton2Click(Sender: TObject);
procedure btn3_sustprint(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure btn8Click(Sender: TObject);
procedure btn11Click(Sender: TObject);
procedure btn9_mailSendClick(Sender: TObject);
procedure btn9_exitClick(Sender: TObject);
procedure btn3_notifyClick(Sender: TObject);
procedure btn5_signoutClick(Sender: TObject);
procedure btn5_signClick(Sender: TObject);
procedure iwbpdfdtr1SignFinish(Sender: TObject;
const bSucceed: WideString);
procedure btn8_confirmsignClick(Sender: TObject);
procedure btn10_viewsignClick(Sender: TObject);
procedure btn2_CancelSignItemClick(Sender: TObject);
procedure btn8_confirmSignoutClick(Sender: TObject);
procedure mniN2_ViewInvoceSignClick(Sender: TObject);
procedure mniN1ViewCustSignClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormDestroy(Sender: TObject);
procedure dxdbgrd1CustomDraw(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 dxdbgrd1Column11CustomDraw(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 dxdbgrd1Column12CustomDraw(Sender: TObject; ACanvas: TCanvas;
ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxDBTreeListColumn;
const AText: String; AFont: TFont; var AColor: TColor; ASelected,
AFocused: Boolean; var ADone: Boolean);
private
{ Private declarations }
m_qdtbh:string;
m_iway:Integer;
m_newfilename:string;
m_newCWfilename:string;//财务签字
m_isNewSign:Boolean;
m_wtdw:string;//委托单位|单位名称
m_isTF_Ok:BOOL;
m_infomation:string;
m_isPJ:Boolean;//是否票结
m_reportname:string;
procedure CreateSignOcx();
function GetNotieState():Boolean;
function CheckIsAllCeckout():Boolean;
function CheckBilldue():Boolean;//检查账期
procedure signletterSateDeal(signStage:string);
function signoutSateDeal(wtdw:string):Boolean;
//
function signoutSateDeal2(wtdw:string):Boolean;
procedure show_qdtxx (qdtbh:string;iway:Integer);
procedure UpateSeaeState(bsno,billstate:string);
function GetClientLimited(sname:string):Boolean;
//临时账期
function gettmpzqdate(cust: string ):string;
public
{ Public declarations }
procedure InitialUserinfo(qdtbh:string;iway:Integer);
procedure SigninfoShow();
end;
var
frm_op_seae_sign_info: Tfrm_op_seae_sign_info;
implementation
uses my_sys_function, u_main, u_data_share;
{$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 Tfrm_op_seae_sign_info.CheckBilldue():Boolean;
var
FeeItems:string;
amt,usd:Double;
bh,wtdw,tdh,jflx:string;
bkmark:TBookmark;
aquery:TADOQuery;
str:string;
usd_this,rmb_this:Double;
strlszq:string;//临时账期
begin
Result:=True;
wtdw:=qry1_qdtm.FieldByName('客户名称').AsString;
bkmark := qry2_qdtd.GetBookMark; //对当前记录作书签标志
qry2_qdtd.DisableControls; //切断Table与数据察觉部件的联系
qry2_qdtd.First ;
//判断账期 不循环,只判断第一条
bh:= qry2_qdtd.FieldByName('编号').AsString;
tdh:=qry2_qdtd.FieldByName('主提单号').AsString;
//jflx:= qry1_qdtm.FieldByName('客户类型').asstring; //qry2_qdtd.FieldByName('结费类型').AsString;
jflx:= getzqlx(wtdw,False);
if(jflx='现结买单')then
begin
strlszq:=gettmpzqdate(wtdw);
if( strlszq<>'') then
begin
jflx:='临时账期';
end
end;
//
if (jflx='') or (jflx='无帐期') or (jflx='现结买单') then
begin
// bh没有用
if GetCrmsales(bh,wtdw,jflx,amt,usd,FeeItems) then
begin
//客户结费类型为票结
m_infomation:= m_infomation+ wtdw+'客户结费类型为票结人民币金额为:'
+FormatFloat('0.00;0.00;0',amt) +'美元金额为:'+FormatFloat('0.00;0.00;0',USD)
+'存在欠费' +#13#10 ;
Result:=False;
end ;
end
else
begin
//bh没有用
if GetCrmsales(bh,wtdw,jflx,amt,usd,FeeItems) then
begin
m_infomation:= m_infomation+ wtdw+'客户结费类型为月结人民币金额为:'
+FormatFloat('0.00;0.00;0',amt) +'美元金额为:'+FormatFloat('0.00;0.00;0',USD);
Result:=False;
//Break;
end;
end;
if(qry1_qdtm.FieldByName('签单条类型').IsNull=False) and ( qry1_qdtm.FieldByName('签单条类型').AsString='票结') then
begin
//票结欠费判断
//无论是否欠费都要提示每票货的欠费情况 ----from 张晨源 2017-08-08
aquery:=CreateAdoQuery();
str:='select sum(应收USD-已收USD ) as USD,sum(应收RMB-已收RMB) as RMB from t_op_gain '
+'where 编号 in (select 编号 from t_op_seae_sign_detail where 签单条编号=''%s'');';
with aquery do
begin
Close;
SQL.Clear;
SQL.Add(Format(str,[m_qdtbh])) ;
open();
if(not isempty) then
begin
usd_this:=fieldbyname('USD').AsFloat;
rmb_this:=fieldbyname('RMB').AsFloat;
end;
end;
if(rmb_this+ usd_this)>0 then
m_infomation:= m_infomation+'本批次业务欠费'+'美元金额为:'+FormatFloat('0.00;0.00;0',usd_this)
+ '人民币金额为:' +FormatFloat('0.00;0.00;0',rmb_this) ;
end;
qry2_qdtd.GotoBookMark(bkmark);
qry2_qdtd.EnableControls; //重新定位记录指针回到原来的位置
qry2_qdtd.FreeBookMark(bkmark); //删除书签BookMark标志
end; //end CheckBilldue
procedure Tfrm_op_seae_sign_info.InitialUserinfo(qdtbh:string;iway:Integer);
begin
m_qdtbh:=qdtbh;
m_iway:=iway;
end;
procedure Tfrm_op_seae_sign_info.SigninfoShow();
begin
//
m_infomation:='';
if not Assigned( frm_op_seae_sign_info) then
begin
frm_op_seae_sign_info:= Tfrm_op_seae_sign_info.Create(self);
end;
frm_op_seae_sign_info.ShowModal();
end;
procedure Tfrm_op_seae_sign_info.show_qdtxx (qdtbh:string;iway:Integer);
var
qdtzht,picpath:string;
cancancel:Boolean;
itmp:Integer;
begin
// CreateSignOcx();
m_isNewSign:=False;
btn5_sign.enabled:=false;
btn8_confirmsign.Enabled:=false;
btn3_notify.enabled:=false;
m_qdtbh:=qdtbh;
qry1_qdtm.Parameters.ParamByName('qdtbh').value:=qdtbh;
//初始化特殊放单为false
m_isTF_Ok:=False;
//pj 2017-08-03
m_isPJ:=False;
m_reportname:='签单条';
dxdbgrdclmn9_usd.Visible:=false;
dxdbgrdclmn9_usd.SummaryFooterType:= cstNone;
dxdbgrdclmn10_rmb.Visible:=false;
dxdbgrdclmn10_rmb.SummaryFooterType:= cstNone;
dxdbgrd1Column11.visible:=false;
dxdbgrd1Column12.visible:=false;
if (qry1_qdtm.State= dsOpening) or (qry1_qdtm.State =dsBrowse) or (qry1_qdtm.State= dsEdit) then
qry1_qdtm.Requery()
else
begin
qry1_qdtm.open;
qry1_qdtm.First;
end;
if(not qry1_qdtm.Eof) then
begin
m_wtdw:= trim(qry1_qdtm.fieldbyname('客户名称').AsString);
if (qry1_qdtm.FieldByName('签单条类型').IsNull=False)
and (qry1_qdtm.FieldByName('签单条类型').AsString='票结' ) then
begin
m_isPJ:=True;
m_reportname:='票结通知单';
dxdbgrdclmn9_usd.Visible:=True;
dxdbgrdclmn9_usd.SummaryFooterType:= cstSum;
dxdbgrdclmn10_rmb.Visible:=True;
dxdbgrdclmn10_rmb.SummaryFooterType:= cstSum;
dxdbgrd1Column11.visible:=true;
dxdbgrd1Column12.visible:=True;
end;
end;
if (m_isPJ) then begin
qry2_qdtd.SQL.text:=StringReplace(qry2_qdtd.SQL.text,'and V_op_bscard_All.会计期间<=Getdate()-7','',[]);
end;
qry2_qdtd.Parameters.ParamByName('qdtbh').value:=qdtbh;
qry2_qdtd.Parameters.ParamByName('qdtbh2').value:=qdtbh;
if (qry2_qdtd.State = dsOpening) or (qry2_qdtd.State= dsBrowse) or (qry2_qdtd.State= dsEdit) then
qry2_qdtd.Requery()
else
begin
qry2_qdtd.open;
qry2_qdtd.First;
end;
//取消签单是否可用
qdtzht:= qry1_qdtm.fieldbyname('状态').AsString;
if (qry1_qdtm.fieldbyname('作废日期').AsDateTime1) then
begin
Application.MessageBox(PChar('特批已经超过期限,请删除签单条后,重新生成签单条!'),pchar('信息提示')
,MB_ICONINFORMATION);
btn5_sign.Enabled:=False;
btn8_confirmsign.Enabled:=False;
end
else
begin
m_isTF_Ok:=true; //特殊放单ok
btn5_sign.Enabled:=true;
btn8_confirmsign.Enabled:=true;
end;
cxdbchckbx1_tf.Visible:=True;
cxlbl16_tf.Visible:=True;
cxdbdtdt1_tf.Visible:=True;
end
else if (m_isPJ) then
//不是特放的
begin
if CheckIsAllCeckout() then
begin
if(qdtzht<>'已作废') then
btn5_sign.Enabled:=True;
btn8_confirmsign.Enabled:=True;
end
else
begin
ShowMessage('票结签单条含有未签出的提单,请先签出提单!');
btn5_sign.Enabled:=False;
btn8_confirmsign.Enabled:=False;
end;
cxdbchckbx1_tf.Visible:=false;
cxlbl16_tf.Visible:=false;
cxdbdtdt1_tf.Visible:=false;
end;
end;
// 财务
if(iway=31) then
begin
//财务 客户签字不可用
btn5_sign.Enabled:=false;
btn8_confirmsign.Enabled:=False;
//
btn5_signout.Enabled :=true;
btn8_confirmSignout.Enabled:=True;
//btn5_signout
end
else
begin
//不是财务则签出不可用
btn5_signout.Enabled:=false;
btn8_confirmSignout.Enabled:=False;
end;
if(not qry1_qdtm.eof) then
begin
if m_iway=31 then
begin
picpath :=qry1_qdtm.fieldbyname('财务签字图片').AsString;
if (not qry1_qdtm.FieldByName('是否特放').IsNull) and ( qry1_qdtm.FieldByName('是否特放').AsBoolean) then
begin
itmp:= strtoint(formatdatetime('yyyyMMdd',GetDbDatetime))
-strtoint(formatdatetime('yyyyMMdd',qry1_qdtm.FieldByName('录入日期').asDatetime));
if( itmp >1) then
begin
Application.MessageBox(PChar('特批已经超过期限,请删除签单条后,重新生成签单条!'),pchar('信息提示')
,MB_ICONINFORMATION);
btn8_confirmSignout.Enabled:=False;
btn5_signout.Enabled:=False;
end
else
m_isTF_Ok:=true; //特殊放单ok
cxdbchckbx1_tf.Visible:=True;
cxlbl16_tf.Visible:=True;
cxdbdtdt1_tf.Visible:=True;
end
else
begin
cxdbchckbx1_tf.Visible:=false;
cxlbl16_tf.Visible:=false;
cxdbdtdt1_tf.Visible:=false;
end;
end
else
picpath :=qry1_qdtm.fieldbyname('客户签字图片').AsString;
if (picpath<>'') and (FileExists(picpath)) then
begin
img1.Picture.LoadFromFile(picpath);
img1.Visible:=True;
end
else
img1.Visible:=false;
end
else
begin
img1.Visible:=false
end;
lbl1_signtip.Caption:='';
if(qry2_qdtd.Recordset<>nil) then
cxlbl20.Caption:= IntToStr(qry2_qdtd.Recordset.recordcount);
end;
procedure Tfrm_op_seae_sign_info.bsSkinButton2Click(Sender: TObject);
begin
//grid_save_xls(dxdbgrid1);
///
end;
/// 设定格式
///
procedure Tfrm_op_seae_sign_info.btn3_sustprint(Sender: TObject);
begin
sys_print(m_reportname,2,ds1_qdtm,ds2_qdtd,nil,nil,nil,nil,nil,nil,nil,nil,nil);
end;
///
///
///
procedure Tfrm_op_seae_sign_info.FormShow(Sender: TObject);
begin
Width:=width-1;
m_newCWfilename:='';
show_qdtxx(m_qdtbh,m_iway);
end;
///
/// 直接打印
///
procedure Tfrm_op_seae_sign_info.btn8Click(Sender: TObject);
begin
try
sys_print(m_reportname,3,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_sign_info.btn11Click(Sender: TObject);
begin
try
sys_print(m_reportname,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_sign_info.btn9_mailSendClick(Sender: TObject);
var
//book1:Tbookmark;
aQuery:TADOQuery;
str:string;
strsjr:string;
begin
//1.验证是否有邮件方案
{
str:=' select d.*,c.客户名称 from t_code_cust_mailproject_detail d left join '
+' t_code_cust_mailproject c on (c.方案代码=d.方案代码) where 单据类型=''签单条'' and '
+ ' c.客户名称=''' + m_wtdw + '''; ';
}
str:= ' select d.*,c.客户名称 from t_code_cust_mailproject_detail d left join t_code_cust_mailproject c'
+' on (c.方案代码=d.方案代码) where 单据类型=''签单条'' and c.客户名称='''+ m_wtdw + ''' and d.方案代码 in '
+' ( SELECT distinct 客户邮件方案 from t_op_seae where 委托单位='''+ m_wtdw + ''' and isnull(客户邮件方案,'''')<>'''' and '
+ ' 主提单号 in ( select 主提单号 from t_op_seae_sign_detail where 签单条编号='''+ m_qdtbh+ ''' ) ) ; ';
strsjr:='';
aQuery:=CreateAdoQuery();
with aQuery do begin
close;sql.Clear;
SQL.Add(str);
Open;
if not IsEmpty then begin
//多条方案的邮件人
First;
while not eof do
begin
//
if strsjr='' then
strsjr := fieldbyname('收件人').AsString
else
strsjr := strsjr +',' +fieldbyname('收件人').AsString;
Next;
end;
First;
//
mailSend.EmptyTable;
mailSend.Open;
mailSend.Insert;
mailSend.FieldByName('收件人').AsString:= strsjr;//fieldbyname('收件人').AsString;
mailSend.FieldByName('邮件签名').AsString:=MailSignName;//frm_data_share.t_sys_employee.fieldbyname('邮件签名').AsString;
str:=fieldbyname('主题模板').AsString +FormatDateTime('YYYYMMDDHHMMSS',now) ;
str:=StringReplace(str,'[客户名称]',qry1_qdtm.fieldbyname('客户名称').AsString ,[]);
mailsend.fieldbyname('邮件主题').AsString :=str;
str:= fieldbyname('附件名称').AsString + qry1_qdtm.Fields.fieldbyname('签单条编号').AsString;
mailSend.FieldByName('附件名称').AsString:=str;
if fieldbyname('邮件内容').IsNull then
str:=' '
else
str:=fieldbyname('邮件内容').AsString;
mailSend.FieldByName('邮件内容').AsString:=str;
mailSend.FieldByName('单据类型').AsString:=fieldbyname('单据类型').AsString;
mailSend.FieldByName('编号').AsString:=qry1_qdtm.Fields.fieldbyname('签单条编号').AsString;
mailSend.FieldByName('主提单号').AsString:='';//t_op_letter.DataSource.DataSet.fieldbyname('主提单号').AsString;
mailSend.Post;
try
sys_print(m_reportname,5,ds1_qdtm,ds2_qdtd,nil,nil,nil,nil,nil,nil,nil,nil,nil,true,m_wtdw,nil,nil,mailSend);
//更新状态
qry1_qdtm.Edit;
qry1_qdtm.FieldByName('邮件发送日期').AsDateTime:=GetDbDatetime();
qry1_qdtm.Post;
except
qry1_qdtm.Cancel();
end;
end
else
begin
Application.MessageBox(PChar('客户"'+ m_wtdw+ '"没有[签单条]邮件配置方案,请先配置!'),PChar('信息提示'),MB_ICONINFORMATION);
end;
aQuery.Close();
end;
end;
procedure Tfrm_op_seae_sign_info.btn9_exitClick(Sender: TObject);
begin
close();
end;
///
/// 检查签出通知按钮状态是否可以使用
///
function Tfrm_op_seae_sign_info.GetNotieState():Boolean;
var
qdtzht:string;
amt:Double;
begin
//
Result:=False;
if(not qry1_qdtm.Eof) then
begin
if(m_isPJ=false) then
begin
//月结和特殊放单都不用发送(特殊放单已直接发送通知到财务)
Exit;
end;
qdtzht:= qry1_qdtm.FieldByName('状态').AsString;
if(qdtzht='生成签单条') or (qdtzht='已打印签单条') or (qdtzht='已发送签单条') then
begin
Result:=true;
end;
end;
qry2_qdtd.First;
while not qry2_qdtd.Eof do begin
amt:=amt+qry2_qdtd.fieldbyname('usd').AsFloat+qry2_qdtd.fieldbyname('rmb').AsFloat;
qry2_qdtd.Next;
end;
if (amt=0) then Result:=True;
//判断:如果全部提单已经签出 则不用提醒,允许签字
end;
function Tfrm_op_seae_sign_info.CheckIsAllCeckout():Boolean;
var
aquery:TADOQuery;
qdtbh,qdtzht,sqlstr:string;
isnoqf:BOOL;
amt:Double;
begin
Result:=False;
isnoqf:=False;
qry2_qdtd.First;
while not qry2_qdtd.Eof do begin
amt:=amt+qry2_qdtd.fieldbyname('usd').AsFloat+qry2_qdtd.fieldbyname('rmb').AsFloat;
qry2_qdtd.Next;
end;
if (amt=0) then isnoqf:=True;
if(not qry1_qdtm.Eof) then
begin
qdtzht:= qry1_qdtm.FieldByName('状态').AsString;
if(qdtzht='签出签单条') or (isnoqf) then
begin
Result:=true;
end
else if(qdtzht='生成签单条') or (qdtzht='已打印签单条') or (qdtzht='已发送签单条') or (qdtzht='财务签字') then
begin
//
aquery:=CreateAdoQuery();
aquery.Close;
aquery.SQL.Clear;
sqlstr:='select count(1) as fcount from ( select d.编号,s.业务状态 FROM [t_op_seae_sign_detail] d left join '
+'(select 编号,业务状态 from t_op_state where 业务状态=''提单签出'' ) s on d.编号=s.编号 where d.签单条编号 =:签单条编号)'
+' v where 业务状态 is null ';
aquery.SQL.Add(sqlstr);
aQuery.Parameters.ParamByName('签单条编号').Value:=m_qdtbh;
aQuery.open();
aQuery.first;
if (not aquery.Eof) and (aquery.FieldByName('fcount').AsInteger=0) then
begin
// 全部签出
aQuery.Close;
aQuery.SQL.Clear;
sqlstr:='update t_op_seae_sign_main set 状态=''签出签单条'',签出时间=getdate() where 签单条编号=''' + qdtbh +''' ';
aquery.SQL.Add(sqlstr);
aquery.ExecSQL();
Result:=True;
end;
end;
end;
//判断
end;
///
/// 通知签出
///
procedure Tfrm_op_seae_sign_info.btn3_notifyClick(Sender: TObject);
var
zht,strsql:string;
begin
//
if(GetNotieState) then
begin
zht:= qry1_qdtm.FieldByName('状态').AsString;
//
try
frm_main.db.BeginTrans;
qry1_qdtm.Edit;
qry1_qdtm.FieldByName('状态').AsString:='通知签出签单条';
qry1_qdtm.FieldByName('通知签出时间').AsDateTime:=GetDbDatetime();
strsql:='INSERT INTO [dbo].[t_op_state]([编号],[业务状态],[录入人] ,[录入日期] ) '
+'select 编号 ,''通知签出'' as 业务状态,'''+ employee +''' as 录入人 ,GETDATE() 录入日期 from'
+' (select 编号 from t_op_seae_sign_detail d where 签单条编号='''+ m_qdtbh +''''
+' and not exists (select 编号 from [t_op_state] where 业务状态=''通知签出'' and 编号= d.编号 )) v;';
frm_main.db.Execute(strsql);
frm_main.db.CommitTrans;
application.MessageBox(PChar('签单条通知已发出'),'信息提示',MB_ICONINFORMATION) ;
qry1_qdtm.Requery();
btn3_notify.Enabled:=False;
except
on E: Exception do
begin
ShowMessage(E.Message);
qry1_qdtm.Cancel;
frm_main.db.rollbacktrans;
end;
end;
end;
end;
///
/// 签字更改状态
///
procedure Tfrm_op_seae_sign_info.signletterSateDeal(signStage:string);
var
FeeItems:string;
amt,usd:Double;
tdh,bh:string;
i:Integer;
dbtime:TDateTime;
begin
qry2_qdtd.first;
While Not qry2_qdtd.EOF Do //对表中全部记录进行其他处理
begin
begin
tdh:=qry2_qdtd.FieldByName('主提单号').AsString;
bh:= qry2_qdtd.FieldByName('编号').AsString;
if (not GetStatus(bh,signStage))
then
begin
dbtime:=GetDbDatetime();
InsertSeaeStatus(bh,signStage,employee,FormatDateTime('yyyy-mm-dd hh:mm:ss',dbtime));//FormatDateTime('YYYY-MM-DD',Now));
if(signStage='提单签出') then
begin
InsertSeaeStatus(bh,'通知放单',employee,FormatDateTime('YYYY-MM-DD',dbtime));
UpateSeaeState(bh,'提单签出');
end;
end;
end;
qry2_qdtd.Next;
end;
end;
///
/// 签出更改状态 no use
///
function Tfrm_op_seae_sign_info.signoutSateDeal2(wtdw:string):Boolean;
var
FeeItems,reasons,JobAmt:string;
amt,usd:Double;
tdh:string; //主提单号
bh:string;// 编号
jflx:string;//结费类型
i:Integer;
aAdoQuery:TAdoQuery;
begin
result:=true;
reasons:='';
qry2_qdtd.first;
While Not qry2_qdtd.EOF Do //对表中全部记录进行其他处理
begin
bh :=qry2_qdtd.FieldByName('编号').AsString;
if not GetStatus(bh,'提单签出') then
begin
InsertSeaeStatus(bh,'提单签出',employee,FormatDateTime('yyyy-mm-dd hh:mm:ss',Now),reasons);
InsertSeaeStatus(bh,'通知放单',employee,FormatDateTime('YYYY-MM-DD',Now));
UpateSeaeState(bh,'提单签出');
end;
qry2_qdtd.Next;
end;
end;
///
/// 签出更改状态 no use
///
function Tfrm_op_seae_sign_info.signoutSateDeal(wtdw:string):Boolean;
var
FeeItems,reasons,JobAmt:string;
amt,usd:Double;
tdh:string; //主提单号
bh:string;// 编号
jflx:string;//结费类型
infoFY:string;
i:Integer;
aAdoQuery:TAdoQuery;
aAdoQueryFY:TAdoQuery;
rmbFY,usdFY:Double;
dbtime:TDateTime;
begin
result:=true;
qry2_qdtd.first;
jflx:= qry1_qdtm.fieldbyname('客户类型').AsString; //qry2_qdtd.FieldByName('结费类型').AsString;//取第一个
infoFY:='';
//1.有临时账期,未过期
if GetCorpNameSpecialAccount(FormatDateTime('YYYY-MM-DD',GetDbDatetime),wtdw) then
begin
//
if MessageDlg(wtdw +' 临时帐期没有过期'+#13#10+'确实要放单吗?',mtWarning,[mbyes,mbno],0)=mryes then
begin
reasons:=trim(InputBox('原因', '原因', '当天入帐'));
if reasons=''then
begin
showmessage('原因不能为空!!');
reasons:=trim(InputBox('原因', '原因', '当天入帐'));
end;
end
else
begin
result:=false;
exit;
end;
end
else
begin
//**b
//2.免签客户,"正本"参数无用
if GetCrmOP(employee,m_wtdw,'正本') then //免签客户
begin
reasons:=trim(InputBox('原因', '原因', '当天入帐'));
if reasons=''then
begin
showmessage('原因不能为空!!');
reasons:=trim(InputBox('原因', '原因', '当天入帐'));
end;
end
else
begin
aAdoQueryFY:=CreateAdoQuery();
with aAdoQueryFY do
begin
Close;Sql.Clear;
SQL.Add(' select ');
SQL.Add('SUM(CASE 类型 WHEN ''收'' THEN (case 币别 when ''USD'' then 金额-结算金额 else 0 end) ELSE 0 END ) as USD ');
SQL.Add(' , SUM(CASE t_ch_fee.类型 WHEN ''收'' THEN (case 币别 when ''RMB'' then 金额-结算金额 else 0 end) ELSE 0 END) as RMB ');
SQL.Add(' From t_ch_fee ');
SQL.Add(' where 编号 in ( ');
SQL.Add(' select 编号 From t_op_seae where 编号 in( select 编号 from t_op_seae_sign_detail where 签单条编号=''' +m_qdtbh + ''') ');
SQL.Add(' ) and 类型=''收'' and 金额<>结算金额 and (费用名称<>''佣金'') ');
Open;
rmbFY:=FieldByName('RMB').AsFloat;
usdFY:=FieldByName('USD').AsFloat;
if (rmbFY<>0) or (usdFY<>0) then
infoFY:='RMB:'+FormatFloat('0.00;-0.00;0',rmbFY)+' '+'USD:'+FormatFloat('0.00;-0.00;0',usdFY);
end;
if (jflx='') or (jflx='无帐期') or (jflx='现结买单') or (qry2_qdtd.FieldByName('结费类型').IsNull) then
begin
//bh 编号未使用
if GetCrmsales(bh,m_wtdw,jflx,amt,usd,FeeItems) then
begin
//JobAmt:=GetCrmpjAmt(bh); //改为下面的按签单条处理
JobAmt:=infoFY;
if MessageDlg('客户结费类型为票结'#13#10'本票金额为:'+JobAmt+#13#10+'超期 人民币金额为:'+FormatFloat('0.00;-0.00;0',amt) +'美元金额为:'+FormatFloat('0.00;-0.00;0',USD) +'确实要放单吗?',mtWarning,[mbyes,mbno],0)=mryes then
begin
reasons:=trim(InputBox('原因', '原因', '当天入帐'));
if reasons=''then
begin
showmessage('原因不能为空!!');
reasons:=trim(InputBox('原因', '原因', '当天入帐'));
// exit;
end;
end
else
begin
result:=false;
exit;
end;
end
else
begin
//JobAmt:=GetCrmpjAmt(bh); //改为下面的按签单条处理
JobAmt:=infoFY;
if trim(JobAmt)<>'' then
begin
if MessageDlg('客户结费类型为票结'#13#10'本票金额为:'+JobAmt +'确实要放单吗?',mtWarning,[mbyes,mbno],0)=mryes then
begin
reasons:=trim(InputBox('原因', '原因', '当天入帐'));
if reasons=''then
begin
showmessage('原因不能为空!!');
reasons:=trim(InputBox('原因', '原因', '当天入帐'));
//exit;
end;
end
else
begin
result:=false;
exit;
end;
end;
end;
end
else
if (jflx='约定时间') or (jflx='约定天数') then
begin
if GetClientLimited(wtdw) then
begin
ShowMessage('月结协议已经过期,不能放单,系统自动调整为票结,请重新确认签字!');
aAdoQuery:=CreateAdoQuery;
with aAdoQuery do
try
Close;SQL.Clear;
SQL.Add('Update t_op_seae set 结费类型=''现结买单''');
SQL.Add('where 编号 in( select 编号 from t_op_seae_sign_detail where 签单条编号='''
+m_qdtbh +''') ');
ExecSQL;
result:=false;
exit;
finally
Free;
end;
end
else
begin
if GetCrmsales(bh,m_wtdw,jflx,amt,usd,FeeItems) then
begin
if MessageDlg('客户结费类型为月结'+#13#10+'人民币金额为:'+FormatFloat('0.00;-0.00;0',amt) +'美元金额为:'+FormatFloat('0.00;-0.00;0',USD)+#13#10+#13#10+'确实要放单吗?',mtWarning,[mbyes,mbno],0)=mryes then
// if MessageDlg('客户结费类型为月结'+#13#10+'人民币金额为:'+FormatFloat('0.00;-0.00;0',amt) +'美元金额为:'+FormatFloat('0.00;-0.00;0',USD)+#13#10+FeeItems+#13#10+'确实要放单吗?',mtWarning,[mbyes,mbno],0)=mryes then
begin
reasons:=trim(InputBox('原因', '原因', '当天入帐'));
if reasons=''then
begin
showmessage('原因不能为空!!');
reasons:=trim(InputBox('原因', '原因', '当天入帐'));
// exit;
end;
end
else
begin
result:=false;
exit;
end;
end ;
end;
end;
end;
end;
dbtime:=GetDbDatetime;
qry2_qdtd.first;
While Not qry2_qdtd.EOF Do //对表中全部记录进行其他处理
begin
bh :=qry2_qdtd.FieldByName('编号').AsString;
if not GetStatus(bh,'提单签出') then
begin
InsertSeaeStatus(bh,'提单签出',employee,FormatDateTime('yyyy-mm-dd hh:mm:ss',dbtime),reasons);
InsertSeaeStatus(bh,'通知放单',employee,FormatDateTime('YYYY-MM-DD hh:mm:ss',dbtime));
UpateSeaeState(bh,'提单签出');
end;
qry2_qdtd.Next;
end;
end;
///
/// 签单条签出
///
procedure Tfrm_op_seae_sign_info.btn5_signoutClick(Sender: TObject);
var
zht,wtdw:string;
strpath:string;
oldfilename:string;
msg:Integer;
pzt:WideString;
i1:Integer;
i2:Integer;
i3:Integer;
i4:Integer;
i5:Integer;
aQuery:TADOQuery;
begin
Exit;
//改为前台处理 from 2017-08-08
{
if(m_isTF_Ok) then
begin
aQuery:=CreateAdoQuery;
try
with aQuery do begin
close;SQL.Clear;
sql.add('select 特殊放单提醒,特殊放单条件 from t_crm_client where 客户简称='''+ m_wtdw +'''');
open;
if not IsEmpty then begin
if FieldByName('特殊放单提醒').AsString='是' then begin
if MessageDlg(m_wtdw+'有特殊放单条件,特殊放单条件为:'+fieldbyname('特殊放单条件').AsString+#13#10+'确实要放单吗?',mtWarning,[mbyes,mbno],0)<>mryes then
begin
exit;
end;
end
else
if(CheckBilldue=false) then //特放无提醒时
begin
if(Application.MessageBox(pchar('当前特殊放单存在欠费'+#13#10+ m_infomation +#13#10+'是否仍要签出?'),'信息提醒'
,MB_ICONQUESTION+MB_YESNO) <> ID_YES) then
Exit;
end;
end
else
if(CheckBilldue=false) then //特放无提醒时
begin
if(Application.MessageBox(pchar('当前特殊签单存在欠费'+#13#10+ m_infomation +#13#10+'是否仍要签出?'),'信息提醒'
,MB_ICONQUESTION+MB_YESNO) <> ID_YES) then
Exit;
end;
end;
finally
FreeAndNil(aQuery);
end;
end;
}
//
m_infomation:='';
if(m_isTF_Ok=false)then //特放期内不做限制,不是特殊放单的进行后续判断
if (CheckBilldue()=False) then
begin
if(Application.MessageBox(pchar('当前签单存在欠费'+#13#10+ m_infomation +#13#10+'是否仍要签出?'),'信息提醒'
,MB_ICONQUESTION+MB_YESNO) <> ID_YES) then
Exit;
end;
lbl1_signtip.Caption:='';
strpath:= GetWinTempPath() ;
oldfilename:= strpath+ 'cwsout111.PDF' ;
m_newCWfilename := strpath+m_qdtbh+'_cwsign'+ IntToStr(Random(10))+ '.PDF' ;
sys_frprintFile(m_reportname,'PDF',ds1_qdtm,ds2_qdtd,nil,nil,nil,nil,nil,nil,nil,nil,nil,True,'',nil,nil,oldfilename);
deletefile(m_newCWfilename);
CopyFile(pchar(oldfilename), PChar(m_newCWfilename),true);
iwbpdfdtr1.LoadFromFile(m_newCWfilename);
pzt:= '598*94' ; //横向 598*94=21*28.5,4*28.5
//pzt:= '342*102' ; //纵向 12cm=342,5=142
i1:=1;
i2:=1;
i3:=0;
i4:=100;
i5:=80;
msg := iwbpdfdtr1.HandSignAtTouchMonitor(i1,i2,i3,pzt, i4, i5);
//msg := iwbpdfdtr1.HandSignAtTouchMonitorPfx(pzt,1,3,0,'120*420',50,60);
end;
procedure Tfrm_op_seae_sign_info.btn5_signClick(Sender: TObject);
var
strpath:string;
oldfilename:string;
msg:Integer;
pzt:WideString;
i1:Integer;
i2:Integer;
i3:Integer;
i4:Integer;
i5:Integer;
aQuery:TADOQuery;
begin
//
m_infomation:='';
//屏蔽前台校验
{
if(m_isTF_Ok=false)then //特放期内不做限制,不是特殊放单的进行后续判断
if (CheckBilldue()=False) then
begin
if(Application.MessageBox(pchar('当前签单存在欠费'+#13#10+ m_infomation +#13#10+'是否仍要签字?'),'信息提醒'
,MB_ICONQUESTION+MB_YESNO) <> ID_YES) then
Exit;
end;
}
//改为前台处理 from 2017-08-08
if(qry1_qdtm.FieldByName('签单条类型').isnull) or (qry1_qdtm.FieldByName('签单条类型').AsString<>'票结' ) then
begin
// 特放b
if(m_isTF_Ok) then
begin
aQuery:=CreateAdoQuery;
try
with aQuery do begin
close;SQL.Clear;
sql.add('select 特殊放单提醒,特殊放单条件 from t_crm_client where 客户简称='''+ m_wtdw +'''');
open;
if not IsEmpty then begin
if FieldByName('特殊放单提醒').AsString='是' then begin
if MessageDlg(m_wtdw+'有特殊放单条件,特殊放单条件为:'+fieldbyname('特殊放单条件').AsString+#13#10+'确实要签发吗?',mtWarning,[mbyes,mbno],0)<>mryes then
begin
exit;
end;
end
else
if(CheckBilldue=false) then //特放无提醒时
begin
if(Application.MessageBox(pchar('当前特殊放单存在欠费'+#13#10+ m_infomation +#13#10+'是否仍要签发?'),'信息提醒'
,MB_ICONQUESTION+MB_YESNO) <> ID_YES) then
Exit;
end;
end
else
if(CheckBilldue=false) then //特放无提醒时
begin
if(Application.MessageBox(pchar('当前特殊签单存在欠费'+#13#10+ m_infomation +#13#10+'是否仍要签发?'),'信息提醒'
,MB_ICONQUESTION+MB_YESNO) <> ID_YES) then
Exit;
end;
end;
finally
FreeAndNil(aQuery);
end;
end
//特放e
else
begin
//月结客户 b
if (CheckBilldue()=False) then
begin
if(Application.MessageBox(pchar('当前签单存在欠费'+#13#10+ m_infomation +#13#10+'是否仍要签出?'),'信息提醒'
,MB_ICONQUESTION+MB_YESNO) <> ID_YES) then
Exit;
end;
//月结客户 e
end;
end;
//
//
lbl1_signtip.Caption:='';
strpath:= GetWinTempPath() ;
oldfilename:= strpath+ '111.PDF' ;
m_newfilename := strpath+m_qdtbh+'_'+ IntToStr(Random(10))+ '.PDF' ;
sys_frprintFile(m_reportname,'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' ; //横向 598*94=21*28.5,4*28.5
//pzt:= '342*102' ; //纵向 12cm=342,5=142
i1:=1;
i2:=1;
i3:=0;
i4:=100;
i5:=80;
//iwbpdfdtr1.PDFRotate(90);
msg := iwbpdfdtr1.HandSignAtTouchMonitor(i1,i2,i3,pzt, i4, i5);
//msg := iwbpdfdtr1.HandSignAtTouchMonitorPfx(pzt,1,3,0,'120*420',50,80);
end;
procedure Tfrm_op_seae_sign_info.iwbpdfdtr1SignFinish(Sender: TObject;
const bSucceed: WideString);
begin
//mmo1.Text:= iwbpdfdtr1.GetTouchMonitorImageBASE64();
img1.Picture.Bitmap:= StringToBitmap(iwbpdfdtr1.GetTouchMonitorImageBASE64());
img1.Visible:=True;
iwbpdfdtr1.Save();
iwbpdfdtr1.CloseRead();
m_isNewSign:=True;
if(m_iway=31) then
begin
btn8_confirmSignout.Enabled:=True;
lbl1_signtip.Caption:='签字完毕,请确认签出!';
application.MessageBox(PChar('签字完毕,请确认签出进行保存!'),'信息提示',MB_ICONINFORMATION) ;
end
else
begin
//默认是前台
lbl1_signtip.Caption:='签字完毕,请确认签字!';
application.MessageBox(PChar('签字完毕,请确认签字进行保存!'),'信息提示',MB_ICONINFORMATION) ;
end;
end;
procedure Tfrm_op_seae_sign_info.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\测试存储文件区域';
// UpLoadCustSignFile
//
if(m_iway=31) then
begin
picfile:= copy(m_newfilename,0, length(m_newfilename) - 3)+'bmp';
end
else
begin
picfile:= copy(m_newfilename,0, length(m_newfilename) - 3)+'bmp';
end;
img1.Picture.SaveToFile(picfile);
UpLoadCustSignFile(m_newfilename,picfile ,remotePath,'user','user',m_qdtbh,m_iway);
signletterSateDeal('提单签出') ;
signletterSateDeal('提单签发');
application.MessageBox(PChar('确认签字成功,签字已保存!'),'信息提示',MB_ICONINFORMATION) ;
close();
end;
procedure Tfrm_op_seae_sign_info.btn10_viewsignClick(Sender: TObject);
var
//
//查看签字
tmpfile:string ;
begin
if m_isNewSign= True then
begin
if(m_iway=31) then
ShellExecute(Handle, nil, pchar(m_newCWfilename), nil, nil, SW_NORMAL)
else
ShellExecute(Handle, nil, pchar(m_newfilename), nil, nil, SW_NORMAL);
Exit;
end;
if qry1_qdtm.IsEmpty then exit;
try
if(m_iway=31) then
tmpfile:=qry1_qdtm.fieldbyname('财务签字').asstring
else
tmpfile:=qry1_qdtm.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_sign_info.CreateSignOcx();
begin
{
if not Assigned(iwbpdfdtr1) then
begin
iwbpdfdtr1:= TiWebPDFEditor.Create(self);
Left := 0;
Top := 134;
Width := 1080;
Height := 700;
Align := alCustom;
TabOrder := 6;
Parent := Self; // 在本窗口播放.
iwbpdfdtr1.OnSignFinish := iwbpdfdtr1SignFinish;
//iwbpdfdtr1.ControlData := 000001009F6F00005948000000000000;
end;
}
end;
procedure Tfrm_op_seae_sign_info.btn2_CancelSignItemClick(Sender: TObject);
var
i,iret:Integer;
isSelectAll :Boolean;
strxh,strinfo,strsql:string;
reasons:string;
begin
//状态是未签出的 用户没有签字的
if dxdbgrd1.SelectedCount<1 then
begin
Application.MessageBox(PChar('请选择要取消的提单!'),'信息提示',MB_ICONINFORMATION) ;
Exit;
end;
//begin check
isSelectAll:=False;
if(dxdbgrd1.Count =dxdbgrd1.SelectedCount) then
begin
strinfo:='取消全部签单签单条将会作废,是否继续?';
isSelectAll:=true;
end
else
strinfo:='有' + IntToStr(dxdbgrd1.SelectedCount) +'条提单将被取消,是否继续?' ;
iret:= application.MessageBox(pchar(strinfo),PChar('信息提示'),MB_YESNO or MB_ICONQUESTION );
if iret <> ID_YES then
Exit;
reasons:=trim(InputBox('原因', '请输入取消原因', ''));
if reasons=''then
begin
showmessage('原因不能为空!!');
exit;
end;
if( isSelectAll) then
begin
//增加取消签单日志 程建波 2017-08-04
strsql:= 'INSERT INTO [dbo].[t_op_seae_sign_cancel_log] '
+' ([签单条编号],[编号],[主提单号],[取消原因],[取消人],[取消日期]) '
+'SELECT [签单条编号],[编号],[主提单号],'''+reasons +''' as 取消原因,'''+employee+''' as 取消人, getdate() as [取消日期] '
+' FROM [t_op_seae_sign_detail] where 签单条编号='''+ m_qdtbh + ''''
+ ' delete from [t_op_state] where 业务状态=''生成签单条'' and 编号 '
+' in ( select 编号 from [t_op_seae_sign_detail] where 签单条编号='''+ m_qdtbh + ''');' +#13#10
+'delete from [t_op_seae_sign_detail] where 签单条编号='''+ m_qdtbh + ''';' +#13#10
+ 'update [t_op_seae_sign_main] set 状态=''已作废'' where 签单条编号='''+ m_qdtbh + ''';';
try
frm_main.db.BeginTrans;
frm_main.db.Execute(strsql) ;
frm_main.db.CommitTrans;
Application.MessageBox(PChar('所有签单已经取消,按"确定"关闭窗口!'),'信息提示',MB_ICONINFORMATION) ;
close();
except
on E: Exception do
begin
//
ShowMessage(E.Message);
frm_main.db.RollbackTrans;
end;
end;
end
else
begin
strxh:='''-123';
for i:=0 to dxdbgrd1.SelectedCount-1 do
begin//
qry2_qdtd.GoTobookmark(pointer(dxdbgrd1.SelectedRows[i]));
strxh := strxh +''',''' + qry2_qdtd.FieldByName('编号').AsString;
end;
strxh := strxh +'''';
try
//增加取消签单日志 程建波 2017-08-04
strsql:= 'INSERT INTO [dbo].[t_op_seae_sign_cancel_log] '
+' ([签单条编号],[编号],[主提单号],[取消原因],[取消人],[取消日期]) '
+'SELECT [签单条编号],[编号],[主提单号],'''+reasons +''' as 取消原因,'''+employee+''' as 取消人, getdate() as [取消日期] '
+' FROM [t_op_seae_sign_detail] where 签单条编号='''+ m_qdtbh + ''''
+ ' delete from [t_op_state] where 业务状态=''生成签单条'' and 编号 '
+' in ('+strxh + ');' +#13#10
+ ' delete from [t_op_state] where 业务状态=''生成签单条'' and 编号 in (' +strxh+ ');'
+' delete from [t_op_seae_sign_detail] where 编号 in ('+strxh + ');';
frm_main.db.BeginTrans;
frm_main.db.Execute(strsql) ;
frm_main.db.CommitTrans;
qry2_qdtd.Requery();
if(qry2_qdtd.Recordset<>nil) then
cxlbl20.Caption:= IntToStr(qry2_qdtd.Recordset.recordcount);
except
on E: Exception do
begin
frm_main.db.RollbackTrans;
ShowMessage(E.Message);
end;
end;
end;
end;
procedure Tfrm_op_seae_sign_info.UpateSeaeState(bsno,billstate:string);
var aAdoQuery:TAdoQuery;
begin
aAdoQuery:=CreateAdoQuery;
with aAdoQuery do
try
Close;SQL.Clear;
SQL.Add('Update t_op_Seae');
SQL.Add('set 提单签发状态=:billstate ,签回日期=:签回日期 where 编号=:bsNo');
Parameters.ParamByName('bsNo').value:=bsno;
Parameters.ParamByName('billstate').value:=billstate;
Parameters.ParamByName('签回日期').value:=GetDbDatetime();;
execsql;
finally
aAdoQuery.Free;
end;
end;
function Tfrm_op_seae_sign_info.GetClientLimited(sname:string):Boolean;
var AAdoQuery:TAdoQuery;
begin
Result:=False;
AAdoQuery:=CreateAdoQuery;
with AAdoQuery do
try
Close;SQL.Clear;
SQL.Add('Select 结束日期 from t_crm_client_sales');
SQL.Add('where 客户简称=:SName and 结费类型 in (''约定时间'',''约定天数'')');
Parameters.ParamByName('SName').Value:=SName;
Open;First;
if not IsEmpty then
begin
if FieldByName('结束日期').Value ID_YES) then
Exit;
end;
try
frm_main.db.BeginTrans;
{img1.Picture.SaveToFile(picfile);
UpLoadCustSignFile(pdffile,picfile ,remotePath,'user','user',m_qdtbh,m_iway);
}//
zht:= qry1_qdtm.FieldByName('状态').AsString;
wtdw:=qry1_qdtm.FieldByName('客户名称').AsString;
qry1_qdtm.Edit;
qry1_qdtm.FieldByName('状态').AsString:='签出签单条';
qry1_qdtm.FieldByName('签出时间').AsDateTime:=GetDbDatetime();
dbtime:=GetDbDatetime;
qry2_qdtd.first;
While Not qry2_qdtd.EOF Do //对表中全部记录进行其他处理
begin
bh :=qry2_qdtd.FieldByName('编号').AsString;
if not GetStatus(bh,'提单签出') then
begin
InsertSeaeStatus(bh,'提单签出',employee,FormatDateTime('yyyy-mm-dd hh:mm:ss',dbtime),reasons);
InsertSeaeStatus(bh,'通知放单',employee,FormatDateTime('YYYY-MM-DD hh:mm:ss',dbtime));
UpateSeaeState(bh,'提单签出');
end;
qry2_qdtd.Next;
end;
aAdoQuery:=CreateAdoQuery;
with aAdoQuery do
begin
Close;sql.Clear;
strsql:= 'UPDATE [t_op_seae_sign_main] SET 财务签字日期 = getdate(),状态=''财务签字'' WHERE [签单条编号] ='''+ m_qdtbh +''';';
SQL.Add(strsql);
strsql:= 'update t_op_seae_sign_detail set 状态=''财务签字'' where 编号 in '
+' (select 编号 from [t_op_seae_sign_detail] WHERE [签单条编号] =''' + m_qdtbh + ''');' ;
SQL.ADD(strsql);
strsql:=' INSERT INTO [t_op_state]([编号],[业务状态],[录入人],[录入日期]) '
+' select 编号,''财务签字'',''' + employee+''',getdate() '
+' from [t_op_seae_sign_detail] WHERE [签单条编号] ='''+ m_qdtbh +''';' ;
SQL.ADD(strsql);
ExecSQL();
end;
frm_main.db.CommitTrans;
application.MessageBox(PChar('签单条已签出'),'信息提示',MB_ICONINFORMATION) ;
qry1_qdtm.Close();
qry1_qdtm.Open;
qry1_qdtm.Requery();
btn5_signout.Enabled:=False;
btn8_confirmSignout.Enabled:=False;
except
on E: Exception do
begin
ShowMessage(E.Message);
qry1_qdtm.Cancel;
frm_main.db.rollbacktrans;
end;
end;
end;
// 签出签单条
procedure Tfrm_op_seae_sign_info.mniN1ViewCustSignClick(Sender: TObject);
var
tmpfile:string;
begin
if qry1_qdtm.IsEmpty then exit;
try
tmpfile:=qry1_qdtm.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_sign_info.mniN2_ViewInvoceSignClick(
Sender: TObject);
var
tmpfile:string;
begin
//
if qry1_qdtm.IsEmpty then exit;
try
tmpfile:=qry1_qdtm.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_sign_info.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
//
qry1_qdtm.Close;
qry2_qdtd.Close;
end;
procedure Tfrm_op_seae_sign_info.FormDestroy(Sender: TObject);
begin
if Self=frm_op_seae_sign_info then
frm_op_seae_sign_info:=nil;
end;
procedure Tfrm_op_seae_sign_info.dxdbgrd1CustomDraw(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 ANode.Index mod 2=0 then
AColor:= cl3DLight;
if (not qry1_qdtm.FieldByName('是否特放').IsNull) and ( qry1_qdtm.FieldByName('是否特放').AsBoolean) then
AFont.Color:=clGreen;
end;
function Tfrm_op_seae_sign_info.gettmpzqdate(cust: string ):string;
var
aQuery:TAdoQuery;
begin
result:='';
aQuery:=CreateAdoQuery;
try
with aQuery do
begin
close;sql.Clear;
sql.Add('select top 1 t.开始日期,t.结束日期 from t_crm_client_sales_tmp t ');
sql.Add(' where 客户简称='''+cust+''' and 结束日期>=cast(GETDATE() as date) order by 结束日期 desc ');
open;First;
if IsEmpty then
begin
result:='';
end
else
begin
result:= FormatDateTime('YYYY-MM-DD',FieldByName('开始日期').AsDateTime)
+ '~'+FormatDateTime('YYYY-MM-DD',FieldByName('结束日期').AsDateTime) ;
end;
end;
finally
FreeAndNil(aQuery);
end;
end;
procedure Tfrm_op_seae_sign_info.dxdbgrd1Column11CustomDraw(
Sender: TObject; ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode;
AColumn: TdxDBTreeListColumn; const AText: String; AFont: TFont;
var AColor: TColor; ASelected, AFocused: Boolean; var ADone: Boolean);
var
SS:Double;
begin
SS:=StrToFloatDef(ANode.strings[dxdbgrd1Column11.Index],0);
if (SS=0) then
AFont.Color:=clred;
end;
procedure Tfrm_op_seae_sign_info.dxdbgrd1Column12CustomDraw(
Sender: TObject; ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode;
AColumn: TdxDBTreeListColumn; const AText: String; AFont: TFont;
var AColor: TColor; ASelected, AFocused: Boolean; var ADone: Boolean);
var
SS:Double;
begin
SS:=StrToFloatDef(ANode.strings[dxdbgrd1Column12.Index],0);
if (SS=0) then
AFont.Color:=clred;
end;
end.