Browse Source

添加登录页面

master
sc 9 months ago
parent
commit
65fc78f092
  1. 3
      App.xaml
  2. 15
      App.xaml.cs
  3. 27
      Login.xaml
  4. 108
      Login.xaml.cs
  5. 9
      Properties/Resources.Designer.cs
  6. 3
      Properties/Resources.en-US.resx
  7. 3
      Properties/Resources.resx
  8. 3
      Properties/Resources.zh-CN.resx
  9. 4
      Properties/Resources.zh-TW.resx
  10. 8
      SunlightCentralizedControlManagement_SCCM_.csproj
  11. 3
      UserClass/AsyncTcpClient.cs
  12. 2
      UserClass/LogGing.cs
  13. 4
      View/ProductionPlanningEdit.xaml.cs
  14. BIN
      sunlight_logotext.jpg

3
App.xaml

@ -1,7 +1,8 @@
<Application x:Class="SunlightCentralizedControlManagement_SCCM_.App" <Application x:Class="SunlightCentralizedControlManagement_SCCM_.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:SunlightCentralizedControlManagement_SCCM_" xmlns:local="clr-namespace:SunlightCentralizedControlManagement_SCCM_"
Startup="Application_Startup"
StartupUri="MainWindow.xaml"> StartupUri="MainWindow.xaml">
<Application.Resources> <Application.Resources>
<ResourceDictionary> <ResourceDictionary>

15
App.xaml.cs

@ -1,4 +1,4 @@
using DyeingComputer.UserClass; using SunlightCentralizedControlManagement_SCCM_.UserClass;
using LiveChartsCore; using LiveChartsCore;
using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView;
using SkiaSharp; using SkiaSharp;
@ -22,6 +22,10 @@ namespace SunlightCentralizedControlManagement_SCCM_
/// </summary> /// </summary>
public partial class App : Application public partial class App : Application
{ {
/// <summary>
///公共变量来自Login的用户名
/// </summary>
public static string USER_Purview { get; set; }
private static Assembly OnResolveAssembly(object sender, ResolveEventArgs args) private static Assembly OnResolveAssembly(object sender, ResolveEventArgs args)
{ {
Assembly executingAssembly = Assembly.GetExecutingAssembly(); Assembly executingAssembly = Assembly.GetExecutingAssembly();
@ -119,10 +123,10 @@ namespace SunlightCentralizedControlManagement_SCCM_
{ {
MessageBox.Show("发生了一个无法处理的错误!请联系SUNLIGHT处理!" MessageBox.Show("发生了一个无法处理的错误!请联系SUNLIGHT处理!"
+ "(1)错误" + Environment.NewLine + "(1)错误" + Environment.NewLine
// + "(2)错误源:" + e.Exception.InnerException.Source + Environment.NewLine + "(2)错误源:" + e.Exception.InnerException.Source + Environment.NewLine
+ "(3)错误信息:" + e.Exception.Message + Environment.NewLine + "(3)错误信息:" + e.Exception.Message + Environment.NewLine
// + "(4)详细信息:" + e.Exception.InnerException.Message + Environment.NewLine + "(4)详细信息:" + e.Exception.InnerException.Message + Environment.NewLine
// + "(5)报错区域:" + e.Exception.InnerException.StackTrace + "(5)报错区域:" + e.Exception.InnerException.StackTrace
); );
} }
@ -169,7 +173,8 @@ namespace SunlightCentralizedControlManagement_SCCM_
/// </summary> /// </summary>
private void Application_Startup(object sender, StartupEventArgs e) private void Application_Startup(object sender, StartupEventArgs e)
{ {
Application.Current.StartupUri = new Uri("MainWindow.xaml", UriKind.Relative);//和MainWindwo同一目录 // Application.Current.StartupUri = new Uri("Login.xaml", UriKind.Relative);
Current.StartupUri = new Uri("MainWindow.xaml", UriKind.Relative);//和MainWindwo同一目录
} }
public static class SystemSleepTool public static class SystemSleepTool

27
Login.xaml

@ -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>

108
Login.xaml.cs

@ -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);
}
}
}

9
Properties/Resources.Designer.cs

@ -1446,6 +1446,15 @@ namespace SunlightCentralizedControlManagement_SCCM_.Properties {
} }
} }
/// <summary>
/// 查找类似 The account number or password is incorrect 的本地化字符串。
/// </summary>
public static string NPERR {
get {
return ResourceManager.GetString("NPERR", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Number 的本地化字符串。 /// 查找类似 Number 的本地化字符串。
/// </summary> /// </summary>

3
Properties/Resources.en-US.resx

@ -951,4 +951,7 @@
<data name="log" xml:space="preserve"> <data name="log" xml:space="preserve">
<value>Log</value> <value>Log</value>
</data> </data>
<data name="NPERR" xml:space="preserve">
<value>The account number or password is incorrect</value>
</data>
</root> </root>

3
Properties/Resources.resx

@ -951,4 +951,7 @@
<data name="log" xml:space="preserve"> <data name="log" xml:space="preserve">
<value>Log</value> <value>Log</value>
</data> </data>
<data name="NPERR" xml:space="preserve">
<value>The account number or password is incorrect</value>
</data>
</root> </root>

3
Properties/Resources.zh-CN.resx

@ -951,4 +951,7 @@
<data name="log" xml:space="preserve"> <data name="log" xml:space="preserve">
<value>日志</value> <value>日志</value>
</data> </data>
<data name="NPERR" xml:space="preserve">
<value>账号或密码错误</value>
</data>
</root> </root>

4
Properties/Resources.zh-TW.resx

@ -943,10 +943,10 @@
<value>頁面不存在</value> <value>頁面不存在</value>
</data> </data>
<data name="ENWOIP" xml:space="preserve"> <data name="ENWOIP" xml:space="preserve">
<value>禁止編輯非待處理工單</value> <value>禁止編輯非待處理工單</value>
</data> </data>
<data name="EHCIP" xml:space="preserve"> <data name="EHCIP" xml:space="preserve">
<value>禁止編輯歷史工單</value> <value>禁止編輯歷史工單</value>
</data> </data>
<data name="log" xml:space="preserve"> <data name="log" xml:space="preserve">
<value>日誌</value> <value>日誌</value>

8
SunlightCentralizedControlManagement_SCCM_.csproj

@ -100,6 +100,9 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
</ApplicationDefinition> </ApplicationDefinition>
<Compile Include="ConvertMoels\BoolRBConvert.cs" /> <Compile Include="ConvertMoels\BoolRBConvert.cs" />
<Compile Include="Login.xaml.cs">
<DependentUpon>Login.xaml</DependentUpon>
</Compile>
<Compile Include="UserClass\AsyncTcpClient.cs" /> <Compile Include="UserClass\AsyncTcpClient.cs" />
<Compile Include="UserClass\ClsLock.cs" /> <Compile Include="UserClass\ClsLock.cs" />
<Compile Include="UserClass\CRCcheck16.cs" /> <Compile Include="UserClass\CRCcheck16.cs" />
@ -184,6 +187,10 @@
<Compile Include="WindowsView\ViewStep.xaml.cs"> <Compile Include="WindowsView\ViewStep.xaml.cs">
<DependentUpon>ViewStep.xaml</DependentUpon> <DependentUpon>ViewStep.xaml</DependentUpon>
</Compile> </Compile>
<Page Include="Login.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="MainWindow.xaml"> <Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
@ -399,6 +406,7 @@
<Content Include="Fonts\font-awesome-4.7.0\css\font-awesome.css" /> <Content Include="Fonts\font-awesome-4.7.0\css\font-awesome.css" />
<Content Include="Fonts\font-awesome-4.7.0\css\font-awesome.min.css" /> <Content Include="Fonts\font-awesome-4.7.0\css\font-awesome.min.css" />
<Content Include="Fonts\font-awesome-4.7.0\fonts\fontawesome-webfont.svg" /> <Content Include="Fonts\font-awesome-4.7.0\fonts\fontawesome-webfont.svg" />
<Resource Include="sunlight_logotext.jpg" />
<Resource Include="WindowsView\sunlight_logotext.jpg" /> <Resource Include="WindowsView\sunlight_logotext.jpg" />
<Resource Include="sunlightlogo.jpg" /> <Resource Include="sunlightlogo.jpg" />
<Resource Include="sunlightlogo.ico" /> <Resource Include="sunlightlogo.ico" />

3
UserClass/AsyncTcpClient.cs

@ -1,5 +1,4 @@
using SunlightCentralizedControlManagement_SCCM_.UserClass; using System;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using System.Linq; using System.Linq;

2
UserClass/LogGing.cs

@ -5,7 +5,7 @@ using System.Data;
using System.IO; using System.IO;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TaskbarClock; using static System.Windows.Forms.VisualStyles.VisualStyleElement.TaskbarClock;
namespace DyeingComputer.UserClass namespace SunlightCentralizedControlManagement_SCCM_.UserClass
{ {
public class LogGing public class LogGing
{ {

4
View/ProductionPlanningEdit.xaml.cs

@ -391,8 +391,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
} }
} }
string ProgramID; //string ProgramID;
string ProgramNAME; //string ProgramNAME;
string Numder = null; string Numder = null;
string ID = null; string ID = null;
string P1, P2, P3, P4, P5; string P1, P2, P3, P4, P5;

BIN
sunlight_logotext.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 231 KiB

Loading…
Cancel
Save