private void btnSave_Click(object sender, EventArgs e) { if (ValidateChildren(ValidationConstraints.Enabled)) { try { BOProduct BO = new BOProduct(); BusinessManager BM = new BusinessManager(); BO.CategoryName = txtCategoryName.Text.Trim(); bool res = BM.BALVerifyCategoryName(BO); if (res == true) { MessageBox.Show("Category name already exits. Please enter a new category name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtCategoryName.Text = ""; txtCategoryName.Focus(); } int rowsAffected = BM.BALInsertCategory(BO); if (rowsAffected > 0) { MessageBox.Show("Successfully saved!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); btnSave.Enabled = false; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }