public AwardPoints(int PID) {
            patron = Patron.FetchObject(PID);
            pgm = Programs.FetchObject(patron.ProgID);
            EarnedBadges = new List<Badge>();

            StartingPoints = PatronPoints.GetTotalPatronPoints(patron.PID);
            EndingPoints = StartingPoints;
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if(!IsPostBack) {
         LoadProgram();
     } else {
         if(ViewState["Program"] == null) {
             LoadProgram();
         } else {
             this.CurrentProgram = (Programs)ViewState["Program"];
         }
     }
 }
        public string GetMGIDs(Patron patron, Programs pgm, ProgramGame gm, int StartingPoints, int defMGID = 0, int whichMinigames = 1) {
            //Tally up the points  
            //var level = 0;
            //var points = 0;
            var bonus = false;
            string ret = defMGID == 0 ? "" : defMGID.ToString();
            var prefix1 = whichMinigames == 1 ? "1" : "2";
            var prefixBonus = bonus ? "Bonus" : "";

            if(pgm.ProgramGameID > 0) {
                // only if we have a game we can earn badges by reading ....
                var ds = ProgramGameLevel.GetAll(gm.PGID);

                var normalLevelTotalPoints = GetGameCompletionPoints(ds);
                //var bonusLevelTotalPoints = GetGameCompletionBonusPoints(ds, gm.BonusLevelPointMultiplier);

                bonus = (StartingPoints > normalLevelTotalPoints);

                // loop thru the levels to see where we are at ... before awarding the new points
                var rp = StartingPoints;   //remaining points
                if(bonus) {
                    prefixBonus = string.Empty;   // first do all non bonus levels
                    // if we are on the bonus, we have access to all of them
                    for(var i = 0; i < ds.Tables[0].Rows.Count; i++) {
                        var MGIDfield = string.Format("Minigame{0}ID{1}", prefix1, prefixBonus);
                        if(Convert.ToInt32(ds.Tables[0].Rows[i][MGIDfield]) != 0) {
                            ret = string.Format("{0}{1}{2}", ret, (ret.Length > 0 ? "," : ""), Convert.ToInt32(ds.Tables[0].Rows[i][MGIDfield]));
                        }
                    }
                    rp = StartingPoints - normalLevelTotalPoints;
                }

                prefixBonus = bonus ? "Bonus" : "";
                // we have not tallied the bonus levels yet, or if not on bonus mode we have not tallied the regular levels yet ....
                for(var i = 0; i < ds.Tables[0].Rows.Count; i++) {
                    var multiplier = (bonus ? gm.BonusLevelPointMultiplier : 1.00m);
                    var levelPoints = Convert.ToInt32(Convert.ToInt32(ds.Tables[0].Rows[i]["PointNumber"]) * multiplier);
                    rp = rp - levelPoints;
                    if(rp < 0) {
                        return ret;
                        //break;
                    }
                    var MGIDfield = string.Format("Minigame{0}ID{1}", prefix1, prefixBonus);
                    if(Convert.ToInt32(ds.Tables[0].Rows[i][MGIDfield]) != 0) {
                        ret = string.Format("{0}{1}{2}", ret, (ret.Length > 0 ? "," : ""), Convert.ToInt32(ds.Tables[0].Rows[i][MGIDfield]));
                    }
                }
            }
            return ret;
        }
        public void LoadNextLevelInfo(Patron p, Programs pg, int tp) {
            int level, points;
            bool bonus;
            GetGameInfo(p, pg, tp, out level, out points, out bonus);

            lblNextLevel.Text =
                string.Format(
                    "I'm on <strong>{0}level: {1}</strong>.<br />I need <strong>{2} point{3}</strong> to level up.<br />",
                    bonus ? "bonus " : string.Empty,
                    level,
                    points,
                    points > 1 ? "s" : string.Empty);


        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadProgram();

                DateTime startDate = this.CurrentProgram.StartDate < this.CurrentProgram.LoggingStart
                    ? this.CurrentProgram.StartDate
                    : this.CurrentProgram.LoggingStart;

                DateTime endDate = this.CurrentProgram.EndDate > this.CurrentProgram.LoggingEnd
                    ? this.CurrentProgram.EndDate
                    : this.CurrentProgram.LoggingEnd;

                if (DateTime.Now < startDate)
                {
                    RegisterLoginPanel.Visible = false;
                    NotYetPanel.Visible = true;
                    var notStarted = StringResources.getString("program-not-started");
                    NotStartedField.Text = notStarted.Contains("{0}")
                        ? string.Format(notStarted, startDate.ToLongDateString())
                        : notStarted;
                }
                else if (DateTime.Now > endDate)
                {
                    RegisterLoginPanel.Visible = false;
                    AlreadyOverPanel.Visible = true;
                    var alreadyOver = StringResources.getString("program-already-over");
                    ProgramAlreadyOver.Text = alreadyOver.Contains("{0}")
                        ? string.Format(alreadyOver, endDate.ToLongDateString())
                        : alreadyOver;
                }
            }
            else {
                if (ViewState["Program"] == null)
                {
                    LoadProgram();
                }
                else {
                    this.CurrentProgram = (Programs)ViewState["Program"];
                }
            }
        }
        public void GetGameInfo(Patron patron, Programs pgm, int StartingPoints, out int level, out int points, out bool bonus)
        {
            //Tally up the points
            level = 0;
            points = 0;
            bonus = false;
            if(pgm.ProgramGameID > 0) {
                // only if we have a game we can earn badges by reading ....
                var gm = ProgramGame.FetchObject(pgm.ProgramGameID);
                var ds = ProgramGameLevel.GetAll(gm.PGID);

                var normalLevelTotalPoints = GetGameCompletionPoints(ds);
                var bonusLevelTotalPoints = GetGameCompletionBonusPoints(ds, gm.BonusLevelPointMultiplier);

                bonus = (StartingPoints > normalLevelTotalPoints);

                // loop thru the levels to see where we are at ... before awarding the new points
                var rp = StartingPoints;   //remaining points
                if(bonus) {
                    // if we are on the bonus, eliminate the "fully completed boards/levels) and then see what the remainder of the points is.
                    rp = rp - normalLevelTotalPoints;
                    level = ds.Tables[0].Rows.Count + 1;   // completed all the levels for the "normal"

                    level = level + (int)((int)rp / (int)bonusLevelTotalPoints) * (ds.Tables[0].Rows.Count + 1);

                    rp = rp % bonusLevelTotalPoints;

                }

                for(var i = 0; i < ds.Tables[0].Rows.Count; i++) {
                    var multiplier = (bonus ? gm.BonusLevelPointMultiplier : 1.00m);
                    var levelPoints = Convert.ToInt32(Convert.ToInt32(ds.Tables[0].Rows[i]["PointNumber"]) * multiplier);
                    rp = rp - levelPoints;
                    if(rp < 0) {
                        points = -rp;
                        break;
                    }
                    level++;
                }
            }
        }
Пример #7
0
        public Badge TallyPoints(Patron patron, Programs pgm, int StartingPoints, int EndingPoints, ref List<Badge> EarnedBadges)
        {
            Badge b = null;
            //Tally up the points and figure out if we need to award a badge.
            if(pgm.ProgramGameID > 0) {
                // only if we have a game we can earn badges by reading ....
                var gm = ProgramGame.FetchObject(pgm.ProgramGameID);
                var ds = ProgramGameLevel.GetAll(gm.PGID);

                var normalLevelTotalPoints = GetGameCompletionPoints(ds);
                var bonusLevelTotalPoints = GetGameCompletionBonusPoints(ds, gm.BonusLevelPointMultiplier);

                var bonus = (StartingPoints > normalLevelTotalPoints);
                var bonusPostfix = (bonus ? "Bonus" : "");
                int BeforeLevel = 0, AfterLevel = 0;

                // loop thru the levels to see where we are at ... before awarding the new points
                var rp = StartingPoints;   //remaining points
                if(bonus) {
                    // if we are on the bonus, eliminate the "fully completed boards/levels) and then see what the remainder of the points is.
                    rp = rp - normalLevelTotalPoints;
                    rp = rp % bonusLevelTotalPoints;
                }

                for(var i = 0; i < ds.Tables[0].Rows.Count; i++) {
                    var multiplier = (bonus ? gm.BonusLevelPointMultiplier : 1.00m);
                    var levelPoints = Convert.ToInt32(Convert.ToInt32(ds.Tables[0].Rows[i]["PointNumber"]) * multiplier);
                    rp = rp - levelPoints;
                    if(rp < 0) {
                        BeforeLevel = i;
                        break;
                    }
                }

                // loop thru the levels to see where we are at ... AFTER awarding the new points
                rp = EndingPoints;   //remaining points
                if(bonus) {
                    // if we are on the bonus, eliminate the "fully completed boards/levels) and then see what the remainder of the points is.
                    rp = rp - normalLevelTotalPoints;
                    rp = rp % bonusLevelTotalPoints;
                }
                for(var i = 0; i < ds.Tables[0].Rows.Count; i++) {
                    var multiplier = (bonus ? gm.BonusLevelPointMultiplier : 1.00m);
                    var levelPoints = Convert.ToInt32(Convert.ToInt32(ds.Tables[0].Rows[i]["PointNumber"]) * multiplier);
                    rp = rp - levelPoints;
                    AfterLevel = i;
                    if(rp < 0) {
                        break;
                    } else {
                        if(!((i + 1) < ds.Tables[0].Rows.Count)) {
                            AfterLevel = (i + 1);
                        }
                    }
                }

                if(BeforeLevel != AfterLevel) {
                    // completed the "beforeLevel" and moved up to the "AfterLevel" , so check if we need to award a badge
                    for(var i = BeforeLevel; i < AfterLevel; i++) {
                        var badgeToAward = Convert.ToInt32(ds.Tables[0].Rows[i]["AwardBadgeID" + bonusPostfix]);
                        if(badgeToAward > 0) {
                            b = Badge.GetBadge(badgeToAward);
                            EarnedBadges.Add(b);
                        }
                    }
                }
            }
            return b;
        }
        public void DoBusinessRulesNext(int curStep)
        {
            // code needs to have the steps in order for the ifs to flow properly on panels with now fields showing

            if (curStep == 1)
            {
                //get Age

                var sDOB = ((TextBox)rptr.Items[0].FindControl("DOB")).Text;
                var sAge = ((TextBox)rptr.Items[0].FindControl("Age")).Text;
                var sGrade = ((TextBox)rptr.Items[0].FindControl("SchoolGrade")).Text;

                var age = -1;
                if (!string.IsNullOrEmpty(sDOB))
                {
                    var DOB = DateTime.Parse(sDOB);
                    age = DateTime.Now.Year - DOB.Year;
                }
                else
                {
                    int.TryParse(sAge, out age);
                }

                RegistrationAge.Text = age.ToString();

                // Get Default Program for the Age
                // Set Program to that
                var grade = -1;
                if (sGrade.Length > 0)
                    int.TryParse(sGrade, out grade);

                var pgmDD = (DropDownList)rptr.Items[0].FindControl("ProgID");
                if (pgmDD.Items.Count == 2)
                {
                    // single program - just select the program
                    pgmDD.SelectedIndex = 1;
                }
                else if (pgmDD.SelectedValue == "0" || string.IsNullOrEmpty(pgmDD.SelectedValue))
                {
                    var defaultProgram = Programs.GetDefaultProgramForAgeAndGrade(age, grade).ToString();
                    if (pgmDD.Items.FindByValue(defaultProgram) != null)
                    {
                        pgmDD.SelectedValue = defaultProgram;
                    }
                }


                if (MasterPID.Text.Length > 0)    // Already registered the master account and now looping for family accounts
                {
                    var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString());
                    var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 2).ToString());

                    curPanel.Visible = false;
                    newPanel.Visible = true;

                    Step.Text = (curStep + 2).ToString();
                }
                else
                {
                    if (age > 17 && SRPSettings.GetSettingValue("AllowFamilyAccounts").SafeToBoolYes())
                    {
                        // Ask about adult
                        var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString());
                        var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString());

                        curPanel.Visible = false;
                        newPanel.Visible = true;

                        Step.Text = (curStep + 1).ToString();
                    }
                    else
                    {
                        var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString());
                        var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 2).ToString());

                        curPanel.Visible = false;
                        newPanel.Visible = true;

                        Step.Text = (curStep + 2).ToString();
                    }
                }


            }
            // Finished Current Step = 1

            if (curStep == 2)
            {
                var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString());
                var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString());

                curPanel.Visible = false;
                newPanel.Visible = true;

                Step.Text = (curStep + 1).ToString();

            }
            // Finished Current Step = 2

            if (curStep == 3)
            {
                var pgmDD = (DropDownList)rptr.Items[0].FindControl("ProgID");
                var selectedProgram = DAL.Programs.FetchObject(int.Parse(pgmDD.SelectedValue));
                if (!selectedProgram.IsRegistrationOpen)
                {
                    string programNotOpen;
                    if (DateTime.Now < selectedProgram.StartDate)
                    {
                        programNotOpen = string.Format("This program opens for registration on {0}", selectedProgram.StartDate.ToLongDateString());
                    }
                    else
                    {
                        programNotOpen = string.Format("Registration for this program ended on {0}", selectedProgram.EndDate.ToLongDateString());
                    }

                    new SessionTools(Session).AlertPatron(programNotOpen,
                        PatronMessageLevels.Danger,
                        "exclamation-sign");
                    return;
                }

                var goal = rptr.Items[0].FindControl("Goal") as TextBox;
                if (goal != null
                   && selectedProgram.GoalDefault > 0)
                {
                    goal.Text = selectedProgram.GoalDefault.ToString();
                }

                var sReqField = (HiddenField)rptr.Items[0].FindControl("ASchoolFieldIsRequired");
                var aSchoolFieldIsRequired = bool.Parse(sReqField.Value) == true;

                if (selectedProgram.HideSchoolInRegistration == true
                    && aSchoolFieldIsRequired == false)
                {
                    ((Panel)rptr.Items[0].FindControl("SchoolArea")).Visible = false;
                }
                else
                {
                    ((Panel)rptr.Items[0].FindControl("SchoolArea")).Visible = true;
                }

                var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString());
                var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString());

                curPanel.Visible = false;
                newPanel.Visible = true;

                Step.Text = (curStep + 1).ToString();

                // do we show this next panel?
                var newPanelVisibility = ((TextBox)rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString() + "Visibility")).Text;
                if (newPanelVisibility == "0")
                    curStep = curStep + 1;  // If not, move to the next panel
            }
            // Finished Current Step = 3

            if (curStep == 4)
            {
                var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString());
                var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString());

                curPanel.Visible = false;
                newPanel.Visible = true;

                Step.Text = (curStep + 1).ToString();

                var PID = int.Parse(((DropDownList)rptr.Items[0].FindControl("ProgID")).SelectedValue);
                var selectedProgram = DAL.Programs.FetchObject(PID);

                // disable goal field when the user has a set goal 
                ((TextBox)rptr.Items[0].FindControl("Goal")).Enabled = (selectedProgram.GoalMin != selectedProgram.GoalMax);


                // Goal needs to be modified by ProgramGamePointConversion
                /* If daily goal is enabled we need to find what method point system uses. Just select the first item that is relevant.. */
                foreach (ActivityType activityTypeValue in Enum.GetValues(typeof(ActivityType)))
                {
                    int activityTypeId = (int)activityTypeValue;
                    var pgc = ProgramGamePointConversion.FetchObjectByActivityId(PID,
                                                                             activityTypeId);

                    if (pgc != null && pgc.PointCount > 0)
                    {
                        var range = (RangeValidator)rptr.Items[0].FindControl("GoalRangeValidator");

                        range.MinimumValue = selectedProgram.GoalMin.ToString();
                        range.MaximumValue = selectedProgram.GoalMax.ToString();
                        range.Text = $"{range.MinimumValue}-{range.MaximumValue}";

                        var limitsInfoText = StringResources.getString("registration-goal-limits-note");
                        ((Label)rptr.Items[0].FindControl("RegistrationGoalInfoNoteLabel")).Text = String.Format(limitsInfoText, range.MinimumValue, range.MaximumValue);

                        /* save the activity type id */
                        ViewState["ActivityTypeId"] = activityTypeId.ToString();

                        var intervalString = selectedProgram.GetGoalInterval.ToString();

                        ((Literal)rptr.Items[0].FindControl("GoalLabel")).Text = $"{intervalString} Goal ({activityTypeValue.ToString()}):";
                        // found a valid point conversion for goal so break
                        break;
                    }
                }

                // do we show this next panel?
                var newPanelVisibility = ((TextBox)rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString() + "Visibility")).Text;
                if (newPanelVisibility == "0")
                    curStep = curStep + 1;  // If not, move to the next panel

            }
            // Finished Current Step = 4

            if (curStep == 5)
            {
                var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString());
                var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString());

                curPanel.Visible = false;
                newPanel.Visible = true;

                Step.Text = (curStep + 1).ToString();

                // deal with parental consent, by program
                var PID = int.Parse(((DropDownList)rptr.Items[0].FindControl("ProgID")).SelectedValue);
                var prog = new Programs();
                prog.Fetch(PID);
                ((Literal)rptr.Items[0].FindControl("lblConsent")).Text = Server.HtmlDecode(prog.ParentalConsentText);

                ((Panel)rptr.Items[0].FindControl("pnlConsent")).Visible = prog.ParentalConsentFlag;

                // do we show this next panel?
                var newPanelVisibility = ((TextBox)rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString() + "Visibility")).Text;
                if (newPanelVisibility == "0" && !prog.ParentalConsentFlag)
                    curStep = curStep + 1;  // If not, move to the next panel

            }
            // Finished Current Step = 5

            if (curStep == 6)
            {
                var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString());
                var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString());

                curPanel.Visible = false;
                newPanel.Visible = true;

                Step.Text = (curStep + 1).ToString();
            }
            // Finished Current Step = 6

            if (curStep == 7)
            {
                if (!SaveAccount())
                {
                    return;
                }

                var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString());
                var newPanel = FindControl("Panel" + (curStep + 1).ToString());

                curPanel.Visible = false;
                //newPanel.Visible = true;

                Step.Text = (curStep + 1).ToString();

                var famAcct = (DropDownList)rptr.Items[0].FindControl("FamilyAccount");
                if (famAcct.SelectedValue == "Yes")
                {
                    curStep = 9;  // Move to the next panel
                    Step.Text = "9";
                    curPanel = FindControl("Panel" + curStep.ToString());
                    curPanel.Visible = true;
                    btnPrev.Enabled = false;
                    btnDone.Visible = true;
                    return;
                }
                else
                {
                    // we're done with registration, we can just jump right in
                    TestingBL.CheckPatronNeedsPreTest();
                    TestingBL.CheckPatronNeedsPostTest();

                    Session[SessionKey.PatronMessage] = ((BaseSRPPage)Page).GetResourceString("registration-success");
                    Session[SessionKey.PatronMessageGlyphicon] = "thumbs-up";
                    Response.Redirect("~");
                }

                newPanel.Visible = true;
                btnPrev.Enabled = false;


            }
            // Finished Current Step = 7

            if (curStep == 8)
            {
                var curPanel = FindControl("Panel" + curStep.ToString());
                var newPanel = FindControl("Panel" + (curStep + 1).ToString());

                curPanel.Visible = false;
                newPanel.Visible = true;

                Step.Text = (curStep + 1).ToString();
                btnPrev.Enabled = false;

                // log them in and take them home

                Response.Redirect(GoToUrl);
            }
            // Finished Current Step = 8

            if (curStep == 9)
            {
                // Reset Steps, flag as family members, restart the wizard

                var curPanel = FindControl("Panel" + curStep.ToString());
                var newPanel = rptr.Items[0].FindControl("Panel1");

                curPanel.Visible = false;
                newPanel.Visible = true;

                btnPrev.Enabled = false;
                btnDone.Visible = false;
                Step.Text = "1";
                Panel0.Visible = true;
                RegisteringFamily.Text = "1";
                RegistrationAge.Text = "0";

                ((TextBox)rptr.Items[0].FindControl("ParentGuardianFirstName")).Text = parentGuardianFirst.Text;
                ((TextBox)rptr.Items[0].FindControl("ParentGuardianMiddleName")).Text = parentGuardianMiddle.Text;
                ((TextBox)rptr.Items[0].FindControl("ParentGuardianLastName")).Text = parentGuardianLast.Text;

                ((TextBox)rptr.Items[0].FindControl("Username")).Text = string.Empty;
                ((TextBox)rptr.Items[0].FindControl("Password")).Text = string.Empty;
                ((TextBox)rptr.Items[0].FindControl("Password")).Attributes.Add("Value", string.Empty);
                ((TextBox)rptr.Items[0].FindControl("Password2")).Text = string.Empty;
                ((TextBox)rptr.Items[0].FindControl("Password2")).Attributes.Add("Value", string.Empty);
                ((TextBox)rptr.Items[0].FindControl("Age")).Text = string.Empty;
                ((TextBox)rptr.Items[0].FindControl("DOB")).Text = string.Empty;
                ((TextBox)rptr.Items[0].FindControl("SchoolGrade")).Text = string.Empty;
                ((DropDownList)rptr.Items[0].FindControl("ProgID")).SelectedValue = string.Empty;
                ((TextBox)rptr.Items[0].FindControl("FirstName")).Text = string.Empty;
                ((TextBox)rptr.Items[0].FindControl("MiddleName")).Text = string.Empty;
                ((DropDownList)rptr.Items[0].FindControl("Gender")).SelectedValue = string.Empty;
                ((TextBox)rptr.Items[0].FindControl("LiteracyLevel1")).Text = string.Empty;
                ((TextBox)rptr.Items[0].FindControl("LiteracyLevel2")).Text = string.Empty;
            }
            // Finished Current Step = 9

        }
        public void DoBusinessRulesPrev(int curStep)
        {
            // code needs to have the steps in reverse order for the ifs to flow properly on panels with now fields showing
            if (curStep == 7)
            {
                var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString());
                var newPanel = rptr.Items[0].FindControl("Panel" + (curStep - 1).ToString());

                curPanel.Visible = false;
                newPanel.Visible = true;

                Step.Text = (curStep - 1).ToString();

                // deal with parental consent, by program
                var PID = int.Parse(((DropDownList)rptr.Items[0].FindControl("ProgID")).SelectedValue);
                var prog = new Programs();
                prog.Fetch(PID);
                ((Literal)rptr.Items[0].FindControl("lblConsent")).Text = Server.HtmlDecode(prog.ParentalConsentText);

                ((Panel)rptr.Items[0].FindControl("pnlConsent")).Visible = prog.ParentalConsentFlag;


                // do we show this next panel?
                var newPanelVisibility = ((TextBox)rptr.Items[0].FindControl("Panel" + (curStep - 1).ToString() + "Visibility")).Text;
                if (newPanelVisibility == "0")
                    curStep = curStep - 1;  // If not, move to the prev panel

            }
            // Finished Current Step = 7

            if (curStep == 6)
            {
                var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString());
                var newPanel = rptr.Items[0].FindControl("Panel" + (curStep - 1).ToString());

                curPanel.Visible = false;
                newPanel.Visible = true;

                Step.Text = (curStep - 1).ToString();

                // do we show this next panel?
                var newPanelVisibility = ((TextBox)rptr.Items[0].FindControl("Panel" + (curStep - 1).ToString() + "Visibility")).Text;
                if (newPanelVisibility == "0")
                    curStep = curStep - 1;  // If not, move to the prev panel

            }
            // Finished Current Step = 6


            if (curStep == 5)
            {
                var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString());
                var newPanel = rptr.Items[0].FindControl("Panel" + (curStep - 1).ToString());

                curPanel.Visible = false;
                newPanel.Visible = true;

                Step.Text = (curStep - 1).ToString();

                // do we show this next panel?
                var newPanelVisibility = ((TextBox)rptr.Items[0].FindControl("Panel" + (curStep - 1).ToString() + "Visibility")).Text;
                if (newPanelVisibility == "0")
                    curStep = curStep - 1;  // If not, move to the prev panel
            }
            // Finished Current Step = 5


            if (curStep == 4)
            {
                var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString());
                var newPanel = rptr.Items[0].FindControl("Panel" + (curStep - 1).ToString());

                curPanel.Visible = false;
                newPanel.Visible = true;

                Step.Text = (curStep - 1).ToString();

            }
            // Finished Current Step = 4


            if (curStep == 3)
            {
                //get Age

                var Age = int.Parse(RegistrationAge.Text);

                if (MasterPID.Text.Length > 0)    // Already registered the master account and now looping for family accounts
                {
                    var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString());
                    var newPanel = rptr.Items[0].FindControl("Panel" + (curStep - 2).ToString());

                    curPanel.Visible = false;
                    newPanel.Visible = true;

                    Step.Text = (curStep - 2).ToString();
                }
                else
                {
                    if (Age > 17)
                    {
                        // Ask about adult
                        var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString());
                        var newPanel = rptr.Items[0].FindControl("Panel" + (curStep - 1).ToString());

                        curPanel.Visible = false;
                        newPanel.Visible = true;

                        Step.Text = (curStep - 1).ToString();
                    }
                    else
                    {
                        var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString());
                        var newPanel = rptr.Items[0].FindControl("Panel" + (curStep - 2).ToString());

                        curPanel.Visible = false;
                        newPanel.Visible = true;

                        Step.Text = (curStep - 2).ToString();
                    }
                }


            }
            // Finished Current Step = 3


            if (curStep == 2)
            {
                var sDOB = ((TextBox)rptr.Items[0].FindControl("DOB")).Text;
                var sAge = ((TextBox)rptr.Items[0].FindControl("Age")).Text;
                var sGrade = ((TextBox)rptr.Items[0].FindControl("SchoolGrade")).Text;

                var age = -1;
                if (!string.IsNullOrEmpty(sDOB))
                {
                    var DOB = DateTime.Parse(sDOB);
                    age = DateTime.Now.Year - DOB.Year;
                }
                else
                {
                    int.TryParse(sAge, out age);
                }

                RegistrationAge.Text = age.ToString();

                // Get Default Program for the Age
                // Set Program to that
                var grade = -1;
                if (sGrade.Length > 0)
                    int.TryParse(sGrade, out grade);

                var pgmDD = (DropDownList)rptr.Items[0].FindControl("ProgID");
                if (pgmDD.SelectedValue == "0" || string.IsNullOrEmpty(pgmDD.SelectedValue))
                {
                    pgmDD.SelectedValue = Programs.GetDefaultProgramForAgeAndGrade(age, grade).ToString();
                }


                var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString());
                var newPanel = rptr.Items[0].FindControl("Panel" + (curStep - 1).ToString());

                curPanel.Visible = false;
                newPanel.Visible = true;

                Step.Text = (curStep - 1).ToString();
            }
            // Finished Current Step = 2
        }
Пример #10
0
        public static int Update(Programs o)
        {
            int iReturn = -1; //assume the worst

            SqlParameter[] arrParams = new SqlParameter[46];

            arrParams[0]  = new SqlParameter("@PID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PID, o.PID.GetTypeCode()));
            arrParams[1]  = new SqlParameter("@AdminName", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AdminName, o.AdminName.GetTypeCode()));
            arrParams[2]  = new SqlParameter("@Title", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Title, o.Title.GetTypeCode()));
            arrParams[3]  = new SqlParameter("@TabName", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TabName, o.TabName.GetTypeCode()));
            arrParams[4]  = new SqlParameter("@POrder", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.POrder, o.POrder.GetTypeCode()));
            arrParams[5]  = new SqlParameter("@IsActive", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.IsActive, o.IsActive.GetTypeCode()));
            arrParams[6]  = new SqlParameter("@IsHidden", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.IsHidden, o.IsHidden.GetTypeCode()));
            arrParams[7]  = new SqlParameter("@StartDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.StartDate, o.StartDate.GetTypeCode()));
            arrParams[8]  = new SqlParameter("@EndDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.EndDate, o.EndDate.GetTypeCode()));
            arrParams[9]  = new SqlParameter("@MaxAge", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MaxAge, o.MaxAge.GetTypeCode()));
            arrParams[10] = new SqlParameter("@MaxGrade", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MaxGrade, o.MaxGrade.GetTypeCode()));
            arrParams[11] = new SqlParameter("@LoggingStart", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LoggingStart, o.LoggingStart.GetTypeCode()));
            arrParams[12] = new SqlParameter("@LoggingEnd", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LoggingEnd, o.LoggingEnd.GetTypeCode()));
            arrParams[13] = new SqlParameter("@ParentalConsentFlag", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ParentalConsentFlag, o.ParentalConsentFlag.GetTypeCode()));
            arrParams[14] = new SqlParameter("@ParentalConsentText", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ParentalConsentText, o.ParentalConsentText.GetTypeCode()));
            arrParams[15] = new SqlParameter("@PatronReviewFlag", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PatronReviewFlag, o.PatronReviewFlag.GetTypeCode()));
            arrParams[16] = new SqlParameter("@LogoutURL", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LogoutURL, o.LogoutURL.GetTypeCode()));
            arrParams[17] = new SqlParameter("@ProgramGameID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ProgramGameID, o.ProgramGameID.GetTypeCode()));
            arrParams[18] = new SqlParameter("@HTML1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.HTML1, o.HTML1.GetTypeCode()));
            arrParams[19] = new SqlParameter("@HTML2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.HTML2, o.HTML2.GetTypeCode()));
            arrParams[20] = new SqlParameter("@HTML3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.HTML3, o.HTML3.GetTypeCode()));
            arrParams[21] = new SqlParameter("@HTML4", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.HTML4, o.HTML4.GetTypeCode()));
            arrParams[22] = new SqlParameter("@HTML5", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.HTML5, o.HTML5.GetTypeCode()));
            arrParams[23] = new SqlParameter("@HTML6", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.HTML6, o.HTML6.GetTypeCode()));
            arrParams[24] = new SqlParameter("@BannerImage", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.BannerImage, o.BannerImage.GetTypeCode()));
            arrParams[25] = new SqlParameter("@RegistrationBadgeID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.RegistrationBadgeID, o.RegistrationBadgeID.GetTypeCode()));
            arrParams[26] = new SqlParameter("@CompletionPoints", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.CompletionPoints, o.CompletionPoints.GetTypeCode()));
            arrParams[27] = new SqlParameter("@LastModUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModUser, o.LastModUser.GetTypeCode()));
            arrParams[28] = new SqlParameter("@AddedDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedDate, o.AddedDate.GetTypeCode()));
            arrParams[29] = new SqlParameter("@AddedUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedUser, o.AddedUser.GetTypeCode()));
            arrParams[30] = new SqlParameter("@LastModDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode()));

            arrParams[31] = new SqlParameter("@TenID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TenID, o.TenID.GetTypeCode()));
            arrParams[32] = new SqlParameter("@FldInt1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt1, o.FldInt1.GetTypeCode()));
            arrParams[33] = new SqlParameter("@FldInt2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt2, o.FldInt2.GetTypeCode()));
            arrParams[34] = new SqlParameter("@FldInt3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt3, o.FldInt3.GetTypeCode()));
            arrParams[35] = new SqlParameter("@FldBit1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit1, o.FldBit1.GetTypeCode()));
            arrParams[36] = new SqlParameter("@FldBit2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit2, o.FldBit2.GetTypeCode()));
            arrParams[37] = new SqlParameter("@FldBit3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit3, o.FldBit3.GetTypeCode()));
            arrParams[38] = new SqlParameter("@FldText1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText1, o.FldText1.GetTypeCode()));
            arrParams[39] = new SqlParameter("@FldText2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText2, o.FldText2.GetTypeCode()));
            arrParams[40] = new SqlParameter("@FldText3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText3, o.FldText3.GetTypeCode()));

            arrParams[41] = new SqlParameter("@PreTestID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PreTestID, o.PreTestID.GetTypeCode()));
            arrParams[42] = new SqlParameter("@PostTestID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PostTestID, o.PostTestID.GetTypeCode()));
            arrParams[43] = new SqlParameter("@PreTestMandatory", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PreTestMandatory, o.PreTestMandatory.GetTypeCode()));
            arrParams[44] = new SqlParameter("@PreTestEndDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PreTestEndDate, o.PreTestEndDate.GetTypeCode()));
            arrParams[45] = new SqlParameter("@PostTestStartDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PostTestStartDate, o.PostTestStartDate.GetTypeCode()));

            try
            {
                iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_Programs_Update", arrParams);
            }

            catch (SqlException exx)
            {
                System.Diagnostics.Debug.Write(exx.Message);
            }

            return(iReturn);
        }
        public void DoBusinessRulesNext(int curStep)
        {
            // code needs to have the steps in order for the ifs to flow properly on panels with now fields showing

            if(curStep == 1) {
                //get Age

                var sDOB = ((TextBox)rptr.Items[0].FindControl("DOB")).Text;
                var sAge = ((TextBox)rptr.Items[0].FindControl("Age")).Text;
                var sGrade = ((TextBox)rptr.Items[0].FindControl("SchoolGrade")).Text;

                var age = -1;
                if(!string.IsNullOrEmpty(sDOB)) {
                    var DOB = DateTime.Parse(sDOB);
                    age = DateTime.Now.Year - DOB.Year;
                } else {
                    int.TryParse(sAge, out age);
                }

                RegistrationAge.Text = age.ToString();

                // Get Default Program for the Age
                // Set Program to that
                var grade = -1;
                if(sGrade.Length > 0)
                    int.TryParse(sGrade, out grade);

                var pgmDD = (DropDownList)rptr.Items[0].FindControl("ProgID");
                if(pgmDD.Items.Count == 2) {
                    // single program - just select the program
                    pgmDD.SelectedIndex = 1;
                } else if(pgmDD.SelectedValue == "0" || string.IsNullOrEmpty(pgmDD.SelectedValue)) {
                    var defaultProgram = Programs.GetDefaultProgramForAgeAndGrade(age, grade).ToString();
                    if(pgmDD.Items.FindByValue(defaultProgram) != null) {
                        pgmDD.SelectedValue = defaultProgram;
                    }
                }

                if(MasterPID.Text.Length > 0)    // Already registered the master account and now looping for family accounts
                {
                    var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString());
                    var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 2).ToString());

                    curPanel.Visible = false;
                    newPanel.Visible = true;

                    Step.Text = (curStep + 2).ToString();
                } else {
                    if(age > 17 && SRPSettings.GetSettingValue("AllowFamilyAccounts").SafeToBoolYes()) {
                        // Ask about adult
                        var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString());
                        var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString());

                        curPanel.Visible = false;
                        newPanel.Visible = true;

                        Step.Text = (curStep + 1).ToString();
                    } else {
                        var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString());
                        var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 2).ToString());

                        curPanel.Visible = false;
                        newPanel.Visible = true;

                        Step.Text = (curStep + 2).ToString();
                    }
                }

            }
            // Finished Current Step = 1

            if(curStep == 2) {
                var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString());
                var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString());

                curPanel.Visible = false;
                newPanel.Visible = true;

                Step.Text = (curStep + 1).ToString();

            }
            // Finished Current Step = 2

            if(curStep == 3) {
                var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString());
                var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString());

                curPanel.Visible = false;
                newPanel.Visible = true;

                Step.Text = (curStep + 1).ToString();

                // do we show this next panel?
                var newPanelVisibility = ((TextBox)rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString() + "Visibility")).Text;
                if(newPanelVisibility == "0")
                    curStep = curStep + 1;  // If not, move to the next panel
            }
            // Finished Current Step = 3

            if(curStep == 4) {
                var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString());
                var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString());

                curPanel.Visible = false;
                newPanel.Visible = true;

                Step.Text = (curStep + 1).ToString();

                // do we show this next panel?
                var newPanelVisibility = ((TextBox)rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString() + "Visibility")).Text;
                if(newPanelVisibility == "0")
                    curStep = curStep + 1;  // If not, move to the next panel

            }
            // Finished Current Step = 4

            if(curStep == 5) {
                var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString());
                var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString());

                curPanel.Visible = false;
                newPanel.Visible = true;

                Step.Text = (curStep + 1).ToString();

                // deal with parental consent, by program
                var PID = int.Parse(((DropDownList)rptr.Items[0].FindControl("ProgID")).SelectedValue);
                var prog = new Programs();
                prog.Fetch(PID);
                ((Label)rptr.Items[0].FindControl("lblConsent")).Text = prog.ParentalConsentText;

                ((Panel)rptr.Items[0].FindControl("pnlConsent")).Visible = prog.ParentalConsentFlag;
                //

                // do we show this next panel?
                var newPanelVisibility = ((TextBox)rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString() + "Visibility")).Text;
                if(newPanelVisibility == "0" && !prog.ParentalConsentFlag)
                    curStep = curStep + 1;  // If not, move to the next panel

            }
            // Finished Current Step = 5

            if(curStep == 6) {
                var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString());
                var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString());

                curPanel.Visible = false;
                newPanel.Visible = true;

                Step.Text = (curStep + 1).ToString();
            }
            // Finished Current Step = 6

            if(curStep == 7) {
                if(!SaveAccount()) {
                    return;
                }

                var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString());
                var newPanel = FindControl("Panel" + (curStep + 1).ToString());

                curPanel.Visible = false;
                //newPanel.Visible = true;

                Step.Text = (curStep + 1).ToString();

                var famAcct = (DropDownList)rptr.Items[0].FindControl("FamilyAccount");
                if(famAcct.SelectedValue == "Yes") {
                    curStep = 9;  // Move to the next panel
                    Step.Text = "9";
                    curPanel = FindControl("Panel" + curStep.ToString());
                    curPanel.Visible = true;
                    btnPrev.Enabled = false;
                    btnDone.Visible = true;
                    return;
                } else {
                    // we're done with registration, we can just jump right in
                    TestingBL.CheckPatronNeedsPreTest();
                    TestingBL.CheckPatronNeedsPostTest();

                    Session[SessionKey.PatronMessage] = ((BaseSRPPage)Page).GetResourceString("registration-success");
                    Session[SessionKey.PatronMessageGlyphicon] = "thumbs-up";
                    Response.Redirect("~");
                }

                newPanel.Visible = true;
                btnPrev.Enabled = false;

            }
            // Finished Current Step = 7

            if(curStep == 8) {
                var curPanel = FindControl("Panel" + curStep.ToString());
                var newPanel = FindControl("Panel" + (curStep + 1).ToString());

                curPanel.Visible = false;
                newPanel.Visible = true;

                Step.Text = (curStep + 1).ToString();
                btnPrev.Enabled = false;

                // log them in and take them home

                Response.Redirect(GoToUrl);
            }
            // Finished Current Step = 8

            if(curStep == 9) {
                // Reset Steps, flag as family members, restart the wizard

                var curPanel = FindControl("Panel" + curStep.ToString());
                var newPanel = rptr.Items[0].FindControl("Panel1");

                curPanel.Visible = false;
                newPanel.Visible = true;

                btnPrev.Enabled = false;
                btnDone.Visible = false;
                Step.Text = "1";
                Panel0.Visible = true;
                RegisteringFamily.Text = "1";
                RegistrationAge.Text = "0";

                ((TextBox)rptr.Items[0].FindControl("ParentGuardianFirstName")).Text = parentGuardianFirst.Text;
                ((TextBox)rptr.Items[0].FindControl("ParentGuardianMiddleName")).Text = parentGuardianMiddle.Text;
                ((TextBox)rptr.Items[0].FindControl("ParentGuardianLastName")).Text = parentGuardianLast.Text;

                ((TextBox)rptr.Items[0].FindControl("Username")).Text = string.Empty;
                ((TextBox)rptr.Items[0].FindControl("Password")).Text = string.Empty;
                ((TextBox)rptr.Items[0].FindControl("Password")).Attributes.Add("Value", string.Empty);
                ((TextBox)rptr.Items[0].FindControl("Password2")).Text = string.Empty;
                ((TextBox)rptr.Items[0].FindControl("Password2")).Attributes.Add("Value", string.Empty);
                ((TextBox)rptr.Items[0].FindControl("Age")).Text = string.Empty;
                ((TextBox)rptr.Items[0].FindControl("DOB")).Text = string.Empty;
                ((TextBox)rptr.Items[0].FindControl("SchoolGrade")).Text = string.Empty;
                ((DropDownList)rptr.Items[0].FindControl("ProgID")).SelectedValue = string.Empty;
                ((TextBox)rptr.Items[0].FindControl("FirstName")).Text = string.Empty;
                ((TextBox)rptr.Items[0].FindControl("MiddleName")).Text = string.Empty;
                ((DropDownList)rptr.Items[0].FindControl("Gender")).SelectedValue = string.Empty;
                ((TextBox)rptr.Items[0].FindControl("LiteracyLevel1")).Text = string.Empty;
                ((TextBox)rptr.Items[0].FindControl("LiteracyLevel2")).Text = string.Empty;
            }
            // Finished Current Step = 9
        }
Пример #12
0
        public int RecalculateGoalCache(Programs program, ProgramGamePointConversion conversion)
        {

            int goal = this.Goal;
            GoalInterval interval = program.GetGoalInterval;

            if (program != null)
            {
                int programLength = 1;

                switch (interval)
                {
                    case GoalInterval.Program:
                        programLength = 1;
                        break;
                    case GoalInterval.Daily:
                        programLength = (int)((program.LoggingEnd - program.LoggingStart).TotalDays);
                        break;
                    case GoalInterval.Weekly:
                        programLength = (int)((program.LoggingEnd - program.LoggingStart).TotalDays) / 7;
                        break;
                }

                goal *= programLength;
            }


            if (conversion != null)
            {
                goal *= conversion.PointCount;
            }

            /* protect against divide by zero error */
            if (goal < 1)
            {
                goal = 0;
            }

            this.GoalCache = goal;
            return this.GoalCache;
        }
Пример #13
0
        public bool Fetch(int PID)
        {
            // declare reader

            SqlDataReader dr;

            SqlParameter[] arrParams = new SqlParameter[1];

            arrParams[0] = new SqlParameter("@PID", PID);

            dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, "app_Programs_GetByID", arrParams);

            if (dr.Read())
            {
                // declare return value

                Programs result = new Programs();

                DateTime _datetime;

                int _int;

                //decimal _decimal;

                if (int.TryParse(dr["PID"].ToString(), out _int))
                {
                    this.PID = _int;
                }
                this.AdminName = dr["AdminName"].ToString();
                this.Title     = dr["Title"].ToString();
                this.TabName   = dr["TabName"].ToString();
                if (int.TryParse(dr["POrder"].ToString(), out _int))
                {
                    this.POrder = _int;
                }
                this.IsActive = bool.Parse(dr["IsActive"].ToString());
                this.IsHidden = bool.Parse(dr["IsHidden"].ToString());
                if (DateTime.TryParse(dr["StartDate"].ToString(), out _datetime))
                {
                    this.StartDate = _datetime;
                }
                if (DateTime.TryParse(dr["EndDate"].ToString(), out _datetime))
                {
                    this.EndDate = _datetime;
                }
                if (int.TryParse(dr["MaxAge"].ToString(), out _int))
                {
                    this.MaxAge = _int;
                }
                if (int.TryParse(dr["MaxGrade"].ToString(), out _int))
                {
                    this.MaxGrade = _int;
                }
                if (DateTime.TryParse(dr["LoggingStart"].ToString(), out _datetime))
                {
                    this.LoggingStart = _datetime;
                }
                if (DateTime.TryParse(dr["LoggingEnd"].ToString(), out _datetime))
                {
                    this.LoggingEnd = _datetime;
                }
                this.ParentalConsentFlag = bool.Parse(dr["ParentalConsentFlag"].ToString());
                this.ParentalConsentText = dr["ParentalConsentText"].ToString();
                this.PatronReviewFlag    = bool.Parse(dr["PatronReviewFlag"].ToString());
                this.LogoutURL           = dr["LogoutURL"].ToString();
                if (int.TryParse(dr["ProgramGameID"].ToString(), out _int))
                {
                    this.ProgramGameID = _int;
                }
                this.HTML1       = dr["HTML1"].ToString();
                this.HTML2       = dr["HTML2"].ToString();
                this.HTML3       = dr["HTML3"].ToString();
                this.HTML4       = dr["HTML4"].ToString();
                this.HTML5       = dr["HTML5"].ToString();
                this.HTML6       = dr["HTML6"].ToString();
                this.BannerImage = dr["BannerImage"].ToString();
                if (int.TryParse(dr["RegistrationBadgeID"].ToString(), out _int))
                {
                    this.RegistrationBadgeID = _int;
                }
                if (int.TryParse(dr["CompletionPoints"].ToString(), out _int))
                {
                    this.CompletionPoints = _int;
                }
                this.LastModUser = dr["LastModUser"].ToString();
                if (DateTime.TryParse(dr["AddedDate"].ToString(), out _datetime))
                {
                    this.AddedDate = _datetime;
                }
                this.AddedUser = dr["AddedUser"].ToString();
                if (DateTime.TryParse(dr["LastModDate"].ToString(), out _datetime))
                {
                    this.LastModDate = _datetime;
                }

                if (int.TryParse(dr["TenID"].ToString(), out _int))
                {
                    this.TenID = _int;
                }
                if (int.TryParse(dr["FldInt1"].ToString(), out _int))
                {
                    this.FldInt1 = _int;
                }
                if (int.TryParse(dr["FldInt2"].ToString(), out _int))
                {
                    this.FldInt2 = _int;
                }
                if (int.TryParse(dr["FldInt3"].ToString(), out _int))
                {
                    this.FldInt3 = _int;
                }
                this.FldBit1  = bool.Parse(dr["FldBit1"].ToString());
                this.FldBit2  = bool.Parse(dr["FldBit2"].ToString());
                this.FldBit3  = bool.Parse(dr["FldBit3"].ToString());
                this.FldText1 = dr["FldText1"].ToString();
                this.FldText2 = dr["FldText2"].ToString();
                this.FldText3 = dr["FldText3"].ToString();

                if (int.TryParse(dr["PreTestID"].ToString(), out _int))
                {
                    this.PreTestID = _int;
                }
                if (int.TryParse(dr["PostTestID"].ToString(), out _int))
                {
                    this.PostTestID = _int;
                }
                this.PreTestMandatory = bool.Parse(dr["PreTestMandatory"].ToString());
                if (DateTime.TryParse(dr["PreTestEndDate"].ToString(), out _datetime))
                {
                    this.PreTestEndDate = _datetime;
                }
                if (DateTime.TryParse(dr["PostTestStartDate"].ToString(), out _datetime))
                {
                    this.PostTestStartDate = _datetime;
                }

                dr.Close();

                CheckAndPopulatePointConversions(this);

                return(true);
            }

            dr.Close();

            return(false);
        }
Пример #14
0
        public static int Insert(Programs o)
        {

            var arrParams = new List<SqlParameter>();

            arrParams.Add(new SqlParameter("@AdminName", GlobalUtilities.DBSafeValue(o.AdminName, o.AdminName.GetTypeCode())));
            arrParams.Add(new SqlParameter("@Title", GlobalUtilities.DBSafeValue(o.Title, o.Title.GetTypeCode())));
            arrParams.Add(new SqlParameter("@TabName", GlobalUtilities.DBSafeValue(o.TabName, o.TabName.GetTypeCode())));
            arrParams.Add(new SqlParameter("@POrder", GlobalUtilities.DBSafeValue(o.POrder, o.POrder.GetTypeCode())));
            arrParams.Add(new SqlParameter("@IsActive", GlobalUtilities.DBSafeValue(o.IsActive, o.IsActive.GetTypeCode())));
            arrParams.Add(new SqlParameter("@IsHidden", GlobalUtilities.DBSafeValue(o.IsHidden, o.IsHidden.GetTypeCode())));
            arrParams.Add(new SqlParameter("@StartDate", GlobalUtilities.DBSafeValue(o.StartDate, o.StartDate.GetTypeCode())));
            arrParams.Add(new SqlParameter("@EndDate", GlobalUtilities.DBSafeValue(o.EndDate, o.EndDate.GetTypeCode())));
            arrParams.Add(new SqlParameter("@MaxAge", GlobalUtilities.DBSafeValue(o.MaxAge, o.MaxAge.GetTypeCode())));
            arrParams.Add(new SqlParameter("@MaxGrade", GlobalUtilities.DBSafeValue(o.MaxGrade, o.MaxGrade.GetTypeCode())));
            arrParams.Add(new SqlParameter("@LoggingStart", GlobalUtilities.DBSafeValue(o.LoggingStart, o.LoggingStart.GetTypeCode())));
            arrParams.Add(new SqlParameter("@LoggingEnd", GlobalUtilities.DBSafeValue(o.LoggingEnd, o.LoggingEnd.GetTypeCode())));
            arrParams.Add(new SqlParameter("@ParentalConsentFlag", GlobalUtilities.DBSafeValue(o.ParentalConsentFlag, o.ParentalConsentFlag.GetTypeCode())));
            arrParams.Add(new SqlParameter("@ParentalConsentText", GlobalUtilities.DBSafeValue(o.ParentalConsentText, o.ParentalConsentText.GetTypeCode())));
            arrParams.Add(new SqlParameter("@PatronReviewFlag", GlobalUtilities.DBSafeValue(o.PatronReviewFlag, o.PatronReviewFlag.GetTypeCode())));
            arrParams.Add(new SqlParameter("@RequireBookDetails", GlobalUtilities.DBSafeValue(o.RequireBookDetails, o.RequireBookDetails.GetTypeCode())));

            arrParams.Add(new SqlParameter("@LogoutURL", GlobalUtilities.DBSafeValue(o.LogoutURL, o.LogoutURL.GetTypeCode())));
            arrParams.Add(new SqlParameter("@ProgramGameID", GlobalUtilities.DBSafeValue(o.ProgramGameID, o.ProgramGameID.GetTypeCode())));
            arrParams.Add(new SqlParameter("@HTML1", GlobalUtilities.DBSafeValue(o.HTML1, o.HTML1.GetTypeCode())));
            arrParams.Add(new SqlParameter("@HTML2", GlobalUtilities.DBSafeValue(o.HTML2, o.HTML2.GetTypeCode())));
            arrParams.Add(new SqlParameter("@HTML3", GlobalUtilities.DBSafeValue(o.HTML3, o.HTML3.GetTypeCode())));
            arrParams.Add(new SqlParameter("@HTML4", GlobalUtilities.DBSafeValue(o.HTML4, o.HTML4.GetTypeCode())));
            arrParams.Add(new SqlParameter("@HTML5", GlobalUtilities.DBSafeValue(o.HTML5, o.HTML5.GetTypeCode())));
            arrParams.Add(new SqlParameter("@HTML6", GlobalUtilities.DBSafeValue(o.HTML6, o.HTML6.GetTypeCode())));
            arrParams.Add(new SqlParameter("@BannerImage", GlobalUtilities.DBSafeValue(o.BannerImage, o.BannerImage.GetTypeCode())));
            arrParams.Add(new SqlParameter("@RegistrationBadgeID", GlobalUtilities.DBSafeValue(o.RegistrationBadgeID, o.RegistrationBadgeID.GetTypeCode())));
            arrParams.Add(new SqlParameter("@CompletionPoints", GlobalUtilities.DBSafeValue(o.CompletionPoints, o.CompletionPoints.GetTypeCode())));
            arrParams.Add(new SqlParameter("@LastModUser", GlobalUtilities.DBSafeValue(o.LastModUser, o.LastModUser.GetTypeCode())));
            arrParams.Add(new SqlParameter("@AddedDate", GlobalUtilities.DBSafeValue(o.AddedDate, o.AddedDate.GetTypeCode())));
            arrParams.Add(new SqlParameter("@AddedUser", GlobalUtilities.DBSafeValue(o.AddedUser, o.AddedUser.GetTypeCode())));
            arrParams.Add(new SqlParameter("@LastModDate", GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode())));

            arrParams.Add(new SqlParameter("@TenID", GlobalUtilities.DBSafeValue(o.TenID, o.TenID.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldInt1", GlobalUtilities.DBSafeValue(o.FldInt1, o.FldInt1.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldInt2", GlobalUtilities.DBSafeValue(o.FldInt2, o.FldInt2.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldInt3", GlobalUtilities.DBSafeValue(o.FldInt3, o.FldInt3.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldBit1", GlobalUtilities.DBSafeValue(o.FldBit1, o.FldBit1.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldBit2", GlobalUtilities.DBSafeValue(o.FldBit2, o.FldBit2.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldBit3", GlobalUtilities.DBSafeValue(o.FldBit3, o.FldBit3.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldText1", GlobalUtilities.DBSafeValue(o.FldText1, o.FldText1.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldText2", GlobalUtilities.DBSafeValue(o.FldText2, o.FldText2.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldText3", GlobalUtilities.DBSafeValue(o.FldText3, o.FldText3.GetTypeCode())));

            arrParams.Add(new SqlParameter("@PreTestID", GlobalUtilities.DBSafeValue(o.PreTestID, o.PreTestID.GetTypeCode())));
            arrParams.Add(new SqlParameter("@PostTestID", GlobalUtilities.DBSafeValue(o.PostTestID, o.PostTestID.GetTypeCode())));
            arrParams.Add(new SqlParameter("@PreTestMandatory", GlobalUtilities.DBSafeValue(o.PreTestMandatory, o.PreTestMandatory.GetTypeCode())));
            arrParams.Add(new SqlParameter("@PreTestEndDate", GlobalUtilities.DBSafeValue(o.PreTestEndDate, o.PreTestEndDate.GetTypeCode())));
            arrParams.Add(new SqlParameter("@PostTestStartDate", GlobalUtilities.DBSafeValue(o.PostTestStartDate, o.PostTestStartDate.GetTypeCode())));
            arrParams.Add(new SqlParameter("@GoalDefault", GlobalUtilities.DBSafeValue(o.GoalDefault, o.GoalDefault.GetTypeCode())));
            arrParams.Add(new SqlParameter("@GoalMin", GlobalUtilities.DBSafeValue(o.GoalMin, o.GoalMin.GetTypeCode())));
            arrParams.Add(new SqlParameter("@GoalMax", GlobalUtilities.DBSafeValue(o.GoalMax, o.GoalMax.GetTypeCode())));
            arrParams.Add(new SqlParameter("@GoalIntervalId", GlobalUtilities.DBSafeValue(o.GoalIntervalId, o.GoalIntervalId.GetTypeCode())));
            arrParams.Add(new SqlParameter("@HideSchoolInRegistration", GlobalUtilities.DBSafeValue(o.HideSchoolInRegistration, o.HideSchoolInRegistration.GetTypeCode())));
            arrParams.Add(new SqlParameter("@DisplayDailyImage", GlobalUtilities.DBSafeValue(o.DisplayDailyImage, o.DisplayDailyImage.GetTypeCode())));

            var newIdParam = new SqlParameter("@PID", GlobalUtilities.DBSafeValue(o.PID, o.PID.GetTypeCode()));
            newIdParam.Direction = ParameterDirection.Output;
            arrParams.Add(newIdParam);

            SqlHelper.ExecuteNonQuery(conn,
                CommandType.StoredProcedure,
                "app_Programs_Insert",
                arrParams.ToArray());

            o.PID = int.Parse(newIdParam.Value.ToString());

            return o.PID;

        }
Пример #15
0
        public static int Update(Programs o)
        {

            int iReturn = -1; //assume the worst

            var arrParams = new List<SqlParameter>();

            arrParams.Add(new SqlParameter("@PID", GlobalUtilities.DBSafeValue(o.PID, o.PID.GetTypeCode())));
            arrParams.Add(new SqlParameter("@AdminName", GlobalUtilities.DBSafeValue(o.AdminName, o.AdminName.GetTypeCode())));
            arrParams.Add(new SqlParameter("@Title", GlobalUtilities.DBSafeValue(o.Title, o.Title.GetTypeCode())));
            arrParams.Add(new SqlParameter("@TabName", GlobalUtilities.DBSafeValue(o.TabName, o.TabName.GetTypeCode())));
            arrParams.Add(new SqlParameter("@POrder", GlobalUtilities.DBSafeValue(o.POrder, o.POrder.GetTypeCode())));
            arrParams.Add(new SqlParameter("@IsActive", GlobalUtilities.DBSafeValue(o.IsActive, o.IsActive.GetTypeCode())));
            arrParams.Add(new SqlParameter("@IsHidden", GlobalUtilities.DBSafeValue(o.IsHidden, o.IsHidden.GetTypeCode())));
            arrParams.Add(new SqlParameter("@StartDate", GlobalUtilities.DBSafeValue(o.StartDate, o.StartDate.GetTypeCode())));
            arrParams.Add(new SqlParameter("@EndDate", GlobalUtilities.DBSafeValue(o.EndDate, o.EndDate.GetTypeCode())));
            arrParams.Add(new SqlParameter("@MaxAge", GlobalUtilities.DBSafeValue(o.MaxAge, o.MaxAge.GetTypeCode())));
            arrParams.Add(new SqlParameter("@MaxGrade", GlobalUtilities.DBSafeValue(o.MaxGrade, o.MaxGrade.GetTypeCode())));
            arrParams.Add(new SqlParameter("@LoggingStart", GlobalUtilities.DBSafeValue(o.LoggingStart, o.LoggingStart.GetTypeCode())));
            arrParams.Add(new SqlParameter("@LoggingEnd", GlobalUtilities.DBSafeValue(o.LoggingEnd, o.LoggingEnd.GetTypeCode())));
            arrParams.Add(new SqlParameter("@ParentalConsentFlag", GlobalUtilities.DBSafeValue(o.ParentalConsentFlag, o.ParentalConsentFlag.GetTypeCode())));
            arrParams.Add(new SqlParameter("@ParentalConsentText", GlobalUtilities.DBSafeValue(o.ParentalConsentText, o.ParentalConsentText.GetTypeCode())));
            arrParams.Add(new SqlParameter("@PatronReviewFlag", GlobalUtilities.DBSafeValue(o.PatronReviewFlag, o.PatronReviewFlag.GetTypeCode())));
            arrParams.Add(new SqlParameter("@RequireBookDetails", GlobalUtilities.DBSafeValue(o.RequireBookDetails, o.RequireBookDetails.GetTypeCode())));
            arrParams.Add(new SqlParameter("@LogoutURL", GlobalUtilities.DBSafeValue(o.LogoutURL, o.LogoutURL.GetTypeCode())));
            arrParams.Add(new SqlParameter("@ProgramGameID", GlobalUtilities.DBSafeValue(o.ProgramGameID, o.ProgramGameID.GetTypeCode())));
            arrParams.Add(new SqlParameter("@HTML1", GlobalUtilities.DBSafeValue(o.HTML1, o.HTML1.GetTypeCode())));
            arrParams.Add(new SqlParameter("@HTML2", GlobalUtilities.DBSafeValue(o.HTML2, o.HTML2.GetTypeCode())));
            arrParams.Add(new SqlParameter("@HTML3", GlobalUtilities.DBSafeValue(o.HTML3, o.HTML3.GetTypeCode())));
            arrParams.Add(new SqlParameter("@HTML4", GlobalUtilities.DBSafeValue(o.HTML4, o.HTML4.GetTypeCode())));
            arrParams.Add(new SqlParameter("@HTML5", GlobalUtilities.DBSafeValue(o.HTML5, o.HTML5.GetTypeCode())));
            arrParams.Add(new SqlParameter("@HTML6", GlobalUtilities.DBSafeValue(o.HTML6, o.HTML6.GetTypeCode())));
            arrParams.Add(new SqlParameter("@BannerImage", GlobalUtilities.DBSafeValue(o.BannerImage, o.BannerImage.GetTypeCode())));
            arrParams.Add(new SqlParameter("@RegistrationBadgeID", GlobalUtilities.DBSafeValue(o.RegistrationBadgeID, o.RegistrationBadgeID.GetTypeCode())));
            arrParams.Add(new SqlParameter("@CompletionPoints", GlobalUtilities.DBSafeValue(o.CompletionPoints, o.CompletionPoints.GetTypeCode())));
            arrParams.Add(new SqlParameter("@LastModUser", GlobalUtilities.DBSafeValue(o.LastModUser, o.LastModUser.GetTypeCode())));
            arrParams.Add(new SqlParameter("@AddedDate", GlobalUtilities.DBSafeValue(o.AddedDate, o.AddedDate.GetTypeCode())));
            arrParams.Add(new SqlParameter("@AddedUser", GlobalUtilities.DBSafeValue(o.AddedUser, o.AddedUser.GetTypeCode())));
            arrParams.Add(new SqlParameter("@LastModDate", GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode())));

            arrParams.Add(new SqlParameter("@TenID", GlobalUtilities.DBSafeValue(o.TenID, o.TenID.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldInt1", GlobalUtilities.DBSafeValue(o.FldInt1, o.FldInt1.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldInt2", GlobalUtilities.DBSafeValue(o.FldInt2, o.FldInt2.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldInt3", GlobalUtilities.DBSafeValue(o.FldInt3, o.FldInt3.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldBit1", GlobalUtilities.DBSafeValue(o.FldBit1, o.FldBit1.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldBit2", GlobalUtilities.DBSafeValue(o.FldBit2, o.FldBit2.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldBit3", GlobalUtilities.DBSafeValue(o.FldBit3, o.FldBit3.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldText1", GlobalUtilities.DBSafeValue(o.FldText1, o.FldText1.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldText2", GlobalUtilities.DBSafeValue(o.FldText2, o.FldText2.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldText3", GlobalUtilities.DBSafeValue(o.FldText3, o.FldText3.GetTypeCode())));

            arrParams.Add(new SqlParameter("@PreTestID", GlobalUtilities.DBSafeValue(o.PreTestID, o.PreTestID.GetTypeCode())));
            arrParams.Add(new SqlParameter("@PostTestID", GlobalUtilities.DBSafeValue(o.PostTestID, o.PostTestID.GetTypeCode())));
            arrParams.Add(new SqlParameter("@PreTestMandatory", GlobalUtilities.DBSafeValue(o.PreTestMandatory, o.PreTestMandatory.GetTypeCode())));
            arrParams.Add(new SqlParameter("@PreTestEndDate", GlobalUtilities.DBSafeValue(o.PreTestEndDate, o.PreTestEndDate.GetTypeCode())));
            arrParams.Add(new SqlParameter("@PostTestStartDate", GlobalUtilities.DBSafeValue(o.PostTestStartDate, o.PostTestStartDate.GetTypeCode())));
            arrParams.Add(new SqlParameter("@GoalDefault", GlobalUtilities.DBSafeValue(o.GoalDefault, o.GoalDefault.GetTypeCode())));
            arrParams.Add(new SqlParameter("@GoalMin", GlobalUtilities.DBSafeValue(o.GoalMin, o.GoalMin.GetTypeCode())));
            arrParams.Add(new SqlParameter("@GoalMax", GlobalUtilities.DBSafeValue(o.GoalMax, o.GoalMax.GetTypeCode())));
            arrParams.Add(new SqlParameter("@GoalIntervalId", GlobalUtilities.DBSafeValue(o.GoalIntervalId, o.GoalIntervalId.GetTypeCode())));
            arrParams.Add(new SqlParameter("@HideSchoolInRegistration", GlobalUtilities.DBSafeValue(o.HideSchoolInRegistration, o.HideSchoolInRegistration.GetTypeCode())));
            arrParams.Add(new SqlParameter("@DisplayDailyImage", GlobalUtilities.DBSafeValue(o.DisplayDailyImage, o.DisplayDailyImage.GetTypeCode())));

            try
            {

                iReturn = SqlHelper.ExecuteNonQuery(conn,
                    CommandType.StoredProcedure,
                    "app_Programs_Update",
                    arrParams.ToArray());
            }

            catch (SqlException exx)
            {
                System.Diagnostics.Debug.Write(exx.Message);
            }

            return iReturn;
        }
Пример #16
0
        public static Programs FetchObject(int PID)
        {

            // declare reader

            SqlDataReader dr;

            SqlParameter[] arrParams = new SqlParameter[1];

            arrParams[0] = new SqlParameter("@PID", PID);

            dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, "app_Programs_GetByID", arrParams);

            if (dr.Read())
            {

                // declare return value

                Programs result = new Programs();

                DateTime _datetime;

                int _int;

                //decimal _decimal;

                if (int.TryParse(dr["PID"].ToString(), out _int)) result.PID = _int;
                result.AdminName = dr["AdminName"].ToString();
                result.Title = dr["Title"].ToString();
                result.TabName = dr["TabName"].ToString();
                if (int.TryParse(dr["POrder"].ToString(), out _int)) result.POrder = _int;
                result.IsActive = bool.Parse(dr["IsActive"].ToString());
                result.IsHidden = bool.Parse(dr["IsHidden"].ToString());
                if (DateTime.TryParse(dr["StartDate"].ToString(), out _datetime)) result.StartDate = _datetime;
                if (DateTime.TryParse(dr["EndDate"].ToString(), out _datetime)) result.EndDate = _datetime;
                if (int.TryParse(dr["MaxAge"].ToString(), out _int)) result.MaxAge = _int;
                if (int.TryParse(dr["MaxGrade"].ToString(), out _int)) result.MaxGrade = _int;
                if (DateTime.TryParse(dr["LoggingStart"].ToString(), out _datetime)) result.LoggingStart = _datetime;
                if (DateTime.TryParse(dr["LoggingEnd"].ToString(), out _datetime)) result.LoggingEnd = _datetime;
                result.ParentalConsentFlag = bool.Parse(dr["ParentalConsentFlag"].ToString());
                result.ParentalConsentText = dr["ParentalConsentText"].ToString();
                result.PatronReviewFlag = bool.Parse(dr["PatronReviewFlag"].ToString());
                result.RequireBookDetails = bool.Parse(dr["RequireBookDetails"].ToString());
                result.LogoutURL = dr["LogoutURL"].ToString();
                if (int.TryParse(dr["ProgramGameID"].ToString(), out _int)) result.ProgramGameID = _int;
                result.HTML1 = dr["HTML1"].ToString();
                result.HTML2 = dr["HTML2"].ToString();
                result.HTML3 = dr["HTML3"].ToString();
                result.HTML4 = dr["HTML4"].ToString();
                result.HTML5 = dr["HTML5"].ToString();
                result.HTML6 = dr["HTML6"].ToString();
                result.BannerImage = dr["BannerImage"].ToString();
                if (int.TryParse(dr["RegistrationBadgeID"].ToString(), out _int)) result.RegistrationBadgeID = _int;
                if (int.TryParse(dr["CompletionPoints"].ToString(), out _int)) result.CompletionPoints = _int;
                result.LastModUser = dr["LastModUser"].ToString();
                if (DateTime.TryParse(dr["AddedDate"].ToString(), out _datetime)) result.AddedDate = _datetime;
                result.AddedUser = dr["AddedUser"].ToString();
                if (DateTime.TryParse(dr["LastModDate"].ToString(), out _datetime)) result.LastModDate = _datetime;

                if (int.TryParse(dr["TenID"].ToString(), out _int)) result.TenID = _int;
                if (int.TryParse(dr["FldInt1"].ToString(), out _int)) result.FldInt1 = _int;
                if (int.TryParse(dr["FldInt2"].ToString(), out _int)) result.FldInt2 = _int;
                if (int.TryParse(dr["FldInt3"].ToString(), out _int)) result.FldInt3 = _int;
                result.FldBit1 = bool.Parse(dr["FldBit1"].ToString());
                result.FldBit2 = bool.Parse(dr["FldBit2"].ToString());
                result.FldBit3 = bool.Parse(dr["FldBit3"].ToString());
                result.FldText1 = dr["FldText1"].ToString();
                result.FldText2 = dr["FldText2"].ToString();
                result.FldText3 = dr["FldText3"].ToString();

                if (int.TryParse(dr["PreTestID"].ToString(), out _int)) result.PreTestID = _int;
                if (int.TryParse(dr["PostTestID"].ToString(), out _int)) result.PostTestID = _int;
                result.PreTestMandatory = bool.Parse(dr["PreTestMandatory"].ToString());
                if (DateTime.TryParse(dr["PreTestEndDate"].ToString(), out _datetime)) result.PreTestEndDate = _datetime;
                if (DateTime.TryParse(dr["PostTestStartDate"].ToString(), out _datetime)) result.PostTestStartDate = _datetime;
                if (int.TryParse(dr["GoalDefault"].ToString(), out _int)) result.GoalDefault = _int;
                if (int.TryParse(dr["GoalMin"].ToString(), out _int)) result.GoalMin = _int;
                if (int.TryParse(dr["GoalMax"].ToString(), out _int)) result.GoalMax = _int;
                if (int.TryParse(dr["GoalIntervalId"].ToString(), out _int)) result.GoalIntervalId = _int;
                result.HideSchoolInRegistration = dr["HideSchoolInRegistration"] as bool? == true;
                result.DisplayDailyImage = dr["DisplayDailyImage"] as bool? == true;

                dr.Close();

                CheckAndPopulatePointConversions(result);

                return result;

            }

            dr.Close();

            return null;

        }
Пример #17
0
        public static int Update(Programs o)
        {
            int iReturn = -1; //assume the worst

            SqlParameter[] arrParams = new SqlParameter[46];

            arrParams[0] = new SqlParameter("@PID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PID, o.PID.GetTypeCode()));
            arrParams[1] = new SqlParameter("@AdminName", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AdminName, o.AdminName.GetTypeCode()));
            arrParams[2] = new SqlParameter("@Title", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Title, o.Title.GetTypeCode()));
            arrParams[3] = new SqlParameter("@TabName", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TabName, o.TabName.GetTypeCode()));
            arrParams[4] = new SqlParameter("@POrder", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.POrder, o.POrder.GetTypeCode()));
            arrParams[5] = new SqlParameter("@IsActive", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.IsActive, o.IsActive.GetTypeCode()));
            arrParams[6] = new SqlParameter("@IsHidden", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.IsHidden, o.IsHidden.GetTypeCode()));
            arrParams[7] = new SqlParameter("@StartDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.StartDate, o.StartDate.GetTypeCode()));
            arrParams[8] = new SqlParameter("@EndDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.EndDate, o.EndDate.GetTypeCode()));
            arrParams[9] = new SqlParameter("@MaxAge", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MaxAge, o.MaxAge.GetTypeCode()));
            arrParams[10] = new SqlParameter("@MaxGrade", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MaxGrade, o.MaxGrade.GetTypeCode()));
            arrParams[11] = new SqlParameter("@LoggingStart", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LoggingStart, o.LoggingStart.GetTypeCode()));
            arrParams[12] = new SqlParameter("@LoggingEnd", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LoggingEnd, o.LoggingEnd.GetTypeCode()));
            arrParams[13] = new SqlParameter("@ParentalConsentFlag", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ParentalConsentFlag, o.ParentalConsentFlag.GetTypeCode()));
            arrParams[14] = new SqlParameter("@ParentalConsentText", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ParentalConsentText, o.ParentalConsentText.GetTypeCode()));
            arrParams[15] = new SqlParameter("@PatronReviewFlag", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PatronReviewFlag, o.PatronReviewFlag.GetTypeCode()));
            arrParams[16] = new SqlParameter("@LogoutURL", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LogoutURL, o.LogoutURL.GetTypeCode()));
            arrParams[17] = new SqlParameter("@ProgramGameID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ProgramGameID, o.ProgramGameID.GetTypeCode()));
            arrParams[18] = new SqlParameter("@HTML1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.HTML1, o.HTML1.GetTypeCode()));
            arrParams[19] = new SqlParameter("@HTML2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.HTML2, o.HTML2.GetTypeCode()));
            arrParams[20] = new SqlParameter("@HTML3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.HTML3, o.HTML3.GetTypeCode()));
            arrParams[21] = new SqlParameter("@HTML4", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.HTML4, o.HTML4.GetTypeCode()));
            arrParams[22] = new SqlParameter("@HTML5", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.HTML5, o.HTML5.GetTypeCode()));
            arrParams[23] = new SqlParameter("@HTML6", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.HTML6, o.HTML6.GetTypeCode()));
            arrParams[24] = new SqlParameter("@BannerImage", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.BannerImage, o.BannerImage.GetTypeCode()));
            arrParams[25] = new SqlParameter("@RegistrationBadgeID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.RegistrationBadgeID, o.RegistrationBadgeID.GetTypeCode()));
            arrParams[26] = new SqlParameter("@CompletionPoints", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.CompletionPoints, o.CompletionPoints.GetTypeCode()));
            arrParams[27] = new SqlParameter("@LastModUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModUser, o.LastModUser.GetTypeCode()));
            arrParams[28] = new SqlParameter("@AddedDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedDate, o.AddedDate.GetTypeCode()));
            arrParams[29] = new SqlParameter("@AddedUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedUser, o.AddedUser.GetTypeCode()));
            arrParams[30] = new SqlParameter("@LastModDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode()));

            arrParams[31] = new SqlParameter("@TenID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TenID, o.TenID.GetTypeCode()));
            arrParams[32] = new SqlParameter("@FldInt1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt1, o.FldInt1.GetTypeCode()));
            arrParams[33] = new SqlParameter("@FldInt2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt2, o.FldInt2.GetTypeCode()));
            arrParams[34] = new SqlParameter("@FldInt3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt3, o.FldInt3.GetTypeCode()));
            arrParams[35] = new SqlParameter("@FldBit1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit1, o.FldBit1.GetTypeCode()));
            arrParams[36] = new SqlParameter("@FldBit2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit2, o.FldBit2.GetTypeCode()));
            arrParams[37] = new SqlParameter("@FldBit3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit3, o.FldBit3.GetTypeCode()));
            arrParams[38] = new SqlParameter("@FldText1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText1, o.FldText1.GetTypeCode()));
            arrParams[39] = new SqlParameter("@FldText2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText2, o.FldText2.GetTypeCode()));
            arrParams[40] = new SqlParameter("@FldText3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText3, o.FldText3.GetTypeCode()));

            arrParams[41] = new SqlParameter("@PreTestID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PreTestID, o.PreTestID.GetTypeCode()));
            arrParams[42] = new SqlParameter("@PostTestID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PostTestID, o.PostTestID.GetTypeCode()));
            arrParams[43] = new SqlParameter("@PreTestMandatory", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PreTestMandatory, o.PreTestMandatory.GetTypeCode()));
            arrParams[44] = new SqlParameter("@PreTestEndDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PreTestEndDate, o.PreTestEndDate.GetTypeCode()));
            arrParams[45] = new SqlParameter("@PostTestStartDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PostTestStartDate, o.PostTestStartDate.GetTypeCode()));

            try
            {

                iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_Programs_Update", arrParams);
            }

            catch (SqlException exx)
            {

                System.Diagnostics.Debug.Write(exx.Message);

            }

            return iReturn;
        }
 private void LoadProgram()
 {
     this.CurrentProgram = Programs.FetchObject(Session["ProgramID"].ToString().SafeToInt());
     ViewState["Program"] = this.CurrentProgram;
 }
Пример #19
0
        public static Programs FetchObject(int PID)
        {
            // declare reader

            SqlDataReader dr;

            SqlParameter[] arrParams = new SqlParameter[1];

            arrParams[0] = new SqlParameter("@PID", PID);

            dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, "app_Programs_GetByID", arrParams);

            if (dr.Read())
            {
                // declare return value

                Programs result = new Programs();

                DateTime _datetime;

                int _int;

                //decimal _decimal;

                if (int.TryParse(dr["PID"].ToString(), out _int))
                {
                    result.PID = _int;
                }
                result.AdminName = dr["AdminName"].ToString();
                result.Title     = dr["Title"].ToString();
                result.TabName   = dr["TabName"].ToString();
                if (int.TryParse(dr["POrder"].ToString(), out _int))
                {
                    result.POrder = _int;
                }
                result.IsActive = bool.Parse(dr["IsActive"].ToString());
                result.IsHidden = bool.Parse(dr["IsHidden"].ToString());
                if (DateTime.TryParse(dr["StartDate"].ToString(), out _datetime))
                {
                    result.StartDate = _datetime;
                }
                if (DateTime.TryParse(dr["EndDate"].ToString(), out _datetime))
                {
                    result.EndDate = _datetime;
                }
                if (int.TryParse(dr["MaxAge"].ToString(), out _int))
                {
                    result.MaxAge = _int;
                }
                if (int.TryParse(dr["MaxGrade"].ToString(), out _int))
                {
                    result.MaxGrade = _int;
                }
                if (DateTime.TryParse(dr["LoggingStart"].ToString(), out _datetime))
                {
                    result.LoggingStart = _datetime;
                }
                if (DateTime.TryParse(dr["LoggingEnd"].ToString(), out _datetime))
                {
                    result.LoggingEnd = _datetime;
                }
                result.ParentalConsentFlag = bool.Parse(dr["ParentalConsentFlag"].ToString());
                result.ParentalConsentText = dr["ParentalConsentText"].ToString();
                result.PatronReviewFlag    = bool.Parse(dr["PatronReviewFlag"].ToString());
                result.RequireBookDetails  = bool.Parse(dr["RequireBookDetails"].ToString());
                result.LogoutURL           = dr["LogoutURL"].ToString();
                if (int.TryParse(dr["ProgramGameID"].ToString(), out _int))
                {
                    result.ProgramGameID = _int;
                }
                result.HTML1       = dr["HTML1"].ToString();
                result.HTML2       = dr["HTML2"].ToString();
                result.HTML3       = dr["HTML3"].ToString();
                result.HTML4       = dr["HTML4"].ToString();
                result.HTML5       = dr["HTML5"].ToString();
                result.HTML6       = dr["HTML6"].ToString();
                result.BannerImage = dr["BannerImage"].ToString();
                if (int.TryParse(dr["RegistrationBadgeID"].ToString(), out _int))
                {
                    result.RegistrationBadgeID = _int;
                }
                if (int.TryParse(dr["CompletionPoints"].ToString(), out _int))
                {
                    result.CompletionPoints = _int;
                }
                result.LastModUser = dr["LastModUser"].ToString();
                if (DateTime.TryParse(dr["AddedDate"].ToString(), out _datetime))
                {
                    result.AddedDate = _datetime;
                }
                result.AddedUser = dr["AddedUser"].ToString();
                if (DateTime.TryParse(dr["LastModDate"].ToString(), out _datetime))
                {
                    result.LastModDate = _datetime;
                }

                if (int.TryParse(dr["TenID"].ToString(), out _int))
                {
                    result.TenID = _int;
                }
                if (int.TryParse(dr["FldInt1"].ToString(), out _int))
                {
                    result.FldInt1 = _int;
                }
                if (int.TryParse(dr["FldInt2"].ToString(), out _int))
                {
                    result.FldInt2 = _int;
                }
                if (int.TryParse(dr["FldInt3"].ToString(), out _int))
                {
                    result.FldInt3 = _int;
                }
                result.FldBit1  = bool.Parse(dr["FldBit1"].ToString());
                result.FldBit2  = bool.Parse(dr["FldBit2"].ToString());
                result.FldBit3  = bool.Parse(dr["FldBit3"].ToString());
                result.FldText1 = dr["FldText1"].ToString();
                result.FldText2 = dr["FldText2"].ToString();
                result.FldText3 = dr["FldText3"].ToString();

                if (int.TryParse(dr["PreTestID"].ToString(), out _int))
                {
                    result.PreTestID = _int;
                }
                if (int.TryParse(dr["PostTestID"].ToString(), out _int))
                {
                    result.PostTestID = _int;
                }
                result.PreTestMandatory = bool.Parse(dr["PreTestMandatory"].ToString());
                if (DateTime.TryParse(dr["PreTestEndDate"].ToString(), out _datetime))
                {
                    result.PreTestEndDate = _datetime;
                }
                if (DateTime.TryParse(dr["PostTestStartDate"].ToString(), out _datetime))
                {
                    result.PostTestStartDate = _datetime;
                }
                if (int.TryParse(dr["GoalDefault"].ToString(), out _int))
                {
                    result.GoalDefault = _int;
                }
                if (int.TryParse(dr["GoalMin"].ToString(), out _int))
                {
                    result.GoalMin = _int;
                }
                if (int.TryParse(dr["GoalMax"].ToString(), out _int))
                {
                    result.GoalMax = _int;
                }
                if (int.TryParse(dr["GoalIntervalId"].ToString(), out _int))
                {
                    result.GoalIntervalId = _int;
                }
                result.HideSchoolInRegistration = dr["HideSchoolInRegistration"] as bool? == true;
                result.DisplayDailyImage        = dr["DisplayDailyImage"] as bool? == true;

                dr.Close();

                CheckAndPopulatePointConversions(result);

                return(result);
            }

            dr.Close();

            return(null);
        }
Пример #20
0
        public static int Insert(Programs o)
        {
            var arrParams = new List <SqlParameter>();

            arrParams.Add(new SqlParameter("@AdminName", GlobalUtilities.DBSafeValue(o.AdminName, o.AdminName.GetTypeCode())));
            arrParams.Add(new SqlParameter("@Title", GlobalUtilities.DBSafeValue(o.Title, o.Title.GetTypeCode())));
            arrParams.Add(new SqlParameter("@TabName", GlobalUtilities.DBSafeValue(o.TabName, o.TabName.GetTypeCode())));
            arrParams.Add(new SqlParameter("@POrder", GlobalUtilities.DBSafeValue(o.POrder, o.POrder.GetTypeCode())));
            arrParams.Add(new SqlParameter("@IsActive", GlobalUtilities.DBSafeValue(o.IsActive, o.IsActive.GetTypeCode())));
            arrParams.Add(new SqlParameter("@IsHidden", GlobalUtilities.DBSafeValue(o.IsHidden, o.IsHidden.GetTypeCode())));
            arrParams.Add(new SqlParameter("@StartDate", GlobalUtilities.DBSafeValue(o.StartDate, o.StartDate.GetTypeCode())));
            arrParams.Add(new SqlParameter("@EndDate", GlobalUtilities.DBSafeValue(o.EndDate, o.EndDate.GetTypeCode())));
            arrParams.Add(new SqlParameter("@MaxAge", GlobalUtilities.DBSafeValue(o.MaxAge, o.MaxAge.GetTypeCode())));
            arrParams.Add(new SqlParameter("@MaxGrade", GlobalUtilities.DBSafeValue(o.MaxGrade, o.MaxGrade.GetTypeCode())));
            arrParams.Add(new SqlParameter("@LoggingStart", GlobalUtilities.DBSafeValue(o.LoggingStart, o.LoggingStart.GetTypeCode())));
            arrParams.Add(new SqlParameter("@LoggingEnd", GlobalUtilities.DBSafeValue(o.LoggingEnd, o.LoggingEnd.GetTypeCode())));
            arrParams.Add(new SqlParameter("@ParentalConsentFlag", GlobalUtilities.DBSafeValue(o.ParentalConsentFlag, o.ParentalConsentFlag.GetTypeCode())));
            arrParams.Add(new SqlParameter("@ParentalConsentText", GlobalUtilities.DBSafeValue(o.ParentalConsentText, o.ParentalConsentText.GetTypeCode())));
            arrParams.Add(new SqlParameter("@PatronReviewFlag", GlobalUtilities.DBSafeValue(o.PatronReviewFlag, o.PatronReviewFlag.GetTypeCode())));
            arrParams.Add(new SqlParameter("@RequireBookDetails", GlobalUtilities.DBSafeValue(o.RequireBookDetails, o.RequireBookDetails.GetTypeCode())));

            arrParams.Add(new SqlParameter("@LogoutURL", GlobalUtilities.DBSafeValue(o.LogoutURL, o.LogoutURL.GetTypeCode())));
            arrParams.Add(new SqlParameter("@ProgramGameID", GlobalUtilities.DBSafeValue(o.ProgramGameID, o.ProgramGameID.GetTypeCode())));
            arrParams.Add(new SqlParameter("@HTML1", GlobalUtilities.DBSafeValue(o.HTML1, o.HTML1.GetTypeCode())));
            arrParams.Add(new SqlParameter("@HTML2", GlobalUtilities.DBSafeValue(o.HTML2, o.HTML2.GetTypeCode())));
            arrParams.Add(new SqlParameter("@HTML3", GlobalUtilities.DBSafeValue(o.HTML3, o.HTML3.GetTypeCode())));
            arrParams.Add(new SqlParameter("@HTML4", GlobalUtilities.DBSafeValue(o.HTML4, o.HTML4.GetTypeCode())));
            arrParams.Add(new SqlParameter("@HTML5", GlobalUtilities.DBSafeValue(o.HTML5, o.HTML5.GetTypeCode())));
            arrParams.Add(new SqlParameter("@HTML6", GlobalUtilities.DBSafeValue(o.HTML6, o.HTML6.GetTypeCode())));
            arrParams.Add(new SqlParameter("@BannerImage", GlobalUtilities.DBSafeValue(o.BannerImage, o.BannerImage.GetTypeCode())));
            arrParams.Add(new SqlParameter("@RegistrationBadgeID", GlobalUtilities.DBSafeValue(o.RegistrationBadgeID, o.RegistrationBadgeID.GetTypeCode())));
            arrParams.Add(new SqlParameter("@CompletionPoints", GlobalUtilities.DBSafeValue(o.CompletionPoints, o.CompletionPoints.GetTypeCode())));
            arrParams.Add(new SqlParameter("@LastModUser", GlobalUtilities.DBSafeValue(o.LastModUser, o.LastModUser.GetTypeCode())));
            arrParams.Add(new SqlParameter("@AddedDate", GlobalUtilities.DBSafeValue(o.AddedDate, o.AddedDate.GetTypeCode())));
            arrParams.Add(new SqlParameter("@AddedUser", GlobalUtilities.DBSafeValue(o.AddedUser, o.AddedUser.GetTypeCode())));
            arrParams.Add(new SqlParameter("@LastModDate", GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode())));

            arrParams.Add(new SqlParameter("@TenID", GlobalUtilities.DBSafeValue(o.TenID, o.TenID.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldInt1", GlobalUtilities.DBSafeValue(o.FldInt1, o.FldInt1.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldInt2", GlobalUtilities.DBSafeValue(o.FldInt2, o.FldInt2.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldInt3", GlobalUtilities.DBSafeValue(o.FldInt3, o.FldInt3.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldBit1", GlobalUtilities.DBSafeValue(o.FldBit1, o.FldBit1.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldBit2", GlobalUtilities.DBSafeValue(o.FldBit2, o.FldBit2.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldBit3", GlobalUtilities.DBSafeValue(o.FldBit3, o.FldBit3.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldText1", GlobalUtilities.DBSafeValue(o.FldText1, o.FldText1.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldText2", GlobalUtilities.DBSafeValue(o.FldText2, o.FldText2.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldText3", GlobalUtilities.DBSafeValue(o.FldText3, o.FldText3.GetTypeCode())));

            arrParams.Add(new SqlParameter("@PreTestID", GlobalUtilities.DBSafeValue(o.PreTestID, o.PreTestID.GetTypeCode())));
            arrParams.Add(new SqlParameter("@PostTestID", GlobalUtilities.DBSafeValue(o.PostTestID, o.PostTestID.GetTypeCode())));
            arrParams.Add(new SqlParameter("@PreTestMandatory", GlobalUtilities.DBSafeValue(o.PreTestMandatory, o.PreTestMandatory.GetTypeCode())));
            arrParams.Add(new SqlParameter("@PreTestEndDate", GlobalUtilities.DBSafeValue(o.PreTestEndDate, o.PreTestEndDate.GetTypeCode())));
            arrParams.Add(new SqlParameter("@PostTestStartDate", GlobalUtilities.DBSafeValue(o.PostTestStartDate, o.PostTestStartDate.GetTypeCode())));
            arrParams.Add(new SqlParameter("@GoalDefault", GlobalUtilities.DBSafeValue(o.GoalDefault, o.GoalDefault.GetTypeCode())));
            arrParams.Add(new SqlParameter("@GoalMin", GlobalUtilities.DBSafeValue(o.GoalMin, o.GoalMin.GetTypeCode())));
            arrParams.Add(new SqlParameter("@GoalMax", GlobalUtilities.DBSafeValue(o.GoalMax, o.GoalMax.GetTypeCode())));
            arrParams.Add(new SqlParameter("@GoalIntervalId", GlobalUtilities.DBSafeValue(o.GoalIntervalId, o.GoalIntervalId.GetTypeCode())));
            arrParams.Add(new SqlParameter("@HideSchoolInRegistration", GlobalUtilities.DBSafeValue(o.HideSchoolInRegistration, o.HideSchoolInRegistration.GetTypeCode())));
            arrParams.Add(new SqlParameter("@DisplayDailyImage", GlobalUtilities.DBSafeValue(o.DisplayDailyImage, o.DisplayDailyImage.GetTypeCode())));

            var newIdParam = new SqlParameter("@PID", GlobalUtilities.DBSafeValue(o.PID, o.PID.GetTypeCode()));

            newIdParam.Direction = ParameterDirection.Output;
            arrParams.Add(newIdParam);

            SqlHelper.ExecuteNonQuery(conn,
                                      CommandType.StoredProcedure,
                                      "app_Programs_Insert",
                                      arrParams.ToArray());

            o.PID = int.Parse(newIdParam.Value.ToString());

            return(o.PID);
        }
        public string GetGameInfo(Patron patron, Programs pgm, ProgramGame gm, int StartingPoints) {
            //Tally up the points  
            //var level = 0;
            //var points = 0;
            var bonus = false;
            string ret = string.Empty;

            if(pgm.ProgramGameID > 0) {
                // only if we have a game we can earn badges by reading ....
                var ds = ProgramGameLevel.GetAll(gm.PGID);

                var normalLevelTotalPoints = GetGameCompletionPoints(ds);
                var bonusLevelTotalPoints = GetGameCompletionBonusPoints(ds, gm.BonusLevelPointMultiplier);

                bonus = (StartingPoints > normalLevelTotalPoints);

                // loop thru the levels to see where we are at ... before awarding the new points
                var rp = StartingPoints;   //remaining points
                if(bonus) {
                    // if we are on the bonus, we have access to all of them
                    for(var i = 0; i < ds.Tables[0].Rows.Count; i++) {
                        ret = string.Format("{0}{1}{2}", ret, (ret.Length > 0 ? "," : ""),
                                            Convert.ToInt32(ds.Tables[0].Rows[i]["PGLID"]));

                    }
                    return ret;
                }

                // we have not completed the bonus yet ....
                for(var i = 0; i < ds.Tables[0].Rows.Count; i++) {
                    var multiplier = (bonus ? gm.BonusLevelPointMultiplier : 1.00m);
                    var levelPoints = Convert.ToInt32(Convert.ToInt32(ds.Tables[0].Rows[i]["PointNumber"]) * multiplier);
                    rp = rp - levelPoints;
                    if(rp < 0) {
                        return ret;
                        //break;
                    }
                    ret = string.Format("{0}{1}{2}", ret, (ret.Length > 0 ? "," : ""),
                                            Convert.ToInt32(ds.Tables[0].Rows[i]["PGLID"]));
                }
            }
            return ret;
        }
Пример #22
0
        public bool Fetch(int PID)
        {
            // declare reader

            SqlDataReader dr;

            SqlParameter[] arrParams = new SqlParameter[1];

            arrParams[0] = new SqlParameter("@PID", PID);

            dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, "app_Programs_GetByID", arrParams);

            if (dr.Read())
            {

                // declare return value

                Programs result = new Programs();

                DateTime _datetime;

                int _int;

                //decimal _decimal;

                if (int.TryParse(dr["PID"].ToString(), out _int)) this.PID = _int;
                this.AdminName = dr["AdminName"].ToString();
                this.Title = dr["Title"].ToString();
                this.TabName = dr["TabName"].ToString();
                if (int.TryParse(dr["POrder"].ToString(), out _int)) this.POrder = _int;
                this.IsActive = bool.Parse(dr["IsActive"].ToString());
                this.IsHidden = bool.Parse(dr["IsHidden"].ToString());
                if (DateTime.TryParse(dr["StartDate"].ToString(), out _datetime)) this.StartDate = _datetime;
                if (DateTime.TryParse(dr["EndDate"].ToString(), out _datetime)) this.EndDate = _datetime;
                if (int.TryParse(dr["MaxAge"].ToString(), out _int)) this.MaxAge = _int;
                if (int.TryParse(dr["MaxGrade"].ToString(), out _int)) this.MaxGrade = _int;
                if (DateTime.TryParse(dr["LoggingStart"].ToString(), out _datetime)) this.LoggingStart = _datetime;
                if (DateTime.TryParse(dr["LoggingEnd"].ToString(), out _datetime)) this.LoggingEnd = _datetime;
                this.ParentalConsentFlag = bool.Parse(dr["ParentalConsentFlag"].ToString());
                this.ParentalConsentText = dr["ParentalConsentText"].ToString();
                this.PatronReviewFlag = bool.Parse(dr["PatronReviewFlag"].ToString());
                this.LogoutURL = dr["LogoutURL"].ToString();
                if (int.TryParse(dr["ProgramGameID"].ToString(), out _int)) this.ProgramGameID = _int;
                this.HTML1 = dr["HTML1"].ToString();
                this.HTML2 = dr["HTML2"].ToString();
                this.HTML3 = dr["HTML3"].ToString();
                this.HTML4 = dr["HTML4"].ToString();
                this.HTML5 = dr["HTML5"].ToString();
                this.HTML6 = dr["HTML6"].ToString();
                this.BannerImage = dr["BannerImage"].ToString();
                if (int.TryParse(dr["RegistrationBadgeID"].ToString(), out _int)) this.RegistrationBadgeID = _int;
                if (int.TryParse(dr["CompletionPoints"].ToString(), out _int)) this.CompletionPoints = _int;
                this.LastModUser = dr["LastModUser"].ToString();
                if (DateTime.TryParse(dr["AddedDate"].ToString(), out _datetime)) this.AddedDate = _datetime;
                this.AddedUser = dr["AddedUser"].ToString();
                if (DateTime.TryParse(dr["LastModDate"].ToString(), out _datetime)) this.LastModDate = _datetime;

                if (int.TryParse(dr["TenID"].ToString(), out _int)) this.TenID = _int;
                if (int.TryParse(dr["FldInt1"].ToString(), out _int)) this.FldInt1 = _int;
                if (int.TryParse(dr["FldInt2"].ToString(), out _int)) this.FldInt2 = _int;
                if (int.TryParse(dr["FldInt3"].ToString(), out _int)) this.FldInt3 = _int;
                this.FldBit1 = bool.Parse(dr["FldBit1"].ToString());
                this.FldBit2 = bool.Parse(dr["FldBit2"].ToString());
                this.FldBit3 = bool.Parse(dr["FldBit3"].ToString());
                this.FldText1 = dr["FldText1"].ToString();
                this.FldText2 = dr["FldText2"].ToString();
                this.FldText3 = dr["FldText3"].ToString();

                if (int.TryParse(dr["PreTestID"].ToString(), out _int)) this.PreTestID = _int;
                if (int.TryParse(dr["PostTestID"].ToString(), out _int)) this.PostTestID = _int;
                this.PreTestMandatory = bool.Parse(dr["PreTestMandatory"].ToString());
                if (DateTime.TryParse(dr["PreTestEndDate"].ToString(), out _datetime)) this.PreTestEndDate = _datetime;
                if (DateTime.TryParse(dr["PostTestStartDate"].ToString(), out _datetime)) this.PostTestStartDate = _datetime;

                dr.Close();

                CheckAndPopulatePointConversions(this);

                return true;

            }

            dr.Close();

            return false;
        }
Пример #23
0
        public static void CheckAndPopulatePointConversions(Programs obj)
        {

            var ds = ProgramGamePointConversion.GetAll(obj.PID);
            if (ds.Tables[0].Rows.Count == 0)
            {
                foreach (ActivityType val in Enum.GetValues(typeof(ActivityType)))
                {
                    var o = new ProgramGamePointConversion();
                    o.PGID = obj.PID;
                    o.ActivityTypeId = (int)val;
                    o.ActivityCount = 1;
                    o.PointCount = 0;
                    o.AddedDate = obj.AddedDate;
                    o.AddedUser = obj.AddedUser;
                    o.LastModDate = o.AddedDate;
                    o.LastModUser = o.AddedUser;

                    o.Insert();
                }
            }
            else
            {
                foreach (ActivityType val in Enum.GetValues(typeof(ActivityType)))
                {
                    var o = ProgramGamePointConversion.FetchObjectByActivityId(obj.PID, (int)val);
                    if (o == null)
                    {
                        o = new ProgramGamePointConversion
                        {
                            PGID = obj.PID,
                            ActivityTypeId = (int)val,
                            ActivityCount = 1,
                            PointCount = 0,
                            AddedDate = obj.AddedDate,
                            AddedUser = obj.AddedUser
                        };
                        o.LastModDate = o.AddedDate;
                        o.LastModUser = o.AddedUser;

                        o.Insert();
                    }
                }
            }
        }
Пример #24
0
        public static int Update(Programs o)
        {
            int iReturn = -1; //assume the worst

            var arrParams = new List <SqlParameter>();

            arrParams.Add(new SqlParameter("@PID", GlobalUtilities.DBSafeValue(o.PID, o.PID.GetTypeCode())));
            arrParams.Add(new SqlParameter("@AdminName", GlobalUtilities.DBSafeValue(o.AdminName, o.AdminName.GetTypeCode())));
            arrParams.Add(new SqlParameter("@Title", GlobalUtilities.DBSafeValue(o.Title, o.Title.GetTypeCode())));
            arrParams.Add(new SqlParameter("@TabName", GlobalUtilities.DBSafeValue(o.TabName, o.TabName.GetTypeCode())));
            arrParams.Add(new SqlParameter("@POrder", GlobalUtilities.DBSafeValue(o.POrder, o.POrder.GetTypeCode())));
            arrParams.Add(new SqlParameter("@IsActive", GlobalUtilities.DBSafeValue(o.IsActive, o.IsActive.GetTypeCode())));
            arrParams.Add(new SqlParameter("@IsHidden", GlobalUtilities.DBSafeValue(o.IsHidden, o.IsHidden.GetTypeCode())));
            arrParams.Add(new SqlParameter("@StartDate", GlobalUtilities.DBSafeValue(o.StartDate, o.StartDate.GetTypeCode())));
            arrParams.Add(new SqlParameter("@EndDate", GlobalUtilities.DBSafeValue(o.EndDate, o.EndDate.GetTypeCode())));
            arrParams.Add(new SqlParameter("@MaxAge", GlobalUtilities.DBSafeValue(o.MaxAge, o.MaxAge.GetTypeCode())));
            arrParams.Add(new SqlParameter("@MaxGrade", GlobalUtilities.DBSafeValue(o.MaxGrade, o.MaxGrade.GetTypeCode())));
            arrParams.Add(new SqlParameter("@LoggingStart", GlobalUtilities.DBSafeValue(o.LoggingStart, o.LoggingStart.GetTypeCode())));
            arrParams.Add(new SqlParameter("@LoggingEnd", GlobalUtilities.DBSafeValue(o.LoggingEnd, o.LoggingEnd.GetTypeCode())));
            arrParams.Add(new SqlParameter("@ParentalConsentFlag", GlobalUtilities.DBSafeValue(o.ParentalConsentFlag, o.ParentalConsentFlag.GetTypeCode())));
            arrParams.Add(new SqlParameter("@ParentalConsentText", GlobalUtilities.DBSafeValue(o.ParentalConsentText, o.ParentalConsentText.GetTypeCode())));
            arrParams.Add(new SqlParameter("@PatronReviewFlag", GlobalUtilities.DBSafeValue(o.PatronReviewFlag, o.PatronReviewFlag.GetTypeCode())));
            arrParams.Add(new SqlParameter("@RequireBookDetails", GlobalUtilities.DBSafeValue(o.RequireBookDetails, o.RequireBookDetails.GetTypeCode())));
            arrParams.Add(new SqlParameter("@LogoutURL", GlobalUtilities.DBSafeValue(o.LogoutURL, o.LogoutURL.GetTypeCode())));
            arrParams.Add(new SqlParameter("@ProgramGameID", GlobalUtilities.DBSafeValue(o.ProgramGameID, o.ProgramGameID.GetTypeCode())));
            arrParams.Add(new SqlParameter("@HTML1", GlobalUtilities.DBSafeValue(o.HTML1, o.HTML1.GetTypeCode())));
            arrParams.Add(new SqlParameter("@HTML2", GlobalUtilities.DBSafeValue(o.HTML2, o.HTML2.GetTypeCode())));
            arrParams.Add(new SqlParameter("@HTML3", GlobalUtilities.DBSafeValue(o.HTML3, o.HTML3.GetTypeCode())));
            arrParams.Add(new SqlParameter("@HTML4", GlobalUtilities.DBSafeValue(o.HTML4, o.HTML4.GetTypeCode())));
            arrParams.Add(new SqlParameter("@HTML5", GlobalUtilities.DBSafeValue(o.HTML5, o.HTML5.GetTypeCode())));
            arrParams.Add(new SqlParameter("@HTML6", GlobalUtilities.DBSafeValue(o.HTML6, o.HTML6.GetTypeCode())));
            arrParams.Add(new SqlParameter("@BannerImage", GlobalUtilities.DBSafeValue(o.BannerImage, o.BannerImage.GetTypeCode())));
            arrParams.Add(new SqlParameter("@RegistrationBadgeID", GlobalUtilities.DBSafeValue(o.RegistrationBadgeID, o.RegistrationBadgeID.GetTypeCode())));
            arrParams.Add(new SqlParameter("@CompletionPoints", GlobalUtilities.DBSafeValue(o.CompletionPoints, o.CompletionPoints.GetTypeCode())));
            arrParams.Add(new SqlParameter("@LastModUser", GlobalUtilities.DBSafeValue(o.LastModUser, o.LastModUser.GetTypeCode())));
            arrParams.Add(new SqlParameter("@AddedDate", GlobalUtilities.DBSafeValue(o.AddedDate, o.AddedDate.GetTypeCode())));
            arrParams.Add(new SqlParameter("@AddedUser", GlobalUtilities.DBSafeValue(o.AddedUser, o.AddedUser.GetTypeCode())));
            arrParams.Add(new SqlParameter("@LastModDate", GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode())));

            arrParams.Add(new SqlParameter("@TenID", GlobalUtilities.DBSafeValue(o.TenID, o.TenID.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldInt1", GlobalUtilities.DBSafeValue(o.FldInt1, o.FldInt1.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldInt2", GlobalUtilities.DBSafeValue(o.FldInt2, o.FldInt2.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldInt3", GlobalUtilities.DBSafeValue(o.FldInt3, o.FldInt3.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldBit1", GlobalUtilities.DBSafeValue(o.FldBit1, o.FldBit1.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldBit2", GlobalUtilities.DBSafeValue(o.FldBit2, o.FldBit2.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldBit3", GlobalUtilities.DBSafeValue(o.FldBit3, o.FldBit3.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldText1", GlobalUtilities.DBSafeValue(o.FldText1, o.FldText1.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldText2", GlobalUtilities.DBSafeValue(o.FldText2, o.FldText2.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldText3", GlobalUtilities.DBSafeValue(o.FldText3, o.FldText3.GetTypeCode())));

            arrParams.Add(new SqlParameter("@PreTestID", GlobalUtilities.DBSafeValue(o.PreTestID, o.PreTestID.GetTypeCode())));
            arrParams.Add(new SqlParameter("@PostTestID", GlobalUtilities.DBSafeValue(o.PostTestID, o.PostTestID.GetTypeCode())));
            arrParams.Add(new SqlParameter("@PreTestMandatory", GlobalUtilities.DBSafeValue(o.PreTestMandatory, o.PreTestMandatory.GetTypeCode())));
            arrParams.Add(new SqlParameter("@PreTestEndDate", GlobalUtilities.DBSafeValue(o.PreTestEndDate, o.PreTestEndDate.GetTypeCode())));
            arrParams.Add(new SqlParameter("@PostTestStartDate", GlobalUtilities.DBSafeValue(o.PostTestStartDate, o.PostTestStartDate.GetTypeCode())));
            arrParams.Add(new SqlParameter("@GoalDefault", GlobalUtilities.DBSafeValue(o.GoalDefault, o.GoalDefault.GetTypeCode())));
            arrParams.Add(new SqlParameter("@GoalMin", GlobalUtilities.DBSafeValue(o.GoalMin, o.GoalMin.GetTypeCode())));
            arrParams.Add(new SqlParameter("@GoalMax", GlobalUtilities.DBSafeValue(o.GoalMax, o.GoalMax.GetTypeCode())));
            arrParams.Add(new SqlParameter("@GoalIntervalId", GlobalUtilities.DBSafeValue(o.GoalIntervalId, o.GoalIntervalId.GetTypeCode())));
            arrParams.Add(new SqlParameter("@HideSchoolInRegistration", GlobalUtilities.DBSafeValue(o.HideSchoolInRegistration, o.HideSchoolInRegistration.GetTypeCode())));
            arrParams.Add(new SqlParameter("@DisplayDailyImage", GlobalUtilities.DBSafeValue(o.DisplayDailyImage, o.DisplayDailyImage.GetTypeCode())));

            try
            {
                iReturn = SqlHelper.ExecuteNonQuery(conn,
                                                    CommandType.StoredProcedure,
                                                    "app_Programs_Update",
                                                    arrParams.ToArray());
            }

            catch (SqlException exx)
            {
                System.Diagnostics.Debug.Write(exx.Message);
            }

            return(iReturn);
        }