FormUserVerification.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Linq;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using DevExpress.XtraEditors;
  11. using ProjectBase.Data.Encrypt;
  12. using ProjectBase.Data.BaseDAL;
  13. using SIMDP.BLL;
  14. using ProjectBase.Data.Logs;
  15. namespace SIMDP.View
  16. {
  17. public partial class FormUserVerification : DevExpress.XtraEditors.XtraForm
  18. {
  19. public FormUserVerification()
  20. {
  21. InitializeComponent();
  22. }
  23. private void btn_Ok_Click(object sender, EventArgs e)
  24. {
  25. if (string.IsNullOrEmpty(this.txt_Account.Text))
  26. {
  27. DevExpress.XtraEditors.XtraMessageBox.Show("请输入账号。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  28. return;
  29. }
  30. if (string.IsNullOrEmpty(this.txt_Password.Text))
  31. {
  32. DevExpress.XtraEditors.XtraMessageBox.Show("请输入密码。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  33. return;
  34. }
  35. try
  36. {
  37. string userid = this.txt_Account.Text.Trim();
  38. string passwordMD5 = EncodeHelper.EncryptString(this.txt_Password.Text);
  39. string message = null;
  40. //权限认证
  41. bool flag = BLLFactory<BlAuthoryUser>.Instance.VerifyAuthorization(userid, passwordMD5, out message);
  42. if (flag)
  43. {
  44. this.DialogResult = DialogResult.OK;
  45. this.Close();
  46. }
  47. else
  48. {
  49. DevExpress.XtraEditors.XtraMessageBox.Show(message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  50. return;
  51. }
  52. }
  53. catch (Exception ex)
  54. {
  55. LogHelper.log.Error(string.Format("用户验证出现错误:{0}", ex.ToString()));
  56. }
  57. }
  58. private void txt_Account_Enter(object sender, EventArgs e)
  59. {
  60. txt_Account.SelectAll();
  61. }
  62. private void txt_Password_Enter(object sender, EventArgs e)
  63. {
  64. txt_Password.SelectAll();
  65. }
  66. protected override bool ProcessCmdKey(ref System.Windows.Forms.Message msg, System.Windows.Forms.Keys keyData)
  67. {
  68. int WM_KEYDOWN = 256;
  69. int WM_SYSKEYDOWN = 260;
  70. if (msg.Msg == WM_KEYDOWN | msg.Msg == WM_SYSKEYDOWN)
  71. {
  72. switch (keyData)
  73. {
  74. case Keys.Escape:
  75. //Application.Exit();
  76. this.Close();
  77. break;
  78. }
  79. }
  80. return false;
  81. }
  82. }
  83. }