protected void btn_Submit_Click(object sender, EventArgs e) { string password = Utils.MD5Encrypt32(Utils.MD5Encrypt32(Utils.MD5Encrypt32(txtpassword.Text))); AdminUser User = new AdminUser(); User.UserName = Filter.AllFilter(txtuserName.Text.Trim()); User.UserPwd = password; User.LastLoginTime = DateTime.Now; if (Id == 0) { //添加 int UserID = AdminUserBiz.AddAdminUser(User); if (UserID > 0) { AdminUserBiz.AddUserRole(string.Empty, UserID); Response.Write("<script>self.parent.tb_remove();</script>"); } else { Response.Write("<script>self.parent.tb_remove();</script>"); } } else { if (txtpassword.Text != string.Empty) { AdminUserBiz.UpdateUser(Id, password, true); } Response.Write("<script>self.parent.tb_remove();</script>"); } }
/// <summary> /// 用户登录 /// </summary> /// <param name="UserName">用户名</param> /// <param name="UserPwd">密码</param> /// <returns>登录是否成功</returns> private bool UserLogin(string UserName, string UserPwd) { AdminUserBLL UserBiz = new AdminUserBLL(); AdminUser item = UserBiz.UserLogin(UserName, UserPwd); if (item != null) { Session["AdminName"] = UserName; Session["admin_userid"] = item.Id; Session["admin_show"] = 1; Session["issystem"] = item.IsSystem; Session["Permissions"] = UserBiz.GetPermissionsByUserID(item.Id); UserBiz.UpdateUser(item.Id, Utils.GetTrueIPAddress()); //写入Cookies Utils.WriteCookie("AdminName", "FZtouch", DESEncrypt.Encrypt(UserName)); Utils.WriteCookie("AdminPwd", "FZtouch", UserPwd); return(true); } else { return(false); } }