private void SaveButton_Click(object sender, EventArgs e) { if (SaveButton.Text == "Save") { company.Name = companyNameTextBox.Text; if (String.IsNullOrEmpty(company.Name)) { MessageBox.Show("Company name field is blank."); return; } if (_companyManager.Duplicate(company) > 0) { MessageBox.Show("This Company name already exists"); return; } isExecuted = _companyManager.InsertCompany(company); if (isExecuted > 0) { MessageBox.Show("Successful"); } else { MessageBox.Show("Unsuccessful"); } companyDisplayGridView.DataSource = _companyManager.DisplayGrid(); companyNameTextBox.Text = ""; } if (SaveButton.Text == "Update") { company.Name = companyNameTextBox.Text; if (String.IsNullOrEmpty(company.Name)) { MessageBox.Show("Company name field is blank."); return; } if (_companyManager.Duplicate(company) > 0) { MessageBox.Show("This Company name already exists"); return; } isExecuted = _companyManager.UpdateCompany(company, rowIndex); if (isExecuted > 0) { MessageBox.Show("Successful"); } else { MessageBox.Show("Unsuccessful"); } companyDisplayGridView.DataSource = _companyManager.DisplayGrid(); companyNameTextBox.Text = ""; SaveButton.Text = "Save"; } }