1.1用户登录界面

用户登录界面.png
1.2收银员登录界面

收银员登录.png
1.3库管员登录界面

库管员登录.png
2.登录界面实现的功能描述
可实现不同用户类型的自主系统登陆,其登录过程方便快捷,信息提示准确全面.
3.登录界面各控件的参数设置
控件A:Form1
| 属性 |
值 |
| FormBorderStyle |
FixdeSingle |
| MaximizeBox |
False |
| MinimizeBox |
False |
控件B:Lable1
控件C:Lable2
控件D:Lable3
控件E:TextBox1
| 属性 |
值 |
| MaxLength |
9 |
| TabIndex |
6 |
控件F:TextBox2
| 属性 |
值 |
| MaxLength |
6 |
| PasswordChar |
* |
| TabIndex |
7 |
控件G:ConboBox
| 属性 |
值 |
| Text |
收银员/库管员 |
| DropDownStyle |
DropDownList |
| TabIndex |
5 |
控件H:Button1
控件I:Button2
控件J:LinkLable
| 属性 |
值 |
| Text |
忘记密码? |
| TabStop |
True |
控件K:PictureBox
| 属性 |
值 |
| Image |
本地资源导入 |
| SizeMode |
StretchImage |
4.重要方法描述
4.1登录窗口边框固定,且不能最大最小化
在Form窗口下,右击属性,在FormBorderStyle中选择FixdeSingle;将MaximizeBox和MinimizeBox设置为False.
4.2 登录时,用户类型不能外部重新输入,且默认为"收银员"
在ComboBox的属性中,DropDownStyle中选择DropDownList;在窗口中双击进入代码页面,在光标自动定位处加入"this.comboBox1.SelectedIndex=0;"
private void Form1_Load(object sender, EventArgs e)
{
this.comboBox1.SelectedIndex = 0;
}
4.3 用户名最大长度为9个字符,密码不可见
在用户名对应的TextBox控件中,将MaxLength值设置为9;
在密码对应的TextBox控件中,将PasswordCha设置为*
4.4 当点击退出按钮时,自动退出登录界面
private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
}
5.想一想,还有哪些尚未完善的功能
5.1 输入用户名后回车, 光标跳转到密码输入框(涉及到KeyPres事件 和Tab键顺序)
在TextBox1属性中点击事件(闪电图标),找到KeyPress双击进入代码页面添加代码
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Enter)
{
SendKeys.Send("{Tab}");
}
}
5.2 输入密码后回车,则直接登录(涉及到TextBox的KeyPres事件)
在TextBox2属性中点击事件(闪电图标),找到KeyPress双击进入代码页面添加代码
private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Enter)
{
this.button1_Click(sender ,e);
}
}
5.3 按Tab进入输入框时,自动全选(涉及到TextBox的Enter事件)
在TextBox1和TextBox2属性中点击事件(闪电图标),找到Enter双击进入代码页面分别添加代码
private void textBox1_Enter(object sender, EventArgs e)
{
((TextBox)sender).SelectAll();
}
private void textBox2_Enter(object sender, EventArgs e)
{
((TextBox)sender).SelectAll();
}