C#商超系统

 实现智能商超系统库管员和收银员登陆系统时所用界面功能


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 comboBox1_SelectedIndexChanged(object sender, EventArgs e)

        {

            this.comboBox1.SelectedIndex = 0;

        }

        private void textBox1_TextChanged(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;

        }

    }

}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容