using GalaSoft.MvvmLight.Command;
using MahApps.Metro.Controls;
using Models;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Audit.Windows
{
///
/// LogWindow.xaml 的交互逻辑
///
public partial class LogWindow : MetroWindow
{
///
/// LogWindow
///
public LogWindow()
{
InitializeComponent();
}
private void Exit(object sender, RoutedEventArgs e)//退出按钮
{
Application.Current.Shutdown();//关闭窗口
}
///
///AuditData
///
public AuditData AuditData { get; set; } = AuditData.Instance;//数据库引用
///
/// UserAccount
///
public UserAccount UserAccount { get; private set; } = AuditData.Instance.Useraccount;//数据库引用
///
/// Log
///
private void Log(object sender, RoutedEventArgs e)//登录按钮
{
string users = this.users.Text;
string Passwds = this.Passwds.Text;
if ((users == "sunlight") || (users == "SUNLIGHT"))//内置账号
{
if ((Passwds == "sql") || (Passwds == "SQL"))//数据库设置页面判断
{
MessageBox.Show("警告:进入数据库设置请您明确操作目的及可能需承担的后果");
Windows.Set_up_Sql setup = new Windows.Set_up_Sql();
setup.Show();//实例化并打开设置窗口
this.Close();//关闭当前窗口
}
else
{
if ((Passwds == "sunlight") || (users == "SUNLIGHT"))//主页面判断
{
MessageBox.Show("SC:开启主页面");
MainWindow mainWindow = new MainWindow();
mainWindow.Show();//实例化并打开主窗口
this.Close();//关闭当前窗口
}
else
{
MessageBox.Show("ERR.C0001:拒绝登录");//设置密码错误
}
}
}
else
{
UserAccountProvide UserAccountProvide = new UserAccountProvide();//实例化数据库用户表
var usersql = UserAccountProvide.Select().FirstOrDefault(item => item.UserCode == users && item.PassWord == Passwds);//查询比较用户信息
if (usersql == null)//判断查询结果
{
MessageBox.Show("ERR.C0000:用户名或密码错误");
}
else
{
MainWindow mainWindow = new MainWindow();
mainWindow.Show();//实例化并打开主窗口
this.Close();//关闭当前窗口
}
}
}
}
}