From 8bd3de7c0d83a82c448a6500621877a84bc98b13 Mon Sep 17 00:00:00 2001 From: cloud301530 <2690004082@qq.com> Date: Mon, 23 Dec 2024 20:42:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9D=83=E9=99=90=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/PBAnaly/LoginCommon/AccessControl.cs | 119 +++++++++ .../LoginCommon/RoleManageForm.Designer.cs | 209 ++++++++++++++++ src/PBAnaly/LoginCommon/RoleManageForm.cs | 162 ++++++++++++ src/PBAnaly/LoginCommon/RoleManageForm.resx | 138 ++++++++++ .../LoginCommon/UserManageForm.Designer.cs | 235 ++++++++++-------- src/PBAnaly/LoginCommon/UserManageForm.cs | 18 ++ src/PBAnaly/MainForm.cs | 182 ++++++++++++++ src/PBAnaly/PBAnaly.csproj | 10 + src/PBAnaly/Program.cs | 1 + src/PBAnaly/UI/SystemSettingForm.cs | 18 +- 10 files changed, 983 insertions(+), 109 deletions(-) create mode 100644 src/PBAnaly/LoginCommon/AccessControl.cs create mode 100644 src/PBAnaly/LoginCommon/RoleManageForm.Designer.cs create mode 100644 src/PBAnaly/LoginCommon/RoleManageForm.cs create mode 100644 src/PBAnaly/LoginCommon/RoleManageForm.resx diff --git a/src/PBAnaly/LoginCommon/AccessControl.cs b/src/PBAnaly/LoginCommon/AccessControl.cs new file mode 100644 index 0000000..7edd52b --- /dev/null +++ b/src/PBAnaly/LoginCommon/AccessControl.cs @@ -0,0 +1,119 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace PBAnaly.LoginCommon +{ + /// + /// 权限管理 + /// + public class AccessControl + { + /// + /// 权限管理项集合 + /// + public static List AccessItems = new List(); + /// + /// 加载配置文件 + /// + public static void LoadConfig() + { + try + { + if (File.Exists("AccessControl.xml")) + { + FileStream fs = new FileStream("AccessControl.xml", FileMode.Open); + XmlSerializer xs = new XmlSerializer(typeof(List)); + AccessItems = xs.Deserialize(fs) as List; + fs.Close(); + } + else + { + System.Windows.Forms.MessageBox.Show("加载配置文件AccessControl.xml不存在。即将推出程序."); + } + } + catch (Exception ex) + { + System.Windows.Forms.MessageBox.Show(string.Format("加载配置文件AccessControl.xml出错。错误原因:{0}即将推出程序.", ex.Message)); + throw ex; + } + } + /// + /// 保存配置文件 + /// + public static void SaveConfig() + { + FileStream fs = new FileStream("AccessControl.xml", FileMode.Create); + XmlSerializer xs = new XmlSerializer(typeof(List)); + xs.Serialize(fs, AccessItems); + fs.Close(); + } + + public static void SaveBinaryConfig() + { + IFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); + Stream fs = new FileStream("AccessControl.bin", FileMode.Create); + formatter.Serialize(fs, AccessItems); + fs.Close(); + } + + public static void LoadBinaryConfig() + { + IFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); + Stream fs = new FileStream("AccessControl.bin", FileMode.Open); + AccessItems = (List)formatter.Deserialize(fs); + fs.Close(); + } + } + + + + + + + #region AccessItem 权限管理项 + /// + /// 权限管理项 + /// + [XmlType(TypeName = "item")] + [Serializable] + public class AccessItem + { + /// + /// 编号 + /// + [XmlAttribute] + public int Id = 0; + /// + /// 操作员是否可操作,true-可操作,false-不可操作 + /// + [XmlAttribute] + public bool Operator = false; + /// + /// 工程师是否可操作,true-可操作,false-不可操作 + /// + [XmlAttribute] + public bool Engineer = false; + /// + /// 管理员是否可操作,true-可操作,false-不可操作 + /// + [XmlAttribute] + public bool Administrator = false; + /// + /// 超级管理员是否可操作,true-可操作,false-不可操作 + /// + [XmlAttribute] + public bool SuperAdministrator = false; + /// + /// 描述是否可操作,true-可操作,false-不可操作 + /// + [XmlAttribute] + public string Disrible = ""; + } + #endregion +} diff --git a/src/PBAnaly/LoginCommon/RoleManageForm.Designer.cs b/src/PBAnaly/LoginCommon/RoleManageForm.Designer.cs new file mode 100644 index 0000000..07f0e3b --- /dev/null +++ b/src/PBAnaly/LoginCommon/RoleManageForm.Designer.cs @@ -0,0 +1,209 @@ +namespace PBAnaly.LoginCommon +{ + partial class RoleManageForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); + this.panel1 = new System.Windows.Forms.Panel(); + this.btn_Close = new System.Windows.Forms.Button(); + this.dataGridView1 = new System.Windows.Forms.DataGridView(); + this.btn_save = new System.Windows.Forms.Button(); + this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Column3 = new System.Windows.Forms.DataGridViewCheckBoxColumn(); + this.Column4 = new System.Windows.Forms.DataGridViewCheckBoxColumn(); + this.Column5 = new System.Windows.Forms.DataGridViewCheckBoxColumn(); + this.Column6 = new System.Windows.Forms.DataGridViewCheckBoxColumn(); + this.panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); + this.SuspendLayout(); + // + // panel1 + // + this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.panel1.BackColor = System.Drawing.Color.White; + this.panel1.Controls.Add(this.btn_save); + this.panel1.Controls.Add(this.dataGridView1); + this.panel1.Location = new System.Drawing.Point(0, 27); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(756, 569); + this.panel1.TabIndex = 0; + // + // btn_Close + // + this.btn_Close.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btn_Close.BackColor = System.Drawing.Color.Transparent; + this.btn_Close.FlatAppearance.BorderSize = 0; + this.btn_Close.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_Close.ForeColor = System.Drawing.Color.Transparent; + this.btn_Close.Image = global::PBAnaly.Properties.Resources.关闭White; + this.btn_Close.Location = new System.Drawing.Point(712, 0); + this.btn_Close.Name = "btn_Close"; + this.btn_Close.Size = new System.Drawing.Size(44, 28); + this.btn_Close.TabIndex = 458; + this.btn_Close.UseVisualStyleBackColor = false; + this.btn_Close.Click += new System.EventHandler(this.btn_Close_Click); + // + // dataGridView1 + // + this.dataGridView1.AllowUserToAddRows = false; + this.dataGridView1.AllowUserToResizeRows = false; + dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.GradientInactiveCaption; + this.dataGridView1.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; + this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + this.dataGridView1.BackgroundColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.InactiveCaption; + dataGridViewCellStyle2.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2; + this.dataGridView1.ColumnHeadersHeight = 30; + this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.Column1, + this.Column2, + this.Column3, + this.Column4, + this.Column5, + this.Column6}); + dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle3.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.dataGridView1.DefaultCellStyle = dataGridViewCellStyle3; + this.dataGridView1.GridColor = System.Drawing.SystemColors.ControlLightLight; + this.dataGridView1.Location = new System.Drawing.Point(0, 0); + this.dataGridView1.Name = "dataGridView1"; + this.dataGridView1.RowHeadersVisible = false; + dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + this.dataGridView1.RowsDefaultCellStyle = dataGridViewCellStyle4; + this.dataGridView1.RowTemplate.Height = 23; + this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect; + this.dataGridView1.Size = new System.Drawing.Size(632, 569); + this.dataGridView1.TabIndex = 4; + // + // btn_save + // + this.btn_save.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(32)))), ((int)(((byte)(96))))); + this.btn_save.FlatAppearance.BorderSize = 0; + this.btn_save.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_save.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Bold); + this.btn_save.ForeColor = System.Drawing.Color.White; + this.btn_save.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.btn_save.Location = new System.Drawing.Point(641, 49); + this.btn_save.Name = "btn_save"; + this.btn_save.Size = new System.Drawing.Size(101, 38); + this.btn_save.TabIndex = 506; + this.btn_save.Text = "保存"; + this.btn_save.UseVisualStyleBackColor = false; + this.btn_save.Click += new System.EventHandler(this.btn_save_Click); + // + // Column1 + // + this.Column1.HeaderText = "序号"; + this.Column1.Name = "Column1"; + // + // Column2 + // + this.Column2.HeaderText = "描述"; + this.Column2.Name = "Column2"; + this.Column2.ReadOnly = true; + // + // Column3 + // + this.Column3.HeaderText = "操作员"; + this.Column3.Name = "Column3"; + this.Column3.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.Column3.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; + // + // Column4 + // + this.Column4.HeaderText = "工程师"; + this.Column4.Name = "Column4"; + this.Column4.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.Column4.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; + // + // Column5 + // + this.Column5.HeaderText = "管理员"; + this.Column5.Name = "Column5"; + this.Column5.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.Column5.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; + // + // Column6 + // + this.Column6.HeaderText = "超级管理员"; + this.Column6.Name = "Column6"; + this.Column6.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.Column6.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; + // + // RoleManageForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48))))); + this.ClientSize = new System.Drawing.Size(754, 595); + this.Controls.Add(this.btn_Close); + this.Controls.Add(this.panel1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; + this.Name = "RoleManageForm"; + this.Text = "RoleManageForm"; + this.Load += new System.EventHandler(this.RoleManageForm_Load); + this.panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.DataGridView dataGridView1; + private System.Windows.Forms.Button btn_Close; + private System.Windows.Forms.Button btn_save; + private System.Windows.Forms.DataGridViewTextBoxColumn Column1; + private System.Windows.Forms.DataGridViewTextBoxColumn Column2; + private System.Windows.Forms.DataGridViewCheckBoxColumn Column3; + private System.Windows.Forms.DataGridViewCheckBoxColumn Column4; + private System.Windows.Forms.DataGridViewCheckBoxColumn Column5; + private System.Windows.Forms.DataGridViewCheckBoxColumn Column6; + } +} \ No newline at end of file diff --git a/src/PBAnaly/LoginCommon/RoleManageForm.cs b/src/PBAnaly/LoginCommon/RoleManageForm.cs new file mode 100644 index 0000000..a730897 --- /dev/null +++ b/src/PBAnaly/LoginCommon/RoleManageForm.cs @@ -0,0 +1,162 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace PBAnaly.LoginCommon +{ + public partial class RoleManageForm : Form + { + public RoleManageForm() + { + InitializeComponent(); + + // 设置窗体的启动位置为屏幕的中心 + this.StartPosition = FormStartPosition.CenterScreen; + this.Location = new System.Drawing.Point((Screen.PrimaryScreen.WorkingArea.Width - this.Width) / 2, + (Screen.PrimaryScreen.WorkingArea.Height - this.Height) / 2); + } + + #region =====重写WndPoc方法 无边框窗体更改大小及拖动========= + const int HTLEFT = 10; + const int HTRIGHT = 11; + const int HTTOP = 12; + const int HTTOPLEFT = 13; + const int HTTOPRIGHT = 14; + const int HTBOTTOM = 15; + const int HTBOTTOMLEFT = 0x10; + const int HTBOTTOMRIGHT = 17; + protected override void WndProc(ref System.Windows.Forms.Message m) + { + try + { + switch (m.Msg) + { + case 0x0084: + base.WndProc(ref m); + System.Drawing.Point vPoint = new System.Drawing.Point((int)m.LParam & 0xFFFF, (int)m.LParam >> 16 & 0xFFFF); + vPoint = PointToClient(vPoint); + if (vPoint.X <= 5) + { + if (vPoint.Y <= 5) + { + m.Result = (IntPtr)HTTOPLEFT; + } + else if (vPoint.Y >= ClientSize.Height - 5) + { + m.Result = (IntPtr)HTBOTTOMLEFT; + } + else + { + m.Result = (IntPtr)HTLEFT; + } + } + else if (vPoint.X >= ClientSize.Width - 5) + { + if (vPoint.Y <= 5) + { + m.Result = (IntPtr)HTTOPRIGHT; + } + else if (vPoint.Y >= ClientSize.Height - 5) + { + m.Result = (IntPtr)HTBOTTOMRIGHT; + } + else + { + m.Result = (IntPtr)HTRIGHT; + } + } + else if (vPoint.Y <= 5) + { + m.Result = (IntPtr)HTTOP; + } + else if (vPoint.Y >= ClientSize.Height - 5) + { + m.Result = (IntPtr)HTBOTTOM; + } + break; + + case 0x0201://鼠标左键按下的消息 用于实现拖动窗口功能 + m.Msg = 0x00A1;//更改消息为非客户区按下鼠标 + m.LParam = IntPtr.Zero;//默认值 + m.WParam = new IntPtr(2);//鼠标放在标题栏内 + base.WndProc(ref m); + break; + + default: + base.WndProc(ref m); + break; + } + } + catch (Exception ex) + { + //showERRORMsg($"重写WndPoc方法 无边框窗体更改大小及拖动方法发生异常,原因:{ex.Message}"); + } + + } + #endregion + + private void btn_save_Click(object sender, EventArgs e) + { + try + { + List items = new List(); + for (int index = 0; index < dataGridView1.RowCount; index++) + { + DataGridViewRow row = dataGridView1.Rows[index]; + AccessItem item = new AccessItem(); + item.Id = (int)row.Cells[0].Value; + item.Disrible = (string)row.Cells[1].Value; + item.Operator = (bool)row.Cells[2].Value; + item.Engineer = (bool)row.Cells[3].Value; + item.Administrator = (bool)row.Cells[4].Value; + item.SuperAdministrator = true; + items.Add(item); + } + AccessControl.AccessItems = items; + AccessControl.SaveConfig(); + + MessageBox.Show("success"); + } + catch (Exception ex) + { + + } + } + + private void RoleManageForm_Load(object sender, EventArgs e) + { + try + { + for (int index = 0; index < AccessControl.AccessItems.Count; index++) + { + DataGridViewRow dr = new DataGridViewRow(); + dr.CreateCells(dataGridView1); + dr.Cells[0].Value = AccessControl.AccessItems[index].Id; + dr.Cells[1].Value = AccessControl.AccessItems[index].Disrible; + dr.Cells[2].Value = AccessControl.AccessItems[index].Operator; + dr.Cells[3].Value = AccessControl.AccessItems[index].Engineer; + dr.Cells[4].Value = AccessControl.AccessItems[index].SuperAdministrator; + dr.Cells[5].Value = AccessControl.AccessItems[index].Administrator; + + + dataGridView1.Rows.Add(dr); + } + } + catch (Exception ex) + { + + } + } + + private void btn_Close_Click(object sender, EventArgs e) + { + Close(); + } + } +} diff --git a/src/PBAnaly/LoginCommon/RoleManageForm.resx b/src/PBAnaly/LoginCommon/RoleManageForm.resx new file mode 100644 index 0000000..b851021 --- /dev/null +++ b/src/PBAnaly/LoginCommon/RoleManageForm.resx @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + + True + + + True + + + True + + + True + + \ No newline at end of file diff --git a/src/PBAnaly/LoginCommon/UserManageForm.Designer.cs b/src/PBAnaly/LoginCommon/UserManageForm.Designer.cs index f6503fb..d583fdd 100644 --- a/src/PBAnaly/LoginCommon/UserManageForm.Designer.cs +++ b/src/PBAnaly/LoginCommon/UserManageForm.Designer.cs @@ -28,11 +28,11 @@ /// private void InitializeComponent() { - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle26 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle27 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle28 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle29 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle30 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.dataGridView1 = new System.Windows.Forms.DataGridView(); this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); @@ -42,24 +42,25 @@ this.Column4 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.tabControl1 = new System.Windows.Forms.TabControl(); this.tab_fix = new System.Windows.Forms.TabPage(); + this.btn_role_manage = new System.Windows.Forms.Button(); this.btn_fix_role = new System.Windows.Forms.Button(); this.txt_UserName = new System.Windows.Forms.TextBox(); this.label11 = new System.Windows.Forms.Label(); this.cbx_role_role = new System.Windows.Forms.ComboBox(); this.label12 = new System.Windows.Forms.Label(); this.tab_delete = new System.Windows.Forms.TabPage(); + this.btn_delete_user = new System.Windows.Forms.Button(); + this.label1 = new System.Windows.Forms.Label(); this.tab_fix_password = new System.Windows.Forms.TabPage(); + this.btn_FixPassword = new System.Windows.Forms.Button(); + this.txt_password = new System.Windows.Forms.TextBox(); + this.label3 = new System.Windows.Forms.Label(); + this.txt_fix_p_UserName = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); this.panel1 = new System.Windows.Forms.Panel(); this.btn_delete = new System.Windows.Forms.Button(); this.btn_edit_password = new System.Windows.Forms.Button(); this.btn_editRole = new System.Windows.Forms.Button(); - this.label1 = new System.Windows.Forms.Label(); - this.btn_delete_user = new System.Windows.Forms.Button(); - this.txt_fix_p_UserName = new System.Windows.Forms.TextBox(); - this.label2 = new System.Windows.Forms.Label(); - this.txt_password = new System.Windows.Forms.TextBox(); - this.label3 = new System.Windows.Forms.Label(); - this.btn_FixPassword = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout(); @@ -99,14 +100,14 @@ this.dataGridView1.AllowUserToResizeRows = false; this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView1.BackgroundColor = System.Drawing.Color.White; - dataGridViewCellStyle26.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle26.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle26.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle26.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle26.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle26.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle26.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle26; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.Column1, @@ -128,8 +129,8 @@ // // Column1 // - dataGridViewCellStyle27.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - this.Column1.DefaultCellStyle = dataGridViewCellStyle27; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + this.Column1.DefaultCellStyle = dataGridViewCellStyle2; this.Column1.HeaderText = "序号"; this.Column1.Name = "Column1"; this.Column1.ReadOnly = true; @@ -137,8 +138,8 @@ // // Column2 // - dataGridViewCellStyle28.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - this.Column2.DefaultCellStyle = dataGridViewCellStyle28; + dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + this.Column2.DefaultCellStyle = dataGridViewCellStyle3; this.Column2.HeaderText = "用户名"; this.Column2.Name = "Column2"; this.Column2.ReadOnly = true; @@ -152,8 +153,8 @@ // // Column3 // - dataGridViewCellStyle29.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - this.Column3.DefaultCellStyle = dataGridViewCellStyle29; + dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + this.Column3.DefaultCellStyle = dataGridViewCellStyle4; this.Column3.HeaderText = "创建时间"; this.Column3.Name = "Column3"; this.Column3.ReadOnly = true; @@ -161,8 +162,8 @@ // // Column4 // - dataGridViewCellStyle30.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - this.Column4.DefaultCellStyle = dataGridViewCellStyle30; + dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + this.Column4.DefaultCellStyle = dataGridViewCellStyle5; this.Column4.HeaderText = "权限"; this.Column4.Name = "Column4"; this.Column4.ReadOnly = true; @@ -184,6 +185,7 @@ // // tab_fix // + this.tab_fix.Controls.Add(this.btn_role_manage); this.tab_fix.Controls.Add(this.btn_fix_role); this.tab_fix.Controls.Add(this.txt_UserName); this.tab_fix.Controls.Add(this.label11); @@ -197,6 +199,22 @@ this.tab_fix.Text = "修改权限"; this.tab_fix.UseVisualStyleBackColor = true; // + // btn_role_manage + // + this.btn_role_manage.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(32)))), ((int)(((byte)(96))))); + this.btn_role_manage.FlatAppearance.BorderSize = 0; + this.btn_role_manage.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_role_manage.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Bold); + this.btn_role_manage.ForeColor = System.Drawing.Color.White; + this.btn_role_manage.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.btn_role_manage.Location = new System.Drawing.Point(284, 305); + this.btn_role_manage.Name = "btn_role_manage"; + this.btn_role_manage.Size = new System.Drawing.Size(101, 38); + this.btn_role_manage.TabIndex = 506; + this.btn_role_manage.Text = "权限管理"; + this.btn_role_manage.UseVisualStyleBackColor = false; + this.btn_role_manage.Click += new System.EventHandler(this.btn_role_manage_Click); + // // btn_fix_role // this.btn_fix_role.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(32)))), ((int)(((byte)(96))))); @@ -270,6 +288,31 @@ this.tab_delete.Text = "删除"; this.tab_delete.UseVisualStyleBackColor = true; // + // btn_delete_user + // + this.btn_delete_user.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(32)))), ((int)(((byte)(96))))); + this.btn_delete_user.FlatAppearance.BorderSize = 0; + this.btn_delete_user.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_delete_user.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Bold); + this.btn_delete_user.ForeColor = System.Drawing.Color.White; + this.btn_delete_user.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.btn_delete_user.Location = new System.Drawing.Point(155, 74); + this.btn_delete_user.Name = "btn_delete_user"; + this.btn_delete_user.Size = new System.Drawing.Size(78, 38); + this.btn_delete_user.TabIndex = 499; + this.btn_delete_user.Text = "删除"; + this.btn_delete_user.UseVisualStyleBackColor = false; + this.btn_delete_user.Click += new System.EventHandler(this.btn_delete_user_Click); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(119, 17); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(161, 12); + this.label1.TabIndex = 0; + this.label1.Text = "选中左侧表格的一行即可删除"; + // // tab_fix_password // this.tab_fix_password.Controls.Add(this.btn_FixPassword); @@ -285,6 +328,61 @@ this.tab_fix_password.Text = "修改密码"; this.tab_fix_password.UseVisualStyleBackColor = true; // + // btn_FixPassword + // + this.btn_FixPassword.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(32)))), ((int)(((byte)(96))))); + this.btn_FixPassword.FlatAppearance.BorderSize = 0; + this.btn_FixPassword.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_FixPassword.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Bold); + this.btn_FixPassword.ForeColor = System.Drawing.Color.White; + this.btn_FixPassword.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.btn_FixPassword.Location = new System.Drawing.Point(285, 216); + this.btn_FixPassword.Name = "btn_FixPassword"; + this.btn_FixPassword.Size = new System.Drawing.Size(101, 38); + this.btn_FixPassword.TabIndex = 509; + this.btn_FixPassword.Text = "修改密码"; + this.btn_FixPassword.UseVisualStyleBackColor = false; + this.btn_FixPassword.Click += new System.EventHandler(this.btn_FixPassword_Click); + // + // txt_password + // + this.txt_password.Font = new System.Drawing.Font("宋体", 10F); + this.txt_password.Location = new System.Drawing.Point(94, 148); + this.txt_password.Multiline = true; + this.txt_password.Name = "txt_password"; + this.txt_password.Size = new System.Drawing.Size(292, 28); + this.txt_password.TabIndex = 508; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Font = new System.Drawing.Font("宋体", 15F); + this.label3.Location = new System.Drawing.Point(39, 156); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(49, 20); + this.label3.TabIndex = 507; + this.label3.Text = "密码"; + // + // txt_fix_p_UserName + // + this.txt_fix_p_UserName.Font = new System.Drawing.Font("宋体", 13F); + this.txt_fix_p_UserName.Location = new System.Drawing.Point(94, 46); + this.txt_fix_p_UserName.Multiline = true; + this.txt_fix_p_UserName.Name = "txt_fix_p_UserName"; + this.txt_fix_p_UserName.ReadOnly = true; + this.txt_fix_p_UserName.Size = new System.Drawing.Size(292, 28); + this.txt_fix_p_UserName.TabIndex = 506; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("宋体", 15F); + this.label2.Location = new System.Drawing.Point(19, 54); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(69, 20); + this.label2.TabIndex = 505; + this.label2.Text = "用户名"; + // // panel1 // this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) @@ -352,86 +450,6 @@ this.btn_editRole.UseVisualStyleBackColor = false; this.btn_editRole.Click += new System.EventHandler(this.btn_editRole_Click); // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(119, 17); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(161, 12); - this.label1.TabIndex = 0; - this.label1.Text = "选中左侧表格的一行即可删除"; - // - // btn_delete_user - // - this.btn_delete_user.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(32)))), ((int)(((byte)(96))))); - this.btn_delete_user.FlatAppearance.BorderSize = 0; - this.btn_delete_user.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btn_delete_user.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Bold); - this.btn_delete_user.ForeColor = System.Drawing.Color.White; - this.btn_delete_user.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; - this.btn_delete_user.Location = new System.Drawing.Point(155, 74); - this.btn_delete_user.Name = "btn_delete_user"; - this.btn_delete_user.Size = new System.Drawing.Size(78, 38); - this.btn_delete_user.TabIndex = 499; - this.btn_delete_user.Text = "删除"; - this.btn_delete_user.UseVisualStyleBackColor = false; - this.btn_delete_user.Click += new System.EventHandler(this.btn_delete_user_Click); - // - // txt_fix_p_UserName - // - this.txt_fix_p_UserName.Font = new System.Drawing.Font("宋体", 13F); - this.txt_fix_p_UserName.Location = new System.Drawing.Point(94, 46); - this.txt_fix_p_UserName.Multiline = true; - this.txt_fix_p_UserName.Name = "txt_fix_p_UserName"; - this.txt_fix_p_UserName.ReadOnly = true; - this.txt_fix_p_UserName.Size = new System.Drawing.Size(292, 28); - this.txt_fix_p_UserName.TabIndex = 506; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Font = new System.Drawing.Font("宋体", 15F); - this.label2.Location = new System.Drawing.Point(19, 54); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(69, 20); - this.label2.TabIndex = 505; - this.label2.Text = "用户名"; - // - // txt_password - // - this.txt_password.Font = new System.Drawing.Font("宋体", 10F); - this.txt_password.Location = new System.Drawing.Point(94, 148); - this.txt_password.Multiline = true; - this.txt_password.Name = "txt_password"; - this.txt_password.Size = new System.Drawing.Size(292, 28); - this.txt_password.TabIndex = 508; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Font = new System.Drawing.Font("宋体", 15F); - this.label3.Location = new System.Drawing.Point(39, 156); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(49, 20); - this.label3.TabIndex = 507; - this.label3.Text = "密码"; - // - // btn_FixPassword - // - this.btn_FixPassword.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(32)))), ((int)(((byte)(96))))); - this.btn_FixPassword.FlatAppearance.BorderSize = 0; - this.btn_FixPassword.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btn_FixPassword.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Bold); - this.btn_FixPassword.ForeColor = System.Drawing.Color.White; - this.btn_FixPassword.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; - this.btn_FixPassword.Location = new System.Drawing.Point(285, 216); - this.btn_FixPassword.Name = "btn_FixPassword"; - this.btn_FixPassword.Size = new System.Drawing.Size(101, 38); - this.btn_FixPassword.TabIndex = 509; - this.btn_FixPassword.Text = "修改密码"; - this.btn_FixPassword.UseVisualStyleBackColor = false; - this.btn_FixPassword.Click += new System.EventHandler(this.btn_FixPassword_Click); - // // UserManageForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); @@ -487,5 +505,6 @@ private System.Windows.Forms.Label label3; private System.Windows.Forms.TextBox txt_fix_p_UserName; private System.Windows.Forms.Label label2; + private System.Windows.Forms.Button btn_role_manage; } } \ No newline at end of file diff --git a/src/PBAnaly/LoginCommon/UserManageForm.cs b/src/PBAnaly/LoginCommon/UserManageForm.cs index a1cb08b..25ed097 100644 --- a/src/PBAnaly/LoginCommon/UserManageForm.cs +++ b/src/PBAnaly/LoginCommon/UserManageForm.cs @@ -48,6 +48,18 @@ namespace PBAnaly.LoginCommon index++; } } + + if (UserManage.IsLogined) + { + if(UserManage.LogionUser.Role == UserRole.SuperAdministrator) + { + btn_role_manage.Visible = true; + } + else + { + btn_role_manage.Visible = false; + } + } } catch (Exception) { @@ -220,5 +232,11 @@ namespace PBAnaly.LoginCommon } } #endregion + + private void btn_role_manage_Click(object sender, EventArgs e) + { + RoleManageForm roleManageForm = new RoleManageForm(); + roleManageForm.ShowDialog(); + } } } diff --git a/src/PBAnaly/MainForm.cs b/src/PBAnaly/MainForm.cs index a1e1267..9dd1a45 100644 --- a/src/PBAnaly/MainForm.cs +++ b/src/PBAnaly/MainForm.cs @@ -3,6 +3,7 @@ using MaterialSkin; using MaterialSkin.Controls; using OpenCvSharp.Flann; using OpenTK; +using PBAnaly.LoginCommon; using PBAnaly.Module; using PBAnaly.Properties; using PBAnaly.UI; @@ -73,6 +74,12 @@ namespace PBAnaly loginForm.Hide(); + UserManage.LogionUserChanged += OnLogionUserChanged; + + InitAccessControls(); + + OnLogionUser(); + UIInit(); FormGenerate_X = 0; @@ -81,6 +88,181 @@ namespace PBAnaly } + #region 重新梳理权限控制,控件的权限可通过管理员进行配置 + /// + /// 用于权限控制,将所有要管控的控件保存到mControls中 + /// + private Control[] mControls; + + /// + /// 初始化权限控件集合 + /// + private void InitAccessControls() + { + mControls = new Control[] + { + materialButton_setting, //0、系统设置 + materialButton_curveimage, //1、泳道波形图 + materialButton_analyzedata, //2、分析数据 + materialButton_outimage, //3、导出图像 + materialButton_LoadData, //4、加载数据 + materialButton_imageProcess, //5、图像处理 + materialButton_acidAnalyze, //6、泳道分析 + materialButton_roiAnalyze, //7、ROIs分析 + materialButton_miniAnalyze, //8、微孔版分析 + materialButton_dotcounts, //9、菌落计数 + materialButton_correction //10、蛋白归一化 + }; + } + + #region OnLogionUserChanged 处理登录用户更改事件 + /// + /// 处理登录用户更改事件 + /// + /// + /// + private void OnLogionUserChanged(object sender, EventArgs e) + { + if (UserManage.IsLogined) + { + switch (UserManage.LogionUser.Role) + { + case UserRole.Operator: + SetOperatorRole(); + break; + case UserRole.Engineer: + SetEngineerRole(); + break; + case UserRole.Administrator: + SetAdministratorRole(); + break; + case UserRole.SuperAdministrator: + SetSuperAdministratorRole(); + break; + } + } + else + { + CloseControlEnabled(); + } + } + + private void OnLogionUser() + { + if (UserManage.IsLogined) + { + switch (UserManage.LogionUser.Role) + { + case UserRole.Operator: + SetOperatorRole(); + break; + case UserRole.Engineer: + SetEngineerRole(); + + break; + case UserRole.Administrator: + SetAdministratorRole(); + break; + case UserRole.SuperAdministrator: + SetSuperAdministratorRole(); + break; + } + } + else + { + CloseControlEnabled(); + } + } + + #endregion + + #region CloseControlEnabled 关闭控件权限,在未登录时使用 + /// + /// 关闭控件权限,在未登录时使用 + /// + private void CloseControlEnabled() + { + if (InvokeRequired) + { + BeginInvoke(new Action(CloseControlEnabled)); + } + else + { + SetControlsEnabled(false); + } + } + #endregion + + #region SetControlsEnabled 设置控件是否可以对用户交互作出响应。 + /// + /// 设置控件是否可以对用户交互作出响应。 + /// + /// true-可以对用户交互作出响应;false-不可以对用户交互作出响应。 + public void SetControlsEnabled(bool isEnabled) + { + for (int index = 0; index < mControls.Length; index++) + { + mControls[index].Enabled = false; + } + } + #endregion + + #region SetOperatorRole 设置操作员权限 + /// + /// 设置操作员权限 + /// + private void SetOperatorRole() + { + for (int index = 0; index < mControls.Length; index++) + { + mControls[index].Enabled = AccessControl.AccessItems[index].Operator; + } + } + #endregion + + #region SetEngineerRole 设置工程师权限 + /// + /// 设置工程师权限 + /// + private void SetEngineerRole() + { + for (int index = 0; index < mControls.Length; index++) + { + mControls[index].Enabled = AccessControl.AccessItems[index].Engineer; + } + } + #endregion + + #region SetAdministratorRole 设置管理员权限 + /// + /// 设置管理员权限 + /// + private void SetAdministratorRole() + { + for (int index = 0; index < mControls.Length; index++) + { + mControls[index].Enabled = AccessControl.AccessItems[index].Administrator; + } + } + #endregion + + #region SetAdministratorRole 设置超级管理员权限 + /// + /// 设置超级管理员权限 + /// + private void SetSuperAdministratorRole() + { + for (int index = 0; index < mControls.Length; index++) + { + mControls[index].Enabled = AccessControl.AccessItems[index].SuperAdministrator; + } + } + #endregion + + #endregion + + + [System.Runtime.InteropServices.DllImport("user32.dll")] private static extern int SendMessage(IntPtr hWnd, int wMsg, bool wParam, int lParm); diff --git a/src/PBAnaly/PBAnaly.csproj b/src/PBAnaly/PBAnaly.csproj index 9d8283f..f63fc37 100644 --- a/src/PBAnaly/PBAnaly.csproj +++ b/src/PBAnaly/PBAnaly.csproj @@ -75,6 +75,7 @@ LogForm.cs + Form @@ -94,6 +95,12 @@ RegisterFrom.cs + + Form + + + RoleManageForm.cs + @@ -201,6 +208,9 @@ RegisterFrom.cs + + RoleManageForm.cs + UserManageForm.cs diff --git a/src/PBAnaly/Program.cs b/src/PBAnaly/Program.cs index e33b75d..9bb3ea1 100644 --- a/src/PBAnaly/Program.cs +++ b/src/PBAnaly/Program.cs @@ -73,6 +73,7 @@ namespace PBAnaly string dbPath = "UserManage.db"; string connectionString = $"Data Source={dbPath};Version=3;"; UserManage.ConnectDb(); + AccessControl.LoadConfig();//加载权限 var login = new LoginForm(); login.StartPosition = FormStartPosition.CenterScreen; diff --git a/src/PBAnaly/UI/SystemSettingForm.cs b/src/PBAnaly/UI/SystemSettingForm.cs index f191fe6..b0d1633 100644 --- a/src/PBAnaly/UI/SystemSettingForm.cs +++ b/src/PBAnaly/UI/SystemSettingForm.cs @@ -1,4 +1,5 @@ using PBAnaly.LoginCommon; +using Sunny.UI.Win32; using System; using System.Collections.Generic; using System.ComponentModel; @@ -20,7 +21,10 @@ namespace PBAnaly.UI pnlMainMenu.BringToFront(); - + // 设置窗体的启动位置为屏幕的中心 + this.StartPosition = FormStartPosition.CenterScreen; + this.Location = new System.Drawing.Point((Screen.PrimaryScreen.WorkingArea.Width - this.Width) / 2, + (Screen.PrimaryScreen.WorkingArea.Height - this.Height) / 2); } UserManageForm UserForm; @@ -118,6 +122,18 @@ namespace PBAnaly.UI tab_UserManage.Controls.Add(UserForm); UserForm.InitUser(); UserForm.Show(); + + if (UserManage.IsLogined) + { + if (UserManage.LogionUser.Role == UserRole.SuperAdministrator) + { + tab_UserManage.Parent = tabMain; + } + else + { + tab_UserManage.Parent = null; + } + } } } }