Example #1
0
        /// <summary>
        /// Change pass if button is pressed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Click(object sender, RoutedEventArgs e)
        {
            var dbTransaction = _db.BeginTransaction();

            try
            {
                InsertUser();
                var x = 0;

                var t = 1 / x;
                InsertAudit();
                InsertUserHist();
                dbTransaction.Commit();
                MessageBox.Show("Password has been changed");
                var a = new After_login(_user);
                a.Show();
                this.Hide();
            }
            catch
            {
                dbTransaction.Rollback();
                MessageBox.Show("An error has occured");
            }
            dbTransaction.Dispose();
        }
Example #2
0
        /// <summary>
        /// Trying to connect to the db
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            String DB            = _dataBaseCombo.SelectionBoxItem.ToString();
            String acquired_pass = GetCredential(DB, user.Text); //Get user credentials

            //  Debug.Assert(GetCredential("Bond_calculator") == null);
            if (Connect(user.Text, acquired_pass))   // if a password is saved in CredentialManager
            {
                this.Hide();
                var afterLogin = new After_login(user.Text); //Go to the Login App page
                afterLogin.Show();
                _ok = true;
            }
            else if (Connect(user.Text, pass.Password)) // if the password stored in the user table matches the pass from passwordbox go; otherwise retry
            {
                this.Hide();
                var after_Login = new After_login(user.Text);
                after_Login.Show();
                SetCredentials(DB, user.Text, pass.Password, PersistanceType.LocalComputer);
                _ok = true;
            }
            if (_ok == false)   // if login failed try again for 3 times max.
            {
                _i++;
                MessageBox.Show("Try again!" + "\n" + "You have tried " + _i + " out of 3");
                //this.Close();
            }
            if (_i >= 3)
            {
                MessageBox.Show("Bye");
                Application.Current.Shutdown();
            }
        }