Exemple #1
0
        private void ChangePasswordForm_Load(object sender, EventArgs e)
        {
            OldPasswordTextbox.ResetText();
            ConfirmPasswordTextbox.ResetText();
            NewPasswordTextbox.Focus();

            //EXCEPTION 1
            try
            {
                variables           = new Variables();
                opacityform         = new OpacityForm();
                cryptography        = new Cryptography();
                sqlconnectionconfig = new SQLConnectionConfig();

                RegistryKey registrykey = Registry.CurrentUser.OpenSubKey(@variables.pathname);
                string      tempdata    = registrykey.GetValue("SQLServerConnectionString").ToString();
                currentuserid = registrykey.GetValue("User ID").ToString();

                //USER SQLSERVER CONNECTION SETTINGS
                sqlconnectionconfig.SqlConnectionString = cryptography.Decrypt(tempdata);
                sqlconnection = new SqlConnection(sqlconnectionconfig.SqlConnectionString);
                sqlconnection.Open();

                //INNER EXCEPTION 1
                try
                {
                    sqlquery1  = "SELECT PASSWORD FROM [Tbl.Users] WHERE [USER ID] = '" + currentuserid + "'";
                    sqlcommand = new SqlCommand(sqlquery1, sqlconnection);
                    SqlDataReader sqldatareader = sqlcommand.ExecuteReader();

                    while (sqldatareader.Read())
                    {
                        OldPasswordTextbox.Text = cryptography.Decrypt(sqldatareader.GetString(0));
                    }
                    sqldatareader.Close();
                }

                catch (Exception exception)
                {
                    opacityform.Show();
                    MessageBox.Show(exception.Message.ToString(), "@Change Password Form Inner Exception 1",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);

                    opacityform.Hide();
                }
            }

            catch (Exception exception)
            {
                opacityform.Show();
                MessageBox.Show(exception.Message.ToString(), "@Change Password Form Exception 1",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);

                opacityform.Hide();
            }
        }
Exemple #2
0
        private bool ChangeUsernamePasswordValidation()
        {
            int length = UsernameTB.Text.Length;

            if (length < 5)
            {
                MessageBox.Show("Username should be at least 6 character long.", "Error !", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }

            length = 0;
            length = PasswordTB.Text.Length;
            if (length < 7)
            {
                MessageBox.Show("New Password should be at least 8 character long.", "Error !", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }

            if (userName == string.Empty || userName != UsernameTB.Text)
            {
                if (userAccount.CheckForUserName(UsernameTB.Text))
                {
                    MessageBox.Show("Username : '******' already exists. Please enter unique Username.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    UsernameTB.Focus();
                    return(false);
                }
            }

            if (!userAccount.CheckOldPassword(OldPasswordTextbox))
            {
                OldPasswordTextbox.Focus();
                return(false);
            }

            //check new password and renew password
            if (!(ReEnterPassword.Text == PasswordTB.Text))
            {
                MessageBox.Show("Repassword didn't matched.", "Error !", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return(false);
            }

            return(true);
        }