protected void Page_Load(object sender, EventArgs e) { if (this.Page.RouteData.Values["thunhap"] != null) { this.UpdateStatus(); _thunhapID = Convert.ToInt32(this.Page.RouteData.Values["thunhap"]); Models.ThuNhap thunhap = _tnEntity.Find(_thunhapID); _kekhaiID = thunhap.KKID; if (!this.Page.IsPostBack) { txtTen.Text = thunhap.TNTen; if (thunhap.TNTien % 1 == 0) { txtTien.Text = thunhap.TNTien.ToString("###"); } else { txtTien.Text = thunhap.TNTien.ToString(); } } } else { this.CreateStatus(); _kekhaiID = Convert.ToInt32(this.Page.RouteData.Values["kekhai"]); } }
public void Delete(int _thunhapID) { Models.EmployeeManagementEntities db = new EmployeeManagementEntities(); Models.ThuNhap thunhap = db.ThuNhaps.FirstOrDefault(x => x.TNID == _thunhapID); db.ThuNhaps.Remove(thunhap); db.SaveChanges(); db.Dispose(); }
public void Update(int _thunhapID, string _ten, decimal _tien) { Models.EmployeeManagementEntities db = new EmployeeManagementEntities(); Models.ThuNhap thunhap = db.ThuNhaps.FirstOrDefault(x => x.TNID == _thunhapID); thunhap.TNTen = _ten; thunhap.TNTien = _tien; db.SaveChanges(); db.Dispose(); }
private string ConvertTien(Models.ThuNhap _thunhap) { if (_thunhap.TNTien % 1 == 0) { return(_thunhap.TNTien.ToString("#,###")); } else { return(_thunhap.TNTien.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["thunhap"] != null) { try { int thunhapID = Convert.ToInt32(this.Page.RouteData.Values["thunhap"]); Models.ThuNhapEntity tnEntity = new Models.ThuNhapEntity(); Models.ThuNhap thunhap = tnEntity.Find(thunhapID); if (thunhap == null) { this.RedirectToIndex(); } else if (thunhap.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["thunhap"] != null) { try { int thunhapID = Convert.ToInt32(this.Page.RouteData.Values["thunhap"]); Models.ThuNhapEntity tnEntity = new Models.ThuNhapEntity(); Models.ThuNhap thunhap = tnEntity.Find(thunhapID); if (thunhap == 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(); } }