Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string Password = "";
- string UPValueCheck = "";
- string Line = "";
- bool Check = false;
- int loginAttempt = 0;
- string user = "";
- while (Check == false && loginAttempt != 3)
- {
- Console.Clear();
- Console.WriteLine("\t\t\t\tPlease Log in");
- Console.WriteLine("--------------------------------------------------------------------------------");
- Console.WriteLine("Username: ");
- Username = Console.ReadLine();
- Console.WriteLine("Password: ");
- Password = Console.ReadLine();
- UPValueCheck = Username + "," + Password;
- using (StreamReader readFile = new StreamReader(Users))
- {
- while ((Line = readFile.ReadLine()) != null)
- {
- var parts = Line.Split(',');
- if (parts[0] == Username && parts[1] == Password)
- {
- Check = true;
- user = parts[0];
- usertype = Convert.ToInt32(parts[2]);
- break;
- }
- else
- {
- Check = false;
- loginAttempt = loginAttempt + 1;
- }
- }
- }
- if (Check == true)
- {
- Console.WriteLine("");
- Console.WriteLine("Correct Username and Password!");
- Console.WriteLine("Welcome to the system!");
- System.Threading.Thread.Sleep(1000);
- MenuSystem();
- }
- else
- {
- Console.WriteLine("");
- Console.WriteLine("Invalid Username and Password.");
- Console.WriteLine("Please try again.");
- System.Threading.Thread.Sleep(1000);
- Login();
- }
- if (Check == false && loginAttempt > 2)
- {
- Console.WriteLine("You have reached maximum attempts. Please contact your Admin.");
- Console.ReadKey();
- Environment.Exit(0);
- }
- else
- {
- break;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement