登录页面逻辑修改
This commit is contained in:
commit
fb4c0cb9b8
3 files changed
+41
-32
No files matched your search
+4
-4
@@ -16,10 +16,10 @@
|
|||||||
<ImageBrush ImageSource="/sunlight_logotext.jpg"/>
|
<ImageBrush ImageSource="/sunlight_logotext.jpg"/>
|
||||||
</Rectangle.Fill>
|
</Rectangle.Fill>
|
||||||
</Rectangle>
|
</Rectangle>
|
||||||
<ComboBox x:Name="User" IsTextSearchEnabled ="False" Height="24" Margin="60,164,10,0" VerticalAlignment="Top" FontSize="14" KeyUp="SearchBox_OnKeyDownd"/>
|
<ComboBox x:Name="User" Height="30" Margin="60,164,10,0" VerticalAlignment="Top" FontSize="14" KeyUp="SearchBox_OnKeyDownd" IsEditable="True"/>
|
||||||
<PasswordBox x:Name="Pasword" Height="24" Margin="60,210,10,0" VerticalAlignment="Top" FontSize="14" KeyUp="SearchBox_OnKeyDownd"/>
|
<PasswordBox x:Name="Pasword" Height="30" 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="30" 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"/>
|
<TextBlock HorizontalAlignment="Left" Height="30" 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 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"/>
|
<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"/>
|
<TextBlock Height="30" Margin="15,115,15,0" TextWrapping="Wrap" Text="尚彩中央控制平台" VerticalAlignment="Top" FontSize="20" HorizontalAlignment="Center"/>
|
||||||
|
|||||||
+33
-27
@@ -40,45 +40,51 @@ namespace SunlightCentralizedControlManagement_SCCM_
|
|||||||
{
|
{
|
||||||
string user = User.Text;
|
string user = User.Text;
|
||||||
string pasword = Pasword.Password; ;
|
string pasword = Pasword.Password; ;
|
||||||
|
try
|
||||||
if (User.Text == "") //检查用户名输入
|
|
||||||
{
|
{
|
||||||
System.Windows.MessageBox.Show(Properties.Resources.NPERR, "SCCM", MessageBoxButton.OK, MessageBoxImage.Error);
|
if (User.Text == "") //检查用户名输入
|
||||||
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;//传入用户名
|
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);
|
Window window = Window.GetWindow(this);
|
||||||
MainWindow Main = new MainWindow();
|
MainWindow Main = new MainWindow();
|
||||||
window.Close();
|
window.Close();
|
||||||
|
UserClass.LogGing.LogGingDATA("LOGon = ENGINEER");
|
||||||
|
|
||||||
UserClass.LogGing.LogGingDATA("LOGon = " + user);
|
|
||||||
Main.ShowDialog();//实例化并置顶打开窗口
|
Main.ShowDialog();//实例化并置顶打开窗口
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
System.Windows.MessageBox.Show(Properties.Resources.NPERR, "SCCM", MessageBoxButton.OK, MessageBoxImage.Error);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
System.Windows.MessageBox.Show(Properties.Resources.NPERR, "SCCM", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SearchBox_OnKeyDownd(object sender, System.Windows.Input.KeyEventArgs e) //回车跳转功能
|
private void SearchBox_OnKeyDownd(object sender, System.Windows.Input.KeyEventArgs e) //回车跳转功能
|
||||||
@@ -96,7 +102,7 @@ namespace SunlightCentralizedControlManagement_SCCM_
|
|||||||
logon.IsEnabled = false;
|
logon.IsEnabled = false;
|
||||||
SQLiteHelper db = new SQLiteHelper(DBAddress); //数据库连接路径
|
SQLiteHelper db = new SQLiteHelper(DBAddress); //数据库连接路径
|
||||||
db.Open(); //打开数据库
|
db.Open(); //打开数据库
|
||||||
logindataTable = db.ExecuteDataSet("select * from USER", null).Tables[0]; //读取表写入缓存
|
logindataTable = db.ExecuteDataSet("select * from USER where Groups<>'CHIEF'", null).Tables[0]; //读取表写入缓存
|
||||||
db.Close();
|
db.Close();
|
||||||
User.ItemsSource = logindataTable.AsEnumerable().Select(rowdata => rowdata.Field<string>("Name"));//转换
|
User.ItemsSource = logindataTable.AsEnumerable().Select(rowdata => rowdata.Field<string>("Name"));//转换
|
||||||
logon.IsEnabled = true; //允许登录按钮
|
logon.IsEnabled = true; //允许登录按钮
|
||||||
|
|||||||
+4
-1
@@ -207,10 +207,13 @@ namespace SunlightCentralizedControlManagement_SCCM_
|
|||||||
|
|
||||||
private void Window_Loaded(object sender, RoutedEventArgs e)//打开页面
|
private void Window_Loaded(object sender, RoutedEventArgs e)//打开页面
|
||||||
{
|
{
|
||||||
username.ItemsSource = MainWindowViewModel.USER_data.Select(
|
if (App.USER_Purview != "ENGINEER")
|
||||||
|
{
|
||||||
|
username.ItemsSource = MainWindowViewModel.USER_data.Select(
|
||||||
"Groups='" + MainWindowViewModel.USER_data.Select("Name='" + App.USER_Purview + "'").
|
"Groups='" + MainWindowViewModel.USER_data.Select("Name='" + App.USER_Purview + "'").
|
||||||
First().Field<string>("Groups").ToString() + "'").
|
First().Field<string>("Groups").ToString() + "'").
|
||||||
AsEnumerable().Select(rowdata => rowdata.Field<string>("Name")).ToList();
|
AsEnumerable().Select(rowdata => rowdata.Field<string>("Name")).ToList();
|
||||||
|
}
|
||||||
username.Text = App.USER_Purview;
|
username.Text = App.USER_Purview;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user