private void AddVocableToDatabase(object sender, RoutedEventArgs e)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(Infinitiv.Text) || string.IsNullOrWhiteSpace(SimplePast.Text) ||
                    string.IsNullOrWhiteSpace(PastParticiple.Text) || string.IsNullOrWhiteSpace(Translation.Text))
                {
                    throw new Exception("Fields must NOT be empty FOOL!");
                }

                var vokabel = new VokabelModel
                {
                    Infinitiv      = Infinitiv.Text,
                    SimplePast     = SimplePast.Text,
                    PastParticiple = PastParticiple.Text,
                    Translation    = Translation.Text
                };

                SqliteDataAccess.SpeichereVokabel(vokabel);

                Infinitiv.Text      = string.Empty;
                SimplePast.Text     = string.Empty;
                PastParticiple.Text = string.Empty;
                Translation.Text    = string.Empty;
            }
            catch (Exception ex)
            {
                MessageBox.Show("An exception just occurred: " + ex.Message, "ERROR", MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
        }
Example #2
0
 public static void SpeichereVokabel(VokabelModel vokabel)
 {
     using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
     {
         cnn.Execute("insert into Vokabel (Infinitiv, SimplePast, PastParticiple, Translation) values (@Infinitiv, @SimplePast, @PastParticiple, @Translation)",
                     vokabel);
     }
 }
        private void RemoveVocableFromList(object sender, RoutedEventArgs e)
        {
            try
            {
                var ausgewählteVokabeln = VokabelListGrid.SelectedItems;

                if (ausgewählteVokabeln.Count == 0)
                {
                    throw new Exception("You need to select Data, if you want to delete it LOL scrub");
                }

                var listOfVocabulary = new List <VokabelModel>();

                foreach (VokabelModel vokabel in ausgewählteVokabeln)
                {
                    var retValVokabel = new VokabelModel
                    {
                        Infinitiv      = vokabel.Infinitiv,
                        SimplePast     = vokabel.SimplePast,
                        PastParticiple = vokabel.PastParticiple,
                        Translation    = vokabel.Translation
                    };

                    listOfVocabulary.Add(retValVokabel);
                }

                SqliteDataAccess.LöscheVokabeln(listOfVocabulary);

                RefreshList(sender, e);
            }
            catch (Exception ex)
            {
                MessageBox.Show("An exception just occurred: " + ex.Message, "ERROR", MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
        }