Exemple #1
0
 // Insert the new contact in the Contacts table.
 public static void Insert(Andmed andmed)
 {
     using (var dbConn = new SQLiteConnection(MainPage.DB_PATH))
     {
         dbConn.RunInTransaction(() =>
         {
             dbConn.Insert(andmed);
         });
     }
 }
Exemple #2
0
        public Page3()
        {
            this.InitializeComponent();

            var item = DatabaseHelperClass.ReadContacts();

            for (int i = 0; i < item.Count(); i++)
            {
                Andmed obj = new Andmed();
                obj.Id           = item.ElementAt(i).Id;
                obj.Hor          = item.ElementAt(i).Hor;
                obj.Ver          = item.ElementAt(i).Ver;
                obj.Nimi         = item.ElementAt(i).Nimi;
                obj.Text         = item.ElementAt(i).Text;
                obj.CreationDate = item.ElementAt(i).CreationDate;
                list.Items.Add(obj);
            }
            Windows.Phone.UI.Input.HardwareButtons.BackPressed += HardwareButtons_BackPressed;
        }
Exemple #3
0
 //Update existing conatct
 public static void UpdateContact(Andmed andmed)
 {
     using (var dbConn = new SQLiteConnection(MainPage.DB_PATH))
     {
         var existingandmed = dbConn.Query <Andmed>("select * from Contacts where Id =" + andmed.Id).FirstOrDefault();
         if (existingandmed != null)
         {
             existingandmed.Nimi         = andmed.Nimi;
             existingandmed.Ver          = andmed.Ver;
             existingandmed.Ver          = andmed.Hor;
             existingandmed.Text         = andmed.Text;
             existingandmed.CreationDate = andmed.CreationDate;
             dbConn.RunInTransaction(() =>
             {
                 dbConn.Update(existingandmed);
             });
         }
     }
 }
Exemple #4
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            Geopoint myPoint;

            if ((e.Parameter as Geopoint) != null)
            {
                System.Diagnostics.Debug.WriteLine("This is a geopoint");
                Save.Content = "Add";
                //isViewing = true;
                mapNote = new Andmed();
                myPoint = (e.Parameter as Geopoint);
            }
            else if (e.Parameter == null)
            {
                System.Diagnostics.Debug.WriteLine((e.Parameter as Geopoint) != null);
                //isViewing = false;

                var locator = new Geolocator();
                locator.DesiredAccuracyInMeters = 50;

                var position = await locator.GetGeopositionAsync();

                myPoint = position.Coordinate.Point;
            }

            else
            {
                Save.Content = "Remove";
                //isViewing = true;
                mapNote           = (Andmed)e.Parameter;
                titleTextBox.Text = mapNote.Nimi;
                noteTextBox.Text  = mapNote.Text;
                var myPosition = new Windows.Devices.Geolocation.BasicGeoposition();

                myPosition.Latitude  = mapNote.Ver;
                myPosition.Longitude = mapNote.Hor;

                myPoint = new Geopoint(myPosition);
            }
            await MyMap.TrySetViewAsync(myPoint, 16D);
        }
Exemple #5
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            if ((string)Save.Content == "Delete")
            {
                DatabaseHelperClass.DeleteContact(mapNote.Id);
                Frame.Navigate(typeof(MainPage));
            }
            else
            {
                Andmed newMapNote = new Andmed();
                newMapNote.Nimi         = titleTextBox.Text;
                newMapNote.Text         = noteTextBox.Text;
                newMapNote.CreationDate = DateTime.Now;
                newMapNote.Ver          = MyMap.Center.Position.Latitude;
                newMapNote.Hor          = MyMap.Center.Position.Longitude;

                DatabaseHelperClass.Insert(newMapNote);
                MessageDialog msgbox = new MessageDialog("Note added");

                await msgbox.ShowAsync();

                Frame.Navigate(typeof(MainPage));
            }
        }