Beispiel #1
0
        public ActionResult Delete(long id)
        {
            try
            {
                // TODO: Add delete logic here

                CategoryDao bdDao    = new CategoryDao();
                NewsDao     dbNewDao = new NewsDao();

                if (bdDao.FindChildCategory(id).Count > 0)
                {
                    SetAlert("Đang sử dụng không được phép xóa", SystemConsts.ALERT_DANGER);
                    return(RedirectToAction("Index"));
                }
                if (dbNewDao.ToActiveByCateID(id).Count > 0)
                {
                    SetAlert("Đang sử dụng không được phép xóa", SystemConsts.ALERT_DANGER);
                    return(RedirectToAction("Index"));
                }
                bdDao.Delete(id);
                // SetAlert("Xóa thành công", "success");
                return(RedirectToAction("Index"));
            }
            catch
            {
                // SetAlert("Không xóa được", "danger");
                return(View());
            }
        }
Beispiel #2
0
        public ActionResult Delete(int id)
        {
            var dao = new CategoryDao();

            dao.Delete(id);
            return(RedirectToAction("Index"));
        }
Beispiel #3
0
        public void delete(Category objCategory)
        {
            bool verification = true;

            Category objCategoryAux = new Category();

            objCategoryAux.IdCategory = objCategory.IdCategory;
            verification = objCategoryDao.Find(objCategoryAux);
            if (!verification)
            {
                objCategory.State = 33;
                return;
            }

            Product objProduct = new Product();

            objProduct.IdCategory = objCategory.IdCategory;
            verification          = !objProductDao.FindCat(objProduct);
            if (!verification)
            {
                objCategory.State = 34;
                return;
            }

            objCategory.State = 99;
            objCategoryDao.Delete(objCategory);
            return;
        }
Beispiel #4
0
        public int Delete(int categoryId)
        {
            CacheHelper <List <Category> > .CleanAll();

            var ids = GetChildIds(categoryId);

            return(CategoryDao.Delete(ids));
        }
 public ActionResult Remove(long?Id)
 {
     if (Id == null)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadGateway));
     }
     Dao.Delete(Id);
     return(RedirectToAction("Index"));
 }
        public ActionResult Delete(long id)
        {
            string deleteStatus = categoryDao.Delete(id);

            if (deleteStatus == COMMON_CONSTANTS.DELETE_SUCCESS)
            {
                return(RedirectToAction("Index", "Category"));
            }
            else
            {
                return(RedirectToAction("Index", "Error"));
            }
        }
        public ActionResult Delete(string id)
        {
            if (id == null || !Regex.IsMatch(id, @"\d"))
            {
                return(RedirectToAction("Index", "Category"));
            }

            var categoryDao = new CategoryDao();

            categoryDao.Delete(Int32.Parse(id));

            ShowNotify("Delete successfully", "success");
            return(RedirectToAction("Index"));
        }
Beispiel #8
0
        public void TestSave2()
        {
            Category category = TestHelper.CreateCategory("test", "测试");

            CategoryDao categoryDao = new CategoryDao(TestHelper.ConnectionString);
            int         isSave      = categoryDao.Save(category);

            Assert.IsTrue(isSave > 0);

            category.Name = "hello";
            int isUpdate = categoryDao.Update(category);

            Assert.IsTrue(isUpdate > 0);

            int isDelete = categoryDao.Delete(new Category[] { category });

            Assert.IsTrue(isDelete > 0);
        }
Beispiel #9
0
        public ActionResult Delete(long id)
        {
            try
            {
                // TODO: Add delete logic here

                CategoryDao bdDao = new CategoryDao();
                ProjectDao  prDao = new ProjectDao();
                if (prDao.FindByCategory(id).Count > 0)
                {
                    SetAlert("Đang sử dụng không được phép xóa", Common.CommonConstant.ALERT_DANGER);
                    return(RedirectToAction("Index"));
                }
                bdDao.Delete(id);
                // SetAlert("Xóa thành công", "success");
                return(RedirectToAction("Index"));
            }
            catch
            {
                // SetAlert("Không xóa được", "danger");
                return(View());
            }
        }
Beispiel #10
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            operate = "delete";
            if (treeView.SelectedNode == null)
            {
                return;
            }

            if (((TreeNodeTag)treeView.SelectedNode.Tag).NodeType == TreeNodeType.Type)
            {
                typesDao.DeleteByCellType(treeView.SelectedNode.Text);
            }
            else if (((TreeNodeTag)treeView.SelectedNode.Tag).NodeType == TreeNodeType.Category)
            {
                if (Dialogs.Confirm("确认并删除所有子项?"))
                {
                    Category cate = cateDao.GetCategoryByName(treeView.SelectedNode.Text);
                    typesDao.DeleteByCateId(cate.CateId);
                    cateDao.Delete(cate.CateId);
                }
            }

            btnRefresh_Click(sender, e);
        }
Beispiel #11
0
 public async Task <Category> Delete(long id)
 {
     return(await categoryDao.Delete(id));
 }
Beispiel #12
0
 /// <summary>
 /// 删除类别
 /// </summary>
 /// <param name="cid"></param>
 /// <returns></returns>
 public bool DelCategory(int cid)
 {
     return(cdao.Delete(cid));
 }
Beispiel #13
0
 public ActionResult Delete(int id)
 {
     dao.Delete(id);
     return(RedirectToAction("Index"));
 }