📄 frmclassroom.frm
字号:
EndProperty
Height = 735
Left = 360
TabIndex = 15
Top = 360
Width = 1575
End
Begin VB.CommandButton Cmdexit
Caption = "退出"
BeginProperty Font
Name = "隶书"
Size = 21.75
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 8640
TabIndex = 14
Top = 360
Width = 1575
End
Begin VB.CommandButton Cmdfind
Caption = "查找"
BeginProperty Font
Name = "隶书"
Size = 21.75
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 4500
TabIndex = 13
Top = 360
Width = 1575
End
End
End
Attribute VB_Name = "Frmclassroom"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim dbclassroom As dao.Database
Dim rstclassroom As dao.Recordset
Dim temp As dao.Recordset
Option Explicit
Private Sub Cmdadd_Click()
Set temp = dbclassroom.OpenRecordset("select * from classroom")
temp.Filter = "classroomid='" & txtid.Text & "'"
Set temp = temp.OpenRecordset()
If temp.RecordCount() <> 0 Then
MsgBox "这个教室编号已存在,您输入的记录不被保存!"
Exit Sub
End If
If rstclassroom.RecordCount() <> 0 Then
rstclassroom.MoveLast
End If
rstclassroom.AddNew
fillrecord
rstclassroom.Update
cleartext
txtid.SetFocus
End Sub
Private Sub Cmddelete_Click()
rstclassroom.Delete
If rstclassroom.RecordCount() = 0 Then
MsgBox "系统中已经没有记录了!"
cleartext
Else
rstclassroom.MoveNext
If rstclassroom.EOF Then
rstclassroom.MoveLast
filltext
End If
End If
End Sub
Private Sub Cmdedit_Click()
Set temp = dbclassroom.OpenRecordset("select * from classroom")
temp.Filter = "classroomid='" & txtid.Text & "'"
Set temp = temp.OpenRecordset()
If temp.RecordCount() = 0 Then
MsgBox "这个教室编号已不存在,您的修改无效!"
Exit Sub
End If
temp.Close
rstclassroom.EditMode
fillrecord
rstclassroom.Update
txtid.SetFocus
End Sub
Private Sub Cmdexit_Click()
dbclassroom.Close
Frmclassroom.Hide
frmmain.Show vbModal
End Sub
Private Sub Cmdfind_Click()
Dim findstr As String
Dim myid As String
findstr = InputBox("请输入要查找的教室编号:", "查找提示窗口")
rstclassroom.FindFirst "classroomid='" & findstr & "'"
If rstclassroom.NoMatch Then
MsgBox "本系统中没有您要查找的记录!"
Exit Sub
Else
filltext
End If
End Sub
Private Sub cmdfirst_Click()
rstclassroom.MoveFirst
filltext
End Sub
Private Sub Cmdlast_Click()
rstclassroom.MoveLast
filltext
End Sub
Private Sub Cmdnext_Click()
rstclassroom.MoveNext
If rstclassroom.EOF Then
MsgBox "这是最后一条记录了!"
rstclassroom.MoveLast
End If
filltext
End Sub
Private Sub Cmdprevious_Click()
rstclassroom.MovePrevious
If rstclassroom.BOF Then
MsgBox "这是第一条记录!"
rstclassroom.MoveFirst
End If
filltext
End Sub
Private Sub Form_Activate()
Set dbclassroom = DBEngine.Workspaces(0).OpenDatabase("d:\课表编排系统\basic.mdb")
Set rstclassroom = dbclassroom.OpenRecordset("select * from classroom")
If rstclassroom.RecordCount() = 0 Then
hidebutton
cleartext
Else
showbutton
rstclassroom.MoveFirst
filltext
End If
txtid.SetFocus
End Sub
Private Sub Form_Load()
Set dbclassroom = DBEngine.Workspaces(0).OpenDatabase("d:\课表编排系统\basic.mdb")
Set rstclassroom = dbclassroom.OpenRecordset("select * from classroom")
If rstclassroom.RecordCount() = 0 Then
hidebutton
cleartext
Else
showbutton
rstclassroom.MoveFirst
filltext
End If
Cmbfunction.AddItem "大教室"
Cmbfunction.AddItem "中教室"
Cmbfunction.AddItem "小教室"
Cmbfunction.AddItem "体育场"
Cmbfunction.AddItem "电子教室"
Cmbfunction.AddItem "实验室"
Combo1.AddItem "1"
Combo1.AddItem "2"
Combo1.AddItem "3"
Combo1.AddItem "4"
Combo1.AddItem "5"
Combo1.AddItem "6"
List1.AddItem "1--大教室"
List1.AddItem "2--中教室"
List1.AddItem "3--小教室"
List1.AddItem "4--体育场"
List1.AddItem "5--实验室"
List1.AddItem "6--电子教室"
End Sub
Public Sub filltext()
txtid.Text = rstclassroom.Fields("classroomid")
Txtname.Text = rstclassroom.Fields("classroomname")
Combo1.Text = rstclassroom.Fields("type")
If rstclassroom.Fields("function") = "" Then
Cmbfunction.Text = ""
Else
Cmbfunction.Text = rstclassroom.Fields("function")
End If
End Sub
Public Sub cleartext()
txtid.Text = ""
Txtname.Text = ""
Combo1.Text = ""
Cmbfunction.Text = ""
End Sub
Public Sub hidebutton()
cmdfirst.Enabled = False
Cmdnext.Enabled = False
Cmdlast.Enabled = False
Cmdprevious.Enabled = False
Cmddelete.Enabled = False
cmdfind.Enabled = False
Cmdedit.Enabled = False
End Sub
Public Sub showbutton()
cmdfirst.Enabled = True
Cmdnext.Enabled = True
Cmdlast.Enabled = True
Cmdlast.Enabled = True
Cmddelete.Enabled = True
cmdfind.Enabled = True
Cmdedit.Enabled = True
Cmdprevious.Enabled = True
End Sub
Public Sub fillrecord()
rstclassroom.Fields("classroomid") = txtid.Text
rstclassroom.Fields("classroomname") = Txtname.Text
If Cmbfunction.Text = "" Then
rstclassroom.Fields("function") = ""
Else
rstclassroom.Fields("function") = Cmbfunction.Text
End If
rstclassroom.Fields("type") = Combo1.Text
End Sub
Private Sub txtid_Click()
txtid.Text = ""
End Sub
Private Sub txtid_GotFocus()
If rstclassroom.RecordCount() = 0 Then
hidebutton
Else
showbutton
End If
End Sub
Private Sub Txtname_Click()
Txtname.Text = ""
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -