📄 教室窗体.frm
字号:
Name = "华文行楷"
Size = 36
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00C00000&
Height = 855
Left = 720
TabIndex = 2
Top = 1800
Width = 3855
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "教室编号:"
BeginProperty Font
Name = "华文行楷"
Size = 36
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00C00000&
Height = 855
Left = 720
TabIndex = 1
Top = 600
Width = 3855
End
End
Begin VB.Frame Frame2
BackColor = &H00FFC0C0&
Height = 1455
Left = 360
TabIndex = 7
Top = 9120
Width = 14295
Begin VB.CommandButton Command1
Caption = "添加"
BeginProperty Font
Name = "隶书"
Size = 36
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 360
TabIndex = 22
Top = 480
Width = 1935
End
Begin VB.CommandButton Cmddelete
BackColor = &H00FFC0C0&
Caption = "删除"
BeginProperty Font
Name = "隶书"
Size = 36
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 4992
TabIndex = 17
Top = 480
Width = 1935
End
Begin VB.CommandButton Cmdedit
BackColor = &H00FFC0C0&
Caption = "编辑"
BeginProperty Font
Name = "隶书"
Size = 36
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 9744
TabIndex = 16
Top = 480
Width = 1935
End
Begin VB.CommandButton Cmdadd
BackColor = &H00FFC0C0&
Caption = "保存"
BeginProperty Font
Name = "隶书"
Size = 36
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 2736
TabIndex = 15
Top = 480
Width = 1935
End
Begin VB.CommandButton Cmdexit
BackColor = &H00FFC0C0&
Caption = "退出"
BeginProperty Font
Name = "隶书"
Size = 36
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 12120
TabIndex = 14
Top = 480
Width = 1935
End
Begin VB.CommandButton Cmdfind
BackColor = &H00FFC0C0&
Caption = "查找"
BeginProperty Font
Name = "隶书"
Size = 36
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 7368
TabIndex = 13
Top = 480
Width = 1935
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
txtid.SetFocus
Adodc1.Refresh
End Sub
Private Sub Cmddelete_Click()
Set rstclassroom = dbclassroom.OpenRecordset("select * from classroom")
rstclassroom.Filter = "classroomid='" & txtid.Text & "'"
Set rstclassroom = rstclassroom.OpenRecordset()
rstclassroom.Delete
Set rstclassroom = dbclassroom.OpenRecordset("select * from classroom")
If rstclassroom.RecordCount() <> 0 Then
If rstclassroom.EOF = True Then
rstclassroom.MoveFirst
Else
rstclassroom.MoveNext
End If
filltext
Else
cleartext
txtid.SetFocus
hidebutton
MsgBox "系统中已经没有记录了!"
End If
Adodc1.Refresh
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.edit
fillrecord
rstclassroom.Update
txtid.SetFocus
End Sub
Private Sub Cmdexit_Click()
dbclassroom.Close
Unload Me
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 Command1_Click()
cleartext
txtid.SetFocus
End Sub
Private Sub DataGrid1_Click()
txtid.Text = DataGrid1.Text
txtname.Text = DataGrid1.Columns(1).Text
Cmbfunction.Text = DataGrid1.Columns(2).Text
Combo1.Text = DataGrid1.Columns(3).Text
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()
Adodc1.Refresh
End Sub
Private Sub txtid_GotFocus()
If rstclassroom.RecordCount() = 0 Then
hidebutton
Else
showbutton
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -