美文网首页
2018-10-21

2018-10-21

作者: 玄色233 | 来源:发表于2018-10-21 19:58 被阅读0次

    智能商超登录

    1.登录界面

    GIF.gif

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

    实现不同用户类型登陆情况和密码核对

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

    控件

    属性
    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.重要方法描述

    1.在Form窗口下,右击属性,在FormBorderStyle中选择FixdeSingle;将MaximizeBox和MinimizeBox设置为False,固定窗体。默认角色收银员。

    2.输入用户名后回车,光标跳转到密码输入框。

    3.输入密码后,回车直接登陆。

    4.按TAB键进入输入框时,自动全选。

    5.代码

    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void button2_Click(object sender, EventArgs e)
            {
                this.Close();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                if (textBox1.Text == "222222" && textBox2.Text == "222222")
                    MessageBox.Show("登陆成功", "提示");
                else
                    MessageBox.Show("用户名或密码错误", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
            }
    
            private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
            {
    
            }
    
            private void textBox2_TextChanged(object sender, EventArgs e)
            {
    
            }
    
            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 textBox1_Enter(object sender, EventArgs e)
            {
                ((TextBox)sender).SelectAll();
            }
    
            private void textBox2_Enter(object sender, EventArgs e)
            {
                ((TextBox)sender).SelectAll();
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                this.comboBox1.SelectedIndex = 0;
            }
    
        }
    }
    

    相关文章

      网友评论

          本文标题:2018-10-21

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