/// <summary> /// Search button for the Deactivated tab, to search for Deactivated 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 DeactivatedSearchButton_Click(object sender, EventArgs e) { MessageUserControl.TryRun(() => { if (DeactivatedSearchBox.Text != "") { MessageUserControl.Visible = true; UnitController sysmgr = new UnitController(); searchArg.Value = DeactivatedSearchBox.Text; Utility utility = new Utility(); utility.checkValidString(searchArg.Value); deactivatedSearch.Value = "true"; bool siteNameChecked = DeactivatedSiteNameCheckbox.Selected; bool descriptionChecked = DeactivatedDescriptionCheckbox.Selected; bool unitNameChecked = DeactivatedUnitNameCheckbox.Selected; searchBy.Value = "All"; if (siteNameChecked == true) { searchBy.Value = "SiteName"; } else if (unitNameChecked == true) { searchBy.Value = "UnitName"; } else if (descriptionChecked == true) { searchBy.Value = "Description"; } DeactivatedUnitListView.DataSourceID = SearchListODS.ID; DeactivatedUnitListView.DataBind(); MessageUserControl.Visible = false; } }); }
/// <summary> /// /// </summary> /// <param name="sender">Sender of the PageLoad IE: Button</param> /// <param name="e">Arguments submitted by the sender. IE: "Cancel"</param> protected void DeactivatedClearButton_Click(object sender, EventArgs e) { MessageUserControl.TryRun(() => { DeactivatedSearchBox.Text = ""; DeactivatedUnitListView.DataSourceID = DeactivatedUnitListView_ODS.ID; DeactivatedUnitListView.DataBind(); MessageUserControl.Visible = false; }); }
/// <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(); }