Пример #1
0
    /// <summary>
    /// When the page loads first the page checks if the admin has proper authentication to access this page, and is redirected to login if not.
    /// Following that, the drop down lists on the page are populated with the appropriate information from the database.
    /// </summary>
    /// <param name="sender">Contains a reference to the control/object that raised the event.</param>
    /// <param name="e">Contains the event data.</param>
    protected void Page_Load(object sender, EventArgs e)
    {
        // this is for the client side input values to be retained after the page loads when a validation error is triggered (so the text is not lost)
        string startingPeriodInput = Request.Form["StartingPeriodInput"];
        string endingPeriodInput   = Request.Form["EndingPeriodInput"];

        this.startingInputValue = startingPeriodInput;
        this.endingInputValue   = endingPeriodInput;

        if (Session["securityID"] == null) // Redirect admin to login if not logged in
        {
            Response.Redirect("~/Admin/Login.aspx");
        }
        else if (!IsPostBack) // this is for loading the dropdown lists on the page with the data from the database
        {
            SiteController  siteController = new SiteController();
            List <SitePOCO> siteList       = siteController.GetSiteList(); // get all sites for the sites drop down list
            HospitalDropDownList.DataSource     = siteList;
            HospitalDropDownList.DataValueField = "siteID";
            HospitalDropDownList.DataTextField  = "siteName";
            HospitalDropDownList.DataBind();
            MealController  mealController = new MealController();
            List <MealPOCO> mealList       = mealController.GetMealList(); // get all meals for the meals drop down list
            MealDropDownList.DataSource     = mealList;
            MealDropDownList.DataValueField = "mealID";
            MealDropDownList.DataTextField  = "mealName";
            MealDropDownList.DataBind();
        }
    }
Пример #2
0
    /// <summary>
    /// Default Web Page Method use to initialize pages and check if the user is logged in.
    /// Initialize drop down lists alert labels
    /// </summary>
    /// <param name="sender">Contains a reference to the control/object that raised the event.</param>
    /// <param name="e">Contains the event data.</param>
    protected void Page_Load(object sender, EventArgs e)
    {
        // this is for the client side input values to be retained after the page loads when a validation error is triggered (so the text is not lost)
        string startingPeriodInput = Request.Form["StartingPeriodInput"];
        string endingPeriodInput   = Request.Form["EndingPeriodInput"];

        this.startingInputValue = startingPeriodInput;
        this.endingInputValue   = endingPeriodInput;
        // Redirect user to login if not logged in
        if (Session["securityID"] == null)
        {
            Response.Redirect("~/Admin/Login.aspx");
        }
        else if (!IsPostBack)
        {
            // Initialize Meal Controller, Meal List, Site Controller, and SitePOCO List variable
            MealController  mealController = new MealController();
            List <MealPOCO> mealList       = mealController.GetMealList();
            SiteController  siteController = new SiteController();
            List <SitePOCO> siteList       = siteController.GetSiteList();
            // Initialize Alert Label
            Alert.Visible = false;
            Alert.Text    = "";
            // Iniitalize and setup Meal Drop down list
            MealDropDownList.DataSource     = mealList;
            MealDropDownList.DataValueField = "mealID";
            MealDropDownList.DataTextField  = "mealName";
            MealDropDownList.DataBind();
            // Iniitalize and setup Site/Hospital Drop down list
            HospitalDropDownList.DataSource     = siteList;
            HospitalDropDownList.DataValueField = "siteID";
            HospitalDropDownList.DataTextField  = "siteName";
            HospitalDropDownList.DataBind();
        }
        // Initialize Alert Label
        Alert.Text    = "";
        Alert.Visible = false;
    }