登陸界面設計
一或油、登錄界面效果圖
登錄界面
二、登陸界面功能描述
1.默認用戶類型為收銀員驰唬。
2.用戶名不超過九個字符顶岸。
3.輸入正確提示登陸成功!(圖一)
圖一
4.輸入錯誤提示登陸失斀斜唷O接丁(圖二)
圖二
5.點擊退出退出程序等!
三搓逾、登錄界面各控件參數(shù)
1.控件button
控件序列 | 屬性 | 值 |
---|---|---|
button1 | Text | 登陸 |
button2 | Text | 退出 |
2.控件textbox
控件序列 | 屬性 | 值 |
---|---|---|
textbox1 | Maxlength | 9 |
textbox2 | passwordchar | * |
3控件comboBox
控件序列 | 屬性 | 值 |
---|---|---|
comboBox1 | Dropdownstyle | DropDownList |
4.控件Label
控件序列 | 屬性 | 值 |
---|---|---|
Label | text | 用戶類型 |
Label | text | 用戶名 |
Label | text | 密碼 |
5.控件pictureBox
控件序列 | 屬性 | 值 |
---|---|---|
pictureBox1 | Backgroundlmage | 自選圖片 |
6.控件Linklabel
控件序列 | 屬性 | 值 |
---|---|---|
Linklabel1 | text | 忘記密碼卷谈? |
7.窗體form
屬性 | 值 |
---|---|
text | 登陸窗口 |
四、重要方法描述
1恃逻、默認角色為收銀員
參考代碼
private void Form1_Load(object sender, EventArgs e)
{
this.comboBox1.SelectedIndex = 0;
}
2雏搂、登陸成功/失敗提示信息(原來為if......else藕施,因太長改為if......else if ......else可行性未知)
參考代碼
private void button1_Click(object sender, EventArgs e)
{
if (comboBox1.Text == "庫管員" && textBox1.Text == "admin" && textBox2.Text == "1" )
MessageBox.Show("登陸成功", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
else if( comboBox1.Text == "收銀員" && textBox1.Text == "2017" && textBox2.Text == "123456")
MessageBox.Show("登陸成功", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
else
MessageBox.Show("登錄失敗", "提示信息", MessageBoxButtons.YesNo, 、MessageBoxIcon.Error);
3凸郑、點擊退出按鈕退出程序
參考代碼
private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
}
4裳食、密碼中按回車直接登陸
參考代碼
private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Enter)
{
button1_Click(sender, e);
}
}
5、在用戶名中按回車跳入密碼輸入框
參考代碼
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Enter)
{
SendKeys.Send("{tab}");
}
}
6芙沥、tab進入密碼輸入框自動全選密碼(在特定條件下诲祸,難以用言語說,不太成功)
參考代碼
private void textBox1_Enter(object sender, EventArgs e)
{
((TextBox)sender).SelectAll();
}
}
五而昨、尚需完善功能
1救氯、添加驗證系統(tǒng)。
2歌憨、添加注冊賬號系統(tǒng)着憨,將注冊的賬號注入數(shù)據(jù)庫,而不是單單在代碼里的兩個默認賬號务嫡。
3甲抖、可以隨意最大化窗口而不會出現(xiàn)內容沒有跟著最大化,還保持原來的樣子心铃。