diff --git a/src/PBAnaly/LoginCommon/BackPassWordForm.Designer.cs b/src/PBAnaly/LoginCommon/BackPassWordForm.Designer.cs new file mode 100644 index 0000000..559ba79 --- /dev/null +++ b/src/PBAnaly/LoginCommon/BackPassWordForm.Designer.cs @@ -0,0 +1,237 @@ +namespace PBAnaly.LoginCommon +{ + partial class BackPassWordForm + { + /// + /// 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() + { + this.btn_back = new MaterialSkin.Controls.MaterialButton(); + this.btn_Frin_Password = new MaterialSkin.Controls.MaterialButton(); + this.txt_UserName = new System.Windows.Forms.TextBox(); + this.txt_Password = new System.Windows.Forms.TextBox(); + this.txt_broblem = new System.Windows.Forms.TextBox(); + this.txt_answer = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); + this.label6 = new System.Windows.Forms.Label(); + this.panel1 = new System.Windows.Forms.Panel(); + this.label4 = new System.Windows.Forms.Label(); + this.panel1.SuspendLayout(); + this.SuspendLayout(); + // + // btn_back + // + this.btn_back.AutoSize = false; + this.btn_back.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.btn_back.Density = MaterialSkin.Controls.MaterialButton.MaterialButtonDensity.Default; + this.btn_back.Depth = 0; + this.btn_back.HighEmphasis = true; + this.btn_back.Icon = null; + this.btn_back.Location = new System.Drawing.Point(14, 9); + this.btn_back.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); + this.btn_back.MouseState = MaterialSkin.MouseState.HOVER; + this.btn_back.Name = "btn_back"; + this.btn_back.NoAccentTextColor = System.Drawing.Color.Empty; + this.btn_back.Size = new System.Drawing.Size(62, 30); + this.btn_back.TabIndex = 14; + this.btn_back.Text = "back"; + this.btn_back.Type = MaterialSkin.Controls.MaterialButton.MaterialButtonType.Contained; + this.btn_back.UseAccentColor = false; + this.btn_back.UseVisualStyleBackColor = true; + this.btn_back.Click += new System.EventHandler(this.btn_back_Click); + // + // btn_Frin_Password + // + this.btn_Frin_Password.AutoSize = false; + this.btn_Frin_Password.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.btn_Frin_Password.Density = MaterialSkin.Controls.MaterialButton.MaterialButtonDensity.Default; + this.btn_Frin_Password.Depth = 0; + this.btn_Frin_Password.HighEmphasis = true; + this.btn_Frin_Password.Icon = null; + this.btn_Frin_Password.Location = new System.Drawing.Point(411, 381); + this.btn_Frin_Password.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); + this.btn_Frin_Password.MouseState = MaterialSkin.MouseState.HOVER; + this.btn_Frin_Password.Name = "btn_Frin_Password"; + this.btn_Frin_Password.NoAccentTextColor = System.Drawing.Color.Empty; + this.btn_Frin_Password.Size = new System.Drawing.Size(147, 36); + this.btn_Frin_Password.TabIndex = 15; + this.btn_Frin_Password.Text = "Find"; + this.btn_Frin_Password.Type = MaterialSkin.Controls.MaterialButton.MaterialButtonType.Contained; + this.btn_Frin_Password.UseAccentColor = false; + this.btn_Frin_Password.UseVisualStyleBackColor = true; + this.btn_Frin_Password.Click += new System.EventHandler(this.btn_Frin_Password_Click); + // + // txt_UserName + // + this.txt_UserName.Font = new System.Drawing.Font("宋体", 18F); + this.txt_UserName.Location = new System.Drawing.Point(195, 66); + this.txt_UserName.Multiline = true; + this.txt_UserName.Name = "txt_UserName"; + this.txt_UserName.Size = new System.Drawing.Size(389, 33); + this.txt_UserName.TabIndex = 16; + this.txt_UserName.Text = "User Name"; + this.txt_UserName.Click += new System.EventHandler(this.txt_UserName_Click); + this.txt_UserName.TextChanged += new System.EventHandler(this.txt_UserName_TextChanged); + // + // txt_Password + // + this.txt_Password.Font = new System.Drawing.Font("宋体", 18F); + this.txt_Password.Location = new System.Drawing.Point(195, 297); + this.txt_Password.Multiline = true; + this.txt_Password.Name = "txt_Password"; + this.txt_Password.Size = new System.Drawing.Size(389, 33); + this.txt_Password.TabIndex = 18; + // + // txt_broblem + // + this.txt_broblem.Font = new System.Drawing.Font("宋体", 18F); + this.txt_broblem.Location = new System.Drawing.Point(195, 138); + this.txt_broblem.Multiline = true; + this.txt_broblem.Name = "txt_broblem"; + this.txt_broblem.ReadOnly = true; + this.txt_broblem.Size = new System.Drawing.Size(389, 33); + this.txt_broblem.TabIndex = 20; + // + // txt_answer + // + this.txt_answer.Font = new System.Drawing.Font("宋体", 18F); + this.txt_answer.Location = new System.Drawing.Point(195, 217); + this.txt_answer.Multiline = true; + this.txt_answer.Name = "txt_answer"; + this.txt_answer.Size = new System.Drawing.Size(389, 33); + this.txt_answer.TabIndex = 21; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Bold); + this.label1.ForeColor = System.Drawing.Color.White; + this.label1.Location = new System.Drawing.Point(78, 72); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(111, 25); + this.label1.TabIndex = 455; + this.label1.Text = "User Name"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Bold); + this.label2.ForeColor = System.Drawing.Color.White; + this.label2.Location = new System.Drawing.Point(41, 303); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(148, 25); + this.label2.TabIndex = 456; + this.label2.Text = "Your Password"; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Bold); + this.label5.ForeColor = System.Drawing.Color.White; + this.label5.Location = new System.Drawing.Point(23, 144); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(166, 25); + this.label5.TabIndex = 458; + this.label5.Text = "security question"; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Bold); + this.label6.ForeColor = System.Drawing.Color.White; + this.label6.Location = new System.Drawing.Point(109, 223); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(80, 25); + this.label6.TabIndex = 459; + this.label6.Text = "Answer"; + // + // 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.FromArgb(((int)(((byte)(50)))), ((int)(((byte)(50)))), ((int)(((byte)(50))))); + this.panel1.Controls.Add(this.label6); + this.panel1.Controls.Add(this.label5); + this.panel1.Controls.Add(this.label2); + this.panel1.Controls.Add(this.label1); + this.panel1.Controls.Add(this.txt_answer); + this.panel1.Controls.Add(this.txt_broblem); + this.panel1.Controls.Add(this.txt_Password); + this.panel1.Controls.Add(this.txt_UserName); + this.panel1.Controls.Add(this.btn_Frin_Password); + this.panel1.Controls.Add(this.btn_back); + this.panel1.Location = new System.Drawing.Point(-3, 33); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(643, 540); + this.panel1.TabIndex = 453; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Bold); + this.label4.ForeColor = System.Drawing.Color.White; + this.label4.Location = new System.Drawing.Point(6, 5); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(221, 25); + this.label4.TabIndex = 455; + this.label4.Text = "find back the password"; + // + // BackPassWordForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(55)))), ((int)(((byte)(71)))), ((int)(((byte)(79))))); + this.ClientSize = new System.Drawing.Size(637, 570); + this.Controls.Add(this.label4); + this.Controls.Add(this.panel1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; + this.Name = "BackPassWordForm"; + this.Text = "BackPassWordForm"; + this.panel1.ResumeLayout(false); + this.panel1.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private MaterialSkin.Controls.MaterialButton btn_back; + private MaterialSkin.Controls.MaterialButton btn_Frin_Password; + private System.Windows.Forms.TextBox txt_UserName; + private System.Windows.Forms.TextBox txt_Password; + private System.Windows.Forms.TextBox txt_broblem; + private System.Windows.Forms.TextBox txt_answer; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.Label label4; + } +} \ No newline at end of file diff --git a/src/PBAnaly/LoginCommon/BackPassWordForm.cs b/src/PBAnaly/LoginCommon/BackPassWordForm.cs new file mode 100644 index 0000000..678a53a --- /dev/null +++ b/src/PBAnaly/LoginCommon/BackPassWordForm.cs @@ -0,0 +1,158 @@ +using AntdUI; +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 BackPassWordForm : Form + { + public BackPassWordForm() + { + 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 txt_UserName_TextChanged(object sender, EventArgs e) + { + try + { + txt_broblem.Text = ""; + + if (UserManage.UsersKeyValuePairs.ContainsKey(txt_UserName.Text)) + { + txt_broblem.Text = UserManage.UsersKeyValuePairs[txt_UserName.Text].PasswordQuestion; + } + + } + catch (Exception) + { + + } + } + + private void btn_Frin_Password_Click(object sender, EventArgs e) + { + try + { + string UserName = txt_UserName.Text; + string Password = txt_Password.Text; + string Broblem = txt_broblem.Text; + string Answer = ""; + + if (string.IsNullOrEmpty(txt_UserName.Text)) { MessageBox.Show("Please enter your username!!"); return; } + if (string.IsNullOrEmpty(txt_answer.Text)) { MessageBox.Show("Please enter the security answer!!"); return; } + + Answer = UserManage.UsersKeyValuePairs[txt_UserName.Text].QuestionAnswer; + + if (Answer != txt_answer.Text) { MessageBox.Show("Incorrect answer!!"); return; } + + txt_Password.Text = UserManage.UsersKeyValuePairs[txt_UserName.Text].Password; + + } + catch (Exception) + { + + } + } + + private void btn_back_Click(object sender, EventArgs e) + { + Close(); + } + + private void txt_UserName_Click(object sender, EventArgs e) + { + txt_UserName.Text = ""; + } + } +} diff --git a/src/PBAnaly/LoginCommon/BackPassWordForm.resx b/src/PBAnaly/LoginCommon/BackPassWordForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/src/PBAnaly/LoginCommon/BackPassWordForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + \ No newline at end of file diff --git a/src/PBAnaly/LoginCommon/LoginForm.Designer.cs b/src/PBAnaly/LoginCommon/LoginForm.Designer.cs index 8903cb6..8e56fb9 100644 --- a/src/PBAnaly/LoginCommon/LoginForm.Designer.cs +++ b/src/PBAnaly/LoginCommon/LoginForm.Designer.cs @@ -34,7 +34,9 @@ this.txt_UserName = new System.Windows.Forms.TextBox(); this.SIGNIN_materialButton = new MaterialSkin.Controls.MaterialButton(); this.btn_Login = new MaterialSkin.Controls.MaterialButton(); + this.label4 = new System.Windows.Forms.Label(); this.btn_Close = new System.Windows.Forms.Button(); + this.lab_forget_pass = new System.Windows.Forms.Label(); this.panel1.SuspendLayout(); this.SuspendLayout(); // @@ -44,11 +46,13 @@ | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(50)))), ((int)(((byte)(50)))), ((int)(((byte)(50))))); + this.panel1.Controls.Add(this.lab_forget_pass); this.panel1.Controls.Add(this.txt_Password); this.panel1.Controls.Add(this.cb_Remember); this.panel1.Controls.Add(this.txt_UserName); this.panel1.Controls.Add(this.SIGNIN_materialButton); this.panel1.Controls.Add(this.btn_Login); + this.panel1.Font = new System.Drawing.Font("宋体", 10F); this.panel1.Location = new System.Drawing.Point(-1, 33); this.panel1.Name = "panel1"; this.panel1.Size = new System.Drawing.Size(588, 332); @@ -104,10 +108,11 @@ this.SIGNIN_materialButton.NoAccentTextColor = System.Drawing.Color.Empty; this.SIGNIN_materialButton.Size = new System.Drawing.Size(147, 36); this.SIGNIN_materialButton.TabIndex = 15; - this.SIGNIN_materialButton.Text = "Sign In"; + this.SIGNIN_materialButton.Text = "Register"; this.SIGNIN_materialButton.Type = MaterialSkin.Controls.MaterialButton.MaterialButtonType.Contained; this.SIGNIN_materialButton.UseAccentColor = false; this.SIGNIN_materialButton.UseVisualStyleBackColor = true; + this.SIGNIN_materialButton.Click += new System.EventHandler(this.SIGNIN_materialButton_Click); // // btn_Login // @@ -130,6 +135,17 @@ this.btn_Login.UseVisualStyleBackColor = true; this.btn_Login.Click += new System.EventHandler(this.btn_Login_Click); // + // label4 + // + this.label4.AutoSize = true; + this.label4.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Bold); + this.label4.ForeColor = System.Drawing.Color.White; + this.label4.Location = new System.Drawing.Point(12, 5); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(63, 25); + this.label4.TabIndex = 451; + this.label4.Text = "Login"; + // // btn_Close // this.btn_Close.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); @@ -145,12 +161,27 @@ this.btn_Close.UseVisualStyleBackColor = false; this.btn_Close.Click += new System.EventHandler(this.btn_Close_Click); // + // lab_forget_pass + // + this.lab_forget_pass.AutoSize = true; + this.lab_forget_pass.Font = new System.Drawing.Font("微软雅黑", 9F); + this.lab_forget_pass.ForeColor = System.Drawing.Color.White; + this.lab_forget_pass.Location = new System.Drawing.Point(288, 175); + this.lab_forget_pass.Name = "lab_forget_pass"; + this.lab_forget_pass.Size = new System.Drawing.Size(207, 17); + this.lab_forget_pass.TabIndex = 495; + this.lab_forget_pass.Text = "Forgot your password? Click back"; + this.lab_forget_pass.Click += new System.EventHandler(this.lab_forget_pass_Click); + this.lab_forget_pass.MouseEnter += new System.EventHandler(this.lab_forget_pass_MouseEnter); + this.lab_forget_pass.MouseLeave += new System.EventHandler(this.lab_forget_pass_MouseLeave); + // // LoginForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(55)))), ((int)(((byte)(71)))), ((int)(((byte)(79))))); this.ClientSize = new System.Drawing.Size(587, 365); + this.Controls.Add(this.label4); this.Controls.Add(this.btn_Close); this.Controls.Add(this.panel1); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; @@ -159,6 +190,7 @@ this.panel1.ResumeLayout(false); this.panel1.PerformLayout(); this.ResumeLayout(false); + this.PerformLayout(); } @@ -171,5 +203,7 @@ private MaterialSkin.Controls.MaterialButton SIGNIN_materialButton; private MaterialSkin.Controls.MaterialButton btn_Login; private System.Windows.Forms.Button btn_Close; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label lab_forget_pass; } } \ No newline at end of file diff --git a/src/PBAnaly/LoginCommon/LoginForm.cs b/src/PBAnaly/LoginCommon/LoginForm.cs index b1de47e..687d690 100644 --- a/src/PBAnaly/LoginCommon/LoginForm.cs +++ b/src/PBAnaly/LoginCommon/LoginForm.cs @@ -187,5 +187,33 @@ namespace PBAnaly.LoginCommon } #endregion + private void SIGNIN_materialButton_Click(object sender, EventArgs e) + { + RegisterFrom register = new RegisterFrom(); + register.ShowDialog(); + + } + + private void lab_forget_pass_MouseEnter(object sender, EventArgs e) + { + // 鼠标进入时,样式变为手指 + Cursor = Cursors.Hand; + lab_forget_pass.Font = new Font("微软雅黑", 10); + lab_forget_pass.ForeColor = Color.LimeGreen; + } + + private void lab_forget_pass_MouseLeave(object sender, EventArgs e) + { + // 鼠标离开时,样式恢复为默认 + Cursor = Cursors.Default; + lab_forget_pass.Font = new Font("微软雅黑", 9); + lab_forget_pass.ForeColor = Color.White; + } + + private void lab_forget_pass_Click(object sender, EventArgs e) + { + BackPassWordForm backPass = new BackPassWordForm(); + backPass.ShowDialog(); + } } } diff --git a/src/PBAnaly/LoginCommon/RegisterFrom.Designer.cs b/src/PBAnaly/LoginCommon/RegisterFrom.Designer.cs new file mode 100644 index 0000000..5be9a4f --- /dev/null +++ b/src/PBAnaly/LoginCommon/RegisterFrom.Designer.cs @@ -0,0 +1,271 @@ +namespace PBAnaly.LoginCommon +{ + partial class RegisterFrom + { + /// + /// 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() + { + this.panel1 = new System.Windows.Forms.Panel(); + this.txt_Password = new System.Windows.Forms.TextBox(); + this.txt_UserName = new System.Windows.Forms.TextBox(); + this.btn_register = new MaterialSkin.Controls.MaterialButton(); + this.btn_back = new MaterialSkin.Controls.MaterialButton(); + this.label4 = new System.Windows.Forms.Label(); + this.txt_enter_password = new System.Windows.Forms.TextBox(); + this.txt_broblem = new System.Windows.Forms.TextBox(); + this.txt_answer = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); + this.label6 = new System.Windows.Forms.Label(); + this.panel1.SuspendLayout(); + 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.FromArgb(((int)(((byte)(50)))), ((int)(((byte)(50)))), ((int)(((byte)(50))))); + this.panel1.Controls.Add(this.label6); + this.panel1.Controls.Add(this.label5); + this.panel1.Controls.Add(this.label3); + this.panel1.Controls.Add(this.label2); + this.panel1.Controls.Add(this.label1); + this.panel1.Controls.Add(this.txt_answer); + this.panel1.Controls.Add(this.txt_broblem); + this.panel1.Controls.Add(this.txt_enter_password); + this.panel1.Controls.Add(this.txt_Password); + this.panel1.Controls.Add(this.txt_UserName); + this.panel1.Controls.Add(this.btn_register); + this.panel1.Controls.Add(this.btn_back); + this.panel1.Location = new System.Drawing.Point(-1, 33); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(638, 537); + this.panel1.TabIndex = 452; + // + // txt_Password + // + this.txt_Password.Font = new System.Drawing.Font("宋体", 18F); + this.txt_Password.Location = new System.Drawing.Point(195, 132); + this.txt_Password.Multiline = true; + this.txt_Password.Name = "txt_Password"; + this.txt_Password.PasswordChar = '*'; + this.txt_Password.Size = new System.Drawing.Size(389, 33); + this.txt_Password.TabIndex = 18; + this.txt_Password.Text = "User Name"; + this.txt_Password.Click += new System.EventHandler(this.txt_Password_Click); + // + // txt_UserName + // + this.txt_UserName.Font = new System.Drawing.Font("宋体", 18F); + this.txt_UserName.Location = new System.Drawing.Point(195, 66); + this.txt_UserName.Multiline = true; + this.txt_UserName.Name = "txt_UserName"; + this.txt_UserName.Size = new System.Drawing.Size(389, 33); + this.txt_UserName.TabIndex = 16; + this.txt_UserName.Text = "User Name"; + this.txt_UserName.Click += new System.EventHandler(this.txt_UserName_Click); + // + // btn_register + // + this.btn_register.AutoSize = false; + this.btn_register.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.btn_register.Density = MaterialSkin.Controls.MaterialButton.MaterialButtonDensity.Default; + this.btn_register.Depth = 0; + this.btn_register.HighEmphasis = true; + this.btn_register.Icon = null; + this.btn_register.Location = new System.Drawing.Point(394, 431); + this.btn_register.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); + this.btn_register.MouseState = MaterialSkin.MouseState.HOVER; + this.btn_register.Name = "btn_register"; + this.btn_register.NoAccentTextColor = System.Drawing.Color.Empty; + this.btn_register.Size = new System.Drawing.Size(147, 36); + this.btn_register.TabIndex = 15; + this.btn_register.Text = "register"; + this.btn_register.Type = MaterialSkin.Controls.MaterialButton.MaterialButtonType.Contained; + this.btn_register.UseAccentColor = false; + this.btn_register.UseVisualStyleBackColor = true; + this.btn_register.Click += new System.EventHandler(this.btn_register_Click); + // + // btn_back + // + this.btn_back.AutoSize = false; + this.btn_back.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.btn_back.Density = MaterialSkin.Controls.MaterialButton.MaterialButtonDensity.Default; + this.btn_back.Depth = 0; + this.btn_back.HighEmphasis = true; + this.btn_back.Icon = null; + this.btn_back.Location = new System.Drawing.Point(14, 9); + this.btn_back.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); + this.btn_back.MouseState = MaterialSkin.MouseState.HOVER; + this.btn_back.Name = "btn_back"; + this.btn_back.NoAccentTextColor = System.Drawing.Color.Empty; + this.btn_back.Size = new System.Drawing.Size(62, 30); + this.btn_back.TabIndex = 14; + this.btn_back.Text = "back"; + this.btn_back.Type = MaterialSkin.Controls.MaterialButton.MaterialButtonType.Contained; + this.btn_back.UseAccentColor = false; + this.btn_back.UseVisualStyleBackColor = true; + this.btn_back.Click += new System.EventHandler(this.btn_back_Click); + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Bold); + this.label4.ForeColor = System.Drawing.Color.White; + this.label4.Location = new System.Drawing.Point(12, 5); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(81, 25); + this.label4.TabIndex = 454; + this.label4.Text = "register"; + // + // txt_enter_password + // + this.txt_enter_password.Font = new System.Drawing.Font("宋体", 18F); + this.txt_enter_password.Location = new System.Drawing.Point(195, 203); + this.txt_enter_password.Multiline = true; + this.txt_enter_password.Name = "txt_enter_password"; + this.txt_enter_password.PasswordChar = '*'; + this.txt_enter_password.Size = new System.Drawing.Size(389, 33); + this.txt_enter_password.TabIndex = 19; + this.txt_enter_password.Text = "User Name"; + this.txt_enter_password.Click += new System.EventHandler(this.txt_enter_password_Click); + // + // txt_broblem + // + this.txt_broblem.Font = new System.Drawing.Font("宋体", 18F); + this.txt_broblem.Location = new System.Drawing.Point(195, 276); + this.txt_broblem.Multiline = true; + this.txt_broblem.Name = "txt_broblem"; + this.txt_broblem.Size = new System.Drawing.Size(389, 33); + this.txt_broblem.TabIndex = 20; + this.txt_broblem.Text = "Security problem"; + this.txt_broblem.Click += new System.EventHandler(this.txt_broblem_Click); + // + // txt_answer + // + this.txt_answer.Font = new System.Drawing.Font("宋体", 18F); + this.txt_answer.Location = new System.Drawing.Point(195, 355); + this.txt_answer.Multiline = true; + this.txt_answer.Name = "txt_answer"; + this.txt_answer.Size = new System.Drawing.Size(389, 33); + this.txt_answer.TabIndex = 21; + this.txt_answer.Text = "Security answer"; + this.txt_answer.Click += new System.EventHandler(this.txt_answer_Click); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Bold); + this.label1.ForeColor = System.Drawing.Color.White; + this.label1.Location = new System.Drawing.Point(78, 72); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(111, 25); + this.label1.TabIndex = 455; + this.label1.Text = "User Name"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Bold); + this.label2.ForeColor = System.Drawing.Color.White; + this.label2.Location = new System.Drawing.Point(90, 138); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(99, 25); + this.label2.TabIndex = 456; + this.label2.Text = "Password"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Bold); + this.label3.ForeColor = System.Drawing.Color.White; + this.label3.Location = new System.Drawing.Point(11, 209); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(178, 25); + this.label3.TabIndex = 457; + this.label3.Text = "Confirm Password"; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Bold); + this.label5.ForeColor = System.Drawing.Color.White; + this.label5.Location = new System.Drawing.Point(23, 282); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(166, 25); + this.label5.TabIndex = 458; + this.label5.Text = "security question"; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Bold); + this.label6.ForeColor = System.Drawing.Color.White; + this.label6.Location = new System.Drawing.Point(109, 361); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(80, 25); + this.label6.TabIndex = 459; + this.label6.Text = "Answer"; + // + // RegisterFrom + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(55)))), ((int)(((byte)(71)))), ((int)(((byte)(79))))); + this.ClientSize = new System.Drawing.Size(637, 570); + this.Controls.Add(this.panel1); + this.Controls.Add(this.label4); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; + this.Name = "RegisterFrom"; + this.Text = "RegisterFrom"; + this.panel1.ResumeLayout(false); + this.panel1.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.TextBox txt_answer; + private System.Windows.Forms.TextBox txt_broblem; + private System.Windows.Forms.TextBox txt_enter_password; + private System.Windows.Forms.TextBox txt_Password; + private System.Windows.Forms.TextBox txt_UserName; + private MaterialSkin.Controls.MaterialButton btn_register; + private MaterialSkin.Controls.MaterialButton btn_back; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label1; + } +} \ No newline at end of file diff --git a/src/PBAnaly/LoginCommon/RegisterFrom.cs b/src/PBAnaly/LoginCommon/RegisterFrom.cs new file mode 100644 index 0000000..68c1fbe --- /dev/null +++ b/src/PBAnaly/LoginCommon/RegisterFrom.cs @@ -0,0 +1,188 @@ +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 RegisterFrom : Form + { + public RegisterFrom() + { + 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 + + #region btn_register_Click 注册按钮 + private void btn_register_Click(object sender, EventArgs e) + { + try + { + string UserName = txt_UserName.Text; + string Password = txt_Password.Text; + string Enter_Password = txt_enter_password.Text; + string Broblem = txt_broblem.Text; + string Answer = txt_answer.Text; + + if (UserManage.UsersKeyValuePairs.ContainsKey(UserName)) { MessageBox.Show("The current user already exists!!"); return; } + if (string.IsNullOrEmpty(UserName)){MessageBox.Show("Please enter your username!!");return;} + if (string.IsNullOrEmpty(Password)){MessageBox.Show("Please enter your Password!!");return;} + if (string.IsNullOrEmpty(Enter_Password)){MessageBox.Show("Please enter a second password!!");return;} + if (string.IsNullOrEmpty(Broblem)){MessageBox.Show("Please enter the security question, in case you forget" + + " the password, you can report the question to retrieve!!");return;} + if (string.IsNullOrEmpty(Answer)){MessageBox.Show("Please enter the security answer!!");return;} + if(Password!= Enter_Password) { MessageBox.Show("The two passwords are different!!"); return; } + + User user = new User(); + user.Name = UserName; + user.Password= Password; + user.Role = UserRole.Operator; + user.PasswordQuestion = Broblem; + user.QuestionAnswer = Answer; + user.CreatedDate=DateTime.Now; + + if (UserManage.RegisterUser(user)) + { + txt_UserName.Text = ""; + txt_Password.Text = ""; + txt_enter_password.Text = ""; + txt_broblem.Text = ""; + txt_answer.Text = ""; + + MessageBox.Show("注册成功"); + } + else + { + MessageBox.Show("注册失败"); + + } + + } + catch (Exception ex) + { + + } + } + #endregion + + private void txt_UserName_Click(object sender, EventArgs e) + { + txt_UserName.Text = ""; + } + + private void txt_Password_Click(object sender, EventArgs e) + { + txt_Password.Text = ""; + } + + private void txt_enter_password_Click(object sender, EventArgs e) + { + txt_enter_password.Text = ""; + } + + private void txt_broblem_Click(object sender, EventArgs e) + { + txt_broblem.Text = ""; + } + + private void txt_answer_Click(object sender, EventArgs e) + { + txt_answer.Text = ""; + } + + private void btn_back_Click(object sender, EventArgs e) + { + this.Close(); + } + } +} diff --git a/src/PBAnaly/LoginCommon/RegisterFrom.resx b/src/PBAnaly/LoginCommon/RegisterFrom.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/src/PBAnaly/LoginCommon/RegisterFrom.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + \ No newline at end of file diff --git a/src/PBAnaly/LoginCommon/UserManage.cs b/src/PBAnaly/LoginCommon/UserManage.cs index 4b8f893..8cce54b 100644 --- a/src/PBAnaly/LoginCommon/UserManage.cs +++ b/src/PBAnaly/LoginCommon/UserManage.cs @@ -6,6 +6,7 @@ using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Xml.Linq; namespace PBAnaly.LoginCommon { @@ -215,7 +216,7 @@ namespace PBAnaly.LoginCommon LastLoginUser.Add(last.UserName, last); } } - + connection.Close(); } catch (Exception e) { @@ -271,5 +272,54 @@ namespace PBAnaly.LoginCommon } #endregion + + #region RegisterUser 注册一个用户 + /// + /// 用户注册 + /// + /// + /// + public static bool RegisterUser(User user) + { + try + { + using (var connection = new SQLiteConnection(connectionString)) + { + connection.Open(); + + string insertSQL = @" + INSERT OR IGNORE INTO User (UserName, Password, CreatedBy, CreatedDate, Role, PasswordQuestion, QuestionAnswer) + VALUES (@UserName, @Password, @CreatedBy, @CreatedDate, @Role, @PasswordQuestion, @QuestionAnswer);"; + + using (var command = new SQLiteCommand(insertSQL, connection)) + { + // 参数化查询,防止SQL注入 + command.Parameters.AddWithValue("@UserName", user.Name); + command.Parameters.AddWithValue("@Password", user.Password); // 示例密码 + command.Parameters.AddWithValue("@CreatedBy", "System"); + command.Parameters.AddWithValue("@CreatedDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); + command.Parameters.AddWithValue("@Role", user.Role); + command.Parameters.AddWithValue("@PasswordQuestion", user.PasswordQuestion); + command.Parameters.AddWithValue("@QuestionAnswer", user.QuestionAnswer); + + command.ExecuteNonQuery(); + + } + + connection.Close(); + } + + UsersKeyValuePairs[user.Name] = user; + return true; + } + catch (Exception ex) + { + return false; + } + } + + + #endregion + } } diff --git a/src/PBAnaly/LoginCommon/UserRole.cs b/src/PBAnaly/LoginCommon/UserRole.cs index 617110d..50ae753 100644 --- a/src/PBAnaly/LoginCommon/UserRole.cs +++ b/src/PBAnaly/LoginCommon/UserRole.cs @@ -17,9 +17,17 @@ namespace PBAnaly.LoginCommon /// Operator, /// + /// 工程师 + /// + Engineer, + /// /// 管理员权限 /// - Administrator + Administrator, + /// + /// 超级管理员 + /// + SuperAdministrator } #endregion } diff --git a/src/PBAnaly/PBAnaly.csproj b/src/PBAnaly/PBAnaly.csproj index 9cc7667..8bcbce7 100644 --- a/src/PBAnaly/PBAnaly.csproj +++ b/src/PBAnaly/PBAnaly.csproj @@ -75,6 +75,12 @@ LogForm.cs + + Form + + + BackPassWordForm.cs + Form @@ -82,6 +88,12 @@ LoginForm.cs + + Form + + + RegisterFrom.cs + @@ -168,9 +180,15 @@ LogForm.cs + + BackPassWordForm.cs + LoginForm.cs + + RegisterFrom.cs + LoginForm.cs