private void editVehicle_Click(object sender, EventArgs e) { if (dataGridView1.DataSource == null) { return; } var vs = dataGridView1.SelectedRows[0].DataBoundItem as Vehical; VihecalType tp = new VihecalType(); if (typeof(Bus) == vs.GetType()) { tp.name = "Bus"; } else if (typeof(Vagon) == vs.GetType()) { tp.name = "Vagon"; } else if (typeof(Locomotiva) == vs.GetType()) { tp.name = "Voz"; } Vihecal fvs = new Vihecal(vs, tp); fvs.ShowDialog(); setvozila(); }
public Vihecal(MongoLayer.Models.Vehical vh = null, VihecalType type = null) { InitializeComponent(); comboBox1.Items.Add("ChoseType"); comboBox1.SelectedIndex = 0; comboBox1.Items.AddRange(types.ToArray()); panel1.Visible = false; panel2.Visible = false; panel3.Visible = false; if (vh != null) { vihecal = vh; this.type = type; textBox1.Text = vh.CurrentCond; if (type.name.Equals("Bus")) { panel1.Visible = true; // panel2.Visible = false; // panel3.Visible = false; panel2.Hide(); panel3.Hide(); comboBox1.SelectedIndex = 1; textBox2.Text = (vh as Bus).NumOfPassengers.ToString(); } else if (type.name.Equals("Vagon")) { panel1.Visible = true; // panel2.Visible = false; // panel3.Visible = false; panel2.Hide(); panel3.Hide(); comboBox1.SelectedIndex = 2; textBox2.Text = (vh as Vagon).NumOfPassengers.ToString(); } else if (type.name.Equals("Voz")) { // panel1.Visible = false; // panel2.Visible = false; panel3.Visible = true; panel2.Hide(); panel1.Hide(); comboBox1.SelectedIndex = 3; textBox4.Text = (vh as Locomotiva).MaximumPulingCapacity.ToString(); listBox1.Items.AddRange(VehicalModel.GetAllVagons(vh.Id).ToArray()); } comboBox1.Enabled = false; } listBox2.Items.AddRange(VehicalModel.GetAllVagons().ToArray()); }