public StudyCircleManagementSystem.Web.Models.LoginDetail GetDetails(string userName)
        {
            StudyCircleManagementSystem.Web.Models.LoginDetail details = new StudyCircleManagementSystem.Web.Models.LoginDetail();
            string connectionString = ConfigurationManager.ConnectionStrings["connectDB"].ToString();

            SqlConnection connection = null;

            connection = new SqlConnection();
            connection.ConnectionString = connectionString;

            connection.Open();

            SqlCommand command = new SqlCommand("dbo.LoginDetails", connection);

            command.CommandType = CommandType.StoredProcedure;

            command.Parameters.Add(new SqlParameter("@userName", SqlDbType.NVarChar));
            command.Parameters["@userName"].Value = userName;

            command.ExecuteNonQuery();

            SqlDataReader detailDataReader = command.ExecuteReader();

            while (detailDataReader.Read())
            {
                details.UserName    = detailDataReader["userName"].ToString();
                details.Password    = detailDataReader["passworddetails"].ToString();
                details.Designation = detailDataReader["designation"].ToString();
            }
            connection.Close();
            return(details);
        }
        public ActionResult Index(StudyCircleManagementSystem.Web.Models.LoginDetail detail)
        {
            LoginManager information = new LoginManager();

            StudyCircleManagementSystem.Web.Models.LoginDetail details = information.GetDetails(detail.UserName);

            if (details.UserName == detail.UserName && details.Password == detail.Password)
            {
                switch (details.Designation)
                {
                case "Manager":
                {
                    return(View("Manager"));
                }

                case "faculty":
                {
                    return(View("Faculty"));
                }

                case "student":
                {
                    return(View("Student"));
                }
                }
            }
            return(View());
        }
示例#3
0
        public static void VerifyUsername()
        {
            Console.Clear();
            Console.WriteLine("UserName: "******"Password: "******"";
            ConsoleKeyInfo key;

            do
            {
                key = Console.ReadKey(true);
                //
                if (key.Key != ConsoleKey.Backspace && key.Key != ConsoleKey.Enter)
                {
                    inputPassword += key.KeyChar;
                    Console.Write("*");
                }
                else
                {
                    Console.Write("\b");
                }
            }while (key.Key != ConsoleKey.Enter);

            //Console.WriteLine(inputPassword);
            //Console.ReadKey();

            LoginManager information = new LoginManager();

            StudyCircleManagementSystem.Web.Models.LoginDetail details = information.GetDetails(inputUsername);

            if (details.UserName == inputUsername && details.Password == inputPassword)
            {
                Console.Clear();
                Console.WriteLine("Hello {0},\n\t you are logged in as {1}.\n\nPress any key to enter.", details.UserName, details.Designation);
                Console.ReadKey();
                switch (details.Designation)
                {
                case "Manager":
                    Manager();
                    break;

                case "faculty":
                    Faculty();
                    break;

                case "student":
                    Student();
                    break;
                }
            }
            else
            {
                Console.Clear();
                Console.WriteLine("Please enter valid username and password.\nOnly two chances left.\nPress \n\n1.Login again\n2.Exit.");
                char choice = Convert.ToChar(Console.ReadLine());
                switch (choice)
                {
                case '1':
                    VerifyUsername();
                    break;

                case '2':
                    Environment.Exit(0);
                    break;

                default:
                    break;
                }
            }
            Console.ReadKey();
        }