UserLoginWindow.xaml.cs 1.8 KB

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