public SemestersController(ApplicationDbContext context) { _semesterRepository = new SemesterRepository(context); _departmentRepository = new DepartmentRepository(context); }
public SemesterController(SemesterRepository semesterRepository) { this.semesterRepository = semesterRepository; }
private void dataGridViewExamCellDoubleClicked(object sender, DataGridViewCellEventArgs e) { SemesterRepository sRepo = new SemesterRepository(); this.comboBoxSemesterName.DataSource = sRepo.GetAllSemesterNames2(); CourseRepository cRepo = new CourseRepository(); this.comboBoxCourseId.DataSource = cRepo.GetCourseIdNameSectionsBySemester2(this.comboBoxSemesterName.Text); AccountRepository aRepo = new AccountRepository(); this.comboBoxFacultyId.DataSource = aRepo.GetAccountIdAndNames2("Faculty"); this.comboBoxSemesterName.SelectedIndex = this.comboBoxSemesterName.FindString(this.dataGridViewExam.CurrentRow.Cells[1].Value.ToString()); this.comboBoxCourseId.SelectedIndex = this.comboBoxCourseId.FindString(this.dataGridViewExam.CurrentRow.Cells[0].Value.ToString()); this.textBoxRoom.Text = this.dataGridViewExam.CurrentRow.Cells[4].Value.ToString(); this.comboBoxFacultyId.SelectedIndex = this.comboBoxFacultyId.FindString(this.dataGridViewExam.CurrentRow.Cells[5].Value.ToString()); if (this.radioButton1.Text == this.dataGridViewExam.CurrentRow.Cells[2].Value.ToString()) { this.radioButton1.Checked = true; } else if (this.radioButton2.Text == this.dataGridViewExam.CurrentRow.Cells[2].Value.ToString()) { this.radioButton2.Checked = true; } else if (this.radioButton3.Text == this.dataGridViewExam.CurrentRow.Cells[2].Value.ToString()) { this.radioButton3.Checked = true; } else if (this.radioButton4.Text == this.dataGridViewExam.CurrentRow.Cells[2].Value.ToString()) { this.radioButton4.Checked = true; } else if (this.radioButton5.Text == this.dataGridViewExam.CurrentRow.Cells[2].Value.ToString()) { this.radioButton5.Checked = true; } else { this.radioButton6.Checked = true; } if (this.radioButtonSlot1.Text == this.dataGridViewExam.CurrentRow.Cells[3].Value.ToString()) { this.radioButtonSlot1.Checked = true; } else if (this.radioButtonSlot2.Text == this.dataGridViewExam.CurrentRow.Cells[3].Value.ToString()) { this.radioButtonSlot2.Checked = true; } else if (this.radioButtonSlot3.Text == this.dataGridViewExam.CurrentRow.Cells[3].Value.ToString()) { this.radioButtonSlot3.Checked = true; } else { this.radioButtonSlot4.Checked = true; } }
private void InsertClicked(object sender, EventArgs e) { Course c = new Course(); Random r = new Random(); SemesterRepository sRepo = new SemesterRepository(); int x; if (this.textBoxName.Text != "" && this.comboBoxSemester.Text != "" && this.textBoxSection.Text != "" && this.comboBoxSchedule.Text != "") { if (sRepo.CheckSemester2(this.comboBoxSemester.Text)) { x = r.Next(1000, 4999); if (this.radioButtonCSE.Checked) { c.CourseId = "CSE" + x.ToString(); c.Department = "CSE"; } else if (this.radioButtonEEE.Checked) { c.CourseId = "EEE" + x.ToString(); c.Department = "EEE"; } else { c.CourseId = "BBA" + x.ToString(); c.Department = "BBA"; } this.labelId.Text = c.CourseId; c.Name = this.textBoxName.Text.ToUpper(); c.Semester = this.comboBoxSemester.Text.ToUpper(); c.Section = this.textBoxSection.Text.ToUpper(); if (this.radioButton20.Checked) { c.MaxStudent = 20; } else if (this.radioButton30.Checked) { c.MaxStudent = 30; } else { c.MaxStudent = 40; } c.CurrentStudent = 0; if (this.radioButton1Credit.Checked) { c.Credit = 1; } else { c.Credit = 3; } c.Schedule = this.comboBoxSchedule.Text.ToUpper(); CourseRepository cRepo = new CourseRepository(); if (cRepo.Insert2(c)) { MessageBox.Show("One Course Added", "Successful"); this.dataGridViewCourse.DataSource = cRepo.GetAllCourses2(); } else { MessageBox.Show("Fill up all the fields", "Failed"); } } else { MessageBox.Show("Invalide Semester Name", "Failed"); } } }