private void DriverBtn_Click(object sender, RoutedEventArgs e) { tempDriver = (DriverC)driverList.SelectedItem; shift.driver = tempDriver; try { if (shift.driver.user_id != "") { MessageBoxResult result = MessageBox.Show("Driver: " + shift.driver.first_name + " " + shift.driver.second_name + " Selected" + ", click yes to continue", "Confirm Selection", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { shift.driverTxt.Text = "Driver Selected"; //shows bus information //shows driver information try { shift.driverTxtBlk.Text = "\n\n User ID: " + shift.driver.user_id + "\n Name: " + shift.driver.first_name + " " + shift.driver.second_name + "\n" + " Driver Type: " + shift.driver.driver_type + "\n" + " CPC Type: " + shift.driver.cpc_type; } catch (Exception ex) { ex.ToString(); } Close(); } } } catch (Exception ex) { MessageBox.Show("To continue, a driver must be selected", "Selection Error"); } }
private void JobInfoDataGrid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { tempJob = (Job)jobInfoDataGrid.SelectedItem; try { if (tempJob.job_id != "") { MessageBoxResult result = MessageBox.Show("Driver: " + tempJob.driver_id + " " + tempJob.bus_reg + " Selected" + ", click yes to continue", "Confirm Selection", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { //creates bus object to display on screen RestClient client = new RestClient(); client.endPoint = "http://localhost:8080/AppServer_war_exploded/logic/bus/" + tempJob.bus_reg; responseBus = client.makeRequest(); busT = JsonConvert.DeserializeObject <Bus>(responseBus.ToString()); busTxtBlk.Text = "\n\n Registration: " + busT.bus_reg.ToUpper() + "\n" + " Model: " + busT.model + " \n" + " Capacity: " + busT.bus_capacity + "\n Type: " + busT.bus_type; //creates driver object to display on screen client.endPoint = "http://localhost:8080/AppServer_war_exploded/logic/get/driver/" + tempJob.driver_id; responseDriver = client.makeRequest(); driverT = JsonConvert.DeserializeObject <DriverC>(responseDriver.ToString()); driverTxtBlk.Text = "\n\n User ID: " + driverT.user_id + "\n Name: " + driverT.first_name + " " + driverT.second_name + "\n" + " Driver Type: " + driverT.driver_type + "\n" + " CPC Type: " + driverT.cpc_type; /////////////////////////////////////////////////////////////// string[] startWords = tempJob.start_location.Split(','); string[] endWords = tempJob.end_location.Split(','); var formattedStartAddress = new System.Text.StringBuilder(); var formattedEndAddress = new System.Text.StringBuilder(); //converts start formatted address into atomic elements for (int i = 1; i < startWords.Length; i++) { formattedStartAddress.AppendLine(startWords[i]); } formattedStartAddress.AppendLine(startWords[0]); //converts end formatted address into atomic elements for (int i = 1; i < endWords.Length; i++) { formattedEndAddress.AppendLine(endWords[i]); } formattedEndAddress.AppendLine(endWords[0]); startTxtBlk.Text = "\n\n\n\n\n\n" + formattedStartAddress.ToString(); endTxtBlk.Text = "\n\n\n\n\n\n" + formattedEndAddress.ToString(); //summaryTxtBlk.Text = "\n\n\n\nDistance: " + mDistance + "miles " + " Estimated Duration: " + time; busTxt.Text = "Bus Selected"; driverTxt.Text = "Driver Selected"; routeTxt.Text = "Driver Selected"; } } } catch (Exception ex) { MessageBox.Show("To continue, a job must be selected", "Selection Error"); } }
private void DriverList_Loaded(object sender, RoutedEventArgs e) { RestClient restClient = new RestClient(); restClient.endPoint = "http://localhost:8080/AppServer_war_exploded/logic/all/drivers"; response = restClient.makeRequest(); if (window.editTxt.Text == "Save") { try { JArray a = JArray.Parse(response); foreach (var obj in a) { DriverC driver = JsonConvert.DeserializeObject <DriverC>(obj.ToString()); if (driver.cpc_type == "Analogue" && shift.busT.tacho == "Digital") { } else { drivers.Add(driver); } } driverList.ItemsSource = drivers; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } else { try { JArray a = JArray.Parse(response); foreach (var obj in a) { DriverC driver = JsonConvert.DeserializeObject <DriverC>(obj.ToString()); if (shift.busTachoType == "Digital") { if (driver.cpc_type == "Analogue") { } else { drivers.Add(driver); } } else { drivers.Add(driver); } } driverList.ItemsSource = drivers; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } }