private void SaveButton_Click(object sender, EventArgs e) { if (SaveButton.Text == "Save") { category.Name = categoryNameTextBox.Text; if (String.IsNullOrEmpty(category.Name)) { MessageBox.Show("Category name field is blank."); return; } if (_stockManager.Duplicate(category) > 0) { MessageBox.Show("This Category name already exists."); return; } isExecuted = _stockManager.InsertCategory(category); if (isExecuted > 0) { MessageBox.Show("Successful"); } else { MessageBox.Show("Unsuccessful"); } categoryDisplayGridView.DataSource = _stockManager.DisplayGrid(); categoryNameTextBox.Text = ""; } if (SaveButton.Text == "Update") { category.Name = categoryNameTextBox.Text; if (String.IsNullOrEmpty(category.Name)) { MessageBox.Show("Category name field is blank."); return; } if (_stockManager.Duplicate(category) > 0) { MessageBox.Show("This Category name already exists"); return; } isExecuted = _stockManager.UpdateCategory(category, rowIndex); if (isExecuted > 0) { MessageBox.Show("Successful"); } else { MessageBox.Show("Unsuccessful"); } categoryDisplayGridView.DataSource = _stockManager.DisplayGrid(); SaveButton.Text = "Save"; categoryNameTextBox.Text = ""; } }