版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、學(xué)生學(xué)籍管理系統(tǒng)詳細(xì)代碼本文為學(xué)生學(xué)籍管理系統(tǒng)的各個(gè)模塊效果圖和詳細(xì)代碼;登錄模塊:登錄模塊代碼:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace StuIFMS public partial class Form1 : Form public Color temp;/存儲(chǔ)臨時(shí)
2、的按鈕顏色 public Form1() InitializeComponent(); private void button3_Click(object sender, EventArgs e) Application.Exit(); public User CurrentUser; private void button2_Click(object sender, EventArgs e) MessageBox.Show("學(xué)生/教師用自己的學(xué)號(hào)/教師編號(hào)登錄!,如過沒有注冊(cè)則點(diǎn)擊“注冊(cè)”進(jìn)行注冊(cè)!", "提示"); private void but
3、ton1_Click(object sender, EventArgs e) bool UserExit = false, KeyRight = false; /聲明上下文集合 DataClasses1DataContext myDataContext = new DataClasses1DataContext(); /把用戶表里所有內(nèi)容提取到User集合里 /排查輸入錯(cuò)誤 /用戶名為空 if (textBox1.Text = "") MessageBox.Show("用戶名不能為空!", "提示"); /用戶名不為空 else /密
4、碼為空 if (textBox2.Text = "") MessageBox.Show("密碼不能為空", "提示"); /密碼不為空 else /學(xué)生身份登錄 if (radioButton1.Checked=true) var User = from user in myDataContext.UsersTable where user.Identity = "學(xué)生" select user; foreach (var stu in User) if (stu.UerID = textBox1.Text) Us
5、erExit = true; if (stu.Password = textBox2.Text) KeyRight = true; CurrentUser = new User(textBox1.Text, textBox2.Text, radioButton1.Text); if (UserExit = false) MessageBox.Show("用戶名不存在!"); else if (KeyRight = false) MessageBox.Show("密碼錯(cuò)誤!"); else /MessageBox.Show("登錄成功"
6、); MainForm fm = new MainForm(CurrentUser); fm.FormClosed += new FormClosedEventHandler(fm_FormClosed); this.Hide(); fm.Initial(CurrentUser,0); fm.Show(); /教師登錄 else var User1 = from teacher in myDataContext.UsersTable where teacher.Identity = "教師" select teacher; foreach (var teac in User
7、1) if (teac.UerID = textBox1.Text) UserExit = true; if (teac.Password = textBox2.Text) KeyRight = true; /記錄登錄用戶用戶名身份信息 CurrentUser = new User(textBox1.Text, textBox2.Text, radioButton2.Text); if (UserExit = false) MessageBox.Show("用戶名不存在"); else if (KeyRight = false) MessageBox.Show("
8、密碼錯(cuò)誤"); else /登錄教師界面 /MessageBox.Show("登錄成功!"); MainForm fm = new MainForm(CurrentUser); fm.Initial(CurrentUser,1); this.Hide(); fm.Show(); void fm_FormClosed(object sender, FormClosedEventArgs e) this.Close(); /注冊(cè)按鈕實(shí)現(xiàn) private void button4_Click(object sender, EventArgs e) LogForm fm
9、= new LogForm(); fm.ShowDialog(); /鼠標(biāo)進(jìn)去按鈕事件 private void button1_MouseEnter(object sender, EventArgs e) temp = button1.BackColor; button1.BackColor = System.Drawing.Color.Pink; /鼠標(biāo)離開按鈕的事件 private void button1_MouseLeave(object sender, EventArgs e) button1.BackColor = temp; private void button3_Mouse
10、Enter(object sender, EventArgs e) temp = button3.BackColor; button3.BackColor = System.Drawing.Color.Pink; /鼠標(biāo)離開事件 private void button3_MouseLeave(object sender, EventArgs e) button3.BackColor = temp; private void button4_MouseEnter(object sender, EventArgs e) temp = button4.BackColor; button4.BackC
11、olor = Color.Orange; private void button4_MouseLeave(object sender, EventArgs e) button4.BackColor = temp; private void button2_MouseEnter(object sender, EventArgs e) temp = button2.BackColor; button2.BackColor = Color.Pink; private void button2_MouseLeave(object sender, EventArgs e) button2.BackCol
12、or = temp; 注冊(cè)模塊代碼:代碼:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace StuIFMS public partial class LogForm : Form public LogForm() InitializeComponent(); private v
13、oid textBox1_TextChanged(object sender, EventArgs e) checkBox1.Checked = false; textBox2.Enabled = false; bool isRegeisted=false;/帳號(hào)是否被注冊(cè)標(biāo)記 bool isexited=false;/帳號(hào)是否存在標(biāo)記 /提取出用戶數(shù)據(jù)表里所有用戶資料 DataClasses1DataContext myDataContext = new DataClasses1DataContext(); var UsersQuery = from User in myDataContex
14、t.UsersTable select User; /文本數(shù)據(jù)發(fā)生變化時(shí)候,檢查輸入是否可以申請(qǐng) /學(xué)生身份申請(qǐng)帳號(hào) if (radioButton1.Checked = true) /在用戶表里檢查該學(xué)生帳號(hào)是否被注冊(cè)了 foreach (var user in UsersQuery) /學(xué)生用戶帳號(hào)已經(jīng)被注冊(cè) if (user.UerID = textBox1.Text && user.Identity = radioButton1.Text) isRegeisted = true; /檢出該學(xué)號(hào)被注冊(cè)了 if (isRegeisted = true) checkBox1.
15、Text = "已注冊(cè)的號(hào)碼" /MessageBox.Show("該學(xué)號(hào)已經(jīng)被注冊(cè)了!"); /帳號(hào)沒有被注冊(cè),在學(xué)生表里檢查該學(xué)號(hào)存在與否 else DataClasses2DataContext myDataContext2 = new DataClasses2DataContext(); /從學(xué)生表里提取所有數(shù)據(jù) var StuQuery = from Stud in myDataContext2.StudentsTable select Stud; foreach (var stu in StuQuery) /學(xué)號(hào)被找到了,說明該學(xué)號(hào)存在且沒有
16、被注冊(cè),可以注冊(cè)該學(xué)號(hào) if (stu.StudentN = textBox1.Text) isexited = true; if (isexited = false) /MessageBox.Show("該學(xué)號(hào)不存在!"); checkBox1.Text = "不存在的學(xué)號(hào)" else /checkBox1打勾,說明可用 checkBox1.Checked = true; checkBox1.Text = "" textBox2.Enabled = true; /教師注冊(cè) else /檢查用戶表看帳號(hào)有沒有被注冊(cè) foreach (
17、var user in UsersQuery) /教師帳號(hào)已經(jīng)被注冊(cè)了 if (textBox1.Text = user.UerID && radioButton2.Text = user.Identity) isRegeisted = true; /被注冊(cè)的處理 if (isRegeisted = true) checkBox1.Text = "帳號(hào)被注冊(cè)" else /未被注冊(cè)的帳號(hào),到教師信息表里查找該教師編號(hào)是否存在 DataClasses3DataContext TeacherDataContext = new DataClasses3DataCo
18、ntext(); /取出教師信息表里的所有數(shù)據(jù),放到集合里 var TeacherQuery = from teac in TeacherDataContext.TeachersTable select teac; foreach (var teacher in TeacherQuery) /查找到存在這個(gè)教師編號(hào) if (teacher.TeacherN = textBox1.Text) isexited = true; /不存在這個(gè)編號(hào)的老師的處理 if (isexited = false) checkBox1.Text = "不存在的編號(hào)" else /checkBo
19、x1打勾,說明可用 checkBox1.Checked = true; checkBox1.Text = "" textBox2.Enabled = true; /密碼輸入按鈕 private void textBox2_TextChanged(object sender, EventArgs e) textBox3.Enabled = false; checkBox2.Checked = false; /檢查密碼規(guī)范,密碼長(zhǎng)度為6-16字符 if (textBox2.Text.ToString() = "") checkBox2.Text = &quo
20、t;密碼非空!" else if (textBox2.Text.Contains(" ") checkBox2.Text = "密碼不能包含空格" else if (textBox2.Text.Length > 16 | textBox2.Text.Length < 6) checkBox2.Text = "密碼長(zhǎng)度6-16!" else /密碼格式正確,checkedBox打勾且激活textBox3 checkBox2.Text = "" checkBox2.Checked = true;
21、textBox3.Enabled = true; /驗(yàn)證密碼的文本改變事件 private void textBox3_TextChanged(object sender, EventArgs e) button1.Enabled = false; checkBox3.Checked = false; /檢驗(yàn)密碼和驗(yàn)證密碼是否相等 if (textBox2.Text != textBox3.Text) checkBox3.Text = "密碼確認(rèn)失敗!" /密碼和確認(rèn)密碼相同,可以注冊(cè),激活注冊(cè)按鈕,同時(shí)把checkBox3打勾 else button1.Enabled =
22、 true; checkBox3.Checked = true; checkBox3.Text = "" /幫助按鈕實(shí)現(xiàn) private void button2_Click(object sender, EventArgs e) MessageBox.Show("師生只能通過自己的唯一學(xué)號(hào)/教師編號(hào)注冊(cè),如果發(fā)現(xiàn)自己帳號(hào)被非法注冊(cè),請(qǐng)聯(lián)系管理員!", "注冊(cè)幫助"); /注冊(cè)按鈕的實(shí)現(xiàn) private void button1_Click(object sender, EventArgs e) /檢測(cè)數(shù)據(jù)填寫狀態(tài),確定是否有了注冊(cè)需
23、要的足夠滿足格式的數(shù)據(jù) if (checkBox1.Checked && checkBox2.Checked && checkBox3.Checked) /滿足條件,將數(shù)據(jù)寫到數(shù)據(jù)庫的UsersTable里 DataClasses1DataContext myDataContext = new DataClasses1DataContext(); /分注冊(cè)身份進(jìn)行建立不同表格行 UsersTable temptable = new UsersTable UerID = textBox1.Text, Password = textBox2.Text ; if (r
24、adioButton1.Checked) temptable.Identity = radioButton1.Text; else temptable.Identity = radioButton2.Text; try myDataContext.UsersTable.InsertOnSubmit(temptable); myDataContext.SubmitChanges(); /button1.Enabled = false; MessageBox.Show("注冊(cè)成功!請(qǐng)牢記你的密碼!"); /清空各個(gè)內(nèi)容 textBox1.Text = ""
25、textBox2.Text = "" textBox3.Text = "" checkBox1.Checked = false; checkBox1.Text = "" checkBox2.Checked = false; checkBox3.Checked = false; checkBox2.Text = "" checkBox3.Text = "" catch (Exception ex) MessageBox.Show("異常" + ex.Message); /屏蔽掉
26、點(diǎn)擊事件,使得點(diǎn)擊無效 private void checkBox1_Click(object sender, EventArgs e) if (checkBox1.Checked) checkBox1.Checked = false; else checkBox1.Checked = true; /屏蔽掉點(diǎn)擊事件,使得點(diǎn)擊無效 private void checkBox2_Click(object sender, EventArgs e) if (checkBox2.Checked) checkBox2.Checked = false; else checkBox2.Checked = tr
27、ue; /屏蔽掉點(diǎn)擊事件,使得點(diǎn)擊無效 private void checkBox3_Click(object sender, EventArgs e) if (checkBox3.Checked) checkBox3.Checked = false; else checkBox3.Checked = true; private void label2_Click(object sender, EventArgs e) private void label1_Click(object sender, EventArgs e) /屏蔽掉點(diǎn)擊事件,使得點(diǎn)擊無效 private void radio
28、Button1_Click(object sender, EventArgs e) /檢測(cè)學(xué)生帳號(hào)是否被注冊(cè) checkBox1.Checked = false; textBox2.Enabled = false; bool isRegeisted = false;/帳號(hào)是否被注冊(cè)標(biāo)記 bool isexited = false;/帳號(hào)是否存在標(biāo)記 /提取出用戶數(shù)據(jù)表里所有用戶資料 DataClasses1DataContext myDataContext = new DataClasses1DataContext(); var UsersQuery = from User in myData
29、Context.UsersTable select User; /在用戶表里檢查該學(xué)生帳號(hào)是否被注冊(cè)了 foreach (var user in UsersQuery) /學(xué)生用戶帳號(hào)已經(jīng)被注冊(cè) if (user.UerID = textBox1.Text && user.Identity ="學(xué)生") isRegeisted = true; /檢出該學(xué)號(hào)被注冊(cè)了 if (isRegeisted = true) checkBox1.Text = "已注冊(cè)的號(hào)碼" /MessageBox.Show("該學(xué)號(hào)已經(jīng)被注冊(cè)了!"
30、;); /帳號(hào)沒有被注冊(cè),在學(xué)生表里檢查該學(xué)號(hào)存在與否 else DataClasses2DataContext myDataContext2 = new DataClasses2DataContext(); /從學(xué)生表里提取所有數(shù)據(jù) var StuQuery = from Stud in myDataContext2.StudentsTable select Stud; foreach (var stu in StuQuery) /學(xué)號(hào)被找到了,說明該學(xué)號(hào)存在且沒有被注冊(cè),可以注冊(cè)該學(xué)號(hào) if (stu.StudentN = textBox1.Text) isexited = true; i
31、f (isexited = false) /MessageBox.Show("該學(xué)號(hào)不存在!"); checkBox1.Text = "不存在的學(xué)號(hào)" else /checkBox1打勾,說明可用 checkBox1.Checked = true; checkBox1.Text = "" textBox2.Enabled = true; /屏蔽掉點(diǎn)擊事件,使得點(diǎn)擊無效 private void radioButton2_Click(object sender, EventArgs e) checkBox1.Checked = fals
32、e; textBox2.Enabled = false; bool isRegeisted = false;/帳號(hào)是否被注冊(cè)標(biāo)記 bool isexited = false;/帳號(hào)是否存在標(biāo)記 /提取出用戶數(shù)據(jù)表里所有用戶資料 DataClasses1DataContext myDataContext = new DataClasses1DataContext(); var UsersQuery = from User in myDataContext.UsersTable select User; /教師注冊(cè) /檢查用戶表看帳號(hào)有沒有被注冊(cè) foreach (var user in User
33、sQuery) /教師帳號(hào)已經(jīng)被注冊(cè)了 if (textBox1.Text = user.UerID && user.Identity="教師") isRegeisted = true; /被注冊(cè)的處理 if (isRegeisted = true) checkBox1.Text = "帳號(hào)被注冊(cè)" else /未被注冊(cè)的帳號(hào),到教師信息表里查找該教師編號(hào)是否存在 DataClasses3DataContext TeacherDataContext = new DataClasses3DataContext(); /取出教師信息表里的所有數(shù)據(jù),放到集合里 var TeacherQuery = from teac in TeacherDataContext.TeachersTable select teac; foreach (var teacher in TeacherQuery) /查找到存在這個(gè)教師編號(hào) if (teacher.
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年高精度燃油濾紙合作協(xié)議書
- 2025年電控多瓶采水器合作協(xié)議書
- 八年級(jí)英語下冊(cè) Unit 10 單元綜合測(cè)試卷(人教河南版 2025年春)
- 人教版 七年級(jí)英語下冊(cè) UNIT 7 單元綜合測(cè)試卷(2025年春)
- 育嬰師服務(wù)協(xié)議書
- 信息技術(shù)在幼兒園一日活動(dòng)中的運(yùn)用
- 2025年個(gè)人承包魚塘合同(2篇)
- 2025年個(gè)體經(jīng)營(yíng)勞動(dòng)合同(4篇)
- 2025年五年級(jí)數(shù)學(xué)上學(xué)期教師工作總結(jié)樣本(四篇)
- 2025年臨床試驗(yàn)合作協(xié)議參考模板(三篇)
- 2025年個(gè)人學(xué)習(xí)領(lǐng)導(dǎo)講話心得體會(huì)和工作措施例文(6篇)
- 2025大連機(jī)場(chǎng)招聘109人易考易錯(cuò)模擬試題(共500題)試卷后附參考答案
- 2020-2025年中國(guó)中小企業(yè)行業(yè)市場(chǎng)調(diào)研分析及投資戰(zhàn)略咨詢報(bào)告
- 2025-2030年中國(guó)電動(dòng)高爾夫球車市場(chǎng)運(yùn)行狀況及未來發(fā)展趨勢(shì)分析報(bào)告
- 物流中心原材料入庫流程
- 河南省濮陽市2024-2025學(xué)年高一上學(xué)期1月期末考試語文試題(含答案)
- 長(zhǎng)沙市2025屆中考生物押題試卷含解析
- 2024年08月北京中信銀行北京分行社會(huì)招考(826)筆試歷年參考題庫附帶答案詳解
- 2024年芽苗菜市場(chǎng)調(diào)查報(bào)告
- 蘇教版二年級(jí)數(shù)學(xué)下冊(cè)全冊(cè)教學(xué)設(shè)計(jì)
- 職業(yè)技術(shù)學(xué)院教學(xué)質(zhì)量監(jiān)控與評(píng)估處2025年教學(xué)質(zhì)量監(jiān)控督導(dǎo)工作計(jì)劃
評(píng)論
0/150
提交評(píng)論