學(xué)生信息管理系統(tǒng)代碼_第1頁
學(xué)生信息管理系統(tǒng)代碼_第2頁
學(xué)生信息管理系統(tǒng)代碼_第3頁
學(xué)生信息管理系統(tǒng)代碼_第4頁
學(xué)生信息管理系統(tǒng)代碼_第5頁
已閱讀5頁,還剩21頁未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、【精品文檔】如有侵權(quán),請聯(lián)系網(wǎng)站刪除,僅供學(xué)習(xí)與交流學(xué)生信息管理系統(tǒng)代碼.精品文檔.主要代碼如下:1、登錄界面代碼:Dim cn As New ADODB.ConnectionDim rst As New ADODB.RecordsetPrivate Sub Command1_Click() Set cn = New ADODB.Connection Set rst = New ADODB.Recordset Static i% cn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID

2、=sa;Initial Catalog=students info;Data Source=C1847" cn.Open usna = Trim(Text1.Text) mysql = "select * from 用戶表 where 用戶名='" & usna & "'" rst.Open mysql, cn If rst.EOF Then MsgBox "用戶名不存在!" cn.Close Text1.Text = "" Text2.Text = ""

3、; Text1.SetFocus Else If Trim(rst("密碼") = Trim(Text2.Text) Then 管理界面.Show Else i = i + 1 If i < 3 Then MsgBox "用戶名或密碼錯誤!", vbOKOnly + vbExclamation, "警告" cn.Close Text2.Text = "" Text1.Text = "" Text1.SetFocus Else MsgBox "該用戶已被鎖定!", vbO

4、KOnly + vbExclamation, "警告" End If End If End If End SubPrivate Sub Command2_Click()Text1.Text = ""Text2.Text = ""Text3.Text = ""End Sub2、管理界面代碼:Private Sub Sinsert_Click()添加學(xué)生信息.ShowEnd SubPrivate Sub Sselect_Click()查詢學(xué)生信息.ShowEnd SubPrivate Sub sustu_Click()

5、查詢更新學(xué)生信息.ShowEnd SubPrivate Sub xgmm_Click()修改密碼.ShowEnd SubPrivate Sub yhzc_Click()用戶注冊.ShowEnd Sub3、查詢學(xué)生信息代碼:Dim cn As New ADODB.ConnectionDim rst As New ADODB.RecordsetPrivate Sub Command1_Click() Set cn = New ADODB.Connection Set rst = New ADODB.Recordset cn.ConnectionString = "Provider=SQL

6、OLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=students info;Data Source=C1847" cn.Open If Combo1.Text <> "" Then mysql = "select * from 學(xué)生信息表 where 系別='" & Trim(Combo1.Text) & "'" rst.Open mysql, cn If rst.EOF Then MsgBox &quo

7、t;沒有學(xué)生!", vbOKOnly + vbExclamation, "警告" Combo1.Text = "" Else With MSFlexGrid1 .TextMatrix(0, 1) = "學(xué)號" .TextMatrix(0, 2) = "姓名" .TextMatrix(0, 3) = "性別" .TextMatrix(0, 4) = "年齡" .TextMatrix(0, 5) = "系別" .TextMatrix(0, 6) =

8、"班級" MSFlexGrid1.Rows = 1 '每次查詢自動定位到第一行 Do While Not rst.EOF .Rows = .Rows + 1 .CellAlignment = 8 .TextMatrix(.Rows - 1, 1) = rst.Fields("學(xué)號") .TextMatrix(.Rows - 1, 2) = rst.Fields("姓名") .TextMatrix(.Rows - 1, 3) = rst.Fields("性別") .TextMatrix(.Rows - 1,

9、4) = rst.Fields("年齡") .TextMatrix(.Rows - 1, 5) = rst.Fields("系別") .TextMatrix(.Rows - 1, 6) = rst.Fields("班級") rst.MoveNext Loop End With End If ElseIf Combo2.Text <> "" Then mysql = "select * from 學(xué)生信息表 where 班級='" & Trim(Combo2.Text)

10、 & "'" rst.Open mysql, cn If rst.EOF Then MsgBox "沒有學(xué)生!", vbOKOnly + vbExclamation, "警告" Combo1.Text = "" Else With MSFlexGrid1 .TextMatrix(0, 1) = "學(xué)號" .TextMatrix(0, 2) = "姓名" .TextMatrix(0, 3) = "性別" .TextMatrix(0, 4) =

11、 "年齡" .TextMatrix(0, 5) = "系別" .TextMatrix(0, 6) = "班級" MSFlexGrid1.Rows = 1 '每次查詢自動定位到第一行 Do While Not rst.EOF .Rows = .Rows + 1 .CellAlignment = 8 .TextMatrix(.Rows - 1, 1) = rst.Fields("學(xué)號") .TextMatrix(.Rows - 1, 2) = rst.Fields("姓名") .TextMa

12、trix(.Rows - 1, 3) = rst.Fields("性別") .TextMatrix(.Rows - 1, 4) = rst.Fields("年齡") .TextMatrix(.Rows - 1, 5) = rst.Fields("系別") .TextMatrix(.Rows - 1, 6) = rst.Fields("班級") rst.MoveNext Loop End With End If ElseIf Text1.Text <> "" Then mysql =

13、"select * from 學(xué)生信息表 where 學(xué)號='" & Trim(Text1.Text) & "'" rst.Open mysql, cn If rst.EOF Then MsgBox "沒有學(xué)生!", vbOKOnly + vbExclamation, "警告" Combo1.Text = "" Else With MSFlexGrid1 .TextMatrix(0, 1) = "學(xué)號" .TextMatrix(0, 2) =

14、"姓名" .TextMatrix(0, 3) = "性別" .TextMatrix(0, 4) = "年齡" .TextMatrix(0, 5) = "系別" .TextMatrix(0, 6) = "班級" MSFlexGrid1.Rows = 1 '每次查詢自動定位到第一行 Do While Not rst.EOF .Rows = .Rows + 1 .CellAlignment = 8 .TextMatrix(.Rows - 1, 1) = rst.Fields("學(xué)號&

15、quot;) .TextMatrix(.Rows - 1, 2) = rst.Fields("姓名") .TextMatrix(.Rows - 1, 3) = rst.Fields("性別") .TextMatrix(.Rows - 1, 4) = rst.Fields("年齡") .TextMatrix(.Rows - 1, 5) = rst.Fields("系別") .TextMatrix(.Rows - 1, 6) = rst.Fields("班級") rst.MoveNext Loop

16、End With End IfElse MsgBox "請輸入查詢條件!", vbOKOnly + vbExclamation, "警告"End IfEnd SubPrivate Sub Command2_Click()Combo1.Text = ""Combo2.Text = ""Text1.Text = ""End SubPrivate Sub Command3_Click()修改學(xué)生信息.ShowEnd Sub '修改學(xué)生信息Private Sub Command4_Click()

17、 Set cn = New ADODB.Connection Set rst = New ADODB.Recordset cn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=students info;Data Source=C1847" cn.Open mysql = "delete from 學(xué)生信息表 where 學(xué)號='" & Text1.Text & "'&qu

18、ot; rst.Open mysql, cn MsgBox "刪除成功!", vbOKOnly + vbExclamation, "警告"End SubPrivate Sub Form_Load()Combo1.AddItem "信息服務(wù)學(xué)院"Combo1.AddItem "電子信息工程系"Combo2.AddItem "40821P"Combo2.AddItem "40811P"Combo2.AddItem "40822P"Combo2.AddItem

19、"40721P"End Sub4、添加學(xué)生信息代碼Dim cn As New ADODB.ConnectionDim rst As New ADODB.RecordsetPrivate Sub Form_Load()Combo1.AddItem "信息服務(wù)學(xué)院"Combo1.AddItem "電子信息工程系"Combo2.AddItem "40821P"Combo2.AddItem "40811P"Combo2.AddItem "40822P"Combo2.AddItem &

20、quot;40721P"End SubPrivate Sub Command1_Click() Set cn = New ADODB.Connection Set rst = New ADODB.Recordset cn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=students info;Data Source=C1847" cn.OpenDim sex As String usna = Trim(Text1.Tex

21、t) mysql = "select * from 學(xué)生信息表 where 學(xué)號='" & usna & "'" rst.Open mysql, cn If rst.EOF Then rst.Close Else rst.Close MsgBox "該學(xué)生信息已存在!", vbOKOnly + vbExclamation, "警告" Text1.Text = "" Text2.Text = "" Text3.Text = ""

22、; Combo1.Text = "" Combo2.Text = "" Option1.Value = False Text1.SetFocus End IfIf Text1.Text = "" Then MsgBox "請輸入學(xué)號!", vbOKOnly + vbExclamation, "警告" Text1.SetFocus Exit Sub End IfIf Text2.Text = "" Then MsgBox "請輸入姓名!", vbOKOnly

23、 + vbExclamation, "警告" Text2.SetFocus Exit Sub End IfIf Text3.Text = "" Then MsgBox "請輸入年齡!", vbOKOnly + vbExclamation, "警告" Text3.SetFocus Exit Sub End IfIf Option1.Value Then sex = "男" Else sex = "女"End Ifxh = Trim(Text1.Text)xm = Trim(Te

24、xt2.Text)xb = sexnl = Trim(Text3.Text)xofy = Trim(Combo1.Text)bj = Trim(Combo2.Text)mysql = "insert into 學(xué)生信息表(學(xué)號,姓名,性別,年齡,系別,班級) values ('" & xh & "','" & xm & "','" & xb & "','" & nl & "',&

25、#39;" & xofy & "','" & bj & "')"rst.Open mysql, cnMsgBox ("信息添加成功!") Text1.Text = "" Text2.Text = "" Text3.Text = "" Combo1.Text = "" Combo2.Text = "" Option1.Value = FalseEnd Sub5、修改密碼:D

26、im rst As New ADODB.Recordset Dim cn As New ADODB.ConnectionPrivate Sub Command1_Click() Set cn = New ADODB.Connection Set rst = New ADODB.Recordset cn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=students info;Data Source=C1847" cn.Open If

27、 Text1.Text = "" Then MsgBox "請輸入密碼!", vbOKOnly + vbExclamation, "警告" Text1.SetFocus Exit Sub End IfIf Text2.Text = "" Then MsgBox "請輸入新密碼!", vbOKOnly + vbExclamation, "警告" Text2.SetFocus Exit Sub End IfIf Text3.Text = "" Then Msg

28、Box "請確認(rèn)輸入的新密碼!", vbOKOnly + vbExclamation, "警告" Text3.SetFocus Exit Sub End IfIf Text2.Text = Text3.Text Thenxmm = Trim(Text2.Text)mysql = "update 用戶表 set 密碼 = '" & xmm & "' where 用戶名 = '" & 登陸.Text1.Text & "'"rst.Ope

29、n mysql, cnMsgBox ("密修改成功!")End If End SubPrivate Sub Command2_Click()Text1.Text = ""Text2.Text = ""Text3.Text = ""End Sub6、修改學(xué)生信息代碼:Dim cn As New ADODB.ConnectionDim rst As New ADODB.RecordsetPrivate Sub Command1_Click() Set cn = New ADODB.Connection Set rst

30、= New ADODB.Recordset cn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=students info;Data Source=C1847" cn.Open usna = Trim(Text1.Text) mysql = "select * from 學(xué)生信息表 where 學(xué)號='" & usna & "'" rst.Open mysql,

31、 cn rst.Close mysql = "delete from 學(xué)生信息表 where 學(xué)號='" & Text1.Text & "'" rst.Open mysql, cnIf Text1.Text = "" Then MsgBox "請輸入學(xué)號!", vbOKOnly + vbExclamation, "警告" Text1.SetFocus Exit Sub End IfIf Text2.Text = "" Then MsgBox &

32、quot;請輸入姓名!", vbOKOnly + vbExclamation, "警告" Text2.SetFocus Exit Sub End IfIf Text3.Text = "" Then MsgBox "請輸入年齡!", vbOKOnly + vbExclamation, "警告" Text3.SetFocus Exit Sub End IfIf Option1.Value Then sex = "男" Else sex = "女"End Ifxh = T

33、rim(Text1.Text)xm = Trim(Text2.Text)xb = sexnl = Trim(Text3.Text)xofy = Trim(Combo1.Text)bj = Trim(Combo2.Text)mysql = "insert into 學(xué)生信息表(學(xué)號,姓名,性別,年齡,系別,班級) values ('" & xh & "','" & xm & "','" & xb & "','" &

34、amp; nl & "','" & xofy & "','" & bj & "')"rst.Open mysql, cnMsgBox ("信息修改成功!") Text1.Text = "" Text2.Text = "" Text3.Text = "" Combo1.Text = "" Combo2.Text = "" Option1.V

35、alue = FalseEnd SubPrivate Sub Form_Load()Combo1.AddItem "信息服務(wù)學(xué)院"Combo1.AddItem "電子信息工程系"Combo2.AddItem "40821P"Combo2.AddItem "40811P"Combo2.AddItem "40822P"Combo2.AddItem "40721P"End Sub7、用戶注冊代碼:Dim rst As New ADODB.Recordset Dim cn As Ne

36、w ADODB.ConnectionPrivate Sub Command1_Click() Set cn = New ADODB.Connection Set rst = New ADODB.Recordset cn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=students info;Data Source=C1847" cn.Open If Text1.Text = "" Then MsgBox &qu

37、ot;請輸入用戶名!", vbOKOnly + vbExclamation, "警告" Text1.SetFocus Exit Sub End IfIf Text2.Text = "" Then MsgBox "請輸入密碼!", vbOKOnly + vbExclamation, "警告" Text2.SetFocus Exit Sub End IfIf Text3.Text = "" Then MsgBox "請?jiān)俅屋斎朊艽a!", vbOKOnly + vbExc

38、lamation, "警告" Text3.SetFocus Exit Sub End Ifsryhm = Trim(Text1.Text)srmm = Trim(Text2.Text)mysql = "insert into 用戶表(用戶名,密碼) values ('" & sryhm & "','" & srmm & "')"rst.Open mysql, cnMsgBox ("用戶添加成功!")Text1.Text = &quo

39、t;"Text2.Text = ""Text3.Text = "" End Sub '添加用戶Private Sub Command2_Click()Text1.Text = ""Text2.Text = ""Text3.Text = ""End Sub '重置按鈕Private Sub Command3_Click() Set cn = New ADODB.Connection Set rst = New ADODB.Recordset cn.ConnectionSt

40、ring = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=students info;Data Source=C1847" cn.Open usna = Trim(Text1.Text) mysql = "select * from 用戶表 where 用戶名='" & usna & "'" rst.Open mysql, cn If rst.EOF Then MsgBox "用戶名可用

41、!" Else MsgBox "用戶名已存在!", vbOKOnly + vbExclamation, "警告" Text1.Text = "" Text2.Text = "" Text3.Text = "" Text1.SetFocus Exit Sub End IfEnd Sub '檢查用戶名Private Sub Command4_Click() Set cn = New ADODB.Connection Set rst = New ADODB.Recordset cn.ConnectionString = "Provider=SQLOLEDB.1;Persist Secu

溫馨提示

  • 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)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論