示例#1
0
        //// GET: KhenThuongController/Details/5
        //public ActionResult Details(int id)
        //{
        //    return View();
        //}

        // GET: KhenThuongController/Create
        public ActionResult Create()
        {
            var model = new ViewModelDG();

            model.ListNhanVien       = database.NhanViens.ToArray();
            model.ListLoaikhenThuong = database.LoaiKhenThuongs.ToArray();
            return(View(model));
        }
示例#2
0
        // GET: DanhGiaController
        public ActionResult Index()
        {
            var model = new ViewModelDG();

            model.ListloaiKyLuat     = database.LoaiKyLuats.ToArray();
            model.ListLoaikhenThuong = database.LoaiKhenThuongs.ToArray();
            return(View(model));
        }
        //// GET: KyLuatController/Details/5
        //public ActionResult Details(int id)
        //{
        //    return View();
        //}

        // GET: KyLuatController/Create
        public ActionResult Create()
        {
            var model = new ViewModelDG();

            model.ListNhanVien   = database.NhanViens.ToArray();
            model.ListloaiKyLuat = database.LoaiKyLuats.ToArray();
            return(View(model));
        }
示例#4
0
        // GET: KhenThuongController/Delete/5
        public ActionResult Delete(int id)
        {
            var model = new ViewModelDG();

            model.ListNhanVien       = database.NhanViens.ToArray();
            model.ListLoaikhenThuong = database.LoaiKhenThuongs.ToArray();
            model.khenThuong         = database.KhenThuongs.Where(x => x.Idkt == id).FirstOrDefault();
            return(View(model));
        }
        // GET: KyLuatController/Delete/5
        public ActionResult Delete(int id)
        {
            var model = new ViewModelDG();

            model.ListNhanVien   = database.NhanViens.ToArray();
            model.ListloaiKyLuat = database.LoaiKyLuats.ToArray();
            model.kyLuat         = database.KyLuats.Where(x => x.Idkl == id).FirstOrDefault();
            return(View(model));
        }
示例#6
0
        public ActionResult DetailsThuong(int id, int th)
        {
            var model = new ViewModelDG();

            model.ListNhanVien       = database.NhanViens.ToArray();
            model.ListkhenThuong     = database.KhenThuongs.Where(x => x.Ngay.Value.Month == th && x.Idnv == id).ToArray();
            model.ListLoaikhenThuong = database.LoaiKhenThuongs.ToArray();
            model.ListNhanVien       = database.NhanViens.ToArray();
            model.nhanVien           = database.NhanViens.Where(x => x.Idnv == id).FirstOrDefault();
            model.taiKhoan           = database.TaiKhoans.Where(x => x.Idnv == id).FirstOrDefault();

            HttpContext.Session.SetString("IDNV", model.nhanVien.Idnv.ToString());
            return(View(model));
        }
示例#7
0
        public async Task <ActionResult> Create(KhenThuong khenThuong)
        {
            var model = new ViewModelDG();

            model.ListNhanVien       = database.NhanViens.ToArray();
            model.ListLoaikhenThuong = database.LoaiKhenThuongs.ToArray();
            if (ModelState.IsValid)
            {
                database.Add(khenThuong);
                await database.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
示例#8
0
        public async Task <IActionResult> Edit(int id, KhenThuong khenThuong)
        {
            var model = new ViewModelDG();

            model.ListNhanVien       = database.NhanViens.ToArray();
            model.ListLoaikhenThuong = database.LoaiKhenThuongs.ToArray();
            model.khenThuong         = database.KhenThuongs.Where(x => x.Idkt == id).FirstOrDefault();
            if (ModelState.IsValid)
            {
                model.khenThuong.Idnv     = khenThuong.Idnv;
                model.khenThuong.IdloaiKt = khenThuong.IdloaiKt;
                model.khenThuong.Ngay     = khenThuong.Ngay;

                database.Update(model.khenThuong);
                await database.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
        public async Task <IActionResult> Edit(int id, KyLuat kyLuat)
        {
            var model = new ViewModelDG();

            model.ListNhanVien   = database.NhanViens.ToArray();
            model.ListloaiKyLuat = database.LoaiKyLuats.ToArray();
            model.kyLuat         = database.KyLuats.Where(x => x.Idkl == id).FirstOrDefault();
            if (ModelState.IsValid)
            {
                model.kyLuat.Idnv     = kyLuat.Idnv;
                model.kyLuat.IdloaiKl = kyLuat.IdloaiKl;
                model.kyLuat.Ngay     = kyLuat.Ngay;

                database.Update(model.kyLuat);
                await database.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
示例#10
0
        // GET: KhenThuongController
        public ActionResult Index(string sortOrder, string currentFilter, string searchString, int?page)
        {
            //A ViewBag property provides the view with the current sort order, because this must be included in
            //  the paging links in order to keep the sort order the same while paging
            ViewBag.CurrentSort  = sortOrder;
            ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";

            ViewBag.Role = TempData["Role"];

            var ModelList = new List <KhenThuong>();

            //ViewBag.CurrentFilter, provides the view with the current filter string.
            //he search string is changed when a value is entered in the text box and the submit button is pressed. In that case, the searchString parameter is not null.
            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            ViewBag.CurrentFilter = searchString;


            using (var context = new QLNSContext())
            {
                var modelv = from s in context.KhenThuongs
                             select s;
                //Search and match data, if search string is not null or empty
                if (!String.IsNullOrEmpty(searchString))
                {
                    modelv = modelv.Where(s => s.Idkt.ToString().Contains(searchString) ||
                                          s.IdnvNavigation.TenNv.Contains(searchString) ||
                                          s.IdloaiKtNavigation.TenKt.Contains(searchString) ||
                                          s.Ngay.Value.Month.ToString().Contains(searchString));
                }
                switch (sortOrder)
                {
                case "name_desc":
                    ModelList = modelv.OrderByDescending(s => s.Idkt).ToList();
                    break;

                default:
                    ModelList = modelv.OrderBy(s => s.Idkt).ToList();
                    break;
                }
            }
            //indicates the size of list
            int pageSize = 5;
            //set page to one is there is no value, ??  is called the null-coalescing operator.
            int pageNumber = (page ?? 1);
            //return the Model data with paged

            var model = new ViewModelDG();

            model.ListNhanVien       = database.NhanViens.ToArray();
            model.ListKhenThuongs    = ModelList.ToPagedList(pageNumber, pageSize);
            model.ListLoaikhenThuong = database.LoaiKhenThuongs.ToArray();
            return(View(model));
        }