Ejemplo n.º 1
0
        public static List <Term> loadTermsFromThisSchool(SqlConnection connection, School school)
        {
            List <Term> returnMe = new List <Term>();

            SqlCommand sqlCommand = new SqlCommand();

            sqlCommand.Connection  = connection;
            sqlCommand.CommandType = CommandType.Text;
            sqlCommand.CommandText = "SELECT * FROM Term WHERE iSchoolID=" + school.getSchoolLogicID() + "";
            sqlCommand.Connection.Open();
            SqlDataReader dataReader = sqlCommand.ExecuteReader();

            if (dataReader.HasRows)
            {
                while (dataReader.Read())
                {
                    returnMe.Add(new Term(
                                     int.Parse(dataReader["iTermID"].ToString().Trim()),
                                     int.Parse(dataReader["iTrackID"].ToString().Trim()),
                                     DateTime.Parse(dataReader["dStartDate"].ToString()),
                                     DateTime.Parse(dataReader["dEndDate"].ToString()),
                                     dataReader["cName"].ToString().Trim(),
                                     int.Parse(dataReader["iSchoolID"].ToString().Trim())
                                     ));
                }
            }

            sqlCommand.Connection.Close();
            return(returnMe);
        }
        public static List <ReportPeriod> loadReportPeriodsFromThisSchool(SqlConnection connection, School school)
        {
            List <ReportPeriod> returnMe = new List <ReportPeriod>();

            SqlCommand sqlCommand = new SqlCommand();

            sqlCommand.Connection  = connection;
            sqlCommand.CommandType = CommandType.Text;
            sqlCommand.CommandText = "SELECT * FROM ReportPeriod WHERE iSchoolID=" + school.getSchoolLogicID() + "";
            sqlCommand.Connection.Open();
            SqlDataReader dataReader = sqlCommand.ExecuteReader();

            if (dataReader.HasRows)
            {
                while (dataReader.Read())
                {
                    returnMe.Add(new ReportPeriod(
                                     int.Parse(dataReader["iReportPeriodID"].ToString().Trim()),
                                     dataReader["cName"].ToString().Trim(),
                                     DateTime.Parse(dataReader["dStartDate"].ToString()),
                                     DateTime.Parse(dataReader["dEndDate"].ToString()),
                                     int.Parse(dataReader["iSchoolID"].ToString().Trim()),
                                     int.Parse(dataReader["iTermID"].ToString().Trim())
                                     ));
                }
            }

            sqlCommand.Connection.Close();
            foreach (ReportPeriod rp in returnMe)
            {
                rp.loadReportPeriodSettings(connection);
            }
            return(returnMe);
        }
Ejemplo n.º 3
0
        public static List <Track> loadAllTracksFromThisSchool(SqlConnection connection, School thisSchool)
        {
            List <Track> returnMe = new List <Track>();

            SqlCommand sqlCommand = new SqlCommand();

            sqlCommand.Connection  = connection;
            sqlCommand.CommandType = CommandType.Text;
            sqlCommand.CommandText = "SELECT * FROM Track WHERE iSchoolID=@SCHOOL ORDER BY iSchoolID ASC, cName ASC;";
            sqlCommand.Parameters.AddWithValue("@SCHOOL", thisSchool.getSchoolLogicID());
            sqlCommand.Connection.Open();
            SqlDataReader dataReader = sqlCommand.ExecuteReader();

            if (dataReader.HasRows)
            {
                while (dataReader.Read())
                {
                    Track newTrack = new Track(
                        int.Parse(dataReader["iTrackID"].ToString().Trim()),
                        dataReader["cName"].ToString().Trim(),
                        DateTime.Parse(dataReader["dStartDate"].ToString()),
                        DateTime.Parse(dataReader["dEndDate"].ToString()),
                        int.Parse(dataReader["iSchoolID"].ToString().Trim()),
                        bool.Parse(dataReader["lDaily"].ToString().Trim()),
                        dataReader["cCode"].ToString().Trim(),
                        int.Parse(dataReader["iDaysInCycle"].ToString().Trim()),
                        int.Parse(dataReader["iBlocksPerDay"].ToString().Trim()),
                        int.Parse(dataReader["iDailyBlocksPerDay"].ToString().Trim())
                        );

                    newTrack.school = thisSchool;

                    returnMe.Add(newTrack);
                }
            }

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