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();
|
}
|
}
|
}
|