using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using WMS.Business; using WMS.Business.Base; using WMS.Common; using WMS.Model.Base; namespace ServerSystem { public partial class PassWord : Form { public UserDataModel userData = new UserDataModel(); public PassWord() { InitializeComponent(); } #region 验证 private bool Validation() { #region 验证 if (t_user.Text.Trim().Length == 0) { SystemCommon.ShowInfoMessageBox("User iS null"); t_user.Focus(); return false; } if (t_passWord.Text.Trim().Length == 0) { SystemCommon.ShowInfoMessageBox("PASSWORD is null!"); t_passWord.Focus(); return false; } if (!LogUserFrm()) return false; string passWord = userData.PASSWORD; if (passWord != t_passWord.Text.Trim()) { SystemCommon.ShowInfoMessageBox("PASSWORD error!"); t_passWord.Focus(); t_passWord.Text = string.Empty; return false; } #endregion return true; } #endregion private void btnAccept_Click(object sender, EventArgs e) { string errText = string.Empty; // 验证 if (!Validation()) { return; } string passWord = userData.PASSWORD; DialogResult = System.Windows.Forms.DialogResult.OK; } private void btnClose_Click(object sender, EventArgs e) { DialogResult = System.Windows.Forms.DialogResult.Cancel ; } private void t_passWord_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { } } #region 用户登录 /// /// 用户登录 /// private bool LogUserFrm() { string userNumber = t_user.Text.Trim(); string errText = string.Empty; string strResult = string.Empty; try { userData = IBussFactory.Instance().GetUserData(userNumber); if (errText.Trim().Length > 0 || userData == null) { SystemCommon.ShowInfoMessageBox(errText); t_user.Focus(); t_user.SelectAll(); return false; } } catch (Exception ex) { SystemCommon.ShowInfoMessageBox("error!" + ex.Message.ToString()); return false; } t_passWord.Focus(); return true; } #endregion private void t_user_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (t_user.Focused) { if (t_user.Text.Trim().Length == 0) { SystemCommon.ShowInfoMessageBox("user is null"); t_user.Focus(); return; } LogUserFrm(); return; } } } private void PassWord_Load(object sender, EventArgs e) { t_user.Focus(); } } }