sc 4 years ago
parent
commit
3c052000e3
  1. 2
      Models/SQL_Ti.edmx.diagram
  2. 4
      Models/UserAccountProvide.cs
  3. 18
      ViewModel/LogViewModel.cs
  4. 26
      Windows/LogWindow.xaml.cs

2
Models/SQL_Ti.edmx.diagram

@ -4,7 +4,7 @@
<edmx:Designer xmlns="http://schemas.microsoft.com/ado/2009/11/edmx"> <edmx:Designer xmlns="http://schemas.microsoft.com/ado/2009/11/edmx">
<!-- Diagram content (shape and connector positions) --> <!-- Diagram content (shape and connector positions) -->
<edmx:Diagrams> <edmx:Diagrams>
<Diagram DiagramId="89d520d3675442b5b0979c510546a2e9" Name="Diagram1" ZoomLevel="70"> <Diagram DiagramId="89d520d3675442b5b0979c510546a2e9" Name="Diagram1" ZoomLevel="49">
<EntityTypeShape EntityType="TicketModel.Product" Width="1.5" PointX="0.75" PointY="0.75" IsExpanded="true" /> <EntityTypeShape EntityType="TicketModel.Product" Width="1.5" PointX="0.75" PointY="0.75" IsExpanded="true" />
<EntityTypeShape EntityType="TicketModel.ProductInventory" Width="1.5" PointX="2.75" PointY="0.75" IsExpanded="true" /> <EntityTypeShape EntityType="TicketModel.ProductInventory" Width="1.5" PointX="2.75" PointY="0.75" IsExpanded="true" />
<EntityTypeShape EntityType="TicketModel.ProductUsed" Width="1.5" PointX="2.75" PointY="3.75" IsExpanded="true" /> <EntityTypeShape EntityType="TicketModel.ProductUsed" Width="1.5" PointX="2.75" PointY="3.75" IsExpanded="true" />

4
Models/UserAccountProvide.cs

@ -8,6 +8,8 @@ namespace Models
{ {
public class UserAccountProvide : IProvider<UserAccount> public class UserAccountProvide : IProvider<UserAccount>
{ {
private TicketEntities db = new TicketEntities();
public int Delete(UserAccount t) public int Delete(UserAccount t)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
@ -20,7 +22,7 @@ namespace Models
public List<UserAccount> Select() public List<UserAccount> Select()
{ {
throw new NotImplementedException(); return db.UserAccount.ToList();
} }
public int Update(UserAccount t) public int Update(UserAccount t)

18
ViewModel/LogViewModel.cs

@ -12,23 +12,19 @@ namespace Audit.ViewModel
{ {
public class LogViewModel : ViewModelBase 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; } get
set { logCommand = value; }
}
public LogViewModel()
{ {
return new RelayCommand(() =>
logCommand = new RelayCommand(() =>
{ {
MessageBox.Show("成功");
}); });
} }
} }
*/
}
} }

26
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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -32,11 +34,9 @@ namespace Audit.Windows
private void Log(object sender, RoutedEventArgs e)//登录按钮 private void Log(object sender, RoutedEventArgs e)//登录按钮
{ {
string user = this.users.Text; if (this.users.Text == "sunlight")
string passwd = this.Passwds.Text;
if (user == "setup")
{ {
if (passwd == "setup") if (this.Passwds.Text == "sunlight")
{ {
MessageBox.Show("警告:进入设置模式请您明确操作目的及可能需承担的后果"); MessageBox.Show("警告:进入设置模式请您明确操作目的及可能需承担的后果");
Windows.Set_up setup = new Windows.Set_up(); Windows.Set_up setup = new Windows.Set_up();
@ -45,12 +45,26 @@ namespace Audit.Windows
} }
else else
{ {
MessageBox.Show("ERR01:拒绝认证");//设置密码错误 MessageBox.Show("ERR.01:拒绝登录");//设置密码错误
} }
} }
else 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();
}
} }
} }
} }

Loading…
Cancel
Save