ab56a9bcf7
SVN-Revision: r240
970 lines
40 KiB
C#
970 lines
40 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Diagnostics;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using DevExpress.XtraEditors;
|
|
using Lskj.Business;
|
|
using Lskj.Business.Impl;
|
|
using Lskj.Control;
|
|
using Lskj.Control.Model;
|
|
using Lskj.Core;
|
|
using Lskj.Data;
|
|
using Lskj.Model;
|
|
using Lskj.PhotoView.Properties;
|
|
using Lskj.Util;
|
|
|
|
namespace Lskj.PhotoView
|
|
{
|
|
public partial class FrmMain : BaseForm
|
|
{
|
|
/// <summary>
|
|
/// 附件目录ID
|
|
/// </summary>
|
|
private int _directoryId;
|
|
/// <summary>
|
|
/// 附件主键值
|
|
/// </summary>
|
|
private string _parmaryKey = "fileId";
|
|
/// <summary>
|
|
/// 附件名称字段
|
|
/// </summary>
|
|
private string _fileNameKey = "sName";
|
|
/// <summary>
|
|
/// 附件固定模块(用于提取表格列、表格颜色、右键菜单、查询条件)
|
|
/// </summary>
|
|
private string _attachMenuCode = "2005_1";
|
|
/// <summary>
|
|
/// 当前操作附件
|
|
/// </summary>
|
|
private string _curFileName = 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>
|
|
public DynamicPhotoViewModel Model;
|
|
/// <summary>
|
|
/// 基础档案模块对象
|
|
/// </summary>
|
|
public AttachModuleModel ModuleModelObj;
|
|
/// <summary>
|
|
/// 附件模块
|
|
/// </summary>
|
|
public ModuleModel AttachModelObj;
|
|
/// <summary>
|
|
/// 查询条件控件
|
|
/// </summary>
|
|
public MyControl SearchObj;
|
|
|
|
public FrmMain()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
#region private method
|
|
/// <summary>
|
|
/// <para>说明:窗口初始化</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-08 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="e">一个包含事件数据的 <see cref="T:System.EventArgs" />。</param>
|
|
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.Model.ModuleCode));
|
|
return;
|
|
}
|
|
|
|
this.AttachModelObj = new ModuleModel(menuRow);
|
|
this.ModuleModelObj = new AttachModuleModel(AttachImpl.GetSystemModule(Model.ModuleCode));
|
|
if (this.ModuleModelObj.ModType == 1 && !this.ModuleModelObj.IsReport)
|
|
this.ModuleModelObj.ParmaryKey = BaseImpl.GetBasePrimaryKey(this.Model.ModuleCode);
|
|
this.Model.Privilege = Model.ModuleId > 0 ? BaseImpl.GetUserPurviewsByMenuId(Model.ModuleId + "") + "" : BaseImpl.GetUserPurviewsByMenuCode(Model.ModuleCode) + "";
|
|
|
|
if (string.IsNullOrEmpty(this.Model.SpeciesValue)) this.Model.SpeciesValue = this.ModuleModelObj.MenuBmpSpec;
|
|
|
|
this._directoryId = AttachImpl.GetAttachDirectoryId(this.Model.DirId, this.Model.ParmaryValue);
|
|
this.AttachModelObj.MenuSql = ReplaceHelper.ReplaceWhereCond(this.AttachModelObj.MenuSql) + " and parentId=" + this._directoryId;
|
|
|
|
// 取消ImageEdit右键菜单
|
|
this.txtEdit.ContextMenu = new ContextMenu();
|
|
|
|
this.SetLeftTreeView(); // 设置树
|
|
this.SetQueryCondition(); // 设置查询条件
|
|
this.SetGridView(); // 设置表格数据
|
|
this.SetAttachEvent();
|
|
|
|
this.SearchObj.SearchGrid();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//MessageUtil.Show(ex);
|
|
LogHelper.Instance.WriteError(ex);
|
|
LogUtil.WriteError("PhotoView初始化出错!", ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
Lskj.Control.Model.AutoSizeChange.ControllInitializeSize(this);
|
|
WaitForm.HideForm();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置左侧树</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-08 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void SetLeftTreeView()
|
|
{
|
|
this.tv_Main.TreeNodeKeyField = "SpeciesNo";
|
|
this.tv_Main.TreeNodeTextField = "SpeciesName";
|
|
this.tv_Main.BindTreeView(AttachImpl.GetAttachSpecies(this.Model.SpeciesValue));
|
|
this.tv_Main.TreeNodeSelectAfter += new TreeViewEventHandler(OnTreeNodeSelectAfter);
|
|
|
|
//GridDragTree dragTree = new GridDragTree(this.gcMain.GridView, this.tv_Main.TreeView);
|
|
//dragTree.OnDragComplete += new GridDragTreeCompleteEventHandler(dragTree_OnDragComplete);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置顶部查询条件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-08 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void SetQueryCondition()
|
|
{
|
|
this.SearchObj = new MyControl(this.AttachModelObj.MenuSql, this.gcMain, this.tv_Main, null);
|
|
|
|
DataTable queryTable = BaseModuleImpl.GetCustomQueryFields(this.AttachModelObj.CondKey);
|
|
this.SearchObj.ModuleId = Model.ModuleId;
|
|
this.SearchObj.ParentUnionField = this.SearchObj.ParentKeyField = this.tv_Main.TreeNodeKeyField;
|
|
|
|
if (queryTable != null && queryTable.Rows.Count > 0)
|
|
{
|
|
// 加载自定义查询条件
|
|
this.pl_top_fix_search.Visible = false;
|
|
this.SearchObj.OtherParams = Model.OtherParams();
|
|
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_fix_search);
|
|
}
|
|
}
|
|
/// <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(OnAttachDeleteSuccess);
|
|
AttachHelper.OnDownLoadSuccess += new EventHandler(OnAttachDownLoadSuccess);
|
|
AttachHelper.OnUploadSuccess += new EventHandler(OnAttachUploadSuccess);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置GridView</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-08 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void SetGridView()
|
|
{
|
|
this.gcMain.SetGridRowColors(BaseModuleImpl.GetBaseGridRowColors(this._attachMenuCode));
|
|
this.gcMain.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(this._attachMenuCode), this.Model, OnGridViewRightCallBack, this.SearchObj, this.GetMenus());
|
|
this.gcMain.SetReadOnlyColumns(BaseModuleImpl.GetBaseGridColumns(this._attachMenuCode), this.ModuleModelObj.FormKey);
|
|
this.gcMain.GridView.DoubleClick += new EventHandler(OnGridViewDoubleClick);
|
|
}
|
|
/// <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 ContextMenuStrip GetMenus()
|
|
{
|
|
ContextMenuStrip menu = new ContextMenuStrip();
|
|
ToolStripMenuItem tsmDownLoad = new ToolStripMenuItem("下载附件", null, OnDownLoadItemClick);
|
|
ToolStripMenuItem tsmUpload = new ToolStripMenuItem("上传附件", null, OnUploadButtonClick);
|
|
ToolStripMenuItem tsmLock = new ToolStripMenuItem("锁定附件", null, OnLockItemClick);
|
|
ToolStripMenuItem tmsUnlock = new ToolStripMenuItem("解锁附件", null, OnUnlockItemClick);
|
|
ToolStripMenuItem tsmDelete = new ToolStripMenuItem("删除附件", null, OnDeleteItemClick);
|
|
ToolStripMenuItem tsmUnion = new ToolStripMenuItem("关联附件", null, OnUnionItemClick);
|
|
btnUpload.Enabled = btnPhoto.Enabled = tsmDownLoad.Enabled = tsmLock.Enabled = tsmDelete.Enabled = tsmUpload.Enabled = tmsUnlock.Enabled = !this.Model.IsView;
|
|
|
|
if (this.Model.Completed && !this.Model.IsView)
|
|
{
|
|
btnUpload.Enabled = btnPhoto.Enabled = tsmLock.Enabled = tsmDelete.Enabled = tsmUpload.Enabled = tmsUnlock.Enabled = false;
|
|
}
|
|
|
|
tsmUnion.Visible = this.Model.IsUnionImage;
|
|
menu.Items.AddRange(new ToolStripMenuItem[] { tsmUnion, tsmDelete, tmsUnlock, tsmLock, tsmUpload, tsmDownLoad });
|
|
return menu;
|
|
}
|
|
#endregion
|
|
|
|
#region protected event
|
|
/// <summary>
|
|
/// <para>说明:左侧树结构点击后</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-09 </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 OnTreeNodeSelectAfter(object sender, TreeViewEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
string where = string.Format(" and {0} like '{1}%' ", this.tv_Main.TreeNodeKeyField, e.Node.Name);
|
|
this.SearchObj.SearchGrid(this.AttachModelObj.MenuSql + where);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:右键菜单执行后刷新数据,刷新规则按照上一次查询条件刷新</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-02 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The sender.</param>
|
|
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
|
protected void OnGridViewRightCallBack(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
this.SearchObj.SearchLastGrid();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:双击修改界面</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-09 </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 OnGridViewDoubleClick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
// 调用附件下载(lstest.exe包含了下载权限验证)
|
|
DataRow rowItem = this.gcMain.GridView.GetFocusedDataRow();
|
|
if (rowItem != null)
|
|
{
|
|
this._curFileName = BaseModuleImpl.GetFileServerPath(Convert.ToInt32(rowItem[this._parmaryKey]));
|
|
if (Path.GetFileName(_curFileName) != Path.GetFileName(this.txtEdit.Tag + ""))
|
|
AttachHelper.DownLoadFile(this.Handle, Path.Combine(SystemInfo.Instance.ServerAttachPath, this._curFileName));
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:拖动数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-09 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The sender.</param>
|
|
/// <param name="e">The e.</param>
|
|
///
|
|
protected void OnOnDragCompleted(object sender, GridDragTreeArgs e)
|
|
{
|
|
//if (e.GridViewSelectRows == null || e.GridViewSelectRows.Length == 0 || e.SelectTreeNode == null) return;
|
|
|
|
//if (MessageUtil.Show(string.Format(ResourceKeys.DragSelectNode, e.SelectTreeNode.Text), MessageBoxButtons.YesNo) == DialogResult.Yes)
|
|
//{
|
|
// int[] records = new int[e.GridViewSelectRows.Length];
|
|
|
|
// for (int i = 0; i < e.GridViewSelectRows.Length; i++)
|
|
// {
|
|
// DataRow item = e.GridViewSelectRows[i];
|
|
// try
|
|
// {
|
|
// records[i] = ReplaceHelper.ReplaceRowParamCond(item, this.ModuleModelObj.DragCond)
|
|
// ? BaseModuleImpl.UpdateRecord(this._attachMenuTable, this.tv_Main.TreeNodeKeyField, e.SelectTreeNode.Tag + "", this.ModuleModelObj.ParmaryKey, item[this.ModuleModelObj.ParmaryKey] + "")
|
|
// : 0;
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// LogHelper.Instance.WriteError(ex);
|
|
// }
|
|
// }
|
|
|
|
// int successCount = records.Contains(1) ? records.Where(x => x == 1).Count() : 0;
|
|
// int faultCount = records.Contains(0) ? records.Where(x => x == 0).Count() : 0;
|
|
|
|
// MessageUtil.Show(string.Format(ResourceKeys.DragSuccessCount, successCount) + "\r\n" + string.Format(ResourceKeys.DragFaultCount, faultCount));
|
|
// this.SearchObj.SearchLastGrid();
|
|
//}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:刷新数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-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="EventArgs"/> instance containing the event data.</param>
|
|
protected void OnRefreshButtonClick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
this.SearchObj.SearchLastGrid();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:查询条件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-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="EventArgs"/> instance containing the event data.</param>
|
|
protected void OnFixSearchButtonClick(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:启动拍照</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-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="EventArgs"/> instance containing the event data.</param>
|
|
protected void OnPhotoButtonClick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
TreeNode tn = tv_Main.TreeView.SelectedNode;
|
|
if (tn == null)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.SelectedFileClass);
|
|
return;
|
|
}
|
|
if (tn.Nodes.Count > 0)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.SelectedFinalNode);
|
|
return;
|
|
}
|
|
if (!DBConfig.Instance.IsCmpCapture)
|
|
{
|
|
RegControlHelper.IsRegisterOcx(PubUtil.AbsolutelyPath + "Cmp/_Install.bat");
|
|
DBConfig.Instance.SetActiveOcx("IsCmpCapture");
|
|
}
|
|
string[] defaultArgs = string.Format(ModuleArgs.DefaultArgs, this.Model.FormText, this.Model.UserId, this.Model.UserName, this.Model.Privilege, this.Model.ModuleCode).Split('~');
|
|
string[] menuArgs = { _directoryId + "", tn.Name };
|
|
string[] args = defaultArgs.Concat(menuArgs).ToArray();
|
|
IForm form = FormHelper.LoadDllForm(ResourceDynamic.CmCapture, args);
|
|
DialogResult result = form.SubForm.ShowDialog();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogUtil.WriteError("附件管理启动拍照出错!", ex);
|
|
//MessageUtil.Show("附件管理启动拍照出错!" + ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:上传附件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-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="EventArgs"/> instance containing the event data.</param>
|
|
protected void OnUploadButtonClick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
TreeNode treeNode = this.tv_Main.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)
|
|
{
|
|
LogUtil.WriteError("附件管理上传附件出错!", ex);
|
|
//MessageUtil.Show("附件管理上传附件出错!" + ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:下载附件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-09 </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 OnDownLoadItemClick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
int[] rows = this.gcMain.GridView.GetSelectedRows();
|
|
if (rows.Length == 0)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.SelectRowIsNull);
|
|
return;
|
|
}
|
|
if (this.gcMain.GridView.Columns.ColumnByName(this._parmaryKey) == null)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.AttachParmaryKeyIsNull);
|
|
return;
|
|
}
|
|
string fileIds = string.Empty;
|
|
for (int i = 0; i < rows.Length; i++)
|
|
{
|
|
DataRow rowItem = this.gcMain.GridView.GetDataRow(rows[i]);
|
|
fileIds += rowItem[this._parmaryKey] + ",";
|
|
}
|
|
|
|
// 调用附件下载(lstest.exe包含了下载权限验证)
|
|
AttachHelper.DownLoadFile(this.Handle, fileIds.Trim(','), this._directoryId + "");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:锁定附件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-09 </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 OnLockItemClick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
int[] rows = this.gcMain.GridView.GetSelectedRows();
|
|
if (rows.Length == 0)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.SelectRowIsNull);
|
|
return;
|
|
}
|
|
|
|
if (MessageUtil.Show(string.Format(ResourceKeys.LockFileTip, rows.Length), MessageBoxButtons.YesNo) == DialogResult.Yes)
|
|
{
|
|
string errorMsg = string.Empty;
|
|
string fileIds = string.Empty;
|
|
|
|
for (int i = 0; i < rows.Length; i++)
|
|
{
|
|
DataRow rowItem = this.gcMain.GridView.GetDataRow(rows[i]);
|
|
|
|
string fileId = rowItem[this._parmaryKey] + "";
|
|
string fileName = rowItem[this._fileNameKey] + "";
|
|
|
|
// 检查权限
|
|
string tipMsg = string.Empty;
|
|
if (AttachImpl.CheckAttachOperation(4, "", Convert.ToInt32(fileId), "", 0, out tipMsg) == 1)
|
|
{
|
|
fileIds += fileId + ",";
|
|
}
|
|
else
|
|
{
|
|
errorMsg += "[" + fileName + "]\r\n";
|
|
}
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(errorMsg))
|
|
{
|
|
MessageUtil.Show(string.Format(ResourceKeys.NotLockFilesTip, errorMsg));
|
|
return;
|
|
}
|
|
// 附件锁定
|
|
if (!string.IsNullOrWhiteSpace(fileIds))
|
|
{
|
|
int result = AttachImpl.LockFiles(fileIds);
|
|
|
|
this.SearchObj.SearchLastGrid();
|
|
MessageUtil.Show(result > 0 ? ResourceKeys.OperSuccess : ResourceKeys.OperFault);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:解锁附件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-09 </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 OnUnlockItemClick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
int[] rows = this.gcMain.GridView.GetSelectedRows();
|
|
if (rows.Length == 0)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.SelectRowIsNull);
|
|
return;
|
|
}
|
|
|
|
if (MessageUtil.Show(string.Format(ResourceKeys.UnLockFileTip, rows.Length), MessageBoxButtons.YesNo) == DialogResult.Yes)
|
|
{
|
|
string errorMsg = string.Empty;
|
|
string fileIds = string.Empty;
|
|
|
|
for (int i = 0; i < rows.Length; i++)
|
|
{
|
|
DataRow rowItem = this.gcMain.GridView.GetDataRow(rows[i]);
|
|
|
|
string fileId = rowItem[this._parmaryKey] + "";
|
|
string fileName = rowItem[this._fileNameKey] + "";
|
|
|
|
// 检查权限
|
|
string tipMsg = string.Empty;
|
|
if (AttachImpl.CheckAttachOperation(5, "", Convert.ToInt32(fileId), "", 0, out tipMsg) == 1)
|
|
{
|
|
fileIds += fileId + ",";
|
|
}
|
|
else
|
|
{
|
|
errorMsg += "[" + fileName + "]\r\n";
|
|
}
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(errorMsg))
|
|
{
|
|
MessageUtil.Show(string.Format(ResourceKeys.NotUnLockFilesTip, errorMsg));
|
|
return;
|
|
}
|
|
// 附件解锁
|
|
if (!string.IsNullOrWhiteSpace(fileIds))
|
|
{
|
|
int result = AttachImpl.UnLockFiles(fileIds);
|
|
|
|
this.SearchObj.SearchLastGrid();
|
|
MessageUtil.Show(result > 0 ? ResourceKeys.OperSuccess : ResourceKeys.OperFault);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:删除附件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-09 </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 OnDeleteItemClick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
int[] rows = this.gcMain.GridView.GetSelectedRows();
|
|
if (rows.Length == 0)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.SelectRowIsNull);
|
|
return;
|
|
}
|
|
if (this.gcMain.GridView.Columns.ColumnByName(this._parmaryKey) == null)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.AttachParmaryKeyIsNull);
|
|
return;
|
|
}
|
|
|
|
if (MessageUtil.Show(ResourceKeys.DeleteFileTip, MessageBoxButtons.YesNo) == DialogResult.Yes)
|
|
{
|
|
try
|
|
{
|
|
string errorMsg = string.Empty;
|
|
string fileIds = string.Empty;
|
|
|
|
for (int i = 0; i < rows.Length; i++)
|
|
{
|
|
DataRow rowItem = this.gcMain.GridView.GetDataRow(rows[i]);
|
|
string fileId = rowItem[this._parmaryKey] + "";
|
|
string fileName = rowItem[this._fileNameKey] + "";
|
|
// 检查权限
|
|
string tipMsg = string.Empty;
|
|
if (AttachImpl.CheckAttachOperation(3, "", Convert.ToInt32(fileId), "", 0, out tipMsg) == 1)
|
|
{
|
|
fileIds += fileId + ",";
|
|
}
|
|
else
|
|
{
|
|
errorMsg += "[" + 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)
|
|
{
|
|
MessageUtil.Show(ex);
|
|
LogHelper.Instance.WriteError(ex);
|
|
LogUtil.WriteError("PhotoView删除附件出错!", ex);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:关联附件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-09 </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 OnUnionItemClick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
int[] rows = this.gcMain.GridView.GetSelectedRows();
|
|
if (rows.Length == 0)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.SelectRowIsNull);
|
|
return;
|
|
}
|
|
DataRow rowItem = this.gcMain.GridView.GetDataRow(rows[0]);
|
|
string fileName = rowItem[this._fileNameKey] + "";
|
|
string fieldId = rowItem[this._parmaryKey] + "";
|
|
|
|
if (!string.IsNullOrEmpty(fieldId))
|
|
{
|
|
if (_imageExt.Contains(Path.GetExtension(fileName)))
|
|
{
|
|
int result = AttachImpl.UpdateUnionAttach(this.ModuleModelObj.TableName, this.Model.UnionColName, fieldId, this.ModuleModelObj.ParmaryKey, this.Model.ParmaryValue);
|
|
MessageUtil.Show(result > 0 ? ResourceKeys.OperSuccess : ResourceKeys.OperFault);
|
|
this.SearchObj.SearchLastGrid();
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show(ResourceKeys.UnionFileExt);
|
|
}
|
|
}
|
|
}
|
|
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>
|
|
protected void OnAttachUploadSuccess(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (this.IsHandleCreated && AttachHelper.IsDefWndProc(this.Handle, (System.Windows.Forms.Message)sender))
|
|
{
|
|
this.SearchObj.SearchLastGrid();
|
|
}
|
|
}
|
|
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 OnAttachDownLoadSuccess(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
|
|
if (this.IsHandleCreated && AttachHelper.IsDefWndProc(this.Handle, (System.Windows.Forms.Message)sender))
|
|
{
|
|
// 加载本地图片
|
|
string filePath = PubUtil.FileDownLoadTempPath + _curFileName;
|
|
if (!string.IsNullOrEmpty(_curFileName) && _curFileName.Contains(".pdf"))
|
|
{
|
|
//下载附件进行合成
|
|
this.txtEdit.Tag = filePath;
|
|
this.txtEdit.Image = Resources.unknow_60;
|
|
PdfViewerHelper.CreateNewPdf(0, _curFileName, filePath);
|
|
return;
|
|
}
|
|
if (!string.IsNullOrEmpty(_curFileName) && this._imageExt.Contains(Path.GetExtension(_curFileName)) && File.Exists(filePath))
|
|
{
|
|
//FileInfo info = new FileInfo(filePath);
|
|
this.txtEdit.Tag = filePath;
|
|
//this.txtEdit.Image = Image.FromFile(filePath);
|
|
this.txtEdit.Image = ImageHelper.ReadImage(filePath);
|
|
}
|
|
else
|
|
{
|
|
this.txtEdit.Tag = filePath;
|
|
this.txtEdit.Image = Resources.unknow_60;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//MessageUtil.Show(ex);
|
|
LogHelper.Instance.WriteError(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 OnAttachDeleteSuccess(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (this.IsHandleCreated && AttachHelper.IsDefWndProc(this.Handle, (System.Windows.Forms.Message)sender))
|
|
{
|
|
this.SearchObj.SearchLastGrid();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:文件预览</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-04-19 </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 OnPhotoEditClick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
string filePath = txtEdit.Tag + "";
|
|
if (!string.IsNullOrWhiteSpace(filePath))
|
|
{
|
|
if (File.Exists(filePath))
|
|
{
|
|
Process.Start(filePath);
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show(ResourceKeys.FileNotFound);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//MessageUtil.Show(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)
|
|
{
|
|
try
|
|
{
|
|
base.DefWndProc(ref m);
|
|
|
|
if (this.Handle == m.HWnd)
|
|
AttachHelper.DefWndProc(m);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
private void simpleButton1_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
WebBrowserUtil.StartWebBrowser(this.Model.ModuleCode, this.AttachModelObj.MenuText);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
}
|
|
}
|
|
} |