private void Btn_checkout_Click(object sender, RoutedEventArgs e) { if (Lbx_Cars.SelectedItem == null) { MessageBox.Show("Please select a Car first."); } else { CarStorage car = Lbx_Cars.SelectedItem as CarStorage; var toDelete = car as CarStorage; var res = MessageBox.Show($"Are you sure to Check-Out {toDelete.CarModel}?" + "\n" + $"Price to Pay: {toDelete.price}€", "Error", MessageBoxButton.OKCancel, MessageBoxImage.Warning); if (res == MessageBoxResult.OK) { App._cars.Remove(toDelete); Customer cust = Lbx_Customer.SelectedItem as Customer; int idcust = cust.CustId; var cars = (from c in App._cars where c.CustId == cust.CustId select c).ToArray(); Lbx_Cars.ItemsSource = null; Lbx_Cars.ItemsSource = cars; } } }
private void Button_AddCar(object sender, RoutedEventArgs e) { if (Lbx_Customer.SelectedItem == null) { MessageBox.Show("Please select a customer first."); } else { Customer cust = Lbx_Customer.SelectedItem as Customer; int idcust = cust.CustId; CarStorage car = new CarStorage { CarModel = "Edit...", VehicleNumber = "Edit...", TicketId = Math.Abs(Guid.NewGuid().GetHashCode()), CustId = idcust, numberofTires = 4, storaeDate = DateTime.Today, storage = "Edit..." }; App._cars.Add(car); var cars = (from c in App._cars where c.CustId == cust.CustId select c).ToArray(); Lbx_Cars.ItemsSource = null; Lbx_Cars.ItemsSource = cars; Lbx_Cars.SelectedItem = car; Lbx_Cars.ScrollIntoView(car); } }
private void Button_ReplaceTire(object sender, RoutedEventArgs e) { //HistoryRecord history = Lbx_Cars.SelectedItem as HistoryRecord; CarStorage chistory = Lbx_Cars.SelectedItem as CarStorage; if (Lbx_Cars.SelectedItem == null) { MessageBox.Show("Please select a Car first."); } else { CarStorage cstore = Lbx_Cars.SelectedItem as CarStorage; cstore.price = cstore.price + 15; Tbx_Price.Text = cstore.price.ToString(); HistoryRecord history = new HistoryRecord { TicketId = chistory.TicketId, CustId = chistory.CustId, CarModel = chistory.CarModel, tireCategory = chistory.tireCategory, VehicleNumber = chistory.VehicleNumber, numberofTires = 4, storageDate = DateTime.Today }; App._history.Add(history); MessageBox.Show("Replacement Successful"); } }