Пример #1
0
        private void signup_Click(object sender, EventArgs e)
        {
            SqlDb        db      = new SqlDb();
            MySqlCommand command = new MySqlCommand("INSERT INTO `users`(`Username`,`Name`,`Password`,`Admin Id`) VALUES (@usn,@nam,@pass,@Adi)", db.getConnection());

            command.Parameters.Add("@usn", MySqlDbType.VarChar).Value  = Username.Text;
            command.Parameters.Add("@nam", MySqlDbType.VarChar).Value  = NameU.Text;
            command.Parameters.Add("@pass", MySqlDbType.VarChar).Value = Password.Text;
            command.Parameters.Add("@Adi", MySqlDbType.VarChar).Value  = AdiD.Text;

            db.openConnection();
            if (!checkTextBoxesValues())
            {
                if (Password.Text.Equals(PasswordConf.Text))
                {
                    if (checkUsername())
                    {
                        MessageBox.Show("This Username Already Exists, Select A Different One", "Duplicate Username", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                    }
                    else

                    {
                        if (command.ExecuteNonQuery() == 1)
                        {
                            MessageBox.Show("Your Account Has Been Created", "Account Created", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.Hide();
                            Form1 log = new Form1();
                            log.Show();
                        }
                        else
                        {
                            MessageBox.Show("ERROR");
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Wrong Confirmation Password", "Password Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Enter Your Informations First", "Empty Data", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
            }



            db.closeConnection();
        }