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

📄 frmadduser.cs

📁 一个学籍管理系统 以在某高校投入使用了
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;

namespace prjClass
{
	/// <summary>
	/// frmAddUser 的摘要说明。
	/// </summary>
	public class frmAddUser : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.TextBox txtName;
		private System.Windows.Forms.Button btnOK;
		private System.Windows.Forms.TextBox txtPwd;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.TextBox txtPwd1;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.Button btnCancel;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.ComboBox cbopur;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public frmAddUser()
		{
			//
			// 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.label1 = new System.Windows.Forms.Label();
			this.txtName = new System.Windows.Forms.TextBox();
			this.btnOK = new System.Windows.Forms.Button();
			this.txtPwd = new System.Windows.Forms.TextBox();
			this.label2 = new System.Windows.Forms.Label();
			this.txtPwd1 = new System.Windows.Forms.TextBox();
			this.label3 = new System.Windows.Forms.Label();
			this.btnCancel = new System.Windows.Forms.Button();
			this.label4 = new System.Windows.Forms.Label();
			this.cbopur = new System.Windows.Forms.ComboBox();
			this.SuspendLayout();
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(24, 40);
			this.label1.Name = "label1";
			this.label1.TabIndex = 0;
			this.label1.Text = "用户名";
			// 
			// txtName
			// 
			this.txtName.Location = new System.Drawing.Point(96, 40);
			this.txtName.Name = "txtName";
			this.txtName.Size = new System.Drawing.Size(176, 21);
			this.txtName.TabIndex = 1;
			this.txtName.Text = "";
			// 
			// btnOK
			// 
			this.btnOK.Location = new System.Drawing.Point(40, 272);
			this.btnOK.Name = "btnOK";
			this.btnOK.TabIndex = 4;
			this.btnOK.Text = "确认";
			this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
			// 
			// txtPwd
			// 
			this.txtPwd.Location = new System.Drawing.Point(96, 96);
			this.txtPwd.Name = "txtPwd";
			this.txtPwd.PasswordChar = '*';
			this.txtPwd.Size = new System.Drawing.Size(176, 21);
			this.txtPwd.TabIndex = 2;
			this.txtPwd.Text = "";
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(24, 96);
			this.label2.Name = "label2";
			this.label2.TabIndex = 3;
			this.label2.Text = "密码";
			// 
			// txtPwd1
			// 
			this.txtPwd1.Location = new System.Drawing.Point(96, 155);
			this.txtPwd1.Name = "txtPwd1";
			this.txtPwd1.PasswordChar = '*';
			this.txtPwd1.Size = new System.Drawing.Size(176, 21);
			this.txtPwd1.TabIndex = 3;
			this.txtPwd1.Text = "";
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(24, 155);
			this.label3.Name = "label3";
			this.label3.TabIndex = 5;
			this.label3.Text = "密码确认";
			// 
			// btnCancel
			// 
			this.btnCancel.Location = new System.Drawing.Point(192, 272);
			this.btnCancel.Name = "btnCancel";
			this.btnCancel.TabIndex = 5;
			this.btnCancel.Text = "取消";
			this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(24, 216);
			this.label4.Name = "label4";
			this.label4.TabIndex = 6;
			this.label4.Text = "权限";
			// 
			// cbopur
			// 
			this.cbopur.Location = new System.Drawing.Point(96, 216);
			this.cbopur.Name = "cbopur";
			this.cbopur.Size = new System.Drawing.Size(176, 20);
			this.cbopur.TabIndex = 7;
			this.cbopur.Text = "comboBox1";
			// 
			// frmAddUser
			// 
			this.AcceptButton = this.btnOK;
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(328, 333);
			this.Controls.Add(this.cbopur);
			this.Controls.Add(this.label4);
			this.Controls.Add(this.btnCancel);
			this.Controls.Add(this.txtPwd1);
			this.Controls.Add(this.txtPwd);
			this.Controls.Add(this.txtName);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.btnOK);
			this.Controls.Add(this.label1);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.MaximizeBox = false;
			this.Name = "frmAddUser";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "添加新用户";
			this.Load += new System.EventHandler(this.frmAddUser_Load);
			this.ResumeLayout(false);

		}
		#endregion


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

		private void btnOK_Click(object sender, System.EventArgs e)
		{
			Class1 c = new Class1();
			string Sql = "select * from Class..UserInfo where UserID = '"+this.txtName.Text+"'";
			string SqlAdd = "insert into Class..UserInfo values('"+this.txtName.Text+"','"+this.txtPwd.Text+"','"+this.cbopur.SelectedItem.ToString()+"')";
			if(c.IsExits(Sql)==true)
			{
				MessageBox.Show("该用户名已经存在","提示信息!",MessageBoxButtons.OK,MessageBoxIcon.Question);
			}
			else if(this.txtPwd1.Text!=this.txtPwd.Text)
			{
				MessageBox.Show("两次输入密码不一致","提示信息!",MessageBoxButtons.OK,MessageBoxIcon.Question);
			}
			else
			{	
				c.EditData(SqlAdd);
				if(MessageBox.Show("添加新用户成功!","提示信息!",MessageBoxButtons.OK,MessageBoxIcon.Information)==DialogResult.OK)
				{
					this.Close();				
				}	
				
			}
		}

		private void frmAddUser_Load(object sender, System.EventArgs e)
		{
			this.cbopur.Items.Add("普通用户");
			this.cbopur.Items.Add("超级用户");
			this.cbopur.SelectedIndex=0;
		}
	}
}

⌨️ 快捷键说明

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