private bool addLocomotiv() { Locomotiva bs = new Locomotiva(); bs.Type = (comboBox1.SelectedItem as VihecalType).name; bs.LastCheck = dateTimePicker1.Value; bs.CurrentCond = textBox1.Text; int psg; if (!int.TryParse(textBox4.Text, out psg)) { return(false); } bs.MaximumPulingCapacity = psg; var trs = TransportModel.GetTransport(bs.Type); bs.Transport = new MongoDB.Driver.MongoDBRef("Transport", trs.Id); var id = VehicalModel.AddVehical(bs); for (int i = 0; i < listBox1.Items.Count; i++) { VehicalModel.AddVagon(id, (listBox1.Items[i] as Vagon).Id); } return(true); }
private bool UpdateVihecal() { Vehical bs = vihecal; bs.Type = (comboBox1.SelectedItem as VihecalType).name; bs.LastCheck = dateTimePicker1.Value; bs.CurrentCond = textBox1.Text; if (type.name.Equals("Bus")) { int psg; if (!int.TryParse(textBox2.Text, out psg)) { return(false); } (bs as Bus).NumOfPassengers = psg; } else if (type.name.Equals("Vagon")) { int psg; if (!int.TryParse(textBox2.Text, out psg)) { return(false); } (bs as Vagon).NumOfPassengers = psg; } else if (type.name.Equals("Voz")) { int psg; if (!int.TryParse(textBox4.Text, out psg)) { return(false); } (bs as Locomotiva).MaximumPulingCapacity = psg; VehicalModel.RemoveVagons(vihecal.Id); for (int i = 0; i < listBox1.Items.Count; i++) { VehicalModel.AddVagon(vihecal.Id, (listBox1.Items[i] as Vagon).Id); } } return(true); }