Ejemplo n.º 1
0
    protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
    {
        int      quest = 1;
        CheckBox cb    = (CheckBox)sender;

        if (sender == this.CheckBox2)
        {
            quest = 2;
        }
        else if (sender == this.CheckBox3)
        {
            quest = 3;
        }
        else if (sender == this.CheckBox4)
        {
            quest = 4;
        }
        MemberExercisePlan myPlan = dbAccess.GetCurrentMemberPlan(PrizeMemberAuthUtils.GetMemberID());

        if (myPlan == null)
        {
            Response.Write(PrizeConstants.CONST_JS_WARNING_PLAN_NOT_START);
            return;
        }
        dbAccess.UpdateOrientationWeekDayResult(myPlan.Id, 6, quest, cb.Checked);
    }
Ejemplo n.º 2
0
    protected void Button3_Click(object sender, EventArgs e)
    {
        int memberId = PrizeMemberAuthUtils.GetMemberID();

        PrizeExercisePlan plan = dbAccess.GetNotStartedExercisePlan(memberId);

        if (plan == null)
        {
            MemberExercisePlan curMemberPlan = dbAccess.GetCurrentMemberPlan(memberId);
            if (curMemberPlan != null)
            {
                plan = dbAccess.GetExercisePlan(curMemberPlan.ExercisePlanId);
            }
            if (plan == null)
            {
                plan = dbAccess.GetLastFinishedExercisePlan(memberId);
            }
        }

        PrizeExercisePlan nextPlan = dbAccess.GetNextExercisePlan(plan);

        if (nextPlan != null)
        {
            Response.Redirect(String.Format("{0}?targetplanid={1}", PrizeConstants.URL_MEMBER_BUY_PLAN, nextPlan.Id));
        }
    }
Ejemplo n.º 3
0
    public PrizeExercisePlan GetNextPlanToBuy(int memberId)
    {
        PrizeExercisePlan plan = GetNotStartedExercisePlan(memberId);

        if (plan == null)
        {
            MemberExercisePlan curMemberPlan = GetCurrentMemberPlan(memberId);
            if (curMemberPlan != null)
            {
                plan = GetExercisePlan(curMemberPlan.ExercisePlanId);
            }
            if (plan == null)
            {
                plan = GetLastFinishedExercisePlan(memberId);
            }
        }

        PrizeExercisePlan nextPlan;

        if (plan != null && plan.IsTrialPlan == 1)
        {
            nextPlan = GetNextExercisePlanForTrialPlan(plan);
        }
        else
        {
            nextPlan = GetNextExercisePlan(plan);
        }

        return(nextPlan);
    }
Ejemplo n.º 4
0
    public PrizeExercisePlan GetLastFinishedExercisePlan(int memberId)
    {
        try
        {
            db.Database.Connection.Open();
            string             finishedStatus = PrizeConstants.STATUS_PLAN_FINISHED + PrizeConstants.STATUS_PLAN_PAID;
            MemberExercisePlan memberPlan     = (from c in db.MemberExercisePlans
                                                 where c.MemberId == memberId && c.Status.Equals(finishedStatus)
                                                 orderby c.EndDate descending
                                                 select c).FirstOrDefault();
            if (memberPlan == null)
            {
                return(null);
            }
            PrizeExercisePlan finishedPlan = (from c in db.PrizeExercisePlans
                                              where c.Id == memberPlan.ExercisePlanId
                                              select c).FirstOrDefault();

            return(finishedPlan);
        }
        finally
        {
            db.Database.Connection.Close();
        }
    }
Ejemplo n.º 5
0
    public MemberExercisePlan GetCurrentMemberPlanOrStartingPlan(int iMemberId)
    {
        try
        {
            db.Database.Connection.Open();
            string             status = PrizeConstants.STATUS_PLAN_STARTED + PrizeConstants.STATUS_PLAN_PAID;
            MemberExercisePlan myPlan = (from c in db.MemberExercisePlans
                                         where c.MemberId == iMemberId && c.Status.Equals(status)
                                         select c).FirstOrDefault();
            if (myPlan != null)
            {
                return(myPlan);
            }

            status = PrizeConstants.STATUS_PLAN_NOT_STARTED + PrizeConstants.STATUS_PLAN_PAID;
            myPlan = (from c in db.MemberExercisePlans
                      where c.MemberId == iMemberId && c.Status.Equals(status)
                      orderby c.StartDate
                      select c).FirstOrDefault();
            return(myPlan);
        }
        finally
        {
            db.Database.Connection.Close();
        }
    }
Ejemplo n.º 6
0
    protected void btnChangePlan_Click(object sender, EventArgs e)
    {
        int targetPlanId = 0;

        int.TryParse(ddlPlan.SelectedItem.Value, out targetPlanId);
        PrizeMemberPlanManager man      = new PrizeMemberPlanManager();
        PrizeDataAccess        dbAccess = new PrizeDataAccess();
        MemberExercisePlan     myPlan   = dbAccess.GetCurrentMemberPlanOrStartingPlan(memberId);

        if (myPlan == null)
        {
            Response.Write("<script>alert('Can't find the user's plan.');</script>");
        }
        else
        {
            if (!man.ChangeMemberPlan(myPlan.Id, targetPlanId))
            {
                Response.Write("<script>alert('The level of the current program not in the database.');</script>");
            }
            else
            {
                Response.Write("<script>alert('The user's program has been changed to " + ddlPlan.SelectedItem.Text + ");</script>");
            }
        }
        this.BindGrid();
    }
Ejemplo n.º 7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (this.IsPostBack)
        {
            return;
        }
        DateTime myDate = GetOrientationDate(1);

        lblDay.Text  = myDate.ToString("dddd d").ToUpper();
        lblDate.Text = myDate.ToString("MMMM, yyyy");
        MemberExercisePlan myPlan = dbAccess.GetCurrentMemberPlan(PrizeMemberAuthUtils.GetMemberID());

        if (myPlan == null)
        {
            Response.Write(PrizeConstants.CONST_JS_WARNING_PLAN_NOT_START);
            this.oriTextarea1.Enabled = false;
            this.oriTextarea2.Enabled = false;
            this.oriTextarea3.Enabled = false;
            this.oriTextarea7.Enabled = false;
            this.radioButtonListEverExercise.Enabled = false;
            this.radioButtonListExerciseType.Enabled = false;
            this.radioButtonListLocation.Enabled     = false;
            this.radioButtonListGoalBefore.Enabled   = false;
        }
    }
Ejemplo n.º 8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        DateTime myDate = GetOrientationDate(1);

        lblDay.Text  = myDate.ToString("dddd d").ToUpper();
        lblDate.Text = myDate.ToString("MMMM, yyyy");

        var member = PrizeMemberAuthUtils.GetMemberData();

        if (member.Photo != null && member.Photo != "")
        {
            imgProfile.ImageUrl = member.Photo;
        }

        if (IsPostBack)
        {
            return;
        }

        MemberExercisePlan myPlan = dbAccess.GetCurrentMemberPlan(PrizeMemberAuthUtils.GetMemberID());

        if (myPlan == null)
        {
            return;
        }

        string result = dbAccess.GetOrientationWeekDayResult(myPlan.Id, 1);

        if (result != null)
        {
            if (result[3] == '1')
            {
                CheckBox1.Checked = true;
            }
            else
            {
                CheckBox1.Checked = false;
            }
            if (result[4] == '1')
            {
                CheckBox2.Checked = true;
            }
            else
            {
                CheckBox2.Checked = false;
            }
            if (result[5] == '1')
            {
                CheckBox3.Checked = true;
            }
            else
            {
                CheckBox3.Checked = false;
            }
        }
    }
Ejemplo n.º 9
0
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        bool bLogin = Membership.ValidateUser(username.Text, password.Text);

        if (bLogin != false)
        {
            Member uMember = Member.GetMemberFromLoginNameAndPassword(username.Text, password.Text);
            if (uMember != null)
            {
                Session["taRegistration"] = uMember.Email;
                System.Web.Security.FormsAuthentication.SetAuthCookie(uMember.LoginName, true);
                Member.AddMemberToCache(uMember);
                MemberExercisePlan myPlan = dbAccess.GetCurrentMemberPlanOrStartingPlan(uMember.Id);
                int myPlanId = 0;
                if (myPlan != null)
                {
                    myPlanId = myPlan.ExercisePlanId;
                }
                PrizeMemberAuthUtils.SaveMemberLoginLog(uMember.Id, myPlanId, this.ToString(), "Login");
                if (myPlan == null)
                {
                    PrizeMember            member  = PrizeMemberAuthUtils.GetMemberData(uMember.Id);
                    PrizeMemberPlanManager planMan = new PrizeMemberPlanManager();
                    Response.Redirect(planMan.GetEmptyPlanJumpURL(member));
                }
                else
                {
                    if (Request.QueryString["returnUrl"] != null)
                    {
                        Response.Redirect(Request.QueryString["returnUrl"]);
                    }
                    PrizeExercisePlan plan = dbAccess.GetExercisePlan(myPlan.ExercisePlanId);
                    if (plan.IsTrialPlan != 1)
                    {
                        Response.Redirect(String.Format("{0}?loginName={1}&memberId={2}", PrizeConstants.URL_MEMBER_COMING_UP, uMember.LoginName, uMember.Id));
                    }
                    else
                    {
                        Response.Redirect(String.Format("{0}?loginName={1}&memberId={2}", PrizeConstants.URL_MEMBER_LANDING, uMember.LoginName, uMember.Id));
                    }
                }
                //var log = new MemberVisitLogs();
                //log.UmbracoId = uMember.Id;
                //log.Page = HttpContext.Current.Request.Url.AbsolutePath;
                //log.CreatedOn = PrizeCommonUtils.GetSystemDate();
                //log.MembersReference.EntityKey = new EntityKey("SydneyCatalystMemberEntities.Members", "Id", member.Id);
                //db.AddToMemberVisitLogs(log);
                //db.SaveChanges();
                return;
            }
        }
        errorLabel.Text = "Invalid UserId/password.";
    }
Ejemplo n.º 10
0
    protected void btnTaskDone_Click(object sender, EventArgs e)
    {
        MemberExercisePlan myPlan = dbAccess.GetCurrentMemberPlan(PrizeMemberAuthUtils.GetMemberID());

        if (myPlan == null)
        {
            Response.Write(PrizeConstants.CONST_JS_WARNING_PLAN_NOT_START);
            return;
        }
        dbAccess.UpdateOrientationWeekDayResult(myPlan.Id, 3, 3, true);
        Response.Redirect("/orientation/day-3");
    }
Ejemplo n.º 11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        DateTime myDate = GetOrientationDate(6);

        lblDay.Text  = myDate.ToString("dddd d").ToUpper();
        lblDate.Text = myDate.ToString("MMMM, yyyy");
        if (!IsPostBack)
        {
            MemberExercisePlan myPlan = dbAccess.GetCurrentMemberPlan(PrizeMemberAuthUtils.GetMemberID());
            if (myPlan == null)
            {
                return;
            }
            string result = dbAccess.GetOrientationWeekDayResult(myPlan.Id, 6);
            if (result != null)
            {
                if (result[0] == '1')
                {
                    CheckBox1.Checked = true;
                }
                else
                {
                    CheckBox1.Checked = false;
                }
                if (result[1] == '1')
                {
                    CheckBox2.Checked = true;
                }
                else
                {
                    CheckBox2.Checked = false;
                }
                if (result[2] == '1')
                {
                    CheckBox3.Checked = true;
                }
                else
                {
                    CheckBox3.Checked = false;
                }
                if (result[3] == '1')
                {
                    CheckBox4.Checked = true;
                }
                else
                {
                    CheckBox4.Checked = false;
                }
            }
        }
    }
Ejemplo n.º 12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        DateTime myDate = GetOrientationDate(5);

        lblDay.Text  = myDate.ToString("dddd d").ToUpper();
        lblDate.Text = myDate.ToString("MMMM, yyyy");
        MemberExercisePlan myPlan = dbAccess.GetCurrentMemberPlan(PrizeMemberAuthUtils.GetMemberID());

        if (myPlan == null)
        {
            Response.Write(PrizeConstants.CONST_JS_WARNING_PLAN_NOT_START);
            return;
        }
    }
Ejemplo n.º 13
0
 public MemberExercisePlan GetMemberExercisePlan(int iMemberExsercisePlanId)
 {
     try
     {
         db.Database.Connection.Open();
         MemberExercisePlan myPlan = (from c in db.MemberExercisePlans
                                      where c.Id == iMemberExsercisePlanId
                                      select c).FirstOrDefault();
         return(myPlan);
     }
     finally
     {
         db.Database.Connection.Close();
     }
 }
Ejemplo n.º 14
0
 public PrizeExercisePlan GetCurrentOrStartingExercisePlanInfo(int iMemberId)
 {
     try
     {
         MemberExercisePlan myPlan = GetCurrentMemberPlanOrStartingPlan(iMemberId);
         if (myPlan == null)
         {
             return(null);
         }
         return(GetExercisePlan(myPlan.ExercisePlanId));
     }
     finally
     {
     }
 }
Ejemplo n.º 15
0
    protected void btnTaskDone_Click(object sender, EventArgs e)
    {
        var sTargetLevel              = result.Text;
        PrizeMemberPlanManager man    = new PrizeMemberPlanManager();
        MemberExercisePlan     myPlan = dbAccess.GetCurrentMemberPlan(PrizeMemberAuthUtils.GetMemberID());

        if (myPlan == null)
        {
            Response.Write(PrizeConstants.CONST_JS_WARNING_PLAN_NOT_START);
            return;
        }

        man.ChangeMemberPlanLevel(myPlan.Id, sTargetLevel);
        dbAccess.UpdateOrientationWeekDayResult(myPlan.Id, 2, 2, true);
        Response.Redirect("/orientation/day-2/get-familiar-with-the-deadlift");
    }
Ejemplo n.º 16
0
 public MemberExercisePlan GetCurrentMemberPausedPlan(int iMemberId)
 {
     try
     {
         db.Database.Connection.Open();
         string             status = PrizeConstants.STATUS_PLAN_SUSPENDED + PrizeConstants.STATUS_PLAN_PAID;
         MemberExercisePlan myPlan = (from c in db.MemberExercisePlans
                                      where c.MemberId == iMemberId && c.Status.Equals(status)
                                      select c).FirstOrDefault();
         return(myPlan);
     }
     finally
     {
         db.Database.Connection.Close();
     }
 }
Ejemplo n.º 17
0
    protected void Page_Load(object sender, EventArgs e)
    {
        DateTime myDate = GetOrientationDate(2);

        lblDay.Text  = myDate.ToString("dddd d").ToUpper();
        lblDate.Text = myDate.ToString("MMMM, yyyy");
        MemberExercisePlan myPlan = dbAccess.GetCurrentMemberPlan(PrizeMemberAuthUtils.GetMemberID());

        if (myPlan == null)
        {
            Response.Write(PrizeConstants.CONST_JS_WARNING_PLAN_NOT_START);
            this.div1.Visible = false;
            return;
        }
        var acc = new PrizeDataAccess();
        PrizeExercisePlan plan = acc.GetExercisePlan(myPlan.ExercisePlanId);

        if (plan.PlanName.ToLower().Contains("muscle"))
        {
            divMuscle.Attributes.Add("class", "show-pg-b");
            hiddenPlan.Text = "muscle";
        }
        if (plan.PlanName.ToLower().Contains("tone"))
        {
            divTone.Attributes.Add("class", "show-pg-t");
            hiddenPlan.Text = "tone";
        }
        if (plan.PlanName.ToLower().Contains("weight"))
        {
            divWeight.Attributes.Add("class", "show-pg-l");
            hiddenPlan.Text = "weight";
        }


        var planName  = acc.GetPlanName(plan);
        var sPlanName = planName.Split('_');

        hiddenLocation.Text = sPlanName[1].ToLower();
        if (sPlanName[1].ToLower() == "gym")
        {
            divFitness.Attributes.Add("class", "tab-inner-content show-gym");
        }
        else
        {
            divFitness.Attributes.Add("class", "tab-inner-content show-home");
        }
    }
Ejemplo n.º 18
0
    public int RemainningWeeks(int memberId)
    {
        int iWeeks = 0;
        MemberExercisePlan curMemberPlan = GetCurrentMemberPlan(memberId);
        MemberExercisePlan startingPlan  = GetMemberStartingPlan(memberId);

        try
        {
            db.Database.Connection.Open();
            if (curMemberPlan != null)
            {
                IQueryable <MemberExercisePlanWeek> weeks = (from l in db.MemberExercisePlanWeeks
                                                             where l.MemberExercisePlanId == curMemberPlan.Id
                                                             orderby l.ExercisePlanWeekId descending
                                                             select l);

                foreach (var week in weeks)
                {
                    if (week.Status.Equals(PrizeConstants.STATUS_PLAN_WEEK_NOT_STARTED))
                    {
                        iWeeks++;
                    }
                }
            }

            if (startingPlan != null)
            {
                IQueryable <MemberExercisePlanWeek> weeks = (from l in db.MemberExercisePlanWeeks
                                                             where l.MemberExercisePlanId == startingPlan.Id
                                                             orderby l.ExercisePlanWeekId descending
                                                             select l);

                foreach (var week in weeks)
                {
                    if (week.Status.Equals(PrizeConstants.STATUS_PLAN_WEEK_NOT_STARTED))
                    {
                        iWeeks++;
                    }
                }
            }
            return(iWeeks);
        }
        finally
        {
            db.Database.Connection.Close();
        }
    }
Ejemplo n.º 19
0
    protected void btnTaskDone_Click(object sender, EventArgs e)
    {
        MemberExercisePlan myPlan = dbAccess.GetCurrentMemberPlan(PrizeMemberAuthUtils.GetMemberID());

        if (myPlan == null)
        {
            Response.Write(PrizeConstants.CONST_JS_WARNING_PLAN_NOT_START);
            return;
        }
        var member = PrizeMemberAuthUtils.GetMemberData();

        if (member != null)
        {
            string temp = string.Format(@"
<html>
<body>
<div>1. What is your training goal and when do you want to achieve it by?</div>
<div>{0}</div>
<br />
<div>2. Have you tried to achieve this goal before and didn't succeed?</div>
<div>{1}</div>
<br />
<div>If yes, explain why you didn't succeed.</div>
<div>{2}</div>
<div>3. Why is this goal important to you.</div>
<div>{3}</div>
<br />
<div>4. Have you ever exercised previously?</div>
<div>{4}</div>
<br />
<div>5. What type of exercise have you been doing in the last 3 months until today? Choose the answer which reflects the predominant part of your weekly routine.</div>
<div>{5}</div>
<br />
<div>6. Where do you exercise majority of the time?</div>
<div>{6}</div>
<br />
<div>7. What obstacles do you foresee stopping you from achieving your goals?</div>
<div>{7}</div>
</body>
</html>", oriTextarea1.Text, radioButtonListGoalBefore.SelectedValue, oriTextarea2.Text,
                                        oriTextarea3.Text, radioButtonListEverExercise.SelectedValue, radioButtonListExerciseType.SelectedValue,
                                        radioButtonListLocation.SelectedValue, oriTextarea7.Text);
            PrizeEmail.SendEmail("*****@*****.**", "Pre-exercise by " + member.Email, temp);
        }
        dbAccess.UpdateOrientationWeekDayResult(myPlan.Id, 1, 2, true);
        Response.Redirect("/orientation/day-1/get-familiar-with-the-squat");
    }
Ejemplo n.º 20
0
    protected void btnPauseResume_Click(object sender, EventArgs e)
    {
        PrizeDataAccess dbAccess = new PrizeDataAccess();

        if (this.ddlPauseResume.Text.Equals("Pause"))
        {
            MemberExercisePlan     myPlan = dbAccess.GetCurrentMemberPlanOrStartingPlan(memberId);
            PrizeMemberPlanManager man    = new PrizeMemberPlanManager();
            if (myPlan == null)
            {
                Response.Write("<script>alert('Can't find the user's available plan.');</script>");
            }
            else
            {
                if (!man.PauseMemberPlan(myPlan.Id))
                {
                    Response.Write("<script>alert('Error happens when pausing the plan.');</script>");
                }
                else
                {
                    Response.Write("<script>alert('The plan is paused);</script>");
                }
            }
        }
        else if (this.ddlPauseResume.Text.Equals("Resume"))
        {
            MemberExercisePlan     myPlan = dbAccess.GetCurrentMemberPausedPlan(memberId);
            PrizeMemberPlanManager man    = new PrizeMemberPlanManager();
            if (myPlan == null)
            {
                Response.Write("<script>alert('Can't find the user's paused plan.');</script>");
            }
            else
            {
                if (!man.ResumeMemberPlan(myPlan.Id))
                {
                    Response.Write("<script>alert('Error happens when resuming the plan.');</script>");
                }
                else
                {
                    Response.Write("<script>alert('The plan is resumed);</script>");
                }
            }
        }
        this.BindGrid();
        return;
    }
Ejemplo n.º 21
0
    public bool PauseMemberPlan(int myPlanId)
    {
        bool          ret = false;
        DIYPTEntities db  = new DIYPTEntities();

        try
        {
            db.Database.Connection.Open();

            MemberExercisePlan myPlan = (from c in db.MemberExercisePlans
                                         where c.Id == myPlanId
                                         select c).FirstOrDefault();
            if (myPlan == null)
            {
                return(ret);
            }

            IQueryable <MemberExercisePlanWeek> myPlanWeeks = (from c in db.MemberExercisePlanWeeks
                                                               where c.MemberExercisePlanId == myPlan.Id
                                                               orderby c.Week
                                                               select c);
            foreach (var planWeek in myPlanWeeks)
            {
                if (planWeek.Status.Equals(PrizeConstants.STATUS_PLAN_WEEK_STARTED) || planWeek.Status.Equals(PrizeConstants.STATUS_PLAN_WEEK_NOT_STARTED))
                {
                    planWeek.Status = PrizeConstants.STATUS_PLAN_WEEK_SUSPENDED;
                }
            }
            myPlan.Status = PrizeConstants.STATUS_PLAN_SUSPENDED + myPlan.Status[1];

            db.SaveChanges();

            return(true);
        }
        catch
        {
            return(false);
        }
        finally
        {
            db.Dispose();
        }
    }
Ejemplo n.º 22
0
    protected void LoadFoodPlanWeek(int memberId, MemberExercisePlan memberPlan, int weekNum)
    {
        MemberFoodPlanWeek foodplanweek;

        foodplanweek = dbAccess.GetMemberFoodPlanWeek(memberId, memberPlan.Id, weekNum, false);

        ddlWeek.SelectedValue = "" + weekNum;

        if (foodplanweek != null)
        {
            tbFood1.Text = foodplanweek.Food1;
            tbFood2.Text = foodplanweek.Food2;
            tbFood3.Text = foodplanweek.Food3;
            tbFood4.Text = foodplanweek.Food4;
            if (foodplanweek.Food5 != null)
            {
                string[] sPersentage = foodplanweek.Food5.Split(';');
                if (sPersentage.Length > 0)
                {
                    tbFood5.Text = sPersentage[0];
                    if (sPersentage.Length > 1)
                    {
                        tbFood6.Text = sPersentage[1];
                        if (sPersentage.Length > 2)
                        {
                            tbFood7.Text = sPersentage[2];
                        }
                    }
                }
            }
            ddlWeek.SelectedValue = "" + foodplanweek.StartWeek;
        }
        else
        {
            tbFood1.Text = string.Empty;
            tbFood2.Text = string.Empty;
            tbFood3.Text = string.Empty;
            tbFood4.Text = string.Empty;
            tbFood5.Text = string.Empty;
            tbFood6.Text = string.Empty;
            tbFood7.Text = string.Empty;
        }
    }
Ejemplo n.º 23
0
    public string GetPlanInfoForPublish()
    {
        string      planInfo = "";
        PrizeMember member   = PrizeMemberAuthUtils.GetMemberData();

        if (member == null)
        {
            return(planInfo);
        }
        MemberExercisePlan myPlan = this.GetCurrentMemberPlanOrStartingPlan(member.UmbracoId);

        if (myPlan == null)
        {
            return(planInfo);
        }
        PrizeExercisePlan plan = this.GetExercisePlan(myPlan.ExercisePlanId);

        char c = PrizeMemberAuthUtils.GetMemberSetting(member.UserSettings, PrizeConstants.MemberSettings.ShowProgram);

        if (c != '0')
        {
            PrizePlanProgram level = (from tbl in db.PrizePlanPrograms
                                      where tbl.Id == plan.ProgramId
                                      select tbl).SingleOrDefault();
            planInfo += level.Name;
        }

        c = PrizeMemberAuthUtils.GetMemberSetting(member.UserSettings, PrizeConstants.MemberSettings.ShowLevel);
        if (c != '0')
        {
            PrizePlanLevel level = (from tbl in db.PrizePlanLevels
                                    where tbl.Id == plan.LevelId
                                    select tbl).SingleOrDefault();
            if (!planInfo.Equals(""))
            {
                planInfo += " ";
            }
            planInfo += level.Name;
        }

        return(planInfo);
    }
Ejemplo n.º 24
0
    protected MemberExercisePlan GetNextMemberPlanNeedToPay(int iMemberId)
    {
        DIYPTEntities db = new DIYPTEntities();

        try
        {
            db.Database.Connection.Open();
            string             statusNotPaid = PrizeConstants.STATUS_PLAN_NOT_STARTED + PrizeConstants.STATUS_PLAN_NOT_PAID;
            string             statusWeekly  = PrizeConstants.STATUS_PLAN_NOT_STARTED + PrizeConstants.STATUS_PLAN_MANUAL_PAYMENT;
            MemberExercisePlan myPlan        = (from c in db.MemberExercisePlans
                                                where c.MemberId == iMemberId && (c.Status.Equals(statusNotPaid) || c.Status.Equals(statusWeekly))
                                                orderby c.Id descending
                                                select c).FirstOrDefault();
            return(myPlan);
        }
        finally
        {
            db.Dispose();
        }
    }
Ejemplo n.º 25
0
    public string GetEmptyPlanJumpURL(PrizeMember member)
    {
        string             sURL   = "";
        PrizeDataAccess    db     = new PrizeDataAccess();
        MemberExercisePlan myPlan = db.GetCurrentMemberPausedPlan(member.UmbracoId);

        if (myPlan != null)
        {
            sURL = PrizeConstants.URL_MEMBER_PLAN_SUSPENDED;
            return(sURL);
        }

        myPlan = GetNextMemberPlanNeedToPay(member.UmbracoId);
        if (myPlan == null)
        {
            sURL = String.Format("{0}?loginName={1}&memberId={2}", PrizeConstants.URL_MEMBER_CONTINUE_PLAN, member.Email, member.UmbracoId);
        }
        else
        {
            sURL = String.Format("{0}?targetplanid={1}&targetmemberplanid={2}", PrizeConstants.URL_MEMBER_BUY_PLAN, myPlan.ExercisePlanId, myPlan.Id);
        }
        return(sURL);
    }
Ejemplo n.º 26
0
    protected void btnChangeLevel_Click(object sender, EventArgs e)
    {
        var sTargetLevel                = ddlLevel.SelectedItem.Text;
        PrizeMemberPlanManager man      = new PrizeMemberPlanManager();
        PrizeDataAccess        dbAccess = new PrizeDataAccess();
        MemberExercisePlan     myPlan   = dbAccess.GetCurrentMemberPlanOrStartingPlan(memberId);

        if (myPlan == null)
        {
            Response.Write("<script>alert('Can't find the user's plan.');</script>");
        }
        else
        {
            if (!man.ChangeMemberPlanLevel(myPlan.Id, sTargetLevel))
            {
                Response.Write("<script>alert('The level of the current program not in the database.');</script>");
            }
            else
            {
                Response.Write("<script>alert('The user's level has been changed to " + sTargetLevel + ");</script>");
            }
        }
        this.BindGrid();
    }
Ejemplo n.º 27
0
    private void DisplayExercise()
    {
        string            tempScript = "<script>";
        int               memberId   = PrizeMemberAuthUtils.GetMemberID();
        PrizeExercisePlan plan       = dbAccess.GetNotStartedExercisePlan(memberId);

        if (plan == null)
        {
            MemberExercisePlan curMemberPlan = dbAccess.GetCurrentMemberPlan(memberId);
            if (curMemberPlan != null)
            {
                plan = dbAccess.GetExercisePlan(curMemberPlan.ExercisePlanId);
            }
            if (plan == null)
            {
                plan = dbAccess.GetLastFinishedExercisePlan(memberId);
            }
        }

        if (plan == null)
        {
            return;
        }

        var acc         = new PrizeDataAccess();
        var planDetails = acc.GetPlanName(plan);
        var planArray   = planDetails.Split('_');

        switch (planArray[0])
        {
        case "Lose Weight":
        case "Tone Up":
            if (planArray[1] == "Home")
            {
                tempScript           += @"$('#exerciseModal1').load('/exercise/pushups-on-knees');
                    $('#exerciseModal2').load('/exercise/powerband-push-press');
                    $('#exerciseModal3').load('/exercise/powerband-pushup-on-knees');";
                imgExercise1.ImageUrl = "/media/13400/landscape_pushup_on_knees_step1.jpg";
                imgExercise2.ImageUrl = "/media/14686/landscape_powerband_push_press_step1.jpg";
                imgExercise3.ImageUrl = "/media/15048/landscape_powerband_pushup_on_knees.jpg";

                lblExercise1.Text = "Pushups on knees";
                lblExercise2.Text = "Powerband push press";
                lblExercise3.Text = "Powerband pushup on knees";
            }
            else
            {
                tempScript           += @"$('#exerciseModal1').load('/exercise/pushups-on-knees');
                    $('#exerciseModal2').load('/exercise/bb-strict-press');
                    $('#exerciseModal3').load('/exercise/bb-push-press');";
                imgExercise1.ImageUrl = "/media/13400/landscape_pushup_on_knees_step1.jpg";
                imgExercise2.ImageUrl = "/media/13358/landscape_bb_strict_press_step1.jpg";
                imgExercise3.ImageUrl = "/media/13357/landscape_bb_push_press_step1.jpg";
                lblExercise1.Text     = "Push ups on knees";
                lblExercise2.Text     = "BB strict press";
                lblExercise3.Text     = "BB push press";
            }
            break;

        case "Build Muscle":
            if (planArray[1] == "Home")
            {
                tempScript           += @"$('#exerciseModal1').load('/exercise/powerband-push-press');
                    $('#exerciseModal2').load('/exercise/Powerband-floor-chest-press');
                    $('#exerciseModal3').load('/exercise/Powerband-pushup-on-toes');";
                imgExercise1.ImageUrl = "/media/14686/landscape_powerband_push_press_step1.jpg";
                imgExercise2.ImageUrl = "/media/15015/landscape_powerband_floor_chest_press_step1.jpg";
                imgExercise3.ImageUrl = "/media/15049/landscape_powerband-_pushup_on_toes.jpg";
                lblExercise1.Text     = "Powerband push press";
                lblExercise2.Text     = "Powerband floor chest press";
                lblExercise3.Text     = "Powerband pushup on toes";
            }
            else
            {
                tempScript           += @"$('#exerciseModal1').load('/exercise/Pushups-on-toes');
                    $('#exerciseModal2').load('/exercise/BB-flat-bench-press');
                    $('#exerciseModal3').load('/exercise/BB-incline-bench-press');";
                imgExercise1.ImageUrl = "/media/13403/landscape_pushup_on_toes_step1.jpg";
                imgExercise2.ImageUrl = "/media/13331/landscape_bb_flat_bench_press_step1.jpg";
                imgExercise3.ImageUrl = "/media/13328/landscape_bb_incline_bench_press_step1.jpg";
                lblExercise1.Text     = "Pushups on toes";
                lblExercise2.Text     = "BB flat bench press";
                lblExercise3.Text     = "BB incline bench press";
            }
            break;

        default:
            break;
        }
        tempScript += "</script>";
        Page.ClientScript.RegisterStartupScript(this.GetType(), "modalPopup", tempScript, false);
    }
Ejemplo n.º 28
0
 protected void ShowNewPlan(PrizeExercisePlan plan, MemberExercisePlan myPlan)
 {
     //if (myPlan.StartDate != null)
     //    lblPlan.Text = dbAccess.GetPlanName(plan);   //plan.PlanName +" Start on " + PrizeCommonUtils.ParseDateTime((DateTime)myPlan.StartDate);
 }
Ejemplo n.º 29
0
    private void DisplayExercise()
    {
        string            tempScript = "<script>";
        int               memberId   = PrizeMemberAuthUtils.GetMemberID();
        PrizeExercisePlan plan       = dbAccess.GetNotStartedExercisePlan(memberId);

        if (plan == null)
        {
            MemberExercisePlan curMemberPlan = dbAccess.GetCurrentMemberPlan(memberId);
            if (curMemberPlan != null)
            {
                plan = dbAccess.GetExercisePlan(curMemberPlan.ExercisePlanId);
            }
            if (plan == null)
            {
                plan = dbAccess.GetLastFinishedExercisePlan(memberId);
            }
        }

        if (plan == null)
        {
            return;
        }

        var acc         = new PrizeDataAccess();
        var planDetails = acc.GetPlanName(plan);
        var planArray   = planDetails.Split('_');

        switch (planArray[0])
        {
        case "Lose Weight":
        case "Tone Up":
            if (planArray[1] == "Home")
            {
                tempScript           += @"$('#exerciseModal1').load('/exercise/Side-plank');
                    $('#exerciseModal2').load('/exercise/Powerband-high-to-low-woodchop');
                    $('#exerciseModal3').load('/exercise/Side-plank-powerband-pull');";
                imgExercise1.ImageUrl = "/media/15009/landscape_side_plank_step1.jpg";
                imgExercise2.ImageUrl = "/media/14715/landscape_powerband_high_to_low_woodchop_step1.jpg";
                imgExercise3.ImageUrl = "/media/15150/landscape_side_plank_powerband_pull_step1.jpg";

                lblExercise1.Text = "Side plank";
                lblExercise2.Text = "Powerband high to low woodchop";
                lblExercise3.Text = "Side plank powerband pull";
            }
            else
            {
                tempScript           += @"$('#exerciseModal1').load('/exercise/Ab-circles');
                    $('#exerciseModal2').load('/exercise/Cable-mid-woodchop');
                    $('#exerciseModal3').load('/exercise/Deadball-woodchop-slam');";
                imgExercise1.ImageUrl = "/media/15145/landscape_ab_circles.jpg";
                imgExercise2.ImageUrl = "/media/15126/landscape_cable_woodchop-mid_step1.jpg";
                imgExercise3.ImageUrl = "/media/14403/landscape_deadball_woodchop_slam_step1.jpg";

                lblExercise1.Text = "Ab circles";
                lblExercise2.Text = "Cable mid woodchop";
                lblExercise3.Text = "Deadball woodchop slam";
            }
            break;

        case "Build Muscle":
            if (planArray[1] == "Home")
            {
                tempScript           += @"$('#exerciseModal1').load('/exercise/Side-plank');
                    $('#exerciseModal2').load('/exercise/Powerband-high-to-low-woodchop');
                    $('#exerciseModal3').load('/exercise/Powerband-pallof-press');";
                imgExercise1.ImageUrl = "/media/15009/landscape_side_plank_step1.jpg";
                imgExercise2.ImageUrl = "/media/14715/landscape_powerband_high_to_low_woodchop_step1.jpg";
                imgExercise3.ImageUrl = "/media/14689/landscape_powerband_pallof_press_step1.jpg";

                lblExercise1.Text = "Side plank";
                lblExercise2.Text = "Powerband high to low woodchop";
                lblExercise3.Text = "Powerband pallof press";
            }
            else
            {
                tempScript           += @"$('#exerciseModal1').load('/exercise/Ab-circles');
                    $('#exerciseModal2').load('/exercise/Cable-low-to-high-woodchop');
                    $('#exerciseModal3').load('/exercise/Cable-pallof-press');";
                imgExercise1.ImageUrl = "/media/15145/landscape_ab_circles.jpg";
                imgExercise2.ImageUrl = "/media/15123/landscape_cable_woodchop-low_to_high_step1.jpg";
                imgExercise3.ImageUrl = "/media/15106/landscape_cable_pallof_press_step1.jpg";

                lblExercise1.Text = "Ab circles";
                lblExercise2.Text = "Cable low to high woodchop";
                lblExercise3.Text = "Cable pallof press";
            }
            break;

        default:
            break;
        }
        tempScript += "</script>";
        Page.ClientScript.RegisterStartupScript(this.GetType(), "modalPopup", tempScript, false);
    }
Ejemplo n.º 30
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();
        }
    }