实现智能商超系统库管员和收银员登陆系统时所用界面功能
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;
}
}
}