1.登陸界面
2.登陸界面實現(xiàn)的功能描述
能夠實現(xiàn)用戶類型以收銀員和庫管員這兩種叫角色
實現(xiàn)用戶名和密碼登錄成功和顯示失敗
窗口大小不能改變
點擊退出 退出應用程序
3.登陸界面各參數(shù)控制
label1控件
屬性 | 值 |
---|---|
text | 用戶類型 |
label2控件
屬性 | 值 |
---|---|
text | 用戶名 |
label3控件
屬性 | 值 |
---|---|
text | 密碼 |
comboBox1控件
屬性 | 值 |
---|---|
編輯項 | 收銀員、庫管員 |
button1控件
屬性 | 值 |
---|---|
MaxLength | 9 |
button2控件
屬性 | 值 |
---|---|
PasswordChar | * |
4.重要方法描述
默認角色
private void Form1_Load(object sender, EventArgs e)
{
this.comboBox1.SelectedIndex = 0;
}
設置用戶的參數(shù)以及密碼并顯示相應的圖標
private void button1_Click(object sender, EventArgs e)
{
if (this.textBox1.Text == "123" && this.textBox2.Text == "123" && this.comboBox1.SelectedItem == "收銀員")
{
MessageBox.Show("正確", "提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Asterisk);
}
else
if (this.textBox1.Text == "456" && this.textBox2.Text == "456" && this.comboBox1.SelectedItem == "庫管員")
{
MessageBox.Show("正確", "提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Asterisk);
}
else
{
MessageBox.Show("錯誤", "提示", MessageBoxButtons.YesNoCancel, 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);
}
按 Tab 進入輸入框時佳谦,自動全選
private void textBox1_Enter(object sender, EventArgs e)
{
((TextBox)sender).SelectAll();
}
private void textBox2_Enter(object sender, EventArgs e)
{
((TextBox)sender).SelectAll();
}