📄 teacher_frm.frm
字号:
Left = 240
TabIndex = 2
Top = 2520
Width = 2895
Begin VB.TextBox Text3
Height = 270
Left = 1440
TabIndex = 14
Top = 1080
Width = 1095
End
Begin VB.TextBox Text2
Height = 270
Left = 1440
TabIndex = 13
Top = 720
Width = 1095
End
Begin VB.TextBox Text1
Height = 270
Left = 1440
TabIndex = 12
Top = 360
Width = 1095
End
Begin VB.OptionButton Option3
Caption = "按职称:"
Height = 225
Left = 240
TabIndex = 6
Top = 1080
Width = 1215
End
Begin VB.OptionButton Option2
Caption = "按姓名:"
Height = 255
Left = 240
TabIndex = 5
Top = 720
Width = 1215
End
Begin VB.OptionButton Option1
Caption = "按编号:"
Height = 255
Left = 240
TabIndex = 4
Top = 360
Value = -1 'True
Width = 1215
End
End
Begin MSDataGridLib.DataGrid DataGrid1
Bindings = "teacher_frm.frx":0000
Height = 1815
Left = 240
TabIndex = 0
Top = 600
Width = 7095
_ExtentX = 12515
_ExtentY = 3201
_Version = 393216
HeadLines = 1
RowHeight = 15
BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ColumnCount = 2
BeginProperty Column00
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column01
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
SplitCount = 1
BeginProperty Split0
BeginProperty Column00
EndProperty
BeginProperty Column01
EndProperty
EndProperty
End
Begin VB.Label Label7
Alignment = 2 'Center
Caption = "删除时请点击所需删除的记录"
ForeColor = &H000000FF&
Height = 495
Left = 360
TabIndex = 28
Top = 5400
Width = 2655
End
Begin VB.Label Label1
Alignment = 2 'Center
Caption = "教师资料添加/查询/修改/删除"
BeginProperty Font
Name = "宋体"
Size = 15
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 1080
TabIndex = 1
Top = 120
Width = 5295
End
End
Attribute VB_Name = "teacher_frm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim con As ADODB.Connection
Dim qn As String
Dim txt As String
Dim No As String
'Dim WithEvents rs As ADODB.Recordset
Private Sub Command1_Click()
Dim query1 As String
If Option1.Value = True Then
qn = "tno"
query1 = "SELECT * FROM teacherinfo WHERE " & qn & " = '" & Text1 & "'"
End If
If Option2.Value = True Then
qn = "tname"
query1 = "SELECT * FROM teacherinfo WHERE " & qn & " = '" & Text2 & "'"
End If
If Option3.Value = True Then
qn = "title"
query1 = "SELECT * FROM teacherinfo WHERE " & qn & " = '" & Text3 & "'"
End If
Dim rs As New ADODB.Recordset
rs.Open query1, con, adOpenForwardOnly, adLockReadOnly
Set DataGrid1.DataSource = Nothing
If Not (rs.EOF And rs.BOF) Then
rs.MoveFirst
rs.MoveLast
End If
If rs.RecordCount > 0 Then
Set DataGrid1.DataSource = rs
MsgBox "总共查到" & rs.RecordCount & "记录", vbInformation
Else
MsgBox "没有找到记录,请重新输入查询数据", vbInformation
End If
End Sub
Private Sub Command2_Click()
Text4 = ""
Text5 = ""
Text6 = ""
Text7 = ""
Text8 = ""
End Sub
Private Sub Command3_Click()
If Option1.Value = True Then
qn = "cno"
txt = Text1.Text
End If
If Option2.Value = True Then
qn = "tname"
txt = Text2.Text
End If
If Option3.Value = True Then
qn = "title"
txt = Text3.Text
End If
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select * from teacherinfo where " & qn & " = '" & txt & "' "
' Adodc1.Refresh
No = Adodc1.Recordset.Fields(0)
' Dim rsvalid As ADODB.Recordset
' Dim strSQL$
'
Dim myrs As New ADODB.Recordset
Dim query1 As String
query1 = "SELECT * FROM choice WHERE teacherno = '" & Trim(No) & " '"
myrs.Open query1, con, adOpenForwardOnly, adLockReadOnly
' Set DataGrid1.DataSource = Nothing
If Not (myrs.EOF And myrs.BOF) Then
myrs.MoveFirst
myrs.MoveLast
End If
' choice.CommandType = adCmdText
' choice.RecordSource = "select * from choice where teacherno = " & No & " "
' choice.Refresh
'
' course_teacher.CommandType = adCmdText
' course_teacher.RecordSource = " select * form course_teacher where tno = " & No & " "
' course_teacher.Refresh
' If choice.Recordset.RecordCount > 0 Then
If myrs.RecordCount > 0 Then
MsgBox "不能删除、与其他表有相关数据联系!", vbInformation + vbOKOnly, "删除提示"
'' ElseIf course_teacher.Recordset.RecordCount > 0 Then
'' MsgBox "不能删除、与其他表有相关数据联系!", vbInformation + vbOKOnly, "删除提示"
Else
MsgBox "能删除、与其他表没有相关数据联系!", vbInformation + vbOKOnly, "删除提示"
Adodc1.Recordset.Delete
End If
End Sub
Private Sub Command4_Click()
Unload Me
End Sub
Private Sub Command5_Click()
'保存记录
Dim myrs As New ADODB.Recordset
myrs.Open "SELECT * FROM teacherinfo", con, adOpenDynamic, adLockOptimistic, adCmdText
myrs.AddNew
If Text4.Text = Empty Then
MsgBox "教师编号不能为空!"
Text4.SetFocus
Exit Sub
End If
If Text5.Text = Empty Then
MsgBox "姓名不能为空!"
Text5.SetFocus
Exit Sub
End If
myrs.Fields(0) = Text4.Text
myrs.Fields(1) = Text5.Text
myrs.Fields(2) = Text6.Text
myrs.Fields(3) = Text7.Text
myrs.Fields(4) = Text8.Text
myrs.Update
Set DataGrid1.DataSource = myrs
Text4.Text = Empty
Text5.Text = Empty
Text6.Text = Empty
Text7.Text = Empty
Text6.Text = Empty
MsgBox "添加成功!"
End Sub
Private Sub Form_Load()
Set con = New ADODB.Connection
con.ConnectionString = Adodc1.ConnectionString
con.CursorLocation = adUseClient
con.Open
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -