登录界面

1. 登录界面的效果图

登录界面

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

在此窗体上可进行超市“收银员”和“库管员”进行登录,密码正确或者错误进行窗口弹出提醒。


登录成功

登录失败

3. 登录界面各控件的参数设置

from1

属性
text 登陆界面
StartPosition centerscreen
Maximizebox false
Minimizebox false

Lable

属性
text 用户类型、用户名、密码

textBox1

属性
MaxLength 9

textBox2

属性
MaxLength 9
PasswordChar *

button

属性
text 登录、退出

linklable

属性
text 忘记密码?

4. 重要方法描述

<1>、设置默认角色为收银员

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

<2>、登录成功或者登录失败

private void button1_Click(object sender, EventArgs e)
        {
            if (this.comboBox1.SelectedItem.ToString()  == "收银员")
            {
                if (this.textBox1 .Text == "lisa" && this.textBox2.Text == "123456")
                {
                    MessageBox.Show("收银员登录成功");
                }
                else
                {
                    MessageBox.Show("用户名或密码错误", "提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Error);
                }
            }

            if (this.comboBox1.SelectedItem.ToString() == "库管员")
            {
                if (this.textBox2.Text == "jxe" && this.textBox2 .Text == "654321")
                {
                    MessageBox.Show("库管员登录成功");
                }
                else
                {
                    MessageBox.Show("用户名或密码错误", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }

<3>、在用户名输入框中按“回车”,光标跳转到密码输入框

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

<4>、点“退出”时退出程序

private void button2_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

5、尚需完善的功能

在密码输入框中按“回车”,直接登录;Tab进入密码输入框时,自动全选密码; Tab进入用户名输入框时,自动全选用户名。

你可能感兴趣的:(登录界面)