Beispiel #1
0
        public static List <OpeningTime> GetHolidayOpeningTimesByLocationID(long locationID)
        {
            DateTime holidayStartDate;
            DateTime?altOpenTime = null, altCloseTime = null;
            bool     closed;

            try
            {
                List <OpeningTime> openingTimes = new List <OpeningTime>();
                OpeningTime        openingTime;

                using (SqlConnection myConnection = new SqlConnection(Variables.CONNSTRING))
                {
                    myConnection.Open();

                    using (SqlCommand myCommand = new SqlCommand("SELECT_HolidayOpeningTimesByLocation", myConnection))
                    {
                        myCommand.CommandType = CommandType.StoredProcedure;

                        myCommand.Parameters.Add("@LocationID", SqlDbType.VarChar).Value = locationID;

                        SqlDataReader myReader = null;

                        myReader = myCommand.ExecuteReader();
                        while (myReader.Read())
                        {
                            //locationID = (long)myReader["LocationID"];
                            holidayStartDate = (DateTime)myReader["HolidayStartDate"];
                            altOpenTime      = Variables.GetNullableDateTime(myReader, "AltOpenTime");
                            altCloseTime     = Variables.GetNullableDateTime(myReader, "AltCloseTime");
                            //sqlDateTime = myReader["AltOpenTime"];
                            //altOpenTime = (sqlDateTime == System.DBNull.Value)
                            //    ? (DateTime?)null
                            //    : Convert.ToDateTime(sqlDateTime);
                            //sqlDateTime = myReader["AltCloseTime"];
                            //altCloseTime = (sqlDateTime == System.DBNull.Value)
                            //    ? (DateTime?)null
                            //    : Convert.ToDateTime(sqlDateTime);
                            closed      = (bool)myReader["Closed"];
                            openingTime = new OpeningTime(locationID, holidayStartDate, altOpenTime, altCloseTime, closed);
                            openingTimes.Add(openingTime);
                        }
                        return(openingTimes);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message);
            }
        }
Beispiel #2
0
        public static List <OpeningTime> GetHolidayOpeningTimes()
        {
            long     locationID;
            DateTime holidayStartDate;
            DateTime?altOpenTime = null, altCloseTime = null;
            bool     closed;

            try
            {
                List <OpeningTime> openingTimes = new List <OpeningTime>();
                OpeningTime        openingTime;

                using (SqlConnection myConnection = new SqlConnection(Variables.CONNSTRING))
                {
                    myConnection.Open();

                    SqlDataReader myReader = null;

                    SqlCommand myCommand = new SqlCommand("SELECT * FROM HolidayOpeningTimes", myConnection);

                    myReader = myCommand.ExecuteReader();

                    while (myReader.Read())
                    {
                        locationID       = (long)myReader["LocationID"];
                        holidayStartDate = (DateTime)myReader["HolidayStartDate"];
                        altOpenTime      = Variables.GetNullableDateTime(myReader, "AltOpenTime");
                        altCloseTime     = Variables.GetNullableDateTime(myReader, "AltCloseTime");
                        //if (myReader["AltOpenTime"] != null)
                        //{
                        //    altOpenTime = (DateTime?)myReader["AltOpenTime"];
                        //}
                        //if (myReader["AltCloseTime"] != null)
                        //{
                        //    altCloseTime = (DateTime?)myReader["AltCloseTime"];
                        //}
                        closed      = (bool)myReader["Closed"];
                        openingTime = new OpeningTime(locationID, holidayStartDate, altOpenTime, altCloseTime, closed);
                        openingTimes.Add(openingTime);
                    }
                    return(openingTimes);
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message);
            }
        }
Beispiel #3
0
        public static List <OpeningTime> GetOpeningTimesByLocationID(long locationID)
        {
            DateTime openTime, closeTime;
            int      dayOfWeek;
            bool     closed;

            try
            {
                List <OpeningTime> openingTimes = new List <OpeningTime>();
                OpeningTime        openingTime;

                using (SqlConnection myConnection = new SqlConnection(Variables.CONNSTRING))
                {
                    myConnection.Open();

                    using (SqlCommand myCommand = new SqlCommand("SELECT_OpeningTimesByLocation", myConnection))
                    {
                        myCommand.CommandType = CommandType.StoredProcedure;

                        myCommand.Parameters.Add("@LocationID", SqlDbType.VarChar).Value = locationID;

                        SqlDataReader myReader = null;

                        myReader = myCommand.ExecuteReader();
                        while (myReader.Read())
                        {
                            dayOfWeek   = (int)myReader["DayOfTheWeek"];
                            openTime    = (DateTime)myReader["OpenTime"];
                            closeTime   = (DateTime)myReader["CloseTime"];
                            closed      = (bool)myReader["Closed"];
                            openingTime = new OpeningTime(locationID, dayOfWeek, openTime, closeTime, closed);
                            openingTimes.Add(openingTime);
                        }
                        return(openingTimes);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message);
            }
        }
Beispiel #4
0
        public static List <OpeningTime> GetOpeningTimes()
        {
            long     locationID;
            DateTime openTime, closeTime;
            int      dayOfWeek;
            bool     closed;

            try
            {
                List <OpeningTime> openingTimes = new List <OpeningTime>();
                OpeningTime        openingTime;

                using (SqlConnection myConnection = new SqlConnection(Variables.CONNSTRING))
                {
                    myConnection.Open();

                    SqlDataReader myReader = null;

                    SqlCommand myCommand = new SqlCommand("SELECT * FROM OpeningTimes", myConnection);

                    myReader = myCommand.ExecuteReader();

                    while (myReader.Read())
                    {
                        locationID  = (long)myReader["LocationID"];
                        dayOfWeek   = (int)myReader["DayOfTheWeek"];
                        openTime    = (DateTime)myReader["OpenTime"];
                        closeTime   = (DateTime)myReader["CloseTime"];
                        closed      = (bool)myReader["Closed"];
                        openingTime = new OpeningTime(locationID, dayOfWeek, openTime, closeTime, closed);
                        openingTimes.Add(openingTime);
                    }
                    return(openingTimes);
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message);
            }
        }