美文网首页
2018-10-21

2018-10-21

作者: 随它吧_bb4c | 来源:发表于2018-10-21 17:04 被阅读0次

    1.登录界面的效果图

    QQ图片20181021160423.png QQ图片20181021160432.jpg
    ![QQ图片20181021161658.jpg](https://img.haomeiwen.com/i14080735/8e8cad6832f165ac.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
    QQ图片20181021161658.jpg
    收银员登入成功.gif
    收银员登入失败.gif 库管员登入成功.gif
    库管员登入失败.gif

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

    • 实现不同用户类型登陆

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

    控件A

    属性
    TEXT 用户登录
    MaximizeBox False
    MinimizeBox False
    StartPosition CenterScreen

    控件label1

    属性
    TEXT 用户类型

    控件label2

    属性
    TEXT 用户名

    控件label3

    属性
    TEXT 密码

    控件Linklabel1

    属性
    TEXT 忘记密码?

    控件comboBox1

    属性
    DropDownStyle DropDownList
    SelectedIndexChanged comboBox1_SelectedIndexChanged

    控件textBox1

    属性
    MaxLength 9
    Click textBox1_Click
    KeyPress textBox1_KeyPress
    TextChanged textBox1_TextChanged

    控件textBox2

    属性
    Click textBox1_Click
    KeyPress textBox2_KeyPress
    Enter text Box1_Enter
    MaxLength 6
    Passwordchar *

    控件button1

    属性
    Text 登陆
    UseVisualStyleBackColor False
    Click button1_Click

    控件button2

    属性
    Text 退出
    UseVisualStyleBackColor False
    Click button2_Click

    4. 重要方法描述

    在Form窗口下,右击属性,在FormBorderStyle中选择FixdeSingle;将MaximizeBoxMinimizeBox设置为False,固定窗体。

    默认角色收银员。

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

    登录代码

    rivate void button1_Click(object sender, EventArgs e)
            {
                if (this.comboBox1.SelectedItem.ToString() == "收银员")
                {
                    if (this.textBox1.Text == "666666" && this.textBox2.Text == "123456")
                    {
                        MessageBox.Show("收银员登录成功");
                    }
                    else
                    {
                       MessageBox.Show("用户名或密码错误", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
    
                    }
                }
    
                if (this.comboBox1.SelectedItem.ToString() == "库管员")
                {
                    if (this.textBox1.Text == "666666" && this.textBox2.Text == "123456")
                    {
                        MessageBox.Show("库管员登录成功");
                    }
                    else
                    {
                        MessageBox.Show("用户名或密码错误", "提示", MessageBoxButtons.OKCancel, 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);
                }
            }
    

    退出应用程序

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

    相关文章

      网友评论

          本文标题:2018-10-21

          本文链接:https://www.haomeiwen.com/subject/ljlbzftx.html