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

📄 regist.aspx.cs

📁 .net环境下开发的,很好哦,这是我门最近做的一个电子商务的作业 实现了很多功能,是典型的C2C模式,很有利用价值,大家下载了多给我提意见
💻 CS
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace secondhand
{
	/// <summary>
	/// regist 的摘要说明。
	/// </summary>
	public class regist : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.RadioButton RadioButton2;
		protected System.Web.UI.WebControls.TextBox TextBox5;
		protected System.Web.UI.WebControls.Label Label2;
		protected System.Web.UI.WebControls.TextBox TextBox1;
		protected System.Web.UI.WebControls.Label Label3;
		protected System.Web.UI.WebControls.Label Label4;
		protected System.Web.UI.WebControls.TextBox TextBox2;
		protected System.Web.UI.WebControls.TextBox TextBox3;
		protected System.Web.UI.WebControls.Label Label6;
		protected System.Web.UI.WebControls.Label Label7;
		protected System.Web.UI.WebControls.TextBox TextBox4;
		protected System.Web.UI.WebControls.Label Label8;
		protected System.Web.UI.WebControls.Label Label9;
		protected System.Web.UI.WebControls.Label Label5;
		protected System.Web.UI.WebControls.Button Button1;
		protected System.Web.UI.WebControls.Button Button2;
		protected System.Web.UI.WebControls.Label Label10;
		protected System.Web.UI.WebControls.TextBox TextBox6;
		protected System.Web.UI.WebControls.Label Label11;
		protected System.Web.UI.WebControls.RadioButton RadioButton1;
		protected System.Web.UI.WebControls.Button Button3;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
		}

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		//		/// <summary>
//		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
//		/// 此方法的内容。
//		/// </summary>
//		private void InitializeComponent()
//		{    
//			this.Load += new System.EventHandler(this.Page_Load);
//
//		}
//		#endregion
//	
//			
//	

	
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.Button1.Click += new System.EventHandler(this.Button1_Click);
			this.Button2.Click += new System.EventHandler(this.Button2_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion


		private void Button3_Click(object sender, System.EventArgs e)
		{   
			string ID=TextBox6.Text;
			string Name=TextBox1.Text;
			string pwd=TextBox2.Text;
			string adress=TextBox3.Text;
			string tel=TextBox4.Text;
			string E_mail=TextBox5.Text;
			string s;
			string ec_Data = 
				"Server=(local);"+
				"uid=sa;pwd=sa;"+
				"database=ec";
			SqlConnection conn = 
				new SqlConnection(ec_Data);
			conn.Open();
			if (ID=="")
			{
				Response.Write ("<script>alert(\"ID号不能为空!\");</script>");	
			
                
			}
			else
			{
				SqlCommand cmd1 = 
					new SqlCommand( "SELECT * FROM  userInfo WHERE userID='"+ID+"'", conn );
				SqlDataReader dr=cmd1.ExecuteReader();
				if(dr.Read()== true)
				{
					Label5.Visible=true;
					Label5.Text= "对不起,该ID号已经被注册!";
					TextBox1.Text="";
					return;
				}
			
				conn.Close();
				if(this.RadioButton1.Checked)
					s="男";
				else s="女";
				conn.Open();
				SqlCommand cmd= 
					new SqlCommand( "INSERT INTO userInfo (userID, userName,pwd,sex,address,telephoneNum,e_mail) values('" + (TextBox6.Text) + "','"+(TextBox1.Text) + "','"+(TextBox2.Text) + "','" + (TextBox3.Text) + "','"+s+"','" +(TextBox4.Text) + "','" +(TextBox5.Text) + "')", conn );
				cmd.ExecuteNonQuery();
				conn.Close();
				Response.Write ("<script>alert(\"注册成功!关闭窗口重新登陆!\");</script>");
	
				Server.Transfer("default.aspx");
			}
		}

		private void Button1_Click(object sender, System.EventArgs e)
		{
			Server.Transfer("default.aspx");
		
		}

		private void Button2_Click(object sender, System.EventArgs e)
		{
			TextBox1.Text="";
			TextBox2.Text="";
			TextBox3.Text="";
			TextBox4.Text="";
			TextBox5.Text="";
		}


	
	}
}


⌨️ 快捷键说明

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