Subversion Repositories Code-Repo

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
9 Kevin 1
using System;
2
using System.Collections.Generic;
3
using System.ComponentModel;
4
using System.Data;
5
using System.Drawing;
6
using System.Linq;
7
using System.Text;
8
using System.Windows.Forms;
9
 
10
namespace SWAT_Office_App
11
{
12
    public partial class ResetUserPassword_Form : Form
13
    {
14
        private string selectedUsername;
15
        public ResetUserPassword_Form(string selectedUser)
16
        {
17
            selectedUsername = selectedUser;
18
            InitializeComponent();
19
            this.txt_Password1.Focus();
20
            this.lbl_Prompt2.Visible = false;
21
 
22
            // Monitors the text in each textbox, triggering changes when certain criteria is met
23
            this.txt_Password1.TextChanged += new EventHandler(this.txt_Box1_TextChanged);
24
            this.txt_Password2.TextChanged += new EventHandler(this.txt_Box2_TextChanged);
25
        }
26
        private void txt_Box1_TextChanged(object sender, EventArgs e)
27
        {
53 Kevin 28
            if (txt_Password1.Text == Settings_Form.globalAdminPassword)
9 Kevin 29
            {
30
                this.txt_Password1.Visible = false;
31
                this.txt_Password2.Visible = true;
32
                this.lbl_Prompt1.Visible = false;
33
                this.lbl_Prompt2.Visible = true;
34
                this.txt_Password2.Focus();
35
            }
36
        }
37
        private void txt_Box2_TextChanged(object sender, EventArgs e)
38
        {
39
            TextBox tb = (TextBox)sender;
40
            if (tb.Text.Length == 0)
41
                this.btn_Ok.Enabled = false;
42
            else
43
                this.btn_Ok.Enabled = true;
44
        }
45
        private void btn_Cancel_Click(object sender, EventArgs e)
46
        {
47
            this.Close();
48
        }
49
        private void btn_Ok_Click(object sender, EventArgs e)
50
        {
53 Kevin 51
            if (!ManageUserAccounts.ChangeUserPassword(selectedUsername, txt_Password2.Text))
52
            {
53
                DebugText.appendText("Error occured while changing password");
54
                MessageBox.Show("Error occured while changing password", "Error");
55
            }
9 Kevin 56
            this.Close();
57
        }
58
    }
59
}