




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、教務(wù)管理員操作流程使用Admin賬號登陸教務(wù)管理員系統(tǒng)代碼區(qū)域:int count = 0; bool isValidUser = false; if (loginType = 教務(wù)管理員) string sql = string.Format(select count(*) from Admin where LoginId=0 AND LoginPwd=1, loginId, loginPwd); try SqlCommand command = new SqlCommand(sql, DBHelper.connection); DBHelper.connection.Open(); cou
2、nt = (int)command.ExecuteScalar(); if (count = 1) isValidUser = true; else index+; if (index = 3) Application.Exit(); isValidUser = false; catch (Exception ex) message = ex.Message; Console.WriteLine(ex.Message); finally DBHelper.connection.Close(); if (cboType.Text = 教務(wù)管理員) AdminForm adminForm = ne
3、w AdminForm(); adminForm.Show(); return true; 成功進(jìn)入后可以進(jìn)行AdminForm.cs (教務(wù)管理員窗體)用戶管理新增用戶新增學(xué)生信息(代碼如下:) AddStudentForm addstudnetForm = new AddStudentForm(); addstudnetForm.MdiParent = this; addstudnetForm.Show();彈出窗口(學(xué)生信息添加)Student表AdminStudentForm.cs保存按鈕代碼如下: if (TianJia() try SqlCommand command = new
4、SqlCommand(sql, DBHelper.connection); DBHelper.connection.Open(); int result = command.ExecuteNonQuery(); if (result != 1) MessageBox.Show(添加失敗, 輸入提示, MessageBoxButtons.OK, MessageBoxIcon.Information); else MessageBox.Show(添加成功, 輸入提示, MessageBoxButtons.OK, MessageBoxIcon.Information); catch (Excepti
5、on ex) MessageBox.Show(ex.Message); finally DBHelper.connection.Close(); private void AddStudentForm_Load(object sender, EventArgs e) string sql = select gradeName from Grade; try SqlCommand command=new SqlCommand(sql,DBHelper.connection); DBHelper.connection.Open(); SqlDataReader reader=command.Exe
6、cuteReader(); while(reader.Read() string gradeName=(string)reader0; cboGrade.Items.Add(gradeName); 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() !=
7、) int gradeId = -1; string sql = string.Format(select 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.C
8、lose(); catch (Exception ex) MessageBox.Show(操作數(shù)據(jù)庫出錯); 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 clas
9、sName = ; cboClass.Items.Clear(); while (reader.Read() className = (string)readerClassName; cboClass.Items.Add(className); reader.Close(); catch (Exception ex) MessageBox.Show(操作數(shù)據(jù)庫出錯); Console.WriteLine(ex.Message); finally DBHelper.connection.Close(); private void txtStudentPassword_TextChanged(ob
10、ject sender, EventArgs e) AdminTeacherForm.cs (教師信息添加窗體) 新增教師信息彈出窗口(教師信息添加)Teacher表保存按鈕代碼如下:if (TianJia() try SqlCommand command = new SqlCommand(sql, DBHelper.connection); DBHelper.connection.Open(); int result = command.ExecuteNonQuery(); if (result != 1) MessageBox.Show(添加失敗, 輸入提示, MessageBoxButt
11、ons.OK, MessageBoxIcon.Information); else MessageBox.Show(添加成功, 輸入提示, MessageBoxButtons.OK, MessageBoxIcon.Information); catch (Exception ex) MessageBox.Show(操作數(shù)據(jù)庫出錯, 輸入提示, MessageBoxButtons.OK, MessageBoxIcon.Information); Console.WriteLine(ex.Message); finally DBHelper.connection.Close(); 查詢修改信息學(xué)生
12、信息查詢及刪除信息(可以進(jìn)行模糊查詢)SearchStudentForm.cs (學(xué)生查詢及刪除信息窗體)查詢按鈕代碼:if (txtName.Text = ) MessageBox.Show(請輸入用戶名, 輸入提示, MessageBoxButtons.OK, MessageBoxIcon.Information); txtName.Focus(); else SearchStudent(); private void tsmiDelete_Click(object sender, EventArgs e) if (listView1.SelectedItems.Count = 0) Me
13、ssageBox.Show(您沒有選擇任何用戶, 輸入提示, MessageBoxButtons.OK, MessageBoxIcon.Information); else DialogResult choice = MessageBox.Show(確定要刪除該用戶嗎, 警告, MessageBoxButtons.OK, MessageBoxIcon.Information); if (choice = DialogResult.OK) int result = 0; try string sql = string.Format(delete Student where StudentId=0
14、, (int)listView1.SelectedItems0.Tag); SqlCommand command = new SqlCommand(sql, DBHelper.connection); DBHelper.connection.Open(); result = command.ExecuteNonQuery(); catch (Exception ex) MessageBox.Show(ex.Message); finally DBHelper.connection.Close(); if (result 1) MessageBox.Show(刪除失敗, 輸入提示, Messag
15、eBoxButtons.OK, MessageBoxIcon.Exclamation); else MessageBox.Show(刪除成功, 輸入提示, MessageBoxButtons.OK, MessageBoxIcon.Information); SearchStudent(); UpdateStudentForm.cs (學(xué)生更新信息窗體)保存信息按鈕代碼:DialogResult result = MessageBox.Show(確實要將修改保存到數(shù)據(jù)庫嗎?, 輸入提示, MessageBoxButtons.OK, MessageBoxIcon.Information); if
16、(result = DialogResult.OK) SqlCommandBuilder builder = new SqlCommandBuilder(dataAdapter); dataAdapter.Update(dataSet, Student); MessageBox.Show(保存成功, 輸入提示, MessageBoxButtons.OK, MessageBoxIcon.Information); else MessageBox.Show(保存失敗, 輸入提示, MessageBoxButtons.OK, MessageBoxIcon.Information); SearchTe
17、acherForm.cs (教師查詢及刪除信息窗體)查詢按鈕代碼:if (txtName.Text = ) MessageBox.Show(請輸入用戶名, 輸入提示, MessageBoxButtons.OK, MessageBoxIcon.Information); txtName.Focus(); else SearchTeacher(); private void btnExit_Click(object sender, EventArgs e) this.Close(); private void tsmiDelete1_Click(object sender, EventArgs e
18、) if (listView1.SelectedItems.Count = 0) MessageBox.Show(您沒有選擇任何用戶, 輸入提示, MessageBoxButtons.OK, MessageBoxIcon.Information); else DialogResult choice = MessageBox.Show(確定要刪除該用戶嗎, 警告, MessageBoxButtons.OK, MessageBoxIcon.Information); if (choice = DialogResult.OK) int result = 0; try string sql = str
19、ing.Format(delete Teacher where TeacherId=0, (int)listView1.SelectedItems0.Tag); SqlCommand command = new SqlCommand(sql, DBHelper.connection); DBHelper.connection.Open(); result = command.ExecuteNonQuery(); catch (Exception ex) MessageBox.Show(ex.Message); finally DBHelper.connection.Close(); if (result 1) MessageBox.Show(刪除失敗, 輸入提示, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); else MessageBox.Show(刪除成功, 輸入提示, MessageBoxButtons.OK, MessageBoxIcon.Info
溫馨提示
- 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至2031年中國高檔實木沙發(fā)腳行業(yè)投資前景及策略咨詢研究報告
- 2025至2031年中國一次性座便紙墊行業(yè)投資前景及策略咨詢研究報告
- 2025至2030年中國裘皮革制品數(shù)據(jù)監(jiān)測研究報告
- 2025年安徽交通職業(yè)技術(shù)學(xué)院單招職業(yè)技能考試題庫及答案一套
- 2025年阿克蘇職業(yè)技術(shù)學(xué)院單招職業(yè)傾向性考試題庫及完整答案1套
- 2025年包頭鋼鐵職業(yè)技術(shù)學(xué)院單招職業(yè)傾向性測試題庫審定版
- 2025年阿拉善職業(yè)技術(shù)學(xué)院單招職業(yè)傾向性測試題庫帶答案
- 2025年安徽城市管理職業(yè)學(xué)院單招職業(yè)適應(yīng)性考試題庫1套
- 2025年安徽醫(yī)學(xué)高等專科學(xué)校單招職業(yè)傾向性測試題庫標(biāo)準(zhǔn)卷
- 2025年安徽新聞出版職業(yè)技術(shù)學(xué)院單招綜合素質(zhì)考試題庫審定版
- 南充市高2025屆高三高考適應(yīng)性考試(二診)英語試卷
- 2025年黑龍江職業(yè)學(xué)院單招職業(yè)適應(yīng)性測試題庫帶答案
- 2025年湖南有色金屬職業(yè)技術(shù)學(xué)院單招職業(yè)傾向性測試題庫附答案
- 第五章產(chǎn)前檢查及高危妊娠監(jiān)測課件
- 2025年02月曲靖市師宗縣事業(yè)單位委托公開遴選工作人員(含遴選)26人筆試歷年典型考題(歷年真題考點)解題思路附帶答案詳解
- 2025年寶雞職業(yè)技術(shù)學(xué)院單招職業(yè)技能測試題庫及完整答案1套
- 2025年車位買賣合同模板電子版
- AI創(chuàng)作指令合集系列之-教案寫作指令
- 《人工智能基礎(chǔ)》課件-AI的前世今生:她從哪里來
- 2024年沙洲職業(yè)工學(xué)院高職單招(英語/數(shù)學(xué)/語文)筆試歷年參考題庫含答案解析
- FontCreator符號字體制作教程
評論
0/150
提交評論