登陆界面的制作

1.登陆界面

登陆界面.JPG

2.登陆界面实现的功能描述

能够实现用户类型以收银员和库管员这两种叫角色
实现用户名和密码登录成功和显示失败
窗口大小不能改变
点击退出 退出应用程序

3.登陆界面各参数控制

label1控件

属性
text 用户类型

label2控件

属性
text 用户名

label3控件

属性
text 密码

comboBox1控件

属性
编辑项 收银员、库管员

button1控件

属性
MaxLength 9

button2控件

属性
PasswordChar *

4.重要方法描述

默认角色

private void Form1_Load(object sender, EventArgs e)
{
this.comboBox1.SelectedIndex = 0;
}

设置用户的参数以及密码并显示相应的图标

private void button1_Click(object sender, EventArgs e)
{
if (this.textBox1.Text == "123" && this.textBox2.Text == "123" && this.comboBox1.SelectedItem == "收银员")
{
MessageBox.Show("正确", "提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Asterisk);
}
else
if (this.textBox1.Text == "456" && this.textBox2.Text == "456" && this.comboBox1.SelectedItem == "库管员")
{
MessageBox.Show("正确", "提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Asterisk);
}
else
{
MessageBox.Show("错误", "提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Error);
}
}

输入用户名后回车,光标跳转到密码输入框

private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Enter)
{
SendKeys.Send("{tab}");
}
}

输入密码后回车,则直接登录

private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Enter)
{
this.button1_Click(sender, e);
}

按 Tab 进入输入框时,自动全选

private void textBox1_Enter(object sender, EventArgs e)
{
((TextBox)sender).SelectAll();
}
private void textBox2_Enter(object sender, EventArgs e)
{
((TextBox)sender).SelectAll();
}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容