Example #1
0
        private void SignInButton_Click(object sender, EventArgs e)
        {
            string userLogin = LoginField.Text;
            string userPass  = PasswordField.Text;

            DB        db    = new DB();
            DataTable table = new DataTable();

            MySqlDataAdapter adapter = new MySqlDataAdapter();

            MySqlCommand command = new MySqlCommand("SELECT * FROM users WHERE login = @userLogin AND pass = @userPass", db.Connection);

            command.Parameters.Add("@userLogin", MySqlDbType.VarChar).Value = userLogin;
            command.Parameters.Add("@userPass", MySqlDbType.VarChar).Value  = userPass;

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

            if (table.Rows.Count > 0)
            {
                MessageBox.Show($"Welcome, {userLogin}!");
                this.Hide();
                StoreForm store = new StoreForm();
                store.Show();
            }
            else
            {
                MessageBox.Show("Wrong Login or Password");
            }
        }
Example #2
0
        private void RegSignUp_Click(object sender, EventArgs e)
        {
            string regLogin      = RegLoginField.Text;
            string regPass       = RegPasswordField.Text;
            string regRepeatPass = RegRepeatPasswordField.Text;

            if (regLogin == "" || regPass == "" || regRepeatPass == "")
            {
                MessageBox.Show("Some Fields Are Empty");
                return;
            }

            if (regPass != regRepeatPass)
            {
                MessageBox.Show("Passwords don't match!");
                return;
            }

            if (IsUserExisting())
            {
                MessageBox.Show($"That Login Already Exists. Please Choose Another Login");
                return;
            }

            DB           db      = new DB();
            MySqlCommand command = new MySqlCommand("INSERT users (Login, Pass) VALUES (@rL, @rP)", db.Connection);

            command.Parameters.Add("@rL", MySqlDbType.VarChar).Value = regLogin;
            command.Parameters.Add("@rP", MySqlDbType.VarChar).Value = regPass;

            db.OpenConnection();

            if (command.ExecuteNonQuery() == 1)
            {
                MessageBox.Show("Accaunt is Created!");
            }
            else
            {
                MessageBox.Show("Accaunt isn't Created!");
            }

            db.CloseConnection();

            this.Hide();
            StoreForm store = new StoreForm();

            store.Show();
        }