private void buttonAdd_Click(object sender, EventArgs e) { if (textBoxSubject.Text == "") { ProcessInvalid(labelSubject); MessageBox.Show("Subject name can't be empty", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (CheckSubjectExists(textBoxSubject.Text)) { ProcessInvalid(labelSubject); MessageBox.Show("Subject already exists", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { var sub = new Subject { SubjectName = textBoxSubject.Text, IsActive = checkBoxIsActive.Checked }; if (_settingService.AddSubject(sub)) { MessageBox.Show("Data Saved Successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); ProcessValid(labelSubject); gridViewSelectedId = sub.SubjectId.ToString(); LoadDataSubject(_settingService.GetSubjectList()); dataGridViewSubject.Refresh(); } else { MessageBox.Show("error", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }