protected void Button1_Click(object sender, EventArgs e) { if (TextBox1.Text == "") { Response.Write("<script>alert('账号不能为空')</script>"); } else { if (TextBox2.Text == "") { Response.Write("<script>alert('密码不能为空')</script>"); } } //string role = this.DropDownList1.SelectedValue; try { if (this.DropDownList1.SelectedValue == "用户") { UsersModel model = new UsersModel(); model.userID = TextBox1.Text; UsersBLL bll = new UsersBLL(); DataTable dt = bll.GetUsersInfoById(model); //SqlDataReader sda = cmd.ExecuteReader(); if (dt.Columns["usersPwd"].ToString() == TextBox2.Text) { Rent.CommDB.ID = TextBox1.Text; Rent.Users.userID = Rent.CommDB.ID; Response.Write("<script>alert('成功登录')</script>"); Response.Redirect("houseInfo.aspx");//跳转到主页面 } else { Response.Write("<script>alert('账号,密码输入错误或请先注册新用户!!!')</script>"); } } if (this.DropDownList1.SelectedValue == "房东") { OwnersModel model = new OwnersModel(); model.ownerID = TextBox1.Text; OwnersBLL bll = new OwnersBLL(); DataTable dt = bll.GetUsersInfoById(model); if (dt.Columns["ownerPwd"].ToString() == TextBox2.Text) { Response.Write("<script>alert('成功登录')</script>"); Owner.ownerID = TextBox1.Text; //获取ownerPhone的值 Owner.ownerPhone = dt.Columns["ownerPhone"].ToString(); Response.Redirect("houseInfo.aspx");//跳转到房东信息页面 } else { Response.Write("<script>alert('账号,密码输入错误或请先注册新用户!!!')</script>"); } } if (this.DropDownList1.SelectedValue == "经纪人") { AgentsModel model = new AgentsModel(); model.agentID = TextBox1.Text; AgentsBLL bll = new AgentsBLL(); DataTable dt = bll.GetAgentsInfoById(model); if (dt.Columns["agentPwd"].ToString() == TextBox2.Text) { Agent.agentID = TextBox1.Text; //获取agentTel的值 Agent.agentTel = dt.Columns["agentTel"].ToString(); Response.Write("<script>alert('成功登录')</script>"); Response.Redirect("houseInfo.aspx");//跳转到经纪人信息页面 } else { Response.Write("<script>alert('账号,密码输入错误或请先注册新用户!!!')</script>"); } } if (this.DropDownList1.SelectedValue == "管理员") { AdminsModel model = new AdminsModel(); model.adminID = TextBox1.Text; AdminsBLL bll = new AdminsBLL(); DataTable dt = bll.GetAdminsInfoById(model); if (dt.Columns["adminPwd"].ToString() == TextBox2.Text) { Admin.adminID = TextBox1.Text; Response.Write("<script>alert('成功登录')</script>"); Response.Redirect("adminEditInfo.aspx");//跳转到管理员信息页面 } else { Response.Write("<script>alert('账号,密码输入错误或请先注册新用户!!!')</script>"); } } } catch { Response.Write("<script>alert('账号,密码输入错误或身份选择错误')</script>"); } }
protected void Button1_Click1(object sender, EventArgs e) { if (TextBox1.Text == "" || TextBox2.Text == "" || TextBox3.Text == "") { Response.Write("<script>alert('请先填写账号密码及验证码')</script>"); } else { //判断验证码是否正确 if (TextBox2.Text == Label1.Text) { /*租户*/ if (this.DropDownList1.SelectedValue == "user") { UsersModel model = new UsersModel(); model.userID = TextBox1.Text; //先判断ID号是否存在 UsersBLL bll = new UsersBLL(); DataTable dt = bll.GetUsersInfoById(model); if (dt.Rows.Count != 0) { Response.Write("<script>alert('账号已存在')</script>"); } else { //再ID号不重复的情况下 对姓名和电话号码进行判断 if (TextBox4.Text == model.userName && TextBox5.Text == model.userPhone) { Response.Write("<script>alert('所填姓名与电话已存在,请重新填写')</script>"); } else { UsersModel mode1 = new UsersModel(); model.userID = TextBox1.Text; model.userPwd = TextBox3.Text; model.userName = TextBox4.Text; model.userPhone = TextBox5.Text; model.UserAge = int.Parse(TextBox6.Text); UsersBLL bll1 = new UsersBLL(); int affectRows = bll1.InsertUsersInfo(mode1); Response.Write("<script>alert('手机号已自动注册,请登录')</script>"); Response.Redirect("Login-ap.aspx"); } } } /*房东*/ if (this.DropDownList1.SelectedValue == "owner") { OwnersModel model = new OwnersModel(); model.ownerID = TextBox1.Text; //先判断ID号是否存在 OwnersBLL bll = new OwnersBLL(); DataTable dt = bll.GetUsersInfoById(model); if (dt.Rows.Count != 0) { Response.Write("<script>alert('账号已存在')</script>"); } else { if (TextBox4.Text == model.ownerName && TextBox5.Text == model.ownerPhone) { Response.Write("<script>alert('所填姓名与电话已存在,请重新填写')</script>"); } else { OwnersModel mode1 = new OwnersModel(); model.ownerID = TextBox1.Text; model.ownerPwd = TextBox3.Text; model.ownerName = TextBox4.Text; model.ownerImage = "https://image.5i5j.com/picture/8108815.jpg"; model.ownerAge = int.Parse(TextBox6.Text); OwnersBLL bll1 = new OwnersBLL(); int affectRows = bll1.InsertOwnersInfo(mode1); Response.Write("<script>alert('手机号已自动注册,请登录')</script>"); Response.Redirect("Login-ap.aspx"); } } } /*经济人*/ if (this.DropDownList1.SelectedValue == "agent") { AgentsModel model = new AgentsModel(); model.agentID = TextBox1.Text; //先判断ID号是否存在 AgentsBLL bll = new AgentsBLL(); DataTable dt = bll.GetAgentsInfoById(model); if (dt.Rows.Count != 0) { Response.Write("<script>alert('账号已存在')</script>"); } else { if (TextBox4.Text == model.agentName && TextBox5.Text == model.agentTel) { Response.Write("<script>alert('所填姓名与电话已存在,请重新填写')</script>"); } else { AgentsModel mode1 = new AgentsModel(); model.agentID = TextBox1.Text; model.agentPwd = TextBox3.Text; model.agentTel = TextBox5.Text; model.agentName = TextBox4.Text; model.agentAge = int.Parse(TextBox6.Text); AgentsBLL bll1 = new AgentsBLL(); int affectRows = bll1.InsertAentsInfo(mode1); Response.Write("<script>alert('手机号已自动注册,请登录')</script>"); Response.Redirect("Login-ap.aspx"); } } } /*管理人*/ if (this.DropDownList1.SelectedValue == "admin") { AdminsModel model = new AdminsModel(); model.adminID = TextBox1.Text; //先判断ID号是否存在 AdminsBLL bll = new AdminsBLL(); DataTable dt = bll.GetAdminsInfoById(model); if (dt.Rows.Count != 0) { Response.Write("<script>alert('账号已存在')</script>"); } else { if (TextBox4.Text == model.adminName && TextBox5.Text == model.adminTel) { Response.Write("<script>alert('所填姓名与电话已存在,请重新填写')</script>"); } else { AdminsModel mode1 = new AdminsModel(); model.adminID = TextBox1.Text; model.adminPwd = TextBox3.Text; model.adminName = TextBox4.Text; model.adminTel = TextBox5.Text; model.adminAge = int.Parse(TextBox6.Text); AdminsBLL bll1 = new AdminsBLL(); int affectRows = bll1.InsertAdminsInfo(mode1); Response.Write("<script>alert('手机号已自动注册,请登录')</script>"); Response.Redirect("Login-ap.aspx"); } } } } else { Response.Write("<script>alert('验证码错误')</script>"); } } }