Exemple #1
0
 public static List<Class> getClass(string tutor)
 {
     List<Class> classList = new List<Class>();
     //Connect to SQL Server
     SqlConnection conn = new SqlConnection("Data Source=PANDORASBOX\\PANDORASBOX; Database=WebDevelopmentDB; Integrated Security=SSPI");
     conn.Open();
     ClassRoster roster = new ClassRoster(int.Parse(tutor));
     //Select all columns for a given StaffID as well as their password hash
     for (int i = 0; i <= roster.Roster.GetLength(0); i++) {
         SqlCommand cmd = new SqlCommand("SELECT ClassCode, Day, Time, Semester, TutorID FROM dbo.ClassList WHERE (ClassCode = " + roster.Roster[i, 0] + ")", conn);
         SqlDataReader rdr = cmd.ExecuteReader();
         while (rdr.Read()) {
             classList.Add(new Class {
                 ClassCode = rdr[0].ToString(),
                 Day = rdr[1].ToString(),
                 Time = rdr[2].ToString(),
                 Semester = rdr[3].ToString(),
                 TutorID = rdr[4].ToString()
             });
         }
         //Close the reader and the SQL connection
         if (rdr != null) {
             rdr.Close();
         }
         conn.Close();
     }
     return classList;
 }
 public static void updateClassRoster(ClassRoster classRoster)
 {
     System.Diagnostics.Trace.WriteLine(classRoster, "Update");
 }
 public static void insertClassRoster(ClassRoster classRoster)
 {
     System.Diagnostics.Trace.WriteLine(classRoster, "Insert");
 }