Ejemplo n.º 1
0
    /*
     * CREATED:     P. Chavez		MAR 29 2018
     * MODIFIED:   C. Stanhope     APR 6 2018
     *  - added try-catch for database access
     * MODIFIED:   C. Stanhope     APR 14 2018
     *  - codes will show themselves independent of each other. You no longer need to have today's code AND tomorrow's code, any that have been generated will be displayed.
     *
     * DisplayAccessCodes()
     * Displays today's and tomorrow's access codes for a care site based on the care site ID passed.
     *
     * PARAMETERS:
     * int careSiteId - the ID of the care site
     *
     * RETURNS:
     * void
     *
     * ODEV METHOD CALLS:
     * MessageUserControl.ShowErrorMessage()
     * CareSiteAccessController.GetCareSiteAccessCodeByDate()
     */
    private void DisplayAccessCodes(int careSiteId)
    {
        try
        {
            // get access codes by today's and tomorrow's dates and the selected caresite
            AccessCodeDTO accessCodeToday    = careSiteAccessController.GetCareSiteAccessCodeByDate(careSiteId, DateTime.Now);
            AccessCodeDTO accessCodeTomorrow = careSiteAccessController.GetCareSiteAccessCodeByDate(careSiteId, DateTime.Now.AddDays(1));

            bool anActiveCodeExists = false;

            #region checking and assigning today's code
            if (accessCodeToday.accesscodeid == -3)
            {
                MessageUserControl.ShowErrorMessage("Today's code is not yet generated. Please return to the dashboard (welcome page) and navigate back to this page. If the error persists, please contact your administrator.");
                TodaysCard.Visible = false;
            }
            else // Today's code exists
            {
                CodeCards.Visible  = true;
                TodaysCard.Visible = true;

                anActiveCodeExists  = true;
                TodayCodeLabel.Text = accessCodeToday.accesscodeword;
                TodayDateLabel.Text = DateTime.Now.ToString("MMM d, yyyy");
            }
            #endregion

            #region checking and assigning tomorrow's code
            if (accessCodeTomorrow.accesscodeid == -3)
            {
                MessageUserControl.ShowErrorMessage("Tomorrow's code is not yet generated. Please return to the dashboard (welcome page) and navigate back to this page. If the error persists, please contact your administrator.");
                TomorrowsCard.Visible = false;
            }
            else // Tomorrow's code exists
            {
                CodeCards.Visible     = true;
                TomorrowsCard.Visible = true;

                anActiveCodeExists     = true;
                TomorrowCodeLabel.Text = accessCodeTomorrow.accesscodeword;
                TomorrowDateLabel.Text = DateTime.Now.AddDays(1).ToString("MMM d, yyyy");
            }
            #endregion

            if (!anActiveCodeExists) // neither code has been generated
            {
                MessageUserControl.ShowErrorMessage("Today's and tomorrow's codes are not yet generated. Please return to the dashboard (welcome page) and navigate back to this page. If the error persists, please contact your administrator.");
                CodeCards.Visible = false;
            }
        }
        catch (Exception ex)
        {
            MessageUserControl.ShowErrorMessage("Retrieving access codes from the database failed. Please try again. If error persists, please contact your administrator.", ex);
        }
    }
Ejemplo n.º 2
0
    /*
     * CREATED:     C. Stanhope		Mar 11 2018
     *
     * CareSiteDDL_SelectedIndexChanged()
     * Refreshes the page data to reflect the change made in the drop-down list, showing either an error or the access codes for the newly selected care site.
     *
     * PARAMETERS:
     * object sender - references the object that raised the Page_Load event
     * EventArgs e - optional class that may be passed that inherits from EventArgs (usually empty)
     *
     * RETURNS:
     * void
     *
     * METHOD CALLS:
     * MessageUserControl.ShowErrorMessage()
     * int.TryParse()
     * DateTime.Now()
     * DateTime.AddDays()
     * ToString()
     */
    protected void CareSiteDDL_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (CareSiteDDL.SelectedIndex == 0)
        {
            MessageUserControl.ShowErrorMessage("No care site selected. Please select a care site.");
            CodeCards.Visible = false;
        }
        else // care site was selected
        {
            int selectedCareSiteID;
            if (int.TryParse(CareSiteDDL.SelectedValue, out selectedCareSiteID))
            {
                // get access codes by today's and tomorrow's dates and the selected caresite
                AccessCodeDTO accessCodeToday    = careSiteAccessController.GetCareSiteAccessCodeByDate(selectedCareSiteID, DateTime.Now);
                AccessCodeDTO accessCodeTomorrow = careSiteAccessController.GetCareSiteAccessCodeByDate(selectedCareSiteID, DateTime.Now.AddDays(1));

                if (accessCodeToday.accesscodeid == -3)
                {
                    MessageUserControl.ShowErrorMessage("Today's code not yet generated. Please contact the administrator.");
                    CodeCards.Visible = false;
                }
                else if (accessCodeTomorrow.accesscodeid == -3)
                {
                    MessageUserControl.ShowErrorMessage("Tomorrows's code not generated. Please contact the administrator.");
                    CodeCards.Visible = false;
                }
                else // today's and tomorrow's codes are generated and displayed
                {
                    TodayCodeLabel.Text    = accessCodeToday.accesscodeword;
                    TomorrowCodeLabel.Text = accessCodeTomorrow.accesscodeword;

                    TodayDateLabel.Text    = DateTime.Now.ToString("MMM d, yyyy");
                    TomorrowDateLabel.Text = DateTime.Now.AddDays(1).ToString("MMM d, yyyy");

                    CodeCards.Visible = true;
                }
            }
            else // the tryparse of the care site ID didn't work
            {
                MessageUserControl.ShowErrorMessage("Something failed. Please contact the administrator.");
            }
        }
    }