login功能加入用户登录及下拉框显示使用者
This commit is contained in:
commit
55deb51005
3 files changed
+62
-9
No files matched your search
+1
-1
@@ -14,7 +14,7 @@
|
||||
<ImageBrush ImageSource="/sunlight_logotext.jpg"/>
|
||||
</Rectangle.Fill>
|
||||
</Rectangle>
|
||||
<ComboBox x:Name="User" Height="24" Margin="60,164,10,0" VerticalAlignment="Top" FontSize="14" IsEditable="True" KeyUp="SearchBox_OnKeyDownd"/>
|
||||
<ComboBox x:Name="User" DisplayMemberPath="UserCode" IsTextSearchEnabled ="False" Height="24" Margin="60,164,10,0" VerticalAlignment="Top" FontSize="14" IsEditable="True" 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"/>
|
||||
|
||||
+57
-3
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-5
@@ -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();//实例化并置顶打开数据库设置窗口
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user