private void AddGearbox(object sender, RoutedEventArgs e) { if (int.TryParse(GearboxGears.Text, out int Quantity) && decimal.TryParse(GearboxPrice.Text, out decimal Price)) { GearboxUI gearboxUI = new GearboxUI() { Name = GearboxName.Text, Price = Price, Quantity = Quantity, Producer = GearboxProducer.Text, Type = GearboxType.Text }; Methods.AddParts(gearboxUI); } }
public Gearbox ConvertTOGearbox(GearboxUI gearboxUI) { Gearbox gearbox = new Gearbox() { Id = gearboxUI.Id, Name = gearboxUI.Name, Price = gearboxUI.Price, Producer = gearboxUI.Producer, Quantity = gearboxUI.Quantity, Type = gearboxUI.Type }; return(gearbox); }
private void AddCar(object sender, RoutedEventArgs e) { decimal.TryParse(CarPrice.Text, out decimal price); string name = CarName.Text; if (CarEngine.SelectedIndex >= 0 && CarGearbox.SelectedIndex >= 0 && CarInterior.SelectedIndex >= 0 && CarExterior.SelectedIndex >= 0 && price >= 0) { EngineUI engineUI = CarEngine.SelectedItem as EngineUI; GearboxUI gearboxUI = CarGearbox.SelectedItem as GearboxUI; InteriorUI interiorUI = CarInterior.SelectedItem as InteriorUI; ExteriorUI exteriorUI = CarExterior.SelectedItem as ExteriorUI; CarUI carUI = new CarUI() { Engine = engineUI, Exterior = exteriorUI, Gearbox = gearboxUI, Interior = interiorUI, Name = name, Price = price, Status = "Not Sold" }; Methods.AddCar(carUI); } }
private void EndModifyGearbox(object sender, RoutedEventArgs e) { if (decimal.TryParse(GearboxPrice.Text, out decimal price) && (int.TryParse(GearboxGears.Text, out int gears)) ) { GearboxUI gearboxUI = new GearboxUI() { Name = GearboxName.Text, Price = price, Producer = GearboxProducer.Text, Quantity = gears, Type = GearboxType.Text, Id = id }; Methods.ModifyParts(gearboxUI); } }