📄 frmmodifyclassinfo.frm
字号:
Top = 660
Width = 450
End
Begin VB.Label Label3
Alignment = 2 'Center
AutoSize = -1 'True
Caption = "班主任"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 210
Left = 1335
TabIndex = 5
Top = 1395
Width = 705
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "教室"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 210
Left = 3960
TabIndex = 4
Top = 1395
Width = 450
End
End
Attribute VB_Name = "frmModifyclassinfo"
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
Private Sub cancelCommand_Click()
If Not mcclean Then
txtClassno.Enabled = False
comboGrade.Enabled = False
txtDirector.Enabled = False
txtClassroom.Enabled = False
Frame2.Enabled = True
firstCommand.Enabled = True
previousCommand.Enabled = True
nextCommand.Enabled = True
lastCommand.Enabled = True
editCommand.Enabled = True
updateCommand.Enabled = False
cancelCommand.Enabled = False
deleteCommand.Enabled = True
mrc.Bookmark = myBookmark
Call viewData
Else
MsgBox "什么都没有修改,有什么好取消的!", vbOKOnly + vbExclamation, "警告"
End If
End Sub
Private Sub deleteCommand_Click()
' Call Form_Load
If mrc.RecordCount <> 1 Then
myBookmark = mrc.Bookmark
str2$ = MsgBox("是否删除当前记录?", vbOKCancel, "删除当前记录")
If str2$ = vbOK Then
mrc.MoveNext
If mrc.EOF Then
mrc.MoveFirst
myBookmark = mrc.Bookmark
mrc.MoveLast
mrc.Delete
mrc.Bookmark = myBookmark
Call viewData
Else
myBookmark = mrc.Bookmark
mrc.MovePrevious
mrc.Delete
mrc.Bookmark = myBookmark
Call viewData
End If
End If
Frame2.Enabled = True
firstCommand.Enabled = True
previousCommand.Enabled = True
nextCommand.Enabled = True
lastCommand.Enabled = True
editCommand.Enabled = True
updateCommand.Enabled = False
cancelCommand.Enabled = False
deleteCommand.Enabled = True
Else
mrc.Delete
MsgBox "最后一条纪录已被删除!", vbOKOnly + vbExclamation, "警告"
Unload Me
End If
End Sub
Private Sub editCommand_Click()
mcclean = False
' txtClassno.Enabled = True
comboGrade.Enabled = True
txtDirector.Enabled = True
txtClassroom.Enabled = True
Frame2.Enabled = False
firstCommand.Enabled = False
previousCommand.Enabled = False
nextCommand.Enabled = False
lastCommand.Enabled = False
editCommand.Enabled = False
updateCommand.Enabled = True
cancelCommand.Enabled = True
deleteCommand.Enabled = False
myBookmark = mrc.Bookmark
End Sub
Private Sub firstCommand_Click()
mrc.MoveFirst
Call viewData
End Sub
Private Sub Form_Load()
Dim txtSQL As String
Dim MsgText As String
txtClassno.Enabled = False
comboGrade.Enabled = False
txtDirector.Enabled = False
txtClassroom.Enabled = False
Frame2.Enabled = True
firstCommand.Enabled = True
previousCommand.Enabled = True
nextCommand.Enabled = True
lastCommand.Enabled = True
editCommand.Enabled = True
updateCommand.Enabled = False
cancelCommand.Enabled = False
deleteCommand.Enabled = True
txtSQL = "select * from class_Info "
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF = False Then
mrc.MoveFirst
Call viewData
myBookmark = mrc.Bookmark
mcclean = True
End If
comboGrade.AddItem "大学一年级"
comboGrade.AddItem "大学二年级"
comboGrade.AddItem "大学三年级"
End Sub
Public Sub viewData()
txtClassno.Text = mrc.Fields(0)
comboGrade.Text = mrc.Fields(1)
txtDirector.Text = mrc.Fields(2)
txtClassroom.Text = mrc.Fields(3)
End Sub
Private Sub lastCommand_Click()
mrc.MoveLast
Call viewData
End Sub
Private Sub nextCommand_Click()
mrc.MoveNext
If mrc.EOF Then
mrc.MoveFirst
End If
Call viewData
End Sub
Private Sub previousCommand_Click()
mrc.MovePrevious
If mrc.BOF Then
mrc.MoveLast
End If
Call viewData
End Sub
Private Sub updateCommand_Click()
Dim txtSQL As String
Dim MsgText As String
If mcclean Then
MsgBox "请先修改班级信息", vbOKOnly + vbExclamation, "警告"
Exit Sub
End If
If Not Testtxt(txtClassno.Text) Then
MsgBox "请输入班号!", vbOKOnly + vbExclamation, "警告"
txtClassno.SetFocus
Exit Sub
End If
If Not IsNumeric(Trim(txtClassno.Text)) Then
MsgBox "请输入数字!", vbOKOnly + vbExclamation, "警告"
Exit Sub
txtClassno.SetFocus
End If
If Not Testtxt(comboGrade.Text) Then
MsgBox "请选择年级!", vbOKOnly + vbExclamation, "警告"
comboGrade.SetFocus
Exit Sub
End If
If Not Testtxt(txtDirector.Text) Then
MsgBox "请输入班主任姓名!", vbOKOnly + vbExclamation, "警告"
txtDirector.SetFocus
Exit Sub
End If
If Not Testtxt(txtClassroom.Text) Then
MsgBox "请输入教室号码!", vbOKOnly + vbExclamation, "警告"
txtClassroom.SetFocus
Exit Sub
End If
' mrc.Delete
' mrc.AddNew
mrc.Fields(0) = Trim(txtClassno.Text)
mrc.Fields(1) = Trim(comboGrade.Text)
mrc.Fields(2) = Trim(txtDirector.Text)
mrc.Fields(3) = Trim(txtClassroom.Text)
mrc.Update
MsgBox "修改班级信息成功!", vbOKOnly + vbExclamation, "警告"
' mrc.Bookmark = myBookmark
Call viewData
txtClassno.Enabled = False
comboGrade.Enabled = False
txtDirector.Enabled = False
txtClassroom.Enabled = False
Frame2.Enabled = True
firstCommand.Enabled = True
previousCommand.Enabled = True
nextCommand.Enabled = True
lastCommand.Enabled = True
editCommand.Enabled = True
updateCommand.Enabled = False
cancelCommand.Enabled = False
deleteCommand.Enabled = True
mcclean = True
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -