980 lines
39 KiB
C#
980 lines
39 KiB
C#
using DevExpress.Utils;
|
|
using DevExpress.XtraEditors;
|
|
using DevExpress.XtraEditors.Controls;
|
|
using DevExpress.XtraEditors.Repository;
|
|
using DevExpress.XtraGrid.Columns;
|
|
using DevExpress.XtraGrid.Views.Base;
|
|
using DevExpress.XtraGrid.Views.Grid;
|
|
using DevExpress.XtraTab;
|
|
using Lskj.Business.Impl;
|
|
using Lskj.Control;
|
|
using Lskj.Control.Model;
|
|
using Lskj.Core;
|
|
using Lskj.Model;
|
|
using Lskj.Util;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Lskj.PubUserTomodule
|
|
{
|
|
public partial class PermissionSettings : UserControl
|
|
{
|
|
|
|
//子菜单下拉框
|
|
public ComboBoxEdit comboBox { get { return this.PrimaryDirectory; } }//下拉框 (从外面赋值)
|
|
//选中的菜单id
|
|
public string Menuid;
|
|
//是否是单据
|
|
public bool isBill;
|
|
//sql生成明细的key
|
|
public List<string> editFormKey = new List<string>();
|
|
|
|
public PermissionSettings()
|
|
{
|
|
InitializeComponent();
|
|
InitializeColumns();
|
|
this.PrimaryDirectory.SelectedValueChanged += new EventHandler(PrimaryDirectoryValueChanged);//选中子目录,加载二级目录
|
|
this.gridLeft.GridView.Click += new EventHandler(OnGridLeftGridViewClick);//选中二级目录,加载全部模块
|
|
this.AllModules.GridView.RowClick += GridView_RowClick;//单击模块,加载元素信息
|
|
this.xtc_container.SelectedPageChanged += new DevExpress.XtraTab.TabPageChangedEventHandler(xtc_container_SelectedPageChanged);
|
|
this.AuthorityControlEx.GridView.Click += AuthorityGridView_Click; //权限表关联下方文本框
|
|
this.AuthorityControlEx.GridView.ShowingEditor += GridView_ShowingEditor;//验证是否可以修改
|
|
|
|
this.textPersonnelList.TextChanged += TextPersonnelList_TextChanged;//文本框改变后改变选中行
|
|
this.textPersonnelList.DoubleClick += TextPersonnelList_DoubleClick;//文本框双击
|
|
InitSpliterPosition();
|
|
this.splitMain_LowerRight.SplitterPositionChanged += SplitMain_LowerRight_SplitterPositionChanged;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 分割条改变时
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void SplitMain_LowerRight_SplitterPositionChanged(object sender, EventArgs e)
|
|
{
|
|
IniHelper.Write(string.Format("Step_spliterPositionMain_{0}", "splitMain_LowerRight"), this.splitMain_LowerRight.SplitterPosition + "");
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:初始化分割条位置</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-12-15</para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void InitSpliterPosition()
|
|
{
|
|
string spliterPosition2 = IniHelper.Read(string.Format("Step_spliterPositionMain_{0}", "splitMain_LowerRight"));
|
|
if (!string.IsNullOrEmpty(spliterPosition2)) this.splitMain_LowerRight.SplitterPosition = Convert.ToInt32(spliterPosition2);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 默认绑定列数据
|
|
/// </summary>
|
|
private void InitializeColumns()
|
|
{
|
|
GridColumn MenuIdColumn = new GridColumn();
|
|
MenuIdColumn.Caption = "编号";
|
|
MenuIdColumn.FieldName = "MenuId";
|
|
MenuIdColumn.VisibleIndex = 1;
|
|
MenuIdColumn.OptionsColumn.AllowEdit = false;
|
|
|
|
GridColumn MenuStructColumn = new GridColumn();
|
|
MenuStructColumn.Caption = "菜单号";
|
|
MenuStructColumn.FieldName = "MenuStruct";
|
|
MenuStructColumn.VisibleIndex = 2;
|
|
|
|
GridColumn MenuCaptionColumn = new GridColumn();
|
|
MenuCaptionColumn.Caption = "菜单名称";
|
|
MenuCaptionColumn.FieldName = "MenuCaption";
|
|
MenuCaptionColumn.VisibleIndex = 3;
|
|
MenuCaptionColumn.OptionsColumn.AllowEdit = false;
|
|
|
|
|
|
this.gridLeft.GridView.Columns.AddRange(new GridColumn[] {
|
|
MenuIdColumn,
|
|
MenuStructColumn,
|
|
MenuCaptionColumn
|
|
});
|
|
|
|
GridColumn treeListColumnMenuId = new GridColumn();
|
|
treeListColumnMenuId.Caption = "菜单id";
|
|
treeListColumnMenuId.FieldName = "MenuId";
|
|
treeListColumnMenuId.Visible = true;
|
|
treeListColumnMenuId.VisibleIndex = 0;
|
|
treeListColumnMenuId.OptionsColumn.AllowEdit = false;
|
|
|
|
GridColumn treeListColumnName = new GridColumn();
|
|
treeListColumnName.Caption = "系统名称";
|
|
treeListColumnName.FieldName = "MenuCaption";
|
|
treeListColumnName.MinWidth = 38;
|
|
treeListColumnName.Visible = true;
|
|
treeListColumnName.VisibleIndex = 1;
|
|
treeListColumnName.Width = 300;
|
|
treeListColumnName.OptionsColumn.AllowEdit = false;
|
|
|
|
GridColumn PurviewIdColumnName = new GridColumn();
|
|
PurviewIdColumnName.Caption = "模块编号";
|
|
PurviewIdColumnName.FieldName = "PurviewId";
|
|
PurviewIdColumnName.MinWidth = 38;
|
|
PurviewIdColumnName.Visible = true;
|
|
PurviewIdColumnName.VisibleIndex = 2;
|
|
PurviewIdColumnName.Width = 300;
|
|
PurviewIdColumnName.OptionsColumn.AllowEdit = false;
|
|
|
|
|
|
this.AllModules.GridView.Columns.AddRange(new GridColumn[] {
|
|
treeListColumnMenuId,
|
|
treeListColumnName,
|
|
PurviewIdColumnName
|
|
});
|
|
|
|
//权限分类
|
|
GridColumn sortIdColumn = new GridColumn();
|
|
sortIdColumn.Caption = "分类ID";
|
|
sortIdColumn.FieldName = "privTypeId";
|
|
sortIdColumn.Visible = true;
|
|
sortIdColumn.VisibleIndex = 0;
|
|
|
|
|
|
GridColumn sortNameColumn = new GridColumn();
|
|
sortNameColumn.Caption = "权限分类名称";
|
|
sortNameColumn.FieldName = "privTypeName";
|
|
sortNameColumn.Visible = true;
|
|
sortNameColumn.VisibleIndex = 1;
|
|
|
|
|
|
|
|
GridColumn remarkColumn = new GridColumn();
|
|
remarkColumn.Caption = "备注";
|
|
remarkColumn.FieldName = "remark";
|
|
remarkColumn.Visible = true;
|
|
remarkColumn.VisibleIndex = 2;
|
|
|
|
|
|
GridColumn userListColumn = new GridColumn();
|
|
userListColumn.Caption = "人员列表";
|
|
userListColumn.FieldName = "userList";
|
|
userListColumn.Visible = true;
|
|
userListColumn.VisibleIndex = 3;
|
|
|
|
RepositoryItemMemoExEdit memoEdit = new RepositoryItemMemoExEdit();
|
|
memoEdit.WordWrap = true;
|
|
memoEdit.ShowIcon = false;
|
|
// memoEdit.EditValueChanged += MemoEdit_EditValueChanged;
|
|
userListColumn.ColumnEdit = memoEdit;
|
|
|
|
|
|
RepositoryItemCheckEdit checkEdit = new RepositoryItemCheckEdit();
|
|
checkEdit.ValueChecked = true;
|
|
checkEdit.ValueUnchecked = false;
|
|
//checkEdit.ValueGrayed = 3;
|
|
//checkEdit.CheckedChanged += new EventHandler(CheckedChanged);
|
|
|
|
GridColumn DisableColumn = new GridColumn();
|
|
DisableColumn.Caption = "禁用";
|
|
DisableColumn.FieldName = "isVisible";
|
|
DisableColumn.Visible = true;
|
|
DisableColumn.VisibleIndex = 4;
|
|
DisableColumn.ColumnEdit = checkEdit;
|
|
|
|
GridColumn roleidColumn = new GridColumn();
|
|
roleidColumn.Caption = "角色Id";
|
|
roleidColumn.FieldName = "roleid";
|
|
roleidColumn.Visible = true;
|
|
roleidColumn.VisibleIndex = 4;
|
|
roleidColumn.OptionsColumn.AllowEdit = false;
|
|
|
|
|
|
|
|
//权限表
|
|
this.AuthorityControlEx.GridView.Columns.AddRange(new GridColumn[] {
|
|
sortIdColumn,
|
|
sortNameColumn,
|
|
remarkColumn,
|
|
userListColumn,
|
|
DisableColumn,
|
|
roleidColumn
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 改变一级目录,加载对应的二级目录
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void PrimaryDirectoryValueChanged(object sender, EventArgs e)
|
|
{
|
|
Menuid = string.Empty;
|
|
string text = (this.PrimaryDirectory.EditValue + "").Split('.')[0];
|
|
DataTable dt = SqlHelper.ExecuteDataTable(string.Format("select * from P_FormMenuConfigTab where len(menustruct)=2 and useFlag=1 and subsysid='{0}' 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.AllModules.gridControl.DataSource = null;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 点击二级目录,加载具体模块
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnGridLeftGridViewClick(object sender, EventArgs e)
|
|
{
|
|
Menuid = string.Empty;
|
|
DataRow mSelectRow = this.gridLeft.GridView.GetFocusedDataRow();
|
|
if (mSelectRow != null)
|
|
{
|
|
string sql = string.Format("select PurviewId,MenuId,MenuCaption 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);
|
|
this.AllModules.gridControl.DataSource = Alldt;
|
|
this.AllModules.GridView.SelectRowHandler(0);
|
|
GridView_RowClick(null, null);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 选中权限分类中的行,在下方文本框中显示选中行人员
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void AuthorityGridView_Click(object sender, EventArgs e)
|
|
{
|
|
GridView gridView = sender as GridView;
|
|
DataRow rowItem = gridView.GetFocusedDataRow();
|
|
this.btn_DeletePermissions.Enabled = true;
|
|
|
|
if (rowItem != null && rowItem.Table.Columns.Contains("roleid"))
|
|
{
|
|
string roleid = rowItem["roleid"] + "";
|
|
//设置了角色id的不能修改
|
|
if (!string.IsNullOrWhiteSpace(roleid) && !roleid.Equals("0"))
|
|
{
|
|
this.btn_DeletePermissions.Enabled = false;
|
|
}
|
|
}
|
|
|
|
if (rowItem != null)
|
|
{
|
|
textPersonnelList.Text = rowItem["userList"] + "";
|
|
}
|
|
else
|
|
{
|
|
textPersonnelList.Text = "";
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 验证选中行是否可以修改(自动生成的不能修改)
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void GridView_ShowingEditor(object sender, CancelEventArgs e)
|
|
{
|
|
GridView gridView = sender as GridView;
|
|
DataRow rowItem = gridView.GetFocusedDataRow();
|
|
if (rowItem != null && rowItem.Table.Columns.Contains("roleid"))
|
|
{
|
|
string roleid = rowItem["roleid"] + "";
|
|
//设置了角色id的不能修改
|
|
if (!string.IsNullOrWhiteSpace(roleid) && !roleid.Equals("0"))
|
|
{
|
|
e.Cancel = true;//该行不可编辑
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 文本框的值改变时,改变选中行的值
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void TextPersonnelList_TextChanged(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
DataRow rowItem = this.AuthorityControlEx.GridView.GetFocusedDataRow();
|
|
if (rowItem != null)
|
|
{
|
|
rowItem["userList"] = textPersonnelList.Text;
|
|
}
|
|
else
|
|
{
|
|
textPersonnelList.Text = "";
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 文本框双击打开拖拽界面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void TextPersonnelList_DoubleClick(object sender, EventArgs e)
|
|
{
|
|
DataRow rowItem = this.AuthorityControlEx.GridView.GetFocusedDataRow();
|
|
if (rowItem != null)
|
|
{
|
|
//设置了角色id的不能修改
|
|
if (rowItem.Table.Columns.Contains("roleid"))
|
|
{
|
|
string roleid = rowItem["roleid"] + "";
|
|
if (!string.IsNullOrWhiteSpace(roleid) && !roleid.Equals("0"))
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
FrmPermissionClassification form = new FrmPermissionClassification();
|
|
//form.SaveRole = true;
|
|
form.RoleTable = PowerImpl.GetWorkRole("", "");
|
|
form.PersonnelTable = PowerImpl.GetWorkEmployee();
|
|
form.AuthorizedName = textPersonnelList.Text;
|
|
//form.Promptinformation = "人员列表(角色只能保存单个)";
|
|
form.onClickTheOKButton += new FrmPermissionClassification.ClickTheOKButton(SetTextPersonnelList);
|
|
DialogResult result = form.ShowDialog();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 反写人员框信息
|
|
/// </summary>
|
|
/// <param name="Name"></param>
|
|
private void SetTextPersonnelList(string Name)
|
|
{
|
|
if (Name.Contains("{&"))
|
|
{
|
|
//记录角色id
|
|
Name = Name.Replace("{&", "").Replace("&}", "");
|
|
string text = string.Empty;
|
|
string roleid = Name.Split(',')[0];
|
|
DataRow rowItem = this.AuthorityControlEx.GridView.GetFocusedDataRow();
|
|
if (rowItem != null)
|
|
{
|
|
rowItem["roleid"] = roleid;
|
|
}
|
|
|
|
DataTable Roledetailed = PowerImpl.GetWorkUsers(roleid);
|
|
if (Roledetailed != null && Roledetailed.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow dr in Roledetailed.Rows)
|
|
{
|
|
text += dr["员工姓名"] + ",";
|
|
}
|
|
textPersonnelList.Text = text;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
textPersonnelList.Text = Name + "";
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 切换页签加载权限模块
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void xtc_container_SelectedPageChanged(object sender, TabPageChangedEventArgs e)
|
|
{
|
|
XtraTabPage page = this.xtc_container.SelectedTabPage;
|
|
string PurviewId = page.Tag + "";
|
|
DataTable table = PowerImpl.GetModuleAuthority(PurviewId);
|
|
this.AuthorityControlEx.gridControl.DataSource = table;
|
|
this.AuthorityGridView_Click(this.AuthorityControlEx.GridView, null);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 点击模块,加载元素信息
|
|
/// </summary>
|
|
private void GridView_RowClick(object sender, RowClickEventArgs e)
|
|
{
|
|
//删除动态生成的页签
|
|
if (this.xtc_container.TabPages.Count > 2)
|
|
{
|
|
for (int i = this.xtc_container.TabPages.Count - 1; i >= 2; i--)
|
|
{
|
|
this.xtc_container.TabPages.RemoveAt(i);
|
|
}
|
|
}
|
|
//清空编辑展现方式明细的FormKey;
|
|
editFormKey.Clear();
|
|
//隐藏单据明细页签
|
|
xtraTabPage2.PageVisible = false;
|
|
|
|
|
|
DataRow mSelectRow = this.AllModules.GridView.GetFocusedDataRow();
|
|
if (mSelectRow != null)
|
|
{
|
|
String dllcode = mSelectRow["PurviewId"] + "";
|
|
//判断是单表还是单据
|
|
DataRow modelRow = MainImpl.GetSystemdllTab(dllcode);//获取单个模块信息 单表
|
|
|
|
DataRow BillmodelRow = BillImpl.GetBillInfo(dllcode);//获取单个模块信息 单据
|
|
if (modelRow == null && BillmodelRow == null)
|
|
{
|
|
MessageUtil.Show("模块编号[" + dllcode + "],配置错误!\r\n该模块信息未找到!");
|
|
return;
|
|
}
|
|
|
|
//设置权限分类表
|
|
xtraTabPage1.Tag = dllcode;
|
|
xtraTabPage2.Tag = dllcode;
|
|
xtc_container_SelectedPageChanged(null, null);
|
|
//右键
|
|
ContextMenuStrip contextMenuStrip = new ContextMenuStrip();
|
|
ToolStripMenuItem menuItem1 = new ToolStripMenuItem("右键设置");
|
|
menuItem1.ImageIndex = 0;
|
|
menuItem1.Click += MenuItem1_Click;
|
|
contextMenuStrip.Items.Add(menuItem1);
|
|
//编辑展现方式明细的右键
|
|
ContextMenuStrip contextMenuStripEditingMethod = new ContextMenuStrip();
|
|
ToolStripMenuItem menuItem1Edit = new ToolStripMenuItem("右键设置");
|
|
menuItem1Edit.ImageIndex = 0;
|
|
menuItem1Edit.Click += MenuItem1Edit_Click;
|
|
contextMenuStripEditingMethod.Items.Add(menuItem1Edit);
|
|
|
|
this.MainTableElement.ContextMenuStrip = null;
|
|
this.BillDetail.ContextMenuStrip = null;
|
|
this.MainTableElement.gridControl.ContextMenuStrip = null;
|
|
this.BillDetail.gridControl.ContextMenuStrip = null;
|
|
//选中模块中的元素信息
|
|
if (modelRow != null)
|
|
{
|
|
//单表
|
|
this.isBill = false;
|
|
//设置主表信息
|
|
this.SetElementTableColumns(this.MainTableElement);
|
|
this.MainTableElement.gridControl.DataSource = PowerImpl.GetBasisData(dllcode);
|
|
this.MainTableElement.GridView.BestFitColumns();//设置根据内容填充列宽
|
|
this.MainTableElement.gridControl.ContextMenuStrip = contextMenuStrip;
|
|
this.MainTableElement.GridView.CellValueChanged -= GridView_CellValueChanged;
|
|
this.MainTableElement.GridView.CellValueChanged += GridView_CellValueChanged;
|
|
|
|
// 设置明细
|
|
List<GridDetailModel> Details = this.GetDetails(dllcode);
|
|
foreach (GridDetailModel item in Details)
|
|
{
|
|
editFormKey.Add(item.FormKey);
|
|
|
|
if (!string.IsNullOrWhiteSpace(item.UnionModule))
|
|
{
|
|
DataRow moduleInformation = MainImpl.GetSystemdllTab(item.UnionModule);
|
|
if (moduleInformation != null)
|
|
{
|
|
XtraTabPage page = new XtraTabPage();
|
|
page.Text = item.DetailName;
|
|
GridControlEx controlEx = new GridControlEx();
|
|
controlEx.Dock = DockStyle.Fill;
|
|
this.SetElementTableColumns(controlEx);
|
|
controlEx.gridControl.DataSource = PowerImpl.GetBasisData(item.UnionModule);
|
|
controlEx.GridView.BestFitColumns();//设置根据内容填充列宽
|
|
controlEx.GridView.CellValueChanged += GridView_CellValueChanged;
|
|
controlEx.gridControl.ContextMenuStrip = contextMenuStrip;
|
|
page.Tag = item.UnionModule;
|
|
page.Controls.Add(controlEx);
|
|
this.xtc_container.TabPages.Add(page);
|
|
}
|
|
|
|
}
|
|
else if (item.IsReadOnly)
|
|
{
|
|
XtraTabPage page = new XtraTabPage();
|
|
page.Text = item.DetailName;
|
|
GridControlEx controlEx = new GridControlEx();
|
|
controlEx.Dock = DockStyle.Fill;
|
|
this.SetElementTableColumns(controlEx, true);
|
|
controlEx.gridControl.DataSource = item.GridColumns;
|
|
controlEx.GridView.BestFitColumns();//设置根据内容填充列宽
|
|
controlEx.GridView.CellValueChanged += GridView_CellValueChanged_SqlMode;
|
|
|
|
//contextMenuStrip.Items.Clear();
|
|
//contextMenuStrip.Items.Add(menuItem1Edit);
|
|
controlEx.gridControl.ContextMenuStrip = contextMenuStripEditingMethod;
|
|
|
|
page.Tag = dllcode;
|
|
page.Controls.Add(controlEx);
|
|
this.xtc_container.TabPages.Add(page);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
else if (BillmodelRow != null)
|
|
{
|
|
//单据
|
|
this.isBill = true;
|
|
//设置主表信息
|
|
this.SetElementTableColumns(this.MainTableElement);
|
|
this.MainTableElement.gridControl.DataSource = PowerImpl.GetBillAboveData(dllcode);
|
|
this.MainTableElement.GridView.BestFitColumns();//设置根据内容填充列宽
|
|
this.MainTableElement.GridView.CellValueChanged -= GridView_CellValueChanged;
|
|
this.MainTableElement.GridView.CellValueChanged += GridView_CellValueChanged;
|
|
//单据明细
|
|
xtraTabPage2.PageVisible = true;
|
|
this.SetElementTableColumns(this.BillDetail);
|
|
this.BillDetail.gridControl.DataSource = PowerImpl.GetBillDetailData(dllcode);
|
|
this.BillDetail.GridView.BestFitColumns();//设置根据内容填充列宽
|
|
this.BillDetail.gridControl.ContextMenuStrip = contextMenuStrip;
|
|
this.BillDetail.GridView.CellValueChanged -= GridView_CellValueChanged;
|
|
this.BillDetail.GridView.CellValueChanged += GridView_CellValueChanged;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//没有选中模块
|
|
this.MainTableElement.gridControl.DataSource = null;
|
|
this.AuthorityControlEx.gridControl.DataSource = null;
|
|
this.textPersonnelList.Text = "";
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 设置表中元素列信息
|
|
/// </summary>
|
|
private void SetElementTableColumns(GridControlEx gridControlEx, bool maskingOperations = false)
|
|
{
|
|
GridColumn orderidColumn = new GridColumn();
|
|
orderidColumn.Caption = "序号";
|
|
orderidColumn.FieldName = "orderid";
|
|
orderidColumn.Visible = true;
|
|
orderidColumn.VisibleIndex = 0;
|
|
orderidColumn.OptionsColumn.AllowEdit = false;
|
|
|
|
|
|
GridColumn fieldnameColumn = new GridColumn();
|
|
fieldnameColumn.Caption = "字段名称";
|
|
fieldnameColumn.FieldName = "fieldName";
|
|
fieldnameColumn.Visible = true;
|
|
fieldnameColumn.VisibleIndex = 1;
|
|
fieldnameColumn.OptionsColumn.AllowEdit = false;
|
|
|
|
|
|
GridColumn username1Column = new GridColumn();
|
|
username1Column.Caption = "用户名称";
|
|
username1Column.FieldName = "userName";
|
|
username1Column.Visible = true;
|
|
username1Column.VisibleIndex = 3;
|
|
username1Column.OptionsColumn.AllowEdit = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GridColumn privilegeViewColumn = new GridColumn();
|
|
privilegeViewColumn.Caption = "浏览权限";
|
|
privilegeViewColumn.FieldName = "privilegeView";
|
|
privilegeViewColumn.Visible = true;
|
|
privilegeViewColumn.VisibleIndex = 8;
|
|
|
|
|
|
GridColumn privilegeOperColumn = new GridColumn();
|
|
privilegeOperColumn.Caption = "操作权限";
|
|
privilegeOperColumn.FieldName = "privilegeOper";
|
|
privilegeOperColumn.Visible = true;
|
|
privilegeOperColumn.VisibleIndex = 7;
|
|
|
|
RepositoryItemCheckedComboBoxEdit btnEdit = new RepositoryItemCheckedComboBoxEdit();
|
|
btnEdit.NullText = "";
|
|
btnEdit.PopupBorderStyle = PopupBorderStyles.Flat;
|
|
btnEdit.AllowNullInput = DefaultBoolean.False;
|
|
btnEdit.DisplayMember = "DisplayName";
|
|
btnEdit.ValueMember = "privTypeId";
|
|
btnEdit.SeparatorChar = ',';
|
|
btnEdit.Buttons[0].Visible = false; // 不能移除,移除后事件不起作用.
|
|
btnEdit.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] { new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Ellipsis) });
|
|
btnEdit.Buttons[1].Tag = btnEdit;
|
|
btnEdit.ButtonClick += new ButtonPressedEventHandler(OnButtonEditClick);
|
|
btnEdit.AllowDropDownWhenReadOnly = DefaultBoolean.True;
|
|
//btnEdit.QueryPopUp += BtnEdit_QueryPopUp;
|
|
gridControlEx.gridControl.RepositoryItems.Add(btnEdit);
|
|
|
|
|
|
privilegeViewColumn.ColumnEdit = btnEdit;
|
|
privilegeOperColumn.ColumnEdit = btnEdit;
|
|
|
|
|
|
gridControlEx.GridView.Columns.Clear();
|
|
|
|
if (maskingOperations)
|
|
{
|
|
gridControlEx.GridView.Columns.AddRange(new GridColumn[] {
|
|
orderidColumn,
|
|
fieldnameColumn,
|
|
username1Column,
|
|
privilegeViewColumn
|
|
});
|
|
}
|
|
else
|
|
{
|
|
gridControlEx.GridView.Columns.AddRange(new GridColumn[] {
|
|
orderidColumn,
|
|
fieldnameColumn,
|
|
username1Column,
|
|
privilegeViewColumn,
|
|
privilegeOperColumn
|
|
});
|
|
}
|
|
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 权限单元格点开时搜索对应的权限分类数据
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnButtonEditClick(object sender, ButtonPressedEventArgs e)
|
|
{
|
|
XtraTabPage page = this.xtc_container.SelectedTabPage;
|
|
string PurviewId = page.Tag + "";
|
|
DataTable table = PowerImpl.GetModuleAuthority(PurviewId);
|
|
CheckedComboBoxEdit btnEdit = (CheckedComboBoxEdit)sender;
|
|
RepositoryItemCheckedComboBoxEdit repository = e.Button.Tag as RepositoryItemCheckedComboBoxEdit;
|
|
repository.DataSource = table;
|
|
btnEdit.ShowPopup();
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:拿到底部表格数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-21 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>List<GridDetailModel>.</returns>
|
|
private List<GridDetailModel> GetDetails(string ModuleCode)
|
|
{
|
|
List<GridDetailModel> details = new List<GridDetailModel>();//表格明细对象的集合
|
|
|
|
DataTable table = BaseModuleImpl.GetBaseDetailPages(ModuleCode);// 根据传入的模块编号获得基础档案底部标签的数据
|
|
|
|
foreach (DataRow item in table.Rows)
|
|
{
|
|
DataTable gridColumns = ReportImpl.GetReportDetailColumns(ModuleCode, item["id"] + "");//获取报表明细列
|
|
details.Add(new GridDetailModel(item, gridColumns, GridCustomColumnStruct.BaseDetailGridView));
|
|
}
|
|
return details;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存权限分类
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void btn_SavePermissions_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
DataRow moduleRow = this.AllModules.GridView.GetFocusedDataRow();
|
|
XtraTabPage page = this.xtc_container.SelectedTabPage;
|
|
string dllcode = page.Tag + "";
|
|
if (moduleRow != null && !string.IsNullOrWhiteSpace(dllcode))
|
|
{
|
|
|
|
DataTable dt = (this.AuthorityControlEx.gridControl.DataSource as DataTable).TrimDeleteRows();
|
|
if (string.IsNullOrWhiteSpace(dllcode)) return;
|
|
|
|
string Sql = string.Format("delete p_systemPrivilege where modId='{0}';", dllcode);
|
|
foreach (DataRow item in dt.Rows)
|
|
{
|
|
Sql += string.Format(" insert into p_systemPrivilege(privTypeId,privTypeName,modId,userList,remark,isVisible,roleid) VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}'); ",
|
|
item["privTypeId"] + "", item["privTypeName"] + "", item["modId"] + "", item["userList"] + "", item["remark"] + "", item["isVisible"] + "", item["roleid"] + "");
|
|
|
|
}
|
|
int result = SqlHelper.ExecuteNonQuery(Sql);
|
|
if (result > 0)
|
|
{
|
|
MessageUtil.Show("保存权限分类成功");
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show("保存权限分类失败");
|
|
return;
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
}
|
|
finally
|
|
{
|
|
int rowHandle = this.AuthorityControlEx.GridView.FocusedRowHandle;
|
|
xtc_container_SelectedPageChanged(null, null); //刷新数据
|
|
this.AuthorityControlEx.GridView.SelectRowHandler(rowHandle);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除权限分类
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void btn_DeletePermissions_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
|
|
int[] rows = this.AuthorityControlEx.GridView.GetSelectedRows();
|
|
if (rows.Length < 1)
|
|
{
|
|
MessageUtil.Show("请选中删除行");
|
|
return;
|
|
}
|
|
this.AuthorityControlEx.GridView.DeleteSelectedRows();
|
|
this.AuthorityControlEx.GridView.ClearSelection();
|
|
this.AuthorityControlEx.GridView.SelectRow(this.AuthorityControlEx.GridView.FocusedRowHandle);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 新增权限分类
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void btn_AddPermissions_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
DataRow moduleRow = this.AllModules.GridView.GetFocusedDataRow();
|
|
//模块编号
|
|
XtraTabPage page = this.xtc_container.SelectedTabPage;
|
|
string dllcode = page.Tag + "";
|
|
if (moduleRow != null && !string.IsNullOrWhiteSpace(dllcode))
|
|
{
|
|
|
|
//新增权限分类数据
|
|
DataTable dt = (this.AuthorityControlEx.gridControl.DataSource as DataTable).TrimDeleteRows();
|
|
this.AuthorityControlEx.GridView.BeginDataUpdate();
|
|
DataRow newRow = dt.NewRow();
|
|
newRow["modId"] = dllcode;
|
|
newRow["privTypeName"] = "默认分类";
|
|
newRow["isVisible"] = false;
|
|
|
|
//获取当前最大的id,没有就为1
|
|
int id = 1;
|
|
string maxid = dt.Rows.Cast<DataRow>().Max(n => n["privTypeId"]) + "";
|
|
if (!string.IsNullOrWhiteSpace(maxid) && int.Parse(maxid) > 0)
|
|
{
|
|
id = int.Parse(maxid) + 1;
|
|
}
|
|
newRow["privTypeId"] = id;
|
|
this.AuthorityControlEx.GridView.EndDataUpdate();
|
|
dt.Rows.Add(newRow);
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 右键设置
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void MenuItem1_Click(object sender, EventArgs e)
|
|
{
|
|
DataRow moduleRow = this.AllModules.GridView.GetFocusedDataRow();
|
|
//模块编号
|
|
XtraTabPage page = this.xtc_container.SelectedTabPage;
|
|
string dllcode = page.Tag + "";
|
|
if (moduleRow != null && !string.IsNullOrWhiteSpace(dllcode))
|
|
{
|
|
ToolStripMenuItem item = sender as ToolStripMenuItem;
|
|
ModuleType Type = ModuleType.BaseModule;
|
|
if (!isBill)
|
|
{
|
|
Type = ModuleType.BaseModule;
|
|
}
|
|
else
|
|
{
|
|
Type = ModuleType.BaseModule;
|
|
dllcode = "BILLDETAIL_" + dllcode;
|
|
}
|
|
|
|
FrmRightMenus form = new FrmRightMenus(Type, dllcode);
|
|
form.RoleTable = PowerImpl.GetWorkRole("", "");
|
|
form.PersonnelTable = PowerImpl.GetWorkEmployee();
|
|
DialogResult result = form.ShowDialog();
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 右键设置(编辑展现方式设置的明细的右键)
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void MenuItem1Edit_Click(object sender, EventArgs e)
|
|
{
|
|
DataRow moduleRow = this.AllModules.GridView.GetFocusedDataRow();
|
|
//当前选中的页签号 - 默认主表和默认单据明细的页签
|
|
int index = this.xtc_container.SelectedTabPageIndex-2;
|
|
if (index >= 0 && editFormKey.Count >= index + 1)
|
|
{
|
|
string key = editFormKey[index];
|
|
if (moduleRow != null && !string.IsNullOrWhiteSpace(key))
|
|
{
|
|
ToolStripMenuItem item = sender as ToolStripMenuItem;
|
|
ModuleType Type = ModuleType.BaseModule;
|
|
|
|
FrmRightMenus form = new FrmRightMenus(Type, key);
|
|
form.RoleTable = PowerImpl.GetWorkRole("", "");
|
|
form.PersonnelTable = PowerImpl.GetWorkEmployee();
|
|
DialogResult result = form.ShowDialog();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 表格值改变
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void GridView_CellValueChanged(object sender, CellValueChangedEventArgs e)
|
|
{
|
|
DataRow mSelectRow = null;//当前行
|
|
string columnName = null;//当前列列名
|
|
string sqlValue = string.Empty;
|
|
GridView gridView = sender as GridView;
|
|
string value = (e.Value + "").Replace(" ","");
|
|
if (!isBill)
|
|
{
|
|
mSelectRow = gridView.GetFocusedDataRow();
|
|
columnName = e.Column.FieldName;
|
|
sqlValue = string.Format("update p_systemwordbooktab set {0}='{1}' where id='{2}';", columnName, value, mSelectRow["id"] + "");
|
|
}
|
|
else
|
|
{
|
|
XtraTabPage page = this.xtc_container.SelectedTabPage;
|
|
if (page == xtraTabPage1)
|
|
{
|
|
//单据主表
|
|
mSelectRow = gridView.GetFocusedDataRow();
|
|
columnName = e.Column.FieldName;
|
|
sqlValue = string.Format("update p_systembillInfo set {0}='{1}' where id='{2}';", columnName, value, mSelectRow["id"] + "");
|
|
}
|
|
else if (page == xtraTabPage2)
|
|
{
|
|
//单据明细
|
|
mSelectRow = gridView.GetFocusedDataRow();
|
|
columnName = e.Column.FieldName;
|
|
sqlValue = string.Format("update p_systembilldetail set {0}='{1}' where id='{2}';", columnName, value, mSelectRow["id"] + "");
|
|
}
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(sqlValue))
|
|
{
|
|
int result = SqlHelper.ExecuteNonQuery(sqlValue);
|
|
if (result > 0)
|
|
{
|
|
// MessageUtil.Show("同步模块权限成功!");
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show("设置模块属性权限失败!");
|
|
return;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 表格值改变(特殊情况,明细直接配置的sql)
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void GridView_CellValueChanged_SqlMode(object sender, CellValueChangedEventArgs e)
|
|
{
|
|
DataRow mSelectRow = null;//当前行
|
|
string columnName = null;//当前列列名
|
|
string sqlValue = string.Empty;
|
|
GridView gridView = sender as GridView;
|
|
string value = (e.Value + "").Replace(" ", "");
|
|
if (!isBill)
|
|
{
|
|
mSelectRow = gridView.GetFocusedDataRow();
|
|
columnName = e.Column.FieldName;
|
|
sqlValue = string.Format("update p_systemDlltabDetailGrid set {0}='{1}' where id='{2}';", columnName, value, mSelectRow["id"] + "");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(sqlValue))
|
|
{
|
|
int result = SqlHelper.ExecuteNonQuery(sqlValue);
|
|
if (result > 0)
|
|
{
|
|
// MessageUtil.Show("同步模块权限成功!");
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show("设置模块属性权限失败!");
|
|
return;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|