融合数据库

This commit is contained in:
耿东亚 2024-12-19 20:01:27 +08:00
commit cf5ad0bdc0
11 changed files with 1235 additions and 3 deletions

View File

@ -0,0 +1,237 @@
namespace PBAnaly.LoginCommon
{
partial class BackPassWordForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}

View File

@ -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 = "";
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -34,7 +34,9 @@
this.txt_UserName = new System.Windows.Forms.TextBox(); this.txt_UserName = new System.Windows.Forms.TextBox();
this.SIGNIN_materialButton = new MaterialSkin.Controls.MaterialButton(); this.SIGNIN_materialButton = new MaterialSkin.Controls.MaterialButton();
this.btn_Login = 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.btn_Close = new System.Windows.Forms.Button();
this.lab_forget_pass = new System.Windows.Forms.Label();
this.panel1.SuspendLayout(); this.panel1.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
@ -44,11 +46,13 @@
| System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(50)))), ((int)(((byte)(50)))), ((int)(((byte)(50))))); 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.txt_Password);
this.panel1.Controls.Add(this.cb_Remember); this.panel1.Controls.Add(this.cb_Remember);
this.panel1.Controls.Add(this.txt_UserName); this.panel1.Controls.Add(this.txt_UserName);
this.panel1.Controls.Add(this.SIGNIN_materialButton); this.panel1.Controls.Add(this.SIGNIN_materialButton);
this.panel1.Controls.Add(this.btn_Login); 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.Location = new System.Drawing.Point(-1, 33);
this.panel1.Name = "panel1"; this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(588, 332); this.panel1.Size = new System.Drawing.Size(588, 332);
@ -104,10 +108,11 @@
this.SIGNIN_materialButton.NoAccentTextColor = System.Drawing.Color.Empty; this.SIGNIN_materialButton.NoAccentTextColor = System.Drawing.Color.Empty;
this.SIGNIN_materialButton.Size = new System.Drawing.Size(147, 36); this.SIGNIN_materialButton.Size = new System.Drawing.Size(147, 36);
this.SIGNIN_materialButton.TabIndex = 15; 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.Type = MaterialSkin.Controls.MaterialButton.MaterialButtonType.Contained;
this.SIGNIN_materialButton.UseAccentColor = false; this.SIGNIN_materialButton.UseAccentColor = false;
this.SIGNIN_materialButton.UseVisualStyleBackColor = true; this.SIGNIN_materialButton.UseVisualStyleBackColor = true;
this.SIGNIN_materialButton.Click += new System.EventHandler(this.SIGNIN_materialButton_Click);
// //
// btn_Login // btn_Login
// //
@ -130,6 +135,17 @@
this.btn_Login.UseVisualStyleBackColor = true; this.btn_Login.UseVisualStyleBackColor = true;
this.btn_Login.Click += new System.EventHandler(this.btn_Login_Click); 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 // btn_Close
// //
this.btn_Close.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 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.UseVisualStyleBackColor = false;
this.btn_Close.Click += new System.EventHandler(this.btn_Close_Click); 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 // LoginForm
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(55)))), ((int)(((byte)(71)))), ((int)(((byte)(79))))); this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(55)))), ((int)(((byte)(71)))), ((int)(((byte)(79)))));
this.ClientSize = new System.Drawing.Size(587, 365); this.ClientSize = new System.Drawing.Size(587, 365);
this.Controls.Add(this.label4);
this.Controls.Add(this.btn_Close); this.Controls.Add(this.btn_Close);
this.Controls.Add(this.panel1); this.Controls.Add(this.panel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
@ -159,6 +190,7 @@
this.panel1.ResumeLayout(false); this.panel1.ResumeLayout(false);
this.panel1.PerformLayout(); this.panel1.PerformLayout();
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout();
} }
@ -171,5 +203,7 @@
private MaterialSkin.Controls.MaterialButton SIGNIN_materialButton; private MaterialSkin.Controls.MaterialButton SIGNIN_materialButton;
private MaterialSkin.Controls.MaterialButton btn_Login; private MaterialSkin.Controls.MaterialButton btn_Login;
private System.Windows.Forms.Button btn_Close; private System.Windows.Forms.Button btn_Close;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label lab_forget_pass;
} }
} }

View File

@ -187,5 +187,33 @@ namespace PBAnaly.LoginCommon
} }
#endregion #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();
}
} }
} }

View File

@ -0,0 +1,271 @@
namespace PBAnaly.LoginCommon
{
partial class RegisterFrom
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}

View File

@ -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();
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -6,6 +6,7 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Xml.Linq;
namespace PBAnaly.LoginCommon namespace PBAnaly.LoginCommon
{ {
@ -215,7 +216,7 @@ namespace PBAnaly.LoginCommon
LastLoginUser.Add(last.UserName, last); LastLoginUser.Add(last.UserName, last);
} }
} }
connection.Close();
} }
catch (Exception e) catch (Exception e)
{ {
@ -271,5 +272,54 @@ namespace PBAnaly.LoginCommon
} }
#endregion #endregion
#region RegisterUser
/// <summary>
/// 用户注册
/// </summary>
/// <param name="user"></param>
/// <returns></returns>
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
} }
} }

View File

@ -17,9 +17,17 @@ namespace PBAnaly.LoginCommon
/// </summary> /// </summary>
Operator, Operator,
/// <summary> /// <summary>
/// 工程师
/// </summary>
Engineer,
/// <summary>
/// 管理员权限 /// 管理员权限
/// </summary> /// </summary>
Administrator Administrator,
/// <summary>
/// 超级管理员
/// </summary>
SuperAdministrator
} }
#endregion #endregion
} }

View File

@ -75,6 +75,12 @@
<Compile Include="LogForm.Designer.cs"> <Compile Include="LogForm.Designer.cs">
<DependentUpon>LogForm.cs</DependentUpon> <DependentUpon>LogForm.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="LoginCommon\BackPassWordForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="LoginCommon\BackPassWordForm.Designer.cs">
<DependentUpon>BackPassWordForm.cs</DependentUpon>
</Compile>
<Compile Include="LoginCommon\LastLogin.cs" /> <Compile Include="LoginCommon\LastLogin.cs" />
<Compile Include="LoginCommon\LoginForm.cs"> <Compile Include="LoginCommon\LoginForm.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
@ -82,6 +88,12 @@
<Compile Include="LoginCommon\LoginForm.Designer.cs"> <Compile Include="LoginCommon\LoginForm.Designer.cs">
<DependentUpon>LoginForm.cs</DependentUpon> <DependentUpon>LoginForm.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="LoginCommon\RegisterFrom.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="LoginCommon\RegisterFrom.Designer.cs">
<DependentUpon>RegisterFrom.cs</DependentUpon>
</Compile>
<Compile Include="LoginCommon\User.cs" /> <Compile Include="LoginCommon\User.cs" />
<Compile Include="LoginCommon\UserManage.cs" /> <Compile Include="LoginCommon\UserManage.cs" />
<Compile Include="LoginCommon\UserRole.cs" /> <Compile Include="LoginCommon\UserRole.cs" />
@ -168,9 +180,15 @@
<EmbeddedResource Include="LogForm.resx"> <EmbeddedResource Include="LogForm.resx">
<DependentUpon>LogForm.cs</DependentUpon> <DependentUpon>LogForm.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="LoginCommon\BackPassWordForm.resx">
<DependentUpon>BackPassWordForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="LoginCommon\LoginForm.resx"> <EmbeddedResource Include="LoginCommon\LoginForm.resx">
<DependentUpon>LoginForm.cs</DependentUpon> <DependentUpon>LoginForm.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="LoginCommon\RegisterFrom.resx">
<DependentUpon>RegisterFrom.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="LoginForm.resx"> <EmbeddedResource Include="LoginForm.resx">
<DependentUpon>LoginForm.cs</DependentUpon> <DependentUpon>LoginForm.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>