📄 学生管理.frm
字号:
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=学生教材管理系统.mdb;Persist Security Info=False"
OLEDBString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=学生教材管理系统.mdb;Persist Security Info=False"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "select * from 学生教材费支出总表"
Caption = "Adodc2"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.Line Line1
X1 = 0
X2 = 10620
Y1 = 6660
Y2 = 6660
End
End
Attribute VB_Name = "学生管理"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdadd_Click()
If cmdadd.Caption = "添加" Then
'Adodc1.Recordset.AddNew
cmdadd.Caption = "确定添加"
cmdmodify.Caption = "放弃添加"
txtxm.Locked = False
txtxh.Locked = False
cboxb.Locked = False
txtxi.Locked = False
txtbj.Locked = False
cmddelete.Enabled = False
txtydjl.Locked = False
txtxm = ""
txtxh = ""
cboxb = "男"
txtydjl = ""
txtxh.SetFocus
Else
If cmdadd.Caption = "放弃修改" Then
cmdmodify.Caption = "修改"
cmdadd.Caption = "添加"
txtxh.Locked = True
txtxm.Locked = True
cboxb.Locked = True
txtxi.Locked = True
txtbj.Locked = True
txtydjl.Locked = True
cmddelete.Enabled = True
txtxh = Adodc1.Recordset.Fields("xh")
txtxm = Adodc1.Recordset.Fields("xm")
cboxb.Text = Adodc1.Recordset.Fields("xb")
If Adodc1.Recordset.Fields("bz") <> "" Then
txtydjl = Adodc1.Recordset.Fields("bz")
Else
txtydjl = ""
End If
txtxi = Adodc1.Recordset.Fields("xi")
txtbj = Adodc1.Recordset.Fields("bj")
End If
If cmdadd.Caption = "确定添加" Then
aaaaaaa = 0
For i = 1 To Len(txtxh)
If Asc(Mid$(txtxh, i, 1)) < 48 Or Asc(Mid$(txtxh, i, 1)) > 57 Then aaaaaaa = 1
Next
If aaaaaaa = 1 Or txtxh = "" Or txtxm = "" Then ' 判断输入的学号是否是数值型的
MsgBox "学号不能为字符,学号和姓名不能为空!", vbOKOnly + vbInformation, "学生管理"
Else
Adodc1.Recordset.MoveFirst '判断在学生基本情况表中有无此学号
Adodc1.Recordset.Find "xh='" & Trim(txtxh) + "'"
If Adodc1.Recordset.EOF Then '如果无此学号添加
Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields("xm") = txtxm
Adodc1.Recordset.Fields("xh") = txtxh
Adodc1.Recordset.Fields("xb") = cboxb.Text
Adodc1.Recordset.Fields("xi") = txtxi
Adodc1.Recordset.Fields("bj") = txtbj
Adodc1.Recordset.Fields("bz") = txtydjl
Adodc1.Recordset.Update
Adodc2.RecordSource = "select * from 学生教材费支出总表 "
Adodc2.Refresh
Adodc2.Recordset.AddNew
Adodc2.Recordset.Fields("xm") = txtxm
Adodc2.Recordset.Fields("xh") = txtxh
Adodc2.Recordset.Fields("xi") = txtxi
Adodc2.Recordset.Fields("bj") = txtbj
Adodc2.Recordset.Update
Adodc2.RecordSource = "select * from 学生收费表 "
Adodc2.Refresh
Adodc2.Recordset.AddNew
Adodc2.Recordset.Fields("xm") = txtxm
Adodc2.Recordset.Fields("xh") = txtxh
Adodc2.Recordset.Fields("xi") = txtxi
Adodc2.Recordset.Fields("bj") = txtbj
Adodc2.Recordset.Update
Adodc2.RecordSource = "select * from 学生选修课教材费支出情况表 "
Adodc2.Refresh
Adodc2.Recordset.AddNew
Adodc2.Recordset.Fields("xm") = txtxm
Adodc2.Recordset.Fields("xh") = txtxh
Adodc2.Recordset.Fields("xi") = txtxi
Adodc2.Recordset.Fields("bj") = txtbj
Adodc2.Recordset.Update
Adodc2.RecordSource = "select * from 学生选修课教材情况表 "
Adodc2.Refresh
Adodc2.Recordset.AddNew
Adodc2.Recordset.Fields("xm") = txtxm
Adodc2.Recordset.Fields("xh") = txtxh
Adodc2.Recordset.Fields("xi") = txtxi
Adodc2.Recordset.Fields("bj") = txtbj
Adodc2.Recordset.Update
Adodc2.RecordSource = "select * from 学生专业课教材费支出情况表 "
Adodc2.Refresh
Adodc2.Recordset.AddNew
Adodc2.Recordset.Fields("xm") = txtxm
Adodc2.Recordset.Fields("xh") = txtxh
Adodc2.Recordset.Fields("xi") = txtxi
Adodc2.Recordset.Fields("bj") = txtbj
Adodc2.Recordset.Update
Adodc2.RecordSource = "select * from 学生专业课教材情况表 "
Adodc2.Refresh
Adodc2.Recordset.AddNew
Adodc2.Recordset.Fields("xm") = txtxm
Adodc2.Recordset.Fields("xh") = txtxh
Adodc2.Recordset.Fields("xi") = txtxi
Adodc2.Recordset.Fields("bj") = txtbj
Adodc2.Recordset.Update
cmdadd.Caption = "添加"
cmdmodify.Caption = "修改"
txtxh.Locked = True
txtxm.Locked = True
cboxb.Locked = True
txtxi.Locked = True
txtbj.Locked = True
txtydjl.Locked = True
cmddelete.Enabled = True
Adodc1.Refresh
DataGrid1.Refresh
Else
MsgBox "学生基本情况表中有此学号,请重新添加!", 48
End If
End If
End If
End If
End Sub
Private Sub cmddelete_Click()
xh = Adodc1.Recordset.Fields("xh")
'Adodc2.Recordset.MoveFirst
If Adodc2.Recordset.RecordCount <> 0 Then
'Adodc2.Recordset.Find "xh='" & xh & "'"
'If Not Adodc2.Recordset.EOF Then
Adodc2.RecordSource = "select * from 学生教材费支出总表 where xh='" & Trim(xh) + "'"
Adodc2.Refresh
Adodc2.Recordset.Delete
Adodc2.RecordSource = "select * from 学生收费表 where xh='" & Trim(xh) + "'"
Adodc2.Refresh
Adodc2.Recordset.Delete
Adodc2.RecordSource = "select * from 学生选修课教材费支出情况表 where xh='" & Trim(xh) + "'"
Adodc2.Refresh
Adodc2.Recordset.Delete
Adodc2.RecordSource = "select * from 学生选修课教材情况表 where xh='" & Trim(xh) + "'"
Adodc2.Refresh
Adodc2.Recordset.Delete
Adodc2.RecordSource = "select * from 学生专业课教材费支出情况表 where xh='" & Trim(xh) + "'"
Adodc2.Refresh
Adodc2.Recordset.Delete
Adodc2.RecordSource = "select * from 学生专业课教材情况表 where xh='" & Trim(xh) + "'"
Adodc2.Refresh
Adodc2.Recordset.Delete
' End If
End If
Adodc1.Recordset.Delete
Adodc1.Recordset.MoveFirst
End Sub
Private Sub cmdexit_Click()
Unload Me
End Sub
Private Sub cmdmodify_Click()
If cmdmodify.Caption = "修改" Then
txtxh.Locked = False
'txtxm.Locked = False
'cboxb.Locked = False
txtxi.Locked = False
txtbj.Locked = False
txtydjl.Locked = False
cmddelete.Enabled = False
cmdmodify.Caption = "确定修改"
cmdadd.Caption = "放弃修改"
txtxh.SetFocus
Else
If cmdmodify.Caption = "确定修改" Then
xh = Adodc1.Recordset.Fields("xh")
cmdmodify.Caption = "修改"
cmdadd.Caption = "添加"
txtxh.Locked = True
'txtxm.Locked = True
'cboxb.Locked = True
txtxi.Locked = True
txtbj.Locked = True
txtydjl.Locked = True
cmddelete.Enabled = True
Adodc1.Recordset.Fields("xh") = Trim(txtxh.Text)
Adodc1.Recordset.Fields("xi") = Trim(txtxi.Text)
Adodc1.Recordset.Fields("bj") = Trim(txtbj.Text)
Adodc1.Recordset.Fields("bz") = Trim(txtydjl.Text)
Adodc1.Recordset.Update
Adodc2.RecordSource = "select * from 学生教材费支出总表 where xh='" & Trim(xh) + "'"
Adodc2.Refresh
If Adodc2.Recordset.RecordCount = 0 Then
MsgBox ("请初始化:学生教材费支出总表、学生收费表、学生选修课教材费支出情况表、学生选修课教材情况表、、学生专业课教材费支出情况表、学生专业课教材情况表")
Else
Adodc2.Recordset.Fields("xh") = Trim(txtxh.Text)
Adodc2.Recordset.Fields("xi") = Trim(txtxi.Text)
Adodc2.Recordset.Fields("bj") = Trim(txtbj.Text)
Adodc2.Recordset.Update
Adodc2.RecordSource = "select * from 学生收费表 where xh='" & Trim(xh) + "'"
Adodc2.Refresh
Adodc2.Recordset.Fields("xh") = Trim(txtxh.Text)
Adodc2.Recordset.Fields("xi") = Trim(txtxi.Text)
Adodc2.Recordset.Fields("bj") = Trim(txtbj.Text)
Adodc2.Recordset.Update
Adodc2.RecordSource = "select * from 学生选修课教材费支出情况表 where xh='" & Trim(xh) + "'"
Adodc2.Refresh
Adodc2.Recordset.Fields("xh") = Trim(txtxh.Text)
Adodc2.Recordset.Fields("xi") = Trim(txtxi.Text)
Adodc2.Recordset.Fields("bj") = Trim(txtbj.Text)
Adodc2.Recordset.Update
Adodc2.RecordSource = "select * from 学生选修课教材情况表 where xh='" & Trim(xh) + "'"
Adodc2.Refresh
Adodc2.Recordset.Fields("xh") = Trim(txtxh.Text)
Adodc2.Recordset.Fields("xi") = Trim(txtxi.Text)
Adodc2.Recordset.Fields("bj") = Trim(txtbj.Text)
Adodc2.Recordset.Update
Adodc2.RecordSource = "select * from 学生专业课教材费支出情况表 where xh='" & Trim(xh) + "'"
Adodc2.Refresh
Adodc2.Recordset.Fields("xh") = Trim(txtxh.Text)
Adodc2.Recordset.Fields("xi") = Trim(txtxi.Text)
Adodc2.Recordset.Fields("bj") = Trim(txtbj.Text)
Adodc2.Recordset.Update
Adodc2.RecordSource = "select * from 学生专业课教材情况表 where xh='" & Trim(xh) + "'"
Adodc2.Refresh
Adodc2.Recordset.Fields("xh") = Trim(txtxh.Text)
Adodc2.Recordset.Fields("xi") = Trim(txtxi.Text)
Adodc2.Recordset.Fields("bj") = Trim(txtbj.Text)
Adodc2.Recordset.Update
End If
End If
If cmdmodify.Caption = "放弃添加" Then
cmdmodify.Caption = "修改"
cmdadd.Caption = "添加"
Adodc1.Refresh
txtxh = Adodc1.Recordset.Fields("xh")
txtxm = Adodc1.Recordset.Fields("xm")
cboxb.Text = Adodc1.Recordset.Fields("xb")
If Adodc1.Recordset.Fields("bz") <> "" Then
txtydjl = Adodc1.Recordset.Fields("bz")
Else
txtydjl = ""
End If
txtxi = Adodc1.Recordset.Fields("xi")
txtbj = Adodc1.Recordset.Fields("bj")
txtxh.Locked = True
txtxm.Locked = True
cboxb.Locked = True
txtxi.Locked = True
txtbj.Locked = True
cmddelete.Enabled = True
txtydjl.Locked = True
End If
End If
End Sub
Private Sub Combo1_Click()
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Dim cnn As ADODB.Connection
Set cnn = New ADODB.Connection
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=学生教材管理系统.mdb;Persist Security Info=False"
Dim sql As String
Adodc1.RecordSource = "select * from 学生基本情况表 where xi ='" & Combo1 + "'"
Adodc1.Refresh
txtxh = Adodc1.Recordset.Fields("xh")
txtxm = Adodc1.Recordset.Fields("xm")
cboxb.Text = Adodc1.Recordset.Fields("xb")
If Adodc1.Recordset.Fields("bz") <> "" Then
txtydjl = Adodc1.Recordset.Fields("bz")
Else
txtydjl = ""
End If
txtxi = Adodc1.Recordset.Fields("xi")
txtbj = Adodc1.Recordset.Fields("bj")
cmdmodify.Caption = "修改"
cmdadd.Caption = "添加"
Adodc1.Refresh
txtxh = Adodc1.Recordset.Fields("xh")
txtxm = Adodc1.Recordset.Fields("xm")
cboxb.Text = Adodc1.Recordset.Fields("xb")
If Adodc1.Recordset.Fields("bz") <> "" Then
txtydjl = Adodc1.Recordset.Fields("bz")
Else
txtydjl = ""
End If
txtxi = Adodc1.Recordset.Fields("xi")
txtbj = Adodc1.Recordset.Fields("bj")
txtxh.Locked = True
txtxm.Locked = True
cboxb.Locked = True
txtxi.Locked = True
txtbj.Locked = True
cmddelete.Enabled = True
txtydjl.Locked = True
sql = "select bj from 学生基本情况表 where xi='" & Combo1 + "'" + " group by bj"
Set rs = cnn.Execute(sql)
rs.MoveFirst
Combo2.Clear
Do While Not rs.EOF
Combo2.AddItem rs.Fields("bj")
rs.MoveNext
Loop
rs.Close
End Sub
Private Sub Combo2_Click()
Adodc1.RecordSource = "select * from 学生基本情况表 where bj='" & Combo2 + "'"
Adodc1.Refresh
txtxh = Adodc1.Recordset.Fields("xh")
txtxm = Adodc1.Recordset.Fields("xm")
cboxb.Text = Adodc1.Recordset.Fields("xb")
If Adodc1.Recordset.Fields("bz") <> "" Then
txtydjl = Adodc1.Recordset.Fields("bz")
Else
txtydjl = ""
End If
txtxi = Adodc1.Recordset.Fields("xi")
txtbj = Adodc1.Recordset.Fields("bj")
End Sub
Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
On Error Resume Next
txtxh = Adodc1.Recordset.Fields("xh")
txtxm = Adodc1.Recordset.Fields("xm")
cboxb.Text = Adodc1.Recordset.Fields("xb")
If Adodc1.Recordset.Fields("bz") <> "" Then
txtydjl = Adodc1.Recordset.Fields("bz")
Else
txtydjl = ""
End If
txtxi = Adodc1.Recordset.Fields("xi")
txtbj = Adodc1.Recordset.Fields("bj")
End Sub
Private Sub Form_Load()
'On Error Resume Next
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Dim cnn As ADODB.Connection
Set cnn = New ADODB.Connection
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=学生教材管理系统.mdb;Persist Security Info=False"
Dim sql As String
sql = "select distinct xi from 学生基本情况表 "
Set rs = cnn.Execute(sql)
rs.MoveFirst
Combo1.Clear
Do While rs.EOF = False
Combo1.AddItem rs.Fields("xi")
rs.MoveNext
Loop
rs.Close
sql = "select distinct bj from 学生基本情况表"
Set rs = cnn.Execute(sql)
Combo2.Clear
Do While Not rs.EOF
Combo2.AddItem rs.Fields("bj")
rs.MoveNext
Loop
rs.Close
txtxh = Adodc1.Recordset.Fields("xh")
txtxm = Adodc1.Recordset.Fields("xm")
cboxb.Text = Adodc1.Recordset.Fields("xb")
If Adodc1.Recordset.Fields("bz") <> "" Then
txtydjl = Adodc1.Recordset.Fields("bz")
Else
txtydjl = ""
End If
txtxi = Adodc1.Recordset.Fields("xi")
txtbj = Adodc1.Recordset.Fields("bj")
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -