コード例 #1
0
        public IEnumerable<SectionModel> GetSections(int Course_Database_ID)
        {
            List<SectionModel> sections = new List<SectionModel>();
            sqlConnection1.Open();
            var reader = GetDatabaseResults("SELECT Sections.Section_Name, Sections.Section_ID, Sections.Time, Buildings.Building_Name FROM Sections JOIN Buildings ON Sections.Building_ID = Buildings.Building_ID WHERE Course_Database_ID='" + Course_Database_ID + "'");

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    var Section_Name = reader.GetString(0);
                    var Section_ID = reader.GetInt32(1);
                    var Time = reader.GetTimeSpan(2);
                    var Building_Name = reader.GetString(3);
                    var section = new SectionModel { Section_Name = Section_Name, Section_ID = Section_ID, Time = Time, Building_Name = Building_Name };
                    sections.Add(section);
                }
            }

            sqlConnection1.Close();

            return sections;
        }
コード例 #2
0
        public IEnumerable<SectionModel> GetProfessorCourses(int id2)
        {
            List<SectionModel> professorSections = new List<SectionModel>();
            var queryString = string.Format("SELECT Courses.Course_Name, Professors.Professor_Name, Sections.Section_Name, Sections.Time, Buildings.Building_Name FROM Sections JOIN Buildings ON Sections.Building_ID = Buildings.Building_ID JOIN Courses ON Sections.Course_Database_ID = Courses.Course_Database_ID JOIN Professors ON Professors.Professor_ID = Courses.Professor_ID WHERE Professors.Professor_ID = {0}", id2);
            sqlConnection1.Open();
            var reader = GetDatabaseResults(queryString);

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    var Course_Name = reader.GetString(0);
                    var Professor_Name = reader.GetString(1);
                    var Section_Name = reader.GetString(2);
                    var Time = reader.GetTimeSpan(3);
                    var Building_Name = reader.GetString(4);
                    var section = new SectionModel { Course_Name = Course_Name, Professor_Name = Professor_Name, Section_Name = Section_Name, Time = Time, Building_Name = Building_Name };
                    professorSections.Add(section);
                }
            }

            sqlConnection1.Close();

            return professorSections;
        }