📄 modmajor.frm
字号:
VERSION 5.00
Begin VB.Form modMajor
BorderStyle = 1 'Fixed Single
Caption = "修改班级信息"
ClientHeight = 4590
ClientLeft = 45
ClientTop = 330
ClientWidth = 5415
ControlBox = 0 'False
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 4590
ScaleWidth = 5415
Begin VB.CommandButton Command5
Caption = "返回(&B)"
Height = 495
Left = 3240
TabIndex = 12
Top = 3960
Width = 1575
End
Begin VB.CommandButton Command4
Caption = "更新数据(&U)"
Height = 495
Left = 3240
TabIndex = 11
Top = 3120
Width = 1575
End
Begin VB.CommandButton Command3
Caption = "删除数据(&D)"
Height = 495
Left = 600
TabIndex = 10
Top = 3120
Width = 1455
End
Begin VB.CommandButton Command2
Caption = "下一条记录(&N)"
Height = 495
Left = 3240
TabIndex = 9
Top = 1920
Width = 1575
End
Begin VB.CommandButton Command1
Caption = "上一条记录(&P)"
Height = 495
Left = 600
TabIndex = 8
Top = 1920
Width = 1455
End
Begin VB.Frame Frame3
Caption = "修改记录"
Height = 1095
Left = 120
TabIndex = 7
Top = 2760
Width = 5175
End
Begin VB.Frame Frame2
Caption = "浏览记录"
Height = 1095
Left = 120
TabIndex = 6
Top = 1560
Width = 5175
End
Begin VB.Frame Frame1
Height = 975
Left = 120
TabIndex = 1
Top = 480
Width = 5175
Begin VB.TextBox Text2
Height = 375
Left = 2880
TabIndex = 5
Top = 360
Width = 1935
End
Begin VB.TextBox Text1
Enabled = 0 'False
Height = 375
Left = 1320
TabIndex = 3
Top = 360
Width = 375
End
Begin VB.Label Label3
Caption = "班级名称:"
Height = 375
Left = 1800
TabIndex = 4
Top = 425
Width = 975
End
Begin VB.Label Label2
Caption = "班级编号:"
Height = 375
Left = 360
TabIndex = 2
Top = 425
Width = 975
End
End
Begin VB.Label Label1
Caption = "Label1"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 240
TabIndex = 0
Top = 120
Width = 2535
End
End
Attribute VB_Name = "modMajor"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim MRC As ADODB.Recordset
Dim myBookmark As Variant
Dim mcclean As Boolean
Public DeptID, MajorID As Integer
Public Sub viewData()
Text1.Text = MRC.Fields(0)
Text2.Text = MRC.Fields(1)
MajorID = Text1.Text
End Sub
Public Sub cmd_Enabled()
Command1.Enabled = False
Command2.Enabled = False
Command3.Enabled = False
Command4.Enabled = False
End Sub
Private Sub Command3_Click()
Dim UptSQL As String
Dim UptMsg As String
Dim UPT As ADODB.Recordset
Dim DelSQL As String
Dim DelMsg As String
Dim DEL As ADODB.Recordset
Dim txtSQL As String
Dim MsgText As String
Dim mrcA As ADODB.Recordset
str2$ = MsgBox("是否删除当前记录?", vbOKCancel, "删除当前记录")
If str2$ = vbOK Then
DelSQL = "DELETE FROM Major WHERE MajorID=" & MajorID & ""
Set DEL = ExecuteSQL(DelSQL, DelMsg)
UptSQL = "UPDATE Major SET MajorID=MajorID-1 WHERE MajorID>" & MajorID & ""
Set UPT = ExecuteSQL(UptSQL, UptMsg)
txtSQL = "SELECT * FROM MAJOR WHERE DeptID=" & DeptID & ""
Set mrcA = ExecuteSQL(txtSQL, MsgText)
If (mrcA.EOF) Then
MsgBox "表中已经没有数据!", vbOKOnly + vbExclamation, "警告"
Text1.Text = ""
Text2.Text = ""
Call Me.cmd_Enabled
Exit Sub
Else
MRC.MovePrevious
If MRC.BOF Then
MRC.MoveLast
End If
End If
Call viewData
Else
Call viewData
End If
End Sub
Private Sub Command4_Click()
Dim UptSQL As String
Dim UptMsg As String
Dim UPT As ADODB.Recordset
Dim txtSQL As String
Dim MsgText As String
Dim mrcA As ADODB.Recordset
txtSQL = "SELECT * FROM Major WHERE MajorName='" & Text2.Text & "'"
Set mrcA = ExecuteSQL(txtSQL, MsgText)
If Not (mrcA.EOF) Then
MsgBox "班级名为[" & Text2.Text & "的记录已经存在]", vbOKOnly + vbExclamation, "学籍管理系统"
Else
UptSQL = "UPDATE Major SET MajorName='" & Text2.Text & "' WHERE MajorID=" & Text1.Text & ""
Set UPT = ExecuteSQL(UptSQL, UptMsg)
If (UptMsg = "UPDATE query successful") Then
MsgBox "修改数据成功!", vbInformation + vbOKOnly, "学籍管理系统"
End If
End If
End Sub
Private Sub Command5_Click()
Unload Me
Unload getDept
End Sub
Private Sub Form_Load()
Dim txtSQL As String
Dim MsgText As String
Dim mrcA As ADODB.Recordset
Me.Move (frmMain.ScaleWidth - Me.Width) / 2, (frmMain.ScaleHeight - Me.Height) / 2
Label1.Caption = getDept.Combo1.Text
txtSQL = "SELECT DeptID FROM DEPARTMENT WHERE DeptName='" & Label1.Caption & "'"
Set mrcA = ExecuteSQL(txtSQL, MsgText)
DeptID = mrcA.Fields(0).Value
txtSQL = "SELECT * FROM MAJOR WHERE DeptID=" & DeptID & ""
Set MRC = ExecuteSQL(txtSQL, MsgText)
If Not MRC.EOF Then
MRC.MoveFirst
Call viewData
mcbookmark = MRC.Bookmark
mcclean = True
Else
MsgBox "表中没有数据!", vbOKOnly + vbExclamation, "成绩管理系统"
Call Me.cmd_Enabled
End If
End Sub
Private Sub Command1_Click()
MRC.MovePrevious
If MRC.BOF Then
MsgBox "该记录为第一条记录!", vbOKOnly + vbExclamation, "成绩管理系统"
MRC.MoveLast
End If
Call viewData
End Sub
Private Sub Command2_Click()
MRC.MoveNext
If MRC.EOF Then
MsgBox "该记录为最后一条记录!", vbOKOnly + vbExclamation, "成绩管理系统"
MRC.MoveFirst
End If
Call viewData
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -