基线 SVN r240
SVN-Revision: r240
This commit is contained in:
@@ -0,0 +1,295 @@
|
||||
/***********************
|
||||
* 说明:PDF签名窗口
|
||||
* 创建人:姜棚
|
||||
* 创建日期:
|
||||
* 修改人:
|
||||
* 修改日期:
|
||||
* 修改备注:
|
||||
* 版本:1.0.0.0
|
||||
***********************/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using Lskj.Control;
|
||||
using Lskj.Model;
|
||||
using Lskj.Util;
|
||||
using Lskj.Business.Impl;
|
||||
using Lskj.Data;
|
||||
using System.IO;
|
||||
using Lskj.Control.Model;
|
||||
using Lskj.Business;
|
||||
|
||||
|
||||
namespace Lskj.PubPDFViewer
|
||||
{
|
||||
/// <summary>
|
||||
/// Class FrmMain.
|
||||
/// </summary>
|
||||
public partial class FrmMain : BaseForm
|
||||
{
|
||||
/// <summary>
|
||||
/// 系统参数模型
|
||||
/// </summary>
|
||||
public DynamicPdfViewerModel SysModel;
|
||||
|
||||
/// <summary>
|
||||
/// 签名来源
|
||||
/// </summary>
|
||||
private DataTable _signSources;
|
||||
|
||||
public FrmMain()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <para>说明:加载PDF窗口</para>
|
||||
/// <para>创建人:姜棚</para>
|
||||
/// <para>创建日期:2018-06-06 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
this.pdfEditorEx1.InitPdfEditor();
|
||||
this.InitializeSetting();
|
||||
this.pdfEditorEx1.OnSaveCallBack += new EventHandler(OnSaveClick);
|
||||
this.pdfEditorEx1.OnDeleteCallBack += new EventHandler(OnDeleteClick);
|
||||
this.pdfEditorEx1.OnSaveAsCallBack += new EventHandler(OnSaveAsClick);
|
||||
//附件下载成功回调
|
||||
AttachHelper.OnDownLoadSuccess += new EventHandler(AttachHelper_OnDownLoadSuccess);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Instance.WriteError(ex);
|
||||
MessageUtil.Show(ex.StackTrace);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:获取用户签名图片</para>
|
||||
/// <para>创建人:姜棚</para>
|
||||
/// <para>创建日期:2018-06-06 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
private void GetSignPic()
|
||||
{
|
||||
DataTable dt = MainImpl.Instance.GetEmployeeList(ERPInfo.Instance.UserId);
|
||||
if (dt.Rows.Count > 0)
|
||||
{
|
||||
byte[] bitMap = dt.Rows[0]["signBmp"] as byte[];
|
||||
if (bitMap.Length > 0)
|
||||
this.pdfEditorEx1.SignImage = ImageHelper.ReadImage(bitMap);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageUtil.Show(ResourceKeys.NotSignPic);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:获取模板源文件</para>
|
||||
/// <para>创建人:姜棚</para>
|
||||
/// <para>创建日期:2018-06-06 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
private void GetPdfTemplet()
|
||||
{
|
||||
DataRow rowItem = AttachImpl.Instance.GetTempletFile(this.SysModel.PdfFileId);
|
||||
if (rowItem != null)
|
||||
{
|
||||
string fileName = rowItem["sName"] + "";
|
||||
string filePath = PubUtil.FileDownLoadTempPath + fileName;
|
||||
if (fileName.Contains(".pdf"))
|
||||
{
|
||||
this._signSources = AttachImpl.Instance.GetSignSources(this.SysModel.PdfFileId);
|
||||
this.pdfEditorEx1.TempletFilePath = filePath;
|
||||
string tipMsg = string.Empty;
|
||||
if (!File.Exists(filePath))
|
||||
{
|
||||
if (AttachImpl.Instance.CheckAttachOperation(2, "", this.SysModel.PdfFileId, fileName, 0, out tipMsg) == 1)
|
||||
{
|
||||
string serverPath = Path.Combine(SystemInfo.Instance.ServerAttachPath, BaseModuleImpl.Instance.GetFileServerPath(this.SysModel.PdfFileId));
|
||||
AttachHelper.DownLoadFile(this.Handle, serverPath);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.pdfEditorEx1.InitPdfPage(this._signSources);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:初始化设置</para>
|
||||
/// <para>创建人:姜棚</para>
|
||||
/// <para>创建日期:2018-06-06 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
private void InitializeSetting()
|
||||
{
|
||||
if (this.SysModel.PdfFileId == 0) return;
|
||||
this.GetPdfTemplet();
|
||||
this.GetSignPic();
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:添加签名数据</para>
|
||||
/// <para>创建人:姜棚</para>
|
||||
/// <para>创建日期:2018-06-06 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
private void InsertSignPoint()
|
||||
{
|
||||
try
|
||||
{
|
||||
this.pdfEditorEx1.CurrentId = AttachImpl.Instance.InsertSignPoint(this.SysModel, ImageHelper.ConvertImage(this.pdfEditorEx1.SignImage), this.pdfEditorEx1.SignBoxPoint.X, this.pdfEditorEx1.SignBoxPoint.Y, this.pdfEditorEx1.CurrentPageNo);
|
||||
if (this.pdfEditorEx1.CurrentId == 0) MessageUtil.Show(ResourceKeys.SaveFault);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Instance.WriteError(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <para>说明:删除</para>
|
||||
/// <para>创建人:姜棚</para>
|
||||
/// <para>创建日期:2018-06-06 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="o">The o.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
protected void OnDeleteClick(object o, EventArgs e)
|
||||
{
|
||||
this.pdfEditorEx1.Delete();
|
||||
//如果数据库存在该条记录进行删除
|
||||
if (this.pdfEditorEx1.CurrentId > 0)
|
||||
{
|
||||
if (AttachImpl.Instance.DeleteSignPoint(this.pdfEditorEx1.CurrentId) > 0)
|
||||
{
|
||||
//删除后重新获取签名集
|
||||
this._signSources = AttachImpl.Instance.GetSignSources(this.SysModel.PdfFileId);
|
||||
this.pdfEditorEx1.InitPdfPage(this._signSources);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:窗口关闭关闭文档</para>
|
||||
/// <para>创建人:姜棚</para>
|
||||
/// <para>创建日期:2018-06-08 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="sender">The sender.</param>
|
||||
/// <param name="e">The <see cref="FormClosingEventArgs"/> instance containing the event data.</param>
|
||||
private void OnFormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
this.pdfEditorEx1.Close();
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:保存</para>
|
||||
/// <para>创建人:姜棚</para>
|
||||
/// <para>创建日期:2018-06-06 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="o">The o.</param>
|
||||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||||
protected void OnSaveClick(object o, EventArgs e)
|
||||
{
|
||||
//根据pic控件显隐判断点击保存前是否操作过
|
||||
if (this.pdfEditorEx1.PicBox.Visible)
|
||||
{
|
||||
InsertSignPoint();
|
||||
//插入后记录当前数据主键,方便清除时候用
|
||||
if (this.pdfEditorEx1.CurrentId > 0)
|
||||
{
|
||||
this.pdfEditorEx1.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:另存为</para>
|
||||
/// <para>创建人:姜棚</para>
|
||||
/// <para>创建日期:2018-06-07 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="o">The o.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
protected void OnSaveAsClick(object o, EventArgs e)
|
||||
{
|
||||
bool saveState = this.pdfEditorEx1.SaveAs();
|
||||
if (saveState)
|
||||
InsertSignPoint();
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:下载成功</para>
|
||||
/// <para>创建人:姜棚</para>
|
||||
/// <para>创建日期:2018-06-07 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
protected void AttachHelper_OnDownLoadSuccess(object sender, EventArgs e)
|
||||
{
|
||||
if (AttachHelper.IsDefWndProc(this.Handle, (System.Windows.Forms.Message)sender))
|
||||
{
|
||||
this.pdfEditorEx1.InitPdfPage(this._signSources);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:消息处理</para>
|
||||
/// <para>创建人:姜棚</para>
|
||||
/// <para>创建日期:2018-06-07 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="m">要处理的 Windows<see cref="T:System.Windows.Forms.Message" />。</param>
|
||||
protected override void DefWndProc(ref Message m)
|
||||
{
|
||||
base.DefWndProc(ref m);
|
||||
|
||||
if (this.Handle == m.HWnd)
|
||||
AttachHelper.DefWndProc(m);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user