private void btnSave_Click(object sender, EventArgs e) { if (ValidateChildren(ValidationConstraints.Enabled)) { try { BOProduct BO = new BOProduct(); BusinessManager BM = new BusinessManager(); BO.ProductName = txtProductName.Text.Trim(); BO.ProductCategory = cboxProductCategory.Text.Trim(); BO.ProductCompany = cboxCompany.Text.Trim(); bool res = BM.BALVerifyProductName(BO); if (res == true) { MessageBox.Show("Product name already exits. Please enter a new product name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtProductName.Text = ""; txtProductName.Focus(); } else { int rowsAffected = BM.BALInsertProductName(BO); if (rowsAffected > 0) { MessageBox.Show("Successfully saved", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); //Autocomplete(); txtProductName.Text = ""; cboxCompany.Text = ""; cboxProductCategory.Text = ""; txtProductName.Focus(); btnSave.Enabled = false; } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }