美文网首页
2018-10-14

2018-10-14

作者: 出来挨打 | 来源:发表于2018-10-14 21:11 被阅读0次

    1登录页面效果图

    QQ截图20181014164023.png

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

    (1).该登陆界面可以实现以库管员、收银员两个不同用户来登陆各自的管理系统;

    (2).选择某一用户类型,输入正确的用户名以及密码后点击“登陆”尝试登陆;

    (3).输入界面密码失败时

    (4).点击“退出”即可退出登陆界面。

    https://v.youku.com/v_show/id_XMzg2Mjc2OTc3Mg==.html?spm=a2hzp.8244740.0.0

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

    控件Form1

    属性
    MaximizeBox False
    MinimizeBox False
    Startposition CenterScreen
    FormBorderStyle FixedSingle
    StartPosition CenterScreen
    Text 用户登录

    控件Label1

    属性
    Text 用户类型

    控件Label2

    属性
    Text 用户名

    控件Label3

    属性
    Text 密码

    控件LinkLabel1

    属性
    Tablindex 5
    Text 忘记密码
    事件

    控件Button1

    属性
    Text 登录
    Tablindex 3
    事件
    Click button1_Click

    控件Button2

    属性
    Text 退出
    Tablindex 4
    事件
    Click button2_Click

    控件ConboBox

    属性
    item (集合)收银员库管员
    Tablindex 0
    事件
    SelectedlindexChanged comboBox1_SelectedIndexChanged

    控件TextBox1

    属性
    MaxLenght 9
    Tablindex 1
    事件
    Enter text Box1_Enter
    Keypress text Box1_Keypress
    TextChanged textBox2_TextChanged

    控件TextBox2

    属性
    Tablindex 2
    PasswordChar *
    事件
    Enter text Box2_Enter
    Keypress text Box2_Keypress
    TextChanged textBox2_TextChanged

    4. 重要方法描述

    (1). 登录窗口出现在屏幕正中央,并且不能放大缩小点击Form1窗口进入属性界面,找到StartPosition并选择CenterScreen;


    QQ截图20181014164023.png

    (2).找到MaximizeBox、MinmiizeBox设置为False。


    QQ截图20181014213237.png

    (3). 默认角色为“收银员”,并且只允许选择“收银员”和“库管员”两种角色


    QQ图片20181014193914.png

    (4).用户名最大长度不超过9个字符,密码需要显示为“*”号找到名为“用户名”的textbox控件,进入属性栏,找到MaxLength并设置为9;


    QQ截图20181014194129.png

    (5).找到名为“密码”的textbox控件,进入属性栏,找到PasswordChar并设置为“*”。


    QQ截图20181014213732.png

    (6).在Form1属性下找到Load事件,双击打开,输入以下代码;

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

    (7). 登录正确则提示成功;登录失败则提示错误,注意使用错误图标

     private void button1_Click(object sender, EventArgs e)
            {
                if (this.comboBox1.SelectedItem.ToString() == "收银员")
                {
                    if (this.textBox1.Text == "200010111" && 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);
                    }
                }
            }
    

    登陆”的button控件,双击并输入以上代码即可。

    (8). 点击“退出”时退出应用程序

      private void textBox1_Enter(object sender, EventArgs e)
            {
                ((TextBox)sender).SelectAll();
            }
    
    

    (9).输入用户名后回车,光标跳转到密码输入框

     private void textBox1_Enter(object sender, EventArgs e)
            {
                ((TextBox)sender).SelectAll();
            }
    

    (10).输入密码后回车,则直接登录

     private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
            {
                if (e.KeyChar == (char)Keys.Enter)
                {
                    this.button1_Click(sender, e);
                }
            }
    

    (11).按 Tab 进入输入框时,自动全选

    
      private void textBox1_Enter(object sender, EventArgs e)
            {
                ((TextBox)sender).SelectAll();
            }
    
            private void textBox2_Enter(object sender, EventArgs e)
            {
                ((TextBox)sender).SelectAll();
            }
    

    5. 想一想,还有哪些尚需完善的功能

    (1).LinkLabel1忘记密码超链接提示
    (2).Button1登陆显示Form2

    相关文章

      网友评论

          本文标题:2018-10-14

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