private void AddClicked(object sender, EventArgs e) { Exam ex = new Exam(); Course c = new Course(); string[] acc = this.comboBoxFacultyId.Text.Split(' '); string[] acc2 = this.comboBoxCourseId.Text.Split(' '); ex.CourseId = acc2[0]; c.CourseId = acc2[0]; ex.Semester = this.comboBoxSemesterName.Text; c.Semester = this.comboBoxSemesterName.Text; ex.Room = this.textBoxRoom.Text; if (this.radioButton1.Checked) { ex.Day = this.radioButton1.Text; } else if (this.radioButton2.Checked) { ex.Day = this.radioButton2.Text; } else if (this.radioButton3.Checked) { ex.Day = this.radioButton3.Text; } else if (this.radioButton4.Checked) { ex.Day = this.radioButton4.Text; } else if (this.radioButton5.Checked) { ex.Day = this.radioButton5.Text; } else { ex.Day = this.radioButton6.Text; } if (this.radioButtonSlot1.Checked) { ex.Slot = this.radioButtonSlot1.Text; } else if (this.radioButtonSlot2.Checked) { ex.Slot = this.radioButtonSlot2.Text; } else if (this.radioButtonSlot3.Checked) { ex.Slot = this.radioButtonSlot3.Text; } else { ex.Slot = this.radioButtonSlot4.Text; } ex.AssignedFacultyId = acc[0]; ExamRepository eRepo = new ExamRepository(); CourseRepository cRepo = new CourseRepository(); if (eRepo.CheckExamCourseId2(ex.CourseId) == false) { if (cRepo.CheckCourseIdAndSemesterName2(c)) { if (ex.Room != "" && eRepo.Insert2(ex)) { MessageBox.Show("One Exam Added", "Successful"); this.dataGridViewExam.DataSource = eRepo.GetAllExams2(); } else { MessageBox.Show("Fill All The Fields", "Failed"); } } else { MessageBox.Show("There Is No Such Course In This Semester", "Failed"); } } else { MessageBox.Show("Exam For This Course ID Already Exists", "Failed"); } }