ab56a9bcf7
SVN-Revision: r240
1288 lines
51 KiB
C#
1288 lines
51 KiB
C#
using DevExpress.Data;
|
|
using DevExpress.Utils.Menu;
|
|
using DevExpress.XtraEditors;
|
|
using DevExpress.XtraEditors.Repository;
|
|
using DevExpress.XtraGrid.Columns;
|
|
using DevExpress.XtraGrid.Menu;
|
|
using DevExpress.XtraGrid.Views.Grid;
|
|
using DevExpress.XtraTreeList;
|
|
using DevExpress.XtraTreeList.Nodes;
|
|
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.Util;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Lskj.PubUserTomodule
|
|
{
|
|
public partial class FrmPermissionSetting : BaseForm
|
|
{
|
|
|
|
|
|
|
|
#region 私有字段
|
|
/// <summary>
|
|
/// 复选框字段名称
|
|
/// </summary>
|
|
private string _checkFieldName = "_check";
|
|
/// <summary>
|
|
/// The _id
|
|
/// </summary>
|
|
private string _id = "_id";
|
|
#endregion
|
|
#region 公有字段
|
|
/// <summary>
|
|
/// 数据源
|
|
/// </summary>
|
|
/// <value>The data source.</value>
|
|
public DataTable DataSource
|
|
{
|
|
get
|
|
{
|
|
return this.gridControl1.DataSourceTable();
|
|
}
|
|
set
|
|
{
|
|
this.gridControl1.DataSource = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 控件类型
|
|
/// </summary>
|
|
/// <value>The type.</value>
|
|
public int IsType { get; set; }
|
|
/// <summary>
|
|
/// 绑定ValueMember
|
|
/// </summary>
|
|
public string ValueMember { get; set; }
|
|
/// <summary>
|
|
/// 隐藏值字段
|
|
/// </summary>
|
|
public string ValueField { get; set; }
|
|
/// <summary>
|
|
/// 显示值字段
|
|
/// </summary>
|
|
public string TextField { get; set; }
|
|
/// <summary>
|
|
/// 备注字段
|
|
/// </summary>
|
|
public string RemarkField = "remark";
|
|
/// <summary>
|
|
/// 数据源
|
|
/// </summary>
|
|
/// <value>The source SQL.</value>
|
|
public string SourceSQL { get; set; }
|
|
/// <summary>
|
|
/// 隐藏值
|
|
/// </summary>
|
|
/// <value>The edit value.</value>
|
|
//public string EditValue { get; set; }
|
|
/// <summary>
|
|
/// 显示值
|
|
/// </summary>
|
|
/// <value>The edit text.</value>
|
|
//public string EditText { get; set; }
|
|
/// <summary>
|
|
/// CurrentOperColumnKey值
|
|
/// </summary>
|
|
/// <value>The data source.</value>
|
|
public string CurrentOperColumnKey = string.Empty;
|
|
/// <summary>
|
|
/// CurrentOperModel值
|
|
/// </summary>
|
|
/// <value>The data source.</value>
|
|
public GridColumnModel CurrentOperModel = null;
|
|
/// <summary>
|
|
/// 配置的关联ModuleCodel值
|
|
/// </summary>
|
|
/// <value>The Union ModuleCodel.</value>
|
|
public string UnionModuleCodel;
|
|
/// <summary>
|
|
/// 左侧树数据
|
|
/// </summary>
|
|
public DataRow LeftRowObj;
|
|
/// <summary>
|
|
/// 系统模块实体对象
|
|
/// </summary>
|
|
/// <value>The system model.</value>
|
|
public ModuleModel SysModel { get; private set; }
|
|
/// <summary>
|
|
/// 分割条位置
|
|
/// </summary>
|
|
public int PositionSplitter;
|
|
/// <summary>
|
|
/// 分割条位置
|
|
/// </summary>
|
|
public int WindowHeight;
|
|
/// <summary>
|
|
/// 选中人员id
|
|
/// </summary>
|
|
public string employeeId;
|
|
/// <summary>
|
|
/// 选中人员的编辑权限
|
|
/// </summary>
|
|
public List<string> EditPurview;
|
|
/// <summary>
|
|
/// 选中人员的只读权限
|
|
/// </summary>
|
|
public List<string> ReadPurview;
|
|
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 点击确定事件,把当前的选中的模块编号传出去
|
|
/// </summary>
|
|
/// <param name="sender">The sender.</param>
|
|
public event ClickTheOKButton onClickTheOKButton;
|
|
public delegate void ClickTheOKButton(List<string> EditPurview, List<string> ReadPurview);
|
|
|
|
|
|
public FrmPermissionSetting(string editPurview, string readPurview)
|
|
{
|
|
InitializeComponent();
|
|
this.gcMain.OptionsBehavior.EditorShowMode = DevExpress.Utils.EditorShowMode.MouseDown;
|
|
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.OnFormClosing);
|
|
//this.gcMain.GridControl.ContextMenuStrip = contextMenuStrip1;
|
|
//this.ModuleGridObj.GridControlObj.GridView.PopupMenuShowing += new DevExpress.XtraGrid.Views.Grid.PopupMenuShowingEventHandler(this.OnGridViewPopupMenuShowing);
|
|
this.gcMain.DoubleClick += new EventHandler(OnRowCellClick);
|
|
this.gcDetail.DoubleClick += new EventHandler(OnDoubleClick);
|
|
GridDragGrid dragGrid = new GridDragGrid(this.gcMain, this.gcDetail);
|
|
GridDragGrid backdragGrid = new GridDragGrid(this.gcDetail, this.gcMain);
|
|
//加载复选框
|
|
GridDragGrid.GridAddCheckBox(this.gcMain);
|
|
GridDragGrid.GridAddCheckBox(this.gcDetail);
|
|
|
|
this.gcDetail.OptionsSelection.EnableAppearanceFocusedCell = false;
|
|
this.Resize += new System.EventHandler(maximization);
|
|
this.splitMain_Right.SplitterMoved += new EventHandler(PositionChange);
|
|
|
|
EditPurview = editPurview.Trim().TrimEnd(',').Split(',').ToList();
|
|
ReadPurview = readPurview.Trim().TrimEnd(',').Split(',').ToList();
|
|
|
|
InitControls();
|
|
|
|
this.gcMain.OptionsBehavior.EditorShowMode = DevExpress.Utils.EditorShowMode.MouseDown;
|
|
this.gcDetail.OptionsBehavior.EditorShowMode = DevExpress.Utils.EditorShowMode.MouseDown;
|
|
}
|
|
|
|
#region 方法
|
|
|
|
|
|
#region 上方数据勾选,下方增加
|
|
public void AccessPermissions(DataRow rowItem, string Editflag = "1", string Readflag = "1")
|
|
{
|
|
//rowItem["Editflag"] = Editflag;
|
|
//rowItem["Readflag"] = Readflag;
|
|
string menuid = rowItem["MenuId"] + "";
|
|
this.EditPurview.Add(menuid);
|
|
//this.ReadPurview.Add(menuid);
|
|
DataTable gcDetailDt = this.gridControl2.DataSource as DataTable;
|
|
//gcDetailDt.Rows.Add(rowItem.ItemArray);
|
|
DataRow row = gcDetailDt.NewRow();
|
|
foreach (DataColumn col in row.Table.Columns)
|
|
{
|
|
row[col.ColumnName] = rowItem[col.ColumnName];
|
|
}
|
|
gcDetailDt.Rows.InsertAt(row, 0);
|
|
DataTable gcMainDt = this.gridControl1.DataSource as DataTable;
|
|
gcMainDt.Rows.Remove(rowItem);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 下方数据删除,上方取消勾选
|
|
public void RemovePermissions(DataRow rowItem, string Editflag = "0", string Readflag = "0")
|
|
{
|
|
|
|
//rowItem["Editflag"] = Editflag;
|
|
//rowItem["Readflag"] = Readflag;
|
|
string menuid = rowItem["MenuId"] + "";
|
|
this.EditPurview.Remove(menuid);
|
|
this.ReadPurview.Remove(menuid);
|
|
DataTable gcMainDt = this.gridControl1.DataSource as DataTable;
|
|
gcMainDt.Rows.Add(rowItem.ItemArray);
|
|
DataTable gcDetailDt = this.gridControl2.DataSource as DataTable;
|
|
gcDetailDt.Rows.Remove(rowItem);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 设置分割条位置
|
|
/// <summary>
|
|
/// <para>说明:设置分割条位置</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-07-21 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
protected void InitlizeSpiltLocation()
|
|
{
|
|
try
|
|
{
|
|
string width = IniHelper.Read(string.Format("base_width_{0}", this.UnionModuleCodel));//通过Key获取Value值
|
|
if (!string.IsNullOrEmpty(width))
|
|
{
|
|
this.splitMain.SplitterPosition = Convert.ToInt32(width);
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
MessageUtil.Show(ex);
|
|
}
|
|
}
|
|
#endregion
|
|
#region 保存表格属性
|
|
/// <summary>
|
|
/// <para>说明:保存表格属性</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-07-20 </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 virtual void SaveItemClick(object sender, EventArgs e)
|
|
{
|
|
DataRow rowItem = null;
|
|
bool success = BaseImpl.HasExistsDataRow(ResourceKeys.SettingTableName, "formKey", CurrentOperColumnKey, string.Format(" and OperatorId='{0}' ", ERPInfo.Instance.UserId), out rowItem);
|
|
if (!success)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.NotFoundSettingColumnTable);
|
|
return;
|
|
}
|
|
|
|
if (MessageUtil.Show(ResourceKeys.IsSaveColumn, MessageBoxButtons.YesNo) == DialogResult.Yes)
|
|
{
|
|
try
|
|
{
|
|
if (rowItem == null)
|
|
{
|
|
success = this.gcMain.SaveCustomColumnToDatabase(this.CurrentOperColumnKey);
|
|
}
|
|
else
|
|
{
|
|
success = this.gcMain.UpdateCustomColumnToDatabase(this.CurrentOperColumnKey);
|
|
}
|
|
this.SetDetailDataSource();
|
|
MessageUtil.Show(success ? ResourceKeys.SaveSuccess : ResourceKeys.SaveFault);
|
|
}
|
|
catch (SqlException sex)
|
|
{
|
|
if (sex.Message.Contains(ResourceKeys.FieldLenIsShort) &&
|
|
MessageUtil.Show(ResourceKeys.SaveFault + "\r\n" + ResourceKeys.CanUpgradeTable, MessageBoxButtons.YesNo) == DialogResult.Yes &&
|
|
BaseImpl.UpdateTableField(ResourceKeys.SettingTableName, "formKey", "varchar(200)"))
|
|
{
|
|
MessageUtil.Show(ResourceKeys.UpdateSuccess);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
LogUtil.WriteError("保存表格属性出错", ex);
|
|
MessageUtil.Show(ex);
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
#region 设置明细数据源
|
|
/// <summary>
|
|
/// <para>说明:设置明细数据源</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-07-20 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void SetDetailDataSource()
|
|
{
|
|
DataTable table = this.DataSource.Copy();
|
|
DataRow[] rows = table.Select(_checkFieldName + "=True");
|
|
|
|
if (rows != null && rows.Length > 0)
|
|
this.gcDetail.GridControl.DataSource = rows.CopyToDataTable();
|
|
else
|
|
{
|
|
this.gcDetail.GridControl.DataSource = table;
|
|
this.gcDetail.GridControl.DataSourceTable().Clear();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 获取选中行数据
|
|
/// <summary>
|
|
/// <para>说明:获取选中行数据</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-07-20 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>DataRow[].</returns>
|
|
public DataRow[] GetViewFocusedDataRows(GridView gridView)
|
|
{
|
|
int[] rows = gridView.GetSelectedRows();
|
|
DataRow[] dataRows = new DataRow[rows.Length];
|
|
for (int i = 0; i < rows.Length; i++)
|
|
{
|
|
dataRows[i] = gridView.GetDataRow(rows[i]);
|
|
}
|
|
return dataRows;
|
|
}
|
|
#endregion
|
|
#region 刷新左侧树数据
|
|
/// <summary>
|
|
/// <para>说明:设置左侧树数据</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-07-21 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
protected void SetLeftTreeView()
|
|
{
|
|
|
|
//this.treeLeft.TreeNodeKeyField = "id";
|
|
//this.treeLeft.TreeNodeTextField = "menucaption";
|
|
//this.treeLeft.TreeNodeSelectAfter += new TreeViewEventHandler(OnTreeLeftTreeNodeSelected);
|
|
|
|
this.treeLeft.OptionsBehavior.EnableFiltering = true;
|
|
this.treeLeft.OptionsView.ShowAutoFilterRow = true;
|
|
this.treeLeft.OptionsBehavior.Editable = false; //treelist不可编辑
|
|
|
|
|
|
string sqlValue = @" WITH tmenu(id,MenuCaption,ParentId,menuid,SubSysId,level)
|
|
as
|
|
(
|
|
SELECT convert(varchar(50), menu.SubSysId)+'_'+ MenuStruct id,MenuCaption,CONVERT(varchar(50), -CONVERT(int, menu.SubSysId)) ParentId,menu.menuid,menu.SubSysId,1 level FROM p_formmenuconfigtab menu
|
|
inner join P_SubSystemTab sub on menu.SubSysId=sub.SubSysId and LEN(menustruct)=2
|
|
UNION ALL
|
|
SELECT convert(varchar(50), a.SubSysId)+'_'+A.MenuStruct id, A.MenuCaption,CONVERT(varchar(50),convert(varchar(50), a.SubSysId)+'_'+ SUBSTRING(a.MenuStruct,1,case when LEN(a.MenuStruct)>2 then LEN(a.MenuStruct)-2 else 0 end)) ParentId,a.MenuId,a.SubSysId ,b.level+1 FROM p_formmenuconfigtab A,tmenu b
|
|
where LEN(a.MenuStruct)>2 and convert(varchar(50), a.SubSysId)+'_'+ SUBSTRING(a.MenuStruct,1,case when LEN(a.MenuStruct)>2 then LEN(a.MenuStruct)-2 else 0 end) = b.id and a.SubSysId=b.SubSysId and LEN(A.menustruct)=2
|
|
)
|
|
select tm.MenuId, lm.id id,tm.urlparams menucode,tm.MenuCaption,tm.DllFileName library,lm.ParentId parentId,tm.SubSysId, lm.level,'' readflag, '' writeflag
|
|
from tmenu lm
|
|
left join p_formmenuconfigtab tm on lm.menuid=tm.menuid
|
|
union all
|
|
select '' menuid,convert(varchar(10), -SubSysId) MenuStruct ,'' menucode,subsysname MenuCaption,'' library,'' parentid,SubSysId,0 level,'' editflag, '' Readflag from P_SubSystemTab
|
|
ORDER BY SubSysId,id";
|
|
|
|
//this.treeLeft.BindTreeView(BaseImpl.GetDataTableResult(sql));
|
|
DataTable treeTable = SqlHelper.ExecuteDataTable(sqlValue);
|
|
DataTable dataTable = new DataTable();
|
|
dataTable.Columns.Add("id");
|
|
dataTable.Columns.Add("parentId");
|
|
dataTable.Columns.Add("Caption");
|
|
dataTable.Columns.Add("MenuId");
|
|
List<string> idlist = new List<string>();
|
|
for (int i = 0; i < treeTable.Rows.Count; i++)
|
|
{
|
|
DataRow newRow = dataTable.NewRow();
|
|
newRow["parentId"] = treeTable.Rows[i]["parentId"];
|
|
newRow["Caption"] = treeTable.Rows[i]["MenuCaption"];
|
|
newRow["MenuId"] = treeTable.Rows[i]["menucode"];
|
|
if (idlist.Contains(treeTable.Rows[i]["id"] + ""))
|
|
{
|
|
newRow["id"] = treeTable.Rows[i]["id"] + "" + '-' + i;
|
|
idlist.Add(newRow["id"] + "");
|
|
}
|
|
else
|
|
{
|
|
newRow["id"] = treeTable.Rows[i]["id"];
|
|
idlist.Add(newRow["id"] + "");
|
|
}
|
|
dataTable.Rows.Add(newRow);
|
|
}
|
|
this.treeLeft.DataSource = dataTable;
|
|
this.treeLeft.KeyFieldName = "id";
|
|
this.treeLeft.ParentFieldName = "parentId";
|
|
this.treeLeft.Columns[0].OptionsColumn.AllowEdit = false;
|
|
this.treeLeft.Columns[1].OptionsColumn.AllowEdit = false;
|
|
this.treeLeft.Columns[1].Visible = false;
|
|
this.treeLeft.ExpandToLevel(0);
|
|
this.treeLeft.OptionsBehavior.AllowIndeterminateCheckState = true;
|
|
this.treeLeft.FocusedNodeChanged += OnLeftTree_AfterCheckNode;
|
|
//this.treeLeft.BeforeCheckNode += OnLeftTree_BeforeCheckNode;
|
|
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:树节点点击后刷新数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-10-26 </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>
|
|
private void OnLeftTree_AfterCheckNode(object sender, FocusedNodeChangedEventArgs e)
|
|
{
|
|
//SetCheckedChildNodes(e.Node, e.Node.CheckState);
|
|
//SetCheckedParentNodes(e.Node, e.Node.CheckState);
|
|
|
|
|
|
DataTable Alldt = new DataTable();
|
|
string id = e.Node.GetValue("id").ToString();
|
|
if (id.Contains("_"))
|
|
{
|
|
string subsysid = id.Split('_')[0];
|
|
string menustruct = id.Split('_')[1];
|
|
string sql = string.Format("select MenuId,MenuCaption, '0' as Editflag ,'0' as Readflag from P_FormMenuConfigTab where subsysid='{0}' and left(menustruct,2)='{1}' and useFlag=1 order by menustruct ", subsysid, menustruct);
|
|
Alldt = SqlHelper.ExecuteDataTable(sql);
|
|
}
|
|
else
|
|
{
|
|
string subsysid = id.Split('_')[0];
|
|
string sql = string.Format("select MenuId,MenuCaption,'0' as Editflag ,'0' as Readflag from P_FormMenuConfigTab where subsysid='{0}' and useFlag=1 order by menustruct ", subsysid);
|
|
Alldt = SqlHelper.ExecuteDataTable(sql);
|
|
}
|
|
|
|
string menuid = string.Empty;
|
|
|
|
DataTable HasBeenSetDt = Alldt.Clone();//已有权限的模块
|
|
List<string> primaryKeys = new List<string>();
|
|
DataTable IsNotSetDt = Alldt.Clone();//没有权限的模块
|
|
for (int i = 0; i < Alldt.Rows.Count; i++)
|
|
{
|
|
menuid = Alldt.Rows[i]["menuid"] + "";
|
|
if (string.IsNullOrWhiteSpace(menuid)) continue;
|
|
//if (EditPurview.Contains(menuid)) Alldt.Rows[i]["Editflag"] = "1";
|
|
//if (ReadPurview.Contains(menuid)) Alldt.Rows[i]["Readflag"] = "1";
|
|
|
|
|
|
//判断已有的操作权限和只读权限中是否有当前模块id
|
|
if (EditPurview.Contains(menuid) || ReadPurview.Contains(menuid))
|
|
{
|
|
HasBeenSetDt.Rows.Add(Alldt.Rows[i].ItemArray);
|
|
primaryKeys.Add(Alldt.Rows[i]["menuid"] + "");
|
|
}
|
|
else
|
|
{
|
|
IsNotSetDt.Rows.Add(Alldt.Rows[i].ItemArray);
|
|
}
|
|
}
|
|
this.gridControl1.DataSource = Alldt;
|
|
|
|
|
|
DataTable gcMainDt = this.gridControl1.DataSource as DataTable;
|
|
for (int i = 0; i < gcMainDt.Rows.Count; i++)
|
|
{
|
|
if (primaryKeys.Contains(gcMainDt.Rows[i]["MenuId"] + "")) this.gcMain.SelectRow(i);
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
// <summary>
|
|
/// <para>说明:点击树表格节点前事件</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-09-22 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
|
private void OnLeftTree_BeforeCheckNode(object sender, DevExpress.XtraTreeList.CheckNodeEventArgs e)
|
|
{
|
|
e.State = (e.PrevState == CheckState.Checked ? CheckState.Unchecked : CheckState.Checked);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <para>说明:加载主表格数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-31 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="where">The where key.</param>
|
|
protected void SetMainGridView(string where = "")
|
|
{
|
|
//string sqlValue = ReplaceHelper.ReplaceWhereCond(this.SysModel.MenuSql);
|
|
//sqlValue = this.SysModel.MenuSql.StartsWith("select", StringComparison.OrdinalIgnoreCase) ? sqlValue + where : sqlValue;
|
|
//if (IsExcel && !string.IsNullOrEmpty(this._labPicName))
|
|
//{
|
|
// string sql = MainImpl.GetDefaultValue(sqlValue, this.ModuleGridObj.ParentKeyField, Model.OtherParams());
|
|
// DataTable dt = MainImpl.GetDataTableResult(ReplaceLeftOrGridValue(sql));
|
|
// if (dt.Rows.Count > 0)
|
|
// {
|
|
// this._currentRow = dt.Rows[0];
|
|
// Byte[] file = (byte[])this._currentRow[this._labPicName];
|
|
// if (file.Length <= 0)
|
|
// {
|
|
// this.excelControlEx1.SpreadSheetBarObj.Control.CreateNewDocument();
|
|
// }
|
|
// else
|
|
// {
|
|
// if (!string.IsNullOrEmpty(this.excelControlEx1.CurrentPath) && File.Exists(this.excelControlEx1.CurrentPath))
|
|
// {
|
|
// File.Delete(this.excelControlEx1.CurrentPath);
|
|
// }
|
|
// this.excelControlEx1.LoadFileSteam(file);
|
|
// }
|
|
// }
|
|
// else
|
|
// {
|
|
// this.excelControlEx1.SpreadSheetBarObj.Control.CreateNewDocument();
|
|
// MessageUtil.Show(ResourceKeys.NotConfigExcel);
|
|
// }
|
|
//}
|
|
//else
|
|
//{
|
|
// // 左侧gridView时,需要替换sql参数(包含查询条件、表格选中行).
|
|
// if (this.gridLeft.Visible)
|
|
// {
|
|
// sqlValue = this._leftGridSearchObj != null ? this._leftGridSearchObj.ReplaceParentControlValue(sqlValue) : sqlValue;
|
|
// sqlValue = ReplaceHelper.ReplaceRowParam(this.gridLeft.GridView.GetFocusedDataRow(), sqlValue);
|
|
// }
|
|
|
|
// this.ModuleGridObj.SearchObj.SearchGrid(sqlValue);
|
|
// if (!this.IsDragDetail)
|
|
// this.ModuleGridDetailObj.SetDetailGridDataSource();
|
|
//}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 点击二级目录,加载具体模块
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnGridLeftGridViewClick(object sender, EventArgs e)
|
|
{
|
|
DataRow mSelectRow = this.gridLeft.GridView.GetFocusedDataRow();
|
|
if (mSelectRow != null)
|
|
{
|
|
string sql = string.Format("select MenuId,MenuCaption, '0' as Editflag ,'0' as Readflag from P_FormMenuConfigTab where subsysid='{0}' and left(menustruct,2)='{1}' and menustruct!='{1}' and useFlag='1' order by menustruct ", mSelectRow["subsysid"] + "", mSelectRow["menustruct"] + "");
|
|
DataTable Alldt = SqlHelper.ExecuteDataTable(sql);
|
|
|
|
string menuid = string.Empty;
|
|
DataTable HasBeenSetDt = Alldt.Clone();//已有权限的模块
|
|
List<string> primaryKeys = new List<string>();
|
|
DataTable IsNotSetDt = Alldt.Clone();//没有权限的模块
|
|
for (int i = 0; i < Alldt.Rows.Count; i++)
|
|
{
|
|
menuid = Alldt.Rows[i]["menuid"] + "";
|
|
if (string.IsNullOrWhiteSpace(menuid)) continue;
|
|
//判断已有的操作权限和只读权限中是否有当前模块id
|
|
if (EditPurview.Contains(menuid) || ReadPurview.Contains(menuid))
|
|
{
|
|
HasBeenSetDt.Rows.Add(Alldt.Rows[i].ItemArray);
|
|
primaryKeys.Add(Alldt.Rows[i]["menuid"] + "");
|
|
}
|
|
else
|
|
{
|
|
IsNotSetDt.Rows.Add(Alldt.Rows[i].ItemArray);
|
|
}
|
|
}
|
|
|
|
this.gridControl1.DataSource = IsNotSetDt;
|
|
this.gridControl2.DataSource = HasBeenSetDt;
|
|
|
|
}
|
|
}
|
|
#endregion
|
|
#region 创建界面
|
|
/// <summary>
|
|
/// <para>说明:创建界面</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-07-21 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="menuCode">The menu code.</param>
|
|
public void InitControls()
|
|
{
|
|
|
|
this.gcDetail.OptionsView.ColumnAutoWidth = true;
|
|
this.gcMain.OptionsView.ColumnAutoWidth = true;
|
|
PositionSplitter = this.splitMain_Right.SplitterPosition;
|
|
WindowHeight = this.Height;
|
|
//this.pl_left_top.Visible = false;
|
|
this.gridLeft.Visible = true;
|
|
this.treeLeft.Visible = false;
|
|
this.InitlizeSpiltLocation();//设置分割条位置
|
|
|
|
|
|
|
|
GridColumn treeListColumnName = new GridColumn();
|
|
treeListColumnName.Caption = "系统名称";
|
|
treeListColumnName.FieldName = "MenuCaption";
|
|
treeListColumnName.MinWidth = 38;
|
|
treeListColumnName.Visible = true;
|
|
treeListColumnName.VisibleIndex = 0;
|
|
treeListColumnName.Width = 300;
|
|
|
|
GridColumn treeListColumnMenuId = new GridColumn();
|
|
treeListColumnMenuId.Caption = "菜单id";
|
|
treeListColumnMenuId.FieldName = "MenuId";
|
|
treeListColumnMenuId.Visible = true;
|
|
treeListColumnMenuId.VisibleIndex = 1;
|
|
|
|
GridColumn treeListColumnReadflag = new GridColumn();
|
|
RepositoryItemCheckEdit checkEdit = new RepositoryItemCheckEdit();
|
|
checkEdit.ValueChecked = "1";
|
|
checkEdit.ValueUnchecked = "0";
|
|
checkEdit.ValueGrayed = 3;
|
|
treeListColumnReadflag.ColumnEdit = checkEdit;
|
|
treeListColumnReadflag.Caption = "只读权限";
|
|
treeListColumnReadflag.FieldName = "Readflag";
|
|
treeListColumnReadflag.Name = "treeListColumnReadflagValue";
|
|
treeListColumnReadflag.Visible = true;
|
|
treeListColumnReadflag.VisibleIndex = 3;
|
|
|
|
GridColumn treeListColumnEditflag = new GridColumn();
|
|
treeListColumnEditflag.ColumnEdit = checkEdit;
|
|
treeListColumnEditflag.Caption = "操作权限";
|
|
treeListColumnEditflag.FieldName = "Editflag";
|
|
treeListColumnEditflag.Name = "treeListColumnEditflagValue";
|
|
treeListColumnEditflag.Visible = true;
|
|
treeListColumnEditflag.VisibleIndex = 2;
|
|
|
|
this.gcMain.Columns.AddRange(new GridColumn[] {
|
|
treeListColumnName,
|
|
treeListColumnMenuId
|
|
});
|
|
|
|
this.gcDetail.Columns.AddRange(new GridColumn[] {
|
|
treeListColumnName,
|
|
treeListColumnMenuId,
|
|
});
|
|
|
|
//SetExistingPermissions(); //设置已有权限
|
|
//this.SetLeftTreeView();//设置左侧树数据
|
|
|
|
|
|
//this.gcDetail.RowCellClick += new RowCellClickEventHandler(gridControlChange);//已有权限改变事件
|
|
this.SettingOperationRights.Click += new EventHandler(OnSettingOperationRightsClick);
|
|
this.SetRemovePermissions.Click += new EventHandler(OnRemovePermissionsClick);
|
|
this.butMenuOperationPermission.Click += ButMenuAllPermissions_Click;
|
|
this.butAllOperation.Click += butAllOperation_Click;
|
|
this.btnOk.Click += new EventHandler(OnbtnOkClick);
|
|
this.btnCancel.Click += new EventHandler(btnCancel_Click);
|
|
SetLevelOneDirectory();
|
|
this.PrimaryDirectory.SelectedValueChanged += new EventHandler(PrimaryDirectoryValueChanged);
|
|
this.gridLeft.GridView.Click += new EventHandler(OnGridLeftGridViewClick);
|
|
this.PrimaryDirectory.SelectedIndex = 0;
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 获得三级目录下所有的操作权限
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void butAllOperation_Click(object sender, EventArgs e)
|
|
{
|
|
DataTable dataTable = gridControl1.DataSource as DataTable;
|
|
foreach (DataRow item in dataTable.Rows)
|
|
{
|
|
string menuid = item["menuid"] + "";
|
|
if (!EditPurview.Contains(menuid)) EditPurview.Add(menuid);
|
|
}
|
|
//刷新页面
|
|
OnGridLeftGridViewClick(null, null);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获得二级目录下所有的操作权限
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void ButMenuAllPermissions_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
DataTable dataTable = gridLeft.GridControl.DataSource as DataTable;
|
|
//循环全部二级目录,查询对应的三级目录
|
|
foreach (DataRow item in dataTable.Rows)
|
|
{
|
|
string sql = string.Format("select MenuId,MenuCaption, '0' as Editflag ,'0' as Readflag from P_FormMenuConfigTab where subsysid='{0}' and left(menustruct,2)='{1}' and menustruct!='{1}' and useFlag='1' order by menustruct ", item["subsysid"] + "", item["menustruct"] + "");
|
|
DataTable Alldt = SqlHelper.ExecuteDataTable(sql);
|
|
|
|
for (int i = 0; i < Alldt.Rows.Count; i++)
|
|
{
|
|
string menuid = Alldt.Rows[i]["menuid"] + "";
|
|
if (!EditPurview.Contains(menuid)) EditPurview.Add(menuid);
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 改变一级目录,加载对应的二级目录
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void PrimaryDirectoryValueChanged(object sender, EventArgs e)
|
|
{
|
|
string text = (this.PrimaryDirectory.EditValue + "").Split('.')[0];
|
|
DataTable dt = SqlHelper.ExecuteDataTable(string.Format("select * from P_FormMenuConfigTab where len(menustruct)=2 and subsysid='{0}' and useFlag=1 order by menustruct", text));
|
|
if (dt.Rows.Count > 0)
|
|
{
|
|
this.gridLeft.gridControl.DataSource = dt;
|
|
this.gridLeft.GridView.SelectRowHandler(0);
|
|
OnGridLeftGridViewClick(null, null);
|
|
}
|
|
else
|
|
{
|
|
this.gridLeft.gridControl.DataSource = null;
|
|
this.gridControl1.DataSource = null;
|
|
this.gridControl2.DataSource = null;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置一级目录,创建二级目录的表格列
|
|
/// </summary>
|
|
protected void SetLevelOneDirectory()
|
|
{
|
|
//获取一级目录
|
|
DataTable treeTable = SqlHelper.ExecuteDataTable("select subsysid,subsysname from P_SubSystemTab where useed=1");
|
|
string text = string.Empty;
|
|
foreach (DataRow dr in treeTable.Rows)
|
|
{
|
|
text = string.Empty;
|
|
text = dr["subsysid"] + "." + dr["subsysname"];
|
|
PrimaryDirectory.Properties.Items.Add(text);
|
|
}
|
|
|
|
//二级目录列
|
|
//GridColumn subsysidColumn = new GridColumn();
|
|
//subsysidColumn.Caption = "ID";
|
|
//subsysidColumn.FieldName = "SubSysId";
|
|
//subsysidColumn.VisibleIndex = 0;
|
|
|
|
GridColumn MenuIdColumn = new GridColumn();
|
|
MenuIdColumn.Caption = "编号";
|
|
MenuIdColumn.FieldName = "MenuId";
|
|
MenuIdColumn.VisibleIndex = 1;
|
|
|
|
GridColumn MenuStructColumn = new GridColumn();
|
|
MenuStructColumn.Caption = "菜单号";
|
|
MenuStructColumn.FieldName = "MenuStruct";
|
|
MenuStructColumn.VisibleIndex = 2;
|
|
|
|
GridColumn MenuCaptionColumn = new GridColumn();
|
|
MenuCaptionColumn.Caption = "菜单名称";
|
|
MenuCaptionColumn.FieldName = "MenuCaption";
|
|
MenuCaptionColumn.VisibleIndex = 3;
|
|
|
|
|
|
this.gridLeft.GridView.Columns.AddRange(new GridColumn[] {
|
|
//subsysidColumn,
|
|
MenuIdColumn,
|
|
MenuStructColumn,
|
|
MenuCaptionColumn
|
|
});
|
|
}
|
|
|
|
|
|
//设置已有权限
|
|
protected void SetExistingPermissions()
|
|
{
|
|
string sql = "select MenuId,MenuCaption,'0' as Editflag ,'0' as Readflag from P_FormMenuConfigTab";
|
|
DataTable treeTable = SqlHelper.ExecuteDataTable(sql);
|
|
string menuid = string.Empty;
|
|
|
|
DataTable HasBeenSetDt = treeTable.Clone();//已有权限的模块
|
|
|
|
for (int i = 0; i < treeTable.Rows.Count; i++)
|
|
{
|
|
menuid = treeTable.Rows[i]["menuid"] + "";
|
|
if (string.IsNullOrWhiteSpace(menuid)) continue;
|
|
//判断已有的操作权限和只读权限中是否有当前模块id
|
|
if (EditPurview.Contains(menuid) || ReadPurview.Contains(menuid))
|
|
{
|
|
HasBeenSetDt.Rows.Add(treeTable.Rows[i].ItemArray);
|
|
}
|
|
}
|
|
this.gridControl2.DataSource = HasBeenSetDt;
|
|
}
|
|
|
|
|
|
#endregion
|
|
#region 子节点状态改变时
|
|
/// <summary>
|
|
/// <para>说明:子节点状态改变时</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-09-22 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
|
private void SetCheckedChildNodes(TreeListNode node, CheckState check)
|
|
{
|
|
for (int i = 0; i < node.Nodes.Count; i++)
|
|
{
|
|
node.Nodes[i].CheckState = check;
|
|
SetCheckedChildNodes(node.Nodes[i], check);
|
|
}
|
|
}
|
|
#endregion
|
|
#region 父节点状态改变时
|
|
/// <summary>
|
|
/// <para>说明:父节点状态改变时</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-09-22 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
|
private void SetCheckedParentNodes(TreeListNode node, CheckState check)
|
|
{
|
|
if (node.ParentNode != null)
|
|
{
|
|
bool b = false;
|
|
CheckState state;
|
|
for (int i = 0; i < node.ParentNode.Nodes.Count; i++)
|
|
{
|
|
state = (CheckState)node.ParentNode.Nodes[i].CheckState;
|
|
if (!check.Equals(state))
|
|
{
|
|
b = !b;
|
|
break;
|
|
}
|
|
}
|
|
node.ParentNode.CheckState = b ? CheckState.Indeterminate : check;
|
|
SetCheckedParentNodes(node.ParentNode, check);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region 设置左侧表格数据
|
|
/// <summary>
|
|
/// <para>说明:设置左侧表格数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-10-25 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
protected void SetLeftGridView()
|
|
{
|
|
this.LeftRowObj = BaseModuleImpl.GetBaseLeftTreeField(UnionModuleCodel);//获取表格左侧树字段
|
|
if (this.LeftRowObj != null)
|
|
{
|
|
//this.ModuleGridObj.ParentKeyField = this.LeftRowObj["fieldsqlid"] + "";
|
|
//this.ModuleGridObj.ParentUnionField = this.LeftRowObj["fieldname"] + "";
|
|
//this.ModuleGridObj.LeftGridEx = this.gridLeft;
|
|
//this.ModuleGridObj.ParentGridEx = this.gridLeft; // 方便右侧添加数据自动带出相同字段值
|
|
|
|
DataTable dtTable = BaseModuleImpl.GetBaseLeftGridField(UnionModuleCodel);
|
|
DataTable dtColorTable = BaseModuleImpl.GetBaseGridRowColors(this.LeftRowObj["fieldKey"] + "");
|
|
this.gridLeft.GridView.RowClick += new DevExpress.XtraGrid.Views.Grid.RowClickEventHandler(OnGridViewRowClick);
|
|
this.gridLeft.SetGridRowColors(dtColorTable);
|
|
this.gridLeft.SetReadOnlyColumns(dtTable, GridCustomColumnStruct.BaseLeftGridView + UnionModuleCodel);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 更新选中状态
|
|
/// <summary>
|
|
/// <para>说明:更新选中状态</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-20 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="spilts">The spilts.</param>
|
|
/// <param name="fieldName">Name of the field.</param>
|
|
/// <param name="check">if set to <c>true</c> [check].</param>
|
|
private void UpdateChecked(string[] spilts, string fieldName, bool isValue, bool check = true)
|
|
{
|
|
if (spilts == null || spilts.Length == 0 || string.IsNullOrEmpty(fieldName) || this.DataSource == null || this.DataSource.Rows.Count == 0)
|
|
return;
|
|
|
|
for (int i = 0; i < spilts.Length; i++)
|
|
{
|
|
DataRow rowItem = rowItem = this.DataSource.Rows.Cast<DataRow>().FirstOrDefault(x => x[isValue ? ValueMember : TextField] + "" == spilts[i].Trim());
|
|
if (rowItem != null)
|
|
{
|
|
rowItem[_checkFieldName] = check;
|
|
rowItem.AcceptChanges();
|
|
}
|
|
}
|
|
this.SetDetailDataSource();
|
|
}
|
|
#endregion
|
|
#region 刷新右侧表格数据
|
|
/// <summary>
|
|
/// <para>说明:刷新右侧表格数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-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="DevExpress.Data.SelectionChangedEventArgs"/> instance containing the event data.</param>
|
|
protected void OnGridViewRowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
this.SetMainGridView();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
#endregion
|
|
|
|
#region 事件
|
|
|
|
#region 设置按钮点击事件
|
|
//设置操作权限按钮点击事件
|
|
private void OnSettingOperationRightsClick(object sender, EventArgs e)
|
|
{
|
|
|
|
int[] rowNumbers = this.gcMain.GetSelectedRows();
|
|
List<DataRow> addRows = new List<DataRow>();
|
|
foreach (int rowIndex in rowNumbers)
|
|
{
|
|
DataRow rowItem = this.gcMain.GetDataRow(rowIndex);
|
|
addRows.Add(rowItem);
|
|
}
|
|
foreach (DataRow dr in addRows)
|
|
{
|
|
AccessPermissions(dr);
|
|
}
|
|
}
|
|
// 设置只读权限按钮点击事件
|
|
private void OnSetReadonlyPermissionClick(object sender, EventArgs e)
|
|
{
|
|
int[] rowNumbers = this.gcMain.GetSelectedRows();
|
|
List<DataRow> addRows = new List<DataRow>();
|
|
foreach (int rowIndex in rowNumbers)
|
|
{
|
|
DataRow rowItem = this.gcMain.GetDataRow(rowIndex);
|
|
addRows.Add(rowItem);
|
|
|
|
}
|
|
//差集
|
|
IEnumerable<DataRow> QCJ = addRows.AsEnumerable().AsEnumerable().Except((this.gridControl2.DataSource as DataTable).Select(), DataRowComparer.Default);
|
|
try
|
|
{
|
|
DataTable jg = QCJ.CopyToDataTable();
|
|
foreach (DataRow dr in jg.Rows)
|
|
{
|
|
AccessPermissions(dr, "0", "1");
|
|
}
|
|
|
|
}
|
|
catch (System.InvalidOperationException ex) //如果差集为null,就回进当前报错
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
//删除权限
|
|
private void OnRemovePermissionsClick(object sender, EventArgs e)
|
|
{
|
|
int[] rowNumbers = this.gcDetail.GetSelectedRows();
|
|
List<DataRow> deleteRows = new List<DataRow>();
|
|
List<string> primaryKeys = new List<string>();
|
|
|
|
foreach (int rowIndex in rowNumbers)
|
|
{
|
|
DataRow rowItem = this.gcDetail.GetDataRow(rowIndex);
|
|
deleteRows.Add(rowItem);
|
|
primaryKeys.Add(rowItem["MenuId"] + "");
|
|
}
|
|
|
|
|
|
foreach (DataRow dr in deleteRows)
|
|
{
|
|
RemovePermissions(dr);
|
|
}
|
|
|
|
DataTable gcMainDt = this.gridControl1.DataSource as DataTable;
|
|
for (int i = 0; i < gcMainDt.Rows.Count; i++)
|
|
{
|
|
if (primaryKeys.Contains(gcMainDt.Rows[i]["MenuId"] + "")) this.gcMain.UnselectRow(i);
|
|
}
|
|
|
|
|
|
//gvPro.UnselectRow(selectIndexs[i])
|
|
}
|
|
|
|
//点击确定按钮
|
|
private void OnbtnOkClick(object sender, EventArgs e)
|
|
{
|
|
if (onClickTheOKButton != null) onClickTheOKButton(EditPurview, ReadPurview);
|
|
this.Close();
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 分割条位置改变
|
|
/// <summary>
|
|
/// <para>说明:分割条位置包含时记录位置</para>
|
|
/// <para>创建人:曹屹峰</para>
|
|
/// <para>创建日期:2021-08-25 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void PositionChange(object sender, EventArgs e)
|
|
{
|
|
PositionSplitter = this.splitMain_Right.SplitterPosition;
|
|
}
|
|
#endregion
|
|
#region 窗口大小改变
|
|
/// <summary>
|
|
/// <para>说明:窗口大小改变时改变分割条位置</para>
|
|
/// <para>创建人:曹屹峰</para>
|
|
/// <para>创建日期:2021-08-25 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void maximization(object sender, EventArgs e)
|
|
{
|
|
double a = (double)PositionSplitter / (double)WindowHeight;
|
|
this.splitMain_Right.SplitterPosition = Convert.ToInt32(Math.Round((double)this.Height * a));
|
|
WindowHeight = this.Height;
|
|
}
|
|
#endregion
|
|
#region 选中行
|
|
/// <summary>
|
|
/// <para>说明:选中行</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-07-20 </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="DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs"/> instance containing the event data.</param>
|
|
private void OnRowCellClick(object sender, EventArgs e)
|
|
{
|
|
DataRow rowItem = this.gcMain.GetFocusedDataRow();
|
|
|
|
if (rowItem != null)
|
|
{
|
|
AccessPermissions(rowItem);
|
|
int LineNumber = this.gcMain.FocusedRowHandle;
|
|
this.gcMain.SelectRow(LineNumber);
|
|
}
|
|
}
|
|
|
|
|
|
#endregion
|
|
#region 取消选择
|
|
/// <summary>
|
|
/// <para>说明:取消选择</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-07-20 </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>
|
|
private void OnDoubleClick(object sender, EventArgs e)
|
|
{
|
|
if (this.gcDetail.RowCount == 0) return;
|
|
DataRow rowItem = this.gcDetail.GetFocusedDataRow();
|
|
string MenuId = rowItem["MenuId"] + "";
|
|
RemovePermissions(rowItem);
|
|
|
|
DataTable gcMainDt = this.gridControl1.DataSource as DataTable;
|
|
for (int i = 0; i < gcMainDt.Rows.Count; i++)
|
|
{
|
|
if (MenuId.Equals(gcMainDt.Rows[i]["MenuId"] + "")) this.gcMain.UnselectRow(i);
|
|
}
|
|
}
|
|
#endregion
|
|
#region 已有权限改变
|
|
/// <summary>
|
|
/// <para>说明:已有权限框内容改变事件</para>
|
|
/// <para>创建人:曹屹峰</para>
|
|
/// <para>创建日期:2022-06-15 </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>
|
|
//private void gridControlChange(object sender, RowCellClickEventArgs e)
|
|
//{
|
|
// if (this.gcDetail.RowCount == 0) return;
|
|
// //DataRow rowItem = this.gcDetail.GetFocusedDataRow();
|
|
|
|
//}
|
|
#endregion
|
|
#region 关闭时清空唯一键
|
|
/// <summary>
|
|
/// <para>说明:关闭时清空唯一键</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-07-20 </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="PopupMenuShowingEventArgs"/> instance containing the event data.</param>
|
|
private void OnFormClosing(object sender, FormClosingEventArgs e)
|
|
{
|
|
CurrentOperColumnKey = "";
|
|
CurrentOperModel = null;
|
|
}
|
|
#endregion
|
|
|
|
#region 确定
|
|
/// <summary>
|
|
/// <para>说明:确定</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-20 </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>
|
|
private void btnOk_Click(object sender, EventArgs e)
|
|
{
|
|
//this.EditValue = string.Empty;
|
|
//this.EditText = string.Empty;
|
|
|
|
DataRow[] rowItems = this.DataSource.Select(_checkFieldName + "=True");
|
|
|
|
//foreach (DataRow item in rowItems)
|
|
//{
|
|
// this.EditValue += item[ValueMember] + ",";
|
|
// this.EditText += item[TextField] + ",";
|
|
//}
|
|
//this.EditValue = this.EditValue.Trim(',');
|
|
//this.EditText = this.EditText.Trim(',');
|
|
|
|
this.DialogResult = DialogResult.OK;
|
|
this.Close();
|
|
}
|
|
#endregion
|
|
|
|
#region 取消
|
|
/// <summary>
|
|
/// <para>说明:取消</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-20 </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>
|
|
private void btnCancel_Click(object sender, EventArgs e)
|
|
{
|
|
this.DialogResult = DialogResult.Cancel;
|
|
}
|
|
#endregion
|
|
|
|
#region 全选所有数据
|
|
/// <summary>
|
|
/// 全选所有数据
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void btn_selectAll_Click(object sender, EventArgs e)
|
|
{
|
|
DataTable DataSource = this.gcMain.GetGridViewFilteredAndSortedDataToDataTable();
|
|
foreach (DataRow item in DataSource.Rows)
|
|
{
|
|
DataRow rowItem = this.DataSource.Select("1=1").FirstOrDefault(x => (item[_id] + "").Equals(x[_id] + ""));
|
|
rowItem[_checkFieldName] = 1;
|
|
rowItem.AcceptChanges();
|
|
}
|
|
this.SetDetailDataSource();
|
|
}
|
|
#endregion
|
|
|
|
#region 取消全选
|
|
/// <summary>
|
|
/// 取消全选
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void btn_cancelAll_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
DataTable dt = this.DataSource.Clone();
|
|
foreach (DataRow item in this.DataSource.Rows)
|
|
{
|
|
if ("True".Equals(item[_checkFieldName] + ""))
|
|
{
|
|
|
|
item[_checkFieldName] = 0;
|
|
}
|
|
}
|
|
this.SetDetailDataSource();
|
|
}
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|