73 lines
2.2 KiB
C#
73 lines
2.2 KiB
C#
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;
|
|
|
|
namespace Project.Dialog
|
|
{
|
|
public partial class fLogin : Form
|
|
{
|
|
public fLogin()
|
|
{
|
|
InitializeComponent();
|
|
this.tbID.KeyDown += (s1, e1) => { if (e1.KeyCode == Keys.Enter) tbPW.Focus(); };
|
|
this.tbPW.KeyDown += (s1, e1) => { if (e1.KeyCode == Keys.Enter) btLogin.PerformClick(); };
|
|
this.KeyPreview = true;
|
|
this.KeyDown += (s1, e1) => {
|
|
if (e1.KeyCode == Keys.Escape) this.Close();
|
|
};
|
|
}
|
|
private void fLogin_Load(object sender, EventArgs e)
|
|
{
|
|
this.tbID.Text = Pub.setting.lastid;
|
|
}
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
if (this.tbID.Text.isEmpty())
|
|
{
|
|
tbID.Focus();
|
|
return;
|
|
}
|
|
if(this.tbPW.Text.isEmpty())
|
|
{
|
|
tbPW.Focus();
|
|
return;
|
|
}
|
|
|
|
//180605
|
|
Pub.setting.lastid = tbID.Text.Trim();
|
|
Pub.setting.Save();
|
|
|
|
var sha1 = new System.Security.Cryptography.SHA1CryptoServiceProvider();
|
|
var buffer = System.Text.Encoding.Default.GetBytes(tbPW.Text);
|
|
var hashbuf = sha1.ComputeHash(buffer);
|
|
var encpass = hashbuf.GetHexString();
|
|
var ta = new dsMSSQLTableAdapters.UsersTableAdapter();
|
|
encpass = encpass.Replace(" ", "");
|
|
var users = ta.GetIDPW(tbID.Text, encpass);
|
|
if(users.Rows.Count < 1)
|
|
{
|
|
Util.MsgE("No user");
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
var userdr = users.Rows[0] as dsMSSQL.UsersRow ;
|
|
Pub.Login.no = userdr.id;
|
|
Pub.Login.name = userdr.name;
|
|
Pub.Login.dept = userdr.dept;
|
|
Pub.Login.level = userdr.level;
|
|
Pub.Login.email = userdr.email;
|
|
}
|
|
DialogResult = DialogResult.OK;
|
|
}
|
|
|
|
|
|
}
|
|
}
|