using DevComponents.DotNetBar; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using WCS_Client.UC; using WCS_Client.Utility; namespace WCS_Client { public partial class FrmLogin : Office2007Form { public FrmLogin() { InitializeComponent(); } int err = 0; private void btn_Login_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtbox_UserName.Text.Trim())) { MessageUtil.ShowWarning("请输入用户名!!!"); txtbox_UserName.Focus(); return; } if (string.IsNullOrEmpty(this.txtbox_Pwd.Text.Trim())) { MessageUtil.ShowWarning("请输入密码!!!"); txtbox_Pwd.Focus(); return; } try { string error = string.Empty; if (BaseWorkflow.Login(txtbox_UserName.Text.Trim(), txtbox_Pwd.Text.Trim(), out error)) { this.DialogResult = DialogResult.OK; } else { throw new Exception(error); } } catch (Exception ex) { err++; if (err < 5) { MessageUtil.ShowWarning(string.Format("登录次数{0}/5,{1}", err, ex.Message)); txtbox_UserName.Focus(); return; } else { this.Close(); return; } } } private void btn_Close_Click(object sender, EventArgs e) { this.Close(); } private void txtbox_Pwd_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { btn_Login_Click(null, null); } } private void txtbox_UserName_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { this.txtbox_Pwd.SelectAll(); txtbox_Pwd.Focus(); } } } }