Example #1
1
        private void NewMenuItem_Click (object sender, RoutedEventArgs e) {
            Stream newFileStream;
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter = "SQLite files (*.sqlite)|*.sqlite";
            saveFileDialog.FilterIndex = 2;
            saveFileDialog.RestoreDirectory = true;

            if (saveFileDialog.ShowDialog() == true) {
                if ((newFileStream = saveFileDialog.OpenFile()) != null) {

                    if (File.Exists(saveFileDialog.FileName)) {
                        newFileStream.Close();

                        DB = new SQLite.SQLiteConnection(saveFileDialog.FileName);
                        DB_Connection = saveFileDialog.FileName;

                        // Hard coded members class, need to add custom table structure
                        DB.CreateTable<Members>();

                        // Possibly save DB
                        SetView();
                    }

                }
            }

        }
        /// <summary>
        /// This code will handle creating the database and a table.
        /// </summary>
        void HandleTouchUpInsideForCreateDatabase(object sender, EventArgs e)
        {
            // Create the database and a table to hold Person information.
            using (var conn= new SQLite.SQLiteConnection(_pathToDatabase))
            {
                conn.CreateTable<Person>();
            }

            // Let the user know that the database was created, and disable the button
            // to prevent double clicks.
            _txtView.Text = "Created new database at " + _pathToDatabase;
            _btnCreateDatabase.Enabled = false;

            _btnInsertUser.TouchUpInside += HandleTouchUpInsideForInsertUser;
            _btnInsertUser.Enabled = true;
        }