Exemple #1
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (ValidateChildren(ValidationConstraints.Enabled))
     {
         if (txtProductName.Text != "")
         {
             if (MessageBox.Show("Do you really want to delete the record?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK)
             {
                 BOProduct       BO = new BOProduct();
                 BusinessManager BM = new BusinessManager();
                 BO.ProductName = txtProductName.Text.Trim();
                 int res = BM.BALDeleteProduct(BO);
                 if (res > 0)
                 {
                     MessageBox.Show("Successfully deleted!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     New();
                 }
                 else
                 {
                     MessageBox.Show("No record found", "Sorry", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     New();
                 }
             }
         }
         else
         {
             MessageBox.Show("Please enter a product to delete", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             txtProductName.Focus();
         }
     }
 }