using DevExpress.XtraGrid.Columns; using Lskj.Business.Impl; using Lskj.Control; using Lskj.Control.Model; using Lskj.Core; using Lskj.Data; using Lskj.Model; using Lskj.Util; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Text; using System.Windows.Forms; using Microsoft.WindowsAPICodePack.Shell; using Microsoft.WindowsAPICodePack.Shell.PropertySystem; using DevExpress.XtraEditors.Repository; using DevExpress.XtraEditors.Controls; using DevExpress.Data; using DevExpress.XtraGrid.Views.Base; using System.Windows.Media; using Lskj.Business; using Lskj.Control.BrowserSetting; using System.Net; using Newtonsoft.Json.Linq; using DevExpress.XtraGrid.Views.Grid; using Microsoft.Win32; using DevExpress.XtraEditors; using DevExpress.XtraTreeList.Nodes; using DevExpress.XtraTreeList; using Newtonsoft.Json; namespace Lskj.PubArtwork { public partial class ArtWorkModel : UserControl { #region 共有变量 /// /// mrp动态链接库 /// public DynamicArtworkModel Model; /// /// 主程序的基础模型 /// public ModuleModel MoudleMainObj; /// /// 明细的基础模型 /// public ModuleModel MoudleDetailObj; /// /// 明细右侧的基础模型 /// public ModuleModel MoudleRightDetailObj; /// ///主表条件控件 /// public MyControl SearchMainObj; /// /// 左侧树数据 /// public DataRow LeftRowObj; /// /// 主表关联左侧树字段 /// public string ParentUnionField; /// /// 主表关联左侧树id /// public string ParentKeyField; /// /// 右侧审核界面 /// public Accraditation FrmAccraditation; /// /// 关联流转模块 /// public ModuleModel accraditationModel; #endregion #region 私有 /// /// 主表明细key值 /// private string _primaryMainKey; /// /// 左侧模块右键 /// private BaseRightMenu baseRightMenu = new BaseRightMenu(); /// /// 文件大小 /// private static readonly string[] suffixes = new string[] { " B", " KB", " MB", " GB", " TB", " PB" }; /// /// 设置明细模块 /// private static GridDetailModel gridDetailModel; /// /// 设置明细模块 /// private static GridDetailModel gridDetailRightModel; /// /// 左侧树图标列表 /// private ImageList imageList = new ImageList(); /// /// 等待区数据表结构 /// private DataTable upperTable = new DataTable(); /// /// 之前选中节点 /// private TreeListNode lastNode = null; /// /// 左侧树构建数据源 /// private DataTable mainGridColumns = new DataTable(); /// /// 左侧树构建颜色 /// private DataTable mainGridColors = new DataTable(); /// /// 之前选中节点 /// private Dictionary IconBytesList = new Dictionary(); /// /// 主模块右键按钮 /// private Dictionary rightBtnDic = new Dictionary(); /// /// 左侧节点主键 /// private string leftTreeGridIdValue { get { string rtnString = string.Empty; if (this.treeLeft.GetGridViewDataSource() != null && this.treeLeft.GetGridViewDataSource().Rows.Count > 0) { rtnString = this.treeLeft.GetGridViewDataSource().Rows[0]["产品代码"] + ""; } return rtnString; } } /// /// 上方拖拽类 /// private GridDragTreeGrid dragGrid; /// /// 下方拖拽类 /// private GridDragTreeGrid nDragGrid; private GridDragGrid OperateDragGrid; private GridDragGrid GmGridDragGrid; private GridDragGrid RenameGridDragGrid; #endregion public ArtWorkModel() { InitializeComponent(); } /// /// 说明:树拖拽完成 /// 创建人:龚宇超 /// 创建日期:2017-11-14 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The sender. /// The e. protected void OnDragTreeCompleted(object sender, GridDragTreeGridArgs e) { try//拖拽后执行文件分配 { int[] selectRowIndexs = e.GridViewObj.GetSelectedRows(); DataRow[] selectRows = new DataRow[selectRowIndexs.Length]; for (int i = 0; i < selectRowIndexs.Length; i++) { selectRows[i] = e.GridViewObj.GetDataRow(selectRowIndexs[i]); } if (selectRows == null || selectRows.Length == 0) return; DataRow targetRow = this.treeLeft.GetViewFocusedDataRow(); int[] records = new int[selectRows.Length]; string resultStr = string.Empty; string result = string.Empty; if (e.GridViewObj == this.gm_Operate.GridView)//待选拖拽 { for (int i = 0; i < selectRows.Length; i++) { try { records[i] = ReplaceHelper.ReplaceRowParamCond(targetRow, this.MoudleMainObj.DragCond) ? 1 : 0; } catch { records[i] = 0; } if (records[i] == 0) { resultStr += string.Format("文件{0}移动失败,原因:{1}\r\n", selectRows[i]["name"], "不满足移动条件"); continue; } bool isMove = MoveFile(selectRows[i], this.leftTreeGridIdValue, e.SelectTreeNode.GetValue("代码") + "", out result); if (!isMove) { resultStr += string.Format("文件{0}移动失败,原因:{1}\r\n", selectRows[i]["name"], result); } } if (!string.IsNullOrEmpty(resultStr)) { MessageUtil.Show(resultStr); } } if (e.GridViewObj == this.gm_Control.GridView)//明细拖拽 { for (int i = 0; i < selectRows.Length; i++) { try { records[i] = ReplaceHelper.ReplaceRowParamCond(targetRow, this.MoudleMainObj.DragCond) ? 1 : 0; } catch { records[i] = 0; } if (records[i] == 0) { resultStr += string.Format("文件{0}移动失败,原因:{1}\r\n", selectRows[i]["name"], "不满足移动条件"); continue; } bool isMove = MoveFile(selectRows[i], e.BeforeTreeNode.GetValue("代码") + "", e.SelectTreeNode.GetValue("代码") + "", out result); if (!isMove) { resultStr += string.Format("文件{0}移动失败,原因:{1}\r\n", selectRows[i]["name"], result); } } if (!string.IsNullOrEmpty(resultStr)) { MessageUtil.Show(resultStr); } } } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message, ex.Message); } finally { TreeListNode lastNode = this.treeLeft.TreeListObj.FocusedNode; int RowIndex = this.treeLeft.TreeListObj.TopVisibleNodeIndex; this.SearchMainObj.SearchLastGrid(); this.treeLeft.TreeListObj.FocusedNode = lastNode; this.treeLeft.TreeListObj.TopVisibleNodeIndex = RowIndex; OnFocusedNodeChanged(null, null); } } #region 操作表格外部拖拽事件 /// /// 文件拖拽到操作页签 /// /// /// private void OngmControlDragDrop(object sender, DragEventArgs e) { string path = ((System.Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString();//获得路径 } /// /// 文件拖拽到操作页签 /// /// /// private void OngmControlDragEnter(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.All;//重要代码:表明是所有类型的数据,比如文件路径 else e.Effect = DragDropEffects.None; } #endregion #region 删除操作页签附件数据 /// /// 删除操作页签附件数据 /// /// /// private void OnbtnDelClick(object sender, EventArgs e) { DataTable dataTable = gm_Operate.gridControl.DataSource as DataTable; int[] rowNumbers = this.gm_Operate.GridView.GetSelectedRows(); string resultStr = string.Empty; foreach (int rowIndex in rowNumbers) { DataRow rowItem = this.gm_Operate.GridView.GetDataRow(rowIndex); bool isDelete = DeleteFile(rowIndex); if (!isDelete) { this.gm_Operate.GridView.UnselectRow(rowIndex); resultStr += string.Format("文件{0}删除失败\r\n", rowItem["name"]); } } if (!string.IsNullOrEmpty(resultStr)) { MessageUtil.Show(resultStr); } this.gm_Operate.GridView.DeleteSelectedRows(); this.gm_Operate.GridView.SelectRow(dataTable.Rows.Count - 1); this.gm_Operate.GridView.FocusedRowHandle = dataTable.Rows.Count - 1; } #endregion #region 方法 /// /// 说明:窗口加载 /// 创建人:王一帆 /// 创建日期:2022-12-08 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The sender. /// The instance containing the event data. public void OnLoad(DynamicArtworkModel _model) { WaitForm.ShowForm(); try { this.Model = _model;//共有动态库赋值 this.MoudleMainObj = new ModuleModel(MainImpl.GetSystemdllTab(Model.ModuleCode));//获取主模块构建类 this.MoudleMainObj.ParmaryKey = _primaryMainKey = BaseImpl.GetBasePrimaryKey(Model.ModuleCode);//构建主表主键值 this.InitializeSplitPosition();//初始化分隔条位置 this.InitializeControl();//初始化主表数据 InitListViewImageList();//初始化左侧图片列表 this.InitializeDetail();//初始化明细数据 this.InitializeOperateGrid();//初始化上面操作页 this.InitializeAccraditation();//初始化右侧审核界面 } catch (Exception) { } finally { } WaitForm.HideForm(); } /// /// 说明:初始化上面附件上传操作表格 /// 创建人:王一帆 /// 创建日期:2023-1-31 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// public void InitializeOperateGrid() { gm_Operate_CreateColumn();//创建表格 this.gm_Operate.DragDrop += gm_Operate_DragDrop;//拖拽事件 this.gm_Operate.DragEnter += gm_Operate_DragEnter; this.gm_Operate.GridView.MouseDown += OnGm_OperateMouseDown; OperateDragGrid = new GridDragGrid(this.gm_Operate.GridView, this.gm_Control.GridView);//等待区向明细拖拽 OperateDragGrid.OnDragComplete += new GridFragGridCompleteEventHandler(OnDragCompleted); GmGridDragGrid = new GridDragGrid(this.gm_Control.GridView, this.gm_Operate.GridView);//明细向等待区拖拽 GmGridDragGrid.OnDragComplete += new GridFragGridCompleteEventHandler(OnDragCompleted); RenameGridDragGrid = new GridDragGrid(this.gm_Operate.GridView, this.gmRight_Control.GridView);//等待区向版本区拖拽 RenameGridDragGrid.OnDragComplete += new GridFragGridCompleteEventHandler(OnRenameDragCompleted); this.gm_Operate.GridView.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.RowSelect; this.gm_Control.GridView.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.RowSelect; this.gmRight_Control.GridView.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.RowSelect; this.gmRight_Control.GridView.OptionsSelection.MultiSelect = false; } /// /// 说明:初始化右侧数据源 /// 创建人:王一帆 /// 创建日期:2023-3-01 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// public void InitializeAccraditation(DynamicBaseAccraditionPopModel dyncModel = null) { this.splitRightControl.PanelVisibility = SplitPanelVisibility.Panel1; //this.splitRightControl.Panel2.Controls.Clear();//管理界面审核不需要 //this.FrmAccraditation = new Accraditation(); //this.FrmAccraditation.Dock = DockStyle.Fill; //this.FrmAccraditation.Parent = this.splitRightControl.Panel2; //if (dyncModel == null) //{ // this.accraditationModel = new ModuleModel(MainImpl.GetSystemdllTab(this.MoudleMainObj.UnionAccraditationDllCoid));//获取关联流转构建类 // string[] defaultArgs = string.Format(ModuleArgs.DefaultArgs, accraditationModel.MenuName, ERPInfo.Instance.UserId, ERPInfo.Instance.UserName, this.Model.Privilege, accraditationModel.ModeCode).Split('~'); // //模块Id/stepcode/点击数据键值/权限 // string[] menuArgs = { "", accraditationModel.ModeCode + "", "", "", "", "0" }; // string[] args = defaultArgs.Concat(menuArgs).ToArray(); // dyncModel = new DynamicBaseAccraditionPopModel(args); //} //this.FrmAccraditation.InitaMain(dyncModel); } /// /// 初始化分隔条 /// private void InitializeSplitPosition() { this.splitLeftControl.SplitterPositionChanged += new EventHandler(OnSplitterPositionChanged); this.splitMainControl.SplitterPositionChanged += new EventHandler(OnSplitterPositionChanged); this.splitRightControl.SplitterPositionChanged += new EventHandler(OnSplitterPositionChanged); this.splitBottomControl.SplitterPositionChanged += new EventHandler(OnSplitterPositionChanged); string leftSpliterPosition = IniHelper.Read(string.Format("Step_spliterPositionLeft_{0}", this.Model.ModuleCode)); if (!string.IsNullOrEmpty(leftSpliterPosition)) this.splitLeftControl.SplitterPosition = Convert.ToInt32(leftSpliterPosition); string mainSpliterPosition = IniHelper.Read(string.Format("Step_spliterPositionMain_{0}", this.Model.ModuleCode)); if (!string.IsNullOrEmpty(mainSpliterPosition)) this.splitMainControl.SplitterPosition = Convert.ToInt32(mainSpliterPosition); string rightSpliterPosition = IniHelper.Read(string.Format("Step_spliterPositionRight_{0}", this.Model.ModuleCode)); if (!string.IsNullOrEmpty(rightSpliterPosition)) this.splitRightControl.SplitterPosition = Convert.ToInt32(rightSpliterPosition); string bottomSpliterPosition = IniHelper.Read(string.Format("Step_spliterPositionbottom_{0}", this.Model.ModuleCode)); if (!string.IsNullOrEmpty(bottomSpliterPosition)) this.splitBottomControl.SplitterPosition = Convert.ToInt32(bottomSpliterPosition); } /// /// 说明:行改变刷新当前审核参数 /// 创建人:王一帆 /// 创建日期:2023-3-01 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// public void AuditFlushed() { //try //{ // string selectSql = this.accraditationModel.MenuSql + " and billno = '{0}'"; // selectSql = string.Format(selectSql, this.leftTreeGridIdValue); // DataRow dataRow = MainImpl.GetDataRowResult(selectSql); // if (dataRow != null && dataRow.Table.Columns.Contains("stepcode")) // { // string stepcode = dataRow["stepcode"] + ""; // this.FrmAccraditation.SysModel.PrimaryValue = this.leftTreeGridIdValue; // this.FrmAccraditation.SysModel.StepCode = stepcode; // this.InitializeAccraditation(this.FrmAccraditation.SysModel); // } // else // { // this.InitializeAccraditation(); // } //} //catch (Exception) //{ // this.InitializeAccraditation(); //} } /// /// 说明:初始化明细表格构建 /// 创建人:王一帆 /// 创建日期:2023-1-31 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// public void InitializeDetail() { string queryTableCacheKey = this.MoudleMainObj.CondKey + "_queryTable"; DataTable moduleDetailTable = BaseModuleImpl.GetBaseDetailPages(this.Model.ModuleCode);//获取所有主表配置明细 if (moduleDetailTable == null || moduleDetailTable.Rows.Count == 0) return; gridDetailModel = new GridDetailModel(moduleDetailTable.Rows[0]); this.gm_Control.GridView.Tag = gridDetailModel; gridDetailModel.SystemModel = new ModuleModel(MainImpl.GetSystemdllTab(gridDetailModel.UnionModule));//获取主模块构建类 this.MoudleDetailObj = new ModuleModel(MainImpl.GetSystemdllTab(gridDetailModel.UnionModule));//获取明细模块构建类 DataTable moduleBottomDetailTable = BaseModuleImpl.GetBaseDetailPages(gridDetailModel.UnionModule);//获取明细的明细配置明细 gridDetailRightModel = (moduleBottomDetailTable == null || moduleBottomDetailTable.Rows.Count == 0) ? null : new GridDetailModel(moduleBottomDetailTable.Rows[0]); this.gmRight_Control.GridView.Tag = gridDetailRightModel; DataTable gridColumns = BaseModuleImpl.GetBaseGridColumns(gridDetailModel.UnionModule); GridColumn iconColumn = new GridColumn(); iconColumn.Caption = "图标"; iconColumn.FieldName = "icon"; iconColumn.UnboundType = UnboundColumnType.Object; RepositoryItemPictureEdit picEdit = new RepositoryItemPictureEdit(); picEdit.AutoHeight = true; picEdit.SizeMode = PictureSizeMode.Zoom; picEdit.BestFitWidth = 16; picEdit.CustomHeight = 16; iconColumn.ColumnEdit = picEdit; iconColumn.Visible = true; iconColumn.VisibleIndex = 0; iconColumn.OptionsColumn.AllowEdit = false; this.gm_Control.GridView.MouseDown += OnGm_ControlMouseDown; this.gm_Control.GridView.FocusedRowObjectChanged += OnGridView_FocusedRowObjectChanged; this.gm_Control.SetReadOnlyColumns(gridColumns, GridCustomColumnStruct.BaseMainGridView + this.MoudleDetailObj.FormKey);//明细 this.gm_Control.GridView.Columns.Insert(0, iconColumn); DynamicModel dyncModel = new DynamicModuleModel(new string[] { gridDetailModel.DetailName, ERPInfo.Instance.UserId, ERPInfo.Instance.UserName, this.Model.Privilege, gridDetailModel.UnionModule, "0" }); this.gm_Control.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(MoudleDetailObj.ModeCode), dyncModel, OnRightMenuCallBack, this.SearchMainObj); if (gridDetailRightModel != null) { this.MoudleRightDetailObj = new ModuleModel(MainImpl.GetSystemdllTab(gridDetailRightModel.UnionModule));//获取明细模块构建类 gridDetailRightModel.SystemModel = MoudleRightDetailObj; DataTable gridRightColumns = BaseModuleImpl.GetBaseGridColumns(gridDetailRightModel.UnionModule); this.gmRight_Control.SetReadOnlyColumns(gridRightColumns, GridCustomColumnStruct.BaseMainGridView + this.MoudleRightDetailObj.FormKey);//明细 DynamicModel dyncModelRight = new DynamicModuleModel(new string[] { gridDetailRightModel.DetailName, ERPInfo.Instance.UserId, ERPInfo.Instance.UserName, this.Model.Privilege, gridDetailRightModel.UnionModule, "0" }); DataTable RightTable = BaseModuleImpl.GetBaseGridRightMenus(MoudleRightDetailObj.ModeCode); this.gmRight_Control.SetGridRightMenus(RightTable, dyncModelRight, null, null); } else { this.splitBottomControl.PanelVisibility = SplitPanelVisibility.Panel1; } } /// /// 说明:初始化主表树表格构建 /// 创建人:王一帆 /// 创建日期:2023-1-31 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// public void InitializeControl() { mainGridColumns = BaseModuleImpl.GetBaseGridColumns(Model.ModuleCode);//主表配置列数据构建 mainGridColors = BaseModuleImpl.GetBaseGridRowColors(this.MoudleMainObj.ModeCode);//主表颜色配置 this.treeLeft.TreeListObj.OptionsView.ShowHorzLines = false; //隐藏水平表格线 this.treeLeft.TreeListObj.OptionsView.ShowVertLines = false; //隐藏垂直表格线 this.treeLeft.TreeListObj.OptionsView.ShowIndentAsRowStyle = false; //隐藏格式 this.treeLeft.Expansion = this.MoudleMainObj.TreeTableExpand; this.treeLeft.TreeListObj.BeforeExpand += OnTreeListObjBeforeExpand; this.treeLeft.TreeListObj.KeyFieldName = "id"; this.treeLeft.TreeListObj.ParentFieldName = "parentId"; this.treeLeft.SetReadOnlyColumns(mainGridColumns, GridCustomColumnStruct.BaseMainGridView + this.MoudleMainObj.FormKey);//主表列配置 this.treeLeft.TreeListObj.CustomDrawNodeCell += new DevExpress.XtraTreeList.CustomDrawNodeCellEventHandler(OnCustomDrawNodeCell);//选中行颜色 this.treeLeft.SetGridRowColors(mainGridColors); this.treeLeft.TreeListObj.OptionsSelection.MultiSelect = false; this.treeLeft.TreeListObj.OptionsSelection.MultiSelectMode = TreeListMultiSelectMode.RowSelect; this.treeLeft.TreeListObj.Click += new EventHandler(OnTreeListObjClick); this.treeLeft.GridView.BestFitColumns(); this.SearchMainObj = new MyControl(this.MoudleMainObj.MenuSql, treeLeft, null, null, null);//构建主表mycontrol this.SearchMainObj.isRevTextEdit = true; this.SearchMainObj.OnSearchBeforeCallBack += new SearchEventHandler(OnSearchBeforeCallBack);//搜索前记录选中 this.SearchMainObj.OnSearchAfterCallBack += new EventHandler(OnRefLeftTree);//执行后展开节点 DataTable queryTable = BaseModuleImpl.GetCustomQueryFields(this.MoudleMainObj.CondKey);//获取主模块构建的条件 if (queryTable != null && queryTable.Rows.Count > 0) { // 加载自定义查询条件 this.plm_top_cond.Controls.Clear(); this.SearchMainObj.InitSearchControl(queryTable, this.plm_top_cond, null, null, this.MoudleMainObj.ConditionRefresh); if (this.SearchMainObj.ControlModels.Where(n => n.FieldType == 5 || n.FieldType == 6 || n.FieldType == 15 || n.FieldType == 16).Count() > 0) { this.SearchMainObj.ButtonObj.Visible = false; if (this.SearchMainObj.RefreshButtonObj != null) this.SearchMainObj.RefreshButtonObj.Location = this.SearchMainObj.ButtonObj.Location; } } else { // 加载固定查询条件 DataTable table = BaseModuleImpl.GetFixedQueryFields(this.Model.ModuleCode);//加载固定查询条件 this.plm_top_cbField.DisplayMember = "fieldText"; this.plm_top_cbField.ValueMember = "fieldName"; this.plm_top_cbField.DataSource = table; this.SearchMainObj.InitDefaultSearchControl(table, this.plm_top_cond, this.plm_top_cbField.Name, this.plm_top_txtFixKey.Name, this.plm_top_btnFixSearch.Name); } if (this.SearchMainObj.ButtonObj != null) { this.SearchMainObj.ButtonObj.Focus(); } this.InitLeftRightBtn();//构建右键 if (Model.HasOperPrivilege()) { // 有权限则允许拖拽 dragGrid = new GridDragTreeGrid(this.gm_Operate.GridView, this.treeLeft.TreeListObj);//等待区向左侧树拖拽 dragGrid.CanDragParentNode = true; dragGrid.isDragCond = this.MoudleMainObj.DragCond; dragGrid.OnDragComplete += new GridDragTreeGridCompleteEventHandler(OnDragTreeCompleted); nDragGrid = new GridDragTreeGrid(this.gm_Control.GridView, this.treeLeft.TreeListObj);//明细向左侧树拖拽 nDragGrid.CanDragParentNode = true; nDragGrid.isDragCond = this.MoudleMainObj.DragCond; nDragGrid.OnDragComplete += new GridDragTreeGridCompleteEventHandler(OnDragTreeCompleted); } } /// /// 初始化左侧树 /// private void InitLeftTreeObj() { this.treeLeft.Dispose(); this.LeftTreePanel.Controls.Clear(); this.treeLeft = new TreeGridControlEx(); this.treeLeft.TreeListObj.OptionsView.ShowHorzLines = false; //隐藏水平表格线 this.treeLeft.TreeListObj.OptionsView.ShowVertLines = false; //隐藏垂直表格线 this.treeLeft.TreeListObj.OptionsView.ShowIndentAsRowStyle = false; //隐藏格式 //this.treeLeft.expansion = false; this.treeLeft.TreeListObj.BeforeExpand += OnTreeListObjBeforeExpand; this.treeLeft.TreeListObj.KeyFieldName = "id"; this.treeLeft.TreeListObj.ParentFieldName = "parentId"; this.treeLeft.SetReadOnlyColumns(mainGridColumns, GridCustomColumnStruct.BaseMainGridView + this.MoudleMainObj.FormKey);//主表列配置 this.treeLeft.TreeListObj.CustomDrawNodeCell += new DevExpress.XtraTreeList.CustomDrawNodeCellEventHandler(OnCustomDrawNodeCell);//选中行颜色 this.treeLeft.SetGridRowColors(mainGridColors); this.treeLeft.TreeListObj.OptionsSelection.MultiSelect = false; this.treeLeft.TreeListObj.OptionsSelection.MultiSelectMode = TreeListMultiSelectMode.RowSelect; this.treeLeft.TreeListObj.Click += new EventHandler(OnTreeListObjClick); this.treeLeft.GridView.BestFitColumns(); this.treeLeft.TreeListObj.SelectImageList = imageList; this.treeLeft.Dock = DockStyle.Fill; this.SearchMainObj.SetGridControlEx(this.treeLeft); this.LeftTreePanel.Controls.Add(this.treeLeft); } /// /// 节点切换时候触发事件 /// /// /// private void OnTreeListObjClick(object sender, EventArgs e) { TreeList treeListGrid = sender as TreeList; Point gcPoint = treeListGrid.PointToScreen((sender as TreeList).Location); Point mousePoint = System.Windows.Forms.Control.MousePosition; Point pt = new Point(mousePoint.X - gcPoint.X, mousePoint.Y - gcPoint.Y); TreeListHitInfo _hitInfo = treeListGrid.CalcHitInfo(pt); if (_hitInfo != null && _hitInfo.Node != null) { DataRowView dataRowView = this.treeLeft.TreeListObj.GetDataRecordByNode(_hitInfo.Node) as DataRowView; DataRow Row = dataRowView != null ? dataRowView.Row : null; bool isDrag = ReplaceHelper.ReplaceRowParamCond(Row, this.MoudleMainObj.DragCond); this.OperateDragGrid.isAllowDrag = isDrag; this.RenameGridDragGrid.isAllowDrag = isDrag; RefRightBtnVisable(); OnFocusedNodeChanged(null, null); } } private void InitLeftRightBtn() { DataTable rightDt = BaseModuleImpl.GetBaseGridRightMenus(this.Model.ModuleCode); if (rightDt != null && rightDt.Rows.Count > 0) { int width = this.pl_treeLeftRight.Width - 5; int height = this.pl_treeLeftRight.Height; foreach (DataRow dataRow in rightDt.Rows) { GridRightMenuModel menuModel = new GridRightMenuModel(dataRow); SimpleButton mrpBtn = new SimpleButton(); //mrpBtnDic.Add(menuModel, mrpBtn); mrpBtn.Name = menuModel.MenuId + ""; mrpBtn.Text = menuModel.MenuName; mrpBtn.Parent = this.pl_treeLeftRight; mrpBtn.Height = 26; mrpBtn.Width = 75; mrpBtn.Anchor = AnchorStyles.Top | AnchorStyles.Right; height = (this.pl_treeLeftRight.Height - mrpBtn.Height) / 2; width = width - mrpBtn.Width - 5; mrpBtn.Location = new Point(width, height); mrpBtn.Click += new EventHandler(OnModuleClick); mrpBtn.Tag = menuModel; rightBtnDic.Add(menuModel, mrpBtn); } this.pl_treeLeftRight.Visible = true; } } /// /// 说明:获取查询条件 /// 创建人:龚宇超 /// 创建日期:2017-11-22 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The model. /// The row item. /// System.String. protected string GetSearchSql(GridDetailModel model, DataRow rowItem) { string fieldName = !string.IsNullOrEmpty(model.UnionParentField) && rowItem.Table.Columns.Contains(model.UnionParentField) ? model.UnionParentField : MoudleMainObj.ParmaryKey; string sqlValue = model.IsReadOnly || model.IsChart ? model.DetailSql : model.SystemModel.MenuSql; sqlValue = ReplaceHelper.ReplaceRowParam(rowItem, sqlValue); if (ReplaceHelper.IsSelect(sqlValue) && !string.IsNullOrEmpty(model.UnionValue)) { sqlValue = ReplaceHelper.ReplaceWhereCond(sqlValue) + string.Format(" and {0}='{1}'", model.UnionValue, rowItem[fieldName] + ""); } if (!string.IsNullOrEmpty(model.UnionCond)) { string UnionCond = ReplaceHelper.ReplaceRowParam(rowItem, model.UnionCond); sqlValue += UnionCond; } return sqlValue; } /// /// 刷新左边选中的明细信息 /// public void RefurbishDetail() { try { DataRow rowItem = this.treeLeft.GetViewFocusedDataRow(); if (rowItem == null) return; string sqlValue = this.GetSearchSql(gridDetailModel, rowItem); DataTable dataTable = SqlHelper.ExecuteDataTable(sqlValue); //设置图标 dataTable.Columns.Add("icon", System.Type.GetType("System.Byte[]")); foreach (DataRow dataRow in dataTable.Rows) { if (string.IsNullOrWhiteSpace(dataRow["icon"] + "")) { string[] suffixs = dataRow.Table.Columns.Contains("name") ? (dataRow["name"] + "").Split('.') : (dataRow[0] + "").Split('.'); string suffix = "." + suffixs[suffixs.Length - 1]; //文件图标 byte[] imgBytes; if (IconBytesList.ContainsKey(suffix)) { imgBytes = IconBytesList[suffix]; } else { imgBytes = picture.GetFileBytes(suffix, false); IconBytesList.Add(suffix, imgBytes); } dataRow["icon"] = imgBytes; } } this.gm_Control.SetGridViewDataSource(dataTable); this.gm_Control.LastSearchSql = sqlValue; this.gm_Control.GridView.BestFitColumns(); if (dataTable == null || dataTable.Rows.Count == 0) { this.gmRight_Control.GridControl.DataSource = new DataTable(); } } catch (Exception ex) { //string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(ex.Message); } } /// /// 说明:加载主表格数据 /// 创建人:龚宇超 /// 创建日期:2018-01-31 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The where key. protected void SetMainGridView(string where = "") { string sqlValue = ReplaceHelper.ReplaceWhereCond(this.MoudleDetailObj.MenuSql); sqlValue = this.MoudleDetailObj.MenuSql.StartsWith("select", StringComparison.OrdinalIgnoreCase) ? sqlValue + where : sqlValue; DataTable dataTable = SqlHelper.ExecuteDataTable(sqlValue); //设置图标 dataTable.Columns.Add("icon", System.Type.GetType("System.Byte[]")); foreach (DataRow dataRow in dataTable.Rows) { if (string.IsNullOrWhiteSpace(dataRow["icon"] + "")) { string[] suffixs = dataRow.Table.Columns.Contains("name") ? (dataRow["name"] + "").Split('.') : (dataRow[0] + "").Split('.'); string suffix = "." + suffixs[suffixs.Length - 1]; //文件图标 byte[] imgBytes; if (IconBytesList.ContainsKey(suffix)) { imgBytes = IconBytesList[suffix]; } else { imgBytes = picture.GetFileBytes(suffix, false); IconBytesList.Add(suffix, imgBytes); } dataRow["icon"] = imgBytes; } } this.gm_Control.SetGridViewDataSource(dataTable); this.gm_Control.LastSearchSql = sqlValue; this.gm_Control.GridView.BestFitColumns(); } #endregion /// /// 说明:创建上方表格列 /// 创建人:龚宇超 /// 创建日期:2018-01-31 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// private void gm_Operate_CreateColumn() { //基础表单 GridColumn fileIdColumn = new GridColumn(); fileIdColumn.Caption = "文件编号"; fileIdColumn.FieldName = "fileId"; fileIdColumn.Visible = false; fileIdColumn.VisibleIndex = 1; fileIdColumn.OptionsColumn.AllowEdit = false; upperTable.Columns.Add("fileId");//添加主键字段 GridColumn iconColumn = new GridColumn(); iconColumn.Caption = "图标"; iconColumn.FieldName = "icon"; iconColumn.Width = 75; iconColumn.UnboundType = UnboundColumnType.Object; RepositoryItemPictureEdit picEdit = new RepositoryItemPictureEdit(); picEdit.AutoHeight = true; picEdit.SizeMode = PictureSizeMode.Zoom; picEdit.BestFitWidth = 16; picEdit.CustomHeight = 16; iconColumn.ColumnEdit = picEdit; iconColumn.Visible = true; iconColumn.VisibleIndex = 0; iconColumn.OptionsColumn.AllowEdit = false; upperTable.Columns.Add("icon", System.Type.GetType("System.Byte[]")); GridColumn nameColumn = new GridColumn(); nameColumn.Caption = "名称"; nameColumn.FieldName = "name"; nameColumn.Width = 320; nameColumn.Visible = true; nameColumn.VisibleIndex = 1; nameColumn.OptionsColumn.AllowEdit = false; upperTable.Columns.Add("name"); GridColumn CreationTimeColumn = new GridColumn(); CreationTimeColumn.Caption = "创建时间"; CreationTimeColumn.FieldName = "CreationTime"; CreationTimeColumn.Width = 180; CreationTimeColumn.Visible = true; CreationTimeColumn.VisibleIndex = 2; CreationTimeColumn.OptionsColumn.AllowEdit = false; upperTable.Columns.Add("CreationTime"); GridColumn typeColumn = new GridColumn(); typeColumn.Caption = "类型"; typeColumn.FieldName = "type"; typeColumn.Width = 100; typeColumn.Visible = true; typeColumn.VisibleIndex = 3; typeColumn.OptionsColumn.AllowEdit = false; upperTable.Columns.Add("type"); GridColumn fileSizeColumn = new GridColumn(); fileSizeColumn.Caption = "大小"; fileSizeColumn.FieldName = "fileSize"; fileSizeColumn.Width = 120; fileSizeColumn.Visible = true; fileSizeColumn.VisibleIndex = 4; fileSizeColumn.OptionsColumn.AllowEdit = false; upperTable.Columns.Add("fileSize"); GridColumn authorColumn = new GridColumn(); authorColumn.Caption = "作者"; authorColumn.FieldName = "author"; authorColumn.Width = 80; authorColumn.Visible = true; authorColumn.VisibleIndex = 5; authorColumn.OptionsColumn.AllowEdit = false; upperTable.Columns.Add("author"); GridColumn fileStreamColumn = new GridColumn(); fileStreamColumn.Caption = "文件流"; fileStreamColumn.FieldName = "fileStream"; fileStreamColumn.Visible = false; fileStreamColumn.OptionsColumn.AllowEdit = false; upperTable.Columns.Add("fileStream"); upperTable.Columns.Add("webpath");//地址 GridColumn UploaderColumn = new GridColumn(); UploaderColumn.Caption = "上传人"; UploaderColumn.FieldName = "Uploader"; UploaderColumn.Width = 80; UploaderColumn.Visible = true; UploaderColumn.VisibleIndex = 6; UploaderColumn.OptionsColumn.AllowEdit = false; upperTable.Columns.Add("Uploader"); GridColumn UploadTimeColumn = new GridColumn(); UploadTimeColumn.Caption = "上传时间"; UploadTimeColumn.FieldName = "UploadTime"; UploadTimeColumn.Width = 80; UploadTimeColumn.Visible = true; UploadTimeColumn.VisibleIndex = 7; UploadTimeColumn.OptionsColumn.AllowEdit = false; upperTable.Columns.Add("UploadTime"); this.gm_Operate.GridView.Columns.AddRange(new GridColumn[] { iconColumn, nameColumn, CreationTimeColumn, typeColumn, fileSizeColumn, //categoryColumn, authorColumn, //titleColumn, //copyrightColumn fileStreamColumn, UploaderColumn, UploadTimeColumn }); } /// /// 加载等待区数据 /// private void RefWaitFields() { string searchSql = "select fileId,sName as name, CreationTime,'' as type,fileSize, author,'' as fileStream,webpath,Uploader,UploadTime " + "from P_fm_FileTab where dllcoid = '{0}' and " + "parentid = (select dirid from P_fm_DirectoryTab where " + "ParentId = (select dirid from v_systemdlltab where DllCoid = '{0}') and PID = '{1}')"; searchSql = ERPInfo.Instance.UserId.Equals("1") ? string.Format(searchSql, this.Model.ModuleCode, this.leftTreeGridIdValue) : string.Format(searchSql + " and UploaderId='{2}'", this.Model.ModuleCode, this.leftTreeGridIdValue, ERPInfo.Instance.UserId); DataTable UploadFilesTab = SqlHelper.ExecuteDataTable(searchSql);//where speciesNo = '0' this.gm_Operate.LastSearchSql = searchSql; upperTable.Clear();//清理当前 foreach (DataRow dataRow in UploadFilesTab.Rows) { DataRow newRow = upperTable.NewRow(); newRow["fileId"] = dataRow["fileId"]; newRow["name"] = dataRow["name"]; newRow["type"] = Path.GetExtension(dataRow["name"] + "").Replace(".", ""); newRow["fileSize"] = BytesToReadableValue(Convert.ToDouble(dataRow["fileSize"])); newRow["author"] = dataRow["author"]; newRow["CreationTime"] = dataRow["CreationTime"]; newRow["Uploader"] = dataRow["Uploader"]; newRow["UploadTime"] = dataRow["UploadTime"]; string[] suffixs = (dataRow["name"] + "").Split('.'); string suffix = "." + suffixs[suffixs.Length - 1]; //文件图标 byte[] imgBytes; if (IconBytesList.ContainsKey(suffix)) { imgBytes = IconBytesList[suffix]; } else { imgBytes = picture.GetFileBytes(suffix, false); IconBytesList.Add(suffix, imgBytes); } newRow["icon"] = imgBytes; newRow["webpath"] = dataRow["webpath"]; upperTable.Rows.Add(newRow); } this.gm_Operate.gridControl.DataSource = upperTable; this.gm_Operate.GridView.SelectRow(upperTable.Rows.Count - 1); this.gm_Operate.GridView.FocusedRowHandle = upperTable.Rows.Count - 1; } /// /// 拖入边框时 /// /// /// private void gm_Operate_DragEnter(object sender, DragEventArgs e) { GridControlEx gridEx = (GridControlEx)sender; if (e.Data.GetDataPresent(DataFormats.FileDrop)) { gridEx.gridControl.AllowDrop = true; e.Effect = DragDropEffects.Link; } else e.Effect = DragDropEffects.None; } /// /// 说明:拖动完成后 /// 创建人:曹屹峰 /// 创建日期:2023-02-03 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// private void gm_Operate_DragDrop(object sender, DragEventArgs e) { WaitForm.ShowForm("文件上传中..."); try { if (this.treeLeft.TreeListObj.DataSource == null || this.treeLeft.GetGridViewDataSource().Rows.Count == 0) { MessageUtil.Show("当前节点数据不存在"); return; } int fileCount = ((System.Array)e.Data.GetData(DataFormats.FileDrop)).Length; string resultStr = string.Empty; string filter = SqlHelper.ExecuteScalar(@"select 合并字段=stuff((select '|'+Mix_apellation+'(*'+bases1 +')'+'|*'+bases1 from P_BaseMixInfoTab b where Tag=a.Tag for xml path('')),1,1,'') from P_BaseMixInfoTab a where Tag='70700201' group by Tag ") + ""; //文件地址 for (int i = 0; i < fileCount; i++) { string File = ((System.Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(i).ToString(); string outMsg = ""; bool isUpload = false; if (filter.ToLower().Contains(Path.GetExtension(File).ToLower())) { isUpload = UploadFile(File, out outMsg); } else { outMsg = "该文件类型不允许上传"; } if (!isUpload) { resultStr += string.Format("文件{0}上传失败,原因:{1}\r\n", Path.GetFileName(File), outMsg); } } if (!string.IsNullOrEmpty(resultStr)) { MessageUtil.Show(resultStr); } } catch (Exception) { } finally { this.RefWaitFields(); } WaitForm.HideForm(); } /// /// 上传按钮点击事件 /// /// /// private void btnAdd_Click(object sender, EventArgs e) { try { if (this.treeLeft.TreeListObj.DataSource == null || this.treeLeft.GetGridViewDataSource().Rows.Count == 0) { MessageUtil.Show("当前节点数据不存在"); return; } string resultStr = string.Empty; OpenFileDialog dialog = new OpenFileDialog(); dialog.Multiselect = true;//该值确定是否可以选择多个文件 dialog.Title = "请选择文件"; string filter = SqlHelper.ExecuteScalar(@"select 合并字段=stuff((select '|'+Mix_apellation+'(*'+bases1 +')'+'|*'+bases1 from P_BaseMixInfoTab b where Tag=a.Tag for xml path('')),1,1,'') from P_BaseMixInfoTab a where Tag='70700201' group by Tag ") + ""; dialog.Filter = string.IsNullOrWhiteSpace(filter) ? "所有文件(*.*)|*.*" : filter; if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { WaitForm.ShowForm("文件上传中..."); foreach (string fileName in dialog.FileNames) { string File = fileName; string outMsg = ""; bool isUpload = false; if (filter.ToLower().Contains(Path.GetExtension(File).ToLower())) { isUpload = UploadFile(File, out outMsg); } else { outMsg = "该文件类型不允许上传"; } if (!isUpload) { resultStr += string.Format("文件{0}上传失败,原因:{1}\r\n", Path.GetFileName(File), outMsg); } } if (!string.IsNullOrEmpty(resultStr)) { MessageUtil.Show(resultStr); } WaitForm.HideForm(); } } catch (Exception) { } finally { this.RefWaitFields(); } } /// /// 搜索前记录选中行 /// /// /// private void OnSearchBeforeCallBack(object sender, SearchArgs e) { this.lastNode = this.treeLeft.TreeListObj.FocusedNode; //InitLeftTreeObj(); } /// /// 搜索后重新绑定数结构 /// /// /// private void OnRefLeftTree(object sender, EventArgs e) { this.treeLeft.TreeListObj.BestFitColumns(); BingingListViewSelectImage(); this.treeLeft.TreeListObj.CollapseAll();//全部折叠 OnFocusedNodeChanged(null, null); this.AuditFlushed();//刷新审核界面 this.ForbiddenPopup(); //this.SearchMainObj.ResetControlValue(); if (this.SearchMainObj.ButtonObj != null) this.SearchMainObj.ButtonObj.Focus(); RefRightBtnVisable(); } /// /// 右键菜单回调 /// /// /// private void OnRightMenuCallBack(object sender, EventArgs e) { try { DataTable dataTable = BaseImpl.GetDataTableResult(this.gm_Control.LastSearchSql); //设置图标 dataTable.Columns.Add("icon", System.Type.GetType("System.Byte[]")); foreach (DataRow dataRow in dataTable.Rows) { if (string.IsNullOrWhiteSpace(dataRow["icon"] + "")) { string[] suffixs = (dataRow[0] + "").Split('.'); string suffix = "." + suffixs[suffixs.Length - 1]; //文件图标 byte[] imgBytes; if (IconBytesList.ContainsKey(suffix)) { imgBytes = IconBytesList[suffix]; } else { imgBytes = picture.GetFileBytes(suffix, false); IconBytesList.Add(suffix, imgBytes); } dataRow["icon"] = imgBytes; } } this.gm_Control.SetGridViewDataSource(dataTable); } catch (Exception ex) { MessageUtil.Show(ex.Message); } } /// /// 附件拖拽完成后 /// /// /// private void OnDragCompleted(object sender, GridDragGridArgs e) { DataRow rowitem = this.treeLeft.GetViewFocusedDataRow(); try { int[] selectRowIndexs = e.SourceGridViewObj.GetSelectedRows(); DataRow[] selectRows = new DataRow[selectRowIndexs.Length]; for (int i = 0; i < selectRowIndexs.Length; i++) { selectRows[i] = e.SourceGridViewObj.GetDataRow(selectRowIndexs[i]); } if (selectRows == null || selectRows.Length == 0) return; DataRow targetRow = this.treeLeft.GetViewFocusedDataRow(); int[] records = new int[selectRows.Length]; if (e.TargetGridViewObj == this.gm_Control.GridView)//向明细表拖拽 { if (selectRows == null || selectRows.Length == 0) return; string resultStr = string.Empty; string result = string.Empty; for (int i = 0; i < selectRows.Length; i++) { try { records[i] = ReplaceHelper.ReplaceRowParamCond(targetRow, this.MoudleMainObj.DragCond) ? 1 : 0; } catch { records[i] = 0; } if (records[i] == 0) { resultStr += string.Format("文件{0}移动失败,原因:{1}\r\n", selectRows[i]["name"], "不满足移动条件"); continue; } bool isMove = MoveFile(selectRows[i], this.leftTreeGridIdValue, this.treeLeft.TreeListObj.FocusedNode.GetValue("代码") + "", out result); if (!isMove) { resultStr += string.Format("文件{0}移动失败,原因:{1}\r\n", selectRows[i]["name"], result); } } if (!string.IsNullOrEmpty(resultStr)) { MessageUtil.Show(resultStr); } } else if (e.TargetGridViewObj == this.gm_Operate.GridView) //向等待区拖拽 { if (selectRows == null || selectRows.Length == 0) return; string resultStr = string.Empty; string result = string.Empty; for (int i = 0; i < selectRows.Length; i++) { try { //只判断明细条件 records[i] = ReplaceHelper.ReplaceRowParamCond(selectRows[i], gridDetailModel.SystemModel.DragCond) ? 1 : 0; } catch { records[i] = 0; } if (records[i] == 0) { resultStr += string.Format("文件{0}移动失败,原因:{1}\r\n", selectRows[i]["name"], "不满足移动条件"); continue; } bool isMove = MoveFile(selectRows[i], this.treeLeft.TreeListObj.FocusedNode.GetValue("代码") + "", this.leftTreeGridIdValue, out result); if (!isMove) { resultStr += string.Format("文件{0}移动失败,原因:{1}\r\n", selectRows[i]["name"], result); } } if (!string.IsNullOrEmpty(resultStr)) { MessageUtil.Show(resultStr); } } } catch (Exception) { MessageUtil.Show("分配附件失败"); } finally { TreeListNode lastNode = this.treeLeft.TreeListObj.FocusedNode; int RowIndex = this.treeLeft.TreeListObj.TopVisibleNodeIndex; this.SearchMainObj.SearchLastGrid(); //DataTable dataTable = MainImpl.GetDataTableResult(this.SearchMainObj.MainGridEx.LastSearchSql); //DataRow dataRow = dataTable.Rows.Cast().Where(n => (n["id"] + "").Equals(rowitem["id"] + "")).FirstOrDefault(); //rowitem["parentid"] = dataRow["parentid"]; this.treeLeft.TreeListObj.FocusedNode = lastNode; this.treeLeft.TreeListObj.TopVisibleNodeIndex = RowIndex; OnFocusedNodeChanged(null, null); } } /// /// 等待区向版本区拖拽 /// /// /// private void OnRenameDragCompleted(object sender, GridDragGridArgs e) { try { DataRow targetBottomRightRow = this.gmRight_Control.GridView.GetFocusedDataRow(); int[] selectRowIndexs = e.SourceGridViewObj.GetSelectedRows(); DataRow[] selectRows = new DataRow[selectRowIndexs.Length]; for (int i = 0; i < selectRowIndexs.Length; i++) { selectRows[i] = e.SourceGridViewObj.GetDataRow(selectRowIndexs[i]); } if (selectRows == null || selectRows.Length == 0) return; DataRow targetRow = this.treeLeft.GetViewFocusedDataRow(); int[] records = new int[selectRows.Length]; if (e.TargetGridViewObj == this.gmRight_Control.GridView)//向版本表拖拽 { if (selectRows == null || selectRows.Length == 0) return; string resultStr = string.Empty; string result = string.Empty; for (int i = 0; i < selectRows.Length; i++) { try { records[i] = ReplaceHelper.ReplaceRowParamCond(targetRow, this.MoudleMainObj.DragCond) ? 1 : 0; } catch { records[i] = 0; } if (records[i] == 0) { resultStr += string.Format("文件{0}移动失败,原因:{1}\r\n", selectRows[i]["name"], "不满足移动条件"); continue; } string ver = targetBottomRightRow.Table.Columns.Contains("Q") ? targetBottomRightRow["Q"] + "" : ""; bool isMove = MoveFile(selectRows[i], this.leftTreeGridIdValue, this.treeLeft.TreeListObj.FocusedNode.GetValue("代码") + "", out result, "2", ver); if (!isMove) { resultStr += string.Format("文件{0}移动失败,原因:{1}\r\n", selectRows[i]["name"], result); } } if (!string.IsNullOrEmpty(resultStr)) { MessageUtil.Show(resultStr); return; } DataRow menuRow = this.gmRight_Control.gridViewRightMenu.MenuTable != null && this.gmRight_Control.gridViewRightMenu.MenuTable.Rows.Count > 0 ? this.gmRight_Control.gridViewRightMenu.MenuTable.Rows[0] : null; GridRightMenuModel gridRightMenuModel = new GridRightMenuModel(menuRow); BaseRightMenu menu = new BaseRightMenu(); menu.Model = this.Model; if (targetBottomRightRow != null) { //menu.ExecRightMenu(gridRightMenuModel, new DataRow[] { targetBottomRightRow }); } } } catch (Exception) { MessageUtil.Show("分配附件失败"); } finally { TreeListNode lastNode = this.treeLeft.TreeListObj.FocusedNode; int RowIndex = this.treeLeft.TreeListObj.TopVisibleNodeIndex; this.SearchMainObj.SearchLastGrid(); this.treeLeft.TreeListObj.FocusedNode = lastNode; this.treeLeft.TreeListObj.TopVisibleNodeIndex = RowIndex; OnFocusedNodeChanged(null, null); } } /// /// 上传附件(新) /// private bool UploadFile(string filePath,out string msg) { bool isUpload = false; string File = filePath; string returnMsg = ""; try { //获取文件信息 System.IO.FileInfo fileInfo = new FileInfo(File); string suffix = Path.GetExtension(File); //获取Excel等文件信息 string fileAuthor = ""; string fileType = ""; try { var file = ShellFile.FromFilePath(File); string[] oldAuthors = file.Properties.System.Author.Value;//作者 if (oldAuthors != null && oldAuthors.Length > 0) { fileAuthor = string.Join(",", oldAuthors); } else { fileAuthor = ""; } fileType = file.Properties.System.ItemTypeText.Value + ""; } catch (Exception) { fileType = Path.GetExtension(File).TrimStart(','); } //新建行并添加拖动内容 DataTable dataTable = gm_Operate.gridControl.DataSource as DataTable; DataRow dataRow = dataTable.NewRow(); //文件图标 //Icon img = Icon.ExtractAssociatedIcon(File); //Icon img = picture.IconFromExtension(fi.Extension, picture.SystemIconSize.Small); byte[] imgBytes; if (IconBytesList.ContainsKey(suffix)) { imgBytes = IconBytesList[suffix]; } else { imgBytes = picture.GetFileBytes(suffix, false); IconBytesList.Add(suffix, imgBytes); } dataRow["icon"] = imgBytes; dataRow["name"] = fileInfo.Name; dataRow["CreationTime"] = fileInfo.CreationTime; //dataRow["type"] = fi.Extension.Replace(".", ""); dataRow["type"] = fileType; dataRow["fileSize"] = BytesToReadableValue(fileInfo.Length); //dataRow["category"] = ""; dataRow["author"] = fileAuthor; //dataRow["title"] = oldTitle; //dataRow["copyright"] = ""; byte[] fileBytes = ConvertFileToBytes(File); dataRow["fileStream"] = Convert.ToBase64String(fileBytes); dataRow["Uploader"] = ERPInfo.Instance.UserId; dataRow["UploadTime"] = DateTime.Now; string idValue = this.treeLeft.GetGridViewDataSource().Rows[0]["产品代码"] + ""; string token = ""; string loginUrl = $"{SystemInfo.Instance.OAUrl}/Api/SysUserAjaxApi.ashx"; HttpTools.setting("application/x-www-form-urlencoded", null, null, HttpTools.Encode.UTF8); Dictionary loginPmsDic = new Dictionary(); loginPmsDic.Add("method", "Login"); loginPmsDic.Add("username", ERPInfo.Instance.UserName); loginPmsDic.Add("password", ERPInfo.Instance.InPassWord); HttpWebResponse loginResponse = HttpTools.Post(loginUrl, "", loginPmsDic, HttpTools.Method.POST, out CookieCollection loginCookie, out string loginResult); if (loginResponse != null && !string.IsNullOrEmpty(loginResult)) { JObject jObject = JsonConvert.DeserializeObject(loginResult); if (jObject.ContainsKey("success")) { if ((jObject["success"] + "").Equals("True")) { if (jObject.ContainsKey("token")) { token = jObject["token"] + ""; } } } } if (!string.IsNullOrEmpty(token)) { string fileBase64Str = Convert.ToBase64String(fileBytes) + ""; string postUrl = "{0}Api/FileUploadApi.ashx?moduleId={1}&idValue={2}&folder={3}&totsize={4}&position={5}&filename={6}&method={7}"; Dictionary headerDic = new Dictionary(); headerDic.Add("Authorization", $"Bearer {token}"); //上传文件到服务器目录 postUrl = "{0}Api/FileUploadApi.ashx?moduleId={1}&idValue={2}&folder={3}&totsize={4}&position={5}&filename={6}&method={7}"; postUrl = string.Format(postUrl, SystemInfo.Instance.OAUrl, this.Model.ModuleCode, idValue, "UploadFilesTemp", fileBytes.Length, 0, dataRow["name"], "DoWebUpload"); HttpTools.setting("application/x-www-form-urlencoded", null, null); HttpWebResponse webResponse = HttpTools.Post(postUrl, fileBase64Str, null, headerDic, HttpTools.Method.POST, out CookieCollection cookieCollection, out string result); if (webResponse != null && !string.IsNullOrEmpty(result)) { JObject jsonObject = (JObject)JsonConvert.DeserializeObject(result); string isSuccess = jsonObject["success"] + ""; if (isSuccess.Equals("True", StringComparison.CurrentCultureIgnoreCase)) { string fileId = jsonObject["other"] + ""; string webpath = jsonObject["data"]["WebRelPath"] + ""; dataRow["fileId"] = fileId; dataRow["webpath"] = webpath; string searchSql = @"update P_fm_FileTab set author='{2}',CreationTime='{3}' ,Uploader='{4}',UploaderId='{5}' ,UploadTime='{6}' where dllcoid = '{0}' and parentid = (select dirid from P_fm_DirectoryTab where ParentId = (select dirid from v_systemdlltab where DllCoid = '{0}') and PID = '{1}') and fileId='{7}' "; searchSql = string.Format(searchSql, this.Model.ModuleCode, this.leftTreeGridIdValue, dataRow["author"], fileInfo.CreationTime, ERPInfo.Instance.UserName, ERPInfo.Instance.UserId, dataRow["UploadTime"], fileId); SqlHelper.ExecuteNonQuery(searchSql); dataTable.Rows.Add(dataRow); isUpload = true; } else { if (jsonObject.ContainsKey("msg")) { returnMsg = jsonObject["msg"] + ""; } isUpload = false; } } else { MessageUtil.Show(string.Format("上传失败,原因:{0}", result)); } } else { MessageUtil.Show(string.Format("验证失败,原因:{0}", loginResult)); } } catch (Exception ex) { returnMsg = ex.Message; isUpload = false; //MessageUtil.Show(string.Format("上传失败,原因:{0}", ex.Message)); //isUpload = false; } msg = returnMsg; return isUpload; } /// /// 上传文件 /// /// /// //private bool UploadFile(string filePath, out string msg) //{ // bool isUpload = false; // string File = filePath; // string returnMsg = ""; // string postUrl = ""; // try // { // //获取文件信息 // System.IO.FileInfo fileInfo = new FileInfo(File); // string suffix = Path.GetExtension(File); // //获取Excel等文件信息 // string fileAuthor = ""; // string fileType = ""; // try // { // var file = ShellFile.FromFilePath(File); // string[] oldAuthors = file.Properties.System.Author.Value;//作者 // if (oldAuthors != null && oldAuthors.Length > 0) // { // fileAuthor = string.Join(",", oldAuthors); // } // else // { // fileAuthor = ""; // } // fileType = file.Properties.System.ItemTypeText.Value + ""; // } // catch (Exception) // { // fileType = Path.GetExtension(File).TrimStart(','); // } // //新建行并添加拖动内容 // DataTable dataTable = gm_Operate.gridControl.DataSource as DataTable; // DataRow dataRow = dataTable.NewRow(); // //文件图标 // //Icon img = Icon.ExtractAssociatedIcon(File); // //Icon img = picture.IconFromExtension(fi.Extension, picture.SystemIconSize.Small); // byte[] imgBytes; // if (IconBytesList.ContainsKey(suffix)) // { // imgBytes = IconBytesList[suffix]; // } // else // { // imgBytes = picture.GetFileBytes(suffix, false); // IconBytesList.Add(suffix, imgBytes); // } // dataRow["icon"] = imgBytes; // dataRow["name"] = fileInfo.Name; // dataRow["CreationTime"] = fileInfo.CreationTime; // //dataRow["type"] = fi.Extension.Replace(".", ""); // dataRow["type"] = fileType; // dataRow["fileSize"] = BytesToReadableValue(fileInfo.Length); // //dataRow["category"] = ""; // dataRow["author"] = fileAuthor; // //dataRow["title"] = oldTitle; // //dataRow["copyright"] = ""; // byte[] fileBytes = ConvertFileToBytes(File); // dataRow["fileStream"] = Convert.ToBase64String(fileBytes); // dataRow["Uploader"] = ERPInfo.Instance.UserId; // dataRow["UploadTime"] = DateTime.Now; // string idValue = this.treeLeft.GetGridViewDataSource().Rows[0]["产品代码"] + ""; // //上传文件到服务器目录 // postUrl = "{0}Api/FileUploadApi.ashx?moduleId={1}&idValue={2}&folder={3}&totsize={4}&position={5}&filename={6}&method={7}"; // postUrl = string.Format(postUrl, SystemInfo.Instance.OAUrl, this.Model.ModuleCode, idValue, "UploadFilesTemp", fileBytes.Length, 0, dataRow["name"], "DoWebUpload"); // HttpTools.setting("application/x-www-form-urlencoded", null, null); // string result = ""; // CookieCollection cookieCollection = null; // HttpWebResponse webResponse = HttpTools.Post(postUrl, dataRow["fileStream"] + "", null, HttpTools.Method.POST, out cookieCollection, out result); // if (webResponse != null && !string.IsNullOrEmpty(result)) // { // JObject jsonObject = (JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(result); // string isSuccess = jsonObject["success"] + ""; // if (isSuccess.Equals("True", StringComparison.CurrentCultureIgnoreCase)) // { // string fileId = jsonObject["other"] + ""; // string webpath = jsonObject["data"]["WebRelPath"] + ""; // dataRow["fileId"] = fileId; // dataRow["webpath"] = webpath; // string searchSql = @"update P_fm_FileTab set author='{2}',CreationTime='{3}' ,Uploader='{4}',UploaderId='{5}' ,UploadTime='{6}' // where dllcoid = '{0}' and // parentid = (select dirid from P_fm_DirectoryTab where // ParentId = (select dirid from v_systemdlltab where DllCoid = '{0}') and PID = '{1}') and fileId='{7}' "; // searchSql = string.Format(searchSql, this.Model.ModuleCode, this.leftTreeGridIdValue, dataRow["author"], fileInfo.CreationTime, ERPInfo.Instance.UserName, ERPInfo.Instance.UserId, dataRow["UploadTime"], fileId); // SqlHelper.ExecuteNonQuery(searchSql); // dataTable.Rows.Add(dataRow); // isUpload = true; // } // else // { // if (jsonObject.ContainsKey("msg")) // { // returnMsg = jsonObject["msg"] + ""; // } // isUpload = false; // } // } // else // { // returnMsg = "上传请求失败"; // isUpload = false; // } // } // catch (Exception ex) // { // returnMsg = ex.Message; // isUpload = false; // } // //if (!string.IsNullOrEmpty(returnMsg)) // //{ // // returnMsg += string.Format("\r\n接口Url:{0}", postUrl); // //} // msg = returnMsg; // return isUpload; //} /// /// 删除文件 /// /// /// private bool DeleteFile(int rowIndex) { DataRow rowItem = this.gm_Operate.GridView.GetDataRow(rowIndex); bool isDelete = false; try { //删除文件 //string postUrl = "{0}Api/FileUploadApi.ashx?moduleId={1}&idValue={2}&folder={3}&filename={4}&method={5}"; string postUrl = "{0}Api/FileUploadApi.ashx?fileId={1}&filename={2}&method={3}"; //postUrl = string.Format(postUrl, SystemInfo.Instance.OAUrl, this.Model.ModuleCode, "", "UploadFilesTemp", rowItem["name"], "DoDelete"); postUrl = string.Format(postUrl, SystemInfo.Instance.OAUrl, rowItem["fileId"], rowItem["webpath"], "DoDelete"); HttpTools.setting("application/x-www-form-urlencoded", null, null); string result = ""; CookieCollection cookieCollection = null; HttpWebResponse webResponse = HttpTools.Post(postUrl, "", null, HttpTools.Method.POST, out cookieCollection, out result); if (webResponse != null && !string.IsNullOrEmpty(result)) { JObject jsonObject = (JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(result); string isSuccess = jsonObject["success"] + ""; if (isSuccess.Equals("True", StringComparison.CurrentCultureIgnoreCase)) { isDelete = true; } else { isDelete = false; } } else { isDelete = false; } } catch (Exception) { isDelete = false; } return isDelete; } /// /// 移动文件 /// /// private bool MoveFile(DataRow rowItem, string sid, string tid, out string Msg, string typeid = "", string ver = "") { bool isMove = false; Msg = ""; string postUrl = ""; try { string sNameSql = $"select vName from P_fm_FileTab where fileId = '{rowItem["fileId"]}'"; string sName = SqlHelper.ExecuteScalar(sNameSql) + ""; if (string.IsNullOrEmpty(typeid)) { postUrl = "{0}Api/FileUploadApi.ashx?moduleId={1}&filename={2}&sid={3}&tid={4}&username={5}&userid={6}&method={7}"; postUrl = string.Format(postUrl, SystemInfo.Instance.OAUrl, this.Model.ModuleCode, sName, sid, tid, ERPInfo.Instance.UserName, ERPInfo.Instance.UserId, "MoveFileTo"); } else { postUrl = "{0}Api/FileUploadApi.ashx?moduleId={1}&filename={2}&sid={3}&tid={4}&username={5}&userid={6}&typeid={7}&ver={8}&method={9}"; postUrl = string.Format(postUrl, SystemInfo.Instance.OAUrl, this.Model.ModuleCode, sName, sid, tid, ERPInfo.Instance.UserName, ERPInfo.Instance.UserId, typeid, ver, "MoveFileTo"); } HttpTools.setting("application/x-www-form-urlencoded", null, null); string result = ""; CookieCollection cookieCollection = null; HttpWebResponse webResponse = HttpTools.Post(postUrl, null, null, HttpTools.Method.POST, out cookieCollection, out result); if (webResponse != null && !string.IsNullOrEmpty(result)) { JObject jsonObject = (JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(result); string isSuccess = jsonObject["success"] + ""; if (isSuccess.Equals("True", StringComparison.CurrentCultureIgnoreCase)) { isMove = true; } else { if (jsonObject.ContainsKey("msg")) { Msg = jsonObject["msg"] + ""; } isMove = false; } } else { isMove = false; Msg = "上传请求失败"; } } catch (Exception ex) { Msg = ex.Message; isMove = false; } //if (!string.IsNullOrEmpty(Msg)) //{ // Msg += string.Format("\r\n接口Url:{0}", postUrl); //} return isMove; } private void InitListViewImageList() { //this.treeLeft.TreeView.CheckBoxes = false; imageList = new ImageList(); string[] files = null; try { files = Directory.GetFiles(PubUtil.TreeViewImagePath, "*.png"); imageList.Images.Add("treeViewDefault", global::Lskj.PubArtwork.Properties.Resources.treeViewDefault); } catch (Exception) { } if (files != null && files.Length > 0) { foreach (string file in files) { imageList.Images.Add(Path.GetFileNameWithoutExtension(file), Image.FromFile(file)); } } this.treeLeft.TreeListObj.SelectImageList = imageList; } /// /// 根据左侧数据重新绑定节点图标 /// private void BingingListViewSelectImage() { //DataTable sourceTable = this.treeLeft.GridControl.DataSourceTable(); foreach (TreeListNode node in this.treeLeft.TreeListObj.Nodes) { SettingIcon(imageList, node); } } /// /// 节点展开后去设置图片 /// /// /// private void OnTreeListObjBeforeExpand(object sender, NodeEventArgs e) { //TreeListNode Nodes && e.Node.ImageIndex SettingIcon(imageList, e.Node, true); } private void RefRightBtnVisable() { foreach (GridRightMenuModel menuModel in this.rightBtnDic.Keys) { SimpleButton mrpBtn = this.rightBtnDic[menuModel]; if (menuModel != null) { if (menuModel.PrivilegeOper.Length > 1 && !menuModel.PrivilegeOper.Contains(ERPInfo.Instance.UserName + ",")) { mrpBtn.Enabled = false; } else { if (!string.IsNullOrWhiteSpace(menuModel.MenuCond)) { try { DataRow mSelectRow = this.treeLeft.GetViewFocusedDataRow(); string cond = string.Empty; if (this.SearchMainObj != null) cond = this.SearchMainObj.ReplaceParentControlValue(menuModel.MenuCond); cond = ReplaceHelper.ReplaceRowParam(mSelectRow, menuModel.MenuCond); if (this.treeLeft.GridView != null) { GridCell[] cells = this.treeLeft.GridView.GetSelectedCells(); if (cells != null && cells.Length > 0 && cond.Contains("{COLUMN_")) { GridCell cell = cells[0]; DataRow focusedRow = this.treeLeft.GridView.GetFocusedDataRow(); string colValue = focusedRow == null || !focusedRow.Table.Columns.Contains(cell.Column.Name) ? "" : focusedRow[cell.Column.Name] + ""; cond = cond.ReplaceColumnParam(cell.Column.Name, cell.Column.Caption, colValue); } } if (this.SearchMainObj != null) cond = this.SearchMainObj.ReplaceParentControlValue(cond); mrpBtn.Enabled = ReplaceHelper.EvalCond(cond); } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(ResourceKeys.SetRightMenuCondFault + "\r\n" + Message); break; } } } } } } /// /// 设置节点图标 /// /// 图片集 /// 节点 private void SettingIcon(ImageList imageList, TreeListNode Nodes, bool recursion = false) { try { //当前节点 DataRowView dataRowView = this.treeLeft.TreeListObj.GetDataRecordByNode(Nodes) as DataRowView; DataRow Row = dataRowView != null ? dataRowView.Row : null; string imageNameNew = string.Empty; if (Row != null && Row.Table.Columns.Contains("pic")) { imageNameNew = Row["pic"] + ""; } if (imageList.Images.ContainsKey(Path.GetFileNameWithoutExtension(imageNameNew + ""))) { int subscript = imageList.Images.Keys.IndexOf(Path.GetFileNameWithoutExtension(imageNameNew + "")); Nodes.ImageIndex = subscript; //未选中状态图标 Nodes.SelectImageIndex = subscript;//选中状态图标 } else { //if (imageList.Images.ContainsKey("treeViewDefault")) // Nodes.StateImageKey = "treeViewDefault"; } } catch (Exception) { if (imageList.Images.ContainsKey("treeViewDefault")) { int subscript = imageList.Images.IndexOfKey("treeViewDefault"); Nodes.ImageIndex = subscript; //未选中状态图标 Nodes.SelectImageIndex = subscript;//选中状态图标 } } //当前节点的子节点 if (recursion) { //当前节点的子节点 foreach (TreeListNode node in Nodes.Nodes) { if (node.ImageIndex != 0 || node.SelectImageIndex != 0) break; SettingIcon(imageList, node); } } } /// /// 图片转换成字节流 /// /// 要转换的Image对象 /// 转换后返回的字节流 public static byte[] ImgToByte(Image img) { try { using (MemoryStream ms = new MemoryStream()) { byte[] imagedata = null; img.Save(ms, System.Drawing.Imaging.ImageFormat.Png); imagedata = ms.GetBuffer(); return imagedata; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); return null; } } /// /// 附件转换二进制数据(用于保存数据库) /// /// 附件路径 /// 二进制 private string fileConvertByte(string filePath) { byte[] bytContent = null; System.IO.FileStream fs = null; System.IO.BinaryReader br = null; try { fs = new FileStream(filePath, System.IO.FileMode.Open); } catch { } if (fs != null) br = new BinaryReader((Stream)fs); if (br != null) bytContent = br.ReadBytes((Int32)fs.Length); if (fs != null) fs.Dispose(); return Convert.ToBase64String(bytContent); } /// /// 附件转换byte[] /// /// 附件路径 /// 二进制 private byte[] ConvertFileToBytes(string filePath) { byte[] bytContent = null; System.IO.FileStream fs = null; System.IO.BinaryReader br = null; try { fs = new FileStream(filePath, System.IO.FileMode.Open); } catch (Exception) { throw; } finally { if (fs != null) br = new BinaryReader((Stream)fs); if (br != null) bytContent = br.ReadBytes((Int32)fs.Length); if (fs != null) fs.Dispose(); } return bytContent; } /// /// 判断上传文件表格是否存在 /// private bool CheckUploadFilesTable() { try { //日志表列名 Dictionary colDic = new Dictionary(); colDic.Add("name", "varchar(500)"); colDic.Add("CreationTime", "varchar(500)"); colDic.Add("type", "varchar(500)"); colDic.Add("fileSize", "varchar(500)"); colDic.Add("author", "varchar(500)"); //colDic.Add("title", "varchar(500)"); colDic.Add("absolutePath", "varchar(2000)"); string isExitApiTab = "select top 1 * from sysObjects where Id=OBJECT_ID(N'P_UploadFilesTab') and xtype='U'"; DataTable apiTab = SqlHelper.ExecuteDataTable(isExitApiTab); if (apiTab.Rows.Count > 0)//存在日志表 { DataTable columnsTab = SqlHelper.ExecuteDataTable(string.Format("select name from syscolumns where id=object_id('P_UploadFilesTab')")); foreach (KeyValuePair colunmField in colDic) { DataRow[] dataRows = columnsTab.Select().Where(n => (n["name"] + "").Equals(colunmField.Key)).ToArray(); if (dataRows.Length == 0) { string addColSql = string.Format("alter table P_UploadFilesTab add {0} {1}", colunmField.Key, colunmField.Value); SqlHelper.ExecuteNonQuery(addColSql);//添加列 } } } else { string createTabSql = "create table P_UploadFilesTab(id int IDENTITY(1,1) NOT NULL,{0})"; string createCol = string.Empty; foreach (KeyValuePair colunmField in colDic) { createCol += string.Format("{0} {1},", colunmField.Key, colunmField.Value); } createTabSql = string.Format(createTabSql, createCol.TrimEnd(',')); SqlHelper.ExecuteNonQuery(createTabSql);//创建表 } return true; } catch (Exception) { return false; } } /// /// 获取文件大小的显示字符串 /// /// /// public static string BytesToReadableValue(double number) { double last = 1; for (int i = 0; i < suffixes.Length; i++) { var current = Math.Pow(1024, i + 1); var temp = number / current; if (temp < 1) { return (number / last).ToString("n2") + suffixes[i]; } last = current; } return number.ToString(); } #region /// /// 说明:模块点击 /// 创建人:龚宇超 /// 创建日期:2018-11-12 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The sender. /// The instance containing the event data. private void OnModuleClick(object sender, EventArgs e) { try { try { WaitForm.ShowForm(); SimpleButton button = sender as SimpleButton; if (button != null) { if (button.Tag is GridRightMenuModel) { GridRightMenuModel model = button.Tag as GridRightMenuModel; BaseRightMenu menu = new BaseRightMenu(); menu.Model = this.Model; DataTable dataTable = this.treeLeft.GridControl.DataSourceTable(); DataRow dataRow = null; if (dataTable != null) { dataRow = this.treeLeft.GetViewFocusedDataRow(); } if (menu.ExecRightMenu(model, new DataRow[] { dataRow }) && model.Refresh) { this.SearchMainObj.SearchLastGrid(); BingingListViewSelectImage(); } //BaseRightMenu menu = new BaseRightMenu(); //menu.Model = this.mrpDyncModel; //menu.ControlObj = this; //if (menu.ExecRightMenu(model, new DataRow[] { null }) && model.Refresh) //{ // this.SearchLastGrid(); //} } } } catch (Exception ex) { //MessageUtil.Show(ex); string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message, ex.Message); } finally { WaitForm.HideForm(); } } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message, ex.Message); } } /// /// 树节点改变时 /// /// /// private void OnFocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e) { this.RefWaitFields(); this.RefurbishDetail(); } /// /// 选中行颜色 /// /// /// private void OnCustomDrawNodeCell(object sender, DevExpress.XtraTreeList.CustomDrawNodeCellEventArgs e) { try { if (e.Node == this.treeLeft.TreeListObj.FocusedNode) e.Appearance.BackColor = ColorTranslator.FromHtml("#9feb6a"); } catch (Exception) { } } /// /// 分隔条位置改变 /// /// /// private void OnSplitterPositionChanged(object sender, EventArgs e) { if (sender == this.splitLeftControl) { IniHelper.Write(string.Format("Step_spliterPositionLeft_{0}", this.Model.ModuleCode), this.splitLeftControl.SplitterPosition + ""); } else if (sender == this.splitMainControl) { IniHelper.Write(string.Format("Step_spliterPositionMain_{0}", this.Model.ModuleCode), this.splitMainControl.SplitterPosition + ""); } else if (sender == this.splitRightControl) { IniHelper.Write(string.Format("Step_spliterPositionRight_{0}", this.Model.ModuleCode), this.splitRightControl.SplitterPosition + ""); } else if (sender == this.splitBottomControl) { IniHelper.Write(string.Format("Step_spliterPositionbottom_{0}", this.Model.ModuleCode), this.splitBottomControl.SplitterPosition + ""); } } /// /// 上方点击时禁用下方拖拽状态 /// /// /// private void OnGm_OperateMouseDown(object sender, MouseEventArgs e) { this.gm_Operate.GridControl.AllowDrop = false; this.nDragGrid.Draging = false; DataTable gmRightDataTable = this.gmRight_Control.GridControl.DataSourceTable(); if (this.RenameGridDragGrid.isAllowDrag) { this.RenameGridDragGrid.isAllowDrag = gmRightDataTable != null && gmRightDataTable.Rows.Count > 0; } } /// /// 下方点击时改变上方拖拽状态 /// /// /// private void OnGm_ControlMouseDown(object sender, EventArgs e) { this.dragGrid.Draging = false; this.gm_Control.GridControl.AllowDrop = false; this.gmRight_Control.GridControl.AllowDrop = false; DataRow Row = this.gm_Control.GetViewFocusedDataRow(); bool isDrag = ReplaceHelper.ReplaceRowParamCond(Row, gridDetailModel.SystemModel.DragCond); this.GmGridDragGrid.isAllowDrag = isDrag; this.nDragGrid.isAllowDrag = isDrag; } /// /// 下方选中行刷新明细 /// /// /// private void OnGridView_FocusedRowObjectChanged(object sender, FocusedRowObjectChangedEventArgs e) { GridView gridView = (GridView)sender; DataRow rowItem = gridView.GetFocusedDataRow(); if (gridDetailRightModel != null) { string searchSql = this.GetSearchSql(gridDetailRightModel, rowItem); DataTable table = MainImpl.GetDataTableResult(searchSql); this.gmRight_Control.LastSearchSql = searchSql; this.gmRight_Control.SetGridViewDataSource(table); } } #endregion /// /// 清空条件框内容后禁用弹窗 /// public void ForbiddenPopup() { foreach (ControlModel model in this.SearchMainObj.ControlModels) { BaseUserControl control = this.SearchMainObj.FindControl(model); if (control != null && model.FieldType != ControlType.LabTreeType) { control.EditText = string.Empty; control.Model.Text = string.Empty; switch (model.FieldType) { case ControlType.LabAutoCompleteValue: case ControlType.LabAutoCompleteText: case ControlType.LabAutoCompleteValueParam: case ControlType.LabAutoCompleteTextParam: if (!this.SearchMainObj.isRevTextEdit) { LabelAutoTextEdit autoTextEdit = control as LabelAutoTextEdit; autoTextEdit.TextEdit.HidePopup(); } else { LabelAutoTextRevEdit autoTextEdit = control as LabelAutoTextRevEdit; autoTextEdit.TextEdit.HidePopup(); } break; default: break; } } } } private void TextEdit_Click(object sender, EventArgs e) { if (sender is AutoGridLookUp) { AutoGridLookUp agl = sender as AutoGridLookUp; if (!agl.AutoShowPopup) { agl.AutoShowPopup = true; agl.Focus(); } } } } }