public void Delete(int _chinhsachID) { Models.EmployeeManagementEntities db = new EmployeeManagementEntities(); Models.ChinhSach chinhsach = db.ChinhSaches.FirstOrDefault(x => x.CSID == _chinhsachID); db.ChinhSaches.Remove(chinhsach); db.SaveChanges(); db.Dispose(); }
public void Update(int _chinhsachID, string _noidung, DateTime _ngay) { Models.EmployeeManagementEntities db = new EmployeeManagementEntities(); Models.ChinhSach chinhsach = db.ChinhSaches.FirstOrDefault(x => x.CSID == _chinhsachID); chinhsach.CSTen = _noidung; chinhsach.CSNgay = _ngay; db.SaveChanges(); db.Dispose(); }
protected void Page_Load(object sender, EventArgs e) { if (Session["account"] != null) { Models.AccountEntity accEntity = new Models.AccountEntity(); string email = Session["account"].ToString(); Models.Account account = accEntity.FindByEmail(email); if (account == null || account.ACCChucNang > 1) { Response.Redirect("~/"); } else if (this.Page.RouteData.Values["chinhsach"] != null) { try { int chinhsachID = Convert.ToInt32(this.Page.RouteData.Values["chinhsach"]); Models.ChinhSachEntity csEntity = new Models.ChinhSachEntity(); Models.ChinhSach chinhsach = csEntity.Find(chinhsachID); if (chinhsach == null) { this.RedirectToIndex(); } } catch { this.RedirectToIndex(); } } else if (this.Page.RouteData.Values["nhanvien"] != null) { try { int nhanvienID = Convert.ToInt32(this.Page.RouteData.Values["nhanvien"]); Models.NhanVienEntity nvEntity = new Models.NhanVienEntity(); Models.NhanVien nhanvien = nvEntity.Find_NhanVien(nhanvienID); if (nhanvien == null) { this.RedirectToIndex(); } } catch { this.RedirectToIndex(); } } else { this.RedirectToIndex(); } } else { Response.Redirect("~/"); } }
protected void Page_Load(object sender, EventArgs e) { if (this.Page.RouteData.Values["chinhsach"] != null) { this.UpdateStatus(); _chinhsachID = Convert.ToInt32(this.Page.RouteData.Values["chinhsach"]); Models.ChinhSach chinhsach = _csEntity.Find(_chinhsachID); _nhanvienID = chinhsach.NVID; if (!this.Page.IsPostBack) { txtNoiDung.Text = chinhsach.CSTen; dpkNgay.SelectedDate = chinhsach.CSNgay; } } else { this.CreateStatus(); _nhanvienID = Convert.ToInt32(this.Page.RouteData.Values["nhanvien"]); } }