コード例 #1
0
    protected void WeekChanged(object sender, EventArgs e)
    {
        DropDownList       ddlWeekList = (DropDownList)sender;
        int                weekNum     = int.Parse(ddlWeekList.SelectedValue);
        MemberExercisePlan myPlan;

        if (Session["MPID"] != null)
        {
            int mPlanId = Convert.ToInt32(Session["MPID"]);
            myPlan = dbAccess.GetMemberExercisePlan(mPlanId);
        }
        else
        {
            myPlan = dbAccess.GetCurrentMemberPlanOrStartingPlan(memberId);
        }

        PrizeExercisePlan plan = dbAccess.GetExercisePlan(myPlan.ExercisePlanId);

        lblPlanInfo.Text = "Plan " + plan.PlanName + " from " + PrizeCommonUtils.ParseDateToEnglish(myPlan.StartDate) + " to " + PrizeCommonUtils.ParseDateToEnglish(myPlan.EndDate.Value);
        LoadFoodPlanWeek(memberId, myPlan, weekNum);
    }
コード例 #2
0
    private void BindGrid()
    {
        using (DIYPTEntities db = new DIYPTEntities())
        {
            db.Database.Connection.Open();
            {
                var languages = from a in db.MemberPlanWeekResults
                                join b in db.PrizeMembers on a.MemberId equals b.UmbracoId
                                join c in db.MemberExercisePlanWeeks on a.MemberExercisePlanWeekId equals c.Id
                                join d in db.MemberExercisePlans on c.MemberExercisePlanId equals d.Id
                                join e in db.PrizeExercisePlans on d.ExercisePlanId equals e.Id
                                where a.MemberId == memberId && d.Status.EndsWith("P")
                                orderby d.StartDate descending, c.StartDate
                    select new
                {
                    Memberid     = a.MemberId,
                    Firstname    = b.Firstname,
                    Surname      = b.Surname,
                    Week         = c.Week,
                    Status       = c.Status,
                    StartDate    = c.StartDate,
                    EndDate      = c.EndDate,
                    PlanName     = e.PlanName,
                    EndWeight    = a.EndWeight,
                    EndWaist     = a.EndWaist,
                    EndBodyFat   = a.EndBodyFat,
                    EndChest     = a.EndChest,
                    EndHip       = a.EndHip,
                    EndHeartRate = a.EndHeartRate,
                    FrontPhoto   = a.FrontPhoto,
                    BackPhoto    = a.BackPhoto,
                    SidePhoto    = a.SidePhoto,
                    Tasks        = a.Tasks,
                };

                GridView1.DataSource = languages.ToList();

                GridView1.DataBind();

                MemberExercisePlan     myPlan     = null;
                MemberExercisePlanWeek myPlanWeek = null;
                if (Session["MPID"] != null)
                {
                    int mPlanId = Convert.ToInt32(Session["MPID"]);
                    myPlan = dbAccess.GetMemberExercisePlan(mPlanId);
                }
                else
                {
                    myPlan     = dbAccess.GetCurrentMemberPlanOrStartingPlan(memberId);
                    myPlanWeek = dbAccess.GetCurrentMemberPlanWeek(memberId);
                }

                this.btnSave.Enabled = false;
                if (myPlan != null)
                {
                    this.btnSave.Enabled = true;
                    var memberPlanWeeks = from a in db.MemberExercisePlanWeeks
                                          where a.MemberExercisePlanId == myPlan.Id
                                          orderby a.Week
                                          select new
                    {
                        WeekText = a.Week,
                        WeekNum  = a.Week
                    };
                    ddlWeek.DataValueField = "WeekNum";
                    ddlWeek.DataTextField  = "WeekText";
                    ddlWeek.DataSource     = memberPlanWeeks.ToList();
                    ddlWeek.DataBind();
                    int weekNum = -1;
                    if (myPlanWeek != null)
                    {
                        weekNum = myPlanWeek.Week;
                    }

                    PrizeExercisePlan plan = dbAccess.GetExercisePlan(myPlan.ExercisePlanId);

                    lblPlanInfo.Text = "Plan " + plan.PlanName + " from " + PrizeCommonUtils.ParseDateToEnglish(myPlan.StartDate) + " to " + PrizeCommonUtils.ParseDateToEnglish(myPlan.EndDate.Value);
                    LoadFoodPlanWeek(memberId, myPlan, weekNum);
                }
            }
            db.Database.Connection.Close();
        }
    }
コード例 #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int memberId = PrizeMemberAuthUtils.GetMemberID();

        var exercisePlan = dbAccess.GetCurrentMemberPlanOrStartingPlan(memberId);

        if (exercisePlan == null)
        {
            PrizeMember            member  = PrizeMemberAuthUtils.GetMemberData(memberId);
            PrizeMemberPlanManager planMan = new PrizeMemberPlanManager();
            Response.Redirect(planMan.GetEmptyPlanJumpURL(member));
        }

        MemberExercisePlanWeek memberPlanWeek;

        if (Request["MemberPlanWeekID"] != null)
        {
            int memberPlanWeekId;
            int.TryParse(Request["MemberPlanWeekID"], out memberPlanWeekId);
            memberPlanWeek = dbAccess.GetMemberPlanWeekById(memberPlanWeekId);
        }
        else
        {
            memberPlanWeek = dbAccess.GetCurrentMemberPlanWeek(memberId);
        }

        if (memberPlanWeek == null)
        {
            divMealPlanContent.Visible = false;
            divNotStarted.Visible      = true;
            return;
        }

        int iWeekNum = memberPlanWeek.Week;

        lblWeekNum.Text = "Week " + iWeekNum;
        divMainMealPlan.Attributes.Add("class", "tab-inner-content nodisplay wk" + iWeekNum);
        lblDateDuration.Text = PrizeCommonUtils.ParseDateToEnglish(memberPlanWeek.StartDate) + " - "
                               + PrizeCommonUtils.ParseDateToEnglish(memberPlanWeek.EndDate);

        MemberExercisePlan memberPlan = dbAccess.GetCurrentMemberPlan(memberId);

        if (memberPlan == null)
        {
            return;
        }
        PrizeExercisePlan plan = dbAccess.GetExercisePlan(memberPlan.ExercisePlanId);

        if (plan == null)
        {
            return;
        }
        lblPlanProgram.Text = plan.PrizePlanProgram.Name;

        MemberExercisePlanWeek prevWeek = dbAccess.GetMemberPlanWeekByMemberPlanAndWeek(memberPlan.Id, memberPlanWeek.Week - 1);

        if (prevWeek != null)
        {
            int prevWeekNum = iWeekNum - 1;
            weekPre.NavigateUrl = "/my-account/meal-plan?MemberPlanWeekID=" + prevWeek.Id;
            weekPre.Text        = "Week " + (memberPlanWeek.Week - 1);
        }
        else
        {
            weekPre.Attributes.Add("class", "no-arrow");
        }

        MemberExercisePlanWeek nextWeek = dbAccess.GetMemberPlanWeekByMemberPlanAndWeek(memberPlan.Id, memberPlanWeek.Week + 1);

        if (nextWeek != null)
        {
            weekNext.NavigateUrl = "/my-account/meal-plan?MemberPlanWeekID=" + nextWeek.Id;
            weekNext.Text        = "Week " + (memberPlanWeek.Week + 1);
        }
        else
        {
            weekNext.Attributes.Add("class", "no-arrow");
        }

        MemberFoodPlanWeek foodWeek = dbAccess.GetMemberFoodPlanWeek(memberId, memberPlanWeek.MemberExercisePlanId, memberPlanWeek.Week);

        if (foodWeek == null)
        {
            return;
        }
        if (foodWeek.Food1 == null || foodWeek.Food1.Equals(""))
        {
            this.colories.Visible = false;
        }
        else
        {
            lblFood1.Text = foodWeek.Food1;
        }

        if (foodWeek.Food2 == null || foodWeek.Food2.Equals(""))
        {
            this.protein.Visible = false;
        }
        else
        {
            lblFood2.Text = foodWeek.Food2;
        }

        if (foodWeek.Food3 == null || foodWeek.Food3.Equals(""))
        {
            this.carbo.Visible = false;
        }
        else
        {
            lblFood3.Text = foodWeek.Food3;
        }

        if (foodWeek.Food4 == null || foodWeek.Food4.Equals(""))
        {
            this.fats.Visible = false;
        }
        else
        {
            lblFood4.Text = foodWeek.Food4;
        }

        if (foodWeek.Food5 != null)
        {
            string[] sPersentage = foodWeek.Food5.Split(';');
            if (sPersentage.Length > 0)
            {
                lblFood5.Text = sPersentage[0];
                if (sPersentage.Length > 1)
                {
                    lblFood6.Text = sPersentage[1];
                    if (sPersentage.Length > 2)
                    {
                        lblFood7.Text = sPersentage[2];
                    }
                }
            }
        }
    }
コード例 #4
0
    protected void LoadWeeklyInfo(int memberID, PrizeExercisePlanWeek planWeek, MemberExercisePlanWeek memberPlanWeek)
    {
        dayNumber = PrizeCommonUtils.GetSystemDate().GetDayOfWeek();

        int memberId = PrizeMemberAuthUtils.GetMemberID();

        using (DIYPTEntities db = new DIYPTEntities())
        {
            db.Database.Connection.Open();

            lblDateDuration.Text = PrizeCommonUtils.ParseDateToEnglish(memberPlanWeek.StartDate) + " - "
                                   + PrizeCommonUtils.ParseDateToEnglish(memberPlanWeek.EndDate);

            for (int i = 0; i < lblDates.Count; i++)
            {
                lblDates[i].Text = PrizeCommonUtils.ParseShortDateToEnglish(memberPlanWeek.StartDate.AddDays(i));
                HyperLink linkDay = FindControl("linkDay" + (i + 1)) as HyperLink;
                if (linkDay != null && planWeek != null)
                {
                    linkDay.NavigateUrl = (String.Format("{0}?PlanWeekId={1}&MemberPlanWeekId={2}&PlanDayNumber={3}", PrizeConstants.URL_MEMBER_DAY_VIEW, planWeek.Id, memberPlanWeek.Id, i + 1));
                }
                else if (planWeek == null)
                {
                    //Orientation week
                    linkDay.NavigateUrl = "/orientation/day-" + (i + 1);
                    labels[i].Text      = "Orientation day " + (i + 1);
                }
            }
            if (planWeek == null)
            {
                lblWeekNum.Text = "Week 0";
                PrizeDataAccess dba = new PrizeDataAccess();
                if (dba.MemberInOrientation(PrizeMemberAuthUtils.GetMemberID()))
                {
                    topInfo.Visible = false;
                }
                db.Database.Connection.Close();
                return;
            }

            int iWeekNum = memberPlanWeek.Week;
            lblWeekNum.Text = "Week " + iWeekNum;

            string[] planWeekDesc      = planWeek.Description.Split('\n');
            bool     bEquipmentSession = false;
            if (strEquipments == null)
            {
                strEquipments = new List <string>();
            }
            for (int i = 0; i < planWeekDesc.Length; i++)
            {
                string[] strKeyValue = planWeekDesc[i].Split(':');
                if (strKeyValue != null && strKeyValue.Length > 1)
                {
                    if ((i == 1) && (strKeyValue[0].IndexOf("phase", StringComparison.OrdinalIgnoreCase) >= 0))
                    {
                        lblTrainingPhase.Text = strKeyValue[1];
                        continue;
                    }
                    if ((i == 2) && (strKeyValue[0].IndexOf("phase duration", StringComparison.OrdinalIgnoreCase) >= 0 || (strKeyValue[0].IndexOf("training duration", StringComparison.OrdinalIgnoreCase) >= 0)))
                    {
                        lblDuration.Text = strKeyValue[1];
                        continue;
                    }

                    if (strKeyValue[0].IndexOf("equipment", StringComparison.OrdinalIgnoreCase) >= 0)
                    {
                        bEquipmentSession = true;
                        strEquipments.Clear();
                        continue;
                    }
                }

                if (bEquipmentSession && Regex.Matches(planWeekDesc[i], @"[a-zA-Z]").Count > 0)
                {
                    strEquipments.Add(planWeekDesc[i]);
                    continue;
                }
            }

            if (strEquipments != null && strEquipments.Count > 0)
            {
                string tempLiteral = "<ul class='equipment-list'>";
                foreach (var e in strEquipments)
                {
                    if (e != " ")
                    {
                        tempLiteral += "<li>" + e + "</li>";
                    }
                }
                tempLiteral                += "</ul>";
                equipmentLiteral.Text       = tempLiteral;
                equipmentLiteralMobile.Text = tempLiteral;
                equipmentDiv.Visible        = true;
            }

            DataSet myPlan = dbAccess.GetExercisePlanInfo((int)planWeek.ExercisePlanId);
            if (myPlan.Tables[0].Rows.Count == 0)
            {
                db.Database.Connection.Close();
                return;
            }

            this.lblGoal.Text = myPlan.Tables[0].Rows[0]["ProgramName"].ToString();


            LoadDailyInfo(memberId, planWeek);

            //PrizePlanProgram myProgram = (from c in db.PrizePlanPrograms
            //                              where c.Id == planWeek.ExercisePlanId
            //                              select c).FirstOrDefault();


            db.Database.Connection.Close();
        }
    }
コード例 #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int.TryParse(Request["PlanWeekId"], out iPlanWeekId);
        int.TryParse(Request["PlanDayNumber"], out iDay);
        int.TryParse(Request["MemberPlanWeekId"], out memberPlanWeekId);

        MemberExercisePlanWeek memberPlanWeek = dbAccess.GetMemberPlanWeekById(memberPlanWeekId);

        if (memberPlanWeek != null)
        {
            lblDate.Text = PrizeCommonUtils.ParseDateToEnglish(memberPlanWeek.StartDate.AddDays(iDay - 1));
        }
        lblDayNum.Text      = "" + iDay;
        lblDayTypeName.Text = PrizeConstants.STR_NO_TRAINNING;
        DataSet ds = dbAccess.GetMemberWeeklyInfo(iPlanWeekId);

        foreach (DataRow row in ds.Tables[0].Rows)
        {
            int iWeekDay = (int)row[0];
            if (iWeekDay == iDay)
            {
                lblDayTypeName.Text = (String)row[2];
            }
        }
        if (lblDayTypeName.Text.ToLower() == PrizeConstants.STR_NO_TRAINNING.ToLower())
        {
            divWarmup.Visible = divCooldown.Visible = divLegend.Visible = false;
            divRest.Visible   = true;
        }

        lblDay.Text = PrizeCommonUtils.ParseWeekDayToEnglish(iDay);
        MemberExercisePlan myPlan = dbAccess.GetMemberExercisePlan(memberPlanWeek.MemberExercisePlanId);

        if (iDay > 1)
        {
            preDay.NavigateUrl = (String.Format("{0}?PlanWeekId={1}&MemberPlanWeekId={2}&PlanDayNumber={3}", PrizeConstants.URL_MEMBER_DAY_VIEW, iPlanWeekId, memberPlanWeekId, iDay - 1));
            preDay.Text        = "Previous Day";
        }
        else
        {
            MemberExercisePlanWeek prevWeek = dbAccess.GetMemberPlanWeekByMemberPlanAndWeek(myPlan.Id, memberPlanWeek.Week - 1);
            if (prevWeek != null)
            {
                preDay.NavigateUrl = (String.Format("{0}?PlanWeekId={1}&MemberPlanWeekId={2}&PlanDayNumber={3}", PrizeConstants.URL_MEMBER_DAY_VIEW, iPlanWeekId, prevWeek.Id, 7));
                preDay.Text        = "Previous Day";
            }
            else
            {
                preDay.Attributes.Add("class", "no-arrow");
            }
        }

        if (iDay < 7)
        {
            nextDay.NavigateUrl = (String.Format("{0}?PlanWeekId={1}&MemberPlanWeekId={2}&PlanDayNumber={3}", PrizeConstants.URL_MEMBER_DAY_VIEW, iPlanWeekId, memberPlanWeekId, iDay + 1));
            nextDay.Text        = "Next Day";
        }
        else
        {
            MemberExercisePlanWeek nextWeek = dbAccess.GetMemberPlanWeekByMemberPlanAndWeek(myPlan.Id, memberPlanWeek.Week + 1);
            if (nextWeek != null)
            {
                nextDay.NavigateUrl = (String.Format("{0}?PlanWeekId={1}&MemberPlanWeekId={2}&PlanDayNumber={3}", PrizeConstants.URL_MEMBER_DAY_VIEW, iPlanWeekId, nextWeek.Id, 1));
                nextDay.Text        = "Next Day";
            }
            else
            {
                nextDay.Attributes.Add("class", "no-arrow");
            }
        }

        InitPageControls();

        DivAdvanceEquipment.Visible = false;
        PrizeDataAccess db = new PrizeDataAccess();
        var             memberExercisePlan = db.GetCurrentMemberPlanOrStartingPlan(PrizeMemberAuthUtils.GetMemberID());

        if (memberExercisePlan != null)
        {
            var exercisePlan = db.GetExercisePlan(memberExercisePlan.ExercisePlanId);
            if (exercisePlan != null)
            {
                if (exercisePlan.PlanName.ToLower().Contains("home") &&
                    (exercisePlan.PlanName.ToLower().Contains("intermediate")
                     ||
                     exercisePlan.PlanName.ToLower().Contains("advanced"))
                    )
                {
                    DivAdvanceEquipment.Visible = true;
                }
            }
        }
        switch (lblDayTypeName.Text.Trim())
        {
        case "Time to celebrate":
            divWarmup.Visible           = divCooldown.Visible = divLegend.Visible = false;
            divRest.Visible             = true;
            DivAdvanceEquipment.Visible = false;
            break;

        case "30min brisk walk":
        case "Brisk walk":
            divWarmup.Visible           = divCooldown.Visible = divLegend.Visible = false;
            divWalk.Visible             = true;
            DivAdvanceEquipment.Visible = false;
            break;

        case "30-60min weekend physical activity":
        case "Weekend physical activity":
            divWarmup.Visible           = divCooldown.Visible = divLegend.Visible = false;
            divWeekend.Visible          = true;
            DivAdvanceEquipment.Visible = false;
            break;

        case "Own 1hr cardio":
        case "Own training":
        case "Own cardio":
            divWarmup.Visible           = divCooldown.Visible = divLegend.Visible = false;
            divCardio.Visible           = true;
            DivAdvanceEquipment.Visible = false;
            break;

        case "Milestone workout = 20x pushups, squats, situps":
        case "Milestone workout 2":
            divWarmup.Visible           = divCooldown.Visible = divLegend.Visible = false;
            divSquat.Visible            = true;
            DivAdvanceEquipment.Visible = false;
            break;

        case "Milestone workout = 20 pushups & make your bed":
        case "Milestone workout 1":
            divWarmup.Visible           = divCooldown.Visible = divLegend.Visible = false;
            divPushup.Visible           = true;
            DivAdvanceEquipment.Visible = false;
            break;

        case "Measurement day and rest":
            divWarmup.Visible           = divCooldown.Visible = divLegend.Visible = false;
            divMeasurement.Visible      = true;
            DivAdvanceEquipment.Visible = false;
            break;

        case "Milestone workout = 20 star jumps & make your bed":
            divWarmup.Visible           = divCooldown.Visible = divLegend.Visible = false;
            DivAdvanceEquipment.Visible = false;
            //divMeasurement.Visible = true;
            break;

        default:
            break;
        }
        LoadDailyInfo(iPlanWeekId, iDay);

        // nextDay.Text = "Next day tuesday";
        // nextDay.NavigateUrl = "/tuesday#?";
    }