private void btnEnter_Click(object sender, EventArgs e) { string path = @"C:\Users\Mphiwa\source\offline rough work\YJMFlight\Creation\FlightSimulator\FlightSimulator\Resources\AuthrnticateUserFile.txt"; string pass = txtPassword.Text; string ussername = txtUsername.Text; bool valid = false; Authentiction_Handler handler = new Authentiction_Handler(); List <Users> users = handler.GetUsers(path); foreach (Users item in users) { string myusser = item.UserName; string mypass = item.Password; if (mypass == pass && myusser == ussername) { valid = true; } } if (valid) { MessageBox.Show("Welcome : " + ussername, "WELCOMEE!!!"); } else { MessageBox.Show("Incorrect user credentials", "ERROR!!"); txtPassword.Clear(); txtUsername.Clear(); txtUsername.Focus(); } }
private void btnSave_Click(object sender, EventArgs e) { string path = @"C:\Users\Mphiwa\source\offline rough work\YJMFlight\Creation\FlightSimulator\FlightSimulator\Resources\AuthrnticateUserFile.txt"; string name, surname, age, id, password, rank; name = txtName.Text; surname = txtSurname.Text; age = txtAge.Text; id = txtID.Text; rank = txtPosition.Text; password = txtPassword.Text; Users users = new Users(name, password); Authentiction_Handler handler = new Authentiction_Handler(); handler.WriteUsers(users, path); }
private void btnBack_Click(object sender, EventArgs e) { string path = @"C:\Users\Mphiwa\source\offline rough work\YJMFlight\Creation\FlightSimulator\FlightSimulator\Resources\AuthrnticateUserFile.txt"; string ussername = txtUsername.Text; string username = txtReEnter.Text; if (ussername == username) { Authentiction_Handler handler = new Authentiction_Handler(); List <Users> users = handler.GetUsers(path); foreach (Users item in users) { string myusser = item.UserName; string mypass = item.Password; if (myusser == ussername) { txtPassword.Text = mypass; } } } }