Example #1
0
        private void btnChgPwd_Click(object sender, EventArgs e)
        {
            bool changed = false;
            try
            {
                PasswordForm pwdform = new PasswordForm();
                pwdform.ShowDialog(this);
                //try to change the password for this user.
                if (pwdform.Password != null)
                {
                    UserStorageView[] users = new UserStorageView[1];
                    users[0] = _User;
                    _User.Password = pwdform.Password;
                    console.Manager.Admon_UpdateUsers(console.Credentials, users);

                    changed = true;

                    //update the console credentials if needed
                    if (console.Credentials.Username == _User.Username)
                    {
                        console.Credentials.Password = pwdform.Password;
                    }
                }
            }
            catch (Exception ex)
            {
                changed = false;
                MessageBox.Show("Error changing password:" + ex.Message, "Change Password", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                if (changed)
                {
                    MessageBox.Show("Password changed successfully.", "Change Password", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Example #2
0
        void ShowForm()
        {
            if ( this.form == null )
            {
                this.form = new PasswordForm( this );
            }

            this.form.ShowTheWindow();
        }
Example #3
0
    //**********************************************
    // event handling method for "Log In" Button
    //
    public void LogInButtonClicked(object source, EventArgs e)
    {
        // First, clear the fields reflecting the
          // previous student's information.
          ClearFields();

          //  Display password dialog
          passwordDialog = new PasswordForm();
          passwordDialog.ShowDialog(this);

          string password = passwordDialog.Password;
          string id = passwordDialog.Id;
          passwordDialog.Dispose();

          // We'll try to construct a Student based on
          // the id we read, and if a file containing
          // Student's information cannot be found,
          // we have a problem.

          currentUser = new Student(id+".dat");
          currentUser.ReadStudentData(schedule);

          // Test to see if the Student fields were properly
          // initialized. If not, reset currentUser to null
          // and display a message box

          if (!currentUser.StudentSuccessfullyInitialized()) {
        // Drat!  The ID was invalid.
        currentUser = null;

        // Let the user know that login failed,
        string message = "Invalid student ID; please try again.";
        MessageBox.Show(message, "Invalid Student ID",
                 MessageBoxButtons.OK, MessageBoxIcon.Warning);
          }
          else {
        // We have a valid Student.  Now, we need
        // to validate the password.

        if (currentUser.ValidatePassword(password)) {

          // Let the user know that the login succeeded.
          string message =
               "Log in succeeded for " + currentUser.Name + ".";
          MessageBox.Show(message, "Log In Succeeded",
                 MessageBoxButtons.OK, MessageBoxIcon.Information);

          // Load the data for the current user into the TextBox and
          // ListBox components.
          SetFields(currentUser);
        }
        else {
          // The id was okay, but the password validation failed;
          // notify the user of this.
          currentUser = null;
          string message = "Invalid password; please try again.";
          MessageBox.Show(message, "Invalid Password",
                 MessageBoxButtons.OK, MessageBoxIcon.Warning);
        }
          }
          // Check states of the various buttons.
          ResetButtons();
    }
Example #4
0
 void FormClosedHandler( object sender, EventArgs e )
 {
     this.form = null;
 }
Example #5
0
        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            using (var dlg = new PasswordForm())
            {
                var dr = dlg.ShowDialog(this);
                if (dr == System.Windows.Forms.DialogResult.Cancel)
                {
                    e.Cancel = true;
                    return;
                }
            }

            if (Properties.Settings.Default.StartInFullScreen)
            {
                EnterFullScreenMode(false);
            }

            controller.Stop();

            if ((thread != null) && (thread.IsAlive))
            {
                thread.Abort();
            }

            if (lastSelCamID != null)
            {
                Properties.Settings.Default.LastSelCamID = (int)this.lastSelCamID;
            }
            try
            {
                _navController.NavReturnDefultPos();
            }
            catch { }

            Properties.Settings.Default.WorkingMode = (int)switchMode.EditValue;
            Debug.WriteLine(Properties.Settings.Default.WorkingMode);
            Properties.Settings.Default.Save();

            dockManager1.SaveLayoutToXml(GetLayoutPath());
        }