登陆界面设计
一、登录界面效果图
二、登陆界面功能描述
1.默认用户类型为收银员。
2.用户名不超过九个字符。
3.输入正确提示登陆成功!(图一)
4.输入错误提示登陆失败!(图二)
5.点击退出退出程序等!
三、登录界面各控件参数
1.控件button
控件序列 | 属性 | 值 |
---|---|---|
button1 | Text | 登陆 |
button2 | Text | 退出 |
2.控件textbox
控件序列 | 属性 | 值 |
---|---|---|
textbox1 | Maxlength | 9 |
textbox2 | passwordchar | * |
3控件comboBox
控件序列 | 属性 | 值 |
---|---|---|
comboBox1 | Dropdownstyle | DropDownList |
4.控件Label
控件序列 | 属性 | 值 |
---|---|---|
Label | text | 用户类型 |
Label | text | 用户名 |
Label | text | 密码 |
5.控件pictureBox
控件序列 | 属性 | 值 |
---|---|---|
pictureBox1 | Backgroundlmage | 自选图片 |
6.控件Linklabel
控件序列 | 属性 | 值 |
---|---|---|
Linklabel1 | text | 忘记密码? |
7.窗体form
属性 | 值 |
---|---|
text | 登陆窗口 |
四、重要方法描述
1、默认角色为收银员
参考代码
private void Form1_Load(object sender, EventArgs e)
{
this.comboBox1.SelectedIndex = 0;
}
2、登陆成功/失败提示信息(原来为if......else,因太长改为if......else if ......else可行性未知)
参考代码
private void button1_Click(object sender, EventArgs e)
{
if (comboBox1.Text == "库管员" && textBox1.Text == "admin" && textBox2.Text == "1" )
MessageBox.Show("登陆成功", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
else if( comboBox1.Text == "收银员" && textBox1.Text == "2017" && textBox2.Text == "123456")
MessageBox.Show("登陆成功", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
else
MessageBox.Show("登录失败", "提示信息", MessageBoxButtons.YesNo, 、MessageBoxIcon.Error);
3、点击退出按钮退出程序
参考代码
private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
}
4、密码中按回车直接登陆
参考代码
private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Enter)
{
button1_Click(sender, e);
}
}
5、在用户名中按回车跳入密码输入框
参考代码
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Enter)
{
SendKeys.Send("{tab}");
}
}
6、tab进入密码输入框自动全选密码(在特定条件下,难以用言语说,不太成功)
参考代码
private void textBox1_Enter(object sender, EventArgs e)
{
((TextBox)sender).SelectAll();
}
}
五、尚需完善功能
1、添加验证系统。
2、添加注册账号系统,将注册的账号注入数据库,而不是单单在代码里的两个默认账号。
3、可以随意最大化窗口而不会出现内容没有跟着最大化,还保持原来的样子。