/*
     * CREATED:     C. Stanhope		MAR 23 2018
     * MODIFIED:   C. Stanhope     APR 6 2018
     *  - added try-catch for database access
     *
     * DeactivateCareSiteButton_Click()
     * Used to deactivate a care site in the database.
     *
     * 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
     *
     * ODEV METHOD CALLS:
     * MessageUserControl.ShowInfoMessage()
     * CareSiteController.GetCareSiteByCareSiteID()
     * MessageUserControl.ShowErrorMessage()
     */
    protected void DeactivateCareSiteButton_Click(object sender, EventArgs e)
    {
        if (selectedCareSite != null)
        {
            try
            {
                careSiteController.DeactivateCareSite(selectedCareSite);

                MessageUserControl.ShowSuccessMessage("The " + selectedCareSite.caresitename + " care site was successfully deactivated.");

                CareSiteDDL.SelectedIndex = 0;
                CareSiteNameTextBox.Text  = "";
                AddressTextBox.Text       = "";
                CityTextBox.Text          = "";
                AccountForm.Visible       = false;

                #region resetting care site ddl
                CareSiteDDL.AppendDataBoundItems = false; // clears old values
                CareSiteDDL.DataSourceID         = null;

                // get new list of care sites
                List <CareSiteDTO> ddlCareSites = careSiteController.GetActiveCareSites();

                // create a fake care site that acts as a "select" in the ddl
                CareSiteDTO fakeSelectCareSite = new CareSiteDTO();
                fakeSelectCareSite.caresiteid   = 0;
                fakeSelectCareSite.caresitename = "Select...";

                ddlCareSites.Add(fakeSelectCareSite);

                // put the new "select" care site at the top of the list
                ddlCareSites = ddlCareSites.OrderBy(site => site.caresiteid).ToList();

                // bind data source
                CareSiteDDL.DataSource = ddlCareSites;
                CareSiteDDL.DataBind();
                #endregion
            }
            catch (Exception ex)
            {
                MessageUserControl.ShowErrorMessage("Deactivating care site failed. Please try again. If error persists, please contact your administrator.", ex);
            }
        }
        else
        {
            MessageUserControl.ShowErrorMessage("No care site selected. The \"Deactivate Care Site\" button should not be available if no care site is selected. Please try again. If error persists, please contact your administrator.");
        }
    }
Exemple #2
0
 /*
  * CREATED:     A. Valberg		MAR 16 2018
  *
  * Page_Load()
  * This method runs when the page loads. It also checks user authorization levels before displaying data.
  *
  * PARAMETERS:
  * object sender - object on the page that is being targeted
  * EventArgs e - event that has triggered the method
  *
  * RETURNS:
  * void
  *
  * ODEV METHOD CALLS:
  * MessageUserControl.ShowErrorMessage()
  * CareSiteController.GetCareSiteByCareSiteID()
  * UnitController.GetCareSiteUnits()
  * GetActiveCareSites()
  * RespondentTypeController.GetAllRespondentTypes()
  * GenderController.GetAllGenders()
  * AgeController.GetAllAges()
  * CareSiteController.GetCareSites()
  */
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (User.IsInRole(AuthorizationLevelRoles.User))
         {
             ApplicationUser user       = userManager.FindById(User.Identity.GetUserId());
             int             careSiteID = user.caresiteid == null ? 0 : (int)user.caresiteid;
             if (careSiteID == 0)
             {
                 MessageUserControl.ShowErrorMessage("Your account has no assigned care site. Please contact your administrator to be assigned a care site.");
             }
             else
             {
                 CareSiteDDL.Items.Clear();
                 CareSiteDDL.Items.Add(new ListItem(careSiteController.GetCareSiteByCareSiteID(careSiteID).caresitename, careSiteID.ToString()));
                 UnitRepeater.DataSource = unitController.GetCareSiteUnits(careSiteID);
                 UnitRepeater.DataBind();
                 RespondentTypeRepeater.DataSource = respondentTypeController.GetAllRespondentTypes();
                 RespondentTypeRepeater.DataBind();
                 GenderRepeater.DataSource = genderController.GetAllGenders();
                 GenderRepeater.DataBind();
                 AgeGroupRepeater.DataSource = ageController.GetAllAges();
                 AgeGroupRepeater.DataBind();
             }
         }
         else
         {
             CareSiteDDL.DataSource = careSiteController.GetCareSites();
             CareSiteDDL.DataBind();
             unitsdiv.Attributes.Add("style", "display:none");
             RespondentTypeRepeater.DataSource = respondentTypeController.GetAllRespondentTypes();
             RespondentTypeRepeater.DataBind();
             GenderRepeater.DataSource = genderController.GetAllGenders();
             GenderRepeater.DataBind();
             AgeGroupRepeater.DataSource = ageController.GetAllAges();
             AgeGroupRepeater.DataBind();
         }
     }
 }
Exemple #3
0
    /*
     * CREATED:     C. Stanhope		Mar 3 2018
     * MODIFIED:   P. Chavez       MAR 27 2018
     *  - Added to method body, used Holly's code
     *
     * Page_Load()
     * Run on page load and is used to display today's and tomorrow's access codes if a care site is selected from the drop-down list.
     *
     * 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
     *
     * ODEV METHOD CALLS:
     * UserManager.FindById()
     * MessageUserControl.ShowErrorMessage()
     * CareSiteController.GetCareSiteByCareSiteID()
     * DisplayAccessCodes()
     */
    protected void Page_Load(object sender, EventArgs e)
    {
        if (CareSiteDDL.SelectedIndex == 0)
        {
            CodeCards.Visible = false;
        }

        if (User.IsInRole(AuthorizationLevelRoles.User))
        {
            UserManager        userManager        = new UserManager();
            ApplicationUser    account            = userManager.FindById(User.Identity.GetUserId());
            CareSiteController careSiteController = new CareSiteController();

            int accountCareSiteId = account.caresiteid == null ? 0 : (int)account.caresiteid;

            if (accountCareSiteId == 0)
            {
                MessageUserControl.ShowErrorMessage("Your account has no assigned care site. Please contact your administrator to be assigned a care site.");
            }
            else
            {
                try
                {
                    CareSiteDDL.DataSourceID         = null;
                    CareSiteDDL.AppendDataBoundItems = false;
                    List <CareSiteDTO> tempCareSiteList = new List <CareSiteDTO>();
                    tempCareSiteList.Add(careSiteController.GetCareSiteByCareSiteID(accountCareSiteId));
                    CareSiteDDL.DataSource = tempCareSiteList;
                    CareSiteDDL.DataBind();

                    DisplayAccessCodes(accountCareSiteId);
                }
                catch (Exception ex)
                {
                    MessageUserControl.ShowErrorMessage("Could not retrieve User's care site. Please try again. If error persists, please contact your administrator.", ex);
                }
            }
        }
    }
Exemple #4
0
    /*
     * CREATED:     H. Conant		MAR 4 2018
     * MODIFIED:   H. Conant       MAR 20 2018
     *  - Added method body
     *
     * Page_Load()
     * This method runs any code it contains when the page loads.
     *
     * PARAMETERS:
     * object sender - object on the page that is being targeted
     * EventArgs e - event that has triggered the method
     *
     * RETURNS:
     * void
     *
     * ODEV METHOD CALLS:
     * UserManager.FindById()
     * MessageUserControl.ShowErrorMessage()
     * CareSiteController.GetCareSiteByCareSiteID()
     * UnitController.GetCareSiteUnits()
     * UnitController.GetAllUnits()
     */
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (User.IsInRole(AuthorizationLevelRoles.User))
            {
                UserManager userManager = new UserManager();

                ApplicationUser account = new ApplicationUser();

                try
                {
                    account = userManager.FindById(User.Identity.GetUserId());
                }
                catch (Exception ex)
                {
                    MessageUserControl.ShowErrorMessage("Your account has no assigned care site. Please contact your administrator to be assigned a care site.", ex);
                }

                CareSiteController careSiteController = new CareSiteController();

                int accountCareSiteId = account.caresiteid == null ? 0 : (int)account.caresiteid;

                if (accountCareSiteId == 0)
                {
                    MessageUserControl.ShowErrorMessage("Your account has no assigned care site. Please contact your administrator to be assigned a care site.");
                }
                else
                {
                    try
                    {
                        CareSiteDDL.DataSourceID         = null;
                        CareSiteDDL.AppendDataBoundItems = false;
                        List <CareSiteDTO> tempCareSiteList = new List <CareSiteDTO>();
                        tempCareSiteList.Add(careSiteController.GetCareSiteByCareSiteID(accountCareSiteId));
                        CareSiteDDL.DataSource = tempCareSiteList;
                        CareSiteDDL.DataBind();

                        List <UnitDTO> tempUnitList = unitController.GetCareSiteUnits(accountCareSiteId);
                        UnitRepeater.DataSource = tempUnitList;
                        UnitRepeater.DataBind();
                        unitsdiv.Attributes.Remove("style");
                    }
                    catch (Exception ex)
                    {
                        MessageUserControl.ShowErrorMessage("Retrieving user care site and/or units from the database failed. Please try again. If error persists, please contact your administrator.", ex);
                    }
                }
            }
            else
            {
                if (CareSiteDDL.SelectedValue == "0")
                {
                    try
                    {
                        int tempCareSiteId;
                        int.TryParse(CareSiteDDL.SelectedValue, out tempCareSiteId);
                        List <UnitDTO> tempUnitList = unitController.GetAllUnits();
                        UnitRepeater.DataSource = tempUnitList;
                        UnitRepeater.DataBind();
                        unitsdiv.Attributes.Add("style", "display:none");
                    }
                    catch (Exception ex)
                    {
                        MessageUserControl.ShowErrorMessage("Retrieving units from the database failed. Please try again. If error persists, please contact your administrator.", ex);
                    }
                }
                else
                {
                    try
                    {
                        int tempCareSiteId;
                        int.TryParse(CareSiteDDL.SelectedValue, out tempCareSiteId);
                        List <UnitDTO> tempUnitList = unitController.GetCareSiteUnits(tempCareSiteId);
                        UnitRepeater.DataSource = tempUnitList;
                        UnitRepeater.DataBind();
                        unitsdiv.Attributes.Remove("style");
                    }
                    catch (Exception ex)
                    {
                        MessageUserControl.ShowErrorMessage("Retrieving units from the database failed. Please try again. If error persists, please contact your administrator.", ex);
                    }
                }
            }
        }
    }