/// <summary> /// This event fires when the user add a job site to a crew or click on the Finish button /// When adding a job site to a crew, it first verifies that a crew is selected /// Then add the Job site /// When user click on the Finish button, it turns off the site menu and the Routes /// It turns on the Job Cards GridView /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void RouteListView_ItemCommand(object sender, ListViewCommandEventArgs e) { string message = ""; string command = e.CommandName; switch (command) { case "AddSite": //Get hold of the row that fired the event ListViewDataItem item = RouteListView.Items[e.Item.DisplayIndex]; DropDownList list = item.FindControl("SelectTask") as DropDownList; InfoUserControl.TryRun(() => { if (string.IsNullOrEmpty(CrewID.Text)) { InfoUserControl.ShowWarning("You must first create or select a Crew before adding a job site!"); } else { int crewId = int.Parse(CrewID.Text); int siteId = int.Parse(e.CommandArgument.ToString()); int taskId = int.Parse(list.SelectedValue); CrewController crewManager = new CrewController(); message = crewManager.AddJobCard(crewId, siteId, taskId); RefreshCurrentCrews(); } }); if (!string.IsNullOrEmpty(message)) { InfoUserControl.ShowInfo("The following Crew(s) are already assigned to this same Site: " + message); RefreshCurrentCrews(); } break; case "Finish": SiteMenu.Visible = false; RouteListView.Visible = false; PopulateRouteStatus(); PopulateUnitReport(); MakeCrew.Visible = true; LastCrews.Visible = true; FleetCategory.Visible = false; ARoute.CssClass = "default-tab"; BRoute.CssClass = "default-tab"; GRoute.CssClass = "default-tab"; WRoute.CssClass = "default-tab"; PRoute.CssClass = "default-tab"; break; } }