|
|
|
@ -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";//传入用户名
|
|
|
|
|
|
|
|
@ -73,6 +86,24 @@ namespace formula_manage |
|
|
|
} |
|
|
|
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; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|