Form_UserLogin.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. cbb_UserName.SelectedIndex = 2;
  25. }
  26. private void bt_Login_Click(object sender, EventArgs e)
  27. {
  28. if (userAccount.UserLogin(userAccount.GetUserName(cbb_UserName.Text),txt_Password.Text))
  29. {
  30. //MessageBox.Show("登录成功", "用户登陆", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  31. this.Close();
  32. }
  33. else
  34. {
  35. txt_Password.Text = "";
  36. txt_Password.Focus();
  37. lab_Err.Visible = true;
  38. }
  39. }
  40. private void txt_Password_KeyDown(object sender, KeyEventArgs e)
  41. {
  42. if (e.KeyCode == Keys.Enter)
  43. {
  44. bt_Login_Click(null, null);
  45. }
  46. }
  47. private void bt_Exit_Click(object sender, EventArgs e)
  48. {
  49. this.Close();
  50. }
  51. }
  52. }