예제 #1
0
파일: Program.cs 프로젝트: TevinH14/P-P2
        private static void Login()
        {
            string userEA       = Utility.StringValidate("Please enter email Address");
            string userPassword = Utility.StringValidate("Please enter password");

            conn = new MySqlConnection(cs);
            conn.Open();

            // Form SQL Statement
            string stm = $"Select * from Users where EmailAddress = @userEA and Password = @userPassword limit 1;";

            // @userFN, @userLN, @userEA, @userPassword
            MySqlDataReader rdr = null;
            // Prepare SQL Statement
            MySqlCommand cmd = new MySqlCommand(stm, conn);

            cmd.Parameters.AddWithValue("@userEA", userEA);
            cmd.Parameters.AddWithValue("@userPassword", userPassword);

            // Execute SQL Statement and Convert Results to a String
            rdr = cmd.ExecuteReader();
            if (!rdr.HasRows)
            {
                Console.WriteLine("email or password is incorrect");
                Login();
            }

            Console.WriteLine("Welcome Back!!!");
            Console.WriteLine("\r\nPress return to continue.");
            Console.ReadKey();
            HomeWorkBulletin homeWorkBulletin = new HomeWorkBulletin(userEA);
        }
예제 #2
0
파일: Program.cs 프로젝트: TevinH14/P-P2
        private static void SignUp()
        {
            //prompt the user and valdidation using Utility class and duble check the user know the password they entered
            string userFN       = Utility.StringValidate("Please enter firstname ");
            string userLN       = Utility.StringValidate("please enter last name");
            string userEA       = Utility.StringValidate("please enter Email Address");
            string userPassword = Utility.StringValidate("please enter password");
            string userVP       = Utility.StringValidate("please verify passord");

            while (userPassword != userVP)
            {
                Console.WriteLine("passwords do not matach please enter the correct password.");
                userVP = Console.ReadLine();
            }
            // Open a connection to MySQL
            conn = new MySqlConnection(cs);
            conn.Open();

            // Form SQL Statement
            string stm = $"insert into Users(FirstName,LastName,EmailAddress,Password)" +
                         $" Values (@userFN,@userLN,@userEA,@userPassword); ";

            // @userFN, @userLN, @userEA, @userPassword
            MySqlDataReader rdr = null;
            // Prepare SQL Statement
            MySqlCommand cmd = new MySqlCommand(stm, conn);

            cmd.Parameters.AddWithValue("@userFN", userFN);
            cmd.Parameters.AddWithValue("@userLN", userLN);
            cmd.Parameters.AddWithValue("@userEA", userEA);
            cmd.Parameters.AddWithValue("@userPassword", userPassword);
            // Execute SQL Statement and Convert Results to a String
            rdr = cmd.ExecuteReader();
            Console.WriteLine("Welcome new user");
            Console.ReadKey();
            HomeWorkBulletin homeWorkBulletin = new HomeWorkBulletin(userEA);
        }