Ejemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!GlobalHandlers.SessionHandler.isLoggedIn())
     {
         Response.Redirect("~/admin/login/default.aspx", false);
         return;
     }
     if (!IsPostBack)
     {
         //initial load...
         //lets add to the filters
         filter = GlobalHandlers.DatabaseHandler.getFilters();
         foreach (Filter f in filter)
         {
             filters.Items.Add(f.Name);
         }
         try {
             if (Request.QueryString["date"] != null)
             {
                 //then its there, redrictced possibly, lets parse it.
                 DateTime dateT;
                 DateTimeRoutines.TryParseDate(Request.QueryString["date"], DateTimeRoutines.DateTimeFormat.USA_DATE, out dateT);
                 if (dateT != null)
                 {
                     //parsed successfully.
                     //lets set Date.Text to the date
                     date.Text = dateT.Month + "/" + dateT.Day + "/" + dateT.Year;
                 }
             }
         }
         catch (Exception eee)
         {
         }
     }
     else if (IsPostBack)
     {
         //yes this is a post back, so lets load our forms
         title.Text = Request.Form["title"].ToString();
         date.Text  = Request.Form["date"].ToString();
         filter     = GlobalHandlers.DatabaseHandler.getFilters();
     }
 }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string   loadNumber  = String.Empty;
            ListItem forSelected = null;

            try
            {
                if (Request.QueryString["date"] != null)
                {
                    string date      = Request.QueryString["date"].ToString();
                    string monthName = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(DateTime.Now.Month);
                    string toset     = monthName + " " + date + " " + DateTime.Now.Year;
                    loadNumber = date;
                    date       = toset;
                    loadDate   = date;
                    loadToday  = false;
                    DateTime n = new DateTime(DateTime.Now.Year, DateTime.Now.Month, Int32.Parse(loadNumber));
                    forSelected = new ListItem(n.DayOfWeek.ToString() + ", " + monthName + " " + n.Day, n.Day + "");
                }
            }
            catch (Exception eee)
            {
                GlobalHandlers.Debugger.write(eee.ToString());
            }

            setupDefaultHeader();
            if (loadToday)
            {
                Date.Text = "Lunch menu for: " + DateTime.Now.ToString("dddd, MMMMM d");
                if (DateTime.Now.isWeekday())
                {
                    string[] lunchItems = GlobalHandlers.DatabaseHandler.getListOfItemsForToday();

                    if (lunchItems == null)
                    {
                        panel.Controls.Add(new LiteralControl("<tr><td>No information</td></tr>"));
                        return;
                    }

                    foreach (string item in lunchItems)
                    {
                        panel.Controls.Add(new LiteralControl("<tr><td>" + item + "</td></tr>"));
                    }
                }
                else
                {
                    panel.Controls.Add(new LiteralControl("<tr><td>No information</td></tr>"));
                }
            }
            else if (!loadToday)
            {
                DateTime d;
                DateTimeRoutines.TryParseDate(loadDate, DateTimeRoutines.DateTimeFormat.USA_DATE, out d);
                GlobalHandlers.Debugger.write("getting this far loadDate:" + loadDate);
                if (d == null)
                {
                    panel.Controls.Add(new LiteralControl("<tr><td>No information</td></tr>"));
                    return;
                }
                Date.Text = "Lunch menu for: " + d.ToString("dddd, MMMMM d");
                if (d.isWeekday())
                {
                    string[] lunchItems = GlobalHandlers.DatabaseHandler.getListOfItemsForADay(loadNumber);
                    if (lunchItems == null)
                    {
                        panel.Controls.Add(new LiteralControl("<tr><td>No information</td></tr>"));
                        return;
                    }

                    foreach (string item in lunchItems)
                    {
                        panel.Controls.Add(new LiteralControl("<tr><td>" + item + "</td></tr>"));
                    }
                }
                else
                {
                    panel.Controls.Add(new LiteralControl("<tr><td>No information</td></tr>"));
                }
            }
            foreach (DateTime day in AllDatesInMonth(DateTime.Now.Year, DateTime.Now.Month))
            {
                if (day.isWeekday() && day >= DateTime.Now)
                {
                    combo.Items.Add(new ListItem(day.DayOfWeek.ToString() + ", " + DateTime.Now.ToString("MMMM") + " " + day.Day, day.Day + ""));
                }
            }
            combo.SelectedIndex = combo.Items.IndexOf(forSelected);
        }