예제 #1
0
        protected void GetClassScheduleData()
        {
            List <ClassSchedule> schedule = ClassSchedule.GetClassScheduleData();

            gridView_Schedule.DataSource = schedule;
            gridView_Schedule.DataBind();
            //removes the default border="1" from the generated grid view
            gridView_Schedule.GridLines = GridLines.None;
            //sets cellspacing to zero
            gridView_Schedule.CellSpacing = 0;
        }
예제 #2
0
        public static List <ClassSchedule> GetClassScheduleData()
        {
            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["db"].ConnectionString);
            SqlCommand    cmd  = new SqlCommand("spClassScheduleDisplay", conn);

            cmd.CommandType = CommandType.StoredProcedure;
            List <ClassSchedule> schedule = new List <ClassSchedule>();

            try
            {
                conn.Open();
                SqlDataReader rdr = cmd.ExecuteReader();
                while (rdr.Read())
                {
                    ClassSchedule cs = new ClassSchedule();
                    cs.sectName      = rdr["SectionName"].ToString();
                    cs.credhrs       = Convert.ToInt32(rdr["CreditHrs"]);
                    cs.courseName    = rdr["CourseName"].ToString();
                    cs.totalSeats    = Convert.ToInt32(rdr["TotalSeats"]);
                    cs.room          = rdr["Room"].ToString();
                    cs.days          = rdr["Days"].ToString();
                    cs.startTime     = rdr["StartTime"].ToString();
                    cs.endTime       = rdr["EndTime"].ToString();
                    cs.teachFullName = rdr["TeachFullName"].ToString();
                    cs.location      = rdr["Location"].ToString();
                    schedule.Add(cs);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
            finally
            {
                cmd.Dispose();
                conn.Close();
            }
            return(schedule);
        }