void deleteButton_Click(object sender, EventArgs e)
        {
            categoryId = Int32.Parse(idHidden.Value);

            CategoryTableAdapter categoryAdapter = new CategoryTableAdapter();

            try
            {
                int parentCategoryId = category.ParentCategoryId;
                categoryAdapter.Delete(categoryId);

                InfoMessage = "Category Deleted";

                if (parentCategoryId > 0)
                {
                    Response.Redirect("~/admin/CategoryEdit.aspx?id=" + parentCategoryId);
                }
                else
                {
                    Response.Redirect("~/admin/CategoryList.aspx");
                }
            }
            catch (SqlException ex)
            {
                if (ex.Number == 547)
                {
                    ErrorMessage = "Category cannot be deleted because it is assigned to an Advertiser";
                }
                else
                {
                    throw ex;
                }
            }
        }
Ejemplo n.º 2
0
 public void Delete(int categoryid)
 {
     _category.Delete(categoryid);
 }