Пример #1
0
        public static List <StudentTaskMark> loadTaskMarksFromThisSchool(SqlConnection connection, School school)
        {
            List <StudentTaskMark> returnMe = new List <StudentTaskMark>();

            SqlCommand sqlCommand = new SqlCommand();

            sqlCommand.Connection  = connection;
            sqlCommand.CommandType = CommandType.Text;
            sqlCommand.CommandText = "SELECT * FROM LSKY_TaskMarks WHERE SchoolGovID=@SCHOOLGOVID ORDER BY ClassName ASC, cLastName ASC, cFirstName ASC";
            sqlCommand.Parameters.AddWithValue("@SCHOOLGOVID", school.getGovIDAsString());
            sqlCommand.Connection.Open();
            SqlDataReader dataReader = sqlCommand.ExecuteReader();

            if (dataReader.HasRows)
            {
                while (dataReader.Read())
                {
                    SLReports.StudentTask.GradeType gradetype = StudentTask.GradeType.Numeric;
                    if (dataReader["GradeType"].ToString().Trim().ToLower() == "alpha")
                    {
                        gradetype = StudentTask.GradeType.Alpha;
                    }
                    else if (dataReader["GradeType"].ToString().Trim() == "numeric")
                    {
                        gradetype = StudentTask.GradeType.Numeric;
                    }

                    returnMe.Add(new StudentTaskMark(
                                     int.Parse(dataReader["TaskMarkID"].ToString().Trim()),
                                     dataReader["cStudentNumber"].ToString().Trim(),
                                     decimal.Parse(dataReader["fGrade"].ToString().Trim()),
                                     dataReader["mNote"].ToString().Trim(),
                                     new StudentTask(
                                         int.Parse(dataReader["iTaskID"].ToString().Trim()),
                                         dataReader["cTaskName"].ToString().Trim(),
                                         gradetype,
                                         DateTime.Parse(dataReader["dTaskDate"].ToString().Trim()),
                                         int.Parse(dataReader["iClassID"].ToString().Trim()),
                                         dataReader["ClassName"].ToString().Trim(),
                                         dataReader["SchoolGovID"].ToString().Trim(),
                                         dataReader["SchoolName"].ToString().Trim()
                                         )
                                     ));
                }
            }

            dataReader.Close();
            sqlCommand.Connection.Close();
            return(returnMe);
        }
Пример #2
0
        public static List <Student> loadReserveStudentsFromThisSchool(SqlConnection connection, School school)
        {
            List <Student> returnMe = new List <Student>();

            SqlCommand sqlCommand = new SqlCommand();

            sqlCommand.Connection  = connection;
            sqlCommand.CommandType = CommandType.Text;
            sqlCommand.CommandText = "SELECT * FROM LSKY_ActiveStudents WHERE ResideOnReserve=1 AND SchoolID=@SchoolID ORDER BY SchoolID ASC, Grade ASC;";
            sqlCommand.Parameters.AddWithValue("@SchoolID", school.getGovIDAsString());
            sqlCommand.Connection.Open();
            SqlDataReader dataReader = sqlCommand.ExecuteReader();

            if (dataReader.HasRows)
            {
                while (dataReader.Read())
                {
                    string HomeRoom  = dataReader["HomeRoom"].ToString().Trim();
                    string HRT_Title = dataReader["HomeRoomTeacherTitle"].ToString().Trim();
                    string HRT_First = dataReader["HomeRoomTeacherFirstName"].ToString().Trim();
                    string HRT_Last  = dataReader["HomeRoomTeacherLastName"].ToString().Trim();
                    if ((!string.IsNullOrEmpty(HRT_First)) && (!string.IsNullOrEmpty(HRT_Last)))
                    {
                        HomeRoom = HomeRoom + " (";
                        if ((!string.IsNullOrEmpty(HRT_Title)))
                        {
                            HomeRoom = HomeRoom + HRT_Title;
                        }
                        else
                        {
                            HomeRoom = HomeRoom + HRT_First;
                        }

                        HomeRoom = HomeRoom + " " + HRT_Last + ")";
                    }
                    bool hasPhoto = false;
                    if (!string.IsNullOrEmpty(dataReader["PhotoType"].ToString()))
                    {
                        hasPhoto = true;
                    }

                    int credits = 0;
                    int.TryParse(dataReader["Credits"].ToString(), out credits);

                    Student newStudent = new Student(
                        dataReader["FirstName"].ToString().Trim(),
                        dataReader["LastName"].ToString().Trim(),
                        dataReader["LegalFirstName"].ToString().Trim(),
                        dataReader["LegalLastName"].ToString().Trim(),
                        dataReader["LegalMiddleName"].ToString(),
                        dataReader["StudentNumber"].ToString().Trim(),
                        dataReader["GovernmentIDNumber"].ToString().Trim(),
                        dataReader["School"].ToString().Trim(),
                        dataReader["SchoolID"].ToString().Trim(),
                        dataReader["Grade"].ToString().Trim(),
                        dataReader["Region"].ToString().Trim(),
                        dataReader["City"].ToString().Trim(),
                        dataReader["Street"].ToString().Trim(),
                        dataReader["HouseNo"].ToString().Trim(),
                        dataReader["ApartmentNo"].ToString().Trim(),
                        dataReader["PostalCode"].ToString().Trim(),
                        dataReader["Phone"].ToString().Trim(),
                        dataReader["Gender"].ToString().Trim(),
                        dataReader["InStatus"].ToString().Trim(),
                        dataReader["InStatusCode"].ToString().Trim(),
                        dataReader["HomeRoom"].ToString().Trim(),
                        DateTime.Parse(dataReader["InDate"].ToString()),
                        DateTime.Parse(dataReader["DateOfBirth"].ToString()),
                        dataReader["BandNo"].ToString().Trim(),
                        dataReader["BandName"].ToString().Trim(),
                        dataReader["ReserveName"].ToString().Trim(),
                        dataReader["ReserveHouse"].ToString().Trim(),
                        dataReader["StatusNo"].ToString().Trim(),
                        bool.Parse(dataReader["ResideOnReserve"].ToString()),
                        int.Parse(dataReader["TrackID"].ToString()),
                        hasPhoto,
                        dataReader["cUserName"].ToString().Trim(),
                        credits,
                        int.Parse(dataReader["iActive_StudentStatusID"].ToString()),
                        dataReader["AboriginalStatus"].ToString().Trim(),
                        dataReader["LanguageHome"].ToString().Trim(),
                        dataReader["ParkingPermit"].ToString().Trim(),
                        dataReader["cLockerNumber"].ToString().Trim(),
                        dataReader["cLockerCombination"].ToString().Trim()
                        );
                    returnMe.Add(newStudent);
                }
            }

            sqlCommand.Connection.Close();
            return(returnMe);
        }