示例#1
0
 private void btnXoa_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Bạn có chắc chắn muốn xóa!", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
     {
         return;
     }
     else
     {
         var  index   = dgvListCategory.CurrentCell.RowIndex;
         bool kiemTra = false;
         kiemTra = _CategoryBusiness.CanDeleteCategory(int.Parse(dgvListCategory.Rows[index].Cells[0].Value.ToString()));
         if (kiemTra == false)
         {
             MessageBox.Show("Danh mục này chưa thể xóa được! muốn xóa danh mục này xin xóa các phân loại và sản phẩm thuộc danh mục này trước", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else
         {
             if (_CategoryBusiness.DeleteCategory(int.Parse(dgvListCategory.Rows[index].Cells[0].Value.ToString())))
             {
                 MessageBox.Show("Xóa Thành Công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 LoadData();
             }
             else
             {
                 MessageBox.Show("Xóa không thành công!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 return;
             }
         }
     }
 }
示例#2
0
        private void buttoncatdelete_Click(object sender, EventArgs e)
        {
            CategoryBusiness.DeleteCategory(selectedCategory);

            ShowCategories();
            ShowCategoriesComboBox();
        }
        public ActionResult DeleteCategory(CategoryViewModel model, int id)
        {
            // _Category.GetCategoryById(id);
            _Category.DeleteCategory(id);

            RedirectToAction("Index");
            //Content("Sucessfull");
            return(View());
        }
        public ActionResult DeleteCategory(int categoryId)
        {
            if (ModelState.IsValid)
            {
                result = CategoryBusiness.DeleteCategory(categoryId);

                if (result)
                {
                    return(Json(new { success = result }));
                }
            }

            return(Json(new { success = result }));
        }
示例#5
0
        protected void gvCategory_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int         index = 0;
            GridViewRow row;
            GridView    grid = sender as GridView;

            switch (e.CommandName)
            {
            case "Delete":
                index = Convert.ToInt32(e.CommandArgument);
                row   = grid.Rows[index];

                categoryBusiness.DeleteCategory(long.Parse(((HyperLink)row.Cells[0].Controls[0]).Text));

                break;
            }
        }
示例#6
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            string       err       = "";
            DialogResult isDeleted = MessageBox.Show("Are you sure want to delete this category?", "Delete a category", MessageBoxButtons.YesNo);

            if (isDeleted == DialogResult.Yes)
            {
                int  r          = dagvCategory.CurrentCell.RowIndex;
                int  categoryID = Int32.Parse(dagvCategory.Rows[r].Cells[0].Value.ToString());
                bool result     = categoryBusiness.DeleteCategory(categoryID, ref err);
                if (result)
                {
                    MessageBox.Show("Deleted successfully!", "Delete a category");
                }
                else
                {
                    MessageBox.Show("Failed to delete a category!Error:" + err, "Delete a category");
                }
                loadData();
            }
        }
示例#7
0
 /// <summary>
 /// Método que elimina en registro de la entidad
 /// </summary>
 public async Task DeleteCategory(Guid ID)
 {
     categoryBusiness.DeleteCategory(ID);
 }
示例#8
0
        // Delete Category
        public async Task <ActionResult> DeleteCategory(int Id)
        {
            var result = await CategoryBusiness.DeleteCategory(Id);

            return(View("Delete", result));
        }