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

📄 registe.aspx.cs

📁 自己写的一个网上图书馆 可实现图书上传借阅等功能
💻 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 e_librarys
{
	/// <summary>
	/// Register 的摘要说明。
	/// </summary>
	public partial class Register : System.Web.UI.Page
	{
	
		protected void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面

            //绑定年月日
            //ArrayList AllYear=new ArrayList();
            //ArrayList AllMonth=new ArrayList();
            //ArrayList AllDay=new ArrayList();
            //for(int Y=1900;Y<=2008;Y++)
            //    AllYear.Add(Y.ToString());
            //for(int M=1;M<=12;M++)
            //    AllMonth.Add(M.ToString());
            //for(int D=1;D<=31;D++)
            //    AllDay.Add(D.ToString());
            //DropDown_Year.DataSource=AllYear;
            //DropDown_Year.DataBind();
            //DropDown_Month.DataSource=AllMonth;
            //DropDown_Month.DataBind();
            //DropDown_Day.DataSource=AllDay;
            //DropDown_Day.DataBind();



		}

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

		}
		#endregion

		protected void Button_Check_Click(object sender, System.EventArgs e)
		{
			string StrConn="server=(local);database=e_library;uid=sa;pwd=;";
			SqlConnection Conn=new SqlConnection(StrConn);
			Conn.Open();
			string StrSql="select * from User_Info where U_Name='"+TextBox_Name.Text+"'";
			SqlCommand Comm=new SqlCommand(StrSql,Conn);
			SqlDataReader Dr=Comm.ExecuteReader();
			if(Dr.Read())
			{
				Label_Hint.Text="该用户名已存在";
			}
			else
			{
				Label_Hint.Text="该用户名可用";
			}
			Conn.Close();
		}

		protected void Submit_Click(object sender, System.EventArgs e)
		{
			//页面验证成功时执行
			if(Page.IsValid)
			{
				string StrConn="server=(local);database=e_library;uid=sa;pwd=";
				SqlConnection Conn=new SqlConnection(StrConn);
				Conn.Open();
				string StrSql="insert into User_Info(U_Name,U_Pswd,U_Email,U_Telephone,U_Dirthday,U_QQ,U_Sex) values('";
				StrSql+=TextBox_Name.Text.ToString()+"','";StrSql+=TextBox_Pswd.Text.ToString()+"','";
				StrSql+=TextBox_Email.Text.ToString()+"','"; StrSql+=TextBox_Telephone.Text.ToString()+"','";
				StrSql+=DropDown_Year.SelectedItem.Text.ToString()+"-"+DropDown_Month.SelectedItem.Text.ToString()+"-"+DropDown_Day.SelectedItem.Text.ToString()+"','";
				StrSql+=TextBox_QQ.Text.ToString()+"','"; StrSql+=RadioButtonList_Sex.SelectedItem.Text.ToString()+"')";
				SqlCommand Comm=new SqlCommand(StrSql,Conn);
				Comm.ExecuteNonQuery();
				Conn.Close();
				Response.Write("<script language='javascript'>alert('注册成功,返回登陆框')</script>");
			
			}
		}

		
//		private void DropDown_Year_SelectedIndexChanged(object sender, System.EventArgs e)
//		{
//			int [] number={31,28,31,30,31,30,31,31,30,31,30,31};
//			int Leap=Convert.ToInt32(DropDown_Year.SelectedItem.Text.ToString());
//			if(Leap%4==0&&Leap%100!=0||Leap%400==0)
//				number[1]=29;
//			ArrayList AllDay=new ArrayList();
//			for(int D=1;D<=number[Convert.ToInt32(DropDown_Month.SelectedItem.Text.ToString())];D++)
//				AllDay.Add(D.ToString());
//			DropDown_Day.DataSource=AllDay;
//			DropDown_Day.DataBind();
//		}

//		private void DropDown_Month_SelectedIndexChanged(object sender, System.EventArgs e)
//		{
//			int [] number={31,28,31,30,31,30,31,31,30,31,30,31};
//			int Leap=Convert.ToInt32(DropDown_Year.SelectedItem.Text.ToString());
//			if(Leap%4==0&&Leap%100!=0||Leap%400==0)
//				number[1]=29;
//			ArrayList AllDay=new ArrayList();
//			for(int D=1;D<=number[Convert.ToInt32(DropDown_Month.SelectedItem.Text.ToString())];D++)
//				AllDay.Add(D.ToString());
//			DropDown_Day.DataSource=AllDay;
//			DropDown_Day.DataBind();
//		}

		
	}
}

⌨️ 快捷键说明

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