using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient; public partial class UserStReg : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["UserId"] == null) { } else { Response.Redirect("ModifyMyInfo.aspx"); } } this.Title = " 服装销售网站"; } protected void Button1_Click(object sender, EventArgs e) { //业务逻辑层 BLL.UsersBusiness busi = new BLL.UsersBusiness(); DataSet ds = new DataSet(); ds = busi.GetList("UserName='" + txtname.Text + "' "); if (ds != null) { if (ds.Tables[0].Rows.Count > 0) { Label1.Text = "账号已经存在"; return; } } //实例化对象 DataSet dss = new DataSet(); dss = busi.GetList("emal='" + txtemal.Text + "' "); if (ds != null) { if (ds.Tables[0].Rows.Count > 0) { Label1.Text = "注册邮箱已经存在"; return; } } //实例化对象 Model.Users en = new Model.Users(); en.emal = txtemal.Text; en.UserName = txtname.Text; en.Sex = DropDownList1.SelectedItem.Text; en.Age = Age.Text; en.Ds = txtds.Text; en.pwd = TextBox1.Text ; en.XingMing = XingMing.Text ; en.SP = SP.Text ; en.Address = Address.Text; //注册会员方法,三层架构 busi.Add(en); Alert.AlertAndRedirect("注册成功!", "Default.aspx"); } }
时间: 2024-02-14 17:24:21 浏览: 32
这是一个使用ASP.NET开发的用户注册页面代码,其中包括了对输入信息的判断,以及将用户信息添加到数据库中的操作。具体可以看到代码中实例化了BLL.UsersBusiness类,该类应该是业务逻辑层,然后通过该类的方法将用户信息添加到数据库中。在页面加载时,会判断用户是否已经登录,如果已经登录则跳转到“ModifyMyInfo.aspx”页面。在单击“Button1”按钮时,会先判断用户名和邮箱是否已经存在,如果存在则提示用户,否则将用户输入信息保存到数据库中,同时弹出提示框“注册成功!”,并跳转到“Default.aspx”页面。
相关问题
using System.Collections.Generic;
using system.collections.generic; 是一个命名空间,它包含了许多泛型集合类,如List、Dictionary、Queue、Stack等等。这些集合类可以用来存储和操作不同类型的数据,提高了程序的灵活性和效率。在使用这些集合类时,需要在代码开头添加using system.collections.generic;语句,以便在程序中引用这个命名空间。
using system.collections.generic;
using system.collections.generic; 是一个命名空间,它包含了许多泛型集合类,如List、Dictionary、Queue、Stack等等。这些集合类可以用来存储和操作不同类型的数据,提高了程序的灵活性和效率。在使用这些集合类时,需要在代码开头添加using system.collections.generic;语句,以便在程序中引用这个命名空间。