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

📄 regist.cs

📁 自己参考开发的程序,用C#编写的,还有很的功能没有实现,数据库的安全性也没有很好的解决好.
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;

namespace 教务管理系统
{
	/// <summary>
	/// Regist 的摘要说明。
	/// </summary>
	public class Regist : System.Windows.Forms.Form
	{
		private DataSet ds = new DataSet();
		private DataTable myTable;
	//	private DataRow myRow;
		private string sendStrSQL = "SELECT * from 用户权限表";
		
		private DataSet ds1 = new DataSet();
		private DataTable myTable1;
		private DataRow myRow1;
		private string sendStrSQL1 = "SELECT * from 学生信息";

		private System.Windows.Forms.TextBox std_ID;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.TextBox PSD_O;
		private System.Windows.Forms.TextBox PSD_N;
		private System.Windows.Forms.Button btnOK;
		private System.Windows.Forms.Button btnCancel;
		private System.Windows.Forms.TextBox Name_New;                                                                                                                                                                                                                                                                                                                                                                                                           
		private System.Windows.Forms.TextBox SEX_NEW;
		private System.Windows.Forms.Label labe_ID;
		private System.Windows.Forms.Label Lab_Name;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

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

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
			LinkDataBase link = new LinkDataBase();	
			string sendTableName = "用户权限表";
			this.ds = link.SelectDataBase(sendStrSQL,sendTableName);
			this.myTable = ds.Tables[0];

			LinkDataBase link1 = new LinkDataBase();	
			string sendTableName1 = "学生信息";
			this.ds1 = link1.SelectDataBase(sendStrSQL1,sendTableName1);
			this.myTable1 = ds1.Tables[0];
		}

		/// <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.labe_ID = new System.Windows.Forms.Label();
			this.std_ID = new System.Windows.Forms.TextBox();
			this.label2 = new System.Windows.Forms.Label();
			this.label3 = new System.Windows.Forms.Label();
			this.PSD_O = new System.Windows.Forms.TextBox();
			this.PSD_N = new System.Windows.Forms.TextBox();
			this.btnOK = new System.Windows.Forms.Button();
			this.btnCancel = new System.Windows.Forms.Button();
			this.Lab_Name = new System.Windows.Forms.Label();
			this.Name_New = new System.Windows.Forms.TextBox();
			this.label4 = new System.Windows.Forms.Label();
			this.SEX_NEW = new System.Windows.Forms.TextBox();
			this.SuspendLayout();
			// 
			// labe_ID
			// 
			this.labe_ID.Location = new System.Drawing.Point(32, 24);
			this.labe_ID.Name = "labe_ID";
			this.labe_ID.Size = new System.Drawing.Size(40, 16);
			this.labe_ID.TabIndex = 0;
			this.labe_ID.Text = "学号";
			// 
			// std_ID
			// 
			this.std_ID.Location = new System.Drawing.Point(80, 16);
			this.std_ID.Name = "std_ID";
			this.std_ID.Size = new System.Drawing.Size(88, 21);
			this.std_ID.TabIndex = 1;
			this.std_ID.Text = "";
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(32, 136);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(32, 16);
			this.label2.TabIndex = 2;
			this.label2.Text = "密码";
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(8, 168);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(56, 24);
			this.label3.TabIndex = 3;
			this.label3.Text = "密码确认";
			// 
			// PSD_O
			// 
			this.PSD_O.Location = new System.Drawing.Point(80, 128);
			this.PSD_O.Name = "PSD_O";
			this.PSD_O.PasswordChar = '*';
			this.PSD_O.Size = new System.Drawing.Size(88, 21);
			this.PSD_O.TabIndex = 4;
			this.PSD_O.Text = "";
			// 
			// PSD_N
			// 
			this.PSD_N.Location = new System.Drawing.Point(80, 168);
			this.PSD_N.Name = "PSD_N";
			this.PSD_N.PasswordChar = '*';
			this.PSD_N.Size = new System.Drawing.Size(88, 21);
			this.PSD_N.TabIndex = 5;
			this.PSD_N.Text = "";
			// 
			// btnOK
			// 
			this.btnOK.Location = new System.Drawing.Point(24, 208);
			this.btnOK.Name = "btnOK";
			this.btnOK.Size = new System.Drawing.Size(56, 24);
			this.btnOK.TabIndex = 6;
			this.btnOK.Text = "确定";
			this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
			// 
			// btnCancel
			// 
			this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.btnCancel.Location = new System.Drawing.Point(96, 208);
			this.btnCancel.Name = "btnCancel";
			this.btnCancel.Size = new System.Drawing.Size(64, 24);
			this.btnCancel.TabIndex = 7;
			this.btnCancel.Text = "取消";
			this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
			// 
			// Lab_Name
			// 
			this.Lab_Name.Location = new System.Drawing.Point(32, 56);
			this.Lab_Name.Name = "Lab_Name";
			this.Lab_Name.Size = new System.Drawing.Size(32, 24);
			this.Lab_Name.TabIndex = 8;
			this.Lab_Name.Text = "姓名";
			// 
			// Name_New
			// 
			this.Name_New.Location = new System.Drawing.Point(80, 48);
			this.Name_New.Name = "Name_New";
			this.Name_New.Size = new System.Drawing.Size(88, 21);
			this.Name_New.TabIndex = 9;
			this.Name_New.Text = "";
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(32, 96);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(32, 16);
			this.label4.TabIndex = 10;
			this.label4.Text = "性别";
			// 
			// SEX_NEW
			// 
			this.SEX_NEW.Location = new System.Drawing.Point(80, 88);
			this.SEX_NEW.Name = "SEX_NEW";
			this.SEX_NEW.Size = new System.Drawing.Size(88, 21);
			this.SEX_NEW.TabIndex = 11;
			this.SEX_NEW.Text = "";
			// 
			// Regist
			// 
			this.AcceptButton = this.btnOK;
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.CancelButton = this.btnCancel;
			this.ClientSize = new System.Drawing.Size(216, 262);
			this.Controls.Add(this.SEX_NEW);
			this.Controls.Add(this.label4);
			this.Controls.Add(this.Name_New);
			this.Controls.Add(this.Lab_Name);
			this.Controls.Add(this.btnCancel);
			this.Controls.Add(this.btnOK);
			this.Controls.Add(this.PSD_N);
			this.Controls.Add(this.PSD_O);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.std_ID);
			this.Controls.Add(this.labe_ID);
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "Regist";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "注册向导";
			this.ResumeLayout(false);

		}
		#endregion
		//-------------单击确定开始注册------------
		private void btnOK_Click(object sender, System.EventArgs e)
		{

			//for (int i=0;i<myTable1.Columns.Count;i++)
			//{
			
				//this.myRow1 = myTable1.Rows[i];
				//只有当输入的学号与学生信息表上的学号相对应注册才能成功
				//if (myRow1[0].ToString().Trim()==this.std_ID.Text.ToString().Trim())
				//{
						//if(PSD_O.Text.Trim()==PSD_N.Text.Trim())
						//{
	
						/*		
								SqlConnection cn= new SqlConnection("workstation id=localhost;Integrated Security=SSPI;database=eisbook");								string sql="insert into 用户权限表 values('"+std_ID.Text.Trim()+"',学生,'"+Name_New.Text.Trim()+"','"+SEX_NEW.Text.Trim()+"','"+PSD_O.Text.Trim()+"')";
								SqlCommand cmd= new SqlCommand(sql, cn);
							
								cmd.Connection.Open();

							
								cmd.ExecuteNonQuery();
						
							*/
						//}
				//MessageBox.Show( "两次输入的密码不一致!");
				//}
			//}
			
			//MessageBox.Show( "       注册成功!      ");
			//return;
		}
		//--------退出---------
		private void btnCancel_Click(object sender,System.EventArgs e){
			this.Close();
		}
	}
}

⌨️ 快捷键说明

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