diff --git a/Models/SQL_Ti.edmx.diagram b/Models/SQL_Ti.edmx.diagram index a6ebfbe..98778d4 100644 --- a/Models/SQL_Ti.edmx.diagram +++ b/Models/SQL_Ti.edmx.diagram @@ -4,7 +4,7 @@ - + diff --git a/Models/UserAccountProvide.cs b/Models/UserAccountProvide.cs index a7519ce..d5ffb8c 100644 --- a/Models/UserAccountProvide.cs +++ b/Models/UserAccountProvide.cs @@ -8,6 +8,8 @@ namespace Models { public class UserAccountProvide : IProvider { + private TicketEntities db = new TicketEntities(); + public int Delete(UserAccount t) { throw new NotImplementedException(); @@ -20,7 +22,7 @@ namespace Models public List Select() { - throw new NotImplementedException(); + return db.UserAccount.ToList(); } public int Update(UserAccount t) diff --git a/ViewModel/LogViewModel.cs b/ViewModel/LogViewModel.cs index ca2d558..0f2fecd 100644 --- a/ViewModel/LogViewModel.cs +++ b/ViewModel/LogViewModel.cs @@ -12,23 +12,19 @@ namespace Audit.ViewModel { public class LogViewModel : ViewModelBase { - public UserAccount UserAccount { get; set; } = AuditData.Instance.UserAccount; + // public UserAccount UserAccount { get; private set; } = AuditData.Instance.UserAccount; - private RelayCommand logCommand; - public RelayCommand LogCommand + //登录命令绑定 +/* public RelayCommand LogCommand { - get { return logCommand; } - set { logCommand = value; } - } - - public LogViewModel() - { - - logCommand = new RelayCommand(() => + get { - MessageBox.Show("成功"); - - }); + return new RelayCommand(() => + { + + }); + } } +*/ } } diff --git a/Windows/LogWindow.xaml.cs b/Windows/LogWindow.xaml.cs index 2701cc9..9e86a45 100644 --- a/Windows/LogWindow.xaml.cs +++ b/Windows/LogWindow.xaml.cs @@ -1,4 +1,6 @@ -using MahApps.Metro.Controls; +using GalaSoft.MvvmLight.Command; +using MahApps.Metro.Controls; +using Models; using System; using System.Collections.Generic; using System.Linq; @@ -24,19 +26,17 @@ namespace Audit.Windows { InitializeComponent(); } - + private void Exit(object sender, RoutedEventArgs e)//退出按钮 { Application.Current.Shutdown();//关闭窗口 } private void Log(object sender, RoutedEventArgs e)//登录按钮 - { - string user = this.users.Text; - string passwd = this.Passwds.Text; - if (user == "setup") + { + if (this.users.Text == "sunlight") { - if (passwd == "setup") + if (this.Passwds.Text == "sunlight") { MessageBox.Show("警告:进入设置模式请您明确操作目的及可能需承担的后果"); Windows.Set_up setup = new Windows.Set_up(); @@ -45,12 +45,26 @@ namespace Audit.Windows } else { - MessageBox.Show("ERR01:拒绝认证");//设置密码错误 + MessageBox.Show("ERR.01:拒绝登录");//设置密码错误 } } else { - + UserAccountProvide UserAccountProvide = new UserAccountProvide(); + var user = UserAccountProvide.Select() + .FirstOrDefault(item => item.UserCode == AuditData.Instance.UserAccount.UserCode + && item.PassWord == AuditData.Instance.UserAccount.PassWord); + + if (user == null) + { + MessageBox.Show("ERR.00:用户名或密码错误"); + } + else + { + MainWindow mainWindow = new MainWindow(); + mainWindow.Show(); + this.Close(); + } } } }