Exemplo n.º 1
0
        public ActionResult Create(ViolatorKTV violatorKTV)
        {
            if (ModelState.IsValid)
            {
                var dao = new ViolatorKTVDao();

                //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];
                violatorKTV.CreatedBy   = session.UserName;
                violatorKTV.CreatedDate = DateTime.Now;

                long id = dao.Insert(violatorKTV);
                if (id > 0)
                {
                    SetAlert("Thêm chấm công nhân viên thành công", "success");
                    return(RedirectToAction("Index", "ViolatorKTV"));
                }
                else
                {
                    ModelState.AddModelError("", "Thêm chấm nhân viên công không thành công");
                }
            }
            SetViewBag();
            SetAlert("Error", "error");
            return(RedirectToAction("Index", "ViolatorKTV"));
        }
Exemplo n.º 2
0
        public ActionResult Edit(int id)
        {
            var violatorKTV = new ViolatorKTVDao().ViewDetail(id);
            var session     = (UserLogin)Session[CommonConstants.USER_SESSION];

            ViewBag.Role = session.GroupID;
            SetViewBagKTV();
            SetViewBag();
            return(View(violatorKTV));
        }
Exemplo n.º 3
0
        public ActionResult Index(string searchString, int page = 1, int pageSize = 10)
        {
            var session = (UserLogin)Session[CommonConstants.USER_SESSION];

            var dao   = new ViolatorKTVDao();
            var model = dao.ListAllPaging(searchString, page, pageSize, session.DepartmentID);

            ViewBag.SearchString = searchString;

            return(View(model));
        }
Exemplo n.º 4
0
        public ActionResult Edit(ViolatorKTV violatorKTV)
        {
            if (ModelState.IsValid)
            {
                var dao     = new ViolatorKTVDao();
                var session = (UserLogin)Session[CommonConstants.USER_SESSION];

                long id = dao.Update(violatorKTV, session.UserName);
                if (id > 0)
                {
                    SetAlert("Sửa thông tin nhân viên thành công", "success");
                    return(RedirectToAction("Index", "ViolatorKTV"));
                }
                else
                {
                    SetAlert("Tài khoản hoặc mã nhân viên đã tồn tại!", "error");
                    return(RedirectToAction("Index", "ViolatorKTV"));
                }
            }
            SetViewBag();
            SetAlert("Sửa thông tin nhân viên thất bại", "error");
            return(RedirectToAction("Index", "ViolatorKTV"));
        }