예제 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        MembershipUser currentUser = Membership.GetUser();
        AccountClass objAccountClass;
        objAccountClass = new AccountClass(objSqlConnClass.sqlConnection);
        BackofficeClass objBackOfficeClass;
        objBackOfficeClass = new BackofficeClass(objSqlConnClass.OpenConnection());
        DataSet DS = objBackOfficeClass.Mem_GET_UserInfo(currentUser.UserName);
        if (DS != null)
        {
            if (DS.Tables[0].Rows.Count > 0)
            {
                if (DS.Tables[0].Rows[0]["ROLENAME"].ToString().Equals("User"))
                {
                    string strTemp = DS.Tables[0].Rows[0]["strRiskStratificationProcessStep"].ToString();
                    if (DS.Tables[0].Rows[0]["strRiskStratificationProcessStep"].ToString().Equals(string.Empty) || DS.Tables[0].Rows[0]["strRiskStratificationProcessStep"].ToString() != "6")
                        Response.Redirect(AppConfig.GetBaseSiteUrl() + "Users/RiskStratificationProcessStep1.aspx?id=" + AppLib.Encrypt(currentUser.UserName), true);
                }
            }
        }

        DS = null;

        objTemplateClass = new TemplateClass(objSqlConnClass.OpenConnection());
    }
    protected void lnkBtnSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            /*if (!chkWaiverAgreement.Checked)
            {
                lblError.Text = "Please accept the waiver agreement";
                return;
            }
            else
            {*/
                SqlConnClass objSqlConnClass = new SqlConnClass();
                BackofficeClass objBackOfficeClass = new BackofficeClass();
                PALClass objPALClass;
                objPALClass = new PALClass(objSqlConnClass.OpenConnection());
                objBackOfficeClass = new BackofficeClass(objSqlConnClass.sqlConnection);

                DataSet DS1 = objBackOfficeClass.Mem_GET_UserInfo(AppLib.GetLoggedInUserName());
                if (DS1 != null)
                {
                    if (DS1.Tables[0].Rows.Count > 0)
                    {
                        BLL.UserLib oUserLib = new BLL.UserLib();
                        oUserLib.UpdateUserStratificationStep(new Guid(DS1.Tables[0].Rows[0]["USER_ID"].ToString()), "3");
                        oUserLib = null;
                        Response.Redirect(AppConfig.GetBaseSiteUrl() + "Users/RiskStratificationProcessStep4.aspx?id=" + Request.QueryString["id"].ToString() + "&c=" + Request.QueryString["c"].ToString() + "&sc=" + Request.QueryString["sc"].ToString());
                    }
                }
            //}
        }
        catch { }
    }
    protected void lnkBtnSubmit_Click(object sender, EventArgs e)
    {
        try
        {

            SqlConnClass objSqlConnClass = new SqlConnClass();
            BackofficeClass objBackOfficeClass = new BackofficeClass();
            DDClass objDDClass;
            objDDClass = new DDClass(objSqlConnClass.OpenConnection());
            objBackOfficeClass = new BackofficeClass(objSqlConnClass.sqlConnection);
            DataSet DS1 = objBackOfficeClass.Mem_GET_UserInfo(AppLib.GetLoggedInUserName());
            if (DS1 != null)
            {
                if (DS1.Tables[0].Rows.Count > 0)
                {
                    DataSet DS = objDDClass.DD_INSERT_DdUsers(DS1.Tables[0].Rows[0]["USER_ID"].ToString(), txtCalories.Text.Trim());
                    objSqlConnClass.CloseConnection();
                    objBackOfficeClass = null;
                    objDDClass = null;
                }
            }

            BLL.UserLib oUserLib = new BLL.UserLib();
            oUserLib.UpdateUserStratificationStep(new Guid(DS1.Tables[0].Rows[0]["USER_ID"].ToString()), "5");
            oUserLib = null;

            Response.Redirect(AppConfig.GetBaseSiteUrl() + "Users/RiskStratificationProcessStep6.aspx?id=" + Request.QueryString["id"].ToString() + "&c=" + Request.QueryString["c"].ToString() + "&sc=" + Request.QueryString["sc"].ToString());
        }
        catch { }
    }
    protected void lnkbtnSave_Click(object sender, EventArgs e)
    {
        BackofficeClass objBackOfficeClass = new BackofficeClass();
        DataSet DS = objBackOfficeClass.Mem_GET_UserInfo(AppLib.GetLoggedInUserName());

        BLL.HotSectionDetailsLib oHotSectionDetailsLib = null;
        Entity.HotSectionDetailsInfo oHotSectionDetailsInfo = null;
        try
        {

            oHotSectionDetailsInfo = new Entity.HotSectionDetailsInfo();
            if (txtHeading.Text.Length > 500)
                oHotSectionDetailsInfo.StrHeading = txtHeading.Text.Substring(0, 498);
            else
                oHotSectionDetailsInfo.StrHeading = txtHeading.Text.Trim();

            oHotSectionDetailsInfo.StrDescription = txtDescription.Text.Trim();
            oHotSectionDetailsInfo.DtCreatedOn = DateTime.Now;
            oHotSectionDetailsInfo.StrLink = string.Empty;
            oHotSectionDetailsInfo.ChrIsDeleted = 'N';
            oHotSectionDetailsInfo.ChrDisplayOnDashboard = 'Y';
            oHotSectionDetailsInfo.GuidUserId = new Guid(DS.Tables[0].Rows[0]["USER_ID"].ToString());
            oHotSectionDetailsLib = new BLL.HotSectionDetailsLib();
            if (ViewState["IntHotSectionId"] != null)
            {
                oHotSectionDetailsInfo.IntHotSectionId = Convert.ToInt32(ViewState["IntHotSectionId"]);
                ViewState["IntHotSectionId"] = null;
                if (oHotSectionDetailsLib.UpdateHotSectionDetails(oHotSectionDetailsInfo) > 0)
                    Response.Redirect(AppConfig.GetBaseSiteUrl() + "BackOffice/UserUtilities/ManageHotLinks.aspx?msg=up");
                else
                    lblMsg.Text = "Record already exists.";
            }
            else
            {
                if (oHotSectionDetailsLib.SaveHotSectionDetails(oHotSectionDetailsInfo) > 0)
                    Response.Redirect(AppConfig.GetBaseSiteUrl() + "BackOffice/UserUtilities/ManageHotLinks.aspx?msg=ins");
                else
                    lblMsg.Text = "Record already exists.";
            }
        }
        catch (Exception ex) { lblMsg.Text = ex.Message; }
        finally
        {
            DS = null;
            objBackOfficeClass = null;
            oHotSectionDetailsInfo = null;
            oHotSectionDetailsLib = null;
        }
    }
    protected void lnkBtnSubmit_Click(object sender, EventArgs e)
    {
        if (hfCategoryId.Value.ToString() == null)
        {
            lblError.Text = "Please accept the waiver agreement";
            return;
        }
        else
        {
            try
            {
                SqlConnClass objSqlConnClass = new SqlConnClass();
                BackofficeClass objBackOfficeClass = new BackofficeClass();
                PALClass objPALClass;
                objPALClass = new PALClass(objSqlConnClass.OpenConnection());
                objBackOfficeClass = new BackofficeClass(objSqlConnClass.sqlConnection);

                DataSet DS1 = objBackOfficeClass.Mem_GET_UserInfo(AppLib.GetLoggedInUserName());
                if (DS1 != null)
                {
                    if (DS1.Tables[0].Rows.Count > 0)
                    {
                        DataSet DS = objPALClass.PAL_INSERTMULTIPLE_PalStarts(DS1.Tables[0].Rows[0]["USER_ID"].ToString(), hfCategoryId.Value, DateTime.Now.ToString("MM/dd/yyyy"), "1");

                        objSqlConnClass.CloseConnection();

                        objBackOfficeClass = null;
                        objPALClass = null;
                        BLL.UserLib oUserLib = new BLL.UserLib();
                        oUserLib.UpdateUserStratificationStep(new Guid(DS1.Tables[0].Rows[0]["USER_ID"].ToString()), "4");
                        oUserLib = null;
                        DS = null;

                        Response.Redirect(AppConfig.GetBaseSiteUrl() + "Users/RiskStratificationProcessStep5.aspx?id=" + Request.QueryString["id"].ToString() + "&c=" + Request.QueryString["c"].ToString() + "&sc=" + Request.QueryString["sc"].ToString());

                    }
                }

                objSqlConnClass.CloseConnection();
                objBackOfficeClass = null;
                objPALClass = null;
            }
            catch { }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        //Session["strUserName"] = "******";
        if (!AppLib.IsLoggedinSessionExists())
        {
            lblError.Text = "Your session has been expired. Please login again";
            return;
        }

        //AppLib.GetLoggedInUserName());
        #region Insert visited log details

        AppLib.InsertVisitedSectionDetails("Risk Stratification Process Step 6");

        #endregion

        if (!Page.IsPostBack)
        {
            SqlConnClass objSqlConnClass = new SqlConnClass();
            BackofficeClass objBackOfficeClass = new BackofficeClass();
            DDClass objDDClass;
            objDDClass = new DDClass(objSqlConnClass.OpenConnection());
            objBackOfficeClass = new BackofficeClass(objSqlConnClass.sqlConnection);
            DataSet DS1 = objBackOfficeClass.Mem_GET_UserInfo(AppLib.GetLoggedInUserName());
            if (DS1 != null)
            {
                if (DS1.Tables[0].Rows.Count > 0)
                {
                    BLL.UserLib oUserLib = new BLL.UserLib();
                    oUserLib.UpdateUserStratificationStep(new Guid(DS1.Tables[0].Rows[0]["USER_ID"].ToString()), "6");
                    oUserLib = null;
                }
            }

            objBackOfficeClass = null;
            objDDClass = null;
            DS1 = null;
        }

        BindCMSText();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        MembershipUser currentUser = Membership.GetUser();
        if (!AppLib.IsLoggedinSessionExists() || currentUser == null)
            Response.Redirect(AppConfig.GetBaseSiteUrl() + "Welcome/main_frame.aspx", true);

        objSqlConnClass.OpenConnection();

        AccountClass objAccountClass;
        objAccountClass = new AccountClass(objSqlConnClass.sqlConnection);
        BackofficeClass objBackOfficeClass;
        objBackOfficeClass = new BackofficeClass(objSqlConnClass.sqlConnection);

        #region Insert visited log details

        //AppLib.InsertVisitedSectionDetails("Dashboard Page");

        #endregion

        DataSet DS = objBackOfficeClass.Mem_GET_UserInfo(currentUser.UserName);
        if (DS != null)
        {
            if (DS.Tables[0].Rows.Count > 0)
            {
                if (DS.Tables[0].Rows[0]["ROLENAME"].ToString().Equals("User"))
                {
                    if (DS.Tables[0].Rows[0]["strRiskStratificationProcessStep"].ToString().Equals(string.Empty) || DS.Tables[0].Rows[0]["strRiskStratificationProcessStep"].ToString() != "6")
                    {
                        DS = null;
                        Response.Redirect(AppConfig.GetBaseSiteUrl() + "Users/RiskStratificationProcessStep1.aspx?id=" + AppLib.Encrypt(currentUser.UserName), true);
                    }
                }
            }
        }

        DS = null;

        objTemplateClass = new TemplateClass(objSqlConnClass.sqlConnection);

        objPALClass = new PALClass(objSqlConnClass.sqlConnection);
    }
    private void UpdatePersonalSummaryDetails()
    {
        BackofficeClass objBackOfficeClass = new BackofficeClass();
        DataSet DS = objBackOfficeClass.Mem_GET_UserInfo(AppLib.GetLoggedInUserName());
        BLL.PersonalSummaryLib oPersonalSummaryLib = null;
        Entity.PersonalSummaryInfo oPersonalSummaryInfo = null;
        try
        {
            oPersonalSummaryLib = new BLL.PersonalSummaryLib();
            oPersonalSummaryInfo = new Entity.PersonalSummaryInfo();

            oPersonalSummaryInfo.DecBMI = Convert.ToDecimal(txtCurrentBMI.Text);
            oPersonalSummaryInfo.DecBodyFATPercentage = Convert.ToDecimal(txtCurrentBodyFAT.Text);
            oPersonalSummaryInfo.DecWaist = Convert.ToDecimal(txtCurrentWaist.Text);
            oPersonalSummaryInfo.DecWaistToHeight = Convert.ToDecimal(txtCurrentWaistToHeight.Text);
            oPersonalSummaryInfo.DecWaistToHip = Convert.ToDecimal(txtCurrentWaistToHips.Text);
            oPersonalSummaryInfo.DecWeight = Convert.ToDecimal(txtCurrentWeight.Text);
            oPersonalSummaryInfo.DtCreatedOn = DateTime.Now;
            oPersonalSummaryInfo.GuidUserId = new Guid(DS.Tables[0].Rows[0]["USER_ID"].ToString());
            oPersonalSummaryLib.SavePersonalSummaryDetails(oPersonalSummaryInfo);
            Response.Redirect(AppConfig.GetBaseSiteUrl() + "Main/MyNutrition.aspx?msg=up");

        }
        catch (Exception ex) { throw ex; }
        finally
        {
            oPersonalSummaryInfo = null;
            oPersonalSummaryLib = null;
            objBackOfficeClass = null;
            DS = null;

        }
    }
    /// <summary>
    /// following function is used to bind the personal summary details.
    /// </summary>
    private void BindPersonalSummaryDetails()
    {
        lblCurrentPersonalSummary.Text = DateTime.Now.ToShortDateString();
        BLL.PersonalSummaryLib oPersonalSummaryLib = null;
        Entity.PersonalSummaryInfo oPersonalSummaryInfo = null;
        BackofficeClass objBackOfficeClass = new BackofficeClass();
        DataSet DS = objBackOfficeClass.Mem_GET_UserInfo(AppLib.GetLoggedInUserName());
        try
        {
            oPersonalSummaryLib = new BLL.PersonalSummaryLib();
            oPersonalSummaryInfo = new Entity.PersonalSummaryInfo();

            oPersonalSummaryInfo = oPersonalSummaryLib.GetPersonalSummaryDetailsByUserId(new Guid(DS.Tables[0].Rows[0]["USER_ID"].ToString()));
            if (oPersonalSummaryInfo != null)
            {
                ViewState["isExists"] = "1";

                lblStartDatePersonalSummary.Text = oPersonalSummaryInfo.DtModifiedOn.ToShortDateString();
                txtStartWeight.Text = oPersonalSummaryInfo.DecWeight.ToString("00.00");
                txtStartWaistToHips.Text = oPersonalSummaryInfo.DecWaistToHip.ToString("00.00");
                txtStartWaistToHeight.Text = oPersonalSummaryInfo.DecWaistToHeight.ToString("00.00");
                txtStartWaist.Text = oPersonalSummaryInfo.DecWaist.ToString("00.00");
                txtStartBodyFAT.Text = oPersonalSummaryInfo.DecBodyFATPercentage.ToString("00.00");
                txtStartBMI.Text = oPersonalSummaryInfo.DecBMI.ToString("00.00");
            }
            else
                ViewState["isExists"] = "0";
        }
        catch (Exception ex) { throw ex; }
        finally
        {
            oPersonalSummaryLib = null;
            oPersonalSummaryInfo = null;
            objBackOfficeClass = null;
            DS = null;
        }
    }
    protected void lnkBtnSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            bool blnIsChecked = false;

            foreach (GridViewRow gvRow in GVQuestionnaire.Rows)
            {
                RadioButtonList rdoListAnswer = (RadioButtonList)gvRow.FindControl("rdoListAnswer");
                if (!blnIsChecked)
                {
                    if (rdoListAnswer != null)
                    {
                        if (rdoListAnswer.SelectedValue.Equals("Yes"))
                        {
                            blnIsChecked = true;
                            break;
                        }
                    }
                }
                else
                {
                    break;
                }
            }

            if (blnIsChecked)
            {
                if (!chkWaiverAgreement.Checked)
                {
                    lblError.Text = "Please accept the waiver agreement";
                    return;
                }
                else
                {
                    List<Entity.QuestionnaireInfo> oListQuestionnaireInfo = new List<Entity.QuestionnaireInfo>();

                    foreach (GridViewRow gvr in GVQuestionnaire.Rows)
                    {
                        Entity.QuestionnaireInfo oQuestionnaireInfo = new Entity.QuestionnaireInfo();
                        oQuestionnaireInfo.DtCreatedDate = DateTime.Now;
                        Label lblQuestionId = (Label)gvr.FindControl("lblQuestionId");
                        Label lblQuestion = (Label)gvr.FindControl("lblQuestion");
                        RadioButtonList rdoListAnswer = (RadioButtonList)gvr.FindControl("rdoListAnswer");

                        if (lblQuestionId != null && lblQuestion != null)
                        {
                            oQuestionnaireInfo.IntQuestionnaireId = Convert.ToInt32(lblQuestionId.Text);
                            oQuestionnaireInfo.StrQuestion = lblQuestion.Text;
                            oQuestionnaireInfo.StrAnswer = rdoListAnswer.SelectedValue;
                        }

                        oListQuestionnaireInfo.Add(oQuestionnaireInfo);
                        oQuestionnaireInfo = null;
                    }

                    BackofficeClass objBackOfficeClass = new BackofficeClass();
                    DataSet DS = objBackOfficeClass.Mem_GET_UserInfo(AppLib.GetLoggedInUserName());
                    if (DS != null)
                    {
                        if (DS.Tables[0].Rows.Count > 0)
                        {
                            BLL.QuestionnaireLib oQuestionnaireLib = new BLL.QuestionnaireLib();
                            oQuestionnaireLib.SaveUserRiskStratificationProcessDetailsPartB(oListQuestionnaireInfo, new Guid(DS.Tables[0].Rows[0]["USER_ID"].ToString()));

                            DS = null;
                            objBackOfficeClass = null;
                            oListQuestionnaireInfo = null;
                            Response.Redirect(AppConfig.GetBaseSiteUrl() + "Users/RiskStratificationProcessStep2.aspx?id=" + Request.QueryString["id"].ToString());
                        }
                    }
                }
            }

            else
            {
                Response.Redirect(AppConfig.GetBaseSiteUrl() + "Users/RiskStratificationProcessStep2.aspx?id=" + Request.QueryString["id"].ToString());
            }

        }

        catch (Exception ex) { lblError.Text = ex.Message; }
    }
    protected void lnkBtnSubmit_Click(object sender, EventArgs e)
    {
        BLL.QuestionnaireLib oQuestionnaireLib = new BLL.QuestionnaireLib();
        try
        {

            bool bolIsPositiveRiskFactor = false;
            int intPositiveRiskFactor = 0;
            int intNegativeRiskFactor = 0;
            //Response.Redirect(AppConfig.GetBaseSiteUrl() + "Users/RiskStratificationProcessStep3.aspx?id=" + Request.QueryString["id"].ToString());
            foreach (GridViewRow gvr in GVQuestionnaireHeading.Rows)
            {
                Label lblQuestionHeading = (Label)gvr.FindControl("lblQuestionHeading");
                GridView GVQuestion = (GridView)gvr.FindControl("GVQuestion");
                string strQuestHeading = lblQuestionHeading.Text;

                if (lblQuestionHeading != null)
                {
                    if (!strQuestHeading.ToLower().Equals("age"))
                    {
                        foreach (GridViewRow gvrQuestions in GVQuestion.Rows)
                        {
                            Label lblQuestionId = (Label)gvrQuestions.FindControl("lblQuestionId");
                            RadioButtonList rdoListAnswer = (RadioButtonList)gvrQuestions.FindControl("rdoListAnswer");

                            if (lblQuestionId.Text.Equals("18"))
                            {

                                //18 means 45 old
                            }
                            else if (lblQuestionId.Text.Equals("19"))
                            {
                                //19 means 55 old

                            }
                        }
                    }

                    if (strQuestHeading.ToLower().Equals("positive risk factor"))
                    {
                        foreach (GridViewRow gvrQuestions in GVQuestion.Rows)
                        {
                            RadioButtonList rdoListAnswer = (RadioButtonList)gvrQuestions.FindControl("rdoListAnswer");
                            if (rdoListAnswer != null)
                            {
                                if (rdoListAnswer.SelectedValue.Equals("Yes"))
                                    bolIsPositiveRiskFactor = true;
                            }
                        }
                    }
                    else if (strQuestHeading.ToLower().Equals("cholesterol"))
                    {
                        bool blnIsAdded = false;
                        foreach (GridViewRow gvrQuestions in GVQuestion.Rows)
                        {
                            RadioButtonList rdoListAnswer = (RadioButtonList)gvrQuestions.FindControl("rdoListAnswer");
                            if (rdoListAnswer.SelectedValue.Equals("Yes"))
                            {
                                if (!blnIsAdded)
                                {
                                    blnIsAdded = true;
                                    intNegativeRiskFactor = intNegativeRiskFactor + 1;
                                }
                            }
                        }
                    }
                    else if (strQuestHeading.ToLower().Equals("hypertension"))
                    {
                        bool blnIsAdded = false;
                        foreach (GridViewRow gvrQuestions in GVQuestion.Rows)
                        {
                            RadioButtonList rdoListAnswer = (RadioButtonList)gvrQuestions.FindControl("rdoListAnswer");
                            if (rdoListAnswer.SelectedValue.Equals("Yes"))
                            {
                                if (!blnIsAdded)
                                {
                                    blnIsAdded = true;
                                    intNegativeRiskFactor = intNegativeRiskFactor + 1;
                                }
                            }
                        }
                    }
                    else if (strQuestHeading.ToLower().Equals("smoking"))
                    {
                        foreach (GridViewRow gvrQuestions in GVQuestion.Rows)
                        {
                            RadioButtonList rdoListAnswer = (RadioButtonList)gvrQuestions.FindControl("rdoListAnswer");
                            if (rdoListAnswer.SelectedValue.Equals("Yes"))
                            {
                                //Response.Write("smoking=" + intNegativeRiskFactor);
                                intNegativeRiskFactor = intNegativeRiskFactor + 1;
                            }
                        }
                    }
                    else if (strQuestHeading.ToLower().Equals("pre-diabetes"))
                    {
                        foreach (GridViewRow gvrQuestions in GVQuestion.Rows)
                        {
                            RadioButtonList rdoListAnswer = (RadioButtonList)gvrQuestions.FindControl("rdoListAnswer");
                            if (rdoListAnswer.SelectedValue.Equals("Yes"))
                                intNegativeRiskFactor = intNegativeRiskFactor + 1;
                        }
                    }
                    else if (strQuestHeading.ToLower().Equals("weight"))
                    {
                        foreach (GridViewRow gvrQuestions in GVQuestion.Rows)
                        {
                            RadioButtonList rdoListAnswer = (RadioButtonList)gvrQuestions.FindControl("rdoListAnswer");
                            if (rdoListAnswer.SelectedValue.Equals("Yes"))
                                intNegativeRiskFactor = intNegativeRiskFactor + 1;
                        }
                    }
                    else if (strQuestHeading.ToLower().Equals("activity factor"))
                    {
                        foreach (GridViewRow gvrQuestions in GVQuestion.Rows)
                        {
                            RadioButtonList rdoListAnswer = (RadioButtonList)gvrQuestions.FindControl("rdoListAnswer");
                            if (rdoListAnswer.SelectedValue.Equals("Yes"))
                                intNegativeRiskFactor = intNegativeRiskFactor + 1;
                        }
                    }
                }
            }

            if (bolIsPositiveRiskFactor)
                intNegativeRiskFactor = intNegativeRiskFactor - 1;

            int intScore = 0;
            int intCategory = 0;

            //intScore = intNegativeRiskFactor - intPositiveRiskFactor;
            intScore = intNegativeRiskFactor;
            objBackOfficeClass = new BackofficeClass();
            string strEmailId = AppLib.Decrypt(Request.QueryString["id"].ToString());

            if (!oQuestionnaireLib.HasUserGivenYesAnswerinFirstRiskStratificationStep(strEmailId))
            {
                oQuestionnaireLib = null;
                DataSet DS = objBackOfficeClass.Mem_GET_UserInfo(strEmailId);
                if (DS != null)
                {
                    if (DS.Tables[0].Rows.Count > 0)
                    {
                        int intCurrentYear = DateTime.Now.Year;
                        int intBirthYear = Convert.ToDateTime(DS.Tables[0].Rows[0]["DATE_BIRTH"]).Year;
                        int intPresentAge = intCurrentYear - intBirthYear;

                        int intGenderCode = Convert.ToInt32(DS.Tables[0].Rows[0]["GENDER_ID"]);
                        if ((intGenderCode.Equals(1) && intPresentAge <= 45) || (intGenderCode.Equals(2) && intPresentAge <= 55))
                        {///1 = male, 2= female
                            if (intScore <= 1)
                            {
                                /*Well category Low Risk*/
                                intCategory = 0;
                                category = "Well";
                            }
                            if (intScore >= 2)
                            {
                                /*Living category Medium Risk*/
                                intCategory = 2;
                                category = "Living";
                            }
                        }
                        else if ((intGenderCode.Equals(1) && intPresentAge > 45) || (intGenderCode.Equals(2) && intPresentAge > 55))
                        {///1 = male, 2= female
                            if (intScore >= 2)
                            {
                                /*Living category Medium Risk*/
                                intCategory = 2;
                                category = "Living";
                            }
                            if (intScore <= 1)
                            {
                                /*Well category Low Risk*/
                                intCategory = 0;
                                category = "Well";
                            }
                        }
                        else
                        {
                            intCategory = 1;
                            category = "Tri";
                            //try and high risk
                            /*if user given any yes answer at the step 1 questions*/
                        }
                    }
                }

                DS = null;
                objBackOfficeClass = null;
            }
            else
            {  //try and high risk
                intCategory = 1;
                category = "Tri";
                /*Means user given any yes answer at the step 1 questions*/

            }

            List<Entity.QuestionnaireInfo> oListQuestionnaireInfo = new List<Entity.QuestionnaireInfo>();

            foreach (GridViewRow gvr in GVQuestionnaireHeading.Rows)
            {
                GridView GVQuestion = (GridView)gvr.FindControl("GVQuestion");
                if (GVQuestion != null)
                {
                    foreach (GridViewRow gvrQuestion in GVQuestion.Rows)
                    {
                        Entity.QuestionnaireInfo oQuestionnaireInfo = new Entity.QuestionnaireInfo();
                        oQuestionnaireInfo.DtCreatedDate = DateTime.Now;
                        Label lblQuestionId = (Label)gvrQuestion.FindControl("lblQuestionId");
                        Label lblQuestion = (Label)gvrQuestion.FindControl("lblQuestion");
                        RadioButtonList rdoListAnswer = (RadioButtonList)gvrQuestion.FindControl("rdoListAnswer");

                        if (lblQuestionId != null && lblQuestion != null)
                        {
                            oQuestionnaireInfo.IntQuestionnaireId = Convert.ToInt32(lblQuestionId.Text);
                            oQuestionnaireInfo.StrQuestion = lblQuestion.Text;
                            oQuestionnaireInfo.StrAnswer = rdoListAnswer.SelectedValue;
                        }

                        oListQuestionnaireInfo.Add(oQuestionnaireInfo);
                        oQuestionnaireInfo = null;
                    }
                }

            }

            objBackOfficeClass = new BackofficeClass();
            DataSet DS1 = objBackOfficeClass.Mem_GET_UserInfo(AppLib.GetLoggedInUserName());
            if (DS1 != null)
            {
                if (DS1.Tables[0].Rows.Count > 0)
                {
                    oQuestionnaireLib = new BLL.QuestionnaireLib();
                    oQuestionnaireLib.SaveUserRiskStratificationProcessDetailsStepSecond(oListQuestionnaireInfo, new Guid(DS1.Tables[0].Rows[0]["USER_ID"].ToString()));

                    BLL.UserLib oUserLib = new BLL.UserLib();
                    if (!oUserLib.CheckUserAssessmentAlreadyExists(new Guid(DS1.Tables[0].Rows[0]["USER_ID"].ToString())))
                        objBackOfficeClass.Mem_INSERT_UserAssessments(DS1.Tables[0].Rows[0]["USER_ID"].ToString(), "1", intScore.ToString());

                    objBackOfficeClass = null;
                    oListQuestionnaireInfo = null;
                    DS1 = null;
                    oUserLib = null;
                    Response.Redirect(AppConfig.GetBaseSiteUrl() + "Users/RiskStratificationProcessStep3.aspx?id=" + Request.QueryString["id"].ToString() + "&sc=" + AppLib.Encrypt(intScore.ToString()) + "&c=" + AppLib.Encrypt(intCategory.ToString()) + "&cat=" + category.ToString());
                }
            }
        }
        catch (Exception ex) { lblError.Text = ex.Message; }
        finally { oQuestionnaireLib = null; }
    }
    /// <summary>
    /// following function is used to check whether the current logged in user is male or female
    /// </summary>
    private void FindLoggedInUserGender()
    {
        string strEmailId = AppLib.Decrypt(Request.QueryString["id"].ToString());
        objBackOfficeClass = new BackofficeClass();
        DataSet DS = objBackOfficeClass.Mem_GET_UserInfo(strEmailId);
        if (DS != null)
        {
            if (DS.Tables[0].Rows.Count > 0)
                intGenderID = Convert.ToInt32(DS.Tables[0].Rows[0]["GENDER_ID"]);
        }

        DS = null;
        objBackOfficeClass = null;
    }
    protected void lnkCalculateScore_Click(object sender, EventArgs e)
    {
        try
        {
            bool bolIsPositiveRiskFactor = false;
            int intPositiveRiskFactor = 0;
            int intNegativeRiskFactor = 0;
            //Response.Redirect(AppConfig.GetBaseSiteUrl() + "Users/RiskStratificationProcessStep3.aspx?id=" + Request.QueryString["id"].ToString());
            foreach (GridViewRow gvr in GVQuestionnaireHeading.Rows)
            {
                Label lblQuestionHeading = (Label)gvr.FindControl("lblQuestionHeading");
                GridView GVQuestion = (GridView)gvr.FindControl("GVQuestion");
                string strQuestHeading = lblQuestionHeading.Text;

                if (lblQuestionHeading != null)
                {
                    if (!strQuestHeading.ToLower().Equals("age"))
                    {
                        foreach (GridViewRow gvrQuestions in GVQuestion.Rows)
                        {
                            Label lblQuestionId = (Label)gvrQuestions.FindControl("lblQuestionId");
                            RadioButtonList rdoListAnswer = (RadioButtonList)gvrQuestions.FindControl("rdoListAnswer");

                            if (lblQuestionId.Text.Equals("18"))
                            {

                                //18 means 45 old
                            }
                            else if (lblQuestionId.Text.Equals("19"))
                            {
                                //19 means 55 old

                            }
                        }
                    }

                    if (strQuestHeading.ToLower().Equals("positive risk factor"))
                    {
                        foreach (GridViewRow gvrQuestions in GVQuestion.Rows)
                        {
                            RadioButtonList rdoListAnswer = (RadioButtonList)gvrQuestions.FindControl("rdoListAnswer");
                            if (rdoListAnswer != null)
                            {
                                if (rdoListAnswer.SelectedValue.Equals("Yes"))
                                    bolIsPositiveRiskFactor = true;
                            }
                        }
                    }
                    else if (strQuestHeading.ToLower().Equals("cholesterol"))
                    {
                        bool blnIsAdded = false;
                        foreach (GridViewRow gvrQuestions in GVQuestion.Rows)
                        {
                            RadioButtonList rdoListAnswer = (RadioButtonList)gvrQuestions.FindControl("rdoListAnswer");
                            if (rdoListAnswer.SelectedValue.Equals("Yes"))
                            {
                                if (!blnIsAdded)
                                {
                                    blnIsAdded = true;
                                    intNegativeRiskFactor = intNegativeRiskFactor + 1;
                                }
                            }
                        }
                    }
                    else if (strQuestHeading.ToLower().Equals("hypertension"))
                    {
                        bool blnIsAdded = false;
                        foreach (GridViewRow gvrQuestions in GVQuestion.Rows)
                        {
                            RadioButtonList rdoListAnswer = (RadioButtonList)gvrQuestions.FindControl("rdoListAnswer");
                            if (rdoListAnswer.SelectedValue.Equals("Yes"))
                            {
                                if (!blnIsAdded)
                                {
                                    blnIsAdded = true;
                                    intNegativeRiskFactor = intNegativeRiskFactor + 1;
                                }
                            }
                        }
                    }
                    else if (strQuestHeading.ToLower().Equals("smoking"))
                    {
                        foreach (GridViewRow gvrQuestions in GVQuestion.Rows)
                        {
                            RadioButtonList rdoListAnswer = (RadioButtonList)gvrQuestions.FindControl("rdoListAnswer");
                            if (rdoListAnswer.SelectedValue.Equals("Yes"))
                            {
                                //Response.Write("smoking=" + intNegativeRiskFactor);
                                intNegativeRiskFactor = intNegativeRiskFactor + 1;
                            }
                        }
                    }
                    else if (strQuestHeading.ToLower().Equals("pre-diabetes"))
                    {
                        foreach (GridViewRow gvrQuestions in GVQuestion.Rows)
                        {
                            RadioButtonList rdoListAnswer = (RadioButtonList)gvrQuestions.FindControl("rdoListAnswer");
                            if (rdoListAnswer.SelectedValue.Equals("Yes"))
                                intNegativeRiskFactor = intNegativeRiskFactor + 1;
                        }
                    }
                    else if (strQuestHeading.ToLower().Equals("weight"))
                    {
                        foreach (GridViewRow gvrQuestions in GVQuestion.Rows)
                        {
                            RadioButtonList rdoListAnswer = (RadioButtonList)gvrQuestions.FindControl("rdoListAnswer");
                            if (rdoListAnswer.SelectedValue.Equals("Yes"))
                                intNegativeRiskFactor = intNegativeRiskFactor + 1;
                        }
                    }
                    else if (strQuestHeading.ToLower().Equals("activity factor"))
                    {
                        foreach (GridViewRow gvrQuestions in GVQuestion.Rows)
                        {
                            RadioButtonList rdoListAnswer = (RadioButtonList)gvrQuestions.FindControl("rdoListAnswer");
                            if (rdoListAnswer.SelectedValue.Equals("Yes"))
                                intNegativeRiskFactor = intNegativeRiskFactor + 1;
                        }
                    }
                }
            }

            //   Response.Write(intNegativeRiskFactor.ToString());

            if (bolIsPositiveRiskFactor)
                intNegativeRiskFactor = intNegativeRiskFactor - 1;

            int intScore = 0;
            int intCategory = 0;
            //intScore = intNegativeRiskFactor - intPositiveRiskFactor;
            intScore = intNegativeRiskFactor;
            objBackOfficeClass = new BackofficeClass();
            string strEmailId = AppLib.Decrypt(Request.QueryString["id"].ToString());

            DataSet DS = objBackOfficeClass.Mem_GET_UserInfo(strEmailId);
            if (DS != null)
            {
                if (DS.Tables[0].Rows.Count > 0)
                {
                    int intCurrentYear = DateTime.Now.Year;
                    int intBirthYear = Convert.ToDateTime(DS.Tables[0].Rows[0]["DATE_BIRTH"]).Year;
                    int intPresentAge = intCurrentYear - intBirthYear;

                    int intGenderCode = Convert.ToInt32(DS.Tables[0].Rows[0]["GENDER_ID"]);
                    if ((intGenderCode.Equals(1) && intPresentAge <= 45) || (intGenderCode.Equals(2) && intPresentAge <= 55))
                    {///1 = male, 2= female
                        if (intScore <= 1)
                        {
                            /*Well category Low Risk*/
                            intCategory = 0;
                            category = "Well";
                        }

                        if (intScore >= 2)
                        {
                            /*Living category Medium Risk*/
                            intCategory = 2;
                            category = "Living";
                        }
                    }
                    else if ((intGenderCode.Equals(1) && intPresentAge > 45) || (intGenderCode.Equals(2) && intPresentAge > 55))
                    {///1 = male, 2= female
                        if (intScore >= 2)
                        {
                            /*Living category Medium Risk*/
                            intCategory = 2;
                            category = "Living";
                        }
                        if (intScore <= 1)
                        {
                            /*Well category Low Risk*/
                            intCategory = 0;
                            category = "Well";
                        }
                    }
                    else
                    {
                        intCategory = 1;
                        category = "Tri";
                        //try and high risk
                        /*if user given any yes answer at the step 1 questions*/
                    }
                }
            }

            DS = null;
            objBackOfficeClass = null;

            //lblTotalScore.Text = "Your Score:" + " " + intScore.ToString();
        }
        catch { }
        finally { }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        objPALClass = new PALClass(objSqlConnClass.OpenConnection());
        gsUserID = Membership.GetUser().ProviderUserKey.ToString();

        MembershipUser currentUser = Membership.GetUser();
        if (!AppLib.IsLoggedinSessionExists() || currentUser == null)
            Response.Redirect(AppConfig.GetBaseSiteUrl() + "Welcome/main_frame.aspx", true);

        AccountClass objAccountClass;
        objAccountClass = new AccountClass(objSqlConnClass.sqlConnection);
        BackofficeClass objBackOfficeClass;
        objBackOfficeClass = new BackofficeClass(objSqlConnClass.OpenConnection());

        #region Insert visited log details

        AppLib.InsertVisitedSectionDetails("Dashboard Page");

        #endregion

        DataSet DS = objBackOfficeClass.Mem_GET_UserInfo(currentUser.UserName);
        if (DS != null)
        {
            if (DS.Tables[0].Rows.Count > 0)
            {
                if (DS.Tables[0].Rows[0]["ROLENAME"].ToString().Equals("User"))
                {
                    if (DS.Tables[0].Rows[0]["strRiskStratificationProcessStep"].ToString().Equals(string.Empty) || DS.Tables[0].Rows[0]["strRiskStratificationProcessStep"].ToString() != "6")
                    {
                        DS = null;
                        Response.Redirect(AppConfig.GetBaseSiteUrl() + "Users/RiskStratificationProcessStep1.aspx?id=" + AppLib.Encrypt(currentUser.UserName), true);
                    }
                }
            }
        }
        BindNutritionalJournal();
        DS = null;

        objTemplateClass = new TemplateClass(objSqlConnClass.OpenConnection());

        int ileftMargin = 0;
        string sTriangleImg = "triangle1.jpg";
        int iMET = 0;
        string sLastWorkout = "";
        DataSet entries = objPALClass.PAL_GET_PalEntries_BY_UserId(gsUserID, "", "");
        foreach (DataRow DR in entries.Tables[0].Rows)
        {
            iMET += Convert.ToInt32(DR["MET_EQUIVALENT"]);
            sLastWorkout = DR["PAL_ENTRY_DATE"].ToString();
        }
        labelLastWorkout.Text = sLastWorkout;

        iMET = 100;
        // 0
        if (iMET <= 0)
        {
            ileftMargin = 7;
            sTriangleImg = "triangle1.jpg";
        }
        // 1
        else if (iMET <= 100)
        {
            ileftMargin = 32;
            sTriangleImg = "triangle1.jpg";
        }
        // 2
        else if (iMET <= 200)
        {
            ileftMargin = 52;
            sTriangleImg = "triangle2.jpg";
        }
        // 3
        else if (iMET <= 300)
        {
            ileftMargin = 72;
            sTriangleImg = "triangle3.jpg";
        }
        // 4
        else if (iMET <= 400)
        {
            ileftMargin = 92;
            sTriangleImg = "triangle4.jpg";
        }
        // 5
        else if (iMET <= 500)
        {
            ileftMargin = 112;
            sTriangleImg = "triangle5.jpg";
        }
        // 6
        else if (iMET <= 600)
        {
            ileftMargin = 132;
            sTriangleImg = "triangle6.jpg";
        }
        // 7
        else if (iMET <= 700)
        {
            ileftMargin = 152;
            sTriangleImg = "triangle7.jpg";
        }
        // 8
        else if (iMET <= 800)
        {
            ileftMargin = 172;
            sTriangleImg = "triangle8.jpg";
        }
        // 9
        else if (iMET <= 900)
        {
            ileftMargin = 192;
            sTriangleImg = "triangle9.jpg";
        }
        // 10
        else if (iMET > 900)
        {
            ileftMargin = 212;
            sTriangleImg = "triangle10.jpg";
        }
        literalTriangle.Text = "<img style='margin-left:20px;' src='" + AppConfig.GetBaseSiteUrl() + "Images/dashboard/" + sTriangleImg + "' />";
        literalMetsMarker.Text = "<div style='width:30px;margin-left:" + ileftMargin.ToString() + "px;margin-top:-7px;font-weight:bold;font-size:larger;font-color:Black;text-align:center;line-height:80%'>&#9650;<br />" + iMET.ToString() + "</div>";

        getActivitiesData();
    }
    private void BindDetails()
    {
        BackofficeClass objBackOfficeClass = new BackofficeClass();
        DataSet DS = objBackOfficeClass.Mem_GET_UserInfo(AppLib.GetLoggedInUserName());

        BLL.HotSectionDetailsLib oHotSectionDetailsLib = null;

        try
        {
            oHotSectionDetailsLib = new BLL.HotSectionDetailsLib();
            Guid _guidUserID = new Guid(DS.Tables[0].Rows[0]["USER_ID"].ToString());
            GVLinks.DataSource = oHotSectionDetailsLib.GetAllHotSectionsByUserId(_guidUserID);
            GVLinks.DataBind();

        }
        catch (Exception ex) { lblMsg.Text = ex.Message; }
        finally
        {
            DS = null;
            objBackOfficeClass = null;
            oHotSectionDetailsLib = null;
        }
    }