private void OnCfmUserKeyDown(object sender, KeyEventArgs e) { TimeSpan ts = DateTime.Now.Subtract(_firstTime); TextBox textBox = sender as TextBox; if (e.KeyData == Keys.Enter && _canKeyDown) { if (textBox != null) { Label messageLbl = CnasUtilityTools.FindControl <Label>(this.ParentForm, "resultLbl"); UserBase user = null; if (textBox.Text.StartsWith("BCB") || string.IsNullOrEmpty(textBox.Text)) { return; } else { user = UserBaseHelper.UserInfoByUserName(textBox.Text); } if (user != null && user.UserID > 0) { if (messageLbl != null) { messageLbl.Text = PromptMessageXmlHelper.Instance.GetPromptMessage("notfindUser", EnumPromptMessage.warning); } //MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("notfindUser", EnumPromptMessage.warning), //"信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { _confirmUser = user; textBox.Text = user.UserName; textBox.Tag = user.UserID; if (messageLbl != null) { messageLbl.Text = PromptMessageXmlHelper.Instance.GetPromptMessage("cfmUserOk", EnumPromptMessage.warning); } } } } _firstTime = DateTime.Now; if (ts.Milliseconds < 20) { _canKeyDown = false; } else { _canKeyDown = true; } if (txtConfirmName.Focused) { txtConfirmName.Text = _confirmUser != null ? _confirmUser.UserName : string.Empty; } }
/// <summary> /// 登录按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void but_ok_Click(object sender, EventArgs e) { if (com_workare.Text.Trim() == "") { MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("Configuration_tips", EnumPromptMessage.warning), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (tex_user.Text.Trim() == "") { MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("usernameRequired", EnumPromptMessage.warning), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (tex_pwd.Text.Trim() == "") { MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("userPassWordRequired", EnumPromptMessage.warning), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //判断用户帐号密码是否 正确 if (!(UserBaseHelper.CheckUserInfo(tex_user.Text.Trim(), tex_pwd.Text.Trim()) > 0)) { MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("userpassworderror", EnumPromptMessage.error), "错误信息", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //根据用户名,返回用户信息 CnasBaseData.UserBaseInfo = UserBaseHelper.UserInfoByUserName(tex_user.Text.Trim()); CnasBaseData.UserName = tex_user.Text.Trim(); if (check_rec.Checked == true) { setsysxml(this.tex_user.Text, com_workare.SelectedIndex.ToString()); } string str_ws = com_workare.Text; string str_code = str_ws.Substring(0, 4); if (str_code == "9000") { CnasMain f_frmmin = new CnasMain(); this.Hide(); f_frmmin.Show(); } else { CnasBaseData.UserAccessCustomer = GetUserAccessCustomers(str_code); var form = new HCSWF_Workspace(str_ws); this.Hide(); form.ShowDialog(); } }
/// <summary> /// 相应keyDown事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnUserEnterKeyDown(object sender, KeyEventArgs e) { //if (e.KeyData == Keys.Enter) //{ // MetroTextBox textBox = sender as MetroTextBox; // if (textBox != null) // { // UserBase user = null; // if (textBox.Text.StartsWith("BCB") || string.IsNullOrEmpty(textBox.Text)) // return; // else // user = UserBaseHelper.UserInfoByUserName(textBox.Text); // if (user == null) // { // textBox.Text = string.Empty; // MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("notfindUser", EnumPromptMessage.warning), // "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); // } // // else // { // if (textBox.Name == "packUserTxt") // { // packUserTxt.Tag = user.UserID; // } // else // { // cfmUserTxt.Tag = user.UserID; // } // } // // } //} MetroTextBox textBox = sender as MetroTextBox; TimeSpan ts = DateTime.Now.Subtract(_firstTime); UserBase user = null; if (e.KeyData == Keys.Enter && _canKeyDown) { if (textBox != null) { if (textBox.Text.StartsWith("BCB") && textBox.Text.Length >= 13) { user = UserBaseHelper.GetUserByBarCode(textBox.Text); } else { user = UserBaseHelper.UserInfoByUserName(textBox.Text); } if (user != null) { if (textBox.Name == "packUserTxt") { //_packUser = user; if (ScanBarCodes.ContainsValue("BCB")) { int index = ScanBarCodes.IndexOfValue("BCB"); ScanBarCodes.RemoveAt(index); } ScanBarCodes.Add(user.Userbcode, "BCB"); //messageLbl.Text = PromptMessageXmlHelper.Instance.GetPromptMessage("packUserOk", EnumPromptMessage.warning); } else { //_confirmUser = user; //messageLbl.Text = PromptMessageXmlHelper.Instance.GetPromptMessage("cfmUserOk", EnumPromptMessage.warning); } textBox.Text = user.UserName; textBox.Tag = user.UserID; } else { //messageLbl.Text = PromptMessageXmlHelper.Instance.GetPromptMessage("notfindUser", EnumPromptMessage.warning); } } } _firstTime = DateTime.Now; if (ts.Milliseconds < 20) { _canKeyDown = false; } else { _canKeyDown = true; } }