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 SmartX; using ITC81DB_2H_ImageDll; using ITC81DB_2H.Datastore; namespace ITC81DB_0H.DialogForms { public partial class DialogFormPasswordKeyPad : Form { #region Field private string m_InputKey; private string m_PasswordOperator; private string m_PasswordEngineer; private string m_PasswordManager; private string m_PasswordDeveloper; private string m_PasswordHiddenMenu; private int m_Digit; private int m_DecPoint; private Define.E_UserGroup m_Group; #endregion #region Property private string InputKey { get { return this.m_InputKey; } set { this.m_InputKey = value; } } public string PasswordOperator { get { return this.m_PasswordOperator; } set { this.m_PasswordOperator = value; } } public string PasswordEngineer { get { return this.m_PasswordEngineer; } set { this.m_PasswordEngineer = value; } } public string PasswordManager { get { return this.m_PasswordManager; } set { this.m_PasswordManager = value; } } public string PasswordDeveloper { get { return this.m_PasswordDeveloper; } set { this.m_PasswordDeveloper = value; } } public string PasswordHiddenMenu { get { return this.m_PasswordHiddenMenu; } set { this.m_PasswordHiddenMenu = value; } } private int Digit { get { return this.m_Digit; } set { this.m_Digit = value; } } private int DecPoint { get { return this.m_DecPoint; } set { this.m_DecPoint = value; } } public Define.E_UserGroup Group { get { return this.m_Group; } set { this.m_Group = value; } } #endregion #region Constructor public DialogFormPasswordKeyPad(int digit, Define.E_LanguageID language, UserPasswordType user) { InitializeComponent(); this.Digit = digit; this.PasswordOperator = user.Level1Password; this.PasswordEngineer = user.Level2Password; this.PasswordManager = user.Level3Password; this.PasswordDeveloper = user.Level4Password; this.PasswordHiddenMenu = DateTime.Now.ToString("MMdd") + "0810"; this.InitializeDesign(language); } #endregion #region Method private void InputNum(string key) { if (this.InputKey.Length >= this.Digit) { this.InputKey = key; this.labelScreen.Text = "*"; } else { this.InputKey += key; this.labelScreen.Text += "*"; } } private void InitializeDesign(Define.E_LanguageID language) { Class1 images = new Class1(); if (language == Define.E_LanguageID.English) { this.buttonCancel.Text = "ESC"; this.buttonEnter.Text = "Enter"; } else if (language == Define.E_LanguageID.Chinese) { this.labelTitle.Text = "键盘"; this.buttonCancel.Text = "取消"; this.buttonEnter.Text = "确认"; } else if (language == Define.E_LanguageID.Czech) { } else if (language == Define.E_LanguageID.Russian) { this.labelTitle.Text = "Клавиатура"; this.buttonCancel.Text = "X"; this.buttonEnter.Text = "Ввод"; } else if (language == Define.E_LanguageID.German) { this.buttonCancel.Text = "X"; this.buttonEnter.Text = "Enter"; } else { this.buttonCancel.Text = "ESC"; this.buttonEnter.Text = "Enter"; } } private void InitializeContnrol() { int x = 0, y = 0; x = Screen.PrimaryScreen.Bounds.Width / 2 - this.Size.Width / 2; y = Screen.PrimaryScreen.Bounds.Height / 2 - this.Size.Height / 2; this.Location = new Point(x, y); this.InputKey = ""; this.labelScreen.Text = ""; } #endregion #region Override Member protected override void OnLoad(EventArgs e) { base.OnLoad(e); this.InitializeContnrol(); } #endregion #region Event Handler private void buttonEnter_Click(object sender, EventArgs e) { if (this.labelScreen.Text.Length == 4) { if (this.Digit == 4) { if (this.InputKey == this.PasswordDeveloper) { this.DialogResult = DialogResult.OK; this.Group = Define.E_UserGroup.Admin; } else if (this.InputKey == this.PasswordManager) { this.DialogResult = DialogResult.OK; this.Group = Define.E_UserGroup.Level3; } else if (this.InputKey == this.PasswordEngineer) { this.DialogResult = DialogResult.OK; this.Group = Define.E_UserGroup.Level2; } else if (this.InputKey == this.PasswordOperator) { this.DialogResult = DialogResult.OK; this.Group = Define.E_UserGroup.Level1; } } } else if (this.labelScreen.Text.Length == 8) { if (this.Digit == 8) { if (this.InputKey == this.PasswordHiddenMenu) this.DialogResult = DialogResult.OK; } } this.InputKey = ""; this.labelScreen.Text = ""; } private void buttonNumber_Click(object sender, EventArgs e) { SmartButton bt = sender as SmartButton; if (bt == null) return; if (bt == this.buttonNumber0) this.InputNum("0"); else if (bt == this.buttonNumber1) this.InputNum("1"); else if (bt == this.buttonNumber2) this.InputNum("2"); else if (bt == this.buttonNumber3) this.InputNum("3"); else if (bt == this.buttonNumber4) this.InputNum("4"); else if (bt == this.buttonNumber5) this.InputNum("5"); else if (bt == this.buttonNumber6) this.InputNum("6"); else if (bt == this.buttonNumber7) this.InputNum("7"); else if (bt == this.buttonNumber8) this.InputNum("8"); else if (bt == this.buttonNumber9) this.InputNum("9"); } private void buttonCancel_Click(object sender, EventArgs e) { this.Close(); } #endregion } }