Advertisement
Guest User

Untitled

a guest
Feb 7th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. string Password = "";
  2. string UPValueCheck = "";
  3. string Line = "";
  4. bool Check = false;
  5. int loginAttempt = 0;
  6.  
  7.  
  8.  
  9. string user = "";
  10.  
  11. while (Check == false && loginAttempt != 3)
  12. {
  13.  
  14. Console.Clear();
  15. Console.WriteLine("\t\t\t\tPlease Log in");
  16. Console.WriteLine("--------------------------------------------------------------------------------");
  17. Console.WriteLine("Username: ");
  18. Username = Console.ReadLine();
  19. Console.WriteLine("Password: ");
  20. Password = Console.ReadLine();
  21. UPValueCheck = Username + "," + Password;
  22.  
  23. using (StreamReader readFile = new StreamReader(Users))
  24. {
  25. while ((Line = readFile.ReadLine()) != null)
  26. {
  27. var parts = Line.Split(',');
  28. if (parts[0] == Username && parts[1] == Password)
  29. {
  30. Check = true;
  31. user = parts[0];
  32. usertype = Convert.ToInt32(parts[2]);
  33. break;
  34. }
  35. else
  36. {
  37. Check = false;
  38. loginAttempt = loginAttempt + 1;
  39.  
  40. }
  41. }
  42.  
  43. }
  44.  
  45. if (Check == true)
  46. {
  47. Console.WriteLine("");
  48. Console.WriteLine("Correct Username and Password!");
  49. Console.WriteLine("Welcome to the system!");
  50. System.Threading.Thread.Sleep(1000);
  51. MenuSystem();
  52.  
  53. }
  54. else
  55. {
  56. Console.WriteLine("");
  57. Console.WriteLine("Invalid Username and Password.");
  58. Console.WriteLine("Please try again.");
  59. System.Threading.Thread.Sleep(1000);
  60. Login();
  61. }
  62.  
  63. if (Check == false && loginAttempt > 2)
  64. {
  65. Console.WriteLine("You have reached maximum attempts. Please contact your Admin.");
  66. Console.ReadKey();
  67. Environment.Exit(0);
  68.  
  69. }
  70. else
  71. {
  72. break;
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement