private static void Main(string[] args) { //Database.dbCall(); //AddUser.dbUserAdd("George","password"); //AllMenus mM = new AllMenus(); //Console.CursorVisible = false; //mM.MainMenu(AllMenus.mainMenu); //mM.SuperAdminMenu(AllMenus.superAdminMenu); AllMenus guest = new AllMenus(); guest.MenuCall(); }
public void LevelMenuCall(string username, string password) { int x = CheckAccessLevel(username, password); AllMenus S1 = new AllMenus(username, password, x); if (x == 1) { S1.MenuCall(AllMenus.userMenu); } else if (x == 2) { S1.MenuCall(AllMenus.adminMenu); } else if (x == 3) { S1.MenuCall(AllMenus.superAdminMenu); } }
public new void MenuCall(List <string> menu) { AllMenus m = new AllMenus(); m.MainMenu(menu, Username, Password, AccessLevel); }
public int CheckAccessLevel(string username, string password) { int x = 1; bool adminStatus = true; bool superAdminStatus = true; SqlConnection con = new SqlConnection(ConnectionString); SqlCommand cmdA = new SqlCommand("Select * from dbo.Users where Username = @Username and Password = @Password and AdminStatus = @AdminStatus", con); SqlCommand cmdS = new SqlCommand("Select * from dbo.Users where Username = @Username and Password = @Password and SuperAdminStatus = @SuperAdminStatus", con); SqlDataReader drS = null; cmdA.Parameters.AddWithValue("@Username", username); cmdA.Parameters.AddWithValue("@Password", password); cmdA.Parameters.AddWithValue("@AdminStatus", adminStatus); cmdS.Parameters.AddWithValue("@Username", username); cmdS.Parameters.AddWithValue("@Password", password); cmdS.Parameters.AddWithValue("@SuperAdminStatus", superAdminStatus); try { con.Open(); SqlDataReader dr = cmdA.ExecuteReader(); while (dr.Read()) { if (dr.HasRows == true) { x = 2; break; } } dr.Close(); drS = cmdS.ExecuteReader(); while (drS.Read()) { if (drS.HasRows == true) { x = 3; break; } } } finally { if (drS != null) { drS.Close(); } if (con != null) { con.Close(); } } Console.Clear(); AllMenus S1 = new AllMenus(username, password, x); if (x == 1) { S1.MenuCall(AllMenus.userMenu); } else if (x == 2) { S1.MenuCall(AllMenus.adminMenu); } else if (x == 3) { S1.MenuCall(AllMenus.superAdminMenu); } return(x); }
public string UserRoles(List <string> userMenu, string username, string password, int accessLevel) { AccessLevelCheck alc = new AccessLevelCheck(username, password, accessLevel); DATABASE_CS.DBPrintUsers pu = new DATABASE_CS.DBPrintUsers(); SqlConnection con = new SqlConnection(pu.ConncetionString); List <string> listOfUsersString = pu.DBUsersPrintString(username); AllMenus am = new AllMenus(username, password, accessLevel); while (true) { for (int i = 0; i < listOfUsersString.Count; i++) { Console.Clear(); Console.WriteLine(" MESSAGES CLIENT"); Console.WriteLine($" Welcome <{username.ToUpper()}>!"); Console.WriteLine($" Level: {accessLevel}"); Console.WriteLine(); Console.CursorVisible = true; Console.WriteLine("Please Select User! Press any key to select.."); Console.ReadKey(); Console.CursorVisible = false; string roleUsername = (Menu.MenuRun(listOfUsersString, username, accessLevel)).Trim(); #region Main Menus if (roleUsername == "Main Menu") { Console.Clear(); alc.LevelMenuCall(username, password); } #endregion #region List Menus else { Console.Clear(); Console.Clear(); Console.WriteLine(" MESSAGES CLIENT"); Console.WriteLine($" Welcome <{username.ToUpper()}>!"); Console.WriteLine($" Level: {accessLevel}"); Console.WriteLine(); string currentRole = alc.CheckAccessLevelByUsername(roleUsername); Console.CursorVisible = true; Console.WriteLine($"You selected (({roleUsername.Trim()})) whose role is ({currentRole}). \nPlease Select his Role! \nPress any key to select.."); Console.ReadKey(); Console.Clear(); Console.CursorVisible = false; List <string> RoleList = new List <string> { "User", "Admin", "Super Admin", "Back" }; var AccessLevel = Menu.MenuRun(RoleList, username, accessLevel); if (AccessLevel == "Super Admin") { DBRole(roleUsername, 3); } else if (AccessLevel == "Admin") { DBRole(roleUsername, 2); } else if (AccessLevel == "Back") { Console.Clear(); alc.LevelMenuCall(username, password); } else { DBRole(roleUsername, 1); } Console.Clear(); Console.WriteLine(" MESSAGES CLIENT"); Console.WriteLine($" Welcome <{username.ToUpper()}>!"); Console.WriteLine($" Level: {accessLevel}"); Console.WriteLine(); Console.WriteLine($"The new AccessLevel of User {roleUsername} is {AccessLevel}."); Console.ReadKey(); Console.Clear(); alc.LevelMenuCall(username, password); } #endregion } } }