private void btnSave_Click(object sender, EventArgs e) { if (ValidateChildren(ValidationConstraints.Enabled)) { try { auto_generate_id(); BusinessManager BM = new BusinessManager(); BOCustomer BO = new BOCustomer(); BO.CustomerID = txtCustomerID.Text.Trim(); BO.CustomerName = txtCustomerName.Text.Trim(); BO.CustomerAddress = txtAddress.Text.Trim(); BO.CustomerPlace = txtPlace.Text.Trim(); BO.CustomerCity = txtCity.Text.Trim(); BO.CustomerZone = cmbZone.Text.Trim(); BO.CustomerPostalCode = txtPostalCode.Text.Trim(); BO.CustomerPhone = txtPhone.Text.Trim(); BO.CustomerMobile = txtMobile.Text.Trim(); BO.CustomerFax = txtFax.Text.Trim(); BO.CustomerEmail = txtEmail.Text.Trim(); BO.CustomerNotes = txtNote.Text.Trim(); bool res = BM.BALVerifyCustomerName(BO); int rowsAffected = 0; if (res == true) { MessageBox.Show("Customer ID already exists", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); New(); } else { rowsAffected = BM.BALInsertIntoCustomer(BO); if (rowsAffected > 0) { MessageBox.Show("Successfully saved", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); btnSave.Enabled = false; New(); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }