public ActionResult Login(FormCollection form) { if (string.IsNullOrEmpty(form["userName"]) || string.IsNullOrEmpty(form["passWord"])) { State = 0; Message = "用户名和密码不能为空"; return JsonMessage(); } Users us = new Users(); us.LoginCode = form["userName"]; us.PassWord = Uitls.Encrypt(form["passWord"]); IQueryable<Users> uList = UsersBLL.GetEntityList(u => u.LoginCode == us.LoginCode && u.PassWord == us.PassWord); if (uList.Count() <= 0) { State = 0; Message = "用户名或密码错误,请重新输入!"; return JsonMessage(); } Users user = uList.Single(); //设置Cookies HttpCookie cookie = new HttpCookie("ul", user.LoginCode); HttpCookie utCookie = new HttpCookie("ut", ((int)us.UserType).ToString()); Response.Cookies.Add(cookie); Request.Cookies.Add(utCookie); //记录最后一次登录时间 user.LastLoginTime = DateTime.Now; UsersBLL.EditEntity(user); return Redirect(Url.Action("", "Index")); }
public static int UserUpdate(Model.Users userInfo) { if (userInfo.Password == null) { SqlParameter[] pars = new SqlParameter[] { new SqlParameter("@ID", SqlDbType.Int), new SqlParameter("@UserID", SqlDbType.VarChar, 50), new SqlParameter("@Email", SqlDbType.VarChar, 50), new SqlParameter("@UserName", SqlDbType.VarChar, 30), new SqlParameter("@Telephone", SqlDbType.VarChar, 50), new SqlParameter("@QQ", SqlDbType.VarChar, 30), new SqlParameter("@OID", SqlDbType.VarChar, 50) }; pars[0].Value = userInfo.ID; pars[1].Value = userInfo.UserID; pars[2].Value = userInfo.Email; pars[3].Value = userInfo.UserName; pars[4].Value = userInfo.Telephone; pars[5].Value = userInfo.QQ; pars[6].Value = userInfo.OID; return(SqlHelper.ExecuteProcess("pro_User_NoPasswordUpdate", pars)); } else { SqlParameter[] pars = new SqlParameter[] { new SqlParameter("@ID", SqlDbType.Int), new SqlParameter("@UserID", SqlDbType.VarChar, 50), new SqlParameter("@Email", SqlDbType.VarChar, 50), new SqlParameter("@Password", SqlDbType.VarChar, 50), new SqlParameter("@UserName", SqlDbType.VarChar, 30), new SqlParameter("@Telephone", SqlDbType.VarChar, 50), new SqlParameter("@QQ", SqlDbType.VarChar, 30), new SqlParameter("@OID", SqlDbType.VarChar, 50) }; pars[0].Value = userInfo.ID; pars[1].Value = userInfo.UserID; pars[2].Value = userInfo.Email; pars[3].Value = userInfo.Password; pars[4].Value = userInfo.UserName; pars[5].Value = userInfo.Telephone; pars[6].Value = userInfo.QQ; pars[7].Value = userInfo.OID; return(SqlHelper.ExecuteProcess("pro_User_Update", pars)); } }
protected void btnSubmit_Click(object sender, EventArgs e) { Model.Users u = new Model.Users { Users_Account = this.txtEmail.Text, Users_Password = MD5Helper.Md5(this.txtPassword.Text), Users_NickName = this.txtNickName.Text, Users_Photo = upFileName(this.FileUpload1, "../../upload/users/"), Users_RolesId = Guid.Parse(this.ddlRolesId.SelectedValue) }; var res = usersSvc.Add(u); ReturnMsg rm = res > 0 ? new ReturnMsg() { Code = StatusCode.OK, Message = "新增用户信息成功", Data = null } : new ReturnMsg() { Code = StatusCode.Error, Message = "新增用户信息失败", Data = null }; Session["Msg"] = rm; //用于传递执行信息的 Response.Redirect("Users_List.aspx"); }
/// <summary> /// 修改密码 /// </summary> /// <param name="oldpwd"></param> /// <param name="newpwd"></param> /// <param name="confirmpwd"></param> /// <returns></returns> public string ResetPwd(string oldpwd, string newpwd, string confirmpwd) { Model.Users session = Utils.GetSession(); string SessionName = session.U_LoginName;//取得当前登陆系统的登录名 string SelLoginName = @"select Upwd from Users where LoginName='" + SessionName + "'"; Dictionary <string, object> dic = Common.CommonClass.Select(SelLoginName); string upwd = dic["Upwd"].ToString();//取出当前登录密码 //判断用户输入的旧密码与数据库中密码是否一致 if (upwd == oldpwd) { if (newpwd != confirmpwd) { return(Utils.GetResult(300, "两次密码输入不一致")); } else { string Setpwd = "UPDATE [Users] SET [Upwd] ='" + newpwd + "' WHERE LoginName='" + SessionName + "'"; int count = Common.CommonClass.ExecutionSQL(Setpwd); if (count > 0) { return(Utils.GetResult(200, "修改成功", "true")); } else { return(Utils.GetResult(300, "修改失败")); } } } else { return(Utils.GetResult(300, "旧密码输入错误")); } }
protected void Page_Load(object sender, EventArgs e) { data = (Model.Users)Session["LoginOk"]; if (data == null || data.User_RolesId == Guid.Empty) { Response.Write("<script>alert('登录超时!');location.href='../Login.aspx';</script>"); } Bind(); }
public int AddUsers(Model.Users users) { int id = -1; //string //int count = DalBase.SelectsByWhere<Model.Users>(); if (DalBase.Insert(users) > 0) { id = Convert.ToInt32(DalBase.GetMax <Model.Users>()); } return(id); }
/// <summary> /// 加载个人资料 /// </summary> /// <returns></returns> public Dictionary <string, object> MyProfile() { Model.Users session = Utils.GetSession(); string SessionName = session.U_LoginName;//取得当前登陆系统的登录名 string SelLoginName = @"select u.UId,UserName,LoginName,UDepartId,UCreateTime,UNote,Upwd,UPhone,UEmail,Department from Users u inner join DepartMent d on u.UDepartId=d.DepartId where LoginName='" + SessionName + "'"; Dictionary <string, object> dicc = Common.CommonClass.Select(SelLoginName); string date = Convert.ToDateTime(dicc["UCreateTime"].ToString()).ToString("yyyy-MM-dd"); Dictionary <string, object> dic = new Dictionary <string, object>(); dic.Add("date", date); dic.Add("dicc", dicc); return(dic); }
protected void btnEdit_ServerClick(object sender, EventArgs e) { string s = ""; for (int j = 0; j < List_Organ.Items.Count; j++) { if (List_Organ.Items[j].Selected == true) { s += List_Organ.Items[j].Value.ToString() + ","; } } s = s.TrimEnd(','); Model.Users userInfo = new Model.Users { UserID = this.txtUserID.Value, ID = id, UserName = this.txtUserName.Value, Telephone = this.txtTelephone.Value, QQ = this.TextBox1.Value, Email = this.txtEmail.Value, OID = s }; if (this.txtPassword.Value.Trim().Length > 0) { if (this.Password1.Value != this.txtPassword.Value) { MessageBox.Show(this, "您两次输入的密码不一样,请重新输入"); return; } userInfo.Password = Security.Encrypt(this.txtPassword.Value, "12345678"); } if (((userInfo.UserID.Length == 0) || (userInfo.Email.Length == 0))) { MessageBox.Show(this, "请您填写完整的信息"); } else { if (BLL.Users.UserUpdate(userInfo) == 1) { BLL.Users.UserRoleEdit(id, this.selIsState.SelectedValue); UserOperatingManager.InputUserOperating(this.Session["admin"].ToString(), "会员管理", "编辑会员" + userInfo.UserID + "信息成功"); MessageBox.ShowAndRedirect(this, "编辑成功!", "/account/UserList.aspx"); } else { UserOperatingManager.InputUserOperating(this.Session["admin"].ToString(), "会员管理", "编辑会员" + userInfo.UserID + "信息失败"); MessageBox.Show(this, "编辑失败!"); } } }
protected void RepLeftNavi_ItemDataBound(object sender, RepeaterItemEventArgs e) { Label lbl = (Label)e.Item.FindControl("lblParentId"); Repeater rep = (Repeater)e.Item.FindControl("RepSonMenu"); object signIn = Session["LoginOk"]; if (signIn != null) { Model.Users users = (Model.Users)signIn; Guid rid = users.Users_RolesId; //得到我们要用的权限id rep.DataSource = Bind(rid, Guid.Parse(lbl.Text)); rep.DataBind(); } }
protected void btnEdit_ServerClick(object sender, EventArgs e) { string s = ""; for (int j = 0; j < List_Organ.Items.Count; j++) { if (List_Organ.Items[j].Selected == true) s += List_Organ.Items[j].Value.ToString() + ","; } s = s.TrimEnd(','); Model.Users userInfo = new Model.Users { UserID = this.txtUserID.Value, ID = id, UserName = this.txtUserName.Value, Telephone = this.txtTelephone.Value, QQ = this.TextBox1.Value, Email = this.txtEmail.Value, OID = s }; if (this.txtPassword.Value.Trim().Length > 0) { if (this.Password1.Value != this.txtPassword.Value) { MessageBox.Show(this, "您两次输入的密码不一样,请重新输入"); return; } userInfo.Password = Security.Encrypt(this.txtPassword.Value, "12345678"); } if (((userInfo.UserID.Length == 0) || (userInfo.Email.Length == 0))) { MessageBox.Show(this, "请您填写完整的信息"); } else { if (BLL.Users.UserUpdate(userInfo) == 1) { BLL.Users.UserRoleEdit(id, this.selIsState.SelectedValue); UserOperatingManager.InputUserOperating(this.Session["admin"].ToString(), "会员管理", "编辑会员" + userInfo.UserID + "信息成功"); MessageBox.ShowAndRedirect(this, "编辑成功!", "/account/UserList.aspx"); } else { UserOperatingManager.InputUserOperating(this.Session["admin"].ToString(), "会员管理", "编辑会员" + userInfo.UserID + "信息失败"); MessageBox.Show(this, "编辑失败!"); } } }
protected void RepLeftNavi_OnItemDataBound(object sender, RepeaterItemEventArgs e) { //这个是我们子级菜单绑定的位置, 因为子级菜单是在Repeater控件内部的,我们需要通过这个事件来查找到对应的控件 //(1) 存储父级菜单id的Label控件 //(2) 绑定子级菜单的Repeater控件 Label lbl = (Label)e.Item.FindControl("lblParentId"); Repeater rep = (Repeater)e.Item.FindControl("RepSonMenu"); object signIn = Session["LoginOk"]; if (signIn != null) { Model.Users users = (Model.Users)signIn; Guid rid = users.Users_RolesId; //得到我们要用的权限id rep.DataSource = Bind(rid, Guid.Parse(lbl.Text)); rep.DataBind(); } }
protected void btnAdd_ServerClick(object sender, EventArgs e) { string s = ""; for (int j = 0; j < List_Organ.Items.Count; j++) { if (List_Organ.Items[j].Selected == true) { s += List_Organ.Items[j].Value.ToString() + ","; } } s = s.TrimEnd(','); Model.Users userInfo = new Model.Users { UserID = this.txtUserID.Value.Trim(), UserName = this.txtUserName.Value.Trim(), Telephone = this.txtTelephone.Text.Trim(), QQ = this.TextBox1.Text.Trim(), Password = Security.Encrypt(this.txtPassword.Value, "12345678"), IsState = "2", Email = this.txtEmail.Value, OID = s }; if (((userInfo.UserID.Length == 0) || (userInfo.UserName.Length == 0)) || ((userInfo.QQ.Length == 0) || (userInfo.Email.Length == 0))) { MessageBox.Show(this, "请您填写完整的信息"); } else { int i = BLL.Users.UserAdd(userInfo); if (i > 0) { BLL.Users.UserRoleAdd(i.ToString(), this.selIsState.SelectedValue); UserOperatingManager.InputUserOperating(this.Session["admin"].ToString(), "会员管理", "创建会员" + userInfo.UserID + "用户名为" + userInfo.UserName + "的信息成功"); MessageBox.ShowAndRedirect(this, "创建用户成功", "/account/UserList.aspx"); } else { UserOperatingManager.InputUserOperating(this.Session["admin"].ToString(), "会员管理", "创建会员" + userInfo.UserID + "用户名为" + userInfo.UserName + "的信息失败"); MessageBox.Show(this, "创建用户失败"); } } }
protected void btnSubmit_Click(object sender, EventArgs e) { string photo = upFileName(this.FileUpload1, "../../upload/users/"); Model.Users u = usersSvc.GetUsersById(Guid.Parse(this.hfId.Value)); if (photo == "") { u.Users_Account = this.txtEmail.Text; u.Users_Password = this.txtPassword.Text; u.Users_NickName = this.txtNickName.Text; u.Users_RolesId = Guid.Parse(this.ddlRolesId.SelectedValue); u.Users_UpdateTime = DateTime.Now; } else { u.Users_Account = this.txtEmail.Text; u.Users_Password = this.txtPassword.Text; u.Users_NickName = this.txtNickName.Text; u.Users_Photo = photo; u.Users_RolesId = Guid.Parse(this.ddlRolesId.SelectedValue); u.Users_UpdateTime = DateTime.Now; } var res = usersSvc.Edit(u); ReturnMsg rm = res > 0 ? new ReturnMsg() { Code = StatusCode.OK, Message = "编辑用户信息成功", Data = null } : new ReturnMsg() { Code = StatusCode.Error, Message = "编辑用户信息失败", Data = null }; Session["Msg"] = rm; //用于传递执行信息的 Response.Redirect("Users_List.aspx"); }
protected void btnAdd_ServerClick(object sender, EventArgs e) { string s = ""; for (int j = 0; j < List_Organ.Items.Count; j++) { if (List_Organ.Items[j].Selected == true) s += List_Organ.Items[j].Value.ToString() + ","; } s = s.TrimEnd(','); Model.Users userInfo = new Model.Users { UserID = this.txtUserID.Value.Trim(), UserName = this.txtUserName.Value.Trim(), Telephone = this.txtTelephone.Text.Trim(), QQ = this.TextBox1.Text.Trim(), Password = Security.Encrypt(this.txtPassword.Value, "12345678"), IsState = "2", Email = this.txtEmail.Value, OID = s }; if (((userInfo.UserID.Length == 0) || (userInfo.UserName.Length == 0)) || ((userInfo.QQ.Length == 0) || (userInfo.Email.Length == 0))) { MessageBox.Show(this, "请您填写完整的信息"); } else { int i = BLL.Users.UserAdd(userInfo); if (i > 0) { BLL.Users.UserRoleAdd(i.ToString(), this.selIsState.SelectedValue); UserOperatingManager.InputUserOperating(this.Session["admin"].ToString(), "会员管理", "创建会员" + userInfo.UserID + "用户名为" + userInfo.UserName + "的信息成功"); MessageBox.ShowAndRedirect(this, "创建用户成功", "/account/UserList.aspx"); } else { UserOperatingManager.InputUserOperating(this.Session["admin"].ToString(), "会员管理", "创建会员" + userInfo.UserID + "用户名为" + userInfo.UserName + "的信息失败"); MessageBox.Show(this, "创建用户失败"); } } }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { return; } object ob = Session["Msg"]; if (ob != null) { var res = ob as ReturnMsg; msg = res.Message; code = (int)res.Code; Session["Msg"] = null; } #region 一级菜单绑定 //在这里我们还需要获取当前账号信息登入的权限等级 object signIn = Session["LoginOk"]; if (signIn != null) { Model.Users users = (Model.Users)signIn; Guid rid = users.Users_RolesId; //得到我们要用的权限id this.RepLeftNavi.DataSource = Bind(rid, Guid.Empty); this.RepLeftNavi.DataBind(); this.lblNickName.Text = users.Users_NickName; this.Image1.ImageUrl = "../../upload/users/" + users.Users_Photo; } else { // Response.Write("<script>alert('登入超时,请重新登入');location.href='../Login.aspx'</script>"); Console.WriteLine("请重新登陆"); } #endregion }
public int EditUser(Model.Users model, int roleId) { return(dal.EditUser(model, roleId)); }
public int UpdUser(Model.Users users) { return(DalBase.Updata(users)); }
/// <summary> /// 增加一条数据 /// </summary> public int AddNewUser(Model.Users model, int roleId) { return(dal.AddNewUser(model, roleId)); }
/// <summary> /// 修改密码 /// </summary> public bool ModifyPwd(Model.Users model) { return(dal.ModifyPwd(model)); }
/// <summary> /// Inserts the user to database. /// </summary> /// <param name="userDto">The user dto.</param> public void InsertUsers(UserDto userDto) { Users user=new Users(); MapDtoToEntity(userDto, user); this.ObjectContext.AddToUsers(user); }
/// <summary> /// Maps the dto to entity. /// </summary> /// <param name="userDto">The user dto.</param> /// <param name="userEntity">The user entity.</param> private void MapDtoToEntity(UserDto userDto, Users userEntity) { userEntity.UserName = userDto.UserName; if (userEntity.UserProfile==null) userEntity.UserProfile = new UserProfile(); userEntity.UserProfile.FirstName = userDto.FirstName; userEntity.UserProfile.Email = userDto.Email; userEntity.UserProfile.LastName = userDto.LastName; userEntity.UserProfile.BirthNumber = userDto.BirthNumber; userEntity.UserProfile.ProfessionId = userDto.ProfessionId; }
public static int UserAdd(Model.Users userInfo) { return(DAL.Users.UserAdd(userInfo)); }
public ActionResult Register(Users model) { if (ModelState.IsValid) { } else { ModelState.AddModelError("error", "提交的不是有效的数据"); } return View(model); }
public static int UserUpdate(Model.Users userInfo) { return(DAL.Users.UserUpdate(userInfo)); }