diff --git a/src/PBAnaly/LoginCommon/UserManage.cs b/src/PBAnaly/LoginCommon/UserManage.cs index eeb92bc..dc0f7d4 100644 --- a/src/PBAnaly/LoginCommon/UserManage.cs +++ b/src/PBAnaly/LoginCommon/UserManage.cs @@ -1,4 +1,5 @@ -using System; +using MiniExcelLibs; +using System; using System.Collections.Generic; using System.Data; using System.Data.SQLite; @@ -207,7 +208,7 @@ namespace PBAnaly.LoginCommon Password = reader["Password"].ToString(), CreatedBy = reader["CreatedBy"].ToString(), CreatedDate = Convert.ToDateTime(reader["CreatedDate"]), - Role = Enum.TryParse(reader["Role"].ToString(), out var role) ? role : UserRole.Operator, + Role = (UserRole)Enum.Parse(typeof(UserRole), reader["Role"].ToString()), PasswordQuestion = reader["PasswordQuestion"].ToString(), QuestionAnswer = reader["QuestionAnswer"].ToString() }; @@ -360,5 +361,126 @@ namespace PBAnaly.LoginCommon #endregion + #region FixUserRole 修改权限 + /// + /// 修改权限 + /// + /// + /// + /// + public static bool FixUserRole(string UserName,string Role) + { + try + { + string updateQuery = "UPDATE User SET Role = @Role WHERE UserName = @UserName"; + + using (SQLiteConnection conn = new SQLiteConnection(connectionString)) + { + conn.Open(); + + using (SQLiteCommand cmd = new SQLiteCommand(updateQuery, conn)) + { + // 参数化查询,防止SQL注入 + cmd.Parameters.AddWithValue("@UserName", UserName); + cmd.Parameters.AddWithValue("@Role", Role); + + // 执行更新命令 + int rowsAffected = cmd.ExecuteNonQuery(); + + Console.WriteLine($"更新成功,受影响的行数:{rowsAffected}"); + } + + conn.Close(); + + return true; + } + } + catch (Exception) + { + return false; + } + } + + #endregion + + #region DeleteUser 删除用户 + /// + /// 删除用户 + /// + /// + /// + public static bool DeleteUser(string UserName) + { + try + { + string sql = string.Format("delete from User where `UserName`='{0}'", UserName); + + using (SQLiteConnection conn = new SQLiteConnection(connectionString)) + { + conn.Open(); + + using (SQLiteCommand cmd = new SQLiteCommand(sql, conn)) + { + + var blnResult = (cmd.ExecuteNonQuery() > 0); + } + + conn.Close(); + UsersKeyValuePairs.Remove(UserName); + return true; + } + } + catch (Exception) + { + + return false; + } + } + + #endregion + + + #region FixUserPassword 修改密码 + /// + /// 修改密码 + /// + /// + /// + /// + public static bool FixUserPassword(string UserName , string Password) + { + try + { + string updateQuery = "UPDATE User SET Password = @Password WHERE UserName = @UserName"; + + using (SQLiteConnection conn = new SQLiteConnection(connectionString)) + { + conn.Open(); + + using (SQLiteCommand cmd = new SQLiteCommand(updateQuery, conn)) + { + // 参数化查询,防止SQL注入 + cmd.Parameters.AddWithValue("@UserName", UserName); + cmd.Parameters.AddWithValue("@Password", Password); + + // 执行更新命令 + int rowsAffected = cmd.ExecuteNonQuery(); + + Console.WriteLine($"更新成功,受影响的行数:{rowsAffected}"); + } + + conn.Close(); + + return true; + } + } + catch (Exception) + { + return false; + } + } + + #endregion + } } diff --git a/src/PBAnaly/LoginCommon/UserManageForm.Designer.cs b/src/PBAnaly/LoginCommon/UserManageForm.Designer.cs new file mode 100644 index 0000000..f6503fb --- /dev/null +++ b/src/PBAnaly/LoginCommon/UserManageForm.Designer.cs @@ -0,0 +1,491 @@ +namespace PBAnaly.LoginCommon +{ + partial class UserManageForm + { + /// + /// 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 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(); + this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.dataGridView1 = new System.Windows.Forms.DataGridView(); + this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Column4 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.tabControl1 = new System.Windows.Forms.TabControl(); + this.tab_fix = new System.Windows.Forms.TabPage(); + 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.tab_fix_password = new System.Windows.Forms.TabPage(); + 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(); + this.splitContainer1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); + this.tabControl1.SuspendLayout(); + this.tab_fix.SuspendLayout(); + this.tab_delete.SuspendLayout(); + this.tab_fix_password.SuspendLayout(); + this.panel1.SuspendLayout(); + this.SuspendLayout(); + // + // splitContainer1 + // + this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer1.Location = new System.Drawing.Point(0, 0); + this.splitContainer1.Name = "splitContainer1"; + // + // splitContainer1.Panel1 + // + this.splitContainer1.Panel1.Controls.Add(this.dataGridView1); + // + // splitContainer1.Panel2 + // + this.splitContainer1.Panel2.BackColor = System.Drawing.Color.White; + this.splitContainer1.Panel2.Controls.Add(this.tabControl1); + this.splitContainer1.Panel2.Controls.Add(this.panel1); + this.splitContainer1.Size = new System.Drawing.Size(863, 507); + this.splitContainer1.SplitterDistance = 427; + this.splitContainer1.TabIndex = 1; + // + // dataGridView1 + // + this.dataGridView1.AllowUserToAddRows = false; + this.dataGridView1.AllowUserToDeleteRows = false; + this.dataGridView1.AllowUserToResizeColumns = false; + 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; + this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.Column1, + this.Column2, + this.Column5, + this.Column3, + this.Column4}); + this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill; + this.dataGridView1.Location = new System.Drawing.Point(0, 0); + this.dataGridView1.MultiSelect = false; + this.dataGridView1.Name = "dataGridView1"; + this.dataGridView1.ReadOnly = true; + this.dataGridView1.RowHeadersVisible = false; + this.dataGridView1.RowTemplate.Height = 23; + this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dataGridView1.Size = new System.Drawing.Size(427, 507); + this.dataGridView1.TabIndex = 496; + this.dataGridView1.SelectionChanged += new System.EventHandler(this.dataGridView1_SelectionChanged); + // + // Column1 + // + dataGridViewCellStyle27.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + this.Column1.DefaultCellStyle = dataGridViewCellStyle27; + this.Column1.HeaderText = "序号"; + this.Column1.Name = "Column1"; + this.Column1.ReadOnly = true; + this.Column1.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + // + // Column2 + // + dataGridViewCellStyle28.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + this.Column2.DefaultCellStyle = dataGridViewCellStyle28; + this.Column2.HeaderText = "用户名"; + this.Column2.Name = "Column2"; + this.Column2.ReadOnly = true; + this.Column2.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + // + // Column5 + // + this.Column5.HeaderText = "创建人"; + this.Column5.Name = "Column5"; + this.Column5.ReadOnly = true; + // + // Column3 + // + dataGridViewCellStyle29.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + this.Column3.DefaultCellStyle = dataGridViewCellStyle29; + this.Column3.HeaderText = "创建时间"; + this.Column3.Name = "Column3"; + this.Column3.ReadOnly = true; + this.Column3.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + // + // Column4 + // + dataGridViewCellStyle30.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + this.Column4.DefaultCellStyle = dataGridViewCellStyle30; + this.Column4.HeaderText = "权限"; + this.Column4.Name = "Column4"; + this.Column4.ReadOnly = true; + this.Column4.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + // + // tabControl1 + // + this.tabControl1.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.tabControl1.Controls.Add(this.tab_fix); + this.tabControl1.Controls.Add(this.tab_delete); + this.tabControl1.Controls.Add(this.tab_fix_password); + this.tabControl1.Location = new System.Drawing.Point(3, 22); + this.tabControl1.Name = "tabControl1"; + this.tabControl1.SelectedIndex = 0; + this.tabControl1.Size = new System.Drawing.Size(429, 485); + this.tabControl1.TabIndex = 0; + // + // tab_fix + // + this.tab_fix.Controls.Add(this.btn_fix_role); + this.tab_fix.Controls.Add(this.txt_UserName); + this.tab_fix.Controls.Add(this.label11); + this.tab_fix.Controls.Add(this.cbx_role_role); + this.tab_fix.Controls.Add(this.label12); + this.tab_fix.Location = new System.Drawing.Point(4, 22); + this.tab_fix.Name = "tab_fix"; + this.tab_fix.Padding = new System.Windows.Forms.Padding(3); + this.tab_fix.Size = new System.Drawing.Size(421, 459); + this.tab_fix.TabIndex = 0; + this.tab_fix.Text = "修改权限"; + this.tab_fix.UseVisualStyleBackColor = true; + // + // btn_fix_role + // + this.btn_fix_role.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(32)))), ((int)(((byte)(96))))); + this.btn_fix_role.FlatAppearance.BorderSize = 0; + this.btn_fix_role.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_fix_role.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Bold); + this.btn_fix_role.ForeColor = System.Drawing.Color.White; + this.btn_fix_role.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.btn_fix_role.Location = new System.Drawing.Point(284, 215); + this.btn_fix_role.Name = "btn_fix_role"; + this.btn_fix_role.Size = new System.Drawing.Size(101, 38); + this.btn_fix_role.TabIndex = 505; + this.btn_fix_role.Text = "修改权限"; + this.btn_fix_role.UseVisualStyleBackColor = false; + this.btn_fix_role.Click += new System.EventHandler(this.btn_fix_role_Click); + // + // txt_UserName + // + this.txt_UserName.Font = new System.Drawing.Font("宋体", 13F); + this.txt_UserName.Location = new System.Drawing.Point(93, 43); + this.txt_UserName.Multiline = true; + this.txt_UserName.Name = "txt_UserName"; + this.txt_UserName.ReadOnly = true; + this.txt_UserName.Size = new System.Drawing.Size(292, 28); + this.txt_UserName.TabIndex = 504; + // + // label11 + // + this.label11.AutoSize = true; + this.label11.Font = new System.Drawing.Font("宋体", 15F); + this.label11.Location = new System.Drawing.Point(18, 51); + this.label11.Name = "label11"; + this.label11.Size = new System.Drawing.Size(69, 20); + this.label11.TabIndex = 503; + this.label11.Text = "用户名"; + // + // cbx_role_role + // + this.cbx_role_role.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cbx_role_role.Font = new System.Drawing.Font("宋体", 15F); + this.cbx_role_role.FormattingEnabled = true; + this.cbx_role_role.Items.AddRange(new object[] { + "Operator", + "Engineer", + "Administrator", + "SuperAdministrator"}); + this.cbx_role_role.Location = new System.Drawing.Point(93, 145); + this.cbx_role_role.Name = "cbx_role_role"; + this.cbx_role_role.Size = new System.Drawing.Size(292, 28); + this.cbx_role_role.TabIndex = 502; + // + // label12 + // + this.label12.AutoSize = true; + this.label12.Font = new System.Drawing.Font("宋体", 15F); + this.label12.Location = new System.Drawing.Point(38, 148); + this.label12.Name = "label12"; + this.label12.Size = new System.Drawing.Size(49, 20); + this.label12.TabIndex = 501; + this.label12.Text = "权限"; + // + // tab_delete + // + this.tab_delete.Controls.Add(this.btn_delete_user); + this.tab_delete.Controls.Add(this.label1); + this.tab_delete.Location = new System.Drawing.Point(4, 22); + this.tab_delete.Name = "tab_delete"; + this.tab_delete.Padding = new System.Windows.Forms.Padding(3); + this.tab_delete.Size = new System.Drawing.Size(421, 459); + this.tab_delete.TabIndex = 1; + this.tab_delete.Text = "删除"; + this.tab_delete.UseVisualStyleBackColor = true; + // + // tab_fix_password + // + this.tab_fix_password.Controls.Add(this.btn_FixPassword); + this.tab_fix_password.Controls.Add(this.txt_password); + this.tab_fix_password.Controls.Add(this.label3); + this.tab_fix_password.Controls.Add(this.txt_fix_p_UserName); + this.tab_fix_password.Controls.Add(this.label2); + this.tab_fix_password.Location = new System.Drawing.Point(4, 22); + this.tab_fix_password.Name = "tab_fix_password"; + this.tab_fix_password.Padding = new System.Windows.Forms.Padding(3); + this.tab_fix_password.Size = new System.Drawing.Size(421, 459); + this.tab_fix_password.TabIndex = 2; + this.tab_fix_password.Text = "修改密码"; + this.tab_fix_password.UseVisualStyleBackColor = true; + // + // panel1 + // + this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.panel1.Controls.Add(this.btn_delete); + this.panel1.Controls.Add(this.btn_edit_password); + this.panel1.Controls.Add(this.btn_editRole); + this.panel1.Location = new System.Drawing.Point(3, 3); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(429, 43); + this.panel1.TabIndex = 453; + // + // btn_delete + // + this.btn_delete.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.btn_delete.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(32)))), ((int)(((byte)(96))))); + this.btn_delete.FlatAppearance.BorderSize = 0; + this.btn_delete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_delete.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Bold); + this.btn_delete.ForeColor = System.Drawing.Color.White; + this.btn_delete.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.btn_delete.Location = new System.Drawing.Point(181, 2); + this.btn_delete.Name = "btn_delete"; + this.btn_delete.Size = new System.Drawing.Size(78, 38); + this.btn_delete.TabIndex = 498; + this.btn_delete.Text = "删除"; + this.btn_delete.UseVisualStyleBackColor = false; + this.btn_delete.Click += new System.EventHandler(this.btn_delete_Click); + // + // btn_edit_password + // + this.btn_edit_password.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); + this.btn_edit_password.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(32)))), ((int)(((byte)(96))))); + this.btn_edit_password.FlatAppearance.BorderSize = 0; + this.btn_edit_password.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_edit_password.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Bold); + this.btn_edit_password.ForeColor = System.Drawing.Color.White; + this.btn_edit_password.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.btn_edit_password.Location = new System.Drawing.Point(321, 2); + this.btn_edit_password.Name = "btn_edit_password"; + this.btn_edit_password.Size = new System.Drawing.Size(101, 38); + this.btn_edit_password.TabIndex = 499; + this.btn_edit_password.Text = "修改密码"; + this.btn_edit_password.UseVisualStyleBackColor = false; + this.btn_edit_password.Click += new System.EventHandler(this.btn_edit_password_Click); + // + // btn_editRole + // + this.btn_editRole.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.btn_editRole.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(32)))), ((int)(((byte)(96))))); + this.btn_editRole.FlatAppearance.BorderSize = 0; + this.btn_editRole.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_editRole.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Bold); + this.btn_editRole.ForeColor = System.Drawing.Color.White; + this.btn_editRole.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.btn_editRole.Location = new System.Drawing.Point(7, 3); + this.btn_editRole.Name = "btn_editRole"; + this.btn_editRole.Size = new System.Drawing.Size(101, 38); + this.btn_editRole.TabIndex = 497; + this.btn_editRole.Text = "修改权限"; + 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); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(863, 507); + this.Controls.Add(this.splitContainer1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; + this.Name = "UserManageForm"; + this.Text = "UserManageForm"; + this.splitContainer1.Panel1.ResumeLayout(false); + this.splitContainer1.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); + this.splitContainer1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); + this.tabControl1.ResumeLayout(false); + this.tab_fix.ResumeLayout(false); + this.tab_fix.PerformLayout(); + this.tab_delete.ResumeLayout(false); + this.tab_delete.PerformLayout(); + this.tab_fix_password.ResumeLayout(false); + this.tab_fix_password.PerformLayout(); + this.panel1.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.SplitContainer splitContainer1; + private System.Windows.Forms.DataGridView dataGridView1; + private System.Windows.Forms.DataGridViewTextBoxColumn Column1; + private System.Windows.Forms.DataGridViewTextBoxColumn Column2; + private System.Windows.Forms.DataGridViewTextBoxColumn Column5; + private System.Windows.Forms.DataGridViewTextBoxColumn Column3; + private System.Windows.Forms.DataGridViewTextBoxColumn Column4; + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.Button btn_delete; + private System.Windows.Forms.Button btn_edit_password; + private System.Windows.Forms.Button btn_editRole; + private System.Windows.Forms.TabControl tabControl1; + private System.Windows.Forms.TabPage tab_fix; + private System.Windows.Forms.TabPage tab_delete; + private System.Windows.Forms.TabPage tab_fix_password; + private System.Windows.Forms.Button btn_fix_role; + private System.Windows.Forms.TextBox txt_UserName; + private System.Windows.Forms.Label label11; + private System.Windows.Forms.ComboBox cbx_role_role; + private System.Windows.Forms.Label label12; + private System.Windows.Forms.Button btn_delete_user; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Button btn_FixPassword; + private System.Windows.Forms.TextBox txt_password; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.TextBox txt_fix_p_UserName; + private System.Windows.Forms.Label label2; + } +} \ No newline at end of file diff --git a/src/PBAnaly/LoginCommon/UserManageForm.cs b/src/PBAnaly/LoginCommon/UserManageForm.cs new file mode 100644 index 0000000..a1cb08b --- /dev/null +++ b/src/PBAnaly/LoginCommon/UserManageForm.cs @@ -0,0 +1,224 @@ +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 UserManageForm : Form + { + public UserManageForm() + { + InitializeComponent(); + + panel1.BringToFront(); + + SetMainMenuButtonCilkeColor("btn_editRole"); + } + + #region InitUser 加载全部的用户 root除外 + /// + /// 加载全部的用户 root除外 + /// + public void InitUser() + { + try + { + int index = 1; + dataGridView1.Rows.Clear(); + + foreach (User user in UserManage.UsersKeyValuePairs.Values) + { + if (user.Name != "root") + { + DataGridViewRow dr = new DataGridViewRow(); + dr.CreateCells(dataGridView1); + dr.Cells[0].Value = index.ToString(); + dr.Cells[1].Value = user.Name; + dr.Cells[2].Value = user.CreatedBy; + dr.Cells[3].Value = user.CreatedDate; + dr.Cells[4].Value = user.Role.ToString(); + dataGridView1.Rows.Add(dr); + + index++; + } + } + } + catch (Exception) + { + + } + } + #endregion + + #region btn_fix_role_Click 修改权限按钮 + private void btn_fix_role_Click(object sender, EventArgs e) + { + DialogResult result = MessageBox.Show($"确定要用户:{txt_UserName.Text}的权限吗?", "提示", MessageBoxButtons.YesNo); + if (result == DialogResult.Yes) + { + try + { + if (!string.IsNullOrEmpty(txt_UserName.Text)) + { + User user = new User(); + user.Name = txt_UserName.Text; + user.Role = (UserRole)Enum.Parse(typeof(UserRole), cbx_role_role.Text); + user.CreatedDate = UserManage.UsersKeyValuePairs[txt_UserName.Text].CreatedDate; + user.CreatedBy = UserManage.UsersKeyValuePairs[txt_UserName.Text].CreatedBy; + user.PasswordQuestion = UserManage.UsersKeyValuePairs[txt_UserName.Text].PasswordQuestion; + user.QuestionAnswer = UserManage.UsersKeyValuePairs[txt_UserName.Text].QuestionAnswer; + user.Password = UserManage.UsersKeyValuePairs[txt_UserName.Text].Password; + + UserManage.UsersKeyValuePairs[user.Name] = user; + + if(UserManage.FixUserRole(txt_UserName.Text, cbx_role_role.Text)) + { + InitUser(); + MessageBox.Show("修改成功"); + } + else + { + MessageBox.Show("修改失败"); + } + } + + + } + catch (Exception ex) + { + MessageBox.Show($"权限修改失败,原因:{ex.Message.ToString()}"); + } + } + } + #endregion + + private void dataGridView1_SelectionChanged(object sender, EventArgs e) + { + if (dataGridView1.SelectedRows.Count > 0) + { + DataGridViewRow row = dataGridView1.SelectedRows[0]; + txt_UserName.Text = row.Cells[1].Value.ToString(); + cbx_role_role.Text = row.Cells[4].Value.ToString(); + + txt_fix_p_UserName.Text=row.Cells[1].Value.ToString(); + txt_password.Text = UserManage.UsersKeyValuePairs[txt_fix_p_UserName.Text].Password; + } + } + + + private void btn_delete_user_Click(object sender, EventArgs e) + { + try + { + if (dataGridView1.SelectedRows.Count > 0 ) + { + if(dataGridView1.SelectedRows.Count >= 2) { MessageBox.Show("一次只能删除一个用户");return; } + + DataGridViewRow row = dataGridView1.SelectedRows[0]; + string UserName = row.Cells[1].Value.ToString(); + + if (UserManage.DeleteUser(UserName)) + { + InitUser(); + } + + } + else + { + MessageBox.Show("请在表格内选择一行要删除的登记信息,且一次只能删除一行"); + } + + } + catch (Exception ex) + { + MessageBox.Show("删除失败,原因:" + ex.Message); + } + } + + private void btn_FixPassword_Click(object sender, EventArgs e) + { + try + { + if (!string.IsNullOrEmpty(txt_UserName.Text)) + { + User user = new User(); + user.Name = txt_UserName.Text; + user.Role = (UserRole)Enum.Parse(typeof(UserRole), cbx_role_role.Text); + user.CreatedDate = UserManage.UsersKeyValuePairs[txt_UserName.Text].CreatedDate; + user.CreatedBy = UserManage.UsersKeyValuePairs[txt_UserName.Text].CreatedBy; + user.PasswordQuestion = UserManage.UsersKeyValuePairs[txt_UserName.Text].PasswordQuestion; + user.QuestionAnswer = UserManage.UsersKeyValuePairs[txt_UserName.Text].QuestionAnswer; + user.Password = txt_password.Text; + + UserManage.UsersKeyValuePairs[user.Name] = user; + + if (UserManage.FixUserPassword(txt_UserName.Text, txt_password.Text)) + { + MessageBox.Show("密码修改成功"); + } + else + { + MessageBox.Show("密码修改失败"); + } + } + + + } + catch (Exception ex) + { + MessageBox.Show($"密码修改失败,原因:{ex.Message.ToString()}"); + } + } + + private void btn_editRole_Click(object sender, EventArgs e) + { + this.tabControl1.SelectedIndex = 0; + SetMainMenuButtonCilkeColor(((Button)sender).Name); + } + + private void btn_delete_Click(object sender, EventArgs e) + { + this.tabControl1.SelectedIndex = 1; + SetMainMenuButtonCilkeColor(((Button)sender).Name); + } + + private void btn_edit_password_Click(object sender, EventArgs e) + { + this.tabControl1.SelectedIndex = 2; + SetMainMenuButtonCilkeColor(((Button)sender).Name); + } + + #region SetMainMenuButtonCilkeColor 主菜单中按钮点击之后,设置按钮的前景色和背景色 + /// + /// 主菜单中按钮点击之后,设置按钮的前景色和背景色 + /// + /// 点击的按钮的名称 + private void SetMainMenuButtonCilkeColor(string strBtnName) + { + foreach (Control control in panel1.Controls) + { + if (control.Name == panel1.Name) + { + continue; + } + else if (control.Name == strBtnName) + { + control.BackColor = Color.Aqua; + control.ForeColor = Color.Black; + } + else + { + control.BackColor = Color.FromArgb(0, 32, 96); + control.ForeColor = Color.White; + } + } + } + #endregion + } +} diff --git a/src/PBAnaly/LoginCommon/UserManageForm.resx b/src/PBAnaly/LoginCommon/UserManageForm.resx new file mode 100644 index 0000000..0a44728 --- /dev/null +++ b/src/PBAnaly/LoginCommon/UserManageForm.resx @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + \ No newline at end of file diff --git a/src/PBAnaly/MainForm.cs b/src/PBAnaly/MainForm.cs index 0035da5..807105b 100644 --- a/src/PBAnaly/MainForm.cs +++ b/src/PBAnaly/MainForm.cs @@ -247,6 +247,8 @@ namespace PBAnaly private void materialButton_setting_Click(object sender, EventArgs e) { + SystemSettingForm system = new SystemSettingForm(); + system.ShowDialog(); //if (settingForm != null) // return; diff --git a/src/PBAnaly/PBAnaly.csproj b/src/PBAnaly/PBAnaly.csproj index 142bfe7..9d8283f 100644 --- a/src/PBAnaly/PBAnaly.csproj +++ b/src/PBAnaly/PBAnaly.csproj @@ -96,6 +96,12 @@ + + Form + + + UserManageForm.cs + Form @@ -195,6 +201,9 @@ RegisterFrom.cs + + UserManageForm.cs + LoginForm.cs @@ -430,6 +439,7 @@ + diff --git a/src/PBAnaly/Properties/Resources.Designer.cs b/src/PBAnaly/Properties/Resources.Designer.cs index b8e58a6..b5f5ee2 100644 --- a/src/PBAnaly/Properties/Resources.Designer.cs +++ b/src/PBAnaly/Properties/Resources.Designer.cs @@ -540,6 +540,16 @@ namespace PBAnaly.Properties { } } + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 添加用户 { + get { + object obj = ResourceManager.GetObject("添加用户", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// 查找 System.Drawing.Bitmap 类型的本地化资源。 /// diff --git a/src/PBAnaly/Properties/Resources.resx b/src/PBAnaly/Properties/Resources.resx index 019f31c..ff9aff5 100644 --- a/src/PBAnaly/Properties/Resources.resx +++ b/src/PBAnaly/Properties/Resources.resx @@ -136,17 +136,17 @@ ..\Resources\EtBr_1.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\壁纸.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\Gray.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\Resources\保存图片.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\蛋白质-01.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\线段.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\YellowHot_1.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\饼干.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\Black_Green_1.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -172,23 +172,26 @@ ..\Resources\波形设置-未选中.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\主页面-图像编辑-正反片.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\Resources\Black_Blue_1.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\zoom-in.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\数据报告 (1).png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\线段 (1).png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\保存.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\圖片_20240731174523.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\图片管理.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\重置.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\Black_Red_0.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -196,6 +199,9 @@ ..\Resources\京仪科技定稿_画板 1 副本2.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\数据报告.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\zoom-out.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -205,9 +211,6 @@ ..\Resources\风控.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\Black_SDS_1.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\Resources\分析.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -238,20 +241,17 @@ ..\Resources\C.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\前台.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\图片管理.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\圆形.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\執行日誌紀錄.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\最大化white.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\圆形.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\Black_Green_0.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\主页面-图像编辑-正反片.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\缩小.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -265,43 +265,46 @@ ..\Resources\Pseudo_1.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\线段.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\Gray.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\10矩形.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\线段 (1).png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\放大.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\YellowHot_1.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\Black_Green_0.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\饼干.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\執行日誌紀錄.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\数据报告.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\蛋白质-01.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\zoom-in.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\壁纸.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\圆形.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\黑白平衡.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\重置.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\最小化white.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\放大.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\Black_SDS_1.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\前台.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\波形图.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\最大化white.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\最小化white.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\添加用户.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a \ No newline at end of file diff --git a/src/PBAnaly/Resources/添加用户.png b/src/PBAnaly/Resources/添加用户.png new file mode 100644 index 0000000..b7aac25 Binary files /dev/null and b/src/PBAnaly/Resources/添加用户.png differ diff --git a/src/PBAnaly/UI/SystemSettingForm.Designer.cs b/src/PBAnaly/UI/SystemSettingForm.Designer.cs index e38385d..297c427 100644 --- a/src/PBAnaly/UI/SystemSettingForm.Designer.cs +++ b/src/PBAnaly/UI/SystemSettingForm.Designer.cs @@ -28,40 +28,20 @@ /// 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(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.panel_mode = new System.Windows.Forms.Panel(); this.tabMain = new System.Windows.Forms.TabControl(); this.tab_UserManage = new System.Windows.Forms.TabPage(); this.pnlMainMenu = new System.Windows.Forms.Panel(); - this.btn_ConfigManage = new System.Windows.Forms.Button(); - this.btn_ComManage = new System.Windows.Forms.Button(); - this.btn_FormatManage = new System.Windows.Forms.Button(); this.btn_ReadManage = new System.Windows.Forms.Button(); this.label4 = new System.Windows.Forms.Label(); this.btn_Min = new System.Windows.Forms.Button(); this.btn_Max = new System.Windows.Forms.Button(); this.btn_Close = new System.Windows.Forms.Button(); - this.splitContainer1 = new System.Windows.Forms.SplitContainer(); - this.dataGridView1 = new System.Windows.Forms.DataGridView(); - this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.Column4 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.panel1.SuspendLayout(); this.panel_mode.SuspendLayout(); this.tabMain.SuspendLayout(); - this.tab_UserManage.SuspendLayout(); this.pnlMainMenu.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); - this.splitContainer1.Panel1.SuspendLayout(); - this.splitContainer1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); this.SuspendLayout(); // // panel1 @@ -84,34 +64,31 @@ | System.Windows.Forms.AnchorStyles.Right))); this.panel_mode.BackColor = System.Drawing.SystemColors.Control; this.panel_mode.Controls.Add(this.tabMain); - this.panel_mode.Location = new System.Drawing.Point(50, 0); + this.panel_mode.Location = new System.Drawing.Point(58, 0); this.panel_mode.Name = "panel_mode"; - this.panel_mode.Size = new System.Drawing.Size(1106, 639); + this.panel_mode.Size = new System.Drawing.Size(1098, 639); this.panel_mode.TabIndex = 444; // // tabMain // this.tabMain.Alignment = System.Windows.Forms.TabAlignment.Left; - this.tabMain.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.tabMain.Controls.Add(this.tab_UserManage); - this.tabMain.Location = new System.Drawing.Point(0, -3); + this.tabMain.Dock = System.Windows.Forms.DockStyle.Fill; + this.tabMain.Location = new System.Drawing.Point(0, 0); this.tabMain.Multiline = true; this.tabMain.Name = "tabMain"; this.tabMain.SelectedIndex = 0; - this.tabMain.Size = new System.Drawing.Size(1114, 651); + this.tabMain.Size = new System.Drawing.Size(1098, 639); this.tabMain.TabIndex = 0; // // tab_UserManage // this.tab_UserManage.BackColor = System.Drawing.Color.White; this.tab_UserManage.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.tab_UserManage.Controls.Add(this.splitContainer1); this.tab_UserManage.Location = new System.Drawing.Point(22, 4); this.tab_UserManage.Name = "tab_UserManage"; this.tab_UserManage.Padding = new System.Windows.Forms.Padding(3); - this.tab_UserManage.Size = new System.Drawing.Size(1088, 643); + this.tab_UserManage.Size = new System.Drawing.Size(1072, 631); this.tab_UserManage.TabIndex = 0; this.tab_UserManage.Text = "用户管理"; // @@ -120,56 +97,18 @@ this.pnlMainMenu.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left))); this.pnlMainMenu.BackColor = System.Drawing.Color.White; - this.pnlMainMenu.Controls.Add(this.btn_ConfigManage); - this.pnlMainMenu.Controls.Add(this.btn_ComManage); - this.pnlMainMenu.Controls.Add(this.btn_FormatManage); this.pnlMainMenu.Controls.Add(this.btn_ReadManage); - this.pnlMainMenu.Location = new System.Drawing.Point(3, 3); + this.pnlMainMenu.Location = new System.Drawing.Point(3, -3); this.pnlMainMenu.Name = "pnlMainMenu"; - this.pnlMainMenu.Size = new System.Drawing.Size(77, 636); + this.pnlMainMenu.Size = new System.Drawing.Size(77, 642); this.pnlMainMenu.TabIndex = 443; // - // btn_ConfigManage - // - this.btn_ConfigManage.BackColor = System.Drawing.Color.White; - this.btn_ConfigManage.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btn_ConfigManage.Font = new System.Drawing.Font("宋体", 9F); - this.btn_ConfigManage.Location = new System.Drawing.Point(3, 279); - this.btn_ConfigManage.Name = "btn_ConfigManage"; - this.btn_ConfigManage.Size = new System.Drawing.Size(76, 86); - this.btn_ConfigManage.TabIndex = 6; - this.btn_ConfigManage.TextAlign = System.Drawing.ContentAlignment.BottomCenter; - this.btn_ConfigManage.UseVisualStyleBackColor = false; - // - // btn_ComManage - // - this.btn_ComManage.BackColor = System.Drawing.Color.White; - this.btn_ComManage.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btn_ComManage.Font = new System.Drawing.Font("宋体", 9F); - this.btn_ComManage.Location = new System.Drawing.Point(3, 187); - this.btn_ComManage.Name = "btn_ComManage"; - this.btn_ComManage.Size = new System.Drawing.Size(76, 86); - this.btn_ComManage.TabIndex = 5; - this.btn_ComManage.TextAlign = System.Drawing.ContentAlignment.BottomCenter; - this.btn_ComManage.UseVisualStyleBackColor = false; - // - // btn_FormatManage - // - this.btn_FormatManage.BackColor = System.Drawing.Color.White; - this.btn_FormatManage.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btn_FormatManage.Font = new System.Drawing.Font("宋体", 9F); - this.btn_FormatManage.Location = new System.Drawing.Point(3, 95); - this.btn_FormatManage.Name = "btn_FormatManage"; - this.btn_FormatManage.Size = new System.Drawing.Size(76, 86); - this.btn_FormatManage.TabIndex = 4; - this.btn_FormatManage.TextAlign = System.Drawing.ContentAlignment.BottomCenter; - this.btn_FormatManage.UseVisualStyleBackColor = false; - // // btn_ReadManage // this.btn_ReadManage.BackColor = System.Drawing.Color.White; this.btn_ReadManage.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btn_ReadManage.Font = new System.Drawing.Font("宋体", 9F); + this.btn_ReadManage.Image = global::PBAnaly.Properties.Resources.添加用户; this.btn_ReadManage.Location = new System.Drawing.Point(3, 3); this.btn_ReadManage.Name = "btn_ReadManage"; this.btn_ReadManage.Size = new System.Drawing.Size(76, 86); @@ -196,11 +135,12 @@ this.btn_Min.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btn_Min.ForeColor = System.Drawing.Color.Transparent; this.btn_Min.Image = global::PBAnaly.Properties.Resources.最小化white; - this.btn_Min.Location = new System.Drawing.Point(1014, 0); + this.btn_Min.Location = new System.Drawing.Point(1014, -1); this.btn_Min.Name = "btn_Min"; this.btn_Min.Size = new System.Drawing.Size(44, 32); this.btn_Min.TabIndex = 459; this.btn_Min.UseVisualStyleBackColor = false; + this.btn_Min.Visible = false; // // btn_Max // @@ -210,11 +150,12 @@ this.btn_Max.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btn_Max.ForeColor = System.Drawing.Color.Transparent; this.btn_Max.Image = global::PBAnaly.Properties.Resources.最大化white; - this.btn_Max.Location = new System.Drawing.Point(1064, 0); + this.btn_Max.Location = new System.Drawing.Point(1064, -1); this.btn_Max.Name = "btn_Max"; this.btn_Max.Size = new System.Drawing.Size(44, 32); this.btn_Max.TabIndex = 458; this.btn_Max.UseVisualStyleBackColor = false; + this.btn_Max.Visible = false; // // btn_Close // @@ -224,100 +165,12 @@ 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(1114, 0); + this.btn_Close.Location = new System.Drawing.Point(1114, -1); this.btn_Close.Name = "btn_Close"; this.btn_Close.Size = new System.Drawing.Size(44, 32); this.btn_Close.TabIndex = 457; this.btn_Close.UseVisualStyleBackColor = false; - // - // splitContainer1 - // - this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; - this.splitContainer1.Location = new System.Drawing.Point(3, 3); - this.splitContainer1.Name = "splitContainer1"; - // - // splitContainer1.Panel1 - // - this.splitContainer1.Panel1.Controls.Add(this.dataGridView1); - this.splitContainer1.Size = new System.Drawing.Size(1082, 637); - this.splitContainer1.SplitterDistance = 562; - this.splitContainer1.TabIndex = 0; - // - // dataGridView1 - // - this.dataGridView1.AllowUserToAddRows = false; - this.dataGridView1.AllowUserToDeleteRows = false; - this.dataGridView1.AllowUserToResizeColumns = false; - this.dataGridView1.AllowUserToResizeRows = false; - this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; - this.dataGridView1.BackgroundColor = System.Drawing.Color.White; - 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, - this.Column2, - this.Column5, - this.Column3, - this.Column4}); - this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill; - this.dataGridView1.Location = new System.Drawing.Point(0, 0); - this.dataGridView1.MultiSelect = false; - this.dataGridView1.Name = "dataGridView1"; - this.dataGridView1.ReadOnly = true; - this.dataGridView1.RowHeadersVisible = false; - this.dataGridView1.RowTemplate.Height = 23; - this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.dataGridView1.Size = new System.Drawing.Size(562, 637); - this.dataGridView1.TabIndex = 496; - // - // Column1 - // - dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - this.Column1.DefaultCellStyle = dataGridViewCellStyle2; - this.Column1.HeaderText = "序号"; - this.Column1.Name = "Column1"; - this.Column1.ReadOnly = true; - this.Column1.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; - // - // Column2 - // - dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - this.Column2.DefaultCellStyle = dataGridViewCellStyle3; - this.Column2.HeaderText = "用户名"; - this.Column2.Name = "Column2"; - this.Column2.ReadOnly = true; - this.Column2.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; - // - // Column5 - // - this.Column5.HeaderText = "创建人"; - this.Column5.Name = "Column5"; - this.Column5.ReadOnly = true; - // - // Column3 - // - dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - this.Column3.DefaultCellStyle = dataGridViewCellStyle4; - this.Column3.HeaderText = "创建时间"; - this.Column3.Name = "Column3"; - this.Column3.ReadOnly = true; - this.Column3.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; - // - // Column4 - // - dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - this.Column4.DefaultCellStyle = dataGridViewCellStyle5; - this.Column4.HeaderText = "权限"; - this.Column4.Name = "Column4"; - this.Column4.ReadOnly = true; - this.Column4.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + this.btn_Close.Click += new System.EventHandler(this.btn_Close_Click); // // SystemSettingForm // @@ -333,15 +186,11 @@ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.Name = "SystemSettingForm"; this.Text = "SystemSettingForm"; + this.Load += new System.EventHandler(this.SystemSettingForm_Load); this.panel1.ResumeLayout(false); this.panel_mode.ResumeLayout(false); this.tabMain.ResumeLayout(false); - this.tab_UserManage.ResumeLayout(false); this.pnlMainMenu.ResumeLayout(false); - this.splitContainer1.Panel1.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); - this.splitContainer1.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -355,19 +204,9 @@ private System.Windows.Forms.Button btn_Max; private System.Windows.Forms.Button btn_Min; private System.Windows.Forms.Panel pnlMainMenu; - private System.Windows.Forms.Button btn_ConfigManage; - private System.Windows.Forms.Button btn_ComManage; - private System.Windows.Forms.Button btn_FormatManage; private System.Windows.Forms.Button btn_ReadManage; private System.Windows.Forms.Panel panel_mode; private System.Windows.Forms.TabControl tabMain; private System.Windows.Forms.TabPage tab_UserManage; - private System.Windows.Forms.SplitContainer splitContainer1; - private System.Windows.Forms.DataGridView dataGridView1; - private System.Windows.Forms.DataGridViewTextBoxColumn Column1; - private System.Windows.Forms.DataGridViewTextBoxColumn Column2; - private System.Windows.Forms.DataGridViewTextBoxColumn Column5; - private System.Windows.Forms.DataGridViewTextBoxColumn Column3; - private System.Windows.Forms.DataGridViewTextBoxColumn Column4; } } \ No newline at end of file diff --git a/src/PBAnaly/UI/SystemSettingForm.cs b/src/PBAnaly/UI/SystemSettingForm.cs index 62b43d5..f191fe6 100644 --- a/src/PBAnaly/UI/SystemSettingForm.cs +++ b/src/PBAnaly/UI/SystemSettingForm.cs @@ -1,9 +1,11 @@ -using System; +using PBAnaly.LoginCommon; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; +using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; @@ -15,6 +17,107 @@ namespace PBAnaly.UI public SystemSettingForm() { InitializeComponent(); + + pnlMainMenu.BringToFront(); + + + } + + UserManageForm UserForm; + + #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_Close_Click(object sender, EventArgs e) + { + this.Close(); + } + + private void SystemSettingForm_Load(object sender, EventArgs e) + { + UserForm = new UserManageForm(); + UserForm.Dock = DockStyle.Fill; + UserForm.Location = new Point(0, 0); + UserForm.TopLevel = false; + tab_UserManage.Controls.Add(UserForm); + UserForm.InitUser(); + UserForm.Show(); } } } diff --git a/src/PBAnaly/UI/SystemSettingForm.resx b/src/PBAnaly/UI/SystemSettingForm.resx index 0a44728..1af7de1 100644 --- a/src/PBAnaly/UI/SystemSettingForm.resx +++ b/src/PBAnaly/UI/SystemSettingForm.resx @@ -117,19 +117,4 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - True - - - True - - - True - - - True - - - True - \ No newline at end of file