INT_PT002/INT_PT002/Controls/User/ControlMenuUserUserEditor.cs

978 lines
45 KiB
C#

using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using INT_PT002.Forms;
using INT_PT002.DialogForms;
using INT_PT002.Part11_UserManager;
using INT_PT002.DataStore;
namespace INT_PT002.Controls
{
public partial class ControlMenuUserUserEditor : UserControl
{
#region Field
private FormMenu m_ParentForm;
private UserItem CurrentUserItem;
#endregion
#region Constructor
public ControlMenuUserUserEditor(FormMenu parent)
{
InitializeComponent();
this.ParentForm = parent;
this.Initialize();
}
#endregion
#region Property
public FormMenu ParentForm
{
get { return this.m_ParentForm; }
private set { this.m_ParentForm = value; }
}
#endregion
#region Method
private void Initialize()
{
this.smartGroupBox1.Text = "User > UserEditor";
}
private void KeyboardClose()
{
this.smartKeyboard.Hide();
this.buttonRegister.Enabled = true;
this.buttonDelete.Enabled = true;
this.groupBoxAccessRight.Enabled = true;
this.listBoxUserList.Enabled = true;
this.textBoxPassword.Enabled = true;
this.buttonPasswordEdit.Enabled = true;
this.textBoxID.Enabled = true;
this.buttonIDEdit.Enabled = true;
if(this.buttonSave.Visible == false)
this.buttonSave.Visible = true;
}
private void ChangeUserControlEnable(bool enable)
{
this.listBoxUserList.Enabled = enable;
this.smartGroupBox1.Enabled = enable;
}
private void UserNew()
{
this.listBoxUserList.SelectedIndexChanged -= new EventHandler(this.listBoxUserList_SelectedIndexChanged);
this.listBoxUserList.SelectItemIndex = -1;
this.listBoxUserList.SelectedIndexChanged += new EventHandler(this.listBoxUserList_SelectedIndexChanged);
this.UpdateInitializeUserDisplay();
this.buttonDelete.Enabled = false;
this.buttonSave.Visible = true;
this.buttonSave.Enabled = true;
this.textBoxID.Enabled = true;
this.textBoxPassword.Enabled = true;
this.labelExpiryDateOfAccount.Enabled = true;
this.labelExpiryDateOfPassword.Enabled = true;
this.labelAutomaticLogoutTime.Enabled = true;
}
private void SaveUserDll()
{
string detail = "";
string code = "", message1 = "", message2 = "";
bool isNewReg = false;
#region listbox 미선택 시 신규 유저 등록, 선택 시 기존 유저 정보 수정
if (this.listBoxUserList.SelectItemIndex == -1)
isNewReg = true;
else
isNewReg = false;
if (isNewReg == true)
{
switch (this.ParentForm.ParentForm.SystemConfig.LANGUAGE)
{
case Define.E_LanguageID.Korean:
code = "유저 설정";
message1 = "신규 사용자 추가 하시겠습니까?";
message2 = "";
break;
case Define.E_LanguageID.English:
code = "User Editor";
message1 = "Would you like to register as a user?";
message2 = "";
break;
default:
break;
}
}
else
{
switch (this.ParentForm.ParentForm.SystemConfig.LANGUAGE)
{
case Define.E_LanguageID.Korean:
code = "유저 설정";
message1 = "선택된 사용자의 정보를 수정 하시겠습니까?";
message2 = "";
break;
case Define.E_LanguageID.English:
code = "User Editor";
message1 = "Are you sure you want to edit the";
message2 = "selected user's information?";
break;
default:
break;
}
}
#endregion
DialogFormYesNo dlg = new DialogFormYesNo(Define.E_MessageBoxIcon.Question, code, message1, message2);
if (dlg.ShowDialog() == DialogResult.Yes)
{
UserItem item = new UserItem();
DateTime time = DateTime.Now;
UserManager.MenuID_t menuId = new UserManager.MenuID_t();
#region ID, Password 검사
// Check ID
if (isNewReg == true)
{
if (this.textBoxID.Text.Length < 6)
{
// ID : 6~20자 입력하세요
DialogFormMessage msg = new DialogFormMessage(null, 3, this.ParentForm.ParentForm.SystemConfig.LANGUAGE);
msg.ShowDialog();
return;
}
}
// Check Password
if (this.textBoxPassword.Text.Length < 6)
{
// PASSWORD : 6~20자 입력하세요
DialogFormMessage msg = new DialogFormMessage(null, 9, this.ParentForm.ParentForm.SystemConfig.LANGUAGE);
msg.ShowDialog();
return;
}
#endregion
item.ID = this.textBoxID.Text;
item.SetPassword(this.textBoxPassword.Text);
item.ExpireAccount = int.Parse(this.labelExpiryDateOfAccount.Text);
item.ExpirePassword = int.Parse(this.labelExpiryDateOfPassword.Text);
//item.IsAdmin = this.cbAdministrator.Checked;
menuId.fMenu = new bool[UserManager.USER_MENU_ID_MAX];
menuId.fMenu[0] = this.checkBoxMainProductChange.Checked;
menuId.fMenu[1] = this.checkBoxMainWeightSetting.Checked;
menuId.fMenu[2] = this.checkBoxMainClear.Checked;
menuId.fMenu[3] = this.checkBoxMainSubMenu.Checked;
menuId.fMenu[4] = this.checkBoxMenuProduct.Checked;
menuId.fMenu[5] = this.checkBoxMenuConfiguration.Checked;
menuId.fMenu[6] = this.checkBoxMenuCommunication.Checked;
menuId.fMenu[7] = this.checkBoxMenuUserSetting.Checked;
menuId.fMenu[8] = this.checkBoxMenuUserGroupEditor.Checked;
menuId.fMenu[9] = this.checkBoxMenuIOTest.Checked;
menuId.fMenu[10] = this.checkBoxMenuMotorSetting.Checked;
menuId.fMenu[11] = this.checkBoxMenuEquipmentLog.Checked;
menuId.fMenu[12] = this.checkBoxMenuCheckLog.Checked;
menuId.fMenu[13] = this.checkBoxMenuAlarmList.Checked;
menuId.fMenu[14] = this.checkBoxMenuInformation.Checked;
menuId.fMenu[15] = this.checkBoxMenuEquipmentSetting.Checked;
menuId.fMenu[16] = this.checkBoxMenuTime.Checked;
for (int i = 17; i < UserManager.USER_MENU_ID_MAX - 16; i++)
menuId.fMenu[i] = false;
if (this.buttonLevel1.ButtonStatus == SmartX.SmartButton.BUTSTATUS.DOWN)
menuId.fMenu[25] = true;
if (this.buttonLevel2.ButtonStatus == SmartX.SmartButton.BUTSTATUS.DOWN)
menuId.fMenu[26] = true;
if (this.buttonLevel3.ButtonStatus == SmartX.SmartButton.BUTSTATUS.DOWN)
menuId.fMenu[27] = true;
if (isNewReg == true)
{
#region 신규 등록
UserManager.UserManager_UserNew(item.ID, item.Password, item.IsAdmin == false ? 0 : 1, item.ExpirePassword, item.ExpireAccount, menuId);
// Part 11
detail = string.Format("Add : {0}", item.ID);
this.ParentForm.ParentForm.SetTrackingHistoryData(Define.E_TrackingOperation.UserEditor, detail);
#endregion
}
else
{
#region 유저 수정
UserManager.UserManager_UserModify(item.ID, item.Password, item.IsAdmin == false ? 0 : 1, item.ExpirePassword, item.ExpireAccount, menuId);
// Part 11
detail = string.Format("Modify : {0}", item.ID);
this.ParentForm.ParentForm.SetTrackingHistoryData(Define.E_TrackingOperation.UserEditor, detail);
#endregion
}
}
}
private void CheckBoxCheckedAsLevel(Define.E_UserGroup level)
{
this.buttonLevel1.Click -= new EventHandler(this.buttonLevel_Click);
this.buttonLevel2.Click -= new EventHandler(this.buttonLevel_Click);
this.buttonLevel3.Click -= new EventHandler(this.buttonLevel_Click);
switch (level)
{
case Define.E_UserGroup.f0_Level1:
this.buttonLevel2.ButtonUp();
this.buttonLevel3.ButtonUp();
this.buttonLevel1.ButtonDown();
this.labelAccessRight.Text = this.ParentForm.ParentForm.SystemConfig.LEVEL1_NAME;
this.checkBoxMainProductChange.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsMainDisplayProductChange;
this.checkBoxMainWeightSetting.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsMainDisplayWeightSetting;
this.checkBoxMainClear.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsMainDisplayClear;
this.checkBoxMainSubMenu.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsMainDisplaySubMenu;
this.checkBoxMenuProduct.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsMenuProduct;
this.checkBoxMenuConfiguration.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsMenuConfiguration;
this.checkBoxMenuCommunication.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsMenuCommunication;
this.checkBoxMenuUserSetting.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsMenuUserSetting;
this.checkBoxMenuUserGroupEditor.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsMenuUserGroupEditor;
this.checkBoxMenuIOTest.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsMenuIOTest;
this.checkBoxMenuMotorSetting.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsMenuMotorSetting;
this.checkBoxMenuEquipmentLog.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsMenuEquipmentLog;
this.checkBoxMenuCheckLog.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsMenuCheckLog;
this.checkBoxMenuAlarmList.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsMenuAlarmList;
this.checkBoxMenuInformation.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsMenuInformation;
this.checkBoxMenuEquipmentSetting.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsMenuEquipmentSetting;
this.checkBoxMenuTime.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsMenuTimeSetting;
break;
case Define.E_UserGroup.f1_Level2:
this.buttonLevel1.ButtonUp();
this.buttonLevel3.ButtonUp();
this.buttonLevel2.ButtonDown();
this.labelAccessRight.Text = this.ParentForm.ParentForm.SystemConfig.LEVEL2_NAME;
this.checkBoxMainProductChange.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsMainDisplayProductChange;
this.checkBoxMainWeightSetting.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsMainDisplayWeightSetting;
this.checkBoxMainClear.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsMainDisplayClear;
this.checkBoxMainSubMenu.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsMainDisplaySubMenu;
this.checkBoxMenuProduct.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsMenuProduct;
this.checkBoxMenuConfiguration.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsMenuConfiguration;
this.checkBoxMenuCommunication.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsMenuCommunication;
this.checkBoxMenuUserSetting.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsMenuUserSetting;
this.checkBoxMenuUserGroupEditor.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsMenuUserGroupEditor;
this.checkBoxMenuIOTest.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsMenuIOTest;
this.checkBoxMenuMotorSetting.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsMenuMotorSetting;
this.checkBoxMenuEquipmentLog.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsMenuEquipmentLog;
this.checkBoxMenuCheckLog.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsMenuCheckLog;
this.checkBoxMenuAlarmList.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsMenuAlarmList;
this.checkBoxMenuInformation.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsMenuInformation;
this.checkBoxMenuEquipmentSetting.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsMenuEquipmentSetting;
this.checkBoxMenuTime.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsMenuTimeSetting;
break;
case Define.E_UserGroup.f2_Level3:
this.buttonLevel1.ButtonUp();
this.buttonLevel2.ButtonUp();
this.buttonLevel3.ButtonDown();
this.labelAccessRight.Text = this.ParentForm.ParentForm.SystemConfig.LEVEL3_NAME;
this.checkBoxMainProductChange.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsMainDisplayProductChange;
this.checkBoxMainWeightSetting.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsMainDisplayWeightSetting;
this.checkBoxMainClear.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsMainDisplayClear;
this.checkBoxMainSubMenu.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsMainDisplaySubMenu;
this.checkBoxMenuProduct.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsMenuProduct;
this.checkBoxMenuConfiguration.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsMenuConfiguration;
this.checkBoxMenuCommunication.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsMenuCommunication;
this.checkBoxMenuUserSetting.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsMenuUserSetting;
this.checkBoxMenuUserGroupEditor.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsMenuUserGroupEditor;
this.checkBoxMenuIOTest.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsMenuIOTest;
this.checkBoxMenuMotorSetting.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsMenuMotorSetting;
this.checkBoxMenuEquipmentLog.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsMenuEquipmentLog;
this.checkBoxMenuCheckLog.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsMenuCheckLog;
this.checkBoxMenuAlarmList.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsMenuAlarmList;
this.checkBoxMenuInformation.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsMenuInformation;
this.checkBoxMenuEquipmentSetting.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsMenuEquipmentSetting;
this.checkBoxMenuTime.Checked = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsMenuTimeSetting;
break;
default:
break;
}
this.buttonLevel1.Click += new EventHandler(this.buttonLevel_Click);
this.buttonLevel2.Click += new EventHandler(this.buttonLevel_Click);
this.buttonLevel3.Click += new EventHandler(this.buttonLevel_Click);
}
private void UpdateInitializeUserDisplay()
{
this.CurrentUserItem = new UserItem();
this.textBoxID.Text = "";
this.textBoxPassword.Text = "";
this.labelExpiryDateOfAccount.Text = "000";
this.labelExpiryDateOfPassword.Text = "00";
this.labelExpiryDateOfAccount2.Text = "yyyy.mm.DD";
this.labelExpiryDateOfPassword2.Text = "yyyy.mm.DD";
this.labelAutomaticLogoutTime.Text = "00";
this.labelAccessRight.Text = "";
this.checkBoxMainProductChange.Checked = false;
this.checkBoxMainWeightSetting.Checked = false;
this.checkBoxMainClear.Checked = false;
this.checkBoxMainSubMenu.Checked = false;
this.checkBoxMenuProduct.Checked = false;
this.checkBoxMenuConfiguration.Checked = false;
this.checkBoxMenuCommunication.Checked = false;
this.checkBoxMenuUserSetting.Checked = false;
this.checkBoxMenuUserGroupEditor.Checked = false;
this.checkBoxMenuIOTest.Checked = false;
this.checkBoxMenuMotorSetting.Checked = false;
this.checkBoxMenuEquipmentLog.Checked = false;
this.checkBoxMenuCheckLog.Checked = false;
this.checkBoxMenuAlarmList.Checked = false;
this.checkBoxMenuInformation.Checked = false;
this.checkBoxMenuEquipmentSetting.Checked = false;
this.checkBoxMenuTime.Checked = false;
this.buttonDelete.Enabled = false;
}
public void UpdateLevelNameDisplay(SystemConfiguration system)
{
this.buttonLevel1.Text = system.LEVEL1_NAME;
this.buttonLevel2.Text = system.LEVEL2_NAME;
this.buttonLevel3.Text = system.LEVEL3_NAME;
}
private void UpdateCurrentUserItem(UserManager.UserMgr_user_list_t item)
{
// CurrentUserItem SET
this.CurrentUserItem.ID = item.user_id;
this.CurrentUserItem.Password = item.user_pw;
this.CurrentUserItem.ExpireAccount = item.expire_period_account;
this.CurrentUserItem.ExpirePassword = item.expire_period_pw;
DateTime time = DateTime.ParseExact(item.register_date.GetDateTime(), "yyyyMMddHHmmss", null);
this.CurrentUserItem.DateRegister = time;
time = DateTime.ParseExact(item.login_date.GetDateTime(), "yyyyMMddHHmmss", null);
this.CurrentUserItem.DateLogin = time;
time = DateTime.ParseExact(item.expire_account_date.GetDateTime(), "yyyyMMddHHmmss", null);
this.CurrentUserItem.DateExpireRegister = time;
time = DateTime.ParseExact(item.expire_register_date.GetDateTime(), "yyyyMMddHHmmss", null);
this.CurrentUserItem.DateExpireLogin = time;
this.CurrentUserItem.IsLockAccount = item.flock_status_account == 0 ? false : true;
this.CurrentUserItem.IsLockPassword = item.flock_status_password == 0 ? false : true;
this.CurrentUserItem.IsAdmin = item.fadmin == 0 ? false : true;
this.CurrentUserItem.IsMainProductChange = item.menuID.fMenu[0];
this.CurrentUserItem.IsMainWeightSetting = item.menuID.fMenu[1];
this.CurrentUserItem.IsMainClear = item.menuID.fMenu[2];
this.CurrentUserItem.IsMainSubMenu = item.menuID.fMenu[3];
this.CurrentUserItem.IsMenuProduct = item.menuID.fMenu[4];
this.CurrentUserItem.IsMenuConfiguration = item.menuID.fMenu[5];
this.CurrentUserItem.IsMenuCommunication = item.menuID.fMenu[6];
this.CurrentUserItem.IsMenuUserSetting = item.menuID.fMenu[7];
this.CurrentUserItem.IsMenuUserGroupEditor = item.menuID.fMenu[8];
this.CurrentUserItem.IsMenuIOTest = item.menuID.fMenu[9];
this.CurrentUserItem.IsMenuMotorSetting = item.menuID.fMenu[10];
this.CurrentUserItem.IsMenuEquipmentLog = item.menuID.fMenu[11];
this.CurrentUserItem.IsMenuCheckLog = item.menuID.fMenu[12];
this.CurrentUserItem.IsMenuAlarmList = item.menuID.fMenu[13];
this.CurrentUserItem.IsMenuInformation = item.menuID.fMenu[14];
this.CurrentUserItem.IsMenuEquipmentSetting = item.menuID.fMenu[15];
this.CurrentUserItem.IsMenuTimeSetting = item.menuID.fMenu[16];
if (item.menuID.fMenu[25] == true)
this.CurrentUserItem.UserGroup = Define.E_UserGroup.f0_Level1;
else if(item.menuID.fMenu[26] == true)
this.CurrentUserItem.UserGroup = Define.E_UserGroup.f1_Level2;
else if(item.menuID.fMenu[27] == true)
this.CurrentUserItem.UserGroup = Define.E_UserGroup.f2_Level3;
}
private void UpdateCurrentUserItem(UserManager.UserMgr_user_info_t item)
{
// CurrentUserItem SET
this.CurrentUserItem.ID = item.user_id;
this.CurrentUserItem.Password = item.user_pw;
this.CurrentUserItem.ExpireAccount = item.expire_period_account;
this.CurrentUserItem.ExpirePassword = item.expire_period_pw;
DateTime time = DateTime.ParseExact(item.register_date.GetDateTime(), "yyyyMMddHHmmss", null);
this.CurrentUserItem.DateRegister = time;
time = DateTime.ParseExact(item.login_date.GetDateTime(), "yyyyMMddHHmmss", null);
this.CurrentUserItem.DateLogin = time;
time = DateTime.ParseExact(item.expire_account_date.GetDateTime(), "yyyyMMddHHmmss", null);
this.CurrentUserItem.DateExpireRegister = time;
time = DateTime.ParseExact(item.expire_register_date.GetDateTime(), "yyyyMMddHHmmss", null);
this.CurrentUserItem.DateExpireLogin = time;
this.CurrentUserItem.IsLockAccount = item.flock_status_account == 0 ? false : true;
this.CurrentUserItem.IsLockPassword = item.flock_status_password == 0 ? false : true;
this.CurrentUserItem.IsAdmin = item.fadmin == 0 ? false : true;
this.CurrentUserItem.IsMainProductChange = item.menuID.fMenu[0];
this.CurrentUserItem.IsMainWeightSetting = item.menuID.fMenu[1];
this.CurrentUserItem.IsMainClear = item.menuID.fMenu[2];
this.CurrentUserItem.IsMainSubMenu = item.menuID.fMenu[3];
this.CurrentUserItem.IsMenuProduct = item.menuID.fMenu[4];
this.CurrentUserItem.IsMenuConfiguration = item.menuID.fMenu[5];
this.CurrentUserItem.IsMenuCommunication = item.menuID.fMenu[6];
this.CurrentUserItem.IsMenuUserSetting = item.menuID.fMenu[7];
this.CurrentUserItem.IsMenuUserGroupEditor = item.menuID.fMenu[8];
this.CurrentUserItem.IsMenuIOTest = item.menuID.fMenu[9];
this.CurrentUserItem.IsMenuMotorSetting = item.menuID.fMenu[10];
this.CurrentUserItem.IsMenuEquipmentLog = item.menuID.fMenu[11];
this.CurrentUserItem.IsMenuCheckLog = item.menuID.fMenu[12];
this.CurrentUserItem.IsMenuAlarmList = item.menuID.fMenu[13];
this.CurrentUserItem.IsMenuInformation = item.menuID.fMenu[14];
this.CurrentUserItem.IsMenuEquipmentSetting = item.menuID.fMenu[15];
this.CurrentUserItem.IsMenuTimeSetting = item.menuID.fMenu[16];
if (item.menuID.fMenu[25] == true)
this.CurrentUserItem.UserGroup = Define.E_UserGroup.f0_Level1;
else if (item.menuID.fMenu[26] == true)
this.CurrentUserItem.UserGroup = Define.E_UserGroup.f1_Level2;
else if (item.menuID.fMenu[27] == true)
this.CurrentUserItem.UserGroup = Define.E_UserGroup.f2_Level3;
}
private void UpdateSelectUserDisplay(UserItem item)
{
// 화면 Enable 처리 추가할것
this.ChangeUserControlEnable(true);
this.textBoxID.Enabled = false;
this.textBoxID.BackColor = Color.LightGray;
this.textBoxID.Text = item.ID;
this.textBoxPassword.Text = item.Password;
this.labelExpiryDateOfAccount.Text = item.ExpireAccount.ToString();
this.labelExpiryDateOfPassword.Text = item.ExpirePassword.ToString();
this.labelExpiryDateOfAccount2.Text = string.Format("{0:yyyy/MM/dd} ~ {1:yyyy/MM/dd}", item.DateRegister, item.DateExpireRegister);
this.labelExpiryDateOfPassword2.Text = string.Format("{0:yyyy/MM/dd} ~ {1:yyyy/MM/dd}", item.DateLogin, item.DateExpireLogin);
this.CheckBoxCheckedAsLevel(item.UserGroup);
//this.cbAdministrator.Visible = true;
//this.cbAdministrator.Checked = item.IsAdmin;
}
private void UpdateUserListBoxDisplay(List<string> items)
{
this.listBoxUserList.ClearAll();
for (int i = 1; i < items.Count; i++)
this.listBoxUserList.AddItem(items[i]);
}
//private void UpdateDefaultSetAccessrightDisplay(UserGroupItem item)
//{
// this.cbMainProductNo.Checked = item.IsMainDisplayProductNo;
// this.cbMainWeightSet.Checked = item.IsMainDisplayWeightSetting;
// this.cbMainClear.Checked = item.IsMainDisplayClear;
// this.cbMainSubMenu.Checked = item.IsMainDisplaySubMenu;
// this.cbMenuCalibration.Checked = item.IsMenuCalibration;
// this.cbMenuConfiguration.Checked = item.IsMenuConfiguration;
// this.cbMenuDataBackup.Checked = item.IsMenuDataBackup;
// this.cbMenuDataStatistics.Checked = item.IsMenuDataStatistics;
// this.cbMenuEquipmentSet.Checked = item.IsMenuEquipmentSetting;
// this.cbMenuFactoryReset.Checked = item.IsMenuFactoryReset;
// this.cbMenuInformation.Checked = item.IsMenuInformation;
// this.cbMenuIOTest.Checked = item.IsMenuIOTest;
// this.cbMenuMotorSet.Checked = item.IsMenuMotorSetting;
// this.cbMenuSystemSet.Checked = item.IsMenuSystemSetting;
// this.cbMenuTimeSet.Checked = item.IsMenuTimeSetting;
// this.cbMenuUpdate.Checked = item.IsMenuUpdate;
// this.cbMenuUserEditor.Checked = item.IsMenuUserSetting;
//}
public void CallBackGetUserData(UserManager.UserMgr_user_list_t user)
{
this.UpdateCurrentUserItem(user);
this.UI_Invoke(delegate
{
this.UpdateSelectUserDisplay(this.CurrentUserItem);
});
}
public void CallBackUserListNewData(UserManager.UserMgr_user_info_t user)
{
string code = "", message1 = "", message2 = "";
switch (this.ParentForm.ParentForm.SystemConfig.LANGUAGE)
{
case Define.E_LanguageID.Korean:
code = "유저설정";
message1 = "사용자 추가 완료!";
message2 = "";
break;
case Define.E_LanguageID.English:
code = "user settings";
message1 = "User addition complete!";
message2 = "";
break;
default:
break;
}
if (user.status == (int)UserManager.E_user_mgr_status.USER_MGR_STATUS_OK)
{
this.UI_Invoke(delegate
{
this.UpdateCurrentUserItem(user);
this.UpdateSelectUserDisplay(this.CurrentUserItem);
this.ParentForm.ParentForm.ListDllUserName.Add(user.user_id);
this.UpdateUserListBoxDisplay(this.ParentForm.ParentForm.ListDllUserName);
this.listBoxUserList.SelectItemIndex = this.listBoxUserList.ItemCount - 1;
this.textBoxID.Enabled = false;
this.textBoxID.BackColor = Color.LightGray;
this.textBoxPassword.Enabled = false;
this.textBoxPassword.BackColor = Color.LightGray;
this.labelExpiryDateOfAccount.Enabled = false;
this.labelExpiryDateOfAccount.BackColor = Color.LightGray;
this.labelExpiryDateOfPassword.Enabled = false;
this.labelExpiryDateOfPassword.BackColor = Color.LightGray;
this.labelAutomaticLogoutTime.Enabled = false;
this.labelAutomaticLogoutTime.BackColor = Color.LightGray;
this.buttonDelete.Enabled = true;
DialogFormMessage dlg = new DialogFormMessage(Define.E_MessageBoxIcon.Asterisk, code, message1, message2, 0);
dlg.ShowDialog();
});
}
else
{
DialogFormMessage msg = new DialogFormMessage(null, user.status, this.ParentForm.ParentForm.SystemConfig.LANGUAGE);
msg.ShowDialog();
}
}
public void CallBackUserModifyUserData(UserManager.UserMgr_user_modify_t user)
{
string code = "", message1 = "", message2 = "";
switch (this.ParentForm.ParentForm.SystemConfig.LANGUAGE)
{
case Define.E_LanguageID.Korean:
code = "유저설정";
message1 = "사용자 정보 수정 완료!";
message2 = "";
break;
case Define.E_LanguageID.English:
code = "user settings";
message1 = "User information modified!";
message2 = "";
break;
default:
break;
}
if (user.status == (int)UserManager.E_user_mgr_status.USER_MGR_STATUS_OK)
{
this.UI_Invoke(delegate
{
// 메시지 박스 교체
UserManager.UserManager_GetUserListID(this.listBoxUserList.Items[this.listBoxUserList.SelectItemIndex]);
DialogFormMessage dlg = new DialogFormMessage(Define.E_MessageBoxIcon.Asterisk, code, message1, message2, 0);
dlg.ShowDialog();
});
}
else
{
DialogFormMessage msg = new DialogFormMessage(null, user.status, this.ParentForm.ParentForm.SystemConfig.LANGUAGE);
msg.ShowDialog();
}
}
public void CallBackUserListLockDataEvent(UserManager.UserMgr_user_lock_t user)
{
if (user.user_id == this.CurrentUserItem.ID)
{
this.CurrentUserItem.IsLockAccount = user.flock_status_account == 0 ? false : true;
this.CurrentUserItem.IsLockPassword = user.flock_status_password == 0 ? false : true;
UserManager.UserManager_GetUserListID(this.listBoxUserList.Items[this.listBoxUserList.SelectItemIndex]);
}
}
public void CallBackUserListDeleteDataEvent(UserManager.UserMgr_user_del_t user)
{
string code = "", message1 = "", message2 = "", detail = "";
switch (this.ParentForm.ParentForm.SystemConfig.LANGUAGE)
{
case Define.E_LanguageID.Korean:
code = "유저설정";
message1 = string.Format("{0} 사용자 삭제 완료!", user.user_id);
message2 = "";
break;
case Define.E_LanguageID.English:
code = "user settings";
message1 = string.Format("{0} User deletion complete!", user.user_id);
message2 = "";
break;
default:
break;
}
if (user.status == 0)
{
for (int i = 0; i < this.ParentForm.ParentForm.ListDllUserName.Count; i++)
{
if (this.ParentForm.ParentForm.ListDllUserName[i] == user.user_id)
{
this.ParentForm.ParentForm.ListDllUserName.RemoveAt(i);
break;
}
}
this.UI_Invoke(delegate
{
this.UpdateUserListBoxDisplay(this.ParentForm.ParentForm.ListDllUserName);
this.UserNew();
DialogFormMessage dlg = new DialogFormMessage(Define.E_MessageBoxIcon.Asterisk, code, message1, message2, 0);
dlg.ShowDialog();
});
//// Part 11
//if (this.ParentForm.ParentForm.SystemConfig.IsPart11 == true)
//{
detail = string.Format("Delete : {0}", user.user_id);
this.ParentForm.ParentForm.SetTrackingHistoryData(Define.E_TrackingOperation.UserEditor, detail);
//}
}
else
{
DialogFormMessage msg = new DialogFormMessage(null, user.status, this.ParentForm.ParentForm.SystemConfig.LANGUAGE);
msg.ShowDialog();
}
}
public void CallBackUserListModifyInfoDataEvent(UserManager.UserMgr_user_info_t user)
{
//if (this.ChildControlUserSet.Visible == true)
//{
// this.ChildControlUserSet.CallBackUserListModifyInfoDataEvent(user);
//}
}
private bool UI_Invoke(ThreadStart invoker)
{
try
{
if (this.InvokeRequired)
{
if (this.IsDisposed)
return true;
this.Invoke(invoker);
}
else
{
invoker();
}
return true;
}
catch (Exception e)
{
return false;
}
}
public void DisplayRefresh()
{
this.UpdateInitializeUserDisplay();
if (this.buttonSave.Enabled == true)
this.buttonSave.Enabled = false;
}
#endregion
#region Event Handler
private void listBoxUserList_SelectedIndexChanged(object sender, EventArgs e)
{
int index = this.listBoxUserList.SelectItemIndex;
if (index != -1)
{
if (this.ParentForm.ParentForm.SystemConfig.CURRENT_USER.ID == this.listBoxUserList.Items[index])
this.buttonDelete.Enabled = false;
else
this.buttonDelete.Enabled = true;
this.ChangeUserControlEnable(true);
UserManager.UserManager_GetUserListID(this.listBoxUserList.Items[index]);
}
}
private void textBoxID_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == '\r')
{
e.Handled = true;
this.smartKeyboard.Hide();
this.buttonRegister.Enabled = true;
this.buttonDelete.Enabled = true;
this.groupBoxAccessRight.Enabled = true;
this.listBoxUserList.Enabled = true;
this.textBoxPassword.Enabled = true;
this.buttonPasswordEdit.Enabled = true;
this.textBoxID.Enabled = true;
this.buttonIDEdit.Enabled = true;
if (this.buttonSave.Visible == false)
this.buttonSave.Visible = true;
}
else if (e.KeyChar == 27)
{
e.Handled = true;
this.textBoxID.Text = this.CurrentUserItem.ID;
this.KeyboardClose();
}
else if (e.KeyChar == '<' || e.KeyChar == '>' || e.KeyChar == '|' || e.KeyChar == '"' || e.KeyChar == '?'
|| e.KeyChar == '*' || e.KeyChar == ':' || e.KeyChar == '/' || e.KeyChar == '\\')
{
e.Handled = true;
}
}
private void textBoxPassword_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == '\r')
{
e.Handled = true;
this.smartKeyboard.Hide();
this.buttonRegister.Enabled = true;
this.buttonDelete.Enabled = true;
this.groupBoxAccessRight.Enabled = true;
this.listBoxUserList.Enabled = true;
this.textBoxPassword.Enabled = true;
this.buttonPasswordEdit.Enabled = true;
this.textBoxID.Enabled = true;
this.buttonIDEdit.Enabled = true;
if (this.buttonSave.Visible == false)
this.buttonSave.Visible = true;
}
else if (e.KeyChar == 27)
{
e.Handled = true;
this.textBoxPassword.Text = this.CurrentUserItem.Password;
this.KeyboardClose();
}
else if (e.KeyChar == '<' || e.KeyChar == '>' || e.KeyChar == '|' || e.KeyChar == '"' || e.KeyChar == '?'
|| e.KeyChar == '*' || e.KeyChar == ':' || e.KeyChar == '/' || e.KeyChar == '\\')
{
e.Handled = true;
}
}
private void smartKeyboard_OnXKeyClick(object sender, EventArgs e)
{
if (this.smartKeyboard.TargetInputObject == this.textBoxPassword)
this.textBoxPassword.Text = this.CurrentUserItem.Password;
else
this.textBoxID.Text = this.CurrentUserItem.ID;
this.KeyboardClose();
}
private void buttonRegister_Click(object sender, EventArgs e)
{
this.UserNew();
}
private void buttonDelete_Click(object sender, EventArgs e)
{
if (this.listBoxUserList.SelectItemIndex == -1)
return;
// 사용자를 삭제 하시겠습니까?
DialogFormYesNo dlg = new DialogFormYesNo(this.ParentForm.ParentForm.SystemConfig.LANGUAGE, 16);
if (dlg.ShowDialog() == DialogResult.Yes)
{
if (this.listBoxUserList.Items.Count <= 1)
return;
if (this.listBoxUserList.SelectItemIndex <= 0)
return;
string id = this.listBoxUserList.Items[this.listBoxUserList.SelectItemIndex];
UserManager.UserManager_UserDel(id);
}
}
private void buttonSave_Click(object sender, EventArgs e)
{
this.SaveUserDll();
#region 자동 로그아웃 타임
this.ParentForm.ParentForm.SystemConfig.AUTOMATIC_LOGOUT = int.Parse(this.labelAutomaticLogoutTime.Text);
if (this.ParentForm.ParentForm.SystemConfig.AUTOMATIC_LOGOUT == 1)
this.ParentForm.ParentForm.FlagAutomaticLogoutWarningTime = 30;
else
this.ParentForm.ParentForm.FlagAutomaticLogoutWarningTime = 60;
UserManager.UserManager_AutoLogoutSetTimeout(this.ParentForm.ParentForm.SystemConfig.AUTOMATIC_LOGOUT, this.ParentForm.ParentForm.FlagAutomaticLogoutWarningTime);
#endregion
this.ParentForm.ParentForm.SaveSystemConfigurationFile(this.ParentForm.ParentForm.SystemConfig);
this.buttonSave.Enabled = false;
}
private void buttonIDEdit_Click(object sender, EventArgs e)
{
this.smartKeyboard.KeyboardType = SmartX.SmartKeyboard.KEYBOARDTYPES.NORMAL;
this.smartKeyboard.Location = new Point(5, 139);
this.smartKeyboard.Size = new Size(897, 352);
this.smartKeyboard.Hide();
this.smartKeyboard.TargetInputObject = this.textBoxID;
this.smartKeyboard.Show();
this.textBoxID.Select(this.textBoxID.Text.Length, 0);
this.buttonRegister.Enabled = false;
this.buttonDelete.Enabled = false;
this.groupBoxAccessRight.Enabled = false;
this.listBoxUserList.Enabled = false;
this.buttonPasswordEdit.Enabled = false;
this.textBoxPassword.Enabled = false;
this.buttonIDEdit.Enabled = false;
}
private void buttonPasswordEdit_Click(object sender, EventArgs e)
{
this.smartKeyboard.KeyboardType = SmartX.SmartKeyboard.KEYBOARDTYPES.NORMAL;
this.smartKeyboard.Location = new Point(5, 139);
this.smartKeyboard.Size = new Size(897, 352);
this.smartKeyboard.Hide();
this.smartKeyboard.TargetInputObject = this.textBoxPassword;
this.smartKeyboard.Show();
this.textBoxPassword.Select(this.textBoxPassword.Text.Length, 0);
this.buttonRegister.Enabled = false;
this.buttonDelete.Enabled = false;
this.groupBoxAccessRight.Enabled = false;
this.listBoxUserList.Enabled = false;
this.buttonPasswordEdit.Enabled = false;
this.textBoxID.Enabled = false;
this.buttonIDEdit.Enabled = false;
}
private void labelExpiryDateOfAccount_Click(object sender, EventArgs e)
{
DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelExpiryDateOfAccount.Text, 3, 0, false);
if (myKeyPad.ShowDialog() == DialogResult.OK)
{
if (myKeyPad.doubleValue < 0 || myKeyPad.doubleValue > 180)
{
// 입력범위를 확인하세요
DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.ParentForm.SystemConfig.LANGUAGE);
myMsg.ShowDialog();
}
else
{
this.labelExpiryDateOfAccount.Text = myKeyPad.StringValue;
if (this.buttonSave.Enabled == false)
this.buttonSave.Enabled = true;
}
}
}
private void labelExpiryDateOfPassword_Click(object sender, EventArgs e)
{
DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelExpiryDateOfPassword.Text, 3, 0, false);
if (myKeyPad.ShowDialog() == DialogResult.OK)
{
if (myKeyPad.IntValue < 0 || myKeyPad.IntValue > 90)
{
// 입력범위를 확인하세요
DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.ParentForm.SystemConfig.LANGUAGE);
myMsg.ShowDialog();
}
else
{
this.labelExpiryDateOfPassword.Text = myKeyPad.StringValue;
if (this.buttonSave.Enabled == false)
this.buttonSave.Enabled = true;
}
}
}
private void labelAutomaticLogoutTime_Click(object sender, EventArgs e)
{
DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelAutomaticLogoutTime.Text, 2, 0, false);
if (myKeyPad.ShowDialog() == DialogResult.OK)
{
if (myKeyPad.IntValue < 0 || myKeyPad.IntValue > 90)
{
// 입력범위를 확인하세요
DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.ParentForm.SystemConfig.LANGUAGE);
myMsg.ShowDialog();
}
else
{
this.labelAutomaticLogoutTime.Text = myKeyPad.StringValue;
if (this.buttonSave.Enabled == false)
this.buttonSave.Enabled = true;
}
}
}
private void buttonLevel_Click(object sender, EventArgs e)
{
SmartX.SmartButton button = sender as SmartX.SmartButton;
if (button == this.buttonLevel1)
{
this.CheckBoxCheckedAsLevel(Define.E_UserGroup.f0_Level1);
}
else if (button == this.buttonLevel2)
{
this.CheckBoxCheckedAsLevel(Define.E_UserGroup.f1_Level2);
}
else if (button == this.buttonLevel3)
{
this.CheckBoxCheckedAsLevel(Define.E_UserGroup.f2_Level3);
}
if (this.buttonSave.Enabled == false)
this.buttonSave.Enabled = true;
}
#endregion
}
}