You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
185 lines
5.8 KiB
185 lines
5.8 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using System.Configuration;
|
|
using System.Data.SqlClient;
|
|
using MESClassLibrary.BLL.BasicInfo;
|
|
|
|
namespace InjectionSearch
|
|
{
|
|
public partial class FrmLogin : Form
|
|
{
|
|
public Action<string, string> LoginAction = null;
|
|
public FrmLogin()
|
|
{
|
|
InitializeComponent();
|
|
StartPosition = FormStartPosition.CenterScreen;
|
|
Program.station = ConfigurationManager.AppSettings["Station"].ToString();
|
|
LoginAction = Login;
|
|
}
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
Login();
|
|
}
|
|
|
|
private void Login()
|
|
{
|
|
string stationID = "";
|
|
Program.station = ConfigurationManager.AppSettings["Station"].ToString();
|
|
Program.StationID = ConfigurationManager.AppSettings["StationID"].ToString();
|
|
Program.tableName = ConfigurationManager.AppSettings["tableName"].ToString();
|
|
OpenDb();
|
|
|
|
#region 判断输入合法性
|
|
|
|
if (textBox1.Text.Trim() == "")
|
|
{
|
|
MessageBox.Show("用户名不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
textBox1.Focus();
|
|
return;
|
|
}
|
|
|
|
if (textBox2.Text.Trim() == "")
|
|
{
|
|
MessageBox.Show("密码不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
textBox1.Focus();
|
|
return;
|
|
}
|
|
|
|
#endregion
|
|
LoginAction(textBox1.Text.Trim(), textBox2.Text.Trim());
|
|
|
|
|
|
//StationBLL sbll = new StationBLL();
|
|
//DataTable sdt = sbll.SearchInfoByNo(Program.station);
|
|
//if (sdt != null && sdt.Rows.Count > 0)
|
|
//{
|
|
// stationID = sdt.Rows[0]["StationID"].ToString();
|
|
//}
|
|
|
|
//sdt.Dispose();
|
|
|
|
//Program.OperatorName = textBox1.Text.Trim();
|
|
|
|
//OperatorBLL bll = new OperatorBLL();
|
|
|
|
//DataTable dt = bll.SearchInfoByNameAndPsw(textBox1.Text.Trim(), stationID, textBox2.Text.Trim());
|
|
//if (dt != null && dt.Rows.Count > 0)
|
|
//{
|
|
// if (ConfigurationManager.AppSettings["PageType"]?.ToString() == "RePrintBarCode")
|
|
// {
|
|
// Form fr = new FrmBarCodeSearch2502();
|
|
// fr.Show();
|
|
// }
|
|
// else
|
|
// {
|
|
// Form fr = new FrmBarCodeSearch2408();
|
|
// fr.Show();
|
|
// }
|
|
// this.Hide();
|
|
//}
|
|
|
|
}
|
|
void Login(string name, string pass)
|
|
{
|
|
string stationID = "";
|
|
StationBLL sbll = new StationBLL();
|
|
DataTable sdt = sbll.SearchInfoByNo(Program.station);
|
|
if (sdt != null && sdt.Rows.Count > 0)
|
|
{
|
|
stationID = sdt.Rows[0]["StationID"].ToString();
|
|
}
|
|
|
|
sdt.Dispose();
|
|
|
|
Program.OperatorName = textBox1.Text.Trim();
|
|
|
|
OperatorBLL bll = new OperatorBLL();
|
|
|
|
DataTable dt = bll.SearchInfoByNameAndPsw(textBox1.Text.Trim(), stationID, textBox2.Text.Trim());
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
Program.UserName = textBox1.Text.Trim();
|
|
if (ConfigurationManager.AppSettings["PageType"]?.ToString() == "RePrintBarCode")
|
|
{
|
|
Form fr = new FrmBarCodeSearch2502();
|
|
fr.Show();
|
|
}
|
|
else
|
|
{
|
|
|
|
Form fr = new FrmBarCodeSearch2408();
|
|
//fr.FormClosed += (arg1, ar2) => {
|
|
// Action act = ReOpen;
|
|
// act.BeginInvoke(null, null);
|
|
|
|
//};
|
|
|
|
fr.Show();
|
|
}
|
|
this.Hide();
|
|
}
|
|
else
|
|
{
|
|
//f7ce2efa-13ac-4daa-8c7e-8f6287889411
|
|
lbtip.Text = "用户名或者密码错误";
|
|
}
|
|
|
|
}
|
|
void ReOpen()
|
|
{
|
|
FrmLogin frm = new FrmLogin();
|
|
frm.Show();
|
|
//System.Diagnostics.Process.Start("InjectionSearch.exe");
|
|
}
|
|
private bool OpenDb()
|
|
{
|
|
bool OpenDb = false;
|
|
|
|
string value = ConfigurationManager.ConnectionStrings["SqlConnString"].ToString();
|
|
Program.DBConn = new SqlConnection(value);
|
|
if (Program.DBConn.State.ToString().ToUpper() == "OPEN") Program.DBConn.Close();
|
|
try
|
|
{
|
|
Program.DBConn.Open();
|
|
}
|
|
catch (Exception Err)
|
|
{
|
|
if (Err != null)
|
|
{
|
|
MessageBox.Show("数据库连接失败,请检查网络连接,并重新连接!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
return OpenDb;
|
|
}
|
|
}
|
|
|
|
OpenDb = true;
|
|
return OpenDb;
|
|
}
|
|
|
|
private void textBox2_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
if (e.KeyCode == Keys.Enter)
|
|
{
|
|
Login();
|
|
}
|
|
}
|
|
|
|
private void FrmLogin_Load(object sender, EventArgs e)
|
|
{
|
|
//var serverUrl = "http://10.60.101.59:8013/";
|
|
//var updateXmlFileName = "InjectionSearchUpdate.xml";
|
|
//var updater = new AutoUpdater();
|
|
//if (updater.CheckUpdateLoad(serverUrl, updateXmlFileName))
|
|
//{
|
|
// Environment.Exit(0);
|
|
//}
|
|
}
|
|
}
|
|
}
|
|
|