private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            string slowkopl = TextBoxDodajSlowkoPL.Text.ToLower();
            string slowkoen = TextBoxDodajSlowkoEN.Text.ToLower();
            string kontekst = TextBoxDodajKontekst.Text;
            if (kontekst.Length == 0)
            {
                kontekst = " ";
            }
            string podpowiedz = TextBoxDodajSlowkoPodpowiedz.Text;
            if (podpowiedz.Length == 0)
            {
                podpowiedz = " ";
            }

            string DBPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, aktualnabaza + ".sqlite");
            var db = new SQLite.SQLiteConnection(DBPath);
            var newfisz = new UserDefaultDataBase
            {
                SlowkoPl = slowkopl,
                SlowkoEn = slowkoen,
                Kontekst = kontekst,
                Podpowiedz = podpowiedz,
                IloscOdpowiedzi = 0,
                IloscPoprawnychOdpowiedzi = 0,
                passa = 0,
                kategoria = 1

            };

            db.Insert(newfisz);

            TextBoxDodajSlowkoEN.Text = "";
            TextBoxDodajSlowkoPL.Text = "";
            TextBoxDodajKontekst.Text = "";
            TextBoxDodajSlowkoPodpowiedz.Text = "";
            DodajSlowkoEndButton.IsEnabled = true;
        }
Example #2
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used when the application is launched to open a specific file, to display
        /// search results, and so forth.
        /// </summary>
        /// <param name="args">Details about the launch request and process.</param>
        protected async override void OnLaunched(LaunchActivatedEventArgs args)
        {
            Frame rootFrame = Window.Current.Content as Frame;

            int sprawdz = 0;
            var path = Windows.Storage.ApplicationData.Current.LocalFolder.Path;
            StorageFolder folder = Windows.Storage.ApplicationData.Current.LocalFolder;
            //var files = await folder.GetFilesAsync();

            IReadOnlyList<StorageFile> fList = await folder.GetFilesAsync();
            foreach (var f in fList)
            {
                //Debug.WriteLine(f.DisplayName);
                if (f.DisplayName.Equals("AppData"))
                {
                    sprawdz = 1;
                }
            };
            Debug.WriteLine(Windows.Storage.ApplicationData.Current.LocalFolder.Path);
            if (sprawdz == 0)
            {
                this.DBPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "AppData.sqlite"); 
                //inicjalizacja bazy
                using (var db = new SQLite.SQLiteConnection(this.DBPath))
                {
                    db.CreateTable<UserInformation>();
                    db.CreateTable<UserDefaultDataBase>();

                    var uzytkownik = new UserInformation
                    {
                        Id = 1,
                        IloscDobrychOdpowiedzi = 0,
                        IloscOgolnychOdpowiedzi = 0,
                        passa = 0,
                        NauczucielTest = 1,
                        NauczycielPin = 0000,
                        IloscLogowan = 0

                    };

                    var slowko1 = new UserDefaultDataBase
                    {
                        SlowkoPl = "Monitor",
                        SlowkoEn = "Screen",
                        Podpowiedz = "You watching move on yours PC's s...",
                        Kontekst = "Monitor komputera",
                        IloscOdpowiedzi = 0,
                        passa = 0,
                        IloscPoprawnychOdpowiedzi = 0,
                        kategoria = 1
                    };


                    db.Insert(uzytkownik);
                    db.Insert(slowko1);
                }
            }

  
            //this.DBPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "AppData.sqlite");
            //Debug.WriteLine("App path: {0}", DBPath);
            ////inicjalizacja bazy
            //using (var db = new SQLite.SQLiteConnection(this.DBPath))
            //{
            //    db.CreateTable<UserInformation>();
            //    db.CreateTable<UserDefaultDataBase>();

            //    var asd = new UserDefaultDataBase
            //    {
            //        SlowkoPl = "Monitor",
            //        SlowkoEn = "Screen",
            //        Podpowiedz = "You watching move on yours PC's s...",
            //        Kontekst = "Monitor komputera",
            //        IloscOdpowiedzi = 0,
            //        passa = 0,
            //        IloscPoprawnychOdpowiedzi = 0
            //    };

            //    db.Insert(asd);
            //}

            

            
            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                if (!rootFrame.Navigate(typeof(MainPage), args.Arguments))
                {
                    throw new Exception("Failed to create initial page");
                }
            }
            // Ensure the current window is active
            Window.Current.Activate();
        }