BOOK-IQ4TD9B9LB\DIT-930
2023-05-15 f5120e92b525474f6b4e50130797946986c28eed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
using SA_LTT.UserInfo;
using System;
using System.Windows.Forms;
using System.Linq;
 
namespace SA_LTT_UI.Viewer
{
    public partial class CreateUserViewer : Form
    {
        MainFrame _mainFrame;
 
        public User user = new User();
 
        public CreateUserViewer(MainFrame mainFrame)
        {
            InitializeComponent();
 
            _mainFrame = mainFrame;
            
            Initialize();
        }
 
        private void Initialize()
        {
            foreach(UserLevel level in Enum.GetValues(typeof(UserLevel)))
            {
                if (level > _mainFrame.equipment.User.Level)
                    break;
 
                cbb_Level.Items.Add(level.ToString());
            }
 
            cbb_Level.SelectedIndex = 0;
        }
 
        private void tb_Password_MouseDown(object sender, MouseEventArgs e)
        {
            tb_Password.PasswordChar = '\0';
        }
 
        private void tb_Password_MouseUp(object sender, MouseEventArgs e)
        {
            tb_Password.PasswordChar = '*';
        }
 
        private void btn_Ok_Click(object sender, EventArgs e)
        {
            if (tb_Name.Text == string.Empty || tb_Password.Text == string.Empty || tb_Name.Text.Contains(" ") || tb_Password.Text.Contains(" "))
            {
                MessageBox.Show("공백은 입력할 수 없습니다.");
                return;
            }
 
            if (_mainFrame.equipment.userManager.ExistsUser(tb_Name.Text) == false)
            {
                UserLevel _level;
                Enum.TryParse(cbb_Level.Text, out _level);
 
                user.Name = tb_Name.Text;
                user.Password = tb_Password.Text;
                user.Level = _level;
 
                char[] nameExceptList = new char[] { '\\', '/', ':', '*', '?', '"', '<', '>', '|' };
 
                foreach (char exceptChar in nameExceptList)
                {
                    if (user.Name.Contains(exceptChar))
                    {
                        MessageBoxPad messageBox = new MessageBoxPad("파일 이름에는 다음 문자를 사용할 수 없습니다. \r\n \\ / : * ? \" < > | ");
                        messageBox.Show();
                        return;
                    }
                }
 
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            else
            {
                MessageBox.Show("이미 존재하는 이름입니다.");
            }
        }
 
        private void btn_Cancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }
    }
}