diff --git a/Login.xaml b/Login.xaml index 4b040e4..1dbe362 100644 --- a/Login.xaml +++ b/Login.xaml @@ -14,7 +14,7 @@ - + diff --git a/Login.xaml.cs b/Login.xaml.cs index cadf5f9..cf759e4 100644 --- a/Login.xaml.cs +++ b/Login.xaml.cs @@ -18,6 +18,7 @@ using System.Data.SqlClient; using System.Data; using System.Security.Policy; using System.IO; +using formula_manage.Windows; namespace formula_manage { @@ -33,7 +34,9 @@ namespace formula_manage public string INIPath = Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "formula.ini"; //配置文件路径 - public Login() + DataTable logindataTable = new DataTable(); //建立login缓存 + + public Login() { WindowStartupLocation = WindowStartupLocation.CenterScreen; InitializeComponent(); @@ -53,6 +56,7 @@ namespace formula_manage wr.WriteLine(Log_time + "FORMULA_start"); wr.Close(); } + } private void Button_Click(object sender, RoutedEventArgs e) //退出按钮事件 @@ -62,7 +66,16 @@ namespace formula_manage private void Button_Click_1(object sender, RoutedEventArgs e) //登录按钮事件 { - if ((User.Text == "engineer" || User.Text == "ENGINEER") && (Pasword.Password == "engineer" || Pasword.Password == "ENGINEER")) + string user = User.Text; + string pasword = Pasword.Password; ; + + if (User.Text == "") + { + System.Windows.MessageBox.Show("请输入用户名"); + return; + } + + if ((user == "engineer" || user == "ENGINEER") && (pasword == "engineer" || pasword == "ENGINEER")) { App.USER_Purview = "ENGINEER";//传入用户名 @@ -70,9 +83,27 @@ namespace formula_manage MainWindow Main = new MainWindow(); window.Close(); Main.ShowDialog();//实例化并置顶打开信息窗口 - } + } else { + string var_sql; + + if (pasword =="") var_sql = "[UserCode]='" + user + "' and [PassWord] is null"; + else var_sql = "[UserCode]='" + user + "' and [PassWord]='" + pasword + "'"; + + var loginOK = this.logindataTable.Select(var_sql).FirstOrDefault(); + + if (loginOK != null) + { + App.USER_Purview = User.Text;//传入用户名 + + Window window = Window.GetWindow(this); + MainWindow Main = new MainWindow(); + window.Close(); + Main.ShowDialog();//实例化并置顶打开窗口 + + } + else System.Windows.MessageBox.Show("账号或密码错误"); } } @@ -174,6 +205,29 @@ namespace formula_manage logon.IsEnabled = true; //允许登录按钮 UserClass.PressKey.PressKeys(Keys.Tab, false); UserClass.PressKey.PressKeys(Keys.Tab, true); + + if (DISPENLINK.Background == Brushes.Green) + { + string user_sql = "SELECT UserCode ,PassWord ,UserSetup ,Capacity ,GROUP_CODE ,Note FROM [Dispensing].[dbo].[UserAccount]";//查询语句 + + try + { + await conn_SC.OpenAsync(); //打开数据连接 + SqlDataAdapter Stuff_data = new SqlDataAdapter(user_sql, Connstr_SC); //查询 + + Stuff_data.Fill(logindataTable); //查询结果存入缓存 + conn_SC.Close(); //关闭连接 + + User.ItemsSource = logindataTable.DefaultView; //数据加入表格 + } + catch (Exception) + { + System.Windows.MessageBox.Show("请求信息失败,检查连接"); + return; + } + } + + } } } diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index e0f0ab1..04bcb0b 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -172,21 +172,19 @@ namespace formula_manage string PreposeT; //料单时间 bool Loginprint; bool Loginanew; - bool LoginMAC; + private void Window_MIN(object sender, RoutedEventArgs e) { UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(INIPath); - // Loginprint = Boolean.Parse(Configini.IniReadvalue("SOFTWARE_SET", "L2")); //是否立即打印料单 - // Loginanew = Boolean.Parse(Configini.IniReadvalue("SOFTWARE_SET", "L3")); //是否立即打印料单 + Loginprint = Boolean.Parse(Configini.IniReadvalue("SOFTWARE_SET", "L2")); //是否立即打印料单 + Loginanew = Boolean.Parse(Configini.IniReadvalue("SOFTWARE_SET", "L3")); //是否立即打印料单 Machine.IsReadOnly = Boolean.Parse(Configini.IniReadvalue("SOFTWARE_SET", "L4")); //允许自定义机台 Prepose = Configini.IniReadvalue("SOFTWARE_SET", "T1"); //自定义料单前缀 PreposeT = Configini.IniReadvalue("SOFTWARE_SET", "T2"); //自定义料单时间 Number.Text = Prepose + System.DateTime.Now.ToString(PreposeT); //生成料单号 - - } private void Tb_KeyPress(object sender, TextCompositionEventArgs e)//输入事件 @@ -205,6 +203,7 @@ namespace formula_manage private void SQL(object sender, RoutedEventArgs e) { + System.Windows.MessageBox.Show("进入数据库设置请您明确操作目的及可能需承担的后果", "警告"); Windows.Sql sql= new Windows.Sql(); sql.ShowDialog();//实例化并置顶打开数据库设置窗口 }