/* * CREATED: A. Valberg MAR 19 2018 * * CareSiteDDL_OnSelectedIndexChanged() * This method runs if the index of the care site DDL changes. * * PARAMETERS: * object sender - object on the page that is being targeted * EventArgs e - event that has triggered the method * * RETURNS: * void * * ODEV METHOD CALLS: * UnitController.GetCareSiteUnits() */ protected void CareSiteDDL_OnSelectedIndexChanged(object sender, EventArgs e) { if (CareSiteDDL.SelectedValue != "" && !User.IsInRole(AuthorizationLevelRoles.User)) { int tempCareSiteId; int.TryParse(CareSiteDDL.SelectedValue, out tempCareSiteId); List <UnitDTO> tempUnitList = unitController.GetCareSiteUnits(tempCareSiteId); unitsdiv.Attributes.Remove("style"); UnitRepeater.DataSource = tempUnitList; UnitRepeater.DataBind(); if (ReportViewer1.Visible) { ReportViewer1.Visible = false; } } else { unitsdiv.Attributes.Add("style", "display:none"); UnitRepeater.DataSource = null; UnitRepeater.DataBind(); if (ReportViewer1.Visible) { ReportViewer1.Visible = false; } } }
/* * CREATED: H. Conant MAR 13 2018 * MODIFIED: H. Conant MAR 20 2018 * - Updated method signature * * RetrieveUnitList_Select() * This method runs any code it contains when the index changes for the care site drop down. * * PARAMETERS: * object sender - object on the page that is being targeted * EventArgs e - event that has triggered the method * * RETURNS: * void * * ODEV METHOD CALLS: * UnitController.GetCareSiteUnits() * MessageUserControl.ShowErrorMessage() * UnitController.GetAllUnits() */ protected void RetrieveUnitList_Select(object sender, EventArgs e) { SurveyRepeater.DataSource = null; SurveyRepeater.DataBind(); ResultCountLabel.Text = "-"; if (User.IsInRole(AuthorizationLevelRoles.User)) { 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); } } 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); } } } }
/* * CREATED: H. Conant MAR 13 2018 * * RetrieveUnitListButton_Click() * This method runs any code it contains when the "Retrieve Units" button is clicked. * * PARAMETERS: * object sender - object on the page that is being targeted * EventArgs e - event that has triggered the method * * RETURNS: * void - Nothing is returned * * METHOD CALLS: * .TryParse() * .GetAllUnits() * .DataBind() */ protected void RetrieveUnitListButton_Click(object sender, EventArgs e) { if (CareSiteDDL.SelectedValue == "0") { int tempCareSiteId; int.TryParse(CareSiteDDL.SelectedValue, out tempCareSiteId); List <UnitDTO> tempUnitList = unitController.GetAllUnits(); UnitRepeater.DataSource = tempUnitList; UnitRepeater.DataBind(); } else { int tempCareSiteId; int.TryParse(CareSiteDDL.SelectedValue, out tempCareSiteId); List <UnitDTO> tempUnitList = unitController.GetCareSiteUnits(tempCareSiteId); UnitRepeater.DataSource = tempUnitList; UnitRepeater.DataBind(); } }
/* * 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(); } } }
/* * 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); } } } } }