2.3系統(tǒng)登陸界面的制作
1.效果圖
1.1收銀員

1.2庫管員

2.涉及到的控件、屬性及方法
涉及控件:comboBox,textBox,button,label,pictureBox,linkLabel
comboBox:
Name:cbb_Type
DorpDownStyle:DropDownList
FormattingEnabled:True
Location:181, 121
Margin:2, 2, 2, 2
Size:118, 20
TabIndex:4
textBox:
Name:tb_User
Forecolor:WindowText
Lines:String[] Array
Location:181, 162
Margin:2, 2, 2, 2
MaxLength:9
Size:118, 21
TabIndex:0
button:
Name:bt_Login\bt_Exit
Font:微軟雅黑, 10.28571pt
Forecolor:ControlText
Location:231, 261
Margin:2, 2, 2, 2
Size:74, 30
TabIndex:3
Text:登錄\退出
UseVasualStyleBackColor:True
label:
Name:label
Font:微軟雅黑, 10.28571pt
Forecolor:ControlText
Location:40, 162
Margin:2, 0, 2, 0
Size:122, 18
TabIndex:14
Text:用戶名等
TextAlign:MiddleRight
pictureBox:
Name:pictureBox
Image:SuperMarketSales.Properties.Resources.首頁
Margin:2, 2, 2, 2
Size:435, 93
SizeMode:StretchImage
linkLabel:
Name:ll_Forget
ActiveLinkColor:Red
AutoSize:True
DisabledLinkColor:133, 133, 133
Font:微軟雅黑, 10.28571pt
ForeColor:ControlText
LinkColor:0, 0, 255
Location:308, 204
Margin:2, 0, 2, 0
Size:79,20
TabIndex:200
Tabstop:True
Text:忘記密碼?
VisitedLinkColor:128, 0, 128
3.登陸界面的迭代
第一階段 了解各種控件的用途和方法,學(xué)會簡單的界面搭建
第二階段 了解各控件的事件及觸發(fā)方式
第三階段 熟悉面向?qū)ο笳Z言,學(xué)會對象調(diào)用,繼承等基本實(shí)現(xiàn)
第四階段 實(shí)現(xiàn)觸發(fā)事件觸發(fā)方式,編寫預(yù)期的觸發(fā)事件
第五階段 補(bǔ)充實(shí)現(xiàn)邏輯
4.重要代碼
4.1登錄系統(tǒng)及系統(tǒng)提示
private void bt_Login_Click(object sender, EventArgs e)
{
if (this.cbb_Type.SelectedItem.ToString() == "收銀員")
{
if (this.tb_User.Text == "200010111" && this.tb_Password.Text == "123456")
{
MessageBox.Show("收銀員登錄成功");
}
else
{
MessageBox.Show("用戶名或密碼錯(cuò)誤", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
if (this.cbb_Type.SelectedItem.ToString() == "庫管員")
{
if (this.tb_User.Text == "admin" && this.tb_Password.Text == "admin")
{
MessageBox.Show("庫管員登錄成功");
}
else
{
MessageBox.Show("用戶名或密碼錯(cuò)誤", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
4.2退出系統(tǒng)
private void bt_Exit_Click(object sender, EventArgs e)
{
Application.Exit();
}
4.3"回車"及"Tab"的使用
private void tb_User_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Enter)
{
SendKeys.Send("{tab}");
}
}
private void tb_Password_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Enter)
{
this.bt_Login_Click(sender, e);
}
}
private void tb_User_Enter(object sender, EventArgs e)
{
((TextBox)sender).SelectAll();
}
private void tb_Password_Enter(object sender, EventArgs e)
{
((TextBox)sender).SelectAll();
}