Exemple #1
0
 public ActionResult Edit([Bind(Include = "MaCTThuong,MaNhanVien,HoTen,TenPB,MaLoaiThuong,TrangThai,NguoiSua,NgaySua,NguoiThuong,NgayThuong")] Ct_Thuong ct_Thuong)
 {
     if (ModelState.IsValid)
     {
         db.Entry(ct_Thuong).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.MaNhanVien   = new SelectList(db.NhanViens, "MaNhanVien", "HoTen", ct_Thuong.MaNhanVien);
     ViewBag.MaLoaiThuong = new SelectList(db.LoaiThuongs.Where(x => x.TrangThai == true), "MaLoaiThuong", "TenLoaiThuong", ct_Thuong.MaLoaiThuong);
     return(View(ct_Thuong));
 }
Exemple #2
0
        public ActionResult Create([Bind(Include = "MaCTThuong,MaNhanVien,MaLoaiThuong,NguoiSua,NgaySua")] Ct_Thuong ct_Thuong)
        {
            if (ModelState.IsValid)
            {
                db.Ct_Thuong.Add(ct_Thuong);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.MaNhanVien   = new SelectList(db.NhanViens, "MaNhanVien", "HoTen", ct_Thuong.MaNhanVien);
            ViewBag.MaLoaiThuong = new SelectList(db.LoaiThuongs, "MaLoaiThuong", "TenLoaiThuong", ct_Thuong.MaLoaiThuong);
            return(View(ct_Thuong));
        }
Exemple #3
0
        // GET: Ct_Thuong/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Ct_Thuong ct_Thuong = db.Ct_Thuong.Find(id);

            if (ct_Thuong == null)
            {
                return(HttpNotFound());
            }
            return(View(ct_Thuong));
        }
Exemple #4
0
        // GET: Ct_Thuong/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Ct_Thuong ct_Thuong = db.Ct_Thuong.Find(id);

            if (ct_Thuong == null)
            {
                return(HttpNotFound());
            }
            ViewBag.MaNhanVien   = new SelectList(db.NhanViens, "MaNhanVien", "MaNhanVien", ct_Thuong.MaNhanVien);
            ViewBag.MaLoaiThuong = new SelectList(db.LoaiThuongs.Where(x => x.TrangThai == true), "MaLoaiThuong", "TenLoaiThuong", ct_Thuong.MaLoaiThuong);
            return(View(ct_Thuong));
        }
Exemple #5
0
        public ActionResult Delete(List <Ct_Thuong> ct_Thuongs)
        {
            try
            {
                db.Configuration.ValidateOnSaveEnabled = false;
                var checkIsChecked = ct_Thuongs.Where(x => x.IsChecked == true).FirstOrDefault();
                if (checkIsChecked == null)
                {
                    this.AddNotification("Vui lòng chọn chi tiết thưởng để xóa!", NotificationType.ERROR);
                    return(RedirectToAction("Index"));
                }
                foreach (var item in ct_Thuongs)
                {
                    if (item.IsChecked == true)
                    {
                        int       maCTThuong = item.MaCTThuong;
                        Ct_Thuong ct_Thuong  = db.Ct_Thuong.Where(x => x.MaCTThuong == maCTThuong).SingleOrDefault();
                        if (ct_Thuong != null)
                        {
                            ct_Thuong.TrangThai = false;
                            if (Session["TenNhanVien"] == null)
                            {
                                ct_Thuong.NguoiSua = "Ẩn danh";
                                ct_Thuong.NgaySua  = DateTime.Now;
                            }
                            else
                            {
                                ct_Thuong.NguoiSua = Session["TenNhanVien"].ToString();
                                ct_Thuong.NgaySua  = DateTime.Now;
                            }
                            db.SaveChanges();
                        }
                    }
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                this.AddNotification("Không thể xóa vì chi tiết thưởng này đã và đang được sử dụng!", NotificationType.ERROR);
                return(RedirectToAction("Index"));
            }
        }
Exemple #6
0
        public ActionResult ThemThuongNhanVien(FormCollection form)
        {
            var listNhanVien = TempData["listNhanVien"] as List <NhanVien>;

            foreach (var item in listNhanVien)
            {
                if (item.IsChecked == true)
                {
                    var chitietThuong = new Ct_Thuong();
                    chitietThuong.MaNhanVien   = item.MaNhanVien;
                    chitietThuong.MaLoaiThuong = Convert.ToInt32(form["MaLoaiThuong"]);
                    chitietThuong.TrangThai    = true;
                    chitietThuong.NguoiThuong  = form["NguoiSua"].ToString();
                    chitietThuong.NgayThuong   = DateTime.Now;
                    chitietThuong.NguoiSua     = form["NguoiSua"].ToString();
                    chitietThuong.NgaySua      = DateTime.Now;
                    db.Ct_Thuong.Add(chitietThuong);
                    db.SaveChanges();
                }
            }

            return(RedirectToAction("Index"));
        }