public void Delete(int _khenthuongID) { Models.EmployeeManagementEntities db = new EmployeeManagementEntities(); Models.KhenThuong khenthuong = db.KhenThuongs.FirstOrDefault(x => x.KTID == _khenthuongID); db.KhenThuongs.Remove(khenthuong); db.SaveChanges(); }
public void Update(int _khenthuongID, string _noidung, string _capquyetdinh, DateTime _ngaythang) { Models.EmployeeManagementEntities db = new EmployeeManagementEntities(); Models.KhenThuong khenthuong = db.KhenThuongs.FirstOrDefault(x => x.KTID == _khenthuongID); khenthuong.KTNoiDung = _noidung; khenthuong.KTCapQuyetDinh = _capquyetdinh; khenthuong.KTNgay = _ngaythang; 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["khenthuong"] != null) { try { int khenthuongID = Convert.ToInt32(this.Page.RouteData.Values["khenthuong"]); Models.KhenThuongEntity ktEntity = new Models.KhenThuongEntity(); Models.KhenThuong khenthuong = ktEntity.Find(khenthuongID); if (khenthuong == null) { this.RedirectIndex(); } } catch { this.RedirectIndex(); } } 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.RedirectIndex(); } } catch { this.RedirectIndex(); } } else { this.RedirectIndex(); } } else { Response.Redirect("~/"); } }
protected void Page_Load(object sender, EventArgs e) { if (this.Page.RouteData.Values["khenthuong"] != null) { this.UpdateStatus(); _khenthuongID = Convert.ToInt32(this.Page.RouteData.Values["khenthuong"]); Models.KhenThuong khenthuong = _ktEntity.Find(_khenthuongID); _nhanvienID = khenthuong.NVID; if (!this.Page.IsPostBack) { txtNoiDung.Text = khenthuong.KTNoiDung; txtCapQuyetDinh.Text = khenthuong.KTCapQuyetDinh; dpkNgay.SelectedDate = khenthuong.KTNgay; } } else { this.CreateStatus(); _nhanvienID = Convert.ToInt32(this.Page.RouteData.Values["nhanvien"]); } }