




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、學(xué)生學(xué)籍管理系統(tǒng)詳細(xì)代碼本文為學(xué)生學(xué)籍管理系統(tǒng)的各個模塊效果圖和詳細(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;/存儲臨時
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é)號/教師編號登錄!,如過沒有注冊則點擊“注冊”進(jìn)行注冊!", "提示"); private void but
3、ton1_Click(object sender, EventArgs e) bool UserExit = false, KeyRight = false; /聲明上下文集合 DataClasses1DataContext myDataContext = new DataClasses1DataContext(); /把用戶表里所有內(nèi)容提取到User集合里 /排查輸入錯誤 /用戶名為空 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("密碼錯誤!"); 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、密碼錯誤"); 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(); /注冊按鈕實現(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; 注冊模塊代碼:代碼: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;/帳號是否被注冊標(biāo)記 bool isexited=false;/帳號是否存在標(biāo)記 /提取出用戶數(shù)據(jù)表里所有用戶資料 DataClasses1DataContext myDataContext = new DataClasses1DataContext(); var UsersQuery = from User in myDataContex
14、t.UsersTable select User; /文本數(shù)據(jù)發(fā)生變化時候,檢查輸入是否可以申請 /學(xué)生身份申請帳號 if (radioButton1.Checked = true) /在用戶表里檢查該學(xué)生帳號是否被注冊了 foreach (var user in UsersQuery) /學(xué)生用戶帳號已經(jīng)被注冊 if (user.UerID = textBox1.Text && user.Identity = radioButton1.Text) isRegeisted = true; /檢出該學(xué)號被注冊了 if (isRegeisted = true) checkBox1.
15、Text = "已注冊的號碼" /MessageBox.Show("該學(xué)號已經(jīng)被注冊了!"); /帳號沒有被注冊,在學(xué)生表里檢查該學(xué)號存在與否 else DataClasses2DataContext myDataContext2 = new DataClasses2DataContext(); /從學(xué)生表里提取所有數(shù)據(jù) var StuQuery = from Stud in myDataContext2.StudentsTable select Stud; foreach (var stu in StuQuery) /學(xué)號被找到了,說明該學(xué)號存在且沒有
16、被注冊,可以注冊該學(xué)號 if (stu.StudentN = textBox1.Text) isexited = true; if (isexited = false) /MessageBox.Show("該學(xué)號不存在!"); checkBox1.Text = "不存在的學(xué)號" else /checkBox1打勾,說明可用 checkBox1.Checked = true; checkBox1.Text = "" textBox2.Enabled = true; /教師注冊 else /檢查用戶表看帳號有沒有被注冊 foreach (
17、var user in UsersQuery) /教師帳號已經(jīng)被注冊了 if (textBox1.Text = user.UerID && radioButton2.Text = user.Identity) isRegeisted = true; /被注冊的處理 if (isRegeisted = true) checkBox1.Text = "帳號被注冊" else /未被注冊的帳號,到教師信息表里查找該教師編號是否存在 DataClasses3DataContext TeacherDataContext = new DataClasses3DataCo
18、ntext(); /取出教師信息表里的所有數(shù)據(jù),放到集合里 var TeacherQuery = from teac in TeacherDataContext.TeachersTable select teac; foreach (var teacher in TeacherQuery) /查找到存在這個教師編號 if (teacher.TeacherN = textBox1.Text) isexited = true; /不存在這個編號的老師的處理 if (isexited = false) checkBox1.Text = "不存在的編號" 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ī)范,密碼長度為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 = "密碼長度6-16!" else /密碼格式正確,checkedBox打勾且激活textBox3 checkBox2.Text = "" checkBox2.Checked = true;
21、textBox3.Enabled = true; /驗證密碼的文本改變事件 private void textBox3_TextChanged(object sender, EventArgs e) button1.Enabled = false; checkBox3.Checked = false; /檢驗密碼和驗證密碼是否相等 if (textBox2.Text != textBox3.Text) checkBox3.Text = "密碼確認(rèn)失??!" /密碼和確認(rèn)密碼相同,可以注冊,激活注冊按鈕,同時把checkBox3打勾 else button1.Enabled =
22、 true; checkBox3.Checked = true; checkBox3.Text = "" /幫助按鈕實現(xiàn) private void button2_Click(object sender, EventArgs e) MessageBox.Show("師生只能通過自己的唯一學(xué)號/教師編號注冊,如果發(fā)現(xiàn)自己帳號被非法注冊,請聯(lián)系管理員!", "注冊幫助"); /注冊按鈕的實現(xiàn) private void button1_Click(object sender, EventArgs e) /檢測數(shù)據(jù)填寫狀態(tài),確定是否有了注冊需
23、要的足夠滿足格式的數(shù)據(jù) if (checkBox1.Checked && checkBox2.Checked && checkBox3.Checked) /滿足條件,將數(shù)據(jù)寫到數(shù)據(jù)庫的UsersTable里 DataClasses1DataContext myDataContext = new DataClasses1DataContext(); /分注冊身份進(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("注冊成功!請牢記你的密碼!"); /清空各個內(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、點擊事件,使得點擊無效 private void checkBox1_Click(object sender, EventArgs e) if (checkBox1.Checked) checkBox1.Checked = false; else checkBox1.Checked = true; /屏蔽掉點擊事件,使得點擊無效 private void checkBox2_Click(object sender, EventArgs e) if (checkBox2.Checked) checkBox2.Checked = false; else checkBox2.Checked = tr
27、ue; /屏蔽掉點擊事件,使得點擊無效 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) /屏蔽掉點擊事件,使得點擊無效 private void radio
28、Button1_Click(object sender, EventArgs e) /檢測學(xué)生帳號是否被注冊 checkBox1.Checked = false; textBox2.Enabled = false; bool isRegeisted = false;/帳號是否被注冊標(biāo)記 bool isexited = false;/帳號是否存在標(biāo)記 /提取出用戶數(shù)據(jù)表里所有用戶資料 DataClasses1DataContext myDataContext = new DataClasses1DataContext(); var UsersQuery = from User in myData
29、Context.UsersTable select User; /在用戶表里檢查該學(xué)生帳號是否被注冊了 foreach (var user in UsersQuery) /學(xué)生用戶帳號已經(jīng)被注冊 if (user.UerID = textBox1.Text && user.Identity ="學(xué)生") isRegeisted = true; /檢出該學(xué)號被注冊了 if (isRegeisted = true) checkBox1.Text = "已注冊的號碼" /MessageBox.Show("該學(xué)號已經(jīng)被注冊了!"
30、;); /帳號沒有被注冊,在學(xué)生表里檢查該學(xué)號存在與否 else DataClasses2DataContext myDataContext2 = new DataClasses2DataContext(); /從學(xué)生表里提取所有數(shù)據(jù) var StuQuery = from Stud in myDataContext2.StudentsTable select Stud; foreach (var stu in StuQuery) /學(xué)號被找到了,說明該學(xué)號存在且沒有被注冊,可以注冊該學(xué)號 if (stu.StudentN = textBox1.Text) isexited = true; i
31、f (isexited = false) /MessageBox.Show("該學(xué)號不存在!"); checkBox1.Text = "不存在的學(xué)號" else /checkBox1打勾,說明可用 checkBox1.Checked = true; checkBox1.Text = "" textBox2.Enabled = true; /屏蔽掉點擊事件,使得點擊無效 private void radioButton2_Click(object sender, EventArgs e) checkBox1.Checked = fals
32、e; textBox2.Enabled = false; bool isRegeisted = false;/帳號是否被注冊標(biāo)記 bool isexited = false;/帳號是否存在標(biāo)記 /提取出用戶數(shù)據(jù)表里所有用戶資料 DataClasses1DataContext myDataContext = new DataClasses1DataContext(); var UsersQuery = from User in myDataContext.UsersTable select User; /教師注冊 /檢查用戶表看帳號有沒有被注冊 foreach (var user in User
33、sQuery) /教師帳號已經(jīng)被注冊了 if (textBox1.Text = user.UerID && user.Identity="教師") isRegeisted = true; /被注冊的處理 if (isRegeisted = true) checkBox1.Text = "帳號被注冊" else /未被注冊的帳號,到教師信息表里查找該教師編號是否存在 DataClasses3DataContext TeacherDataContext = new DataClasses3DataContext(); /取出教師信息表里的所有數(shù)據(jù),放到集合里 var TeacherQuery = from teac in TeacherDataContext.TeachersTable select teac; foreach (var teacher in TeacherQuery) /查找到存在這個教師編號 if (teacher.
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025-2030中國激光產(chǎn)業(yè)市場深度調(diào)研及發(fā)展前景與投資前景研究報告
- 2025-2030中國漫展行業(yè)市場現(xiàn)狀分析及競爭格局與投資發(fā)展研究報告
- 2025-2030中國濾清器行業(yè)運行態(tài)勢與投資前景深度評估研究報告
- 2025-2030中國溜冰鞋行業(yè)市場現(xiàn)狀供需分析及投資評估規(guī)劃分析研究報告
- 2025-2030中國港口及物料裝卸設(shè)備車行業(yè)市場現(xiàn)狀供需分析及投資評估規(guī)劃分析研究報告
- 2025-2030中國漁用藥品市場現(xiàn)狀監(jiān)測及發(fā)展前景規(guī)模研究報告
- 2025-2030中國清真肉行業(yè)市場現(xiàn)狀供需分析及投資評估規(guī)劃分析研究報告
- 2025-2030中國液化石油氣灶具行業(yè)市場運營模式及未來發(fā)展動向研究報告
- 2025-2030中國液體活檢用采血管行業(yè)市場發(fā)展趨勢與前景展望戰(zhàn)略研究報告
- 2025-2030中國潤滑劑儲存容器行業(yè)市場現(xiàn)狀供需分析及投資評估規(guī)劃分析研究報告
- 2024智能網(wǎng)聯(lián)汽車自動駕駛功能仿真試驗方法及要求
- 重大事件保電作業(yè)指導(dǎo)書
- 山東省濟(jì)南市2022-2023學(xué)年六年級下學(xué)期語文期末考試試卷(含答案)
- 五年級上冊小數(shù)乘除法計算題(純豎式計算)1
- 供電所績效考核實施方案
- 《寶葫蘆的秘密》導(dǎo)讀課(教案)部編版語文四年級下冊
- 艾滋病伴卡氏肺孢子蟲肺炎的個案護(hù)理
- 資產(chǎn)負(fù)債表完整版本
- 彩盒生產(chǎn)工藝流程圖
- 污水處理項目實施重點、難點分析
- 機械制圖繪制標(biāo)準(zhǔn)
評論
0/150
提交評論