Form_UserLogin.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using StandardLibrary;
  11. namespace UserSettings
  12. {
  13. public partial class Form_UserLogin : Form
  14. {
  15. UserAccount userAccount;
  16. public Form_UserLogin(UserAccount userAccount)
  17. {
  18. InitializeComponent();
  19. this.userAccount = userAccount;
  20. }
  21. private void Form_UserLogin_Load(object sender, EventArgs e)
  22. {
  23. cbb_UserName.SelectedIndex = 0;
  24. }
  25. private void bt_Login_Click(object sender, EventArgs e)
  26. {
  27. if (userAccount.UserLogin(userAccount.GetUserName(cbb_UserName.Text),txt_Password.Text))
  28. {
  29. //MessageBox.Show("登录成功", "用户登陆", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  30. this.Close();
  31. }
  32. else
  33. {
  34. txt_Password.Text = "";
  35. txt_Password.Focus();
  36. lab_Err.Visible = true;
  37. }
  38. }
  39. private void txt_Password_KeyDown(object sender, KeyEventArgs e)
  40. {
  41. if (e.KeyCode == Keys.Enter)
  42. {
  43. bt_Login_Click(null, null);
  44. }
  45. }
  46. private void bt_Exit_Click(object sender, EventArgs e)
  47. {
  48. this.Close();
  49. }
  50. }
  51. }