增加权限菜单管控

Beta
凯 王 2021-05-12 08:50:36 +08:00
parent 1c3a2d6943
commit e9f8f27864
6 changed files with 97 additions and 44 deletions

View File

@ -10,5 +10,6 @@ namespace WinformGeneralDeveloperFrame.Commons
public class AppInfo
{
public static sysUserInfo LoginUserInfo;
public static List<string> FunctionList = new List<string>();
}
}

View File

@ -39,6 +39,7 @@ namespace MES.Entity
public bool isForm{set;get;}
[ModelBindControl("txtisToolBtn")]
public bool isToolBtn { set; get; }
[ModelBindControl("txtfunctionCode")]
public string functionCode { set; get; }
}
}

View File

@ -93,6 +93,9 @@ namespace MES.Form
this.layoutControlItem14 = new DevExpress.XtraLayout.LayoutControlItem();
this.layoutControlItem2 = new DevExpress.XtraLayout.LayoutControlItem();
this.xtraOpenFileDialog1 = new DevExpress.XtraEditors.XtraOpenFileDialog(this.components);
this.gridColumn15 = new DevExpress.XtraGrid.Columns.GridColumn();
this.txtfunctionCode = new DevExpress.XtraEditors.TextEdit();
this.layoutControlItem15 = new DevExpress.XtraLayout.LayoutControlItem();
((System.ComponentModel.ISupportInitialize)(this.repositoryItemTreeListtxtpid)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.repositoryItemTreeListtxtpidTreeList)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.repositoryItemCheckedComboBoxEdit1)).BeginInit();
@ -141,6 +144,8 @@ namespace MES.Form
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem13)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem14)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.txtfunctionCode.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem15)).BeginInit();
this.SuspendLayout();
//
// gridColumn1
@ -358,7 +363,8 @@ namespace MES.Form
this.gridColumn11,
this.gridColumn12,
this.gridColumn13,
this.gridColumn14});
this.gridColumn14,
this.gridColumn15});
this.grdListView.GridControl = this.grdList;
this.grdListView.Name = "grdListView";
this.grdListView.OptionsBehavior.Editable = false;
@ -398,6 +404,7 @@ namespace MES.Form
//
// layoutControl1
//
this.layoutControl1.Controls.Add(this.txtfunctionCode);
this.layoutControl1.Controls.Add(this.txtname);
this.layoutControl1.Controls.Add(this.txtid);
this.layoutControl1.Controls.Add(this.simpleButton1);
@ -422,9 +429,9 @@ namespace MES.Form
//
// txtname
//
this.txtname.Location = new System.Drawing.Point(391, 12);
this.txtname.Location = new System.Drawing.Point(401, 12);
this.txtname.Name = "txtname";
this.txtname.Size = new System.Drawing.Size(273, 20);
this.txtname.Size = new System.Drawing.Size(263, 20);
this.txtname.StyleController = this.layoutControl1;
this.txtname.TabIndex = 15;
//
@ -432,7 +439,7 @@ namespace MES.Form
//
this.txtid.Location = new System.Drawing.Point(63, 12);
this.txtid.Name = "txtid";
this.txtid.Size = new System.Drawing.Size(109, 20);
this.txtid.Size = new System.Drawing.Size(114, 20);
this.txtid.StyleController = this.layoutControl1;
this.txtid.TabIndex = 14;
//
@ -440,7 +447,7 @@ namespace MES.Form
//
this.simpleButton1.Location = new System.Drawing.Point(311, 36);
this.simpleButton1.Name = "simpleButton1";
this.simpleButton1.Size = new System.Drawing.Size(24, 22);
this.simpleButton1.Size = new System.Drawing.Size(35, 22);
this.simpleButton1.StyleController = this.layoutControl1;
this.simpleButton1.TabIndex = 13;
this.simpleButton1.Text = "...";
@ -449,14 +456,14 @@ namespace MES.Form
// txtpid
//
this.txtpid.EditValue = "";
this.txtpid.Location = new System.Drawing.Point(227, 12);
this.txtpid.Location = new System.Drawing.Point(232, 12);
this.txtpid.Name = "txtpid";
this.txtpid.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
this.txtpid.Properties.DisplayMember = "Name";
this.txtpid.Properties.TreeList = this.txtpidTreeList;
this.txtpid.Properties.ValueMember = "ID";
this.txtpid.Size = new System.Drawing.Size(109, 20);
this.txtpid.Size = new System.Drawing.Size(114, 20);
this.txtpid.StyleController = this.layoutControl1;
this.txtpid.TabIndex = 1;
//
@ -480,9 +487,9 @@ namespace MES.Form
//
// txtwinformType
//
this.txtwinformType.Location = new System.Drawing.Point(390, 36);
this.txtwinformType.Location = new System.Drawing.Point(401, 36);
this.txtwinformType.Name = "txtwinformType";
this.txtwinformType.Size = new System.Drawing.Size(274, 20);
this.txtwinformType.Size = new System.Drawing.Size(263, 20);
this.txtwinformType.StyleController = this.layoutControl1;
this.txtwinformType.TabIndex = 4;
//
@ -490,19 +497,19 @@ namespace MES.Form
//
this.txtsort.Location = new System.Drawing.Point(63, 62);
this.txtsort.Name = "txtsort";
this.txtsort.Size = new System.Drawing.Size(273, 20);
this.txtsort.Size = new System.Drawing.Size(114, 20);
this.txtsort.StyleController = this.layoutControl1;
this.txtsort.TabIndex = 5;
//
// txtisEnabled
//
this.txtisEnabled.EditValue = null;
this.txtisEnabled.Location = new System.Drawing.Point(340, 62);
this.txtisEnabled.Location = new System.Drawing.Point(516, 62);
this.txtisEnabled.Name = "txtisEnabled";
this.txtisEnabled.Properties.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.Default;
this.txtisEnabled.Properties.Caption = "有效";
this.txtisEnabled.Properties.NullStyle = DevExpress.XtraEditors.Controls.StyleIndeterminate.Unchecked;
this.txtisEnabled.Size = new System.Drawing.Size(144, 19);
this.txtisEnabled.Size = new System.Drawing.Size(64, 19);
this.txtisEnabled.StyleController = this.layoutControl1;
this.txtisEnabled.TabIndex = 6;
//
@ -529,7 +536,7 @@ namespace MES.Form
this.txtcreatorId.Properties.PopupFilterMode = DevExpress.XtraEditors.PopupFilterMode.Contains;
this.txtcreatorId.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;
this.txtcreatorId.Properties.ValueMember = "ID";
this.txtcreatorId.Size = new System.Drawing.Size(273, 20);
this.txtcreatorId.Size = new System.Drawing.Size(283, 20);
this.txtcreatorId.StyleController = this.layoutControl1;
this.txtcreatorId.TabIndex = 8;
//
@ -537,7 +544,7 @@ namespace MES.Form
//
this.txtcreateTime.EditValue = null;
this.txtcreateTime.ImeMode = System.Windows.Forms.ImeMode.Off;
this.txtcreateTime.Location = new System.Drawing.Point(391, 110);
this.txtcreateTime.Location = new System.Drawing.Point(401, 110);
this.txtcreateTime.Name = "txtcreateTime";
this.txtcreateTime.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
@ -545,7 +552,7 @@ namespace MES.Form
new DevExpress.XtraEditors.Controls.EditorButton()});
this.txtcreateTime.Properties.DisplayFormat.FormatString = "G";
this.txtcreateTime.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime;
this.txtcreateTime.Size = new System.Drawing.Size(273, 20);
this.txtcreateTime.Size = new System.Drawing.Size(263, 20);
this.txtcreateTime.StyleController = this.layoutControl1;
this.txtcreateTime.TabIndex = 9;
//
@ -560,7 +567,7 @@ namespace MES.Form
this.txteditorId.Properties.PopupFilterMode = DevExpress.XtraEditors.PopupFilterMode.Contains;
this.txteditorId.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;
this.txteditorId.Properties.ValueMember = "ID";
this.txteditorId.Size = new System.Drawing.Size(273, 20);
this.txteditorId.Size = new System.Drawing.Size(283, 20);
this.txteditorId.StyleController = this.layoutControl1;
this.txteditorId.TabIndex = 10;
//
@ -568,7 +575,7 @@ namespace MES.Form
//
this.txteditTime.EditValue = null;
this.txteditTime.ImeMode = System.Windows.Forms.ImeMode.Off;
this.txteditTime.Location = new System.Drawing.Point(391, 134);
this.txteditTime.Location = new System.Drawing.Point(401, 134);
this.txteditTime.Name = "txteditTime";
this.txteditTime.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
@ -576,19 +583,19 @@ namespace MES.Form
new DevExpress.XtraEditors.Controls.EditorButton()});
this.txteditTime.Properties.DisplayFormat.FormatString = "G";
this.txteditTime.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime;
this.txteditTime.Size = new System.Drawing.Size(273, 20);
this.txteditTime.Size = new System.Drawing.Size(263, 20);
this.txteditTime.StyleController = this.layoutControl1;
this.txteditTime.TabIndex = 11;
//
// txtisForm
//
this.txtisForm.EditValue = null;
this.txtisForm.Location = new System.Drawing.Point(488, 62);
this.txtisForm.Location = new System.Drawing.Point(584, 62);
this.txtisForm.Name = "txtisForm";
this.txtisForm.Properties.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.Default;
this.txtisForm.Properties.Caption = "是否界面";
this.txtisForm.Properties.NullStyle = DevExpress.XtraEditors.Controls.StyleIndeterminate.Unchecked;
this.txtisForm.Size = new System.Drawing.Size(176, 19);
this.txtisForm.Size = new System.Drawing.Size(80, 19);
this.txtisForm.StyleController = this.layoutControl1;
this.txtisForm.TabIndex = 12;
//
@ -611,7 +618,8 @@ namespace MES.Form
this.layoutControlItem11,
this.layoutControlItem13,
this.layoutControlItem14,
this.layoutControlItem2});
this.layoutControlItem2,
this.layoutControlItem15});
this.layoutControlGroup1.Name = "layoutControlGroup1";
this.layoutControlGroup1.Size = new System.Drawing.Size(676, 394);
this.layoutControlGroup1.TextVisible = false;
@ -620,9 +628,9 @@ namespace MES.Form
//
this.layoutControlItem1.Control = this.txtpid;
this.layoutControlItem1.CustomizationFormText = "父id";
this.layoutControlItem1.Location = new System.Drawing.Point(164, 0);
this.layoutControlItem1.Location = new System.Drawing.Point(169, 0);
this.layoutControlItem1.Name = "layoutControlItem1";
this.layoutControlItem1.Size = new System.Drawing.Size(164, 24);
this.layoutControlItem1.Size = new System.Drawing.Size(169, 24);
this.layoutControlItem1.Text = "父id";
this.layoutControlItem1.TextSize = new System.Drawing.Size(48, 14);
//
@ -642,7 +650,7 @@ namespace MES.Form
this.layoutControlItem5.CustomizationFormText = "排序";
this.layoutControlItem5.Location = new System.Drawing.Point(0, 50);
this.layoutControlItem5.Name = "layoutControlItem5";
this.layoutControlItem5.Size = new System.Drawing.Size(328, 24);
this.layoutControlItem5.Size = new System.Drawing.Size(169, 24);
this.layoutControlItem5.Text = "排序";
this.layoutControlItem5.TextSize = new System.Drawing.Size(48, 14);
//
@ -662,7 +670,7 @@ namespace MES.Form
this.layoutControlItem8.CustomizationFormText = "创建人";
this.layoutControlItem8.Location = new System.Drawing.Point(0, 98);
this.layoutControlItem8.Name = "layoutControlItem8";
this.layoutControlItem8.Size = new System.Drawing.Size(328, 24);
this.layoutControlItem8.Size = new System.Drawing.Size(338, 24);
this.layoutControlItem8.Text = "创建人";
this.layoutControlItem8.TextSize = new System.Drawing.Size(48, 14);
//
@ -672,7 +680,7 @@ namespace MES.Form
this.layoutControlItem10.CustomizationFormText = "编辑人";
this.layoutControlItem10.Location = new System.Drawing.Point(0, 122);
this.layoutControlItem10.Name = "layoutControlItem10";
this.layoutControlItem10.Size = new System.Drawing.Size(328, 24);
this.layoutControlItem10.Size = new System.Drawing.Size(338, 24);
this.layoutControlItem10.Text = "编辑人";
this.layoutControlItem10.TextSize = new System.Drawing.Size(48, 14);
//
@ -680,9 +688,9 @@ namespace MES.Form
//
this.layoutControlItem4.Control = this.txtwinformType;
this.layoutControlItem4.CustomizationFormText = "菜单类型";
this.layoutControlItem4.Location = new System.Drawing.Point(327, 24);
this.layoutControlItem4.Location = new System.Drawing.Point(338, 24);
this.layoutControlItem4.Name = "layoutControlItem4";
this.layoutControlItem4.Size = new System.Drawing.Size(329, 26);
this.layoutControlItem4.Size = new System.Drawing.Size(318, 26);
this.layoutControlItem4.Text = "菜单类型";
this.layoutControlItem4.TextSize = new System.Drawing.Size(48, 14);
//
@ -690,9 +698,9 @@ namespace MES.Form
//
this.layoutControlItem6.Control = this.txtisEnabled;
this.layoutControlItem6.CustomizationFormText = "有效";
this.layoutControlItem6.Location = new System.Drawing.Point(328, 50);
this.layoutControlItem6.Location = new System.Drawing.Point(504, 50);
this.layoutControlItem6.Name = "layoutControlItem6";
this.layoutControlItem6.Size = new System.Drawing.Size(148, 24);
this.layoutControlItem6.Size = new System.Drawing.Size(68, 24);
this.layoutControlItem6.Text = "有效";
this.layoutControlItem6.TextSize = new System.Drawing.Size(0, 0);
this.layoutControlItem6.TextVisible = false;
@ -701,9 +709,9 @@ namespace MES.Form
//
this.layoutControlItem12.Control = this.txtisForm;
this.layoutControlItem12.CustomizationFormText = "是否界面";
this.layoutControlItem12.Location = new System.Drawing.Point(476, 50);
this.layoutControlItem12.Location = new System.Drawing.Point(572, 50);
this.layoutControlItem12.Name = "layoutControlItem12";
this.layoutControlItem12.Size = new System.Drawing.Size(180, 24);
this.layoutControlItem12.Size = new System.Drawing.Size(84, 24);
this.layoutControlItem12.Text = "是否界面";
this.layoutControlItem12.TextSize = new System.Drawing.Size(0, 0);
this.layoutControlItem12.TextVisible = false;
@ -720,9 +728,9 @@ namespace MES.Form
//
this.layoutControlItem9.Control = this.txtcreateTime;
this.layoutControlItem9.CustomizationFormText = "创建时间";
this.layoutControlItem9.Location = new System.Drawing.Point(328, 98);
this.layoutControlItem9.Location = new System.Drawing.Point(338, 98);
this.layoutControlItem9.Name = "layoutControlItem9";
this.layoutControlItem9.Size = new System.Drawing.Size(328, 24);
this.layoutControlItem9.Size = new System.Drawing.Size(318, 24);
this.layoutControlItem9.Text = "创建时间";
this.layoutControlItem9.TextSize = new System.Drawing.Size(48, 14);
//
@ -730,9 +738,9 @@ namespace MES.Form
//
this.layoutControlItem11.Control = this.txteditTime;
this.layoutControlItem11.CustomizationFormText = "编辑时间";
this.layoutControlItem11.Location = new System.Drawing.Point(328, 122);
this.layoutControlItem11.Location = new System.Drawing.Point(338, 122);
this.layoutControlItem11.Name = "layoutControlItem11";
this.layoutControlItem11.Size = new System.Drawing.Size(328, 24);
this.layoutControlItem11.Size = new System.Drawing.Size(318, 24);
this.layoutControlItem11.Text = "编辑时间";
this.layoutControlItem11.TextSize = new System.Drawing.Size(48, 14);
//
@ -741,7 +749,7 @@ namespace MES.Form
this.layoutControlItem13.Control = this.simpleButton1;
this.layoutControlItem13.Location = new System.Drawing.Point(299, 24);
this.layoutControlItem13.Name = "layoutControlItem13";
this.layoutControlItem13.Size = new System.Drawing.Size(28, 26);
this.layoutControlItem13.Size = new System.Drawing.Size(39, 26);
this.layoutControlItem13.TextSize = new System.Drawing.Size(0, 0);
this.layoutControlItem13.TextVisible = false;
//
@ -750,16 +758,16 @@ namespace MES.Form
this.layoutControlItem14.Control = this.txtid;
this.layoutControlItem14.Location = new System.Drawing.Point(0, 0);
this.layoutControlItem14.Name = "layoutControlItem14";
this.layoutControlItem14.Size = new System.Drawing.Size(164, 24);
this.layoutControlItem14.Size = new System.Drawing.Size(169, 24);
this.layoutControlItem14.Text = "id";
this.layoutControlItem14.TextSize = new System.Drawing.Size(48, 14);
//
// layoutControlItem2
//
this.layoutControlItem2.Control = this.txtname;
this.layoutControlItem2.Location = new System.Drawing.Point(328, 0);
this.layoutControlItem2.Location = new System.Drawing.Point(338, 0);
this.layoutControlItem2.Name = "layoutControlItem2";
this.layoutControlItem2.Size = new System.Drawing.Size(328, 24);
this.layoutControlItem2.Size = new System.Drawing.Size(318, 24);
this.layoutControlItem2.Text = "菜单名称";
this.layoutControlItem2.TextSize = new System.Drawing.Size(48, 14);
//
@ -767,6 +775,31 @@ namespace MES.Form
//
this.xtraOpenFileDialog1.FileName = "xtraOpenFileDialog1";
//
// gridColumn15
//
this.gridColumn15.Caption = "权限编码";
this.gridColumn15.FieldName = "functionCode";
this.gridColumn15.Name = "gridColumn15";
this.gridColumn15.Visible = true;
this.gridColumn15.VisibleIndex = 13;
//
// txtfunctionCode
//
this.txtfunctionCode.Location = new System.Drawing.Point(232, 62);
this.txtfunctionCode.Name = "txtfunctionCode";
this.txtfunctionCode.Size = new System.Drawing.Size(280, 20);
this.txtfunctionCode.StyleController = this.layoutControl1;
this.txtfunctionCode.TabIndex = 16;
//
// layoutControlItem15
//
this.layoutControlItem15.Control = this.txtfunctionCode;
this.layoutControlItem15.Location = new System.Drawing.Point(169, 50);
this.layoutControlItem15.Name = "layoutControlItem15";
this.layoutControlItem15.Size = new System.Drawing.Size(335, 24);
this.layoutControlItem15.Text = "权限编码";
this.layoutControlItem15.TextSize = new System.Drawing.Size(48, 14);
//
// FrmsysMenu
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 14F);
@ -825,6 +858,8 @@ namespace MES.Form
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem13)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem14)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.txtfunctionCode.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem15)).EndInit();
this.ResumeLayout(false);
}
@ -902,5 +937,8 @@ namespace MES.Form
private DevExpress.XtraGrid.Columns.GridColumn gridColumn14;
private DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit repositoryItemCheckEdit1;
private DevExpress.XtraEditors.Repository.RepositoryItemCheckedComboBoxEdit repositoryItemCheckedComboBoxEdit1;
private DevExpress.XtraGrid.Columns.GridColumn gridColumn15;
private TextEdit txtfunctionCode;
private LayoutControlItem layoutControlItem15;
}
}

View File

@ -82,6 +82,7 @@ namespace WinformGeneralDeveloperFrame
foreach (var item in data)
{
if(!AppInfo.FunctionList.Contains(item.functionCode))continue;
SimpleButton btn = new SimpleButton();
btn.Name = "btn" + item.id;
btn.Size = new System.Drawing.Size(90, 75);

View File

@ -29,6 +29,18 @@ namespace WinformGeneralDeveloperFrame
SplashScreenManager.CloseForm(false);
}
private void InitData()
{
using (var db=new MESDB())
{
AppInfo.FunctionList = db.Database.SqlQuery<string>(string.Format(@"SELECT a.functionCode
FROM[winformdevfarme].[dbo].[sysFunction] a
left join[winformdevfarme].[dbo].[sysRoleFunction] b on a.id = b.functionId
left join[winformdevfarme].[dbo].[sysUserRole] c on b.roleId = c.roleId
left join[winformdevfarme].[dbo].[sysUser] d on d.id = c.userId
where d.account = '{0}'",AppInfo.LoginUserInfo.account)).ToListAsync().Result;
}
}
private void ribbonControl1_Click(object sender, EventArgs e)
{
@ -57,6 +69,7 @@ namespace WinformGeneralDeveloperFrame
private void Init()
{
InitData();
NarBarInit();
}
@ -68,15 +81,14 @@ namespace WinformGeneralDeveloperFrame
{
menusList=db.sysMenuInfo.Where(p=>p.isEnabled).ToList();
}
foreach (var item in menusList)
{
if (item.pid == 0)
if (item.pid == 0&&AppInfo.FunctionList.Contains(item.functionCode))
{
NavBarGroup gNavBarGroup = new NavBarGroup(item.name);
foreach (var itemInfo in menusList)
{
if (itemInfo.pid == item.id)
if (itemInfo.pid == item.id && AppInfo.FunctionList.Contains(itemInfo.functionCode))
{
NavBarItem navBarItem = new NavBarItem(itemInfo.name);
navBarItem.LinkClicked += (sender, args) =>