protected void ShowData() { string id = Request["UserId"]; if (!string.IsNullOrEmpty(id)) { this.trPwd.Visible = false; UserInfoBll bll = new UserInfoBll(); UserInfo model = bll.GetModel(Convert.ToInt32(id)); if (model != null) { this.txtUserName.Text = model.UserName; //this.txtAdminPwd.Text = model.AdminPwd; string[] roleIds = model.RoleId.Split(','); for (int i = 0; i < this.chkListRole.Items.Count; i++) { for (int j = 0; j < roleIds.Length; j++) { if (chkListRole.Items[i].Value == roleIds[j]) { chkListRole.Items[i].Selected = true; } } } this.rdoList.SelectedValue = model.IsLock.ToString(); this.txtDesc.Text = model.Desc; } } }
/// <summary> /// 验证Cookie /// </summary> private void CheckCookie() { HttpCookie cookie = HttpContext.Current.Request.Cookies[Key.COOKIE_CURRENTUSER]; if (cookie == null) { ScriptHelper.AlertRedirect("您还未登录", "/login.aspx"); return; } if (string.IsNullOrWhiteSpace(cookie.Value)) { ScriptHelper.AlertRedirect("您还未登录", "/login.aspx"); return; } string UserIdStr = CryptoHelper.TripleDES_Decrypt(cookie.Value, Key.TRIPLEDES_KEY); if (!UserIdStr.IsNumber()) { ScriptHelper.AlertRedirect("您还未登录", "/login.aspx"); return; } int userid = Convert.ToInt32(UserIdStr); UserInfoBll bll = new UserInfoBll(); oyxf.Model.UserInfo ui = bll.GetModel(userid); if (ui == null) { ScriptHelper.AlertRedirect("您还未登录", "/login.aspx"); return; } HttpContext.Current.Session[Key.SESSION_CURRENTUSER] = ui; }
//保存 protected void btnSave_Click(object sender, EventArgs e) { string id = Request["UserId"]; UserInfoBll bll = new UserInfoBll(); UserInfo model = new UserInfo(); string oldAdminName = string.Empty; if (!string.IsNullOrEmpty(id))//如果是修改操作 { model = bll.GetModel(Convert.ToInt32(id)); } else //如果是新增操作 { model.UserPwd = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(this.txtUserPwd.Text.Trim(), "MD5"); } model.UserName = this.txtUserName.Text.Trim(); model.RoleId = ""; for (int i = 0; i < this.chkListRole.Items.Count; i++) { if (this.chkListRole.Items[i].Selected) { model.RoleId += this.chkListRole.Items[i].Value + ","; } } if (model.RoleId.IndexOf(',') != -1) { model.RoleId = model.RoleId.Substring(0, model.RoleId.Length - 1); } if (string.IsNullOrEmpty(model.RoleId)) { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('请选择一个角色!');</script>"); return; } model.IsLock = Convert.ToInt32(this.rdoList.SelectedValue); model.Desc = this.txtDesc.Text.Trim(); int n = 0; if (!string.IsNullOrEmpty(id))//如果是修改操作 { n = bll.Update(model, null); } else //如果是新增操作 { n = bll.Insert(model, null); } if (n > 0) { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('保存成功!');</script>"); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('保存失败!');</script>"); } }
private void BindData(int userId) { oyxf.Model.UserInfo model = bllUserInfo.GetModel(userId); txtUserId.Value = model.UserId.ToString(); txtUsername.Text = model.Username; txtPassword.Attributes["value"] = "******";//Password类型的 要用Attributes["value"]赋值 txtRealName.Text = model.RealName; txtPhone.Text = model.Phone; ddlUserType.SelectedValue = model.UserType.ToString(); rblStatus.SelectedValue = model.Status.ToString(); txtCreateDate.Value = model.CreateDate.ToString("yyyy-MM-dd HH:mm:ss:fff"); }
/// <summary> /// 返回用户简历 /// </summary> /// <param name="uid"></param> /// <returns></returns> public ActionResult UserResume(int uid = 0) { UserInfoBll bllUser = new UserInfoBll(); UserInfo model = bllUser.GetModel(uid); if (model != null) { ViewBag.WorkExp = model.WorkExperience.ToList(); ViewBag.ProjectExp = model.ProjectExperience.ToList(); } return(View(model)); }
private void LoadData() { UserInfo m = userInfobll.GetModel(this._userId); if (m != null) { txtname.Text = m.username; txtpwd1.Text = m.userpwd; txtpwd2.Text = m.userpwd; label6.Text = m.userpwd; comboBox1.SelectedIndex = Convert.ToInt32(m.qx); } }
//登陆 protected void btnLogin_Click(object sender, EventArgs e) { string uName = this.txtAdminName.Text.Trim(); string uPwd = this.txtAdminPwd.Text.Trim(); string vCode = this.txtVcode.Text.Trim().ToLower(); string code = Session["vcode"] == null ? "" : Session["vcode"].ToString().Trim().ToLower(); if (vCode == "" || vCode != code) { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('验证码错误!');</script>"); return; } UserInfoBll bll = new UserInfoBll(); UserInfo model = bll.GetModel(uName, CommonFun.GetMD5(uPwd)); if (model != null) { if (model.IsLock == 1) { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('帐户被锁定,不能登陆,请与管理员联系!');</script>"); return; } else { LoginUserInfo user = new LoginUserInfo(); user.UserId = model.UserId; user.UserName = model.UserName; user.RoleId = model.RoleId; CommonFun.UserLoginSetCookie(user.UserName, this.Page, DateTime.Now.AddMinutes(30), user); Response.Write("<script type='text/javascript'>window.location = 'Default.aspx'</script>"); } } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('用户名或密码错误!');</script>"); return; } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string username = context.Request.Form["username"]; string password = context.Request.Form["password"]; string checkcode = context.Request.Form["checkcode"].ToUpper(); string autologin = context.Request.Form["autologin"]; string checkcodeSession = context.Session[Key.CAPTCHA].ToString().ToUpper(); //1.合法性判断 //2.验证码是否正确 if (!checkcode.Equals(checkcodeSession)) { AjaxHelper.WriteError(msg: "验证码错误"); } //3.账号密码是否正确 UserInfoBll bll = new UserInfoBll(); oyxf.Model.UserInfo ui = bll.GetModel(username); if (ui == null) { AjaxHelper.WriteError(msg: "账号或密码不正确"); } if (ui.Status == 0) { AjaxHelper.WriteError(msg: "该用户已被禁用"); } //4.Session context.Session[Key.SESSION_CURRENTUSER] = ui; //5.Cookie GenerateCookie(autologin, ui); AjaxHelper.WriteSuccess(); }