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; } } }
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; } } }