14 changed files with 179 additions and 13 deletions
@ -0,0 +1,27 @@ |
|||
<Window x:Class="SunlightCentralizedControlManagement_SCCM_.Login" |
|||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
|||
xmlns:input="clr-namespace:System.Windows.Input;assembly=PresentationCore" |
|||
xmlns:local="clr-namespace:SunlightCentralizedControlManagement_SCCM_" |
|||
xmlns:lang="clr-namespace:SunlightCentralizedControlManagement_SCCM_.Properties" |
|||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" |
|||
mc:Ignorable="d" Title="Login" |
|||
Height="320" Width="248" MaxHeight="320" MaxWidth="248" ResizeMode="NoResize" |
|||
Loaded="Window_Loaded" WindowStyle="None"> |
|||
<Grid> |
|||
<Rectangle HorizontalAlignment="Center" Height="118" VerticalAlignment="Top" Width="248"> |
|||
<Rectangle.Fill> |
|||
<ImageBrush ImageSource="/sunlight_logotext.jpg"/> |
|||
</Rectangle.Fill> |
|||
</Rectangle> |
|||
<ComboBox x:Name="User" IsTextSearchEnabled ="False" Height="24" Margin="60,164,10,0" VerticalAlignment="Top" FontSize="14" KeyUp="SearchBox_OnKeyDownd"/> |
|||
<PasswordBox x:Name="Pasword" Height="24" Margin="60,210,10,0" VerticalAlignment="Top" FontSize="14" KeyUp="SearchBox_OnKeyDownd"/> |
|||
<TextBlock HorizontalAlignment="Left" Height="26" Margin="10,163,0,0" TextWrapping="Wrap" Text="账号:" VerticalAlignment="Top" Width="45" FontSize="20" RenderTransformOrigin="0.833,0.478"/> |
|||
<TextBlock HorizontalAlignment="Left" Height="26" Margin="10,208,0,0" TextWrapping="Wrap" Text="密码:" VerticalAlignment="Top" Width="45" FontSize="20" RenderTransformOrigin="0.833,0.478"/> |
|||
<Button x:Name="logon" Content="登录" HorizontalAlignment="Left" Height="33" Margin="40,264,0,0" VerticalAlignment="Top" Width="64" Click="Button_Click_1" Background="#FFDDDDDD" Foreground="Black" BorderBrush="White"/> |
|||
<Button Content="退出" HorizontalAlignment="Right" Height="33" Margin="140,264,40,0" VerticalAlignment="Top" Width="64" Click="Button_Click" Background="#FFDDDDDD" Foreground="Black" BorderBrush="White"/> |
|||
<TextBlock Height="30" Margin="15,115,15,0" TextWrapping="Wrap" Text="尚彩中央控制平台" VerticalAlignment="Top" FontSize="20" HorizontalAlignment="Center"/> |
|||
</Grid> |
|||
</Window> |
|||
@ -0,0 +1,108 @@ |
|||
using SunlightCentralizedControlManagement_SCCM_.ViewModel; |
|||
using System; |
|||
using System.Data; |
|||
using System.Data.SqlClient; |
|||
using System.Linq; |
|||
using System.Windows; |
|||
using System.Windows.Forms; |
|||
using System.Windows.Input; |
|||
using System.Windows.Media; |
|||
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper; |
|||
|
|||
namespace SunlightCentralizedControlManagement_SCCM_ |
|||
{ |
|||
/// <summary>
|
|||
/// Login.xaml 的交互逻辑
|
|||
/// </summary>
|
|||
public partial class Login : Window |
|||
{ |
|||
public string INIPath = Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "SCCM.ini"; //配置文件路径
|
|||
|
|||
private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\SCCM.db"; //数据库路径
|
|||
DataTable logindataTable = new DataTable(); //建立login缓存
|
|||
|
|||
public Login() |
|||
{ |
|||
WindowStartupLocation = WindowStartupLocation.CenterScreen; |
|||
InitializeComponent(); |
|||
|
|||
UserClass.LogGing.LogGingDATA("SCCM_start"); |
|||
} |
|||
|
|||
private void Button_Click(object sender, RoutedEventArgs e) //退出按钮事件
|
|||
{ |
|||
UserClass.LogGing.LogGingDATA("SCCM_LogStop"); |
|||
Window window = Window.GetWindow(this); |
|||
window.Close(); |
|||
} |
|||
|
|||
private void Button_Click_1(object sender, RoutedEventArgs e) //登录按钮事件
|
|||
{ |
|||
string user = User.Text; |
|||
string pasword = Pasword.Password; ; |
|||
|
|||
if (User.Text == "") //检查用户名输入
|
|||
{ |
|||
System.Windows.MessageBox.Show(Properties.Resources.NPERR, "SCCM", MessageBoxButton.OK, MessageBoxImage.Error); |
|||
return; |
|||
} |
|||
|
|||
if ((user == "engineer" || user == "ENGINEER") && (pasword == "engineer" || pasword == "ENGINEER")) //确认账号是否是工程师
|
|||
{ |
|||
App.USER_Purview = "ENGINEER";//传入用户名
|
|||
|
|||
Window window = Window.GetWindow(this); |
|||
MainWindow Main = new MainWindow(); |
|||
window.Close(); |
|||
UserClass.LogGing.LogGingDATA("LOGon = ENGINEER"); |
|||
|
|||
Main.ShowDialog();//实例化并置顶打开窗口
|
|||
} |
|||
else |
|||
{ |
|||
var paw = logindataTable.Select("Name='" + user + "'").First().Field<string>("Password"); |
|||
if (paw == null) paw = ""; |
|||
|
|||
if (paw == pasword) |
|||
{ |
|||
App.USER_Purview = User.Text;//传入用户名
|
|||
|
|||
Window window = Window.GetWindow(this); |
|||
MainWindow Main = new MainWindow(); |
|||
window.Close(); |
|||
|
|||
UserClass.LogGing.LogGingDATA("LOGon = " + user); |
|||
Main.ShowDialog();//实例化并置顶打开窗口
|
|||
} |
|||
else |
|||
{ |
|||
System.Windows.MessageBox.Show(Properties.Resources.NPERR, "SCCM", MessageBoxButton.OK, MessageBoxImage.Error); |
|||
} |
|||
} |
|||
} |
|||
|
|||
private void SearchBox_OnKeyDownd(object sender, System.Windows.Input.KeyEventArgs e) //回车跳转功能
|
|||
{ |
|||
if (e.Key == Key.Enter) |
|||
{ |
|||
//SendKeys.SendWait("{Tab}");
|
|||
UserClass.PressKey.PressKeys(Keys.Tab, false); |
|||
UserClass.PressKey.PressKeys(Keys.Tab, true); |
|||
} |
|||
} |
|||
|
|||
private void Window_Loaded(object sender, RoutedEventArgs e) |
|||
{ |
|||
logon.IsEnabled = false; |
|||
SQLiteHelper db = new SQLiteHelper(DBAddress); //数据库连接路径
|
|||
db.Open(); //打开数据库
|
|||
logindataTable = db.ExecuteDataSet("select * from USER", null).Tables[0]; //读取表写入缓存
|
|||
db.Close(); |
|||
User.ItemsSource = logindataTable.AsEnumerable().Select(rowdata => rowdata.Field<string>("Name"));//转换
|
|||
logon.IsEnabled = true; //允许登录按钮
|
|||
UserClass.PressKey.PressKeys(Keys.Tab, false); |
|||
UserClass.PressKey.PressKeys(Keys.Tab, true); |
|||
} |
|||
|
|||
} |
|||
} |
|||
|
After Width: | Height: | Size: 231 KiB |
Loading…
Reference in new issue