Exemplo n.º 1
0
 /// <summary>
 /// Search button for the Active tab, to search for active sites
 /// </summary>
 /// <param name="sender">Sender of the PageLoad IE: Button</param>
 /// <param name="e">Arguments submitted by the sender. IE: "Cancel"</param>
 protected void ActiveSearchButton_Click(object sender, EventArgs e)
 {
     MessageUserControl.TryRun(() =>
     {
         if (ActiveSearchBox.Text != "")
         {
             MessageUserControl.Visible = true;
             searchArg.Value            = ActiveSearchBox.Text;
             Utility utility            = new Utility();
             utility.checkValidString(searchArg.Value);
             deactivatedSearch.Value = "false";
             bool siteNameChecked    = ActiveSiteNameCheckbox.Selected;
             bool descriptionChecked = ActiveDescriptionCheckbox.Selected;
             bool unitNameChecked    = ActiveUnitNameCheckbox.Selected;
             searchBy.Value          = "All";
             if (siteNameChecked == true)
             {
                 searchBy.Value = "SiteName";
             }
             else if (unitNameChecked == true)
             {
                 searchBy.Value = "UnitName";
             }
             else if (descriptionChecked == true)
             {
                 searchBy.Value = "Description";
             }
             ActiveUnitListView.DataSourceID = SearchListODS.ID;
             ActiveUnitListView.DataBind();
             MessageUserControl.Visible = false;
         }
     });
 }
Exemplo n.º 2
0
 /// <summary>
 /// Clear button for the
 /// </summary>
 /// <param name="sender">Sender of the PageLoad IE: Button</param>
 /// <param name="e">Arguments submitted by the sender. IE: "Cancel"</param>
 protected void ActiveClearButton_Click(object sender, EventArgs e)
 {
     MessageUserControl.TryRun(() =>
     {
         ActiveSearchBox.Text            = "";
         ActiveUnitListView.DataSourceID = ActiveUnitListView_ODS.ID;
         ActiveUnitListView.DataBind();
         MessageUserControl.Visible = false;
     });
 }
Exemplo n.º 3
0
 /// <summary>
 /// Re-enables the search buttons and datapager when the edit item cancel button is pushed.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void ActiveSiteListView_ItemCanceling(object sender, ListViewCancelEventArgs e)
 {
     MessageUserControl.TryRun(() =>
     {
         ActiveSearchButton.Enabled = true;
         ActiveClearButton.Enabled  = true;
         DataPager pager            = ActiveUnitListView.FindControl("ActiveDataPager") as DataPager;
         pager.Visible = true;
     });
 }
Exemplo n.º 4
0
    protected void AddUnitButton_Click(object sender, EventArgs e)
    {
        MessageUserControl.TryRun(() =>
        {
            MessageUserControl.Visible = true;

            DropDownList siteNameDDL = AddSiteNameDDL;
            int siteId         = int.Parse(siteNameDDL.SelectedValue);
            string unitName    = AddUnitName.Text;
            string description = AddUnitDescription.Text;

            Utility utility = new Utility();
            utility.checkValidString(unitName);
            utility.checkValidString(description);

            if (string.IsNullOrEmpty(unitName))
            {
                MessageUserControl.ShowInfo("Warning", "Unit Name is required.");
            }
            else if (string.IsNullOrEmpty(description))
            {
                MessageUserControl.ShowInfo("Warning", "Description is required.");
            }
            else
            {
                MessageUserControl.TryRun(() =>
                {
                    UnitController sysmgr = new UnitController();
                    sysmgr.Unit_Add(siteId, unitName, description, int.Parse(UserSiteId.Text));
                    ActiveUnitListView.DataSourceID = ActiveUnitListView_ODS.ID;
                    AddUnitListView.DataBind();
                    ActiveUnitListView.DataBind();

                    // Clear fields after add
                    AddClearButton_Click(sender, e);
                }, "Success", "New unit has been added.");
            }
        });
    }
Exemplo n.º 5
0
    /// <summary>
    /// Button commands for inside the ListView. Allows the user to do things like Update, Add, Clear, Cancel etc.
    /// </summary>
    /// <param name="sender">Sender of the PageLoad IE: Button</param>
    /// <param name="e">Arguments submitted by the sender. IE: "Cancel"</param>
    protected void UnitListView_ItemCommand(object sender, ListViewCommandEventArgs e)
    {
        MessageUserControl.Visible = false;

        int unitId = 1;

        MessageUserControl.TryRun(() =>
        {
            // If the user is attempting to do anything but Add or Cancel, collect the unitId from the ListView
            if (!e.CommandName.Equals("Cancel") && !e.CommandName.Equals("Add"))
            {
                unitId = int.Parse(e.CommandArgument.ToString());
            }

            // Update the Unit on the selected row. Only one item can be updated at a time.
            if (e.CommandName.Equals("Change"))
            {
                MessageUserControl.TryRun(() =>
                {
                    int i = e.Item.DisplayIndex;

                    DropDownList siteNameDDL = ActiveUnitListView.Items[i].FindControl("SiteNameDDL") as DropDownList;
                    int siteId = int.Parse(siteNameDDL.SelectedValue);
                    TextBox unitNameTextBox    = ActiveUnitListView.Items[i].FindControl("UnitNameTextBox") as TextBox;
                    string unitName            = unitNameTextBox.Text;
                    TextBox descriptionTextBox = ActiveUnitListView.Items[i].FindControl("DescriptionTextBox") as TextBox;
                    string description         = descriptionTextBox.Text;

                    MessageUserControl.Visible = true;

                    Utility utility = new Utility();
                    utility.checkValidString(unitName);
                    utility.checkValidString(description);

                    UnitController sysmgr = new UnitController();
                    sysmgr.Unit_Update(unitId, siteId, unitName, description);
                    ActiveUnitListView.DataSourceID = ActiveUnitListView_ODS.ID;
                    ActiveUnitListView.EditIndex    = -1;
                    ActiveUnitListView.DataBind();
                    AddUnitListView.DataBind();
                    DeactivatedUnitListView.DataBind();
                    ActiveSearchBox.Text       = "";
                    MessageUserControl.Visible = true;
                    ActiveSearchButton.Enabled = true;
                    ActiveClearButton.Enabled  = true;
                    DataPager pager            = ActiveUnitListView.FindControl("ActiveDataPager") as DataPager;
                    pager.Visible = true;
                }, "Success", "Unit has been updated");
            }

            // Deactivate the Unit on the selected row.
            else if (e.CommandName.Equals("Deactivate"))
            {
                MessageUserControl.TryRun(() =>
                {
                    MessageUserControl.Visible = true;
                    UnitController sysmgr      = new UnitController();
                    sysmgr.Unit_Deactivate(unitId);
                }, "Success", "Unit has been deactivated");
            }
        });

        ActiveUnitListView.DataSourceID      = ActiveUnitListView_ODS.ID;
        DeactivatedUnitListView.DataSourceID = DeactivatedUnitListView_ODS.ID;
        AddSiteNameDDL.DataSourceID          = ActiveSiteNameDDL_ODS.ID;
        ActiveUnitListView.DataBind();
        AddUnitListView.DataBind();
        DeactivatedUnitListView.DataBind();
        AddSiteNameDDL.DataBind();
    }