Beispiel #1
0
        // checks to see if table exists, if it doesn't it creates the table
        public static void createTable()
        {
            if (System.IO.File.Exists("pmDB.sqlite"))
            {
                Console.WriteLine("Error file exists!");
            }
            else
            {
                SQLiteConnection.CreateFile("pmDB.sqlite");
                string promptValue = Prompt.ShowDialog("New Password", "This is the first time creating the database, would you like to enter "
                                                       + "a password for your database?");
                Settings.Default.Password = promptValue;
                Settings.Default.Save();
                MessageBox.Show(Settings.Default.Password.ToString());
            }


            string pw = "Password="******"Password"].ToString();

            conn = new SQLiteConnection(connStr + pw);

            string answer = "";


            while (!(answer.Equals(Settings.Default["Password"].ToString())))
            {
                answer = Prompt.ShowDialog("Enter Password", "Enter Password");
            }
            conn.Open();



            string        sql;
            SQLiteCommand cmd;

            //checks to see if table already exists, creates table otherwise
            sql = "CREATE TABLE if not exists Password" +
                  "(Id INTEGER PRIMARY KEY AUTOINCREMENT, " +
                  "Username VARCHAR(100), " +
                  "Password VARCHAR(100), " +
                  "Website  VARCHAR(100), " +
                  "Date    DATE);";
            //creates table based on sql string
            cmd = new SQLiteCommand(sql, conn);
            cmd.ExecuteNonQuery();
            conn.Close();
        }
        private void btnChangePW_Click(object sender, EventArgs e)
        {
            string newPW = Prompt.ShowDialog("What do you want the new PW to be?", "New Password");

            DBManager.ChangePassword(newPW);
        }