一. 登錄界面的效果圖
二. 登錄界面實(shí)現(xiàn)的功能描述
具體要求:
1. 登錄窗口出現(xiàn)在屏幕正中央,并且不能放大縮小
2. 默認(rèn)角色為“收銀員”验夯,并且只允許選擇“收銀員”和“庫(kù)管員”兩種角色
3. 用戶名最大長(zhǎng)度不超過(guò)9個(gè)字符香璃,密碼需要顯示為“*”號(hào)
4. 登錄正確則提示成功漓概;登錄失敗則提示錯(cuò)誤,注意使用錯(cuò)誤圖標(biāo)
5. 點(diǎn)擊“退出”時(shí)退出應(yīng)用程序
加分項(xiàng):
1. 輸入用戶名后回車勃刨,光標(biāo)跳轉(zhuǎn)到密碼輸入框(涉及到 KeyPress 事件和 Tab 鍵順序)
2. 輸入密碼后回車磨确,則直接登錄(涉及到 TextBox 的 KeyPress 事件)
3. 按 Tab 進(jìn)入輸入框時(shí)锋恬,自動(dòng)全選(涉及到 TextBox 的 Enter事件)
三. 登錄界面各控件的參數(shù)設(shè)置
1.Lable控件
屬性 |
值 |
Text |
用戶類型/用戶名/密碼 |
Font |
幼圓滔岳,14.25pt |
2.comebox控件
3.Textbox控件
屬性 |
值 |
Font |
幼圓,14.25pt |
MaxLength |
6 |
PasswordChar |
* |
4.linkLable控件
屬性 |
值 |
Font |
幼圓谱煤,14.25pt |
Text |
忘記密碼 |
5.button控件
屬性 |
值 |
Font |
幼圓墨辛,14.25pt |
Text |
登錄/退出 |
6.pictureBox控件
屬性 |
值 |
Font |
幼圓,14.25pt |
Backgroundlmage |
導(dǎo)入 |
BackgroundlmageLayout |
Stretch |
7.Form
屬性 |
值 |
Font |
幼圓趴俘,9pt |
Text |
用戶登錄 |
FormBorderStyle |
FixedToolWindow |
四. 重要方法描述
1.窗口加載時(shí),設(shè)置默認(rèn)角色為“收銀員”
private void Form1_Load(object sender, EventArgs e)
{
this.comboBox1.SelectedIndex = 0;
}
2.點(diǎn)擊“登錄”按鈕則登錄系統(tǒng)
private void button1_Click(object sender, EventArgs e)
{
if (this.comeboBox1.SelectedItem.ToString() == "收銀員")
{
if (this.textBox1.Text == "201700" && this.textBox2.Text == "123456")
{
MessageBox.Show("收銀員登錄成功");
}
else
{
MessageBox.Show("用戶名或密碼錯(cuò)誤", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
if (this.comboBox1.SelectedItem.ToString() == "庫(kù)管員")
{
if (this.textBox1.Text == "admin" && this.textBox2.Text == "admin")
{
MessageBox.Show("庫(kù)管員登錄成功");
}
else
{
MessageBox.Show("用戶名或密碼錯(cuò)誤", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
3.點(diǎn)擊“退出”按鈕則退出應(yīng)用程序
private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
}
五. 想一想奏赘,還有哪些尚需完善的功能
暫時(shí)沒想到寥闪,技術(shù)不過(guò)關(guān)
// 在用戶名輸入框中按“回車”,光標(biāo)跳轉(zhuǎn)到密碼輸入框
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Enter)
{
SendKeys.Send("{tab}");
}
}
// Tab進(jìn)入密碼輸入框時(shí)磨淌,自動(dòng)全選密碼
private void textBox2_Enter(object sender, EventArgs e)
{
((TextBox)sender).SelectAll();
}