Ejemplo n.º 1
0
        public ClassDetails GetFullClassDetails(int classId)
        {
            Connection();
            Class classModel = new Class();

            SqlCommand cmd = new SqlCommand("Project.GetFullClassDetailsByClass", con)
            {
                CommandType = CommandType.StoredProcedure
            };

            cmd.Parameters.AddWithValue("@ClassId", classId);

            SqlDataAdapter sd = new SqlDataAdapter(cmd);
            DataTable      dt = new DataTable();

            con.Open();
            sd.Fill(dt);
            con.Close();

            if (dt.Rows.Count > 0)
            {
                DataRow dr = dt.Rows[0];
                return(new ClassDetails
                {
                    ClassName = Convert.ToString(dr["ClassName"]),
                    ClassId = Convert.ToInt32(dr["ClassId"]),
                    FirstName = Convert.ToString(dr["FirstName"]),
                    LastName = Convert.ToString(dr["LastName"]),
                    TermName = Convert.ToString(dr["TermName"]),
                    Days = ClassDetails.ConvertBitsToDays(Convert.ToInt32(dr["Days"])),
                    StartTime = TimeSpan.Parse(Convert.ToString(dr["StartTime"])),
                    EndTime = TimeSpan.Parse(Convert.ToString(dr["EndTime"])),
                    Building = Convert.ToString(dr["Building"]),
                    RoomNumber = Convert.ToInt32(dr["RoomNumber"])
                });
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
        public List <ClassDetails> GetStudentClassDetails(int studentId)
        {
            Connection();
            Student student = new Student();

            SqlCommand cmd = new SqlCommand("Project.GetFullClassDetailsByStudent", con)
            {
                CommandType = CommandType.StoredProcedure
            };

            cmd.Parameters.AddWithValue("@StudentId", studentId);

            SqlDataAdapter sd = new SqlDataAdapter(cmd);
            DataTable      dt = new DataTable();

            con.Open();
            sd.Fill(dt);
            con.Close();

            List <ClassDetails> classDetails = new List <ClassDetails>();

            foreach (DataRow dr in dt.Rows)
            {
                classDetails.Add(new ClassDetails
                {
                    ClassName  = Convert.ToString(dr["ClassName"]),
                    ClassId    = Convert.ToInt32(dr["ClassId"]),
                    FirstName  = Convert.ToString(dr["FirstName"]),
                    LastName   = Convert.ToString(dr["LastName"]),
                    TermName   = Convert.ToString(dr["TermName"]),
                    Days       = ClassDetails.ConvertBitsToDays(Convert.ToInt32(dr["Days"])),
                    StartTime  = TimeSpan.Parse(Convert.ToString(dr["StartTime"])),
                    EndTime    = TimeSpan.Parse(Convert.ToString(dr["EndTime"])),
                    Building   = Convert.ToString(dr["Building"]),
                    RoomNumber = Convert.ToInt32(dr["RoomNumber"])
                });
            }

            return(classDetails);
        }
Ejemplo n.º 3
0
        public List <ClassDetails> GetFilteredClasses(string firstName, string lastName, string department, string days, string startTime, string endTime, string termName, string termYear, string type)
        {
            Connection();
            List <ClassDetails> classlist = new List <ClassDetails>();

            SqlCommand cmd = new SqlCommand("Project.GetFilteredClasses", con)
            {
                CommandType = CommandType.StoredProcedure
            };

            if (department != "")
            {
                cmd.Parameters.AddWithValue("@Department", department);
            }
            if (firstName != "")
            {
                cmd.Parameters.AddWithValue("@FirstName", firstName);
            }
            if (lastName != "")
            {
                cmd.Parameters.AddWithValue("@LastName", lastName);
            }
            if (startTime != "")
            {
                cmd.Parameters.AddWithValue("@StartTime", startTime);
            }
            if (endTime != "")
            {
                cmd.Parameters.AddWithValue("@EndTime", endTime);
            }
            if (days != "")
            {
                cmd.Parameters.AddWithValue("@Days", ClassDetails.ConvertDaysToBits(days));
            }
            if (termName != "")
            {
                cmd.Parameters.AddWithValue("@TermName", termName);
            }
            if (termYear != "")
            {
                cmd.Parameters.AddWithValue("@TermYear", termYear);
            }
            if (type != "")
            {
                cmd.Parameters.AddWithValue("@Type", type);
            }

            SqlDataAdapter sd = new SqlDataAdapter(cmd);
            DataTable      dt = new DataTable();

            con.Open();
            sd.Fill(dt);
            con.Close();
            foreach (DataRow dr in dt.Rows)
            {
                classlist.Add(
                    new ClassDetails
                {
                    ClassName  = Convert.ToString(dr["ClassName"]),
                    ClassId    = Convert.ToInt32(dr["ClassId"]),
                    FirstName  = Convert.ToString(dr["FirstName"]),
                    LastName   = Convert.ToString(dr["LastName"]),
                    TermName   = Convert.ToString(dr["TermName"]),
                    Days       = ClassDetails.ConvertBitsToDays(Convert.ToInt32(dr["Days"])),
                    StartTime  = TimeSpan.Parse(Convert.ToString(dr["StartTime"])),
                    EndTime    = TimeSpan.Parse(Convert.ToString(dr["EndTime"])),
                    Building   = Convert.ToString(dr["Building"]),
                    RoomNumber = Convert.ToInt32(dr["RoomNumber"])
                });
            }
            return(classlist);
        }