Esempio n. 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;
             }
         }
     }
 }