Example #1
0
 /// <summary>
 /// Получение точек
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public void btn_GetNewPoints_Click(object sender, EventArgs e)
 {
     presenter = new MapPresenter(this);
     presenter.GetDataFromForm();
     presenter.ShowMap();
     UpdateStat();
 }
Example #2
0
        /// <summary>
        /// Загрузить последний сценарий
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void загрузитьToolStripMenuItem_Click(object sender, EventArgs e)
        {
            presenter = new MapPresenter(this);
            SqlConnectionStringBuilder bldr = CreateConnection();

            using (SqlConnection conn = new SqlConnection(bldr.ConnectionString))
            {
                conn.Open();

                SqlCommand cmdGames = new SqlCommand();
                cmdGames.Connection  = conn;
                cmdGames.CommandText = "Select Iterations, CurIteration, QCargo, QTruck FROM Games";

                using (DbDataReader reader = cmdGames.ExecuteReader())
                {
                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            presenter.Map.NumIterations = Convert.ToInt32(reader.GetValue(0));
                            presenter.Map.NumCargoes    = Convert.ToInt32(reader.GetValue(2));
                            presenter.Map.NumTrucks     = Convert.ToInt32(reader.GetValue(3));
                            presenter.Map.CurIteration  = Convert.ToInt32(reader.GetValue(1));
                        }
                    }
                }

                SqlCommand cmdTrucks = new SqlCommand();
                cmdTrucks.Connection  = conn;
                cmdTrucks.CommandText = "Select TypeName, Nametruck, PositionX, PositionY, Status, FuelBalance, StepOfRoute FROM Trucks";

                using (DbDataReader reader = cmdTrucks.ExecuteReader())
                {
                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            Coordinate coord = new Coordinate();
                            coord.X = Convert.ToInt32(reader.GetValue(2));
                            coord.Y = Convert.ToInt32(reader.GetValue(3));

                            ITruck truck;

                            if ((Convert.ToString(reader.GetValue(0))) == "Truck     ")
                            {
                                truck = new Truck(coord);
                            }
                            else
                            {
                                truck = new User(coord);
                            }

                            ((Point)truck).Name = Convert.ToString(reader.GetValue(1));
                            truck.Status        = Convert.ToBoolean(reader.GetValue(4));
                            truck.Fuelbalance   = Convert.ToInt32(reader.GetValue(5));
                            truck.StepOfRoute   = Convert.ToInt32(reader.GetValue(6));
                            presenter.Map.Points.Add(truck);
                        }
                    }
                }

                SqlCommand cmdCargoes = new SqlCommand();
                cmdCargoes.Connection  = conn;
                cmdCargoes.CommandText = "Select NameCargo, PositionX, PositionY, Status FROM Cargoes";

                using (DbDataReader reader = cmdCargoes.ExecuteReader())
                {
                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            Coordinate coord = new Coordinate();
                            coord.X = Convert.ToInt32(reader.GetValue(1));
                            coord.Y = Convert.ToInt32(reader.GetValue(2));

                            Cargo cargo = new Cargo(coord);

                            ((Point)cargo).Name = Convert.ToString(reader.GetValue(0));
                            cargo.StatusCargo   = Convert.ToBoolean(reader.GetValue(3));

                            if (cargo.StatusCargo == false)
                            {
                                cargo.Pen       = new Pen(Color.RosyBrown);
                                cargo.TextColor = Brushes.RosyBrown;
                            }
                            presenter.Map.Points.Add(cargo);
                        }
                    }
                }
            }
            presenter.ShowMap();
        }
Example #3
0
 /// <summary>
 /// Обновление поля
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public void UpdateFields(object sender, EventArgs e)
 {
     presenter.ShowMap();
     UpdateStat();
 }