diff --git a/Login.xaml b/Login.xaml
index f60fb42..8f24e84 100644
--- a/Login.xaml
+++ b/Login.xaml
@@ -16,10 +16,10 @@
-
-
-
-
+
+
+
+
diff --git a/Login.xaml.cs b/Login.xaml.cs
index 241196c..d41b01d 100644
--- a/Login.xaml.cs
+++ b/Login.xaml.cs
@@ -40,45 +40,51 @@ namespace SunlightCentralizedControlManagement_SCCM_
{
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")) //确认账号是否是工程师
+ try
{
- 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("Password");
- if (paw == null) paw = "";
+ if (User.Text == "") //检查用户名输入
+ {
+ System.Windows.MessageBox.Show(Properties.Resources.NPERR, "SCCM", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
- if (paw == pasword)
+ if ((user == "engineer" || user == "ENGINEER") && (pasword == "engineer" || pasword == "ENGINEER")) //确认账号是否是工程师
{
- App.USER_Purview = User.Text;//传入用户名
+ App.USER_Purview = "ENGINEER";//传入用户名
Window window = Window.GetWindow(this);
MainWindow Main = new MainWindow();
window.Close();
+ UserClass.LogGing.LogGingDATA("LOGon = ENGINEER");
- UserClass.LogGing.LogGingDATA("LOGon = " + user);
Main.ShowDialog();//实例化并置顶打开窗口
}
else
{
- System.Windows.MessageBox.Show(Properties.Resources.NPERR, "SCCM", MessageBoxButton.OK, MessageBoxImage.Error);
+ var paw = logindataTable.Select("Name='" + user + "'").First().Field("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) //回车跳转功能
@@ -96,7 +102,7 @@ namespace SunlightCentralizedControlManagement_SCCM_
logon.IsEnabled = false;
SQLiteHelper db = new SQLiteHelper(DBAddress); //数据库连接路径
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();
User.ItemsSource = logindataTable.AsEnumerable().Select(rowdata => rowdata.Field("Name"));//转换
logon.IsEnabled = true; //允许登录按钮
diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs
index 17a29c9..b45bae9 100644
--- a/MainWindow.xaml.cs
+++ b/MainWindow.xaml.cs
@@ -207,10 +207,13 @@ namespace SunlightCentralizedControlManagement_SCCM_
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 + "'").
First().Field("Groups").ToString() + "'").
AsEnumerable().Select(rowdata => rowdata.Field("Name")).ToList();
+ }
username.Text = App.USER_Purview;
}
}