Пример #1
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            DateTime start = DateTime.Now;
            int rec;
            Random rnd = new Random();
            string strInsert = " Insert into Customer (Name,Place,Lat, Long, Date, Hour, Status, Priority,Desc) values (@Name,@Place,@Lat,@Long,@Date,@Hour,@Status,@Priority,@Desc)";

            for (int i = 0; i < 5; i++)
            {
                Customer tst = new Customer
                {
                    Name = "Name " + i,
                    Place = Name + "@" + "aaa.com",
                    Lat = Name + "@" + "aaa.com",
                    Long = Name + "@" + "aaa.com",
                    Date = Name + "@" + "aaa.com",
                    Hour = Name + "@" + "aaa.com",
                    Status = Name + "@" + "aaa.com",
                    Priority = Name + "@" + "aaa.com",
                    Desc = "Desc for " + i
                };
                rec = (Application.Current as App).db.Insert < Customer>(tst,strInsert);
            }
            System.Diagnostics.Debug.WriteLine("\nInserted 5 " + " rows\r\nGenerated in " + (DateTime.Now - start).TotalSeconds);
        }
Пример #2
0
        private void bAdd_Click(object sender, EventArgs e)
        {
            DateTime start = DateTime.Now;
            int rec;
            App thisApp = App.Current as App;
            Random rnd = new Random();
            string strInsert = " Insert into Customer (Name,Place,Lat, Long, Date, Hour, Status, Priority,Desc) values (@Name,@Place,@Lat,@Long,@Date,@Hour,@Status,@Priority,@Desc)";
            thisApp.ok_set_coord = false;
            string spriority = "", splace = "", sdesc = "", status = "off";
            if (sPriority.Value.ToString() == "1") spriority = "low";
            if (sPriority.Value.ToString() == "2") spriority = "medium";
            if (sPriority.Value.ToString() == "3") spriority = "high";
            if (tbPlace.Text == "") splace = "Place not set yet.";
            else splace = tbPlace.Text;
            if (tbDescriere.Text == "") sdesc = "Description not added yet.";
            else sdesc = tbDescriere.Text;
            if (switch1.IsChecked == true) status = "Yes";
            else status = "No";
            Customer tst = new Customer
            {
                Name = tbTaskName.Text + " ",
                Place = splace + " ",

                Lat = thisApp.Lat.ToString() + " ",
                Long = thisApp.Long.ToString() + " ",
                Date = datepicker1.Value.ToString() + " ",
                Hour = timepicker.Value.ToString() + " ",
                Status = status,
                Priority = spriority + " ",
                Desc = sdesc + " "
            };
            if (tbTaskName.Text == "") MessageBox.Show("Your task must have a name.");
            else
            {
                rec = (Application.Current as App).db.Insert<Customer>(tst, strInsert);

                System.Diagnostics.Debug.WriteLine("\nInserted 5 " + " rows\r\nGenerated in " + (DateTime.Now - start).TotalSeconds);
                if (switch1.IsChecked == true) NavigationService.Navigate(new Uri("/AddNotification.xaml", UriKind.RelativeOrAbsolute));
                NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.RelativeOrAbsolute));
            }
        }
Пример #3
0
        private void Save(object sender, EventArgs e)
        {
            string place, name, lat, Long,date, hour, status,pri, desc;
            place = tbWhere.Text;
            name = textBlock0.Text;
            if (thisApp.Lat != -1000 && thisApp.Long != -1000)
            {
                lat = thisApp.Lat.ToString();
                Long = thisApp.Long.ToString();

            }
            else
            {
                lat=Long="-1000";
            }
            date = datepicker1.Value.ToString();
            hour = timepicker.Value.ToString();
            status = (switch1.IsChecked == true) ? "Yes" : "No";
            pri = slider1.Value.ToString();
            desc = tBDescription.Text;
            
            DateTime start = DateTime.Now;
            string strDel = " Delete from Customer where ID=" + thisApp.id.ToString();
            (Application.Current as App).db.Delete<Customer>(strDel);

            System.Diagnostics.Debug.WriteLine("\nDelete last " + " record\r\n in " + (DateTime.Now - start).TotalSeconds);
        //    rec = (Application.Current as App).db.Insert<Customer>(tst, strInsert);
            string strInsert = " Insert into Customer (Name,Place,Lat, Long, Date, Hour, Status, Priority,Desc) values (@Name,@Place,@Lat,@Long,@Date,@Hour,@Status,@Priority,@Desc)";

            int rec;
            Customer tst = new Customer
            {
                Name = name,
                Place = place,
                Lat = lat,
                Long = Long,
                Date = date,
                Hour = hour,
                Status = status,
                Priority = pri,
                Desc = desc
            };
            
            rec = (Application.Current as App).db.Insert<Customer>(tst, strInsert);

            System.Diagnostics.Debug.WriteLine("\nInserted 5 " + " rows\r\nGenerated in " + (DateTime.Now - start).TotalSeconds);
            if (switch1.IsChecked == true) NavigationService.Navigate(new Uri("/AddNotification.xaml", UriKind.RelativeOrAbsolute));
            else  NavigationService.GoBack();
        }