public ActionResult EditChildrentDanhMuc(FormCollection coll)
        {
            string  mess    = "";
            int     id      = Convert.ToInt32(coll["hdId"].ToString());
            string  txtTen  = coll["txtTen"].ToString();
            string  group   = (Convert.ToDouble(coll["cmbDanhMuc"].ToString()) + 0.1).ToString();
            danhmuc danhMuc = db.danhmucs.Where(x => x.id_danhmuc == id).Single();

            try
            {
                danhMuc.ten_danhmuc  = txtTen;
                danhMuc.groupdanhmuc = Convert.ToDouble(group);
                db.SubmitChanges();
                mess = Lib.messenger(0, "Cập nhật thành công!");
            }
            catch (Exception ex) {
                mess = Lib.messenger(2, "Cập nhật thất bại!");
            }
            ViewBag.Title = Conf.TITLE + "Danh mục " + danhMuc.ten_danhmuc;
            List <danhmuc> listDanhMuc = this.GetParent();
            List <object>  list        = new List <object>();

            list.Add(danhMuc);
            list.Add(listDanhMuc);
            ViewBag.error = mess;
            return(View(list));;
        }
Example #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            danhmuc danhmuc = db.danhmuc.Find(id);

            db.danhmuc.Remove(danhmuc);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #3
0
 public ActionResult Edit([Bind(Include = "iddm,tendm")] danhmuc danhmuc)
 {
     if (ModelState.IsValid)
     {
         db.Entry(danhmuc).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(danhmuc));
 }
Example #4
0
        public ActionResult Create([Bind(Include = "iddm,tendm")] danhmuc danhmuc)
        {
            if (ModelState.IsValid)
            {
                db.danhmuc.Add(danhmuc);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(danhmuc));
        }
        //edit chidrent category:
        public ActionResult EditChildrentDanhMuc(string title, int id)
        {
            danhmuc danhMuc = db.danhmucs.Where(x => x.id_danhmuc == id).Single();

            ViewBag.Title = Conf.TITLE + "Danh mục " + danhMuc.ten_danhmuc;
            List <danhmuc> listDanhMuc = this.GetParent();
            List <object>  list        = new List <object>();

            list.Add(danhMuc);
            list.Add(listDanhMuc);
            return(View(list));
        }
Example #6
0
        // GET: admin/danhmucs/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            danhmuc danhmuc = db.danhmuc.Find(id);

            if (danhmuc == null)
            {
                return(HttpNotFound());
            }
            return(View(danhmuc));
        }
        public bool edit_danh_muc(int id, danhmuc dm)
        {
            string msgError = "";

            try
            {
                var dt = _Helper.ExecuteSProcedureReturnDataTable(out msgError, "edit_danh_muc_agian", "@id_danhmuc", id, "@ten_danhmuc", dm.tendm);
                if (!string.IsNullOrEmpty(msgError))
                {
                    throw new Exception(msgError);
                }
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
        public ActionResult AddParent(FormCollection coll)
        {
            string result = "";

            ViewBag.Title = Conf.TITLE + "Thêm danh mục cha";
            var    queryDanhMuc = db.danhmucs.OrderByDescending(x => x.groupdanhmuc).First();
            double group        = Convert.ToInt32(queryDanhMuc.groupdanhmuc.ToString().Split(Conf.CHAR_PLIT)[0]) + 1.1;

            try
            {
                danhmuc d = new danhmuc();
                d.ten_danhmuc  = coll["txtTen"];
                d.groupdanhmuc = group;
                db.danhmucs.InsertOnSubmit(d);
                db.SubmitChanges();
                result = Lib.messenger(0, "Thêm danh mục thành công!");
            }
            catch (Exception ex) {
                result = Lib.messenger(2, "Thêm danh mục thất bại!");
            }
            ViewBag.error = result;
            return(View());
        }
        public ActionResult AddChildrent(FormCollection coll)
        {
            string result     = "";
            var    danhMucPar = this.GetParent();

            ViewBag.Title = Conf.TITLE + "Thêm danh mục con";
            string group = coll["cmbDanhMuc"];

            try
            {
                danhmuc d = new danhmuc();
                d.ten_danhmuc  = coll["txtTen"];
                d.groupdanhmuc = Convert.ToDouble(group);
                db.danhmucs.InsertOnSubmit(d);
                db.SubmitChanges();
                result = Lib.messenger(0, "Thêm danh mục thành công! ");
            }
            catch (Exception ex)
            {
                result = Lib.messenger(2, "Thêm danh mục thất bại!");
            }
            ViewBag.error = result;
            return(View(danhMucPar));
        }
Example #10
0
 public bool create_danh_muc([FromBody] danhmuc dm)
 {
     return(_Buss.create_danh_muc(dm));
 }
 public bool edit_danh_muc(int id, danhmuc dm)
 {
     return(_Respo.edit_danh_muc(id, dm));
 }
 public bool create_danh_muc(danhmuc dm)
 {
     return(_Respo.create_danh_muc(dm));
 }