2018-05-25

2.3系統(tǒng)登陸界面的制作

1.效果圖

1.1收銀員

收銀員.gif

1.2庫管員

庫管員.gif

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();
}
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容