ab56a9bcf7
SVN-Revision: r240
1562 lines
58 KiB
C#
1562 lines
58 KiB
C#
/***********************
|
|
* 说明:附件
|
|
* 创建人:龚宇超
|
|
* 创建日期:2018-02-08
|
|
* 修改人:
|
|
* 修改日期:
|
|
* 修改备注:
|
|
* 版本: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.Model;
|
|
using Lskj.Control;
|
|
using Lskj.Util;
|
|
using Lskj.Business.Impl;
|
|
using Lskj.Model;
|
|
using Lskj.Data;
|
|
using Lskj.FileManager.Properties;
|
|
using DevExpress.XtraTab;
|
|
using DevExpress.XtraEditors;
|
|
using DevExpress.XtraRichEdit;
|
|
using DevExpress.XtraPdfViewer;
|
|
using DevExpress.XtraSpreadsheet;
|
|
using DevExpress.Spreadsheet;
|
|
using System.IO;
|
|
using System.Threading;
|
|
using Lskj.Business;
|
|
using System.Text.RegularExpressions;
|
|
using System.Diagnostics;
|
|
using Lskj.Core;
|
|
|
|
namespace Lskj.FileManager
|
|
{
|
|
/// <summary>
|
|
/// Class FrmMain.
|
|
/// </summary>
|
|
public partial class FrmMain : BaseForm
|
|
{
|
|
#region 公有变量
|
|
/// <summary>
|
|
/// 传入参数
|
|
/// </summary>
|
|
public DynamicFileManagerModel SysModelObj;
|
|
/// <summary>
|
|
/// 基础档案模块对象
|
|
/// </summary>
|
|
public ModuleModel ModuleModelObj;
|
|
/// <summary>
|
|
/// 查询条件控件
|
|
/// </summary>
|
|
public MyControl SearchObj;
|
|
/// <summary>
|
|
/// 附件模块
|
|
/// </summary>
|
|
public ModuleModel AttachModelObj;
|
|
/// <summary>
|
|
/// 画框鼠标
|
|
/// </summary>
|
|
public Rectangle MouseRect = Rectangle.Empty;
|
|
#endregion
|
|
|
|
#region 私有变量
|
|
/// <summary>
|
|
/// 附件目录ID
|
|
/// </summary>
|
|
private int _directoryId;
|
|
/// <summary>
|
|
///y坐标
|
|
/// </summary>
|
|
private int _locationY = 0;
|
|
/// <summary>
|
|
/// 一排摆放个数
|
|
/// </summary>
|
|
private int _number = 0;
|
|
/// <summary>
|
|
/// 换行
|
|
/// </summary>
|
|
private int _newLine = 0;
|
|
/// <summary>
|
|
/// 附件固定模块(用于提取表格列、表格颜色、右键菜单、查询条件)
|
|
/// </summary>
|
|
private string _attachMenuCode = "2005_1";
|
|
/// <summary>
|
|
/// 当前结点
|
|
/// </summary>
|
|
private string _speciNo = string.Empty;
|
|
/// <summary>
|
|
/// 可关联图片类型
|
|
/// </summary>
|
|
private string[] _imageExt = { ".bmp", ".dib", ".rle", ".emf", ".gif", ".jpg", ".jpeg", ".jpe", ".jif", ".pcx", ".dcx", ".pic", ".png", ".tga", ".tif", ".tiffxif", ".wmf", ".jfif " };
|
|
/// <summary>
|
|
/// 画框起始点
|
|
/// </summary>
|
|
private Point _pointStart;
|
|
/// <summary>
|
|
/// 画框结束点
|
|
/// </summary>
|
|
private Point _pointEnd;
|
|
/// <summary>
|
|
/// 储存选中附件集合
|
|
/// </summary>
|
|
private List<AttachControlEx> _attachSelectList { get { return this.pl_main.Controls.Cast<AttachControlEx>().Where(o => o.Selected).ToList(); } }
|
|
/// <summary>
|
|
/// 储存附件集合
|
|
/// </summary>
|
|
private List<AttachControlEx> _attachList = new List<AttachControlEx>();
|
|
/// <summary>
|
|
/// 后退历史
|
|
/// </summary>
|
|
private List<string> _backHistory = new List<string>();
|
|
/// <summary>
|
|
/// 当前预览文件
|
|
/// </summary>
|
|
private string _currentFilePath = string.Empty;
|
|
/// <summary>
|
|
/// 当前附件编号
|
|
/// </summary>
|
|
private int _currentFileNo = 0;
|
|
#endregion
|
|
|
|
public FrmMain()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
//加载
|
|
protected override void OnLoad(EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
WaitForm.ShowForm();
|
|
DataRow menuRow = MainImpl.GetSystemdllTab(this._attachMenuCode);
|
|
if (menuRow == null)
|
|
{
|
|
MessageUtil.Show(string.Format(ResourceKeys.NotFoundMenu, this.SysModelObj.ModuleCode));
|
|
return;
|
|
}
|
|
this.ModuleModelObj = new ModuleModel(MainImpl.GetSystemdllTab(SysModelObj.ModuleCode));
|
|
this.AttachModelObj = new ModuleModel(menuRow);
|
|
if (string.IsNullOrEmpty(this.SysModelObj.SpeciesValue)) this.SysModelObj.SpeciesValue = this.ModuleModelObj.MenuBmpSpec;
|
|
this.SetLeftTreeView();
|
|
this._directoryId = AttachImpl.GetAttachDirectoryId(this.SysModelObj.DirId, this.SysModelObj.ParmaryValue);
|
|
this.AttachModelObj.MenuSql = ReplaceHelper.ReplaceParam(this.AttachModelObj.MenuSql) + " and parentId=" + this._directoryId;
|
|
InitFilesControl(BaseImpl.GetDataTableResult(this.AttachModelObj.MenuSql));
|
|
this.tabBottomDetail.InitTabPages(GetBottomDetailGrid());
|
|
this.SetSearchCond();
|
|
this.SetAttachEvent();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
LogHelper.Instance.WriteError(ex);
|
|
}
|
|
finally
|
|
{
|
|
Lskj.Control.Model.AutoSizeChange.ControllInitializeSize(this);
|
|
WaitForm.HideForm();
|
|
}
|
|
}
|
|
|
|
|
|
#region 设置左边的树
|
|
/// <summary>
|
|
/// <para>说明:设置左边树</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-09 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>ContextMenuStrip.</returns>
|
|
private void SetLeftTreeView()
|
|
{
|
|
try
|
|
{
|
|
this.tvLeft.TreeNodeKeyField = "SpeciesNo";
|
|
this.tvLeft.TreeNodeTextField = "SpeciesName";
|
|
this.tvLeft.BindTreeView(AttachImpl.GetAttachSpecies(this.SysModelObj.SpeciesValue));
|
|
this.tvLeft.TreeView.AfterSelect += new TreeViewEventHandler(SelectedNodeChanged);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 左边树点击后
|
|
/// <summary>
|
|
/// <para>说明:左侧树结构点击后</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-08 </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="TreeViewEventArgs"/> instance containing the event data.</param>
|
|
protected void SelectedNodeChanged(object sender, TreeViewEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
string where = string.Format(" and {0}= '{1}' ", this.tvLeft.TreeNodeKeyField, e.Node.Name);
|
|
this.SysModelObj.SpeciesValue = this._speciNo = e.Node.Name;
|
|
//判断是否为最底层节点
|
|
if (this.tvLeft.TreeView.SelectedNode.Nodes.Count <= 0) this.btnGoForward.Enabled = false;
|
|
//加载附件
|
|
InitFilesControl(BaseImpl.GetDataTableResult(this.AttachModelObj.MenuSql + where));
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 设置顶部查询条件
|
|
/// <summary>
|
|
/// <para>说明:设置顶部查询条件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-08 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void SetSearchCond()
|
|
{
|
|
try
|
|
{
|
|
this.SearchObj = new MyControl(this.AttachModelObj.MenuSql, null);
|
|
DataTable queryTable = BaseModuleImpl.GetCustomQueryFields(this.AttachModelObj.CondKey);
|
|
this.SearchObj.ModuleId = SysModelObj.ModuleId;
|
|
this.SearchObj.RememberRow = true;
|
|
this.SearchObj.ParentUnionField = this.SearchObj.ParentKeyField = this.tvLeft.TreeNodeKeyField;
|
|
|
|
if (queryTable.Rows.Count > 0)
|
|
{
|
|
// 加载自定义查询条件
|
|
this.pl_top_search.Controls.Clear();
|
|
this.SearchObj.OtherParams = SysModelObj.OtherParams();
|
|
this.SearchObj.OnSearchBeforeCallBack += new SearchEventHandler(CustomSearch_Click);
|
|
this.pl_top.Height = this.SearchObj.InitSearchControl(queryTable, this.pl_top_search, null);
|
|
}
|
|
else
|
|
{
|
|
// 加载固定查询条件
|
|
DataTable table = BaseModuleImpl.GetFixedQueryFields(this._attachMenuCode);
|
|
this.cbField.DisplayMember = "fieldText";
|
|
this.cbField.ValueMember = "fieldName";
|
|
this.cbField.DataSource = table;
|
|
this.SearchObj.InitDefaultSearchControl(table, this.pl_top_search);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 获取固定菜单
|
|
/// <summary>
|
|
/// <para>说明:获取固定菜单</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-08 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private ContextMenuStrip GetMenus()
|
|
{
|
|
ContextMenuStrip menu = new ContextMenuStrip();
|
|
ToolStripMenuItem tsmDownLoad = new ToolStripMenuItem("下载附件", null, tsmDownLoad_Click);
|
|
ToolStripMenuItem tsmLock = new ToolStripMenuItem("锁定附件", null, tsmLock_Click);
|
|
ToolStripMenuItem tmsUnlock = new ToolStripMenuItem("附件解锁", null, tmsUnlock_Click);
|
|
ToolStripMenuItem tsmDelete = new ToolStripMenuItem("删除附件", null, tmsDelete_Click);
|
|
ToolStripMenuItem tsmView = new ToolStripMenuItem("附件预览", null, tmsView_Click);
|
|
ToolStripMenuItem tsmUnion = new ToolStripMenuItem("关联附件", null, tmsUnion_Click);
|
|
UpLoad.Enabled = tsmDownLoad.Enabled = tsmLock.Enabled = tsmDelete.Enabled = tmsUnlock.Enabled = !this.SysModelObj.IsView;
|
|
tsmUnion.Visible = this.SysModelObj.IsUnionImage;
|
|
menu.Items.AddRange(new ToolStripMenuItem[] { tsmUnion, tsmView, tsmDelete, tmsUnlock, tsmLock, tsmDownLoad });
|
|
return menu;
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// <para>说明:关联附件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-08 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void tmsUnion_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (this._attachList.Count == 0)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.NotSelectedFile);
|
|
return;
|
|
}
|
|
string fileName = this._attachList[0].FileName;
|
|
if (!string.IsNullOrEmpty(fileName))
|
|
{
|
|
if (_imageExt.Contains(Path.GetExtension(fileName)))
|
|
{
|
|
int result = AttachImpl.UpdateUnionAttach(this.ModuleModelObj.MenuTable, this.SysModelObj.UnionColName, fileName, this.ModuleModelObj.ParmaryKey, this.SysModelObj.ParmaryValue);
|
|
MessageUtil.Show(result > 0 ? ResourceKeys.OperSuccess : ResourceKeys.OperFault);
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show(ResourceKeys.UnionFileExt);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
}
|
|
|
|
#region 下载附件
|
|
/// <summary>
|
|
/// <para>说明:下载附件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-08 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void tsmDownLoad_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (this._attachSelectList.Count == 0)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.NotSelectedFile);
|
|
return;
|
|
}
|
|
string fileIds = string.Empty;
|
|
foreach (AttachControlEx attach in this._attachSelectList)
|
|
{
|
|
fileIds += attach.FileNo + ",";
|
|
}
|
|
// 调用附件下载(lstest.exe包含了下载权限验证)
|
|
AttachHelper.DownLoadFile(this.Handle, fileIds.Trim(','), this._directoryId + "");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 上传附件
|
|
/// <summary>
|
|
/// <para>说明:上传附件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-23 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void btnUpload_Click(object seneder, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
TreeNode treeNode = this.tvLeft.TreeView.SelectedNode;
|
|
if (treeNode == null)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.UnableSelectedNode);
|
|
return;
|
|
}
|
|
if (treeNode.Nodes.Count > 0)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.UnableSelectedLastNode);
|
|
return;
|
|
}
|
|
string spesiesNo = treeNode.Name;
|
|
string fileNum = "001";
|
|
AttachHelper.UpLoadFile(this.Handle, this._directoryId + "", spesiesNo, fileNum);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 锁定附件
|
|
/// <summary>
|
|
/// <para>说明:锁定附件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-24</para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void tsmLock_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (this._attachSelectList.Count == 0)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.NotSelectLockFile);
|
|
}
|
|
else
|
|
{
|
|
// 检查权限
|
|
string tipMsg = string.Empty;
|
|
if (AttachImpl.CheckAttachOperation(4, "", Convert.ToInt32(this._attachSelectList[0].FileNo), "", 0, out tipMsg) == 1)
|
|
{
|
|
string fileIds = string.Empty;
|
|
foreach (AttachControlEx attach in this._attachSelectList)
|
|
{
|
|
fileIds += attach.FileNo + ",";
|
|
}
|
|
DataTable dtFiles = AttachImpl.GetMatchConditionFiles(fileIds);
|
|
if (dtFiles.Rows.Count < 0)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.NotFindMatchFile);
|
|
return;
|
|
}
|
|
if (dtFiles.Rows.Count == AttachImpl.GetLockDataCount(dtFiles, "1"))
|
|
{
|
|
MessageUtil.Show(string.Format(ResourceKeys.FileDataLockSuccess, dtFiles.Rows.Count));
|
|
setAttachLock(_attachSelectList);
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show(ResourceKeys.FileLockFail);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show(ResourceKeys.NotAuthorization);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 设置附件锁状态
|
|
/// <summary>
|
|
/// <para>说明:设置附件锁状态</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-24 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void setAttachLock(List<AttachControlEx> list)
|
|
{
|
|
try
|
|
{
|
|
foreach (AttachControlEx attach in list)
|
|
{
|
|
attach.Locked = true;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 解锁附件
|
|
/// <summary>
|
|
/// <para>说明:解锁附件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-26 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void tmsUnlock_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (this._attachSelectList.Count == 0)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.NotSelectUnLockFile);
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
string tipMsg = string.Empty;
|
|
if (AttachImpl.CheckAttachOperation(5, "", Convert.ToInt32(this._attachSelectList[0].FileNo), "", 0, out tipMsg) == 1)
|
|
{
|
|
string fileIds = string.Empty;
|
|
foreach (AttachControlEx attach in this._attachSelectList)
|
|
{
|
|
fileIds += attach.FileNo + ",";
|
|
}
|
|
DataTable dtFiles = AttachImpl.GetMatchConditionFiles(fileIds);
|
|
if (dtFiles.Rows.Count < 0)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.NotFindMatchFile);
|
|
return;
|
|
}
|
|
if (dtFiles.Rows.Count == AttachImpl.GetLockDataCount(dtFiles, "0"))
|
|
{
|
|
MessageUtil.Show(string.Format(ResourceKeys.FileDataUnLockSuccess, dtFiles.Rows.Count));
|
|
setAttachUnLock(_attachSelectList);
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show(ResourceKeys.FileUnLockFail);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show(ResourceKeys.NotAuthorization);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 设置解锁状态
|
|
/// <summary>
|
|
/// <para>说明:设置解锁状态</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-26 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void setAttachUnLock(List<AttachControlEx> list)
|
|
{
|
|
foreach (AttachControlEx attach in list)
|
|
{
|
|
attach.Locked = false;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 删除附件
|
|
/// <summary>
|
|
/// <para>说明:删除附件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-08 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void tmsDelete_Click(object sender, EventArgs e)
|
|
{
|
|
//数据删除处理
|
|
if (_attachSelectList.Count == 0)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.NotFindDeleteFile);
|
|
return;
|
|
}
|
|
if (MessageUtil.Show(ResourceKeys.DeleteFileTip, MessageBoxButtons.YesNo) != DialogResult.Yes)
|
|
{
|
|
return;
|
|
}
|
|
try
|
|
{
|
|
string errorMsg = string.Empty;
|
|
string fileIds = string.Empty;
|
|
foreach (AttachControlEx attach in this._attachSelectList)
|
|
{
|
|
string tipMsg = string.Empty;
|
|
if (AttachImpl.CheckAttachOperation(3, "", Convert.ToInt32(attach.FileNo), "", 0, out tipMsg) == 1)
|
|
{
|
|
fileIds += attach.FileNo + ",";
|
|
this._attachList.Remove(attach);
|
|
}
|
|
else
|
|
{
|
|
errorMsg += "[" + attach.FileName + "]\r\n";
|
|
}
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(errorMsg))
|
|
{
|
|
MessageUtil.Show(string.Format(ResourceKeys.NotDeleteFilesTip, errorMsg));
|
|
return;
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(fileIds))
|
|
{
|
|
// 调用附件删除
|
|
AttachHelper.DeleteFile(this.Handle, fileIds.Trim(','));
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 获取附件
|
|
/// <summary>
|
|
/// <para>说明:获取附件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-08 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="dt">数据来源.</param>
|
|
private void InitFilesControl(DataTable dt)
|
|
{
|
|
try {
|
|
this._attachList.Clear();
|
|
this.ClearFilePanel();
|
|
if (dt.Rows.Count > 0)
|
|
{
|
|
#region 文件生成
|
|
//文件处理
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
{
|
|
string filename = dt.Rows[i]["sName"] + "";
|
|
AttachControlEx file = new AttachControlEx();
|
|
file.FileNo = Convert.ToInt32(dt.Rows[i]["fileId"]);
|
|
file.OnClickEvent += new EventHandler(GetFileDetailEvent);
|
|
file.ClearAllSelectEvent += new EventHandler(ClearAllSelectEvent);
|
|
file.Locked = dt.Rows[i]["A1"] + "" == "1";
|
|
file.FileName = filename;
|
|
file.FileDetial = dt.Rows[i];
|
|
file.SetAttachLabel(filename);
|
|
//文件格式统一小写
|
|
string extension = filename.ToLower().Split('.')[1];
|
|
this.splitContainerRight.PanelVisibility = SplitPanelVisibility.Both;
|
|
file.SetAttachImage(GetFileImage(extension));
|
|
FileArrangement(file);
|
|
_attachList.Add(file);
|
|
}
|
|
#endregion
|
|
}
|
|
else
|
|
{
|
|
#region 文件夹生成
|
|
//文件夹
|
|
DataTable dtFiles = AttachImpl.GetAttachSpecies(this.SysModelObj.SpeciesValue);
|
|
for (int i = 0; i < dtFiles.Rows.Count; i++)
|
|
{
|
|
string tnKey = dtFiles.Rows[i]["SpeciesNo"] + "";
|
|
string tnValue = dtFiles.Rows[i]["SpeciesName"] + "";
|
|
if (tnKey.Length <= this.SysModelObj.SpeciesValue.Length + 2)
|
|
{
|
|
if (tnKey != this.SysModelObj.SpeciesValue)
|
|
{
|
|
AttachControlEx attch = new AttachControlEx();
|
|
attch.OnMouseDoubleClickEvent += new EventHandler(OpenFileEvent);
|
|
attch.SetAttachLabel(tnValue);
|
|
attch.Spcino = tnKey;
|
|
attch.ClearAllSelectEvent += new EventHandler(ClearAllSelectEvent);
|
|
this.splitContainerRight.PanelVisibility = SplitPanelVisibility.Panel1;
|
|
DataTable dts = BaseImpl.GetDataTableResult(this.AttachModelObj.MenuSql + " and speciesno like '" + tnKey + "%'");
|
|
attch.SetAttachImage(dts.Rows.Count > 0 ? Resources.c_60 : Resources.folder_unempty);
|
|
FileArrangement(attch);
|
|
_attachList.Add(attch);
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
AttachControlEx.SetAttachControlMenu(this.pl_main, BaseModuleImpl.GetBaseGridRightMenus(this._attachMenuCode), this.SysModelObj, null, null, GetMenus());
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 文件明细
|
|
/// <summary>
|
|
/// <para>说明:文件明细</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-08 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void GetFileDetailEvent(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
AttachControlEx attach = sender as AttachControlEx;
|
|
|
|
if (attach.FileDetial != null)
|
|
{
|
|
//数据填充
|
|
foreach (XtraTabPage tabPage in this.tabBottomDetail.TabControlObj.TabPages)
|
|
{
|
|
GridDetailModel model = this.tabBottomDetail.GetGridDetailModel(tabPage);
|
|
this.tabBottomDetail.SetGridDataSource(tabPage, MainImpl.GetDataTableResult(this.GetSearchSql(model, attach.FileDetial)));
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 获取查询条件
|
|
/// <summary>
|
|
/// <para>说明:获取查询条件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-22 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="model">The model.</param>
|
|
/// <param name="rowItem">The row item.</param>
|
|
/// <returns>System.String.</returns>
|
|
protected string GetSearchSql(GridDetailModel model, DataRow rowItem)
|
|
{
|
|
string fieldName = !string.IsNullOrEmpty(model.UnionParentField) ? model.UnionParentField : this.ModuleModelObj.ParmaryKey;
|
|
string sqlValue = model.IsReadOnly ? model.DetailSql : model.SystemModel.MenuSql;
|
|
|
|
if (ReplaceHelper.IsSelect(sqlValue) && !string.IsNullOrEmpty(model.UnionValue))
|
|
{
|
|
sqlValue = ReplaceHelper.ReplaceWhereCond(sqlValue) + string.Format(" and {0}='{1}'", model.UnionValue, rowItem[fieldName] + "");
|
|
}
|
|
else
|
|
{
|
|
sqlValue = ReplaceHelper.ReplaceRowParam(rowItem, sqlValue);
|
|
}
|
|
return sqlValue;
|
|
}
|
|
#endregion
|
|
|
|
#region 双击打开文件夹
|
|
/// <summary>
|
|
/// <para>说明:双击打开文件夹</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-08 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="dt">数据来源.</param>
|
|
private void OpenFileEvent(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
AttachControlEx attach = sender as AttachControlEx;
|
|
if (attach != null)
|
|
{
|
|
this.tvLeft.TreeView.SelectedNode = this.tvLeft.TreeView.Nodes.Find(attach.Spcino, true)[0];
|
|
this.btnGoBack.Enabled = true;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 获取附件明细
|
|
/// <summary>
|
|
/// <para>说明:获取报表明细</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-23 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private List<GridDetailModel> GetBottomDetailGrid()
|
|
{
|
|
List<GridDetailModel> details = new List<GridDetailModel>();
|
|
DataTable moduleDetailBottomTable = BaseModuleImpl.GetBaseDetailPages(_attachMenuCode);
|
|
if (moduleDetailBottomTable.Rows.Count == 0)
|
|
{
|
|
moduleDetailBottomTable = BaseModuleImpl.GetBaseAddTabDetail(_attachMenuCode);
|
|
}
|
|
foreach (DataRow item in moduleDetailBottomTable.Rows)
|
|
{
|
|
DataTable dtGridColumns = ReportImpl.GetReportDetailColumns(this.SysModelObj.ModuleCode, item["id"] + "");
|
|
GridDetailModel grid = new GridDetailModel(item, dtGridColumns, GridCustomColumnStruct.BaseDetailGridView);
|
|
grid.DetailSql = "";
|
|
details.Add(grid);
|
|
}
|
|
return details;
|
|
}
|
|
#endregion
|
|
|
|
#region 得到文件图片
|
|
/// <summary>
|
|
/// <para>说明:得到文件图片</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-08 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private Image GetFileImage(string extension)
|
|
{
|
|
Bitmap image = null;
|
|
switch (extension)
|
|
{
|
|
case "txt":
|
|
image = Resources.txt_60;
|
|
break;
|
|
case "doc":
|
|
case "word":
|
|
image = Resources.word_60;
|
|
break;
|
|
case "pdf":
|
|
image = Resources.pdf_60;
|
|
break;
|
|
case "rar":
|
|
image = Resources.rar_60;
|
|
break;
|
|
case "xls":
|
|
case "xlsx":
|
|
image = Resources.xls_60;
|
|
break;
|
|
case "amr":
|
|
image = Resources.amr_60;
|
|
break;
|
|
case "jpg":
|
|
case "png":
|
|
image = Resources.pic_60;
|
|
break;
|
|
case "ppt":
|
|
image = Resources.ppt_60;
|
|
break;
|
|
default:
|
|
image = Resources.unknow_60;
|
|
break;
|
|
}
|
|
return image;
|
|
}
|
|
#endregion
|
|
|
|
#region 重置坐标
|
|
/// <summary>
|
|
/// <para>说明:清理附件面板</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-23 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void ClearFilePanel()
|
|
{
|
|
this.pl_main.Controls.Clear();
|
|
//重置
|
|
this._locationY = 0;
|
|
this._number = 0;
|
|
this._newLine = 1;
|
|
}
|
|
#endregion
|
|
|
|
#region 文件排布算法
|
|
/// <summary>
|
|
/// <para>说明:文件排布算法</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-08 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void FileArrangement(AttachControlEx a)
|
|
{
|
|
_locationY = a.Location.Y + _locationY;
|
|
int x = a.Location.X + (a.Width + 12) * _number;
|
|
if (x > pl_main.Width - a.Width)//计算容器宽度是否还够放下
|
|
{
|
|
_locationY = a.Height * _newLine + 12; //换行
|
|
x = 0;
|
|
_newLine++;
|
|
_number = 0;
|
|
}
|
|
a.Location = new Point(x + 12, _locationY + 12);
|
|
_number++;
|
|
this.pl_main.Controls.Add(a);
|
|
}
|
|
#endregion
|
|
|
|
#region 鼠标按下
|
|
/// <summary>
|
|
/// <para>说明:鼠标按下</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-22 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void pl_main_MouseDown(object sender, MouseEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
//左键点击
|
|
if (e.Button == MouseButtons.Left)
|
|
{
|
|
this._pointStart = new Point(e.X, e.Y);
|
|
//点击在空白区域清除选中
|
|
foreach (AttachControlEx attach in _attachSelectList)
|
|
{
|
|
AttachControlEx.ClearFilesSelect(attach);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Point point = this.PointToClient(Cursor.Position);
|
|
this.contextMenuStrip.Show(this, point);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 画框操作
|
|
/// <summary>
|
|
/// <para>说明:鼠标移动</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-22 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void pl_main_MouseMove(object sender, MouseEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (e.Button == MouseButtons.Left)
|
|
{
|
|
this._pointEnd = new Point(e.X, e.Y);
|
|
GetRectangle();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:鼠标抬起</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-22 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void pl_main_MouseUp(object sender, MouseEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
DrawRectangles();
|
|
//获取框中附件,并赋予状态
|
|
foreach (AttachControlEx attach in pl_main.Controls)
|
|
{
|
|
if (attach.Bounds.IntersectsWith(MouseRect))
|
|
{
|
|
attach.AttachControlSelect();
|
|
}
|
|
}
|
|
MouseRect = Rectangle.Empty;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:得到框体大小</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-08 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void GetRectangle()
|
|
{
|
|
DrawRectangles();
|
|
MouseRect.X = _pointStart.X < _pointEnd.X ? _pointStart.X : _pointEnd.X;//返回最小值的x;
|
|
MouseRect.Y = _pointStart.Y < _pointEnd.Y ? _pointStart.Y : _pointEnd.Y;//返回最小值的y;
|
|
MouseRect.Width = Math.Abs(_pointStart.X - _pointEnd.X);//宽度
|
|
MouseRect.Height = Math.Abs(_pointStart.Y - _pointEnd.Y);//高度.
|
|
DrawRectangles();
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:画框</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-08 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void DrawRectangles()
|
|
{
|
|
Rectangle rect = pl_main.RectangleToScreen(MouseRect);
|
|
ControlPaint.DrawReversibleFrame(rect, Color.White, FrameStyle.Dashed);
|
|
}
|
|
#endregion
|
|
|
|
#region 后退操作
|
|
/// <summary>
|
|
/// <para>说明:后退操作</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-22 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void btnGoBack_Click(object sender, EventArgs e)
|
|
{
|
|
try {
|
|
if (this._speciNo.Length > 2)
|
|
{
|
|
_backHistory.Add(this._speciNo);
|
|
this._speciNo = _speciNo.Substring(0, _speciNo.Length - 2);
|
|
this.tvLeft.TreeView.SelectedNode = this.tvLeft.TreeView.Nodes.Find(this._speciNo, true)[0];
|
|
this.btnGoBack.Enabled = this._speciNo.Length > 2;
|
|
KeepAttachSelected(_backHistory[_backHistory.Count - 1]);
|
|
}
|
|
if (_backHistory.Count > 0) this.btnGoForward.Enabled = true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// <para>说明:前进后退保持附件选中状态</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-22 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void KeepAttachSelected(string speciNo)
|
|
{
|
|
AttachControlEx attach = pl_main.Controls.Cast<AttachControlEx>().FirstOrDefault(o => o.Spcino == speciNo);
|
|
if (attach != null) attach.AttachControlSelect();
|
|
}
|
|
|
|
#region 前进操作
|
|
/// <summary>
|
|
/// <para>说明:前进操作</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-22 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void btnGoForward_Click(object sender, EventArgs e)
|
|
{
|
|
try {
|
|
//树和右边操作同步
|
|
this.tvLeft.TreeView.SelectedNode = this.tvLeft.TreeView.Nodes.Find(_backHistory[_backHistory.Count - 1], true)[0];
|
|
if (_backHistory.Count >= 2) KeepAttachSelected(_backHistory[_backHistory.Count - 2]);
|
|
//当到最底层时,按扭禁用
|
|
this.btnGoBack.Enabled = this._speciNo.Length > 2;
|
|
_backHistory.RemoveAt(_backHistory.Count - 1);
|
|
if (_backHistory.Count == 0) this.btnGoForward.Enabled = false;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 面板重置大小
|
|
/// <summary>
|
|
/// <para>说明:面板重置大小</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-08 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void pl_main_Resize(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
ClearFilePanel();
|
|
foreach (AttachControlEx attach in _attachList)
|
|
{
|
|
attach.Location = new Point(0, 0);
|
|
FileArrangement(attach);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 固定搜索事件
|
|
/// <summary>
|
|
/// <para>说明:搜索</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-22 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void btnSearch_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
string where = string.Format(" and {0} like '{1}%' ", this.cbField.SelectedValue, this.txtFixKey.Text);
|
|
InitFilesControl(BaseImpl.GetDataTableResult(this.AttachModelObj.MenuSql + where));
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 自定义搜索事件
|
|
/// <summary>
|
|
/// <para>说明:自定义搜索</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-01 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void CustomSearch_Click(object sender, SearchArgs e)
|
|
{
|
|
try
|
|
{
|
|
InitFilesControl(BaseImpl.GetDataTableResult(this.SearchObj.SetSearchSqlValue(this.AttachModelObj.MenuSql)));
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region 附件操作回调
|
|
/// <summary>
|
|
/// <para>说明:设置附件操作回调</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-22 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void SetAttachEvent()
|
|
{
|
|
AttachHelper.OnDeleteSuccess += new EventHandler(AttachHelper_OnDeleteSuccess);
|
|
AttachHelper.OnDownLoadSuccess += new EventHandler(AttachHelper_OnDownLoadSuccess);
|
|
}
|
|
#endregion
|
|
|
|
#region 预览附件
|
|
/// <summary>
|
|
/// <para>说明:文件预览事件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-23 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void tmsView_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (_attachSelectList.Count <= 0) return;
|
|
AttachControlEx attach = _attachSelectList[0];
|
|
string tipMsg = string.Empty;
|
|
_currentFileNo = Convert.ToInt32(this._attachSelectList[0].FileNo);
|
|
if (AttachImpl.CheckAttachOperation(2, "", _currentFileNo, "", 0, out tipMsg) == 1)
|
|
{
|
|
_currentFilePath = PubUtil.FileDownLoadTempPath + attach.FileName;
|
|
//判断本地文件
|
|
if (!File.Exists(_currentFilePath))
|
|
{
|
|
string serverPath = Path.Combine(SystemInfo.Instance.ServerAttachPath, BaseModuleImpl.GetFileServerPath(attach.FileNo));
|
|
//下载预览
|
|
AttachHelper.DownLoadFile(this.Handle, serverPath);
|
|
}
|
|
else
|
|
{
|
|
PreviewFile(_currentFilePath);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:预览附件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-23 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="fileExtension">附件地址</param>
|
|
private void PreviewFile(string fileUrl)
|
|
{
|
|
Form pviewFrm = new Form();
|
|
pviewFrm.Width = 800;
|
|
pviewFrm.Height = 800;
|
|
pviewFrm.WindowState = FormWindowState.Normal;
|
|
pviewFrm.StartPosition = FormStartPosition.CenterScreen;
|
|
pviewFrm.Text = "附件预览";
|
|
string fileExtension = fileUrl.ToLower().Split('.')[1];
|
|
switch (fileExtension)
|
|
{
|
|
case "word":
|
|
case "txt":
|
|
case "html":
|
|
case "doc":
|
|
RichEditControl rc = new RichEditControl();
|
|
rc.Dock = DockStyle.Fill;
|
|
rc.LoadDocument(fileUrl);
|
|
pviewFrm.Controls.Add(rc);
|
|
break;
|
|
case "jpg":
|
|
case "png":
|
|
PictureBox p = new PictureBox();
|
|
p.Dock = DockStyle.Fill;
|
|
p.SizeMode = PictureBoxSizeMode.StretchImage;
|
|
p.Image = Image.FromFile(fileUrl);
|
|
pviewFrm.Controls.Add(p);
|
|
break;
|
|
case "pdf":
|
|
//用office制作的pdf会出现乱码
|
|
PdfViewer pdfview = new PdfViewer();
|
|
pdfview.Dock = DockStyle.Fill;
|
|
pdfview.ZoomMode = PdfZoomMode.FitToWidth;
|
|
PdfViewerHelper.CreateNewPdf(this._currentFileNo, "", fileUrl);
|
|
pdfview.LoadDocument(fileUrl);
|
|
pviewFrm.Controls.Add(pdfview);
|
|
break;
|
|
case "xlsx":
|
|
case "xls":
|
|
SpreadsheetControl sheet = new SpreadsheetControl();
|
|
sheet.Dock = DockStyle.Fill;
|
|
sheet.Enabled = false;
|
|
IWorkbook workbook = sheet.Document;
|
|
workbook.LoadDocument(fileUrl);
|
|
pviewFrm.Controls.Add(sheet);
|
|
break;
|
|
default:
|
|
XtraMessageBox.Show("该文件格式不支持预览");
|
|
return;
|
|
}
|
|
pviewFrm.Show();
|
|
}
|
|
#endregion
|
|
|
|
#region 附件下载删除回调
|
|
/// <summary>
|
|
/// <para>说明:</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-22 </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>
|
|
/// <exception cref="System.NotImplementedException"></exception>
|
|
protected void AttachHelper_OnDownLoadSuccess(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (AttachHelper.IsDefWndProc(this.Handle, (System.Windows.Forms.Message)sender))
|
|
{
|
|
if (this._currentFileNo != 0)
|
|
PdfViewerHelper.CreateNewPdf(this._currentFileNo, "", this._currentFilePath);
|
|
// 加载本地图片
|
|
this.PreviewFile(_currentFilePath);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:删除成功</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-22 </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>
|
|
/// <exception cref="System.NotImplementedException"></exception>
|
|
protected void AttachHelper_OnDeleteSuccess(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (AttachHelper.IsDefWndProc(this.Handle, (System.Windows.Forms.Message)sender))
|
|
{
|
|
//重新绘制附件
|
|
this.ClearFilePanel();
|
|
//将各个控件位置重置
|
|
foreach (AttachControlEx attach in this._attachList)
|
|
{
|
|
attach.Location = new Point(0, 0);
|
|
FileArrangement(attach);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:消息处理</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-22 </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);
|
|
}
|
|
#endregion
|
|
|
|
#region 清除所有附件状态
|
|
/// <summary>
|
|
/// <para>说明:清除所有附件状态</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-23</para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="fileExtension">附件地址</param>
|
|
private void ClearAllSelectEvent(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
foreach (AttachControlEx attach in this._attachSelectList)
|
|
{
|
|
AttachControlEx.ClearFilesSelect(attach);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 记录分割条
|
|
/// <summary>
|
|
/// <para>说明:记录分割条位置</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-24</para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="fileExtension">附件地址</param>
|
|
private void FrmMain_FormClosed(object sender, FormClosedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
IniHelper.Write(string.Format("base_SplitterPosition_{0}", this.SysModelObj.ModuleCode), splitContainerControl1.SplitterPosition + "");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 设置分割条
|
|
/// <summary>
|
|
/// <para>说明:设置分割条位置</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-24</para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void InitlizeSpiltLocation()
|
|
{
|
|
string splitterPosition = IniHelper.Read(string.Format("base_SplitterPosition_{0}", this.SysModelObj.ModuleCode));
|
|
if (!string.IsNullOrEmpty(splitterPosition))
|
|
{
|
|
splitContainerControl1.SplitterPosition = Convert.ToInt32(splitterPosition);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 多选
|
|
/// <summary>
|
|
/// <para>说明:ctrl键按下</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-08 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void AttachControl_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (e.KeyValue == 17) AttachControlEx.Ctrlflag = true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:ctrl键弹起</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-08 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void AttachControl_KeyUp(object sender, KeyEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (e.KeyValue == 17) AttachControlEx.Ctrlflag = false;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
}
|
|
}
|