Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            string login = textBoxLogin.Text;
            string pass  = textBoxPass.Text;
            string fName = textBoxFName.Text;
            string sName = textBoxSName.Text;
            string email = textBoxEMail.Text;

            if (IsValidEmail(email) == false)
            {
                MessageBox.Show("You entered invalid email!");
                return;
            }
            string errorMsg = "";

            if (ValidatePassword(pass, out errorMsg) == false)
            {
                MessageBox.Show(errorMsg);
                return;
            }
            if (checkLogin(login) == false)
            {
                MessageBox.Show("This login is already taken!");
                return;
            }
            // adding user
            string query = $"INSERT INTO users values(0, '{login}', '{HashFunc.CalculateMD5Hash(pass)}', '{fName}', '{sName}', '{email}')";

            DBFunc.sendRequest(query);
            (this).Close();
        }
Esempio n. 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            string login = textBoxLogin.Text;
            string pass  = textBoxPass.Text;

            pass = HashFunc.CalculateMD5Hash(pass);
            if (userExists(login, pass) && userIsAdmin(login))
            {
                AdminForm mainForm = new AdminForm();
                mainForm.Show();
                mainForm.FormClosing += new FormClosingEventHandler(mainForm_closing);
                (this).Hide();
            }
            else if (userExists(login, pass))
            {
                if (userIsBanned(login))
                {
                    MessageBox.Show("This user is banned!");
                    return;
                }
                Form1 mainForm = new Form1(login);
                mainForm.Show();
                mainForm.FormClosing += new FormClosingEventHandler(mainForm_closing);
                (this).Hide();
            }
            else
            {
                MessageBox.Show("User does not exist!");
            }
        }