protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var familyRelationship = new FamilyTools().ValidImpersonation(Request, Session);

                if (familyRelationship == null)
                {
                    Response.Redirect("~");
                }
                ViewState["SubmitAsPatronId"] = familyRelationship.PatronId;

                var patron  = Patron.FetchObject(familyRelationship.PatronId);
                var program = Programs.FetchObject(patron.ProgID);

                lblAccount.Text = DisplayHelper.FormatName(patron.FirstName,
                                                           patron.LastName,
                                                           patron.Username);

                if (program == null || !program.IsOpen)
                {
                    familyCodeControlPanel.Visible = false;
                    return;
                }
                ViewState["SubmitAsPatronId"] = familyRelationship.PatronId;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var familyRelationship = new FamilyTools().ValidImpersonation(Request, Session);
                if (familyRelationship == null)
                {
                    Response.Redirect("~");
                }

                ViewState["SubmitAsPatronId"] = familyRelationship.PatronId;

                var patron  = Patron.FetchObject(familyRelationship.PatronId);
                var program = Programs.FetchObject(patron.ProgID);

                lblAccount.Text = DisplayHelper.FormatName(patron.FirstName,
                                                           patron.LastName,
                                                           patron.Username);

                if (program == null || !program.IsOpen)
                {
                    familyReadingLogControlPanel.Visible = false;
                    return;
                }

                ViewState["ProgramGameId"] = program.PID.ToString();

                if (Request.Cookies[CookieKey.LogBookDetails] != null)
                {
                    enterBookDetails.Checked = true;
                }

                foreach (ActivityType activityTypeValue in Enum.GetValues(typeof(ActivityType)))
                {
                    int    activityTypeId = (int)activityTypeValue;
                    string lookupString   = string.Format("{0}.{1}.{2}",
                                                          CacheKey.PointGameConversionStub,
                                                          patron.ProgID,
                                                          activityTypeId);
                    var pgc = Cache[lookupString] as ProgramGamePointConversion;
                    if (pgc == null)
                    {
                        this.Log().Debug("Cache miss looking up {0}", lookupString);
                        pgc = ProgramGamePointConversion.FetchObjectByActivityId(patron.ProgID,
                                                                                 activityTypeId);
                        Cache[lookupString] = pgc;
                    }

                    if (pgc != null && pgc.PointCount > 0)
                    {
                        activityTypeSelector.Items.Add(new ListItem(activityTypeValue.ToString(),
                                                                    activityTypeId.ToString()));
                    }
                }

                if (activityTypeSelector.Items.Count == 1)
                {
                    var singleOption = activityTypeSelector.Items[0];

                    if (int.Parse(singleOption.Value) == (int)ActivityType.Books)
                    {
                        countSubmittedLabel.Visible     = false;
                        familyReadingActivityField.Text = "1";
                        familyReadingActivityField.Attributes.Remove("style");
                        familyReadingActivityField.Attributes.Add("style", "display: none;");
                        activityTypeSelector.Attributes.Remove("style");
                        activityTypeSelector.Attributes.Add("style", "display: none;");
                        activityTypeSingleLabel.Visible = false;
                        submitButton.Text = StringResources.getString("readinglog-read-a-book");
                    }
                    else
                    {
                        activityTypeSelector.Attributes.Remove("style");
                        activityTypeSelector.Attributes.Add("style", "display: none;");
                        activityTypeSingleLabel.Text    = singleOption.Text;
                        activityTypeSingleLabel.Visible = true;
                    }
                }
                else
                {
                    activityTypeSingleLabel.Visible = false;
                }
            }
        }