Пример #1
0
        private void gvCategory_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int rowindex   = gvCategory.CurrentCell.RowIndex;
            var senderGrid = (DataGridView)sender;

            if (senderGrid.Columns[e.ColumnIndex] is DataGridViewImageColumn && e.RowIndex >= 0)
            {
                DialogResult result = MessageBox.Show("Do you want to delete ?", "Warning", MessageBoxButtons.YesNo);
                if (result == DialogResult.Yes)
                {
                    try
                    {
                        Category category = new Category
                        {
                            CategoryId          = categoryId,
                            CategoryName        = txtCategoryname.Text,
                            CategoryDescription = txtDescription.Text,
                            ProductFromId       = int.Parse(cboCategoryFrom.SelectedValue.ToString())
                        };
                        CategoyBLL.DeleteCategory(category);
                        MessageBox.Show("Delete Successful", "Warning");
                        txtCategoryname.Text = "";
                        txtCategoryname.Focus();
                    }
                    catch { MessageBox.Show("Delete fail", "Warning"); }
                }
                LoadCategory();
                txtCategoryname.Text = string.Empty;
                txtDescription.Text  = string.Empty;
            }
        }
Пример #2
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Are You Sure Want To Delete Category Record?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         int i = blc.DeleteCategory(Convert.ToInt32(txtId.Text));
         if (i > 0)
         {
             MessageBox.Show("Category Deleted Successfully");
             txtCategoryName.Text = "";
             txtCategoryName.Focus();
         }
     }
 }
 private void btnDeleteCategory_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Are You Sure Want To Delete Category?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         int i = blc.DeleteCategory(categoryid);
         if (i > 0)
         {
             txtCategoryName.Text = "";
             MessageBox.Show("Category Deleted Successfully");
             LoadGrid();
             btnAddNewCategory.Enabled = true;
             btnUpdateCategory.Enabled = false;
             btnDeleteCategory.Enabled = false;
         }
     }
 }
Пример #4
0
    protected void lnkDelete_Click(object sender, EventArgs e)
    {
        int test = 0;

        foreach (GridViewRow row in gvCategoryList.Rows)
        {
            CheckBox cb = (CheckBox)row.FindControl("chkSel");
            if (cb.Checked)
            {
                ++test;
                int id = int.Parse(row.Cells[1].Text);
                int k  = BLLCategory.DeleteCategory(id);
            }
        }
        if (test == 0)
        {
            ClientScript.RegisterStartupScript(this.GetType(), "Notify", "alert('!!!Please select a Category from the list to delete');", true);
        }
        else
        {
            Response.Redirect("CategoryList.aspx");
        }
    }