Subversion Repositories Code-Repo

Rev

Blame | Last modification | View Log | RSS feed

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SWAT_Office_App
{
    public partial class AddSystemAccount_Form : Form
    {
        public AddSystemAccount_Form()
        {
            InitializeComponent();
            this.btn_Ok.Enabled = false;

            this.txt_AddSystemAccount.TextChanged += new EventHandler(this.txt_TextChanged);
        }
        private void txt_TextChanged(object sender, EventArgs e)
        {
            TextBox tb = (TextBox)sender;
            if (tb.Text.Length == 0)
                this.btn_Ok.Enabled = false;
            else
                this.btn_Ok.Enabled = true;
        }
        private void btn_Cancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        private void btn_Ok_Click(object sender, EventArgs e)
        {
            bool error = false;
            // Checks if account already exists in the list of system accounts
            foreach (string systemUser in Settings_Form.systemAccounts)
            {
                if (this.txt_AddSystemAccount.Text.ToLower() == systemUser.ToLower())
                {
                    MessageBox.Show("Account is already in the list of system accounts", "Error");
                    error = true;
                    this.txt_AddSystemAccount.Text = "";
                    this.txt_AddSystemAccount.Focus();
                }
            }
            if (error == false)
            {
                Settings_Form.systemAccounts.Add(txt_AddSystemAccount.Text);
                this.Close();
            }
        }
    }
}