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.
194 lines
5.7 KiB
194 lines
5.7 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using System.Configuration;
|
|
using System.Data.SqlClient;
|
|
using System.Diagnostics;
|
|
using System.Reflection;
|
|
using System.Runtime.InteropServices;
|
|
using MESClassLibrary.BLL.BasicInfo;
|
|
using MESClassLibrary.Model;
|
|
using MESClassLibrary.BLL.Log;
|
|
|
|
namespace PaintingPC
|
|
{
|
|
public partial class FrmLogin : Form
|
|
{
|
|
private string _defualtPage = string.Empty;
|
|
public FrmLogin()
|
|
{
|
|
InitializeComponent();
|
|
this.StartPosition = FormStartPosition.CenterScreen;
|
|
Program.station = ConfigurationManager.AppSettings["Station"].ToString();
|
|
}
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
lbtip.Text = "";
|
|
_defualtPage = ConfigurationManager.AppSettings["DefualtPage"]?.ToString();
|
|
|
|
OpenDb();
|
|
string stationID = "";
|
|
#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
|
|
|
|
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();
|
|
|
|
|
|
OperatorBLL bll = new OperatorBLL();
|
|
|
|
DataTable dt = bll.SearchInfoByNameAndPsw(textBox1.Text.Trim(), stationID, textBox2.Text.Trim());
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
this.Visible = false;
|
|
Form fr = new FrmQuality(false);
|
|
fr.Show();
|
|
|
|
}
|
|
else
|
|
{
|
|
//f7ce2efa-13ac-4daa-8c7e-8f6287889411
|
|
lbtip.Text = "用户名或者密码错误";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
|
}
|
|
}
|
|
|
|
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 button2_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
|
|
private void textBox1_Click(object sender, EventArgs e)
|
|
{
|
|
ShowInputPanel();
|
|
}
|
|
|
|
private const Int32 WM_SYSCOMMAND = 274;
|
|
|
|
private const UInt32 SC_CLOSE = 61536;
|
|
|
|
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
|
|
|
private static extern bool PostMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
|
|
|
|
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
|
|
|
private static extern bool PostMessage(IntPtr hWnd, int Msg, uint wParam, uint lParam);
|
|
|
|
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
|
|
|
private static extern bool PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
|
|
|
|
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
|
|
|
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
|
|
|
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
|
|
|
private static extern int RegisterWindowMessage(string lpString);
|
|
|
|
|
|
|
|
//显示屏幕键盘
|
|
|
|
public static int ShowInputPanel()
|
|
{
|
|
|
|
try
|
|
{
|
|
|
|
dynamic file = "C:\\Program Files\\Common Files\\microsoft shared\\ink\\TabTip.exe";
|
|
|
|
if (!System.IO.File.Exists(file))
|
|
|
|
return -1;
|
|
|
|
Process.Start(file);
|
|
|
|
//return SetUnDock(); //不知SetUnDock()是什么,所以直接注释返回1
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
catch (Exception)
|
|
{
|
|
|
|
return 255;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private void textBox2_Click(object sender, EventArgs e)
|
|
{
|
|
ShowInputPanel();
|
|
}
|
|
|
|
private void FrmLogin_Load(object sender, EventArgs e)
|
|
{
|
|
var serverUrl = "http://10.60.101.59:8013/";
|
|
var updateXmlFileName = "InjectionUpdate.xml";
|
|
var updater = new AutoUpdater();
|
|
if (updater.CheckUpdateLoad(serverUrl, updateXmlFileName))
|
|
{
|
|
Environment.Exit(0);
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|