public void Update(KHACHHANG kh) { var user = HttpContext.Current.Session[GlobalConstant.USER]; if (user != null) { NHANVIEN currentUser = (NHANVIEN)user; kh.lastupdateUser = currentUser.MaNV; } DateTime current = DateTime.Now; kh.lastupdateDate = current; using (QLXeKhachEntities context = new QLXeKhachEntities()) { context.Entry(kh).State = EntityState.Modified; context.SaveChanges(); } }
public ActionResult Edit() { string maTuyen = Request["maTuyen"]; string maTram = Request["maTram"]; string tgian = Request["tgian"]; if (maTuyen == null || maTram == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } LOTRINH lOTRINH = db.LOTRINHs.Find(Int32.Parse(maTuyen), Int32.Parse(maTram)); if (lOTRINH == null) { return(HttpNotFound()); } lOTRINH.KhoangThoiGian = Int32.Parse(tgian); db.Entry(lOTRINH).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
public void ResetPassword(string password, string confirmPassword) { if (password == confirmPassword) { var user = HttpContext.Current.Session[GlobalConstant.USER]; if (user != null) { NHANVIEN currentUser = (NHANVIEN)user; currentUser.Password = EncryptionUtil.instant(password); currentUser.TrangThaiTaiKhoan = 1; //change password using (QLXeKhachEntities context = new QLXeKhachEntities()) { try { var entity = context.NHANVIENs.Find(currentUser.MaNV); if (entity == null) { return; } context.Entry(entity).CurrentValues.SetValues(currentUser); context.SaveChanges(); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); } } } } else { throw new ArgumentException("Mật khẩu xác nhận không chính xác"); } }