private void RefreshTab(string name) { switch (name) { case "TeachersPage": { TeachersGridView.DataSource = CoursesRequests.GetTeachers().Where(p => p.Name.Contains(findTeacherBox.Text)).ToList(); if (TeachersGridView.RowCount == 0) { CallDTeacherForm.Enabled = CallETeacherForm.Enabled = false; } else { CallDTeacherForm.Enabled = CallETeacherForm.Enabled = true; } break; } case "SchoolsPage": { SchoolsGridView.DataSource = CoursesRequests.GetSchools().Where(p => p.Name.Contains(findSchoolBox.Text)).ToList(); if (SchoolsGridView.RowCount == 0) { CallDSchoolForm.Enabled = CallESchoolForm.Enabled = false; } else { CallDSchoolForm.Enabled = CallESchoolForm.Enabled = true; } break; } case "SubjectsPage": { SubjectsGridView.DataSource = CoursesRequests.GetSubjects().Where(p => p.Name.Contains(findSubjectBox.Text)).ToList(); if (SubjectsGridView.RowCount == 0) { CallDSubjectForm.Enabled = CallESubjectForm.Enabled = false; } else { CallDSubjectForm.Enabled = CallESubjectForm.Enabled = true; } break; } case "StudentsPage": { StudentsGridView.DataSource = CoursesRequests.GetStudentViews().Where(p => p.Name.Contains(findStudentBox.Text)).ToList(); if (StudentsGridView.RowCount == 0) { CallDStudentForm.Enabled = CallEStudentForm.Enabled = false; } else { CallDStudentForm.Enabled = CallEStudentForm.Enabled = true; } break; } case "CoursesPage": { CoursesGridView.Columns[3].DefaultCellStyle.Format = "C"; CoursesGridView.DataSource = CoursesRequests.GetCourseViews(); if (CoursesGridView.RowCount == 0) { CallDCourseForm.Enabled = CallECourseForm.Enabled = false; } else { CallDCourseForm.Enabled = CallECourseForm.Enabled = true; } break; } default: break; } }
private void BindTeacherForm_Load(object sender, EventArgs e) { teacherBox.DisplayMember = "Name"; teacherBox.ValueMember = "Id"; teacherBox.DataSource = CoursesRequests.GetTeachers(); }