一沾乘、登錄界面的效果圖
二擦剑、登錄界面實(shí)現(xiàn)的功能描述
登錄界面默認(rèn)用戶類型為收銀員亿昏,支持超市管理員和收銀員的登錄峦剔,密碼找回及退出功能
三、登錄界面各控件的參數(shù)設(shè)置
Form1(窗體控件:Form1)
屬性 |
值 |
FormBorderStyle |
FixedSingle |
MaximizeBox |
False |
MinimizeBox |
False |
StartPosition |
CenterScreen |
comboBox1(登錄類型控件:cb_style)
屬性 |
值 |
DropDownStyle |
DropDownList |
Items |
管理員角钩、收銀員 |
textBox1(用戶名控件:tb_user)
textBox2(用戶密碼控件:tb_pwd)
四吝沫、重要方法描述
4.1設(shè)置默認(rèn)收銀員代碼
private void Form1_Load(object sender, EventArgs e)
{
this.cb_style.SelectedItem = "收銀員";
}
4.2登錄按鈕點(diǎn)擊事件
private void button2_Click(object sender, EventArgs e)
{
if (this.cb_style.SelectedItem == "管理員")
{
if (tb_user.Text == "2016270000" && tb_pwd.Text == "123456")
{
MessageBox.Show("密碼正確", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
Form form2 = new Form2();
form2.ShowDialog();
}
else {
MessageBox.Show("用戶名或密碼錯(cuò)誤", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
if (this.cb_style.SelectedItem == "收銀員")
{
if (tb_user.Text == "2016270386" && tb_pwd.Text == "19980602")
{
MessageBox.Show("密碼正確", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
Form form2 = new Form2();
form2.ShowDialog();
}
else
{
MessageBox.Show("用戶名或密碼錯(cuò)誤", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
4.3回車鍵換行
private void textBox1_KeyPress_1(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Enter)
{
SendKeys.Send("{tab}");
}
}
4.4Tab進(jìn)入密碼輸入框時(shí),自動(dòng)全選密碼
private void textBox2_Enter_1(object sender, EventArgs e)
{
((TextBox)sender).SelectAll();
}
4.4回車鍵直接登錄
private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Enter)
{
button2_Click(sender,e);
}
}
五递礼、想一想惨险,還有哪些尚需完善的功能
未完待續(xù)