Ejemplo n.º 1
0
        public ActionResult Create([Bind(Include = "DM_NhomNgheID,TenNhomNghe,MoTa")] DM_NHOMNGHE dm_nhomnghe)
        {
            if (ModelState.IsValid)
            {
                var checkExist = db.DM_NHOMNGHE.Where(b => b.TenNhomNghe.ToUpper().Contains(dm_nhomnghe.TenNhomNghe.ToUpper().Trim())

                                                      );

                string msgErrs = string.Empty;
                if (checkExist.Count() > 0)
                {
                    DM_NHOMNGHE obj = checkExist.FirstOrDefault();

                    msgErrs = string.Format("Đã tồn tại nhóm nghề có tên [{0}]", obj.TenNhomNghe.ToString()) + "<br />";
                }

                if (string.IsNullOrEmpty(msgErrs))
                {
                    db.DM_NHOMNGHE.Add(dm_nhomnghe);
                    db.SaveChanges();

                    this.Information(string.Format(Constants.NOTIFY_ADD_SUCCESS, string.Empty));

                    return(RedirectToAction("Index"));
                }
                else
                {
                    Inline_Danger(msgErrs, true);
                }
            }

            return(View(dm_nhomnghe));
        }
Ejemplo n.º 2
0
        // GET: /DM_NhomNghe/Edit/5
        public ActionResult Edit(int id)
        {
            DM_NHOMNGHE dm_nhomnghe = db.DM_NHOMNGHE.Find(id);

            if (dm_nhomnghe == null)
            {
                return(HttpNotFound());
            }
            return(View(dm_nhomnghe));
        }
Ejemplo n.º 3
0
        public ActionResult Edit([Bind(Include = "DM_NhomNgheID,TenNhomNghe,MoTa")] DM_NHOMNGHE dm_nhomnghe)
        {
            if (ModelState.IsValid)
            {
                db.Entry(dm_nhomnghe).State = EntityState.Modified;
                db.SaveChanges();

                this.Information(string.Format(Constants.NOTIFY_UPDATE_SUCCESS, string.Empty));

                return(RedirectToAction("Index"));
            }
            return(View(dm_nhomnghe));
        }
Ejemplo n.º 4
0
        public ActionResult Delete(int id)
        {
            try
            {
                DM_NHOMNGHE dm_nhomnghe = db.DM_NHOMNGHE.Find(id);
                db.DM_NHOMNGHE.Remove(dm_nhomnghe);
                db.SaveChanges();

                this.Information(string.Format(Constants.NOTIFY_DELETE_SUCCESS, string.Empty));
            }
            catch
            {
                //this.Error("Không thể xóa nhóm nghề khi tồn tại danh sách nghề thuộc nhóm, hoặc nghề thuộc nhóm đã được sử dụng");
                Inline_Danger("Nhóm nghề này đã được sử dụng tại chức năng khác nên không thể xóa", true);
            }
            return(RedirectToAction("Index"));
        }