Example #1
0
        private void login_button_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "Username")
            {
                MessageBox.Show("Enter the Username");
                return;
            }

            if (textBox2.Text == "Password")
            {
                MessageBox.Show("Enter the Password");
                return;
            }
            else
            {
                if (textBox2.Text == "")
                {
                    MessageBox.Show("Enter the Password");
                    return;
                }
            }



            loginUser = textBox1.Text;
            passUser  = textBox2.Text;

            database db = new database();

            DataTable        table   = new DataTable();
            MySqlDataAdapter adapter = new MySqlDataAdapter();

            MySqlCommand command = new MySqlCommand("SELECT * FROM `users` WHERE `login` = @uL AND `password` = @uP", db.GetConnection());

            command.Parameters.Add("@uL", MySqlDbType.VarChar).Value = loginUser;
            command.Parameters.Add("@uP", MySqlDbType.VarChar).Value = passUser;

            adapter.SelectCommand = command;
            adapter.Fill(table);

            if (table.Rows.Count > 0)
            {
                this.Hide();
                EnterForm enter = new EnterForm();//////////////////////////////////////////////////////////////////////
                enter.Show();
            }
            else
            {
                textBox3.ForeColor = Color.Red;
            }
        }
Example #2
0
File: Form2.cs Project: Rendrum/APA
        public Boolean userCheck()
        {
            database db = new database();

            DataTable        table   = new DataTable();
            MySqlDataAdapter adapter = new MySqlDataAdapter();

            MySqlCommand command = new MySqlCommand("SELECT * FROM `users` WHERE `login` = @uL", db.GetConnection());

            command.Parameters.Add("@uL", MySqlDbType.VarChar).Value = textBox10.Text;

            adapter.SelectCommand = command;
            adapter.Fill(table);

            if (table.Rows.Count > 0)
            {
                MessageBox.Show("Login already exists");
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #3
0
File: Form2.cs Project: Rendrum/APA
        private void button4_Click(object sender, EventArgs e)
        {
            if (textBox12.Text == "Name")
            {
                MessageBox.Show("Enter the Name");
                return;
            }

            if (textBox11.Text == "Surname")
            {
                MessageBox.Show("Enter the Surname");
                return;
            }

            if (textBox10.Text == "Username")
            {
                MessageBox.Show("Enter the Username");
                return;
            }

            if (textBox9.Text == "Password")
            {
                MessageBox.Show("Enter the Password");
                return;
            }
            else
            {
                if (textBox9.Text == "")
                {
                    MessageBox.Show("Enter the Password");
                    return;
                }
            }



            if (userCheck())
            {
                return;
            }

            database     db      = new database();
            MySqlCommand command = new MySqlCommand("INSERT INTO `users` (`login`, `password`, `nume`, `prenume`) VALUES (@log, @pass, @nume, @prenume)", db.GetConnection());

            command.Parameters.Add("@log", MySqlDbType.VarChar).Value     = textBox10.Text;
            command.Parameters.Add("@nume", MySqlDbType.VarChar).Value    = textBox12.Text;
            command.Parameters.Add("@prenume", MySqlDbType.VarChar).Value = textBox11.Text;
            command.Parameters.Add("@pass", MySqlDbType.VarChar).Value    = textBox9.Text;

            db.ConnectionOpen();

            if (command.ExecuteNonQuery() == 1)
            {
                MessageBox.Show("Registred!");
            }
            else
            {
                MessageBox.Show("Something wrong, i can feel it");
            }

            db.ConnectionClose();
        }
Example #4
0
        public bool crack(char[] word)
        {
            myPass = "";
            for (int i = 0; i < word.Length; i++)
            {
                myPass += word[i];
            }

            if (textBox1.Text == "Username")
            {
                MessageBox.Show("Enter the Username");
            }

            if (textBox2.Text == "Password")
            {
            }
            else
            {
                if (textBox2.Text == "")
                {
                }
            }



            loginUser = textBox4.Text;
            passUser  = myPass;

            database db = new database();

            DataTable        table   = new DataTable();
            MySqlDataAdapter adapter = new MySqlDataAdapter();

            MySqlCommand command = new MySqlCommand("SELECT * FROM `users` WHERE `login` = @uL AND `password` = @uP", db.GetConnection());

            command.Parameters.Add("@uL", MySqlDbType.VarChar).Value = loginUser;
            command.Parameters.Add("@uP", MySqlDbType.VarChar).Value = passUser;

            adapter.SelectCommand = command;
            adapter.Fill(table);

            if (table.Rows.Count > 0)
            {
                return(true);

                MessageBox.Show($"Password is {passUser}");
            }
            else
            {
                textBox3.ForeColor = Color.Red;

                return(false);
            }



            /*textBox2.Text = myPass;
             *
             * if (password != myPass)
             * {
             *  return "";
             * }
             * else
             * {
             *  Console.WriteLine("Finded!");
             *  Console.WriteLine(myPass);
             *  return myPass;
             * }*/
        }