protected void Page_Load(object sender, EventArgs e) { if (this.Page.RouteData.Values["khoanno"] != null) { this.UpdateStatus(); _khoannoID = Convert.ToInt32(this.Page.RouteData.Values["khoanno"]); Models.KhoanNo khoanno = _knEntity.Find(_khoannoID); _kekhaiID = khoanno.KKID; if (!this.Page.IsPostBack) { txtTen.Text = khoanno.KNTen; txtSoLuong.Text = khoanno.KNSoLuong.ToString(); if (khoanno.KNGiaTri % 1 == 0) { txtGiaTri.Text = khoanno.KNGiaTri.ToString("###"); } else { txtGiaTri.Text = khoanno.KNGiaTri.ToString(); } } } else { this.CreateStatus(); _kekhaiID = Convert.ToInt32(this.Page.RouteData.Values["kekhai"]); } }
public void Delete(int _khoannoID) { Models.EmployeeManagementEntities db = new EmployeeManagementEntities(); Models.KhoanNo khoanno = db.KhoanNos.FirstOrDefault(x => x.KNID == _khoannoID); db.KhoanNos.Remove(khoanno); db.SaveChanges(); db.Dispose(); }
public void Update(int _khoannoID, string _ten, decimal _soluong, decimal _giatri) { Models.EmployeeManagementEntities db = new EmployeeManagementEntities(); Models.KhoanNo khoanno = db.KhoanNos.FirstOrDefault(x => x.KNID == _khoannoID); khoanno.KNTen = _ten; khoanno.KNSoLuong = _soluong; khoanno.KNGiaTri = _giatri; db.SaveChanges(); db.Dispose(); }
private string ConvertGiaTri(Models.KhoanNo _khoanno) { if (_khoanno.KNGiaTri % 1 == 0) { return(_khoanno.KNGiaTri.ToString("#,###")); } else { return(_khoanno.KNGiaTri.ToString("#,###.##")); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["account"] != null) { string email = Session["account"].ToString(); Models.AccountEntity accEntity = new Models.AccountEntity(); Models.Account account = accEntity.FindByEmail(email); if (account == null) { this.RedirectToIndex(); } else if (account.ACCChucNang > 1) { if (!account.ACCUpKeKhai) { this.RedirectToIndex(); } else if (this.Page.RouteData.Values["khoanno"] != null) { try { int khoannoID = Convert.ToInt32(this.Page.RouteData.Values["khoanno"]); Models.KhoanNoEntity knEntity = new Models.KhoanNoEntity(); Models.KhoanNo khoanno = knEntity.Find(khoannoID); if (khoanno == null) { this.RedirectToIndex(); } else if (khoanno.KeKhai.NVID != account.NVID) { this.RedirectToIndex(); } } catch { this.RedirectToIndex(); } } else if (this.Page.RouteData.Values["kekhai"] != null) { try { int kekhaiID = Convert.ToInt32(this.Page.RouteData.Values["kekhai"]); Models.KeKhaiEntity kkEntity = new Models.KeKhaiEntity(); Models.KeKhai kekhai = kkEntity.Find(kekhaiID); if (kekhai == null) { this.RedirectToIndex(); } else if (kekhai.NVID != account.NVID) { this.RedirectToIndex(); } } catch { this.RedirectToIndex(); } } else { this.RedirectToIndex(); } } else if (this.Page.RouteData.Values["khoanno"] != null) { try { int khoannoID = Convert.ToInt32(this.Page.RouteData.Values["khoanno"]); Models.KhoanNoEntity knEntity = new Models.KhoanNoEntity(); Models.KhoanNo khoanno = knEntity.Find(khoannoID); if (khoanno == null) { this.RedirectToIndex(); } } catch { this.RedirectToIndex(); } } else if (this.Page.RouteData.Values["kekhai"] != null) { try { int kekhaiID = Convert.ToInt32(this.Page.RouteData.Values["kekhai"]); Models.KeKhaiEntity kkEntity = new Models.KeKhaiEntity(); Models.KeKhai kekhai = kkEntity.Find(kekhaiID); if (kekhai == null) { this.RedirectToIndex(); } } catch { this.RedirectToIndex(); } } else { this.RedirectToIndex(); } } else { this.RedirectToIndex(); } }