示例#1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["securityID"] == null) // Redirects to login if not logged in
        {
            Response.Redirect("~/Admin/Login.aspx");
        }
        else if ((int)Session["securityID"] != 2) // Return HTTP Code 403
        {
            Context.Response.StatusCode = 403;
        }


        // Catches the initial site ID when the page loads from the SideDropDownList and displays Active units Listview for that site.
        if (!IsPostBack)
        {
            seeArchive = false;
            SiteDropDownList.DataBind();


            SelectedSiteID.Text = SiteDropDownList.SelectedValue;

            if (SelectedSiteID == null)
            {
                throw new Exception("Select an existsing Site");
            }
            else
            {
                UnitsListView.Visible = true;
                UnitsListView.DataBind();
            }
        }
    }
示例#2
0
    /// <summary>
    /// This method catches the the value of the site dropdownlist when changed
    /// and displays the active units for that site.
    /// <summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void SiteDropDownList_SelectedIndexChanged(object sender, EventArgs e)
    {
        SelectedSiteID.Text = SiteDropDownList.SelectedValue;

        UnitsListView.Visible = true;
        seeArchive            = false;
        RevealButton.Text     = "Show Archived";
        ArchivedUnitsListView.DataBind();
        UnitsListView.DataBind();
    }
示例#3
0
    /// <summary>
    /// This button on click method is for adding a new unit to the selected site in the database.
    /// <summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>

    protected void AddUnitButton_Click(object sender, EventArgs e)
    {
        int            siteId     = int.Parse(SelectedSiteID.Text);
        int            userId     = (int)Session["adminID"];
        string         unitNumber = AddUnitTextBox.Text.Trim();
        UnitController sysmgr     = new UnitController();

        MessageUserControl.TryRun(() =>
        {
            sysmgr.AddUnit(unitNumber, userId, siteId);
            UnitsListView.DataBind();
            AddUnitTextBox.Text = "";
        }, "Success", "Successfully added the new unit: \"" + unitNumber + "\"");
    }
示例#4
0
    /// <summary>
    /// when the view active/archive is clicked, this changes the chosen ods for all listviews to the other ods.
    /// if the archived ods is being used, then the active ods is set, and vice-versa.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void ToggleView(object sender, EventArgs e)
    {
        if (seeArchive)
        {
            seeArchive            = false;
            UnitsListView.Visible = true;
            UnitsListView.DataBind();
            ArchivedUnitsListView.Visible = false;

            RevealButton.Text = "Show Archived";
        }
        else
        {
            seeArchive = true;
            ArchivedUnitsListView.Visible = true;
            ArchivedUnitsListView.DataBind();
            UnitsListView.Visible = false;

            RevealButton.Text = "Show Active";
        }
    }