예제 #1
0
        private bool addSwitch()
        {
            foreach (SwitchInfo sw in MainForm.switches)
            {
                if (sw.Name.ToLower().Equals(txtName.Text.ToLower().Trim()))
                {
                    MessageBox.Show("That switch name is already in use, please try something else.", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return(false);
                }

                if (sw.Address.ToLower().Equals(txtAddress.Text.ToLower().Trim()))
                {
                    MessageBox.Show("That switch address is already in use, please try something else.", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return(false);
                }
            }

            SwitchInfo swtch = new SwitchInfo(txtName.Text, txtAddress.Text, txtUserName.Text, Functions.EncryptPassword(txtPassword.Text));

            MainForm.switches.Add(swtch);
            return(true);
        }