74 lines
2.2 KiB
C#
74 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;
|
|
this.Show();
|
|
Application.DoEvents();
|
|
|
|
if (this.tbID.Text.isEmpty() == false) tbPW.Focus();
|
|
else tbID.Focus();
|
|
}
|
|
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 encpass = Pub.MakePasswordEnc(tbPW.Text);
|
|
var ta = new dsMSSQLTableAdapters.UsersTableAdapter();
|
|
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 ;
|
|
FCOMMON.info.Login.no = userdr.id;
|
|
FCOMMON.info.Login.name = userdr.name;
|
|
FCOMMON.info.Login.dept = userdr.dept;
|
|
FCOMMON.info.Login.level = userdr.level;
|
|
FCOMMON.info.Login.email = userdr.email;
|
|
}
|
|
DialogResult = DialogResult.OK;
|
|
}
|
|
|
|
|
|
}
|
|
}
|