public ActionResult Create(RevenueExpenditure revenueExpenditure)
        {
            if (ModelState.IsValid)
            {
                var dao = new RevenueExpenditureDao();

                //lấy id trong session đăng nhập của quản trị lưu vào phiên tạo mới user
                var session = (UserLogin)Session[CommonConstants.USER_SESSION];
                revenueExpenditure.CreatedBy   = session.UserName;
                revenueExpenditure.CreatedDate = DateTime.Now;

                long id = dao.Insert(revenueExpenditure);
                if (id > 0)
                {
                    SetAlert("Thêm chấm công nhân viên thành công", "success");
                    return(RedirectToAction("Index", "RevenueExpenditure"));
                }
                else
                {
                    ModelState.AddModelError("", "Thêm chấm nhân viên công không thành công");
                }
            }
            SetViewBag();
            SetTypeBag();
            SetAlert("Error", "error");
            return(RedirectToAction("Index", "RevenueExpenditure"));
        }
Пример #2
0
        public long Update(RevenueExpenditure entity, string username)
        {
            var revenueExpenditure = db.RevenueExpenditures.Find(entity.ID);

            revenueExpenditure.Contents    = entity.Contents;
            revenueExpenditure.Type_ID     = entity.Type_ID;
            revenueExpenditure.Description = entity.Description;
            revenueExpenditure.Money       = entity.Money;

            //Ngày chỉnh sửa = Now
            revenueExpenditure.ModifiedBy   = username;
            revenueExpenditure.ModifiedDate = DateTime.Now;
            db.SaveChanges();
            return(entity.ID);
        }
        public ActionResult Edit(RevenueExpenditure revenueExpenditure)
        {
            if (ModelState.IsValid)
            {
                var dao     = new RevenueExpenditureDao();
                var session = (UserLogin)Session[CommonConstants.USER_SESSION];

                long id = dao.Update(revenueExpenditure, session.UserName);
                if (id > 0)
                {
                    SetAlert("Sửa thông tin nhân viên thành công", "success");
                    return(RedirectToAction("Index", "RevenueExpenditure"));
                }
                else
                {
                    SetAlert("Tài khoản hoặc mã nhân viên đã tồn tại!", "error");
                    return(RedirectToAction("Index", "RevenueExpenditure"));
                }
            }
            SetViewBag();
            SetTypeBag();
            SetAlert("Sửa thông tin nhân viên thất bại", "error");
            return(RedirectToAction("Index", "RevenueExpenditure"));
        }
Пример #4
0
 public long Insert(RevenueExpenditure entity)
 {
     db.RevenueExpenditures.Add(entity);
     db.SaveChanges();
     return(entity.ID);
 }