Пример #1
0
        private void btnRegister_Click(object sender, EventArgs e)
        {
            UserAccountManagerBLL accountBLL = new UserAccountManagerBLL();
            Users newUser = new Users();

            newUser.FirstName = txtFname.Text;
            newUser.Surname = txtSname.Text;
            newUser.Email = txtEmail.Text;
            // Userpassword is encrypted using SHA1();
            if (txtPassword.Text == txtConfirmPass.Text)
            {
                newUser.Password = txtConfirmPass.Text; //EncryptPassword.Encrypt(txtConfirmPass.Text);

                if (accountBLL.NewUser(newUser))
                {
                    MessageBox.Show("Registration Successful", "Success");
                    pbDropBox.Visible = true;
                    lblLinkDropBox.Visible = true;
                    btnDone.Visible = true;
                    btnRegister.Visible = false;
                    success = true;
                }
            }
            else
            {
                MessageBox.Show("Your passwords don't match!", "Error");
            }
        }
Пример #2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            Users cUser = new Users();

            if (UserLogin(cUser))
            {
                userToken = accountManager.GetToken(txtEmail.Text);
                userSecret = accountManager.GetSecret(txtEmail.Text);

                MessageBox.Show("Login Successful");

                DropTray dTray = new DropTray();
                dTray.Email = txtEmail.Text;
                dTray.UserToken = userToken;
                dTray.UserSecret = userSecret;
                dTray.UserPassword = txtPassword.Text;
                dTray.Show();

                this.Hide();
                return;
            }
            else
            {
                MessageBox.Show("Login Unsuccessful" + Environment.NewLine + "Please check your details and internet connection!","Error");
            }
        }
        public bool CreateUser(Users newUser)
        {
            bool userCreated = false;

            using (myCxn = new MySqlConnection(this.ConnectionString))
            {
                using (myCmd = new MySqlCommand("spNewUser", myCxn))
                {
                    myCmd.CommandType = CommandType.StoredProcedure;

                    myCmd.Parameters.Add("pFirstName", MySqlDbType.VarChar, 50).Value = newUser.FirstName;
                    myCmd.Parameters.Add("pSurname", MySqlDbType.VarChar, 50).Value = newUser.Surname;
                    myCmd.Parameters.Add("pEmail", MySqlDbType.VarChar, 50).Value = newUser.Email;
                    myCmd.Parameters.Add("pUserPassword", MySqlDbType.VarChar, 256).Value = newUser.Password;
                    myCmd.Parameters.Add("pUserID", MySqlDbType.Int16).Direction = ParameterDirection.Output;

                    myCxn.Open();
                    myCmd.ExecuteNonQuery();
                    myCxn.Close();

                    userCreated = true;
                }

                if (userCreated)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
        }
 public bool UserLogin(Users currentUser)
 {
     return userDAL.UserLoginNew(currentUser);
 }
 public bool NewUser(Users newUser)
 {
     return userDAL.CreateUser(newUser);
 }
Пример #6
0
        bool UserLogin(Users currentUsers)
        {
            currentUser.Email = txtEmail.Text;
            currentUser.Password = txtPassword.Text;// EncryptPassword.Encrypt(txtPassword.Text);

            return accountManager.UserLogin(currentUser);
        }
        public bool UserLoginNew(Users currentUser)
        {
            using (myCxn = new MySqlConnection(this.ConnectionString))
            {
                using (myCmd = new MySqlCommand("spUserLoginNew", myCxn))
                {
                    myCmd.CommandType = CommandType.StoredProcedure;

                    myCxn.Open();
                    if (myCxn.State == ConnectionState.Open)
                    {
                        myCmd.Parameters.Add("pEmail", MySqlDbType.VarChar, 50).Value = currentUser.Email;

                        MySqlDataReader myReader = myCmd.ExecuteReader();

                        while (myReader.Read())
                        {
                            string eMail = myReader["Email"].ToString();
                            string pass = myReader["UserPassword"].ToString();

                            if (eMail == currentUser.Email && pass == currentUser.Password)
                            {
                                Success = true;
                                break;
                            }
                            else
                                return false;
                        }

                        myReader.Close();
                        myCxn.Close();
                    }
                    else
                    {
                        return false;
                    }
                }
                return Success;
            }
        }