1. 登录界面的效果图
2. 登录界面实现的功能描述
库管员和收银员分别登录,显示出不同的信息
3. 登录界面各控件的参数设置
控件A
属性 |
值 |
Text |
登陆界面 |
MaximizeBox |
False |
MinimizeBox |
False |
控件label1
控件label2
控件label3
控件comboBox1
属性 |
值 |
DropDownStyle |
DropDownList |
SelectedIndexChanged |
comboBox1_SelectedIndexChanged |
控件Linklabel1
控件textBox1
属性 |
值 |
Click |
textBox1_Click |
KeyPress |
textBox1_KeyPress |
TextChanged |
textBox1_TextChanged |
控件textBox2
属性 |
值 |
Click |
textBox2_Click |
KeyPress |
textBox2_KeyPress |
Enter |
textBox2_Enter |
控件Button1
属性 |
值 |
Text |
登陆 |
UseVisualStyleBackColor |
False |
Click |
button1_Click |
控件Button2
属性 |
值 |
Text |
取消 |
UseVisualStyleBackColor |
False |
Click |
button2_Click |
4. 重要方法描述
4.1将登录窗口固定化,既不能放大也不能缩小
在Form窗口下,右键单击属性,在FormBorderStyle中选择FixdeSingle;将MaximizeBox和MinimizeBox都设置为False即可。
4.2在窗口加载时,设置默认角色为“收银员”。代码如下
private void Form1_Load(object sender, EventArgs e)
{
this.comboBox1.SelectedIndex = 0;
}
5. 想一想,还有哪些尚需完善的功能
代码
private void button1_Click(object sender, EventArgs e)
{
if (this.comboBox1.SelectedItem.ToString() == "收银员")
{
if (this.textBox1.Text == "123456" && this.textBox2.Text == "123456")
{
MessageBox.Show("收银员登录成功");
}
else
{
MessageBox.Show("用户名或密码错误", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
if (this.comboBox1.SelectedItem.ToString() == "库管员")
{
if (this.textBox1.Text == "admin" && this.textBox2.Text == "admin")
{
MessageBox.Show("库管员登录成功");
}
else
{
MessageBox.Show("用户名或密码错误", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Enter)
{
textBox2.Focus();
}
}
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Enter)
{
this.userLogin();
}
}