1.貼效果圖豺撑,最好是GIF文件
1.gif
2.描述畫(huà)面主要功能,并列出支持這些功能的后臺(tái)數(shù)據(jù)庫(kù)表結(jié)構(gòu)
窗口加載時(shí)炕檩,默認(rèn)角色為“收銀員”,輸入用戶名密碼捌斧,點(diǎn)擊“登錄”按鈕則登錄系統(tǒng)笛质,用戶名密碼正確登錄成功泉沾,反之登錄失敗。
字段名稱 | 類型 | 說(shuō)明 |
---|---|---|
ID | int | 用戶名经瓷,為Primary Key |
NAME | Varchar(50) | 姓名 |
Password | Varchar(50) | 密碼 |
Phone | Varchar(15) | 電話 |
3.ADO.NET查詢數(shù)據(jù)庫(kù)的流程
①建立數(shù)據(jù)庫(kù)連接
②創(chuàng)建SQL 命令
③執(zhí)行SQL命令
④處理SQL命令結(jié)果
4.貼入重要代碼片段爆哑,并進(jìn)行詳細(xì)描述
// 窗口加載時(shí),設(shè)置默認(rèn)角色為“收銀員”
private void frm_Login_Load(object sender, EventArgs e)
{
// 設(shè)置收銀員為默認(rèn)登錄類型
this.cbb_UserType.SelectedIndex = 0;
// 禁止Tab鍵停留到LinkLabel上
this.ll_Register.TabStop = false;
this.ll_Forget.TabStop = false;
}
// 點(diǎn)擊“登錄”按鈕則登錄系統(tǒng)
private void bt_Login_Click(object sender, EventArgs e)
{
String connStr = "Data Source=.;Initial Catalog=SuperMarketSales;Integrated Security=True";
SqlConnection sqlConn = new SqlConnection(connStr);
try
{
sqlConn.Open();
String sqlStr = "";
if (this.cbb_UserType.Text == "收銀員")
{
// 注意USER是SQL Server關(guān)鍵字舆吮,表名不能命名為USER揭朝,而應(yīng)當(dāng)用USERS
sqlStr = "select * from USERS where ID=@id and PASSWORD=@pwd";
}
else
{
sqlStr = "select * from ADMIN where ID=@id and PASSWORD=@pwd";
}
SqlCommand cmd = new SqlCommand(sqlStr, sqlConn);
// 點(diǎn)擊“退出”按鈕則退出應(yīng)用程序
private void bt_Exit_Click(object sender, EventArgs e)
{
Application.Exit();
}
// 在用戶名輸入框中按“回車”,光標(biāo)跳轉(zhuǎn)到密碼輸入框
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);
}
}
// Tab進(jìn)入用戶名輸入框時(shí)潭袱,自動(dòng)全選用戶名
private void tb_User_Enter(object sender, EventArgs e)
{
((TextBox)sender).SelectAll();
}
// Tab進(jìn)入密碼輸入框時(shí),自動(dòng)全選密碼
private void tb_Password_Enter(object sender, EventArgs e)
{
((TextBox)sender).SelectAll();
}