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

📄 class_register.aspx.cs

📁 利用远程控制进行上课
💻 CS
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;


namespace free
{
	/// <summary>
	/// Summary description for class_register.
	/// </summary>
	public class class_register : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Button Button1;
		protected System.Web.UI.WebControls.Button Button2;
		protected System.Web.UI.WebControls.TextBox stu_name;
		protected System.Web.UI.WebControls.RadioButtonList stu_sex;
		protected System.Web.UI.WebControls.TextBox stu_phone;
		protected System.Web.UI.WebControls.TextBox stu_idcard;
		protected System.Web.UI.WebControls.TextBox stu_qq;
		protected System.Web.UI.WebControls.DropDownList stu_city;
		protected System.Web.UI.WebControls.TextBox stu_address;
		protected System.Web.UI.WebControls.Button tijiao;
		protected System.Web.UI.WebControls.Button chongtian;
		protected System.Web.UI.WebControls.TextBox stu_email;
		protected System.Web.UI.WebControls.TextBox stu_password;
		protected System.Web.UI.WebControls.TextBox stu_repassword;
		protected System.Web.UI.WebControls.Label wrong;
		SqlConnection mycon;
		protected System.Web.UI.WebControls.DropDownList stu_nian;
		protected System.Web.UI.WebControls.DropDownList stu_yue;
		protected System.Web.UI.WebControls.DropDownList stu_ri;
		protected System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator2;
		protected System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator4;
		protected System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator1;
		SqlCommand mycomm_1;
		

	
		private void Page_Load(object sender, System.EventArgs e)
		{
			// Put user code to initialize the page here
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    
			this.stu_phone.TextChanged += new System.EventHandler(this.stu_phone_TextChanged);
			this.tijiao.Click += new System.EventHandler(this.tijiao_Click);
			this.chongtian.Click += new System.EventHandler(this.Button4_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		

		private void tijiao_Click(object sender, System.EventArgs e)
		{
			if(stu_name.Text.Trim()==null||stu_address.Text.Trim()==null)
			{
				wrong.Text="用户名或联系地址不能为空!";
			}
			else
			{
				mycon=new SqlConnection(Session["str_connection"].ToString());
				mycon.Open();
				SqlDataReader mydr;
				string sqlstr="select * from class_student_information where stu_name='"+stu_name.Text+"'";
				mycomm_1=new SqlCommand(sqlstr,mycon);
				mydr=mycomm_1.ExecuteReader();
				if (mydr.Read())
				{
					wrong.Text="该用户已经存在,请重新输入!";
					
				
					mycon.Close();
					mydr.Close();
					return ;
				}
				else if (stu_password.Text!=stu_repassword.Text)
				{
					
					wrong.Text="两次输入密码不一致,请重新输入!";
					return ;
				}
				else if(Page.IsValid)
				{
					mydr.Close();
					sqlstr="Insert into class_student_information(stu_name,stu_password,stu_email,stu_city,stu_sex,stu_phone,stu_qq,stu_address,stu_birthday,stu_idcard) values('"+stu_name.Text+"','"+stu_password.Text+"','"+stu_email.Text +"','"+stu_city.SelectedValue +"','"+stu_sex.SelectedValue +"','"+stu_phone.Text +"','"+stu_address.Text+"','"+stu_qq.Text +"','"+stu_nian.SelectedValue+stu_yue.SelectedValue +stu_ri.SelectedValue+"','"+stu_idcard.Text+"')";
					mycomm_1=new SqlCommand(sqlstr,mycon);
					if(mycomm_1.ExecuteNonQuery()>0)	
					{
						//					MailMessage mail=new MailMessage();
						//					mail.To=t_email.Text;
						//					mail.From="huaruan2004@126.com";
						//					mail.Subject="海纳会员注册成功";
						//					mail.Body="欢迎您成为海纳的一分子,请您记住您的资料:用户名:"+t_yonghuming.Text+",密码:"+t_mima.Text+".希望您能多提宝贵的意见!";
						//					SmtpMail.Send(mail);
						//Response.Redirect("success.aspx");
					    
						mycon.Close();
						Response.Cookies["free_xueyuan"].Value =stu_name.Text.Trim().ToString();
						Response.Redirect("class_zhucetishi.aspx");
					}
					else
					{
						wrong.Text="输入有误,请重试!";
					
					}
					mycon.Close();

				}
				
			}
			
				
		}

		private void Button4_Click(object sender, System.EventArgs e)
		{
			stu_sex.SelectedIndex=-1;
			stu_name.Text="";
			stu_idcard.Text="";
			stu_qq.Text="";
			stu_email.Text="";
			stu_city.SelectedIndex=-1;
			stu_phone.Text="";
			stu_address.Text="";
			stu_nian.SelectedIndex=-1;
			stu_yue.SelectedIndex=-1;
			stu_ri.SelectedIndex=-1;
			wrong.Text="";
		}

		private void stu_phone_TextChanged(object sender, System.EventArgs e)
		{
		
		}

		

		
		
	}
}

⌨️ 快捷键说明

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