private static bool CheckUsernameToTransfer(string userName, string userToTransfer)// eos position 6
        {
            string query           = "SELECT COUNT (username) FROM users WHERE username = '******'";
            int    result          = Convert.ToInt32(AddQuerryInt(query));
            bool   invalidUsername = false;

            if (result == 0.000)
            {
                Console.Clear();

                string message = "The user you are looking for does not exists.";
                ConsoleLayout.Attention(message, 0);

                ConsoleLayout.Position(2);
                Console.WriteLine("To choose an other username please press 'Enter'");

                ConsoleLayout.Position(4);
                Console.WriteLine(" To go back to menou please type 'M'");

                string message1 = "Who's that?";
                ConsoleLayout.Speech(message1, -4);

                ConsoleLayout.Position(6);
                string userinput = Convert.ToString(Console.ReadLine());

                if ((userinput == "M") || (userinput == "m"))
                {
                    ShowMenus.ChooseUser(userName);
                }
                invalidUsername = true;
            }
            return(invalidUsername);
        }
Ejemplo n.º 2
0
        public static void CheckUser(SqlConnection sqlconn)
        {
            Welcome();
            int result = 0;
            int i      = 2;

            do
            {
                // Console.WriteLine("{0," + Console.WindowWidth / 2 + "}", " ");
                ConsoleLayout.Position(0);
                Console.WriteLine("Please enter your username");

                ConsoleLayout.Position(2);
                string userName = Convert.ToString(Console.ReadLine());

                ConsoleLayout.Position(4);
                Console.WriteLine("Please enter your password");

                ConsoleLayout.Position(6);
                string passWord = GenerateSHA256String(Hide());


                //sc.Parameters.AddWithValue("@password", GetHashedText(pass.Text));

                SqlCommand cmd = new SqlCommand("SELECT COUNT (*) FROM users WHERE username = @username AND password = @password", sqlconn);
                cmd.Parameters.AddWithValue("@username", userName);
                cmd.Parameters.AddWithValue("@password", passWord);
                result = (int)cmd.ExecuteScalar();

                if (result > 0)
                {
                    ConsoleLayout.Position(10);
                    Console.WriteLine("Successful Connection");

                    System.Threading.Thread.Sleep(1000);
                    Console.Clear();
                    ShowMenus.ChooseUser(userName);
                    break;
                }
                else if (i == 0)
                {
                    string message1 = "Where is your mind?";
                    ConsoleLayout.Speech(message1, 0);
                    string message = "Sorry, invalid user!!!";
                    ConsoleLayout.Attention(message, 10);

                    ConsoleLayout.Position(12);
                    Environment.Exit(0);
                }
                else
                {
                    i--;
                    string message = "Unsuccessfull Connection";
                    ConsoleLayout.Attention(message, 10);
                    ConsoleLayout.Position(12);
                    Console.WriteLine("Please try again, {0} tries left!!!", i + 1);

                    System.Threading.Thread.Sleep(1000);
                    Console.Clear();
                }
            }while ((result == 0) && (i >= 0));
        }