FrmLogin.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. using DevComponents.DotNetBar;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Windows.Forms;
  10. using WCS_Client.UC;
  11. using WCS_Client.Utility;
  12. namespace WCS_Client
  13. {
  14. public partial class FrmLogin : Office2007Form
  15. {
  16. public FrmLogin()
  17. {
  18. InitializeComponent();
  19. }
  20. int err = 0;
  21. private void btn_Login_Click(object sender, EventArgs e)
  22. {
  23. if (string.IsNullOrEmpty(txtbox_UserName.Text.Trim()))
  24. {
  25. MessageUtil.ShowWarning("请输入用户名!!!");
  26. txtbox_UserName.Focus();
  27. return;
  28. }
  29. if (string.IsNullOrEmpty(this.txtbox_Pwd.Text.Trim()))
  30. {
  31. MessageUtil.ShowWarning("请输入密码!!!");
  32. txtbox_Pwd.Focus();
  33. return;
  34. }
  35. try
  36. {
  37. string error = string.Empty;
  38. if (BaseWorkflow.Login(txtbox_UserName.Text.Trim(), txtbox_Pwd.Text.Trim(), out error))
  39. {
  40. this.DialogResult = DialogResult.OK;
  41. }
  42. else
  43. {
  44. throw new Exception(error);
  45. }
  46. }
  47. catch (Exception ex)
  48. {
  49. err++;
  50. if (err < 5)
  51. {
  52. MessageUtil.ShowWarning(string.Format("登录次数{0}/5,{1}", err, ex.Message));
  53. txtbox_UserName.Focus();
  54. return;
  55. }
  56. else
  57. {
  58. this.Close();
  59. return;
  60. }
  61. }
  62. }
  63. private void btn_Close_Click(object sender, EventArgs e)
  64. {
  65. this.Close();
  66. }
  67. private void txtbox_Pwd_KeyDown(object sender, KeyEventArgs e)
  68. {
  69. if (e.KeyCode == Keys.Enter)
  70. {
  71. btn_Login_Click(null, null);
  72. }
  73. }
  74. private void txtbox_UserName_KeyDown(object sender, KeyEventArgs e)
  75. {
  76. if (e.KeyCode == Keys.Enter)
  77. {
  78. this.txtbox_Pwd.SelectAll();
  79. txtbox_Pwd.Focus();
  80. }
  81. }
  82. }
  83. }