コード例 #1
0
        private void sufCreateAccountButton_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrWhiteSpace(sufNameInput.Text.Trim()) || String.IsNullOrWhiteSpace(sufEmailInput.Text.Trim()) || String.IsNullOrWhiteSpace(sufConfirmEmailInput.Text.Trim()) || String.IsNullOrWhiteSpace(sufUsernameInput.Text.Trim()) || String.IsNullOrWhiteSpace(sufPasswordInput.Text.Trim()) || String.IsNullOrWhiteSpace(sufConfirmPasswordInput.Text.Trim()) || String.IsNullOrWhiteSpace(sufPasswordReminderInput.Text.Trim()) || (termsAgreementCheckbox.CheckState == CheckState.Unchecked))
            {
                MessageBox.Show("Please fill in all the required form fields.");
            }
            else
            {
                sufErrorProvider1.Clear();
                if (sufEmailInput.Text.Trim() != sufConfirmEmailInput.Text.Trim())
                {
                    sufErrorProvider1.SetError(sufConfirmEmailLabel, "The provided confirmation email address does not match the email address stated in the email address form field above.");
                }
                else if (sufPasswordInput.Text.Trim() != sufConfirmPasswordInput.Text.Trim())
                {
                    sufErrorProvider1.SetError(sufConfirmPasswordLabel, "The provided confirmation password does not match the password entered in the password form field above.");
                }
                else if (sufPasswordInput.Text.Trim() == sufPasswordReminderInput.Text.Trim())
                {
                    sufErrorProvider1.SetError(sufPasswordReminderLabel, "Your password reminder cannot be the same as your password. Please change your password reminder or your password.");
                }
                else if (String.IsNullOrWhiteSpace(sufDBTableNameInput.Text.Trim()))
                {
                    sufErrorProvider1.SetError(sufDBTableNameLabel, "You must enter a name for the database table that will be storing your list of PassVault Information.");
                }
                else
                {
                    Connection connector = new Connection(LoginMode.signUp, sufDBTableNameInput.Text.ToString());
                    connector.ConnectToDB();
                    string[] inputData = { sufNameInput.Text.Trim(), sufEmailInput.Text.Trim(), sufUsernameInput.Text.Trim(), sufPasswordInput.Text.Trim(), sufPasswordReminderInput.Text.Trim(), sufDBTableNameInput.Text.Trim() };
                    //START TEST
                    Encryption encryptor = new Encryption();
                    string[] EncryptedContent = encryptor.StartEncryption(inputData);
                    //END TEST
                    connector.InsertToTable(EncryptedContent);
                    connector.ShowTableData();
                    connector.CloseConnection();

                    sufFinalName.Text = sufFinalName.Text + ": " + sufNameInput.Text.Trim();
                    sufFinalEmail.Text = sufFinalEmail.Text + ": " + sufEmailInput.Text.Trim();
                    sufFinalUsername.Text = sufFinalUsername.Text + ": " + sufUsernameInput.Text.Trim();
                    sufFinalPassword.Text = sufFinalPassword.Text + ": " + sufPasswordInput.Text.Trim();
                    sufFinalPasswordHint.Text = sufFinalPasswordHint.Text + ": " + sufPasswordReminderInput.Text.Trim();
                    sufFinalDBTableName.Text = sufFinalDBTableName.Text + ": " + sufDBTableNameInput.Text.Trim();

                    signUpPanel2.Show();
                    signUpPanel1.Hide();
                }
            }
        }
コード例 #2
0
 private void mainLoginButton_Click(object sender, EventArgs e)
 {
     if (String.IsNullOrWhiteSpace(mainUsernameInput.Text) || String.IsNullOrWhiteSpace(mainPasswordInput.Text))
     {
         MessageBox.Show("Please fill in all the required form fields.");
     }
     else
     {
         string[] loginData = {mainUsernameInput.Text.Trim().ToString(), mainPasswordInput.Text.Trim().ToString()};
         Encryption loginEncryptor = new Encryption();
         string[] encryptedLoginData = loginEncryptor.StartEncryption(loginData);
         Connection pvLoginConnect = new Connection(LoginMode.mainLogin, encryptedLoginData[0], encryptedLoginData[1]);
         switch (adminOverrideAccessCheckbox.CheckState)
         {
             case CheckState.Unchecked:
                 //Connect & Compare User Input to Database
                 pvLoginConnect.ConnectToDB();
                 Encryption tableNameDecryptor = new Encryption();
                 info = tableNameDecryptor.SingleDecryption(pvLoginConnect.LoginCheck()); //info contains the tableName needed to be displayed
                 
                 switch (String.IsNullOrEmpty(info))
                 { 
                     case true:
                         //Nothing Happens
                         break;
                     case false:
                         //Load Table Data Corresponding to User
                         passVaultForm mainProg = new passVaultForm(); 
                         mainProg.Show();
                         break;
                 }
                 pvLoginConnect.CloseConnection();
                 break;
             case CheckState.Checked:
                 MessageBox.Show("OVERRIDE LOGIN ENABLED!");
                 //Look for File Directory for Offline Access after Online Connection Made.
                 //OFFLINE OVERRIDE
                 string[] tempOvAct = new string[File.ReadLines(@"C:\Users\Eric Liang\Desktop\XP6VV.txt").Count()];
                 using (StreamReader sr = File.OpenText(@"C:\Users\Eric Liang\Desktop\XP6VV.txt"))
                 {
                     for (int i = 0; i < File.ReadLines(@"C:\Users\Eric Liang\Desktop\XP6VV.txt").Count(); i++)
                     {
                         tempOvAct[i] = sr.ReadLine().Trim();
                     } 
                 }
                 if (mainUsernameInput.Text == tempOvAct[0] && mainPasswordInput.Text == tempOvAct[1])
                 {
                     MessageBox.Show("OVERRIDE ACCESS GRANTED. Loading Data...");
                     System.Threading.Thread.Sleep(5000); //Delay Time for Console Window to Load All Data Otherwise Blankout
                     AllocConsole(); //Opens Console Window
                     Connection Override = new Connection(LoginMode.mainLogin);
                     Override.ConnectToDB();
                     Override.ShowTableData();
                     Override.CloseConnection();
                 }
                 else
                 {
                     MessageBox.Show("Error! Wrong Information.");
                 }
                 break;
             default:
                 MessageBox.Show("Uh oh, something went horribly wrong.");
                 break;
         }
     }
 }
コード例 #3
0
        private void addAccountButton_Click(object sender, EventArgs e)
        {
            int accountRowCount = accountGrid.RowCount;
            int rowIncrement = accountRowCount + 1;
            Console.Write(accountRowCount);

            //Missing Form Field Input Check
            if (labelInput.TextLength < 2 || addUserInput.TextLength < 1 || addPassInput.TextLength < 1)
            {
                MessageBox.Show("Please fill in all the form fields.");
            }
            else
            {
                Connection inserter = new Connection(LoginMode.dbLogin, Login.info);
                string[] data = { labelInput.Text.Trim(), addUserInput.Text.Trim(), addPassInput.Text.Trim(), notesRichTextbox.Text.Trim() };
                Encryption encryptInputData = new Encryption();
                string[] encryptedInputData = encryptInputData.StartEncryption(data);
                inserter.ConnectToDB();
                inserter.InsertToTable(encryptedInputData);
                //Update DataGridView Contents
                inserter.CloseConnection();
                Form1_Load(null, null);
            }
        }