UserLoginWindow.xaml.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Shapes;
  14. namespace CCDCountWpf
  15. {
  16. /// <summary>
  17. /// UserLoginWindow.xaml 的交互逻辑
  18. /// </summary>
  19. public partial class UserLoginWindow : Window
  20. {
  21. public UserLoginWindow()
  22. {
  23. InitializeComponent();
  24. }
  25. private void UserLoginBtn_Click(object sender, RoutedEventArgs e)
  26. {
  27. if(!MessageBus.UserMessageClass.CheckUserLogin(UserNameTbx.Text, UserPassTbx.Password))
  28. {
  29. MessageBox.Show("用户名或密码错误!");
  30. return;
  31. }
  32. MessageBus.NowLoginUserMessage = MessageBus.UserMessageClass.GetUserMessageForName(UserNameTbx.Text)[0];
  33. SplashWindow splash = new SplashWindow();
  34. splash.Show();
  35. this.Close();
  36. MainWindow mainWindow = new MainWindow();
  37. mainWindow.Show();
  38. splash.Close();
  39. }
  40. private void UserCancelBtn_Click(object sender, RoutedEventArgs e)
  41. {
  42. this.Close();
  43. Environment.Exit(0);
  44. }
  45. private void Window_KeyDown(object sender, KeyEventArgs e)
  46. {
  47. if (e.Key == Key.Enter)
  48. {
  49. // 触发目标按钮的点击事件
  50. UserLoginBtn.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
  51. e.Handled = true; // 标记事件已处理
  52. }
  53. }
  54. }
  55. }