/// <summary> /// 用户登录数据访问 /// </summary> /// <param name="username">用户名</param> /// <returns></returns> public DataTable checkUser(URegModel uRegModel) { DataTable dt = new DataTable(); string cmdText = "select * from userRegister where userName = @userName and userPass =@pwd "; SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@userName",uRegModel.userName ), new SqlParameter("@pwd",uRegModel.userPass) }; dt = sqlhelper.getRow(cmdText, paras, CommandType.Text); return dt; }
private string checkLogin(URegModel urM) { string msg = null; if (userBLL.login(urM)) { if (userBLL.getUReg(urM.userName)._Lock == "0") { userInfo = userBLL.getUInfo(urM.userName); Session["userInfo"] = userInfo; msg = "登录成功,正在返回登录前的页面,请稍后……"; } else { msg = "您已经成功登陆,但您的账户已经被锁定,如有疑问,请联系网站管理员!"; } } else { msg = "登录失败!用户名或者密码错误"; } return msg; }
protected void btnSetStatus_Click(object sender, EventArgs e) { this.lblSetName.Text = "状态"; for (int i = 0; i <= this.gdvUserRegister.Rows.Count - 1; i++) { HtmlInputCheckBox hicb = (HtmlInputCheckBox)this.gdvUserRegister.Rows[i].FindControl("chkId"); if (hicb.Checked == true) { string uid = ((Label)(this.gdvUserRegister.Rows[i].FindControl("lblUserName"))).Text.Trim(); um = userbll.getUReg(uid); this.lblUid.Text = um.userName; ScriptManager.RegisterStartupScript(this.upnlUserManage, this.GetType(), "", "showDiv();document.getElementById('lockSetSpan').style.display='block';", true); } } }
//注册新用户 public bool newRegister(URegModel uRegModel) { return userDAL.register(uRegModel); }
//登陆 public bool login(URegModel ur) { bool flag = false; DataTable dt = new DataTable(); dt = userDAL.checkUser(ur); if (dt.Rows.Count > 0) { if (userDAL.loginTime(ur.userName)) { flag = true; } else { flag = false; } } return flag; }
/// <summary> /// 注册新用户 /// </summary> /// <param name="uReg">注册实体参数</param> /// <returns></returns> public bool register(URegModel uReg) { bool flag = false; string cmdText = "insert into userRegister(userName,userPass,passQuestion,passAnswer,email) values(@userName,@userPass,@passQuestion,@passAnswer,@email);"; SqlParameter[] paras = new SqlParameter[] { new SqlParameter ("@userName", uReg.userName ), new SqlParameter ("@userPass",uReg.userPass ), new SqlParameter ("@passQuestion",uReg.passQuestion ), new SqlParameter ("@passAnswer",uReg.passAnswer), new SqlParameter ("@email",uReg.Email) }; int res = sqlhelper.ExecuteNonQuery(cmdText, paras, CommandType.Text); if (res > 0) { flag = true; } return flag; }
/// <summary> /// 返回注册用户信息 /// </summary> /// <param name="userName">用户名</param> /// <returns></returns> public URegModel getRegInfo(string userName) { URegModel uRegModel = new URegModel(); DataTable dt = new DataTable(); string cmdText = "select * from userRegister where userName = @userName"; SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@userName",userName), }; dt = sqlhelper.getRow(cmdText, paras, CommandType.Text); uRegModel.Id = dt.Rows[0]["id"].ToString(); uRegModel.userName = dt.Rows[0]["userName"].ToString(); uRegModel.userPass = dt.Rows[0]["userPass"].ToString(); uRegModel.passQuestion = dt.Rows[0]["passQuestion"].ToString(); uRegModel.passAnswer = dt.Rows[0]["passAnswer"].ToString(); uRegModel.Email = dt.Rows[0]["email"].ToString(); uRegModel._Lock = dt.Rows[0]["lock"].ToString(); uRegModel.lockCause = dt.Rows[0]["lockCause"].ToString(); uRegModel.Privilege = dt.Rows[0]["privilege"].ToString(); uRegModel.registerDate = dt.Rows[0]["registerDate"].ToString(); uRegModel.updateTime = dt.Rows[0]["updateTime"].ToString(); return uRegModel; }