Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            String nPasswd = nPasswdTxt.Text;
            String cPasswd = confPasswd.Text;

            conn.Open();
            comm = new MySqlCommand("UPDATE userstable set Passwd=@passwd where Email=@email", conn);
            comm.Parameters.Add("@email", MySqlDbType.VarChar).Value  = reEmail;
            comm.Parameters.Add("@passwd", MySqlDbType.VarChar).Value = nPasswdTxt.Text;

            if (nPasswd.Trim() == "" || cPasswd.Trim() == "")
            {
                MessageBox.Show("PLEASE FILL ALL THE BLANK FIELDS");
            }
            else
            {
                if (confPasswd.Text != nPasswdTxt.Text)
                {
                    MessageBox.Show("PASSWORDS DO NOT MATCH");
                }
                else
                {
                    if (comm.ExecuteNonQuery() == 1)
                    {
                        MessageBox.Show("PASSWORD HAS CHANGED SUCCESSFULLY");
                        this.Hide();
                        LoginForm login = new LoginForm();
                        login.ShowDialog();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("AN ERROR OCCURED PLEASE TRY AGAIN");
                    }
                }
            }
            conn.Close();
        }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            String fname          = fnameTxt.Text;
            String lname          = lnameTxt.Text;
            String email          = emailTxt.Text;
            String address        = addrTxt.Text;
            String phone          = phoneTxt.Text;
            String usrn           = usernameTxt.Text;
            String passwd         = passwdTxt.Text;
            String cpasswd        = c_passwdTxt.Text;
            int    allowdatausage = ads;

            if (fname.Trim() == "" || lname.Trim() == "" || email.Trim() == "" || address.Trim() == "" || phone.Trim() == "" || usrn.Trim() == "" || passwd.Trim() == "")
            {
                MessageBox.Show("PLEASE FILL ALL NECESSARY FIELDS");
            }
            else if (!(passwd.Equals(cpasswd)))
            {
                MessageBox.Show("PASSWORDS DO NOT MATCH PLEASE TRY AGAIN");
                eLabel.ForeColor     = Color.Black;
                userLabel.ForeColor  = Color.Black;
                cPassLabel.ForeColor = Color.Red;
                cPassLabel.Text      = "*Confirm Password";
                c_passwdTxt.Focus();
                c_passwdTxt.Text = "";
            }
            else if (usernameExists(usrn))
            {
                MessageBox.Show("USERNAME: "******" ALREADY EXISTS");
                eLabel.ForeColor     = Color.Black;
                userLabel.ForeColor  = Color.Red;
                cPassLabel.ForeColor = Color.Black;
                userLabel.Text       = "*Username";
                usernameTxt.Focus();
                usernameTxt.Text = "";
            }
            else if (emailExists(email))
            {
                MessageBox.Show("EMAIL: " + email + " ALREADY EXISTS");
                eLabel.ForeColor     = Color.Red;
                userLabel.ForeColor  = Color.Black;
                cPassLabel.ForeColor = Color.Black;
                eLabel.Text          = "*Email";
                emailTxt.Focus();
                emailTxt.Text = "";
            }
            else
            {
                conn.Open();
                MySqlCommand com = new MySqlCommand("INSERT INTO `userstable`(`fname`, `lname`, `email`, `address`, `phone`, `username`, `passwd`,`allowDataUsage`) VALUES (@fname,@lname,@email,@addr,@phone,@usrn,@passwd,@allowDataUsage)", conn);
                com.Parameters.Add("@fname", MySqlDbType.VarChar).Value          = fname;
                com.Parameters.Add("@lname", MySqlDbType.VarChar).Value          = lname;
                com.Parameters.Add("@email", MySqlDbType.VarChar).Value          = email;
                com.Parameters.Add("@addr", MySqlDbType.VarChar).Value           = address;
                com.Parameters.Add("@phone", MySqlDbType.VarChar).Value          = phone;
                com.Parameters.Add("@usrn", MySqlDbType.VarChar).Value           = usrn;
                com.Parameters.Add("@passwd", MySqlDbType.VarChar).Value         = _service.RetrieveHash(passwd);
                com.Parameters.Add("@allowDataUsage", MySqlDbType.VarChar).Value = allowdatausage;


                if (com.ExecuteNonQuery() == 1)
                {
                    MessageBox.Show("SIGN UP WAS SUCCESSFULL");
                    this.Hide();
                    LoginForm login = new LoginForm();
                    login.ShowDialog();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("SIGN UP FAILED PLEASE TRY AGAIN");
                }

                conn.Close();
            }
        }