⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmregist.cs

📁 小型图书管理系统,C#和SQlServer构建,Winform桌面应用程序
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Data;

using library.VisiteDB;

namespace library.Forms
{
	/// <summary>
	/// frmRegist 的摘要说明。
	/// </summary>
	public class frmRegist : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label lbUsername;
		private System.Windows.Forms.TextBox txtUsername;
		private System.Windows.Forms.Button btnOK;
		private System.Windows.Forms.Button btnCancel;
		private System.Windows.Forms.Label lbPassword1;
		private System.Windows.Forms.Label lbPassword2;
		private System.Windows.Forms.Label lbEmail;
		private System.Windows.Forms.TextBox txtPassword1;
		private System.Windows.Forms.TextBox txtPassword2;
		private System.Windows.Forms.TextBox txtEmail;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;
		private DataEngine de = new DataEngine();

		public frmRegist()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}

		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.lbUsername = new System.Windows.Forms.Label();
			this.lbPassword1 = new System.Windows.Forms.Label();
			this.lbPassword2 = new System.Windows.Forms.Label();
			this.lbEmail = new System.Windows.Forms.Label();
			this.txtUsername = new System.Windows.Forms.TextBox();
			this.txtPassword1 = new System.Windows.Forms.TextBox();
			this.txtPassword2 = new System.Windows.Forms.TextBox();
			this.txtEmail = new System.Windows.Forms.TextBox();
			this.btnOK = new System.Windows.Forms.Button();
			this.btnCancel = new System.Windows.Forms.Button();
			this.SuspendLayout();
			// 
			// lbUsername
			// 
			this.lbUsername.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.lbUsername.Location = new System.Drawing.Point(32, 24);
			this.lbUsername.Name = "lbUsername";
			this.lbUsername.Size = new System.Drawing.Size(64, 24);
			this.lbUsername.TabIndex = 0;
			this.lbUsername.Text = "用户名";
			this.lbUsername.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// lbPassword1
			// 
			this.lbPassword1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.lbPassword1.Location = new System.Drawing.Point(32, 64);
			this.lbPassword1.Name = "lbPassword1";
			this.lbPassword1.Size = new System.Drawing.Size(64, 24);
			this.lbPassword1.TabIndex = 1;
			this.lbPassword1.Text = "密码";
			this.lbPassword1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// lbPassword2
			// 
			this.lbPassword2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.lbPassword2.Location = new System.Drawing.Point(32, 104);
			this.lbPassword2.Name = "lbPassword2";
			this.lbPassword2.Size = new System.Drawing.Size(72, 16);
			this.lbPassword2.TabIndex = 2;
			this.lbPassword2.Text = "确认密码";
			// 
			// lbEmail
			// 
			this.lbEmail.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.lbEmail.Location = new System.Drawing.Point(40, 144);
			this.lbEmail.Name = "lbEmail";
			this.lbEmail.Size = new System.Drawing.Size(64, 16);
			this.lbEmail.TabIndex = 3;
			this.lbEmail.Text = "E-Mail";
			this.lbEmail.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// txtUsername
			// 
			this.txtUsername.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.txtUsername.Location = new System.Drawing.Point(120, 24);
			this.txtUsername.Name = "txtUsername";
			this.txtUsername.Size = new System.Drawing.Size(176, 21);
			this.txtUsername.TabIndex = 4;
			this.txtUsername.Text = "";
			// 
			// txtPassword1
			// 
			this.txtPassword1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.txtPassword1.Location = new System.Drawing.Point(120, 64);
			this.txtPassword1.Name = "txtPassword1";
			this.txtPassword1.PasswordChar = '*';
			this.txtPassword1.Size = new System.Drawing.Size(176, 21);
			this.txtPassword1.TabIndex = 5;
			this.txtPassword1.Text = "";
			// 
			// txtPassword2
			// 
			this.txtPassword2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.txtPassword2.Location = new System.Drawing.Point(120, 104);
			this.txtPassword2.Name = "txtPassword2";
			this.txtPassword2.PasswordChar = '*';
			this.txtPassword2.Size = new System.Drawing.Size(176, 21);
			this.txtPassword2.TabIndex = 6;
			this.txtPassword2.Text = "";
			// 
			// txtEmail
			// 
			this.txtEmail.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.txtEmail.Location = new System.Drawing.Point(120, 144);
			this.txtEmail.Name = "txtEmail";
			this.txtEmail.Size = new System.Drawing.Size(176, 21);
			this.txtEmail.TabIndex = 7;
			this.txtEmail.Text = "";
			// 
			// btnOK
			// 
			this.btnOK.Location = new System.Drawing.Point(64, 200);
			this.btnOK.Name = "btnOK";
			this.btnOK.Size = new System.Drawing.Size(80, 32);
			this.btnOK.TabIndex = 8;
			this.btnOK.Text = "提交";
			this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
			// 
			// btnCancel
			// 
			this.btnCancel.Location = new System.Drawing.Point(184, 200);
			this.btnCancel.Name = "btnCancel";
			this.btnCancel.Size = new System.Drawing.Size(80, 32);
			this.btnCancel.TabIndex = 9;
			this.btnCancel.Text = "取消";
			this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
			// 
			// frmRegist
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(344, 262);
			this.Controls.Add(this.btnCancel);
			this.Controls.Add(this.btnOK);
			this.Controls.Add(this.txtEmail);
			this.Controls.Add(this.txtPassword2);
			this.Controls.Add(this.txtPassword1);
			this.Controls.Add(this.txtUsername);
			this.Controls.Add(this.lbEmail);
			this.Controls.Add(this.lbPassword2);
			this.Controls.Add(this.lbPassword1);
			this.Controls.Add(this.lbUsername);
			this.Name = "frmRegist";
			this.Text = "新用户注册";
			this.ResumeLayout(false);

		}
		#endregion

		private void btnOK_Click(object sender, System.EventArgs e)
		{
			if(txtUsername.Text == "")
			{
				MessageBox.Show("用户名不能为空","提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
			}
			else if(txtPassword1.Text == "" || txtPassword2.Text == "")
			{
				MessageBox.Show("必须输入密码", "提示", MessageBoxButtons.OKCancel , MessageBoxIcon.Warning );
			}
			else if(txtPassword1.Text != txtPassword2.Text)
			{
				MessageBox.Show("两次输入的密码不一致", "提示", MessageBoxButtons.OKCancel , MessageBoxIcon.Warning );
			}
			else if(txtEmail.Text == "" || txtEmail.Text.IndexOf("@") < 0)
			{
				MessageBox.Show("Email地址不正确", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
			}
			else
			{
				bool result = de.userRegister(txtUsername.Text, txtPassword1.Text, txtEmail.Text);
				if(result == true)
				{
					MessageBox.Show("祝贺你注册成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
					this.Dispose();
				}
				else
				{
					MessageBox.Show("注册失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
				}
			}
		}

		private void btnCancel_Click(object sender, System.EventArgs e)
		{
			this.Dispose();
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -