1、登錄界面的效果圖
2、登錄界面實(shí)現(xiàn)的功能描述
該界面的功能主要是:
(1)在用戶類型里選擇“收銀員”或“庫管員”并輸入相應(yīng)的用戶名和密碼,然后點(diǎn)擊“登錄”按鈕,若用戶名和密碼正確,則對話框中會出現(xiàn)“收銀員登錄成功”或“庫管員登錄成功”;相反,若錯誤則會出現(xiàn)提示“用戶名或密碼錯誤”。(開始界面中的用戶類型是默認(rèn)“收銀員”)
(2)當(dāng)點(diǎn)擊“退出”按鈕時,則會退出應(yīng)用程序。
3、登錄界面各控件的參數(shù)設(shè)置
控件A(label1)
屬性
值
TEXT
用戶類型
Font
微軟雅黑,10,28571pt
FroeColor
ControlText
TextAlign
MiddleRigt
Tablndex
0
控件B(label2)
屬性
值
TEXT
用戶名
Font
微軟雅黑,10,28571pt
FroeColor
ControlText
TextAlign
MiddleRigt
Tablndex
14
控件C(label3)
屬性
值
TEXT
密碼
Font
微軟雅黑,10,28571pt
FroeColor
ControlText
TextAlign
MiddleRigt
Tablndex
15
控件D(label4)
屬性
值
TEXT
忘記密碼?
Font
微軟雅黑,10,28571pt
FroeColor
ControlText
LinkColor
0,0,25
Tablndex
200
TabStop
Ture
AutoSize
Ture
ActiveLinkColor
Red
控件E(PictureBox)
屬性
值
SizeMode
Stretchlmage
Image
圖片
控件F(Form1)
屬性
值
TEXT
用戶登錄
StartPosition
CenterScreen
MaximizeBox
False
MinimizeBox
False
FormBorderStyle
FixedSingle
控件G(Button1)
屬性
值
TEXT
登錄
Font
微軟雅黑,10,28571pt
FroeColor
ControlText
Tablndex
2
控件H(Button2)
屬性
值
TEXT
退出
Font
微軟雅黑,10,28571pt
FroeColor
ControlText
Tablndex
3
控件I(ComboBOX)
屬性
值
DropDownStyle
DropDownList
FormattingEn
True
Tablndex
4
字符串集合編輯器
收銀員、庫管員
控件J(TextBox1)
屬性
值
MaxLength
9
Lines
String[]Array
Tablndex
0
控件K(TextBox2)
屬性
值
PasswordChar
*
Lines
String[]Array
Tablndex
1
4、重要方法描述
登錄/退出/默認(rèn)收銀員代碼: using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SuperMarketSales
{
public partial class LoginForm : Form
{
public LoginForm()
{
InitializeComponent();
}
// 窗口加載時,設(shè)置默認(rèn)角色為“收銀員”
private void LoginForm_Load(object sender, EventArgs e)
{
this.cbb_Type.SelectedIndex = 0;
}
// 點(diǎn)擊“登錄”按鈕則登錄系統(tǒng)
private void bt_Login_Click(object sender, EventArgs e)
{
if (this.cbb_Type.SelectedItem.ToString() == "收銀員")
{
if (this.tb_User.Text == "123456" && this.tb_Password.Text == "123456")
{
MessageBox.Show("收銀員登錄成功");
}
else
{
MessageBox.Show("用戶名或密碼錯誤", "提示", 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("用戶名或密碼錯誤", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
// 點(diǎn)擊“退出”按鈕則退出應(yīng)用程序
private void bt_Exit_Click(object sender, EventArgs e)
{
Application.Exit();
}
5、功能完善
(1)在用戶名輸入框中按“回車”,光標(biāo)跳轉(zhuǎn)到密碼輸入框;
代碼:
private void tb_User_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Enter)
{
SendKeys.Send("{tab}");
}
}
(2)在密碼輸入框中按“回車”,則直接登錄;
代碼:
private void tb_Password_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Enter)
{
this.bt_Login_Click(sender, e);
}
}
最后編輯于 :2018.10.19 16:14:14
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者 【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。 平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。