using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Data.SqlClient; namespace GeoTema { public partial class MainMenu : Form { public MainMenu() { InitializeComponent(); } public static string User = ""; public static string Pass = ""; public static string type = ""; private void btnLogin_Click(object sender, EventArgs e) { User = txtUserName.Text; Pass = txtPassword.Text; string statement = "use GeoTema_Users select Usertype from Users where Username = '" + User + "' and Password = '" + Pass + "'"; type = Sql.SQLCheck(statement); //Runs a method to determine if the login exists and returns the type of user if (Pass == "Passw0rd") { MessageBox.Show("Password is currently the default one. Please change it!"); this.Hide(); ChangeDefaultPassword Pass1 = new ChangeDefaultPassword(); Pass1.ShowDialog(); this.Close(); } else { switch (type) //Uses the type of user to determine what part of the program to send them to { case "administrator": { this.Hide(); AdminMenu Admin1 = new AdminMenu(); Admin1.ShowDialog(); this.Close(); break; } case "super user": { this.Hide(); SuperMenu Super1 = new SuperMenu(); Super1.ShowDialog(); this.Close(); break; } case "user": { this.Hide(); UserMenu User1 = new UserMenu(); User1.ShowDialog(); this.Close(); break; } } } } public bool PasswordCheck(string Password) //This method takes an inputted string and checks that it meets certain requirements and returns either true or false { bool OK = true; int SmallLetter = 0; int BigLetter = 0; int Number = 0; for(int i=0;i 0) SmallLetter++; if ("ABCDEFGHIJKLMNOPQRSTUVWXYZÅÆØ".IndexOf(Password.Substring(i, 1)) > 0) BigLetter++; if ("0123456789".IndexOf(Password.Substring(i, 1)) > 0) Number++; } if (SmallLetter > 0 && BigLetter > 0 && Number > 0 && Password.Length >=8) //The string must have at least 1 of each: small letter, big letter and number AND it must be at least 8 characters OK = true; else OK = false; return OK; } } }