using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using BusinessRule;
namespace WinERP
{
public partial class FrmLogin : Form
{
private DataAccess.UserInfo currentUser = null;
public FrmLogin()
{
InitializeComponent();
}
private void FrmLogin_Load(object sender, EventArgs e)
{
DataAccess.ReadWriteXML rwXML = new DataAccess.ReadWriteXML();
string loginUserID = rwXML.Read("UserID");
UserInfo obj = new UserInfo(null);
obj.GetUserID(cbUserID, loginUserID);
if (cbUserID.SelectedText.Trim().Length > 0)
{
currentUser = DataAccess.UserInfo.GetUser(cbUserID.SelectedItem.ToString().Trim());
}
}
private void cbUserID_SelectedIndexChanged(object sender, EventArgs e)
{
currentUser = DataAccess.UserInfo.GetUser(cbUserID.SelectedItem.ToString().Trim());
tbUserName.Text = currentUser.UserName;
tbUserPwd.Focus();
tbUserPwd.SelectAll();
}
private void btnLogin_Click(object sender, EventArgs e)
{
if (tbUserPwd.Text.Trim() != currentUser.UserPwd)
{
MessageBox.Show("盞絏岿粇?叫?穝?癸??块??", "岿粇", MessageBoxButtons.OK, MessageBoxIcon.Error);
tbUserPwd.Focus();
tbUserPwd.SelectAll();
return;
}
if (!currentUser.UserState)
{
MessageBox.Show("赣眀腹??玛?叫蒓恨瞶?羛╰?", "岿粇", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
DataAccess.ReadWriteXML rwXML = new DataAccess.ReadWriteXML();
rwXML.Update("UserID", cbUserID.SelectedItem.ToString().Trim());
FrmMain frmMain = new FrmMain(this.currentUser);
frmMain.Show();
this.Visible = false;
}
private void btnCancel_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}