ITC81DB_2H/ITC81DB_0H/DialogForms/DialogFormLogOn.cs

434 lines
20 KiB
C#

using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using ITC81DB_0H.Forms;
using ITC81DB_2H_ImageDll;
using ITC81DB_2H.Datastore;
using ITC81DB_0H.Part11_UserManager;
namespace ITC81DB_0H.DialogForms
{
public partial class DialogFormLogOn : Form
{
#region Field
private bool IsPart11;
// false : 패스워드 변경, true : 로그인
private bool IsLogin;
private string ID;
UserManager.UserMgr_user_info_t UserInfo = new UserManager.UserMgr_user_info_t();
private FormMain m_ParentForm;
#endregion
#region Constructor
public DialogFormLogOn(FormMain parent, Define.E_LanguageID language, bool isPart11)
{
InitializeComponent();
this.ParentForm = parent;
this.IsPart11 = isPart11;
this.IsLogin = true;
this.InitializeDesignLogOn(language);
this.DefaultSettingLogOn();
}
public DialogFormLogOn(FormMain parent, Define.E_LanguageID language, string id)
{
InitializeComponent();
this.ParentForm = parent;
this.ID = id;
this.IsLogin = false;
this.InitializeDesignChangePassword(language);
this.DefaultSettingChangePassword();
}
#endregion
#region Property
public FormMain ParentForm
{
get { return this.m_ParentForm; }
set { this.m_ParentForm = value; }
}
#endregion
#region Method
public void InitializeDesignLogOn(Define.E_LanguageID language)
{
Class1 images = new Class1();
this.pictureBoxImage.Image = new Bitmap(images.GetImage(Class1.ButtonImages.LoginImage1));
if (language == Define.E_LanguageID.English)
{
this.labelTitle.Text = "User Login";
this.labelTitleID.Text = "ID";
this.labelTitlePassword.Text = "Password";
this.buttonCancel.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engFormMainLoginCancelDisable));
this.buttonCancel.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engFormMainLoginCancelDown));
this.buttonCancel.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engFormMainLoginCancelUp));
this.buttonLogon.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engFormMainLoginDisable));
this.buttonLogon.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engFormMainLoginDown));
this.buttonLogon.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engFormMainLoginUp));
}
else if (language == Define.E_LanguageID.German)
{
this.labelTitle.Text = "Einloggen";
this.labelTitleID.Text = "ID";
this.labelTitlePassword.Text = "Passwort";
this.buttonCancel.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerFormMainLoginCancelDisable));
this.buttonCancel.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerFormMainLoginCancelDown));
this.buttonCancel.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerFormMainLoginCancelUp));
this.buttonLogon.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerFormMainLoginDisable));
this.buttonLogon.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerFormMainLoginDown));
this.buttonLogon.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerFormMainLoginUp));
}
else if (this.ParentForm.SystemConfig1.Language == Define.E_LanguageID.Spanish)
{
this.labelTitle.Text = "Acceso";
this.labelTitleID.Text = "ID";
this.labelTitlePassword.Text = "Clave";
this.buttonCancel.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engFormMainLoginCancelDisable));
this.buttonCancel.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engFormMainLoginCancelDown));
this.buttonCancel.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engFormMainLoginCancelUp));
this.buttonLogon.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engFormMainLoginDisable));
this.buttonLogon.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engFormMainLoginDown));
this.buttonLogon.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engFormMainLoginUp));
}
else
{
this.labelTitle.Text = "로그인";
this.labelTitleID.Text = "ID";
this.labelTitlePassword.Text = "비밀번호";
this.buttonCancel.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.korFormMainLoginCancelDisable));
this.buttonCancel.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.korFormMainLoginCancelDown));
this.buttonCancel.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.korFormMainLoginCancelUp));
this.buttonLogon.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.korFormMainLoginDisable));
this.buttonLogon.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.korFormMainLoginDown));
this.buttonLogon.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.korFormMainLoginUp));
}
}
private void DefaultSettingLogOn()
{
this.textBoxID.Text = "";
this.textBoxPassword.Text = "";
this.Location = new Point(0, 65);
this.smartKeyboard.KeyboardType = SmartX.SmartKeyboard.KEYBOARDTYPES.NORMAL;
this.smartKeyboard.Show();
}
private void Login()
{
// Check ID
if (this.textBoxID.Text.Length < 6)
{
// ID : 6~20자 입력하세요
DialogFormMessage msg = new DialogFormMessage(null, 3, this.ParentForm.SystemConfig1.Language);
msg.ShowDialog();
return;
}
// Check Password
if (this.textBoxPassword.Text.Length < 6)
{
// PASSWORD : 6~20자 입력하세요
DialogFormMessage msg = new DialogFormMessage(null, 9, this.ParentForm.SystemConfig1.Language);
msg.ShowDialog();
return;
}
UserManager.UserManager_UserLoginDirect(this.textBoxID.Text, this.textBoxPassword.Text, ref this.UserInfo);
if (this.UserInfo.status == 0)
{
#region 로그인 성공
try
{
string sValue = "";
this.SuccessLogin(this.UserInfo);
sValue = this.ParentForm.ChildFormMainDisplay.DisplayExpireOfPassword(this.ParentForm.CurrentSystemStatus.CurrentUser.Group);
if (sValue != "-")
{
int intExpireDate = int.Parse(sValue);
if (intExpireDate >= -10)
{
int extract = int.Parse(Regex.Replace(sValue, @"\D", ""));
DialogFormYesNo df = new DialogFormYesNo(this.ParentForm.SystemConfig1.Language, 2, extract.ToString());
df.BringToFront();
if (df.ShowDialog() == DialogResult.Yes)
{
DialogFormLogOn changePW = new DialogFormLogOn(this.ParentForm, this.ParentForm.SystemConfig1.Language, this.textBoxID.Text);
if (changePW.ShowDialog() == DialogResult.OK)
{
UserManager.UserManager_UserLoginDirect(this.ID, this.textBoxPassword.Text, ref this.UserInfo);
this.SuccessLogin(this.UserInfo);
}
}
}
}
}
catch (Exception ex)
{
FormMain.Exception(ex);
}
#endregion
this.DialogResult = DialogResult.OK;
this.Close();
}
else
{
if (this.UserInfo.status == 15)
{
this.Close();
string sValue = "";
sValue = this.ParentForm.ChildFormMainDisplay.DisplayExpireOfPassword(this.ParentForm.CurrentSystemStatus.CurrentUser.Group);
if (sValue != "-")
{
int intExpireDate = int.Parse(sValue);
if (intExpireDate > 0)
{
DialogFormLogOn changePW = new DialogFormLogOn(this.ParentForm, this.ParentForm.SystemConfig1.Language, this.textBoxID.Text);
if (changePW.ShowDialog() == DialogResult.OK)
{
UserManager.UserManager_UserLoginDirect(this.ID, this.textBoxPassword.Text, ref this.UserInfo);
this.SuccessLogin(this.UserInfo);
}
}
}
}
else
{
DialogFormMessage myMsg = new DialogFormMessage(null, this.UserInfo.status, this.ParentForm.SystemConfig1.Language);
myMsg.ShowDialog();
}
}
}
private void SuccessLogin(UserManager.UserMgr_user_info_t user)
{
if (user.active_level == 1)
this.ParentForm.CurrentSystemStatus.CurrentUser.Group = Define.E_UserGroup.Level1;
else if (user.active_level == 2)
this.ParentForm.CurrentSystemStatus.CurrentUser.Group = Define.E_UserGroup.Level2;
else if (user.active_level == 3)
this.ParentForm.CurrentSystemStatus.CurrentUser.Group = Define.E_UserGroup.Level3;
else if (user.active_level == 9)
this.ParentForm.CurrentSystemStatus.CurrentUser.Group = Define.E_UserGroup.Admin;
else if (user.active_level == 10)
this.ParentForm.CurrentSystemStatus.CurrentUser.Group = Define.E_UserGroup.Developer;
this.ParentForm.CurrentSystemStatus.CurrentUser.ActiveLevel = user.active_level;
this.ParentForm.CurrentSystemStatus.CurrentUser.ID = user.user_id;
this.ParentForm.CurrentSystemStatus.CurrentUser.Password = user.user_pw;
this.ParentForm.CurrentSystemStatus.CurrentUser.ExpireAccount = user.expire_period_account;
this.ParentForm.CurrentSystemStatus.CurrentUser.ExpirePassword = user.expire_period_pw;
DateTime time = DateTime.ParseExact(user.register_date.GetDateTime(), "yyyyMMddHHmmss", null);
this.ParentForm.CurrentSystemStatus.CurrentUser.DateRegister = time;
time = DateTime.ParseExact(user.login_date.GetDateTime(), "yyyyMMddHHmmss", null);
this.ParentForm.CurrentSystemStatus.CurrentUser.DateLogin = time;
if (this.ParentForm.CurrentSystemStatus.CurrentUser.Group == Define.E_UserGroup.Admin
|| this.ParentForm.CurrentSystemStatus.CurrentUser.Group == Define.E_UserGroup.Developer)
{
this.ParentForm.CurrentSystemStatus.CurrentUser.DateExpireRegister = DateTime.Now;
this.ParentForm.CurrentSystemStatus.CurrentUser.DateExpireLogin = DateTime.Now;
}
else
{
time = DateTime.ParseExact(user.expire_account_date.GetDateTime(), "yyyyMMddHHmmss", null);
this.ParentForm.CurrentSystemStatus.CurrentUser.DateExpireLogin = time;
time = DateTime.ParseExact(user.expire_register_date.GetDateTime(), "yyyyMMddHHmmss", null);
this.ParentForm.CurrentSystemStatus.CurrentUser.DateExpireRegister = time;
}
this.ParentForm.CurrentSystemStatus.CurrentUser.IsLockAccount = user.flock_status_account == 0 ? false : true;
this.ParentForm.CurrentSystemStatus.CurrentUser.IsLockPassword = user.flock_status_password == 0 ? false : true;
if (this.ParentForm.SystemConfig3.IsPart11 == true)
this.ParentForm.CurrentSystemStatus.CurrentUser.IsAdmin = user.fadmin == 0 ? false : true;
else
this.ParentForm.CurrentSystemStatus.CurrentUser.IsAdmin = true;
}
public void InitializeDesignChangePassword(Define.E_LanguageID language)
{
Class1 images = new Class1();
this.pictureBoxImage.Image = new Bitmap(images.GetImage(Class1.ButtonImages.LoginImage2));
if (language == Define.E_LanguageID.English)
{
this.labelTitle.Text = "Change Password";
this.labelTitleID.Text = "New";
this.labelTitlePassword.Text = "Verify";
this.buttonCancel.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engFormMainLoginCancelDisable));
this.buttonCancel.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engFormMainLoginCancelDown));
this.buttonCancel.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engFormMainLoginCancelUp));
this.buttonLogon.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engFormMainLoginChangeDisable));
this.buttonLogon.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engFormMainLoginChangeDown));
this.buttonLogon.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engFormMainLoginChangeUp));
}
else if (language == Define.E_LanguageID.German)
{
this.labelTitle.Text = "Kennwort ändern";
this.labelTitleID.Text = "Neu";
this.labelTitlePassword.Text = "Verifizieren";
this.buttonCancel.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerFormMainLoginCancelDisable));
this.buttonCancel.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerFormMainLoginCancelDown));
this.buttonCancel.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerFormMainLoginCancelUp));
this.buttonLogon.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerFormMainLoginChangeDisable));
this.buttonLogon.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerFormMainLoginChangeDown));
this.buttonLogon.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerFormMainLoginChangeUp));
}
else if (language == Define.E_LanguageID.Spanish)
{
this.labelTitle.Text = "Cambiar la contraseña";
this.labelTitleID.Text = "Nuevo";
this.labelTitlePassword.Text = "Verificar";
this.buttonCancel.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engFormMainLoginCancelDisable));
this.buttonCancel.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engFormMainLoginCancelDown));
this.buttonCancel.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engFormMainLoginCancelUp));
this.buttonLogon.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engFormMainLoginChangeDisable));
this.buttonLogon.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engFormMainLoginChangeDown));
this.buttonLogon.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engFormMainLoginChangeUp));
}
else
{
this.labelTitle.Text = "비밀번호 변경";
this.labelTitleID.Text = "새 비밀번호";
this.labelTitlePassword.Text = "비밀번호 확인";
this.buttonCancel.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.korFormMainLoginCancelDisable));
this.buttonCancel.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.korFormMainLoginCancelDown));
this.buttonCancel.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.korFormMainLoginCancelUp));
this.buttonLogon.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.korFormMainLoginChangeDisable));
this.buttonLogon.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.korFormMainLoginChangeDown));
this.buttonLogon.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.korFormMainLoginChangeUp));
}
}
private void DefaultSettingChangePassword()
{
this.Location = new Point(0, 65);
this.textBoxID.Text = "";
this.textBoxPassword.Text = "";
this.textBoxID.PasswordChar = '*';
this.textBoxPassword.PasswordChar = '*';
this.smartKeyboard.KeyboardType = SmartX.SmartKeyboard.KEYBOARDTYPES.NORMAL;
this.smartKeyboard.Show();
}
private void SaveChangePassword()
{
string detail = "";
// Check Password
if (this.textBoxPassword.Text.Length < 6)
{
// PASSWORD : 6~20자 입력하세요
DialogFormMessage msg = new DialogFormMessage(null, 9, this.ParentForm.SystemConfig1.Language);
msg.ShowDialog();
return;
}
if (this.textBoxID.Text != this.textBoxPassword.Text)
{
// 비밀번호가 동일하지 않습니다
DialogFormMessage myMsg = new DialogFormMessage(null, 17, this.ParentForm.SystemConfig1.Language);
myMsg.ShowDialog();
}
else
{
UserManager.UserManager_UserModifyPW(this.ID, this.textBoxPassword.Text);
this.DialogResult = DialogResult.OK;
this.Close();
}
}
#endregion
#region Event Handler
private void buttonLogon_Click(object sender, EventArgs e)
{
// Automatic Logout Reset
if (this.IsPart11 == true)
this.ParentForm.ChildFormMainDisplay.Part11AutomaticLogoutReset();
if (this.IsLogin == true)
this.Login();
else
this.SaveChangePassword();
}
private void buttonCancel_Click(object sender, EventArgs e)
{
// Automatic Logout Reset
if (this.IsPart11 == true)
this.ParentForm.ChildFormMainDisplay.Part11AutomaticLogoutReset();
this.DialogResult = DialogResult.Cancel;
this.Close();
}
private void textBoxID_GotFocus(object sender, EventArgs e)
{
// Automatic Logout Reset
if (this.IsPart11 == true)
this.ParentForm.ChildFormMainDisplay.Part11AutomaticLogoutReset();
this.smartKeyboard.TargetInputObject = this.textBoxID;
this.textBoxID.Select(this.textBoxID.Text.Length, 0);
}
private void textBoxPassword_GotFocus(object sender, EventArgs e)
{
// Automatic Logout Reset
if (this.IsPart11 == true)
this.ParentForm.ChildFormMainDisplay.Part11AutomaticLogoutReset();
this.smartKeyboard.TargetInputObject = this.textBoxPassword;
this.textBoxPassword.Select(this.textBoxPassword.Text.Length, 0);
}
private void smartKeyboard_OnXKeyClick(object sender, EventArgs e)
{
//this.smartKeyboard.Show();
}
private void smartKeyboard_Click(object sender, EventArgs e)
{
// Automatic Logout Reset
if (this.IsPart11 == true)
this.ParentForm.ChildFormMainDisplay.Part11AutomaticLogoutReset();
}
#endregion
}
}