//protected void ProdCalendar1_ControlSaved(object sender, ControlSavedEventArgs e)
        //{
        //    lblFeedback.Text = "Calendar saved: " + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss");
        //    btnAddNewProdCal.Visible = true;
        //    pnlEditProdCal.Visible = false;
        //    pnlProdCalList.Visible = true;

        //    ProdCalendar1.Clear();

        //    BindgvwProdCalendars();
        //}

        //protected void ProdCalendar1_ControlCancelled(object sender)
        //{
        //    btnAddNewProdCal.Visible = true;
        //    pnlEditProdCal.Visible = false;
        //    pnlProdCalList.Visible = true;

        //    ProdCalendar1.Clear();
        //}

        //void gvwProdCalendars_RowDeleting(object sender, GridViewDeleteEventArgs e)
        //{
        //    try
        //    {
        //        //int menuItemId = int.Parse(e.Keys[0].ToString());
        //        //hccProgram del = hccProgram.GetById(menuItemId);

        //        //if (del != null)
        //        //{
        //        //    del.Retire(true);
        //        //    BindgvwProdCalendars();
        //        //}
        //    }
        //    catch (Exception)
        //    {
        //        throw;
        //    }
        //}

        //void gvwProdCalendars_SelectedIndexChanged(object sender, EventArgs e)
        //{
        //    try
        //    {
        //        //int menuItemId = int.Parse(gvwProdCalendars.SelectedDataKey.Value.ToString());

        //        //ProdCalendar1.PrimaryKeyIndex = menuItemId;
        //        //ProdCalendar1.Bind();

        //        //btnAddNewProdCal.Visible = false;
        //        //pnlEditProdCal.Visible = true;
        //        //pnlProdCalList.Visible = false;
        //    }
        //    catch (Exception)
        //    {
        //        throw;
        //    }
        //}

        //void gvwProdCalendars_RowCreated(object sender, GridViewRowEventArgs e)
        //{
        //    //if (e.Row.RowType == DataControlRowType.DataRow)
        //    //{
        //    //    LinkButton lkbDelete = e.Row.Cells[2].Controls.OfType<LinkButton>().SingleOrDefault(a => a.Text == "Retire");

        //    //    if (lkbDelete != null)
        //    //        lkbDelete.Attributes.Add("onclick", "return confirm('Are you sure that you want to retire this calendar?');");
        //    //}
        //}

        //void gvwProdCalendars_PageIndexChanging(object sender, GridViewPageEventArgs e)
        //{
        //    //gvwProdCalendars.PageIndex = e.NewPageIndex;
        //    BindgvwProdCalendars();
        //}

        void btnBatchNewProdCals_Click(object sender, EventArgs e)
        {
            DateTime        lastDelDate = hccProductionCalendar.GetAll().Max(a => a.DeliveryDate);
            DateTime        endDate     = lastDelDate.AddYears(1);
            List <DateTime> dates       = new List <DateTime>();

            for (DateTime date = lastDelDate.AddDays(1); date <= endDate; date = date.AddDays(1))
            {
                if (date.DayOfWeek == DayOfWeek.Friday)
                {
                    dates.Add(date);
                }
            }

            dates.ForEach(delegate(DateTime date)
            {
                hccProductionCalendar CurrentProductionCalendar = new hccProductionCalendar();

                CurrentProductionCalendar.Name            = "Delivery Date " + date.ToShortDateString();
                CurrentProductionCalendar.DeliveryDate    = date;
                CurrentProductionCalendar.OrderCutOffDate = date.AddDays(-8);

                CurrentProductionCalendar.Save();
            });

            BindgvwProdCalendars();
        }
        void BindddlDelDates()
        {
            if (ddlDelDates.Items.Count == 0)
            {
                ddlDelDates.DataSource           = hccProductionCalendar.GetAll();
                ddlDelDates.DataTextField        = "DeliveryDate";
                ddlDelDates.DataTextFormatString = "{0:MM/dd/yyyy}";
                ddlDelDates.DataValueField       = "CalendarId";
                ddlDelDates.DataBind();

                try
                {
                    hccProductionCalendar next = hccProductionCalendar.GetNextCalendar();
                    ListItem li = ddlDelDates.Items.FindByValue(next.CalendarID.ToString());

                    if (li != null)
                    {
                        li.Selected = true;
                    }
                }
                catch (Exception)
                {
                    throw;
                }
                //ddlDelDates.Items.Insert(0, new ListItem("Select a Delivery Date...", "-1"));
            }
        }
        protected void ButtonRefresh_Click(object sender, EventArgs e)
        {
            hccProductionCalendar cal = hccProductionCalendar.GetBy(DateTime.Parse(txtStartDate.Text));

            if (cal != null)
            {
                cM.CurrentCalendarId = cal.CalendarID;
            }

            cM.CurrentCartItem = hccCartItem.GetById(int.Parse(ddlCustomers.SelectedItem.Value));

            if (cM.CurrentCartItem.Plan_PlanID != null)
            {
                hccProgramPlan plan    = hccProgramPlan.GetById(cM.CurrentCartItem.Plan_PlanID.Value);
                hccProgram     program = hccProgram.GetById(plan.ProgramID);

                if (plan != null && program != null)
                {
                    // load user profile data
                    hccUserProfile profile = cM.CurrentCartItem.UserProfile;
                    hccUserProfile parent  = hccUserProfile.GetParentProfileBy(profile.MembershipID);

                    lblOrderData.Text = string.Format("Order #{0}: {1}/{2}",
                                                      cM.CurrentCartItem.OrderNumber, program.Name, plan.Name);
                    lblCustData.Text = string.Format("For: {0}, {1} ({2})  Delivery Date: {3}",
                                                     parent.LastName, parent.FirstName, profile.ProfileName, txtStartDate.Text); //cM.CurrentCartItem.DeliveryDate.ToShortDateString()

                    defaultMenuSelections = hccProgramDefaultMenu.GetBy(cM.CurrentCalendarId, program.ProgramID);

                    days = cM.BindWeeklyGlance(defaultMenuSelections, plan.NumDaysPerWeek, int.Parse(ddlCustomers.SelectedValue));
                    lvCustomerMealReport.DataSource = days;
                    lvCustomerMealReport.DataBind();
                }
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         hccProductionCalendar nextProdCal = hccProductionCalendar.GetNext4Last2Calendars()[1];
         txtStartDate.Text = nextProdCal == null?DateTime.Now.ToShortDateString() : nextProdCal.DeliveryDate.ToShortDateString();
     }
 }
        protected void cstName_ServerValidate(object source, ServerValidateEventArgs args)
        {
            hccProductionCalendar existCal = hccProductionCalendar.GetBy(txtCalendarName.Text.Trim());

            if (existCal != null && existCal.CalendarID != this.PrimaryKeyIndex)
            {
                args.IsValid = false;
            }
        }
        void ddlDeliveryDates_SelectedIndexChanged(object sender, EventArgs e)
        {
            int prodCalId = int.Parse(ddlDeliveryDates.SelectedValue);

            if (prodCalId > 0)
            {
                cal = hccProductionCalendar.GetById(prodCalId);

                BindddlMenuItems(cal.MenuID);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                hccProductionCalendar nextProdCal = hccProductionCalendar.GetNext4Calendars().FirstOrDefault();

                txtStartDate.Text = nextProdCal == null?DateTime.Now.ToShortDateString() : nextProdCal.DeliveryDate.AddDays(-1).ToShortDateString();

                txtEndDate.Text = nextProdCal == null?DateTime.Now.ToShortDateString() : nextProdCal.DeliveryDate.ToShortDateString();

                ButtonRefresh_Click(this, new EventArgs());
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                hccProductionCalendar nextProdCal = hccProductionCalendar.GetNext4Calendars().FirstOrDefault();

                txtStartDate.Text = nextProdCal == null?DateTime.Now.ToShortDateString() : nextProdCal.DeliveryDate.ToShortDateString();

                txtEndDate.Text = nextProdCal == null?DateTime.Now.ToShortDateString() : nextProdCal.DeliveryDate.ToShortDateString();

                BindddlMealTypes();
            }
        }
Exemple #9
0
        void BindddlMenuItems()
        {
            hccProductionCalendar cal = hccProductionCalendar.GetBy(CurrentCartItem.DeliveryDate);

            ddlMenuItems.ClearSelection();
            ddlMenuItems.Items.Clear();

            ddlMenuItems.DataSource     = hccMenuItem.GetByMenuId(cal.MenuID).Where(mi => !hccMenuItem.SideMealTypes.Contains(mi.MealType) && !mi.IsRetired);
            ddlMenuItems.DataTextField  = "TypeAndName";
            ddlMenuItems.DataValueField = "MenuItemID";
            ddlMenuItems.DataBind();

            ddlMenuItems.Items.Insert(0, new ListItem("Select a Menu Item...", "-1"));
            ddlMenuItems.Enabled = true;
        }
        protected override void LoadForm()
        {
            //PrimaryKeyIndex = Convert.ToInt32(CurrentCalendarId.Value);
            CurrentProductionCalendar = hccProductionCalendar.GetById(PrimaryKeyIndex);

            if (CurrentProductionCalendar != null)
            {
                BindDdlMenus();
                txtCalendarName.Text      = CurrentProductionCalendar.Name;
                ddlMenus.SelectedIndex    = ddlMenus.Items.IndexOf(ddlMenus.Items.FindByValue(CurrentProductionCalendar.MenuID.ToString()));
                txtOrderCutOffDate.Text   = CurrentProductionCalendar.OrderCutOffDate.ToString("MM/dd/yyyy");
                txtOrderDeliveryDate.Text = CurrentProductionCalendar.DeliveryDate.ToString("MM/dd/yyyy");
                txtDescription.Text       = CurrentProductionCalendar.Description;
            }
        }
        protected override void SaveForm()
        {
            CurrentProductionCalendar = hccProductionCalendar.GetById(PrimaryKeyIndex);

            if (CurrentProductionCalendar == null)
            {
                CurrentProductionCalendar = new hccProductionCalendar();
            }

            CurrentProductionCalendar.Name            = txtCalendarName.Text.Trim();
            CurrentProductionCalendar.Description     = txtDescription.Text.Trim();
            CurrentProductionCalendar.DeliveryDate    = DateTime.Parse(txtOrderDeliveryDate.Text.Trim());
            CurrentProductionCalendar.OrderCutOffDate = DateTime.Parse(txtOrderCutOffDate.Text.Trim());
            CurrentProductionCalendar.MenuID          = int.Parse(ddlMenus.SelectedValue);

            int calId = CurrentProductionCalendar.Save();

            OnSaved(new ControlSavedEventArgs(calId));
        }
        void BindDropDownLists(List <hccAllergen> userAllergens)
        {
            try
            {
                if (CurrentProgramId > 0 && CurrentCalendarId > 0)
                {
                    hccProgram            program = hccProgram.GetById(CurrentProgramId);
                    hccProductionCalendar cal     = hccProductionCalendar.GetById(CurrentCalendarId);

                    hccMenu menu = cal.GetMenu();

                    if (program != null && menu != null)
                    {
                        List <hccProgramMealType> requiredMealTypes = hccProgramMealType.GetBy(program.ProgramID)
                                                                      .Where(a => a.RequiredQuantity > 0).ToList();
                        int day = int.Parse(rdoDays.SelectedValue);

                        // Display for selected day
                        pnlDefaultMenu.CssClass += " dayPanel";
                        HtmlGenericControl pName = new HtmlGenericControl("p");
                        pName.Attributes.Add("class", "dayName label");
                        pName.InnerText = "Day " + day.ToString();
                        pnlDefaultMenu.Controls.Add(pName);
                        pnlDefaultMenu.Controls.Add(new HtmlGenericControl("hr"));

                        requiredMealTypes.ForEach(delegate(hccProgramMealType mealType)
                        {
                            HtmlGenericControl liType = new HtmlGenericControl("li");
                            liType.InnerText          = ((Enums.MealTypes)mealType.MealTypeID).ToString() + ": " + mealType.RequiredQuantity.ToString();

                            HtmlGenericControl mealTypespan = new HtmlGenericControl("span");
                            mealTypespan.InnerHtml          = "<b>" + ((Enums.MealTypes)mealType.MealTypeID).ToString() + "</b>";
                            pnlDefaultMenu.Controls.Add(mealTypespan);

                            int i = 1;
                            while (i <= mealType.RequiredQuantity)
                            {
                                // container for meanu item
                                HtmlGenericControl divItemContainer = new HtmlGenericControl("div");
                                divItemContainer.Attributes.Add("class", "divItemContainer");
                                pnlDefaultMenu.Controls.Add(divItemContainer);

                                // container for ddl
                                HtmlGenericControl divDdl = new HtmlGenericControl("div");
                                divDdl.Attributes.Add("class", "divDdl");
                                divItemContainer.Controls.Add(divDdl);

                                DropDownList ddlMealItem = new DropDownList();
                                ddlMealItem.CssClass     = "mealItemDdl";
                                ddlMealItem.Attributes.Add("calId", CurrentCalendarId.ToString());
                                ddlMealItem.Attributes.Add("progId", CurrentProgramId.ToString());
                                ddlMealItem.Attributes.Add("day", day.ToString());
                                ddlMealItem.Attributes.Add("type", mealType.MealTypeID.ToString());
                                ddlMealItem.Attributes.Add("ord", i.ToString());

                                List <hccMenuItem> menuItems = hccMenuItem.GetByMenuId(menu.MenuID)
                                                               .Where(a => a.MealTypeID == mealType.MealTypeID).OrderBy(a => a.Name).ToList();

                                List <ListItem> menuItemsWithSizes = new List <ListItem>();

                                menuItems.ForEach(delegate(hccMenuItem mainItem)
                                {
                                    hccMenuItem menuItem = hccMenuItem.GetById(mainItem.MenuItemID);
                                    bool hasAllergen     = false;
                                    ListItem lItem       = null;

                                    if (menuItem != null)
                                    {
                                        List <hccAllergen> matchAllergens    = new List <hccAllergen>();
                                        List <hccAllergen> menuItemAllergens = menuItem.GetAllergens();
                                        matchAllergens = menuItemAllergens.Intersect(userAllergens).ToList();

                                        if (matchAllergens.Count > 0)
                                        {
                                            hasAllergen = true;
                                        }
                                    }

                                    lItem = new ListItem(mainItem.Name + " : "
                                                         + Enums.CartItemSize.ChildSize.ToString(), mainItem.MenuItemID.ToString() + "-"
                                                         + ((int)Enums.CartItemSize.ChildSize).ToString());
                                    if (hasAllergen)
                                    {
                                        lItem.Attributes["class"] += " redFont";
                                    }
                                    menuItemsWithSizes.Add(lItem);

                                    lItem = new ListItem(mainItem.Name + " : "
                                                         + Enums.CartItemSize.SmallSize.ToString(), mainItem.MenuItemID.ToString() + "-"
                                                         + ((int)Enums.CartItemSize.SmallSize).ToString());
                                    if (hasAllergen)
                                    {
                                        lItem.Attributes["class"] += " redFont";
                                    }
                                    menuItemsWithSizes.Add(lItem);

                                    lItem = new ListItem(mainItem.Name + " : "
                                                         + Enums.CartItemSize.RegularSize.ToString(), mainItem.MenuItemID.ToString() + "-"
                                                         + ((int)Enums.CartItemSize.RegularSize).ToString());
                                    if (hasAllergen)
                                    {
                                        lItem.Attributes["class"] += " redFont";
                                    }
                                    menuItemsWithSizes.Add(lItem);

                                    lItem = new ListItem(mainItem.Name + " : "
                                                         + Enums.CartItemSize.LargeSize.ToString(), mainItem.MenuItemID.ToString() + "-"
                                                         + ((int)Enums.CartItemSize.LargeSize).ToString());
                                    if (hasAllergen)
                                    {
                                        lItem.Attributes["class"] += " redFont";
                                    }
                                    menuItemsWithSizes.Add(lItem);
                                });

                                ddlMealItem.DataSource     = new List <ListItem>();
                                ddlMealItem.DataTextField  = "Text";
                                ddlMealItem.DataValueField = "Value";
                                ddlMealItem.DataBind();

                                ddlMealItem.Items.AddRange(menuItemsWithSizes.ToArray());
                                ddlMealItem.Items.Insert(0, new ListItem("None", "0"));

                                divDdl.Controls.Add(ddlMealItem);

                                // container for nutrition
                                HtmlGenericControl divNuts = new HtmlGenericControl("div");
                                divNuts.Attributes.Add("class", "divNuts");
                                divItemContainer.Controls.Add(divNuts);

                                // container for allergens
                                HtmlGenericControl divAllrgs = new HtmlGenericControl("div");
                                divAllrgs.Attributes.Add("class", "divAllrgs");
                                divItemContainer.Controls.Add(divAllrgs);

                                // container for prefs
                                HtmlGenericControl divPrefs = new HtmlGenericControl("div");
                                divPrefs.Attributes.Add("class", "divPrefs");
                                divItemContainer.Controls.Add(divPrefs);

                                divItemContainer.Controls.Add(new HtmlGenericControl("p"));

                                i++;
                            }

                            pnlDefaultMenu.Controls.Add(new HtmlGenericControl("hr"));
                        });

                        if (cal.DeliveryDate < DateTime.Now)
                        {
                            pnlDefaultMenu.Enabled = false;
                            chkIsComplete.Enabled  = false;
                            //chkIsCancelled.Enabled = false;
                        }
                    }
                    else
                    {
                        if (menu == null)
                        {
                            lblFeedback.Text += "No menu has been assigned to the Production Calendar associated with the Delivery Date assigned to this item. " +
                                                "Please assign a menu to the Production Calendar and select a Default Menu for this program, prior to continuing.&nbsp;";
                            pnlDefaultMenu.Visible = false;
                        }
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
        protected override void LoadForm()
        {
            try
            {
                hccProductionCalendar cal = null;

                if (Request.QueryString["dd"] != null && !string.IsNullOrEmpty(Request.QueryString["dd"]))
                {
                    DateTime _delDate = DateTime.ParseExact(Request.QueryString["dd"].ToString(), "M/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture);
                    cal = hccProductionCalendar.GetBy(_delDate);
                    //cal = hccProductionCalendar.GetBy(DateTime.Parse(Request.QueryString["dd"].ToString()));

                    if (cal != null)
                    {
                        CurrentCalendarId = cal.CalendarID;
                    }

                    lkbBack.PostBackUrl += "?cal=" + cal.CalendarID.ToString();
                }

                hccProgramPlan plan    = hccProgramPlan.GetById(CurrentCartItem.Plan_PlanID.Value);
                hccProgram     program = hccProgram.GetById(plan.ProgramID);
                if (plan != null && program != null)
                {
                    CurrentProgramId = program.ProgramID;
                    CurrentNumOfDays = plan.NumDaysPerWeek;

                    // load user profile data
                    hccUserProfile profile = CurrentCartItem.UserProfile;
                    hccUserProfile parent  = hccUserProfile.GetParentProfileBy(profile.MembershipID);

                    lblCustomerName.Text = parent.FirstName + " " + parent.LastName;
                    lblProfileName.Text  = profile.ProfileName;
                    lblProgram.Text      = program.Name;
                    lblPlan.Text         = plan.Name;
                    lblPlanOption.Text   = hccProgramOption.GetById(CurrentCartItem.Plan_ProgramOptionID.Value).OptionText;
                    lblOrderNumber.Text  = CurrentCartItem.OrderNumber;
                    lblQuantity.Text     = CurrentCartItem.Quantity.ToString();
                    lblDeliveryDate.Text = cal.DeliveryDate.ToShortDateString();

                    hccCartItemCalendar cartCal = hccCartItemCalendar.GetBy(CurrentCartItem.CartItemID, cal.CalendarID);

                    if (cartCal != null)
                    {
                        chkIsComplete.Checked = cartCal.IsFulfilled;
                    }

                    chkIsCancelledDisplay.Checked = CurrentCartItem.IsCancelled;

                    lvwAllrgs.DataSource = profile.GetAllergens();
                    lvwAllrgs.DataBind();
                    ProfileNotesEdit_AllergenNote.CurrentUserProfileId = profile.UserProfileID;
                    ProfileNotesEdit_AllergenNote.Bind();

                    lvwPrefs.DataSource = profile.GetPreferences();
                    lvwPrefs.DataBind();
                    ProfileNotesEdit_PreferenceNote.CurrentUserProfileId = profile.UserProfileID;
                    ProfileNotesEdit_PreferenceNote.Bind();

                    defaultMenuSelections = hccProgramDefaultMenu.GetBy(CurrentCalendarId, CurrentProgramId);

                    days = BindWeeklyGlance(defaultMenuSelections, CurrentNumOfDays);

                    BindDdlDays(days);

                    BindForm();
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #14
0
        protected override void LoadForm()
        {
            try
            {
                if (Request.QueryString["dd"] != null && !string.IsNullOrEmpty(Request.QueryString["dd"]))
                {
                    DateTime _delDate         = DateTime.ParseExact(Request.QueryString["dd"].ToString(), "M/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture);
                    hccProductionCalendar cal = hccProductionCalendar.GetBy(_delDate);
                    //hccProductionCalendar cal = hccProductionCalendar.GetBy(DateTime.Parse(Request.QueryString["dd"].ToString()));

                    if (cal != null)
                    {
                        CurrentCalendarId = cal.CalendarID;

                        if (cal.DeliveryDate < DateTime.Now)
                        {
                            //chkIsCancelled.Enabled = false;
                            btnSave.Enabled = false;
                        }
                    }

                    lkbBack.PostBackUrl += "?cal=" + cal.CalendarID.ToString();
                }

                if (CurrentCartItem != null)
                {
                    // load user profile data
                    hccUserProfile profile = CurrentCartItem.UserProfile;

                    if (profile != null)
                    {
                        hccUserProfile parent = hccUserProfile.GetParentProfileBy(profile.MembershipID);
                        if (parent != null)
                        {
                            lblCustomerName.Text = parent.FirstName + " " + parent.LastName;
                        }

                        lblProfileName.Text           = profile.ProfileName;
                        lblOrderNumber.Text           = CurrentCartItem.OrderNumber;
                        lblDeliveryDate.Text          = CurrentCartItem.DeliveryDate.ToShortDateString();
                        chkIsCancelledDisplay.Checked = CurrentCartItem.IsCancelled;
                        chkIsComplete.Checked         = CurrentCartItem.IsCompleted;

                        lvwAllrgs.DataSource = profile.GetAllergens();
                        lvwAllrgs.DataBind();
                        ProfileNotesEdit_AllergenNote.CurrentUserProfileId = profile.UserProfileID;
                        ProfileNotesEdit_AllergenNote.Bind();

                        lvwPrefs.DataSource = profile.GetPreferences();
                        lvwPrefs.DataBind();
                        ProfileNotesEdit_PreferenceNote.CurrentUserProfileId = profile.UserProfileID;
                        ProfileNotesEdit_PreferenceNote.Bind();
                    }

                    BindgvwALCItems();
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #15
0
        protected override void LoadForm()
        {
            try
            {
                if (Request.QueryString["dd"] != null && !string.IsNullOrEmpty(Request.QueryString["dd"]))
                {
                    DateTime _delDate         = DateTime.ParseExact(Request.QueryString["dd"].ToString(), "M/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture);
                    hccProductionCalendar cal = hccProductionCalendar.GetBy(_delDate);
                    //hccProductionCalendar cal = hccProductionCalendar.GetBy(DateTime.Parse(Request.QueryString["dd"].ToString()));

                    if (cal != null)
                    {
                        CurrentCalendarId = cal.CalendarID;

                        if (cal.DeliveryDate < DateTime.Now)
                        {
                            //chkIsCancelled.Enabled = false;
                            btnSave.Enabled = false;
                        }
                    }

                    lkbBack.PostBackUrl += "?cal=" + cal.CalendarID.ToString();
                }

                if (CurrentCartItem != null)
                {
                    // load user profile data
                    hccUserProfile profile = CurrentCartItem.UserProfile;

                    if (profile != null)
                    {
                        hccUserProfile parent = hccUserProfile.GetParentProfileBy(profile.MembershipID);
                        if (parent != null)
                        {
                            lblCustomerName.Text = parent.FirstName + " " + parent.LastName;
                        }

                        lblProfileName.Text  = profile.ProfileName;
                        lblOrderNumber.Text  = CurrentCartItem.OrderNumber;
                        lblDeliveryDate.Text = CurrentCartItem.DeliveryDate.ToShortDateString();

                        lvwAllrgs.DataSource = profile.GetAllergens();
                        lvwAllrgs.DataBind();
                        ProfileNotesEdit_AllergenNote.CurrentUserProfileId = profile.UserProfileID;
                        ProfileNotesEdit_AllergenNote.Bind();

                        lvwPrefs.DataSource = profile.GetPreferences();
                        lvwPrefs.DataBind();
                        ProfileNotesEdit_PreferenceNote.CurrentUserProfileId = profile.UserProfileID;
                        ProfileNotesEdit_PreferenceNote.Bind();

                        lblItemName.Text              = CurrentCartItem.ItemName;
                        lblPrice.Text                 = CurrentCartItem.ItemPrice.ToString("c");
                        chkIsComplete.Checked         = CurrentCartItem.IsCompleted;
                        chkIsCancelledDisplay.Checked = CurrentCartItem.IsCancelled;
                        //chkIsCancelled.Attributes.Add("onclick", "javascript: return confirm('Are you sure that you want to change this order item's Cancellation status?')");
                    }

                    lblQuantity.Text = CurrentCartItem.Quantity.ToString();

                    if (CurrentCartItem.Gift_IssuedTo.HasValue)
                    {
                        lblIssuedTo.Text = hccUserProfile.GetParentProfileBy(CurrentCartItem.Gift_IssuedTo.Value).FullName;
                    }

                    if (CurrentCartItem.Gift_IssuedDate.HasValue)
                    {
                        lblIssuedDate.Text = CurrentCartItem.Gift_IssuedDate.Value.ToShortDateString();
                    }

                    lblRecipientEmail.Text = CurrentCartItem.Gift_RecipientEmail;

                    if (CurrentCartItem.Gift_RecipientAddressId.HasValue)
                    {
                        lblRecipientAddress.Text = hccAddress.GetById(CurrentCartItem.Gift_RecipientAddressId.Value).ToHtml();
                    }

                    lblRecipientMessage.Text = CurrentCartItem.Gift_RecipientMessage;

                    if (CurrentCartItem.Gift_RedeemedBy.HasValue)
                    {
                        lblRedeemedBy.Text = hccUserProfile.GetParentProfileBy(CurrentCartItem.Gift_RedeemedBy.Value).FullName;
                    }

                    if (CurrentCartItem.Gift_RedeemedDate.HasValue)
                    {
                        lblRedeemedDate.Text = CurrentCartItem.Gift_RedeemedDate.Value.ToShortDateString();
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
        void BindDropDownLists()
        {
            if (CurrentProgramId > 0 && CurrentCalendarId > 0)
            {
                hccProductionCalendar cal = hccProductionCalendar.GetById(CurrentCalendarId);
                hccMenu menu = cal.GetMenu();
                if (menu == null)
                {
                    lblFeedback.Text += "The selected delivery date does not have an associated menu. Please select a menu to use for the Production Calendar corresponding with this delivery date.";
                }
                else
                {
                    hccProgram program = hccProgram.GetById(CurrentProgramId);

                    if (program != null)
                    {
                        List <hccProgramMealType> mt = hccProgramMealType.GetBy(program.ProgramID);
                        List <hccProgramMealType> requiredMealTypes = mt.Where(a => a.RequiredQuantity > 0).ToList();

                        // Display for 7 days
                        for (int day = 1; day <= 7; day++)
                        {
                            Panel pnlDay = new Panel();
                            pnlDay.CssClass = "dayPanel";
                            HtmlGenericControl pName = new HtmlGenericControl("p");
                            pName.InnerHtml = "<center><b>Day " + day.ToString() + "</b></center>";
                            pnlDay.Controls.Add(pName);
                            pnlDay.Controls.Add(new HtmlGenericControl("hr"));

                            requiredMealTypes.ForEach(delegate(hccProgramMealType mealType)
                            {
                                if (day == 1) // list on the first item
                                {
                                    HtmlGenericControl liType = new HtmlGenericControl("li");
                                    liType.InnerText          = ((Enums.MealTypes)mealType.MealTypeID).ToString() + ": " + mealType.RequiredQuantity.ToString();
                                    ulReqTypes.Controls.Add(liType);

                                    HtmlGenericControl mealTypespan = new HtmlGenericControl("h4");
                                    mealTypespan.InnerHtml          = "<b>" + ((Enums.MealTypes)mealType.MealTypeID).ToString() + "</b>";
                                    pnlDay.Controls.Add(mealTypespan);
                                }
                                else
                                {
                                    HtmlGenericControl mealTypespan = new HtmlGenericControl("h4");
                                    mealTypespan.InnerHtml          = "<div>&nbsp;</div>";
                                    pnlDay.Controls.Add(mealTypespan);
                                }

                                int i = 1;
                                while (i <= mealType.RequiredQuantity)
                                {
                                    DropDownList ddlMealItem = new DropDownList();
                                    ddlMealItem.CssClass     = "mealItemDdl";
                                    ddlMealItem.Attributes.Add("calId", CurrentCalendarId.ToString());
                                    ddlMealItem.Attributes.Add("progId", CurrentProgramId.ToString());
                                    ddlMealItem.Attributes.Add("day", day.ToString());
                                    ddlMealItem.Attributes.Add("type", mealType.MealTypeID.ToString());
                                    ddlMealItem.Attributes.Add("ord", i.ToString());

                                    List <hccMenuItem> menuItems = hccMenuItem.GetByMenuId(menu.MenuID)
                                                                   .Where(a => a.MealTypeID == mealType.MealTypeID).OrderBy(a => a.Name).ToList();

                                    List <ListItem> menuItemsWithSizes = new List <ListItem>();
                                    menuItems.ForEach(delegate(hccMenuItem mainItem)
                                    {
                                        menuItemsWithSizes.Add(new ListItem(mainItem.Name + " : "
                                                                            + Enums.CartItemSize.ChildSize.ToString(), mainItem.MenuItemID.ToString() + "-" + ((int)Enums.CartItemSize.ChildSize).ToString()));

                                        menuItemsWithSizes.Add(new ListItem(mainItem.Name + " : "
                                                                            + Enums.CartItemSize.SmallSize.ToString(), mainItem.MenuItemID.ToString() + "-" + ((int)Enums.CartItemSize.SmallSize).ToString()));

                                        menuItemsWithSizes.Add(new ListItem(mainItem.Name + " : "
                                                                            + Enums.CartItemSize.RegularSize.ToString(), mainItem.MenuItemID.ToString() + "-" + ((int)Enums.CartItemSize.RegularSize).ToString()));

                                        menuItemsWithSizes.Add(new ListItem(mainItem.Name + " : "
                                                                            + Enums.CartItemSize.LargeSize.ToString(), mainItem.MenuItemID.ToString() + "-" + ((int)Enums.CartItemSize.LargeSize).ToString()));
                                    });

                                    ddlMealItem.DataSource     = menuItemsWithSizes;
                                    ddlMealItem.DataTextField  = "Text";
                                    ddlMealItem.DataValueField = "Value";
                                    ddlMealItem.DataBind();

                                    ddlMealItem.Items.Insert(0, new ListItem("None", "0"));
                                    pnlDay.Controls.Add(ddlMealItem);

                                    CheckBoxList menuitempreferencescheckBoxList = new CheckBoxList();
                                    menuitempreferencescheckBoxList.CssClass     = "mealItemchk";
                                    menuitempreferencescheckBoxList.Attributes.Add("calId", CurrentCalendarId.ToString());
                                    menuitempreferencescheckBoxList.Attributes.Add("progId", CurrentProgramId.ToString());
                                    menuitempreferencescheckBoxList.Attributes.Add("day", day.ToString());
                                    menuitempreferencescheckBoxList.Attributes.Add("type", mealType.MealTypeID.ToString());
                                    menuitempreferencescheckBoxList.Attributes.Add("ord", i.ToString());
                                    pnlDay.Controls.Add(menuitempreferencescheckBoxList);


                                    pnlDay.Controls.Add(new HtmlGenericControl("p"));
                                    i++;
                                }

                                pnlDay.Controls.Add(new HtmlGenericControl("hr"));
                            });

                            HtmlGenericControl nut = new HtmlGenericControl("div");
                            nut.ID = "divNutrition" + day.ToString();
                            nut.Attributes.Add("day", day.ToString());
                            nut.Attributes.Add("class", "nutrition" + day);
                            nut.InnerHtml = "<fieldset><legend>Calories</legend><p id='cals" + day.ToString() + "'>##Cals##</p></fieldset>" +
                                            "<fieldset><legend>Fat</legend><p id='fat" + day.ToString() + "'>##Fats##</p></fieldset>" +
                                            "<fieldset><legend>Protein</legend><p id='prtn" + day.ToString() + "'>##Ptrns##</p></fieldset>" +
                                            "<fieldset><legend>Carbohydrates</legend><p id='carb" + day.ToString() + "'>##Carbs##</p></fieldset>" +
                                            "<fieldset><legend>Dietary Fiber</legend><p id='fbr" + day.ToString() + "'>##Fbrs##</p></fieldset>" +
                                            "<fieldset><legend>Sodium</legend><p id='sod" + day.ToString() + "'>##Sod##</p></fieldset>";
                            pnlDay.Controls.Add(nut);

                            pnlDefaultMenu.Controls.Add(pnlDay);
                        }

                        if (cal.DeliveryDate < DateTime.Now)
                        {
                            pnlDefaultMenu.Enabled = true;                     //[BWE]
                            pnlDefaultMenu.Attributes.Add("class", "enabled"); //[BWE]
                        }
                        else
                        {
                            pnlDefaultMenu.Enabled = true;
                            pnlDefaultMenu.Attributes.Remove("class");
                        }
                    }
                }
            }
        }