1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- using System;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Input;
- using Venus_MainPages.Roles;
- using WPF.Themes.UserControls;
- namespace Venus_MainPages.Views
- {
- /// <summary>
- /// LoginView.xaml 的交互逻辑
- /// </summary>
- public partial class LoginView : Window
- {
- public bool IsLoginSuccess { get; set; }
- public User CurrentUser { get; set; }
- public LoginView()
- {
- InitializeComponent();
- }
- private void Close_Click(object sender, RoutedEventArgs e)
- {
- IsLoginSuccess = false;
- this.Close();
- }
- private void Login_Click(object sender, RoutedEventArgs e)
- {
- Login();
- }
- private void PassWordTextBox_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.Key == Key.Return)
- {
- Login();
- }
- }
- private void UserTextBox_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.Key == Key.Return)
- {
- PassWordTextBox.Focus();
- }
- }
- private void Login()
- {
- IsLoginSuccess = true;
- if (UserTextBox.Text != "admin")
- {
- IsLoginSuccess = false;
- WPFMessageBox.ShowError("用户名错误");
- return;
- }
- if (PassWordTextBox.Password != "admin")
- {
- IsLoginSuccess = false;
- WPFMessageBox.ShowError("密码错误");
- return;
- }
- CurrentUser = new User(UserTextBox.Text, PassWordTextBox.Password, (Role)Enum.Parse(typeof(Role), (MangerComboBox.SelectedItem as ComboBoxItem).Content.ToString(), true));
- this.Visibility = Visibility.Hidden;
- //this.Close();
- }
- }
- }
|