예제 #1
0
 private async Task AccountStore(ObservableCollection <AccountsModel> account)
 {
     try
     {
         var dbpath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "data.db3");
         using (var db = new SQLite.SQLiteConnection(dbpath))
         {
             foreach (AccountsModel accountM in Accounts)
             {
                 var accountInDB = db.Find <AccountsModel>(accountM.Accountid);
                 if (accountInDB != null)
                 {
                     db.Delete(accountM);
                 }
                 db.Insert(accountM);
             }
             db.Commit();
             db.Dispose();
             db.Close();
         }
     }
     catch (SQLiteException)
     {
     }
 }
예제 #2
0
        async Task RunReadTest()
        {
            await Task.Factory.StartNew(() =>
            {
                using (var db = new SQLiteConnection(DatabasePath))
                {
                   db.RunInTransaction(async () => {
                        var person1 = db.Find<Person>(f => f.FullName.EndsWith("8"));
                        var person2 = db.Find<Person>(f => f.FullName.EndsWith("3"));

                        var message = person1 != null && person2 != null
                                           ? "Completed!"
                                           : "Did not find both people!";

                        await dispatcher.RunIdleAsync(a => { ReadResult = message; });
                    });
                }
            });
        }
        private async void ButtonEdit_ClickM(object sender, EventArgs e)
        {
            using (var con = new SQLite.SQLiteConnection(App.FilePath))
            {
                Match = (MatchData)MatchViews.SelectedItem;

                var matchToEdit = con.Find <MatchData>(Match.MatchId);

                await Navigation.PushAsync(new MatchEditEntry(matchToEdit));
            }
        }
예제 #4
0
        private void ButtonDelete_Click(object sender, EventArgs e)
        {
            if (DeleteButton.Text == "Delete")
            {
                DeleteButton.Text = "Confirm?";

                DateContent.BackgroundColor      = Color.Red;
                RatingContent.BackgroundColor    = Color.Red;
                GoalsContent.BackgroundColor     = Color.Red;
                AssistsContent.BackgroundColor   = Color.Red;
                TacklesContent.BackgroundColor   = Color.Red;
                DribblesContent.BackgroundColor  = Color.Red;
                KeyPassesContent.BackgroundColor = Color.Red;
                StaminaContent.BackgroundColor   = Color.Red;
            }

            else
            {
                using (var con = new SQLite.SQLiteConnection(App.FilePath))
                {
                    training = (TrainingData)TrainingViews.SelectedItem;

                    var trainingToDelete = con.Find <TrainingData>(training.TrainingId);

                    con.Delete <TrainingData>(trainingToDelete.TrainingId);

                    TrainingViews.ItemsSource = null;

                    sessions = con.Table <TrainingData>().ToList();

                    TrainingViews.ItemsSource = sessions;
                }
                DeleteButton.Text = "Delete";

                DateContent.BackgroundColor      = Color.Black;
                RatingContent.BackgroundColor    = Color.Black;
                GoalsContent.BackgroundColor     = Color.Black;
                AssistsContent.BackgroundColor   = Color.Black;
                TacklesContent.BackgroundColor   = Color.Black;
                DribblesContent.BackgroundColor  = Color.Black;
                KeyPassesContent.BackgroundColor = Color.Black;
                StaminaContent.BackgroundColor   = Color.Black;


                DateContent.Text      = " ";
                RatingContent.Text    = " ";
                GoalsContent.Text     = " ";
                AssistsContent.Text   = " ";
                TacklesContent.Text   = " ";
                DribblesContent.Text  = " ";
                KeyPassesContent.Text = " ";
                StaminaContent.Text   = " ";
            }
        }
예제 #5
0
        private void BtnSerch_Clicked(object sender, EventArgs e)
        {
            List <TUser> Users   = new List <TUser>();
            var          id      = int.Parse(txId.Text);
            string       strPath = GetDbPath();

            using (var con = new SQLite.SQLiteConnection(strPath))
            {
                Users.Add(con.Find <TUser>(id));
                UserList.ItemsSource = Users;
            }
        }
예제 #6
0
        private async void ButtonEdit_Click(object sender, EventArgs e)
        {
            using (var con = new SQLite.SQLiteConnection(App.FilePath))
            {
                training = (TrainingData)TrainingViews.SelectedItem;

                var trainingToEdit = con.Find <TrainingData>(training.TrainingId);


                await Navigation.PushAsync(new TrainingEditPage(trainingToEdit));
            }
        }
예제 #7
0
		public static CourseSchedule FindCourseSchedule (decimal classId)
		{
			CheckAndCreateDatabase ();
			string path = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Personal), "CourseSchedule.sqlite");

			using (SQLiteConnection db = new SQLiteConnection (path)) {				
				// create the tables
				var classSchedule = db.Find<CourseSchedule> (c => c.ClassId == classId);

				// close the connection
				db.Close ();

				return classSchedule;
			}
		}
 public static void UpdateDeck(DeckViewModel deck)
 {
     using (var database = new SQLiteConnection(databasePath))
     {
         var _deck = database.Find<Deck>(d1 => d1.Id.ToString() == deck.UniqueId);
         if (_deck != null)
         {
             _deck.CategoryId = new Guid(deck.Category.UniqueId);
             _deck.Title = deck.Title;
             _deck.Author = deck.Author;
             _deck.Subject = deck.Subject;
             _deck.Description = deck.Description ;
             _deck.ImagePath = deck.ImagePath;
             database.Update(deck);
         }
     }
 }
 public static void UpdateCategory(CategoryViewModel category)
 {
     using (var database = new SQLiteConnection(databasePath))
     {
         var _category = database.Find<Category>(c1 => c1.Id.ToString() == category.UniqueId);
         if (_category != null)
         {
             _category.Name = category.Name;
             database.Update(_category);
         }
     }
 }
예제 #10
0
 public static void UpdateCard(CardsViewModel card)
 {
     using (var database = new SQLiteConnection(databasePath))
     {
         var _card = database.Find<Card>(c1 => c1.Id.ToString() == card.UniqueId);
         if (_card != null)
         {
             _card.FrontContent = card.FrontContent;
             _card.BackContent = card.BackContent;
             database.Update(_card);
         }
     }
 }
예제 #11
0
 public static void DeleteDeck(DeckViewModel deck)
 {
     using (var database = new SQLiteConnection(databasePath))
     {
         var _deck = database.Find<Deck>(d1 => d1.Id.ToString() == deck.UniqueId);
         database.Delete(_deck);
     }
 }
예제 #12
0
 public static void DeleteCategory(CategoryViewModel category)
 {
     using (var database = new SQLiteConnection(databasePath))
     {
         var _category = database.Find<Category>(c1 => c1.Id.ToString() == category.UniqueId);
         database.Delete(category);
     }
 }
예제 #13
0
 public static void DeleteCard(CardsViewModel card)
 {
     using (var database = new SQLiteConnection(databasePath))
     {
         var _card = database.Find<Card>(c1 => c1.Id.ToString() == card.UniqueId);
         database.Delete(_card);
     }
 }
예제 #14
0
 static public AlertCategory getAlertCategory(string category)
 {
     return(db.Find <AlertCategory>(category));
 }
예제 #15
0
        public MainWindow(string dbpath)
        {
            db_ = new SQLiteConnection(dbpath);
            db_.CreateTable<Task>();
            db_.CreateTable<ProgSettings>();
            tasks_ = new ObservableCollection<Task>(db_.Table<Task>().OrderBy(t => t.Order));
            settings_ = db_.Find<ProgSettings>(1);

            minimise_ = new MinimizeToTray(this, settings_.BallonShown);

            settings_.Plugins = new ObservableCollection<Plugin>(new Plugin[] { new PluginCore(settings_), new PluginWords(db_) });

            if (settings_ == null)
                settings_ = new ProgSettings(db_);
            else
                settings_.DB = db_;
            foreach (Task newItem in tasks_)
            {
                newItem.PropertyChanged += this.OnItemPropertyChanged;
            }

            InitializeComponent();
            List_Tasks.ItemsSource = tasks_;
            Text_Add_Item.Focus();

            workArc_.Right = true;
            playArc_.Right = false;
            workGrey_.Right = false;
            playGrey_.Right = true;

            customRenders_.Add(workArc_);
            customRenders_.Add(playArc_);
            customRenders_.Add(workGrey_);
            customRenders_.Add(playGrey_);

            this.ResetTimer(true, DateTime.Now);

            App.Tick += Tick;
            Closed += MainWindow_Closed;

            mediaPlayer_.Open(new Uri(Environment.CurrentDirectory + "\\bell.mp3"));
            mediaPlayer_.Volume = 1.0;

            tasks_.CollectionChanged += this.OnCollectionChanged;
        }
        private void ButtonDelete_ClickM(object sender, EventArgs e)
        {
            if (DeleteButton.Text == "Delete")
            {
                DeleteButton.Text = "Confirm?";

                DateContent.BackgroundColor      = Color.Red;
                OpponentContent.BackgroundColor  = Color.Red;
                MinutesContent.BackgroundColor   = Color.Red;
                MatchTypeContent.BackgroundColor = Color.Red;
                RatingContent.BackgroundColor    = Color.Red;
                GoalsContent.BackgroundColor     = Color.Red;
                AssistsContent.BackgroundColor   = Color.Red;
                TacklesContent.BackgroundColor   = Color.Red;
                DribblesContent.BackgroundColor  = Color.Red;
                KeyPassesContent.BackgroundColor = Color.Red;
                StaminaContent.BackgroundColor   = Color.Red;
            }

            else
            {
                using (var con = new SQLite.SQLiteConnection(App.FilePath))
                {
                    Match = (MatchData)MatchViews.SelectedItem;

                    var matchToDelete = con.Find <MatchData>(Match.MatchId);

                    con.Delete <MatchData>(matchToDelete.MatchId);

                    MatchViews.ItemsSource = null;

                    matches = con.Table <MatchData>().ToList();

                    MatchViews.ItemsSource = matches;
                }
                DeleteButton.Text = "Delete";

                DateContent.BackgroundColor      = Color.Black;
                OpponentContent.BackgroundColor  = Color.Black;
                MinutesContent.BackgroundColor   = Color.Black;
                MatchTypeContent.BackgroundColor = Color.Black;
                RatingContent.BackgroundColor    = Color.Black;
                GoalsContent.BackgroundColor     = Color.Black;
                AssistsContent.BackgroundColor   = Color.Black;
                TacklesContent.BackgroundColor   = Color.Black;
                DribblesContent.BackgroundColor  = Color.Black;
                KeyPassesContent.BackgroundColor = Color.Black;
                StaminaContent.BackgroundColor   = Color.Black;


                DateContent.Text      = " ";
                OpponentContent.Text  = " ";
                MinutesContent.Text   = " ";
                MatchTypeContent.Text = " ";
                RatingContent.Text    = " ";
                GoalsContent.Text     = " ";
                AssistsContent.Text   = " ";
                TacklesContent.Text   = " ";
                DribblesContent.Text  = " ";
                KeyPassesContent.Text = " ";
                StaminaContent.Text   = " ";
            }
        }