public static void Update(int id, string username, string password) { string sql = @"update Users set Password=@Password where Id=@id"; SqlParam p = new SqlParam(); p.AddParam("@id", id, SqlDbType.Int, 0); p.AddParam("@Password", St.GetMd5(username + password), SqlDbType.VarChar, 100); ProjectDB.SqlExecute(sql, p); UnicornCache.Remove(CacheKey.User); }
public static void Add(string username, string realname, int userrole, DateTime leavetime, int bugzillaid) { string sql = @" if exists(select Id from Users where UserName=@UserName) update Users set RealName=@RealName,RoleType=@RoleType,LeaveTime=@LeaveTime,bugzillaid=@bugzillaid where UserName=@UserName else insert into Users(UserName,Password,RealName,RoleType,Status,LeaveTime,bugzillaid) values(@UserName,@Password,@RealName,@RoleType,1,@LeaveTime,@bugzillaid)" ; SqlParam p = new SqlParam(); p.AddParam("@UserName", username, SqlDbType.VarChar, 100); p.AddParam("@RealName", realname, SqlDbType.VarChar, 500); p.AddParam("@RoleType", userrole, SqlDbType.Int, 0); p.AddParam("@Password", St.GetMd5(username + "123456"), SqlDbType.VarChar, 100); p.AddParam("@LeaveTime", leavetime, SqlDbType.DateTime, 0); p.AddParam("@bugzillaid", bugzillaid, SqlDbType.Int, 0); ProjectDB.SqlExecute(sql, p); UnicornCache.Remove(CacheKey.User); }
protected void btnLogin_Click(object sender, EventArgs e) { string username = UserName.Value.Trim(); string password = Password.Value; Model.User u = DAL.UserRule.Get(username); if (u.Password == St.GetMd5(username + password) && u.Status == 1) { Session["user"] = u; St.SetCookie("user", u.UserName, DateTime.Now.AddYears(1)); St.SetCookie("user2", u.Password, DateTime.Now.AddYears(1)); Response.Redirect("Default.aspx"); } else { divError.Visible = true; } }