private void buttonAdd_Click(object sender, EventArgs e) { if (textBoxSection.Text == "") { ProcessInvalid(labelSection); MessageBox.Show("Section name can't be empty", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (comboBoxTeacher.Text == "--Select--") { ProcessInvalid(labelTeacher); MessageBox.Show("Must Select a Class Teacher", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (CheckSectionExists(textBoxSection.Text)) { ProcessInvalid(labelSection); MessageBox.Show("Section already exists", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { var classSec = new ClassSection { ClassId = selectClassId, SectionName = textBoxSection.Text, IsActive = checkBoxIsActive.Checked, ClassTeacherId = (int)comboBoxTeacher.SelectedValue }; if (_settingService.AddClassSection(classSec)) { MessageBox.Show("Data Saved Successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); ProcessValid(labelSection); ProcessValid(labelTeacher); gridViewSelectedId = classSec.ClassSectionId.ToString(); LoadDataSection(_settingService.GetClassSectionList(classSec.ClassId)); dataGridViewSection.Refresh(); } else { MessageBox.Show("error"); } } }