Subversion Repositories Code-Repo

Rev

Rev 63 | Details | Compare with Previous | 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
{
63 Kevin 12
    public partial class Add_System_Account_Form : Form
9 Kevin 13
    {
63 Kevin 14
        public Add_System_Account_Form()
9 Kevin 15
        {
16
            InitializeComponent();
17
            this.btn_Ok.Enabled = false;
18
 
19
            this.txt_AddSystemAccount.TextChanged += new EventHandler(this.txt_TextChanged);
20
        }
21
        private void txt_TextChanged(object sender, EventArgs e)
22
        {
23
            TextBox tb = (TextBox)sender;
24
            if (tb.Text.Length == 0)
25
                this.btn_Ok.Enabled = false;
26
            else
27
                this.btn_Ok.Enabled = true;
28
        }
29
        private void btn_Cancel_Click(object sender, EventArgs e)
30
        {
31
            this.Close();
32
        }
33
        private void btn_Ok_Click(object sender, EventArgs e)
34
        {
35
            bool error = false;
36
            // Checks if account already exists in the list of system accounts
37
            foreach (string systemUser in Settings_Form.systemAccounts)
38
            {
39
                if (this.txt_AddSystemAccount.Text.ToLower() == systemUser.ToLower())
40
                {
41
                    MessageBox.Show("Account is already in the list of system accounts", "Error");
42
                    error = true;
43
                    this.txt_AddSystemAccount.Text = "";
44
                    this.txt_AddSystemAccount.Focus();
45
                }
46
            }
47
            if (error == false)
48
            {
49
                Settings_Form.systemAccounts.Add(txt_AddSystemAccount.Text);
50
                this.Close();
51
            }
52
        }
53
    }
54
}