Пример #1
0
        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);
            }
        }
Пример #2
0
        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();
        }
Пример #3
0
        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);
        }