




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、教師管理操作流程使用Teacher賬號登陸教師管理系統代碼區域:if (loginType = 教師) string sql = string.Format(select count(*) from teacher where LoginId=0 AND LoginPwd=1, loginId, loginPwd); try SqlCommand command = new SqlCommand(sql, DBHelper.connection); DBHelper.connection.Open(); count = (int)command.ExecuteScalar(); if (cou
2、nt = 1) isValidUser = true; else index+; if (index = 3) Application.Exit(); isValidUser = false; catch (Exception ex) message = ex.Message; Console.WriteLine(ex.Message); 查詢修改信息查詢教師基本信息(代碼區域:) TeacherBaseForm teacherBaseForm = new TeacherBaseForm(); teacherBaseForm.Show();TeacherBaseForm(教師基本信息窗體)查詢
3、及修改學生信息(代碼區域:) UpdateStudentForm updateStudentForm = new UpdateStudentForm(); updateStudentForm.Show();SearchTeacherForm.cs(查詢及修改信息窗體)AddScoreForm(學生成績錄入窗體)錄入按鈕代碼:string sql = string.Format(select StudentId,StudentNo,StudentName from Student where StudentId=0, txtId.Text); try SqlCommand command = n
4、ew SqlCommand(sql, DBHelper.connection); DBHelper.connection.Open(); SqlDataReader reader = command.ExecuteReader(); while (reader.Read() id = (int)readerStudentId; no = (string)readerStudentNo; name = (string)readerStudentName; reader.Close(); catch (Exception ex) MessageBox.Show(ex.Message); final
5、ly DBHelper.connection.Close(); if (TianJia() if (txtId.Text = Convert.ToString(id) & txtStudentNo.Text = no & txtStudentName.Text = name) string studentName = txtStudentName.Text; string sdudentNo = txtStudentNo.Text; string subject = cboSubject.Text; string score = txtScore.Text; int classId = Get
6、ClassId(); string studentId = txtId.Text; string sql1 = string.Format(insert into Score(StudentNo,Subject,SScore,SName,ClassId,StudentId)values(0,1,2,3,4,5), sdudentNo, subject, score, studentName, classId, studentId); try SqlCommand command = new SqlCommand(sql1, DBHelper.connection); DBHelper.conn
7、ection.Open(); int result = command.ExecuteNonQuery(); if (result != 1) MessageBox.Show(添加失敗, 輸入提示, MessageBoxButtons.OK, MessageBoxIcon.Information); else MessageBox.Show(添加成功, 輸入提示, MessageBoxButtons.OK, MessageBoxIcon.Information); catch (Exception ex) /MessageBox.Show(操作數據庫出錯!, 輸入提示, MessageBoxB
8、uttons.OK, MessageBoxIcon.Information); /Console.WriteLine(ex.Message); MessageBox.Show(ex.Message); finally DBHelper.connection.Close(); else MessageBox.Show(您輸入的學生在數據庫中沒有,請重新輸入, 輸入提示, MessageBoxButtons.OK, MessageBoxIcon.Information); private void AddScoreForm_Load(object sender, EventArgs e) stri
9、ng sql = select gradeName from Grade; try SqlCommand command = new SqlCommand(sql, DBHelper.connection); DBHelper.connection.Open(); SqlDataReader reader = command.ExecuteReader(); while (reader.Read() string gradeName = (string)reader0; cboGrade.Items.Add(gradeName); reader.Close(); catch (Exceptio
10、n ex) MessageBox.Show(ex.Message); finally DBHelper.connection.Close(); string sql1 = select SubjectName from Subject; try SqlCommand command = new SqlCommand(sql1, DBHelper.connection); DBHelper.connection.Open(); SqlDataReader reader = command.ExecuteReader(); while (reader.Read() string subName =
11、 (string)reader0; cboSubject.Items.Add(subName); reader.Close(); catch (Exception ex) MessageBox.Show(ex.Message); finally DBHelper.connection.Close(); private void cboGrade_SelectedIndexChanged(object sender, EventArgs e) if (cboGrade.Text.Trim() != ) int gradeId = -1; string sql = string.Format(se
12、lect GradeId from Grade where GradeName=0, cboGrade.Text); SqlCommand command = new SqlCommand(sql, DBHelper.connection); try DBHelper.connection.Open(); SqlDataReader reader = command.ExecuteReader(); if (reader.Read() gradeId = (int)reader0; reader.Close(); catch (Exception ex) MessageBox.Show(操作數
13、據庫出錯); Console.WriteLine(ex.Message); finally DBHelper.connection.Close(); sql = SELECT ClassName FROM Class WHERE GradeId= + gradeId; command.CommandText = sql; try DBHelper.connection.Open(); SqlDataReader reader = command.ExecuteReader(); string className = ; cboClass.Items.Clear(); while (reader
14、.Read() className = (string)readerClassName; cboClass.Items.Add(className); reader.Close(); catch (Exception ex) MessageBox.Show(操作數據庫出錯); Console.WriteLine(ex.Message); finally DBHelper.connection.Close(); private void txtId_TextChanged(object sender, EventArgs e) UpdateScoreForm(更新成績窗體)保存按鈕代碼:DialogResult result = MessageBox.Show(確實要將修改保存到數據庫嗎?, 輸入提示, MessageBoxButtons.OK, MessageBoxIcon.Information); if (result = DialogResult.OK) SqlCommandBuilder builder = new S
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 在線編程教育平臺在2025年的國際化發展策略研究報告
- 直播電商主播在2025年的粉絲互動與內容營銷策略研究報告
- 2025年互聯網金融平臺資金存管風險管理及應對措施分析
- 工業互聯網平臺量子密鑰分發技術在智能物流領域的應用報告
- 電子病歷系統在醫院信息化建設中的應用優化與醫療信息化產業發展政策報告
- 葡萄酒產區特色與品牌國際化品牌傳播渠道研究報告
- 2025年廢舊塑料回收利用技術升級與環保產業轉型路徑報告
- 過敏醫療領域過敏源檢測技術發展現狀與2025年市場前景
- 校園安全管理報告:2025年智慧校園安全風險識別與預防技術發展趨勢分析
- 同在一個屋檐下5篇
- 體育指導員協會籌備
- MOOC 新媒體文化十二講-暨南大學 中國大學慕課答案
- 廣西博物館2024事業單位招聘通過歷年高頻考題難、易錯點模擬試題(共500題)附帶答案詳解
- 展廳講解員培訓方案
- 物流服務營銷策略分析
- MOOC 光纖通信-南京郵電大學 中國大學慕課答案
- 律師事務所設立承諾書
- 2024陜西延長石油氣田公司遴選選聘筆試參考題庫附帶答案詳解
- 安全與發展同步進行
- 民盟入盟申請書(通用6篇)
- 調度自動化系統主站信息自動聯調技術規范
評論
0/150
提交評論