Пример #1
0
        private void btnCitySave_Click(object sender, EventArgs e)
        {
            if (isValid.isCityNameValid(tbEditCity.Text))
            {
                City city = citiesDataLink.Retrieve(cityToEdit.CityID);
                city.Name = tbEditCity.Text;
                citiesDataLink.Update(city);

                /*IEnumerable<Route> routes = routesDataLink.RetrieveAll();
                 * Route routeToUpdate;
                 *
                 * foreach (Route route in routes)
                 * {
                 *  if (route.Start == cityToEdit.Name)
                 *  {
                 *      routeToUpdate = routesDataLink.Retrieve(route.RouteID);
                 *      routeToUpdate.Start = city.Name;
                 *      routesDataLink.Update(routeToUpdate);
                 *  }
                 *  if (route.Finish == cityToEdit.Name)
                 *  {
                 *      routeToUpdate = routesDataLink.Retrieve(route.RouteID);
                 *      routeToUpdate.Finish = city.Name;
                 *      routesDataLink.Update(routeToUpdate);
                 *  }
                 * }*/

                this.Hide();
            }
        }
Пример #2
0
        private void btnAddCity_Click(object sender, EventArgs e)//__________________________Add____________________________
        {
            if (isValid.isCityNameValid(tbCityName.Text))
            {
                if (citiesDataLink.Exists(tbCityName.Text))
                {
                    MessageBox.Show("Город с таким названием уже введен");
                }
                else
                {
                    City city = new City()
                    {
                        Name = tbCityName.Text
                    };

                    citiesDataLink.Add(city);

                    fillCityTable();

                    tbCityName.Text = "";
                }
            }
        }