Ejemplo n.º 1
0
        private void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult result = MessageBox.Show("Girilen veriler veri tabanına yazılacak, onaylıyor musunuz?", "My App", MessageBoxButton.YesNoCancel);

            switch (result)
            {
            case MessageBoxResult.Yes:

                double lat = Convert.ToDouble(txtBoxPlaceLatitude.Text);
                double lng = Convert.ToDouble(txtBoxPlaceLongitude.Text);

                NetTopologySuite.Geometries.Point point = new NetTopologySuite.Geometries.Point(lat, lng)
                {
                    SRID = 4326
                };
                Places place = new Places()
                {
                    Type     = txtBoxPlaceType.Text,
                    Name     = txtBoxPlaceName.Text,
                    Tel      = txtPhone.Text,
                    Address  = txtAddress.Text,
                    Location = point,
                };

                using (mycityDbContext context = new mycityDbContext())
                {
                    context.Add(place);
                    context.SaveChanges();
                }


                MessageBox.Show("Veriler başarıyla aktarıldı...");
                txtBoxPlaceType.Text      = "";
                txtBoxPlaceName.Text      = "";
                txtBoxPlaceLatitude.Text  = "";
                txtBoxPlaceLongitude.Text = "";
                myMap.Mode = new AerialMode(true);

                break;

            case MessageBoxResult.No:
                // MessageBox.Show("Oh well, too bad!", "My App");
                break;

            case MessageBoxResult.Cancel:
                txtBoxPlaceType.Text      = "";
                txtBoxPlaceName.Text      = "";
                txtBoxPlaceLatitude.Text  = "";
                txtBoxPlaceLongitude.Text = "";
                myMap.Mode = new AerialMode(true);
                break;
            }
        }
Ejemplo n.º 2
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            Places placeRow = dataGridPlace.SelectedItem as Places;

            using (mycityDbContext context = new mycityDbContext())
            {
                var place = (from p in context.Places where p.PlacesId == placeRow.PlacesId select p).Single();
                context.Places.Remove(place);
                context.SaveChanges();
                MessageBox.Show("Satır silinmiştir.");
                LoadGrid();
            }
        }