Esempio n. 1
0
 /// <summary>
 /// Clears the search textbox and repopulates the sitelist with all deactivated sites.
 /// </summary>
 /// <param name="sender">Contains a reference to the control/object that raised the event.</param>
 /// <param name="e">Contains the event data of the event that triggered the method.</param>
 protected void DeactivatedClearButton_Click(object sender, EventArgs e)
 {
     DeactivatedSearchBox.Text            = "";
     DeactivatedSiteListView.DataSourceID = DeactivatedSiteListODS.ID;
     DeactivatedSiteListView.DataBind();
     MessageUserControl.Visible = false;
 }
Esempio n. 2
0
    /// <summary>
    /// Searches deactivated sites based on the selected radio button and the users input in the search box.
    /// </summary>
    /// <param name="sender">Contains a reference to the control/object that raised the event.</param>
    /// <param name="e">Contains the event data of the event that triggered the method.</param>
    protected void DeactivatedSearchButton_Click(object sender, EventArgs e)
    {
        MessageUserControl.TryRun(() =>
        {
            if (DeactivatedSearchBox.Text != "")
            {
                MessageUserControl.Visible = true;
                // Sets the hidden searchArg field to the user's search field text for use by the SearchListODS.
                searchArg.Value = DeactivatedSearchBox.Text;

                // Special character validation.
                Utility utility = new Utility();
                utility.checkValidString(searchArg.Value);

                // Sets the deactivated flag and the searchBy hidden field value.
                deactivatedSearch.Value = "true";
                bool siteNameChecked    = DeactivatedSiteNameCheckbox.Selected;
                bool descriptionChecked = DeactivatedDescriptionCheckbox.Selected;
                searchBy.Value          = "All";
                if (siteNameChecked == true)
                {
                    searchBy.Value = "Site Name";
                }
                else if (descriptionChecked == true)
                {
                    searchBy.Value = "Description";
                }

                // Changes the listview ODS to the search ODS and binds it.
                DeactivatedSiteListView.DataSourceID = SearchListODS.ID;
                DeactivatedSiteListView.DataBind();
                MessageUserControl.Visible = false;
            }
        });
    }
Esempio n. 3
0
    /// <summary>
    /// Handles all the events caused by clicking any button in the ActiveSiteListView.
    /// </summary>
    /// <param name="sender">Contains a reference to the control/object that raised the event.</param>
    /// <param name="e">Contains the event data of the event that triggered the method.</param>
    protected void SiteListView_ItemCommand(object sender, ListViewCommandEventArgs e)
    {
        MessageUserControl.Visible = false;
        int siteId = 1;

        // If the cancel button is pressed the CommandArgument will be null so we do not want to try to convert it to string.
        // Otherwise we want to get the siteId of the row the user clicked the button on.
        if (!e.CommandName.Equals("Cancel"))
        {
            siteId = int.Parse(e.CommandArgument.ToString());
        }
        // If the user presses the "Update" button we grab the values they input into the textboxes and then run Site_Update using them as the parameters.
        // Afterwords we must set EditIndex to -1 to deactivate edit mode on the updated field.
        if (e.CommandName.Equals("Change"))
        {
            // Grabs the index of the current item in the listview.
            int i = e.Item.DisplayIndex;

            // Gets the values the user has input into the textboxs and assigns them to a string variable.
            TextBox siteNameBox    = ActiveSiteListView.Items[i].FindControl("SiteNameTextBox") as TextBox;
            string  siteName       = siteNameBox.Text;
            TextBox descriptionBox = ActiveSiteListView.Items[i].FindControl("DescriptionTextBox") as TextBox;
            string  description    = descriptionBox.Text;
            TextBox passcodeBox    = ActiveSiteListView.Items[i].FindControl("PasscodeTextBox") as TextBox;
            string  passcode       = passcodeBox.Text;

            MessageUserControl.TryRun(() =>
            {
                MessageUserControl.Visible = true;

                // Validation for special characters.
                Utility utility = new Utility();
                utility.checkValidString(siteName);
                utility.checkValidString(description);
                utility.checkValidString(passcode);

                // Updates the selected site, turns off the edit mode and rebinds all active site listviews.
                SiteController sysmgr = new SiteController();
                sysmgr.Site_Update(siteId, siteName, description, passcode);
                ActiveSiteListView.DataSourceID = ActiveSiteListODS.ID;
                ActiveSiteListView.EditIndex    = -1;
                ActiveSiteListView.DataBind();
                AddSiteListView.DataBind();

                // Clears the search field and re-enables all the controls that are disabled during edit mode.
                ActiveSearchBox.Text       = "";
                ActiveSearchButton.Enabled = true;
                ActiveClearButton.Enabled  = true;
                DataPager pager            = ActiveSiteListView.FindControl("ActiveDataPager") as DataPager;
                pager.Visible = true;
            }, "Success", "Site has been updated");
        }
        // If the user presses deactivate we simply take the siteId from above and deactivate the site it is attributed to.
        else if (e.CommandName.Equals("Deactivate"))
        {
            MessageUserControl.TryRun(() =>
            {
                MessageUserControl.Visible = true;

                // Deactivates the current site.
                SiteController sysmgr = new SiteController();
                sysmgr.Site_Deactivate(siteId);
            }, "Success", "Site has been deactivated");

            // Rebinds all listviews and resets the ODS' to their defaults rather than the search ODS.
            ActiveSiteListView.DataSourceID      = ActiveSiteListODS.ID;
            DeactivatedSiteListView.DataSourceID = DeactivatedSiteListODS.ID;
            ActiveSiteListView.DataBind();
            AddSiteListView.DataBind();
            DeactivatedSiteListView.DataBind();
        }
    }