Esempio n. 1
0
        public DriverForm(string FIO, string typeDriver, Car car) : this(false)
        {
            driver = Driver.Driver.CreateDriver(FIO, typeDriver.Equals("True"), car);
            checkBoxIsIntruder.Checked   = typeDriver.Equals("True");
            comboBoxIDAuto.SelectedIndex = comboBoxIDAuto.FindString(car.TypeName);

            textBoxFIO.Text = FIO;

            ID = FIO;
        }
Esempio n. 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(tbTypeDriver.Text))
            {
                MessageBox.Show("Поле тип водителя не задан !");
            }
            else
            {
                double d;
                if (double.TryParse(cbIDAuto.Text, out d))
                {
                    //нашел машину для водителя
                    var findcar = Car.ListAuto.FirstOrDefault(l => l.ElementAt(0).ToString() == cbIDAuto.SelectedItem.ToString());


                    var findfuel = Fuel.ListFuel.FirstOrDefault(l => l.ElementAt(0).ToString() == findcar[2].ToString());

                    Fuel ffuel = new Fuel(int.Parse(findfuel[0].ToString()), findfuel[1].ToString(), double.Parse(findfuel[2].ToString()));

                    Car fcar = new Car(int.Parse(findcar[0].ToString()), findcar[1].ToString(), ffuel, double.Parse(findcar[3].ToString()));

                    if (tbTypeDriver.Text == "Нет")
                    {
                        typed = false;
                    }
                    else
                    {
                        typed = true;
                    }
                    if (driver == null)
                    {
                        driver = new Driver.Driver(typed, fcar);
                    }
                    else
                    {
                        driver.IsViolateTL = typed;
                        driver.Car         = fcar;
                    }
                    if (addOrEdit)
                    {
                        Add();
                    }
                    else
                    {
                        Edit();
                    }
                }
                else
                {
                    MessageBox.Show("Не корректно задан id машины !");
                }
            }
        }
Esempio n. 3
0
 public DriverForm(int id, bool typeDriver, Car car) : this(false)
 {
     if (typeDriver == false)
     {
         type = "Нет";
     }
     else
     {
         type = "Да";
     }
     driver = new Driver.Driver(id, typeDriver, car);
     int index = cbIDAuto.FindString(car.ID.ToString());
     cbIDAuto.SelectedIndex = index;
     tbTypeDriver.Text      = type;
 }
Esempio n. 4
0
        private void Accept()
        {
            textBoxFIO.BackColor = Color.White;

            string name  = textBoxFIO.Text;
            string model = string.Empty;

            if (string.IsNullOrEmpty(name) || string.IsNullOrWhiteSpace(name))
            {
                MessageBox.Show("Введите ФИО!");
                textBoxFIO.BackColor = Color.Red;
            }
            else if (comboBoxIDAuto.SelectedItem == null)
            {
                MessageBox.Show("Выберите модель!");
            }
            else
            {
                model = comboBoxIDAuto.SelectedItem.ToString();

                var findcar = Car.ListAuto.FirstOrDefault(l => l.ElementAt(0).ToString().Equals(model));

                var findfuel = Fuel.ListFuel.FirstOrDefault(l => l.ElementAt(0).Equals(findcar[1].ToString()));

                Fuel fuel = Fuel.CreateFuel(findfuel[0].ToString(), double.Parse(findfuel[1].ToString()));

                Car fcar = Car.CreateCar(findcar[0].ToString(), fuel, double.Parse(findcar[2].ToString()), double.Parse(findcar[3].ToString()));

                if (driver == null)
                {
                    driver = new Driver.Driver(name, checkBoxIsIntruder.Checked, fcar);
                }
                else
                {
                    driver.IsViolateTL = checkBoxIsIntruder.Checked;
                    driver.Car         = fcar;
                }

                if (addOrEdit)
                {
                    Add();
                }
                else
                {
                    Edit();
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Составление маршрута
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ПараметрыМаршрутаToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OptionsRouteForm optionsRouteForm = new OptionsRouteForm();

            optionsRouteForm.ShowDialog();

            if (optionsRouteForm.DialogResult == DialogResult.OK)
            {
                Criterial criterial = optionsRouteForm.Criterial;
                driver = optionsRouteForm.Drive;
                optionsRouteForm.Close();


                Map.Way = new List <Vertex>();
                foreach (var item in Map.edges.List)
                {
                    item.IsInWay = false;
                }
                new Route().FindMinLengthWay(Map.vertexes, Map.edges, criterial, driver);
                MakeMap.ViewPort.StatusLabel.Text     = "Маршрут построен...";
                ToolStripMenuItem_StaticView.Enabled  = true;
                ToolStripMenuItem_DynamicView.Enabled = true;
            }
        }
Esempio n. 6
0
        private void OkRouteButton_Click(object sender, System.EventArgs e)
        {
            if (driverComboBox.SelectedItem == null)
            {
                MessageBox.Show("Выберите водителя!");
            }
            else if (critSearchComboBox.SelectedItem == null)
            {
                MessageBox.Show("Выберите критерий поиска!");
            }
            else
            {
                System.Collections.Generic.List <object> driver = Driver.Driver.ListDriver.First(dv => dv[0].ToString().Equals(driverComboBox.SelectedItem.ToString()));


                switch (critSearchComboBox.SelectedItem.ToString())
                {
                case "Время":
                {
                    Criterial = Main.Criterial.Time;

                    System.Collections.Generic.List <object> cars  = Driver.Car.ListAuto.First(car => car[0].ToString().Equals(driver[2].ToString()));
                    System.Collections.Generic.List <object> fuels = Driver.Fuel.ListFuel.First(fuel => fuel[0].ToString().Equals(cars[1].ToString()));

                    Driver.Fuel curFuel = Driver.Fuel.CreateFuel(fuels[0].ToString(), double.Parse(fuels[1].ToString()));
                    Driver.Car  curCar  = Driver.Car.CreateCar(cars[0].ToString(), curFuel, double.Parse(cars[2].ToString()), double.Parse(cars[3].ToString()));

                    Drive = Driver.Driver.CreateDriver(driver[0].ToString(), bool.Parse(driver[1].ToString()), curCar);
                    break;
                }

                case "Длина":
                {
                    System.Collections.Generic.List <object> cars  = Driver.Car.ListAuto.First(car => car[0].ToString().Equals(driver[2].ToString()));
                    System.Collections.Generic.List <object> fuels = Driver.Fuel.ListFuel.First(fuel => fuel[0].ToString().Equals(cars[1].ToString()));
                    Criterial = Main.Criterial.Length;
                    Driver.Fuel curFuel = Driver.Fuel.CreateFuel(fuels[0].ToString(), double.Parse(fuels[1].ToString()));
                    Driver.Car  curCar  = Driver.Car.CreateCar(cars[0].ToString(), curFuel, double.Parse(cars[2].ToString()), double.Parse(cars[3].ToString()));
                    Drive = Driver.Driver.CreateDriver(driver[0].ToString(), bool.Parse(driver[1].ToString()), curCar);

                    break;
                }

                case "Стоимость":
                {
                    Criterial = Main.Criterial.Price;

                    System.Collections.Generic.List <object> cars  = Driver.Car.ListAuto.First(car => car[0].ToString().Equals(driver[2].ToString()));
                    System.Collections.Generic.List <object> fuels = Driver.Fuel.ListFuel.First(fuel => fuel[0].ToString().Equals(cars[1].ToString()));

                    Driver.Fuel curFuel = Driver.Fuel.CreateFuel(fuels[0].ToString(), double.Parse(fuels[1].ToString()));
                    Driver.Car  curCar  = Driver.Car.CreateCar(cars[0].ToString(), curFuel, double.Parse(cars[2].ToString()), double.Parse(cars[3].ToString()));
                    Drive = Driver.Driver.CreateDriver(driver[0].ToString(), bool.Parse(driver[1].ToString()), curCar);

                    break;
                }
                }

                this.DialogResult = DialogResult.OK;

                Hide();
            }
        }