📄 frmenter.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Hotel.Operation;
namespace Hotel.UI
{
public partial class frmEnter : Form
{
public frmEnter()
{
InitializeComponent();
}
public bool en = false;
UserInfoAccess objUserInfoAccess =null;
int num = 0;//统计次数
//添加所有用户编号到cboName
private void frmEnter_Load(object sender, EventArgs e)
{
objUserInfoAccess = new UserInfoAccess();
ArrayList arr = new ArrayList();
arr=objUserInfoAccess.GetUserID();
for (int i = 0; i < arr.Count; i++)
{
cboName.Items.Add(arr[i].ToString());
}
}
private void cboName_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)13)
{
txtPwd.Focus();
}
}
private void txtPwd_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)13)
{
btnLogin.Focus();
}
}
private void btnExit_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void btnLogin_Click(object sender, EventArgs e)
{
//判断是否为空
if (cboName.Text.Trim() == string.Empty)
{
cboName.Text = "";
MessageBox.Show("请输入登录编号!", "提示");
return;
}
if (txtPwd.Text.Trim() == string.Empty)
{
txtPwd.Text = "";
MessageBox.Show("请输入密码!", "提示");
return;
}
string userID = cboName.Text.Trim();
string pwd = txtPwd.Text.Trim();
if (objUserInfoAccess.GetPassword(userID, pwd))
{
Program.strName = cboName.Text.Trim();//保留用户名
en = true;
this.Close();
}
else
{
MessageBox.Show("用户编号或密码错误!", "提示");
cboName.Focus();//获取焦点
}
num++;//统计次数
if (num > 2)
{
MessageBox.Show("您输入错误次数受限,系统关闭!", "提示");
Application.Exit();
}
}
private void label1_Click(object sender, EventArgs e)
{
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -