📄 classform.frm
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form classForm
BorderStyle = 1 'Fixed Single
Caption = "班级信息管理窗口"
ClientHeight = 6270
ClientLeft = 45
ClientTop = 405
ClientWidth = 8115
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 6270
ScaleWidth = 8115
Begin VB.Frame Frame2
Caption = "班级信息编辑"
Height = 6015
Left = 240
TabIndex = 1
Top = 120
Width = 2655
Begin VB.CommandButton delBnt
Caption = "删除"
Height = 375
Left = 120
TabIndex = 13
Top = 5520
Width = 2415
End
Begin VB.CommandButton editBnt
Caption = "修改"
Height = 375
Left = 120
TabIndex = 12
Top = 5040
Width = 2415
End
Begin VB.CommandButton addBnt
Caption = "添加"
Height = 375
Left = 120
TabIndex = 11
Top = 4560
Width = 2415
End
Begin VB.Frame Frame3
Caption = "备注"
Height = 2175
Left = 120
TabIndex = 9
Top = 2280
Width = 2415
Begin VB.TextBox txtNote
Height = 1815
Left = 120
MultiLine = -1 'True
TabIndex = 10
Top = 240
Width = 2175
End
End
Begin VB.TextBox txtTeacher
Height = 270
Left = 840
TabIndex = 8
Top = 1680
Width = 1695
End
Begin VB.TextBox txtName
Height = 270
Left = 840
TabIndex = 6
Top = 1080
Width = 1695
End
Begin VB.TextBox txtNo
Enabled = 0 'False
Height = 270
Left = 840
TabIndex = 4
Top = 480
Width = 1695
End
Begin VB.Label Label3
Caption = "班主任:"
Height = 255
Left = 120
TabIndex = 7
Top = 1680
Width = 735
End
Begin VB.Label Label2
Caption = "名称:"
Height = 255
Left = 120
TabIndex = 5
Top = 1080
Width = 735
End
Begin VB.Label Label1
Caption = "序号:"
Height = 255
Left = 120
TabIndex = 3
Top = 480
Width = 1095
End
End
Begin VB.Frame Frame1
Caption = "班级列表"
Height = 6015
Left = 3000
TabIndex = 0
Top = 120
Width = 4935
Begin MSFlexGridLib.MSFlexGrid MSF
Height = 5655
Left = 120
TabIndex = 2
Top = 240
Width = 4695
_ExtentX = 8281
_ExtentY = 9975
_Version = 393216
SelectionMode = 1
End
End
End
Attribute VB_Name = "classForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public Sub classshowtitle()
Dim i As Integer
MSF.Clear
With MSF
.Cols = 5
.TextMatrix(0, 1) = "序号"
.TextMatrix(0, 2) = "班级名称"
.TextMatrix(0, 3) = "班主任"
.TextMatrix(0, 4) = "备注"
.ColWidth(0) = 100
.ColWidth(1) = 1300
.ColWidth(2) = 1200
.ColWidth(3) = 1200
.ColWidth(4) = 1500
.FixedRows = 1
For i = 1 To 4
.ColAlignment(i) = 0
Next i
.FillStyle = flexFillSingle
.Col = 0
.Row = 0
.RowSel = 1
.ColSel = .Cols - 1
.CellAlignment = 4
.Row = 1
End With
End Sub
Public Sub classshowdata()
Dim j As Integer
Dim i As Integer
Dim mrc1 As ADODB.Recordset
strSql = "select * from class_info"
Set mrc1 = ExecuteSQL(Trim(strSql))
If mrc1.EOF = False Then
mrc1.MoveFirst
With MSF
.Rows = 1
Do While Not mrc1.EOF
.Rows = .Rows + 1
For i = 1 To mrc1.Fields.Count
.TextMatrix(.Rows - 1, i) = mrc1.Fields(i - 1)
Next i
mrc1.MoveNext
Loop
mrc1.Close
End With
End If
End Sub
Private Sub addBnt_Click()
If classForm.txtName = "" Then
MsgBox "班级名不能为空!", vbExclamation + vbOKOnly, "警告"
Exit Sub
Else
strSql = "select * from class_info where class_info_name = '" & Trim(classForm.txtName) & "'"
Set rs = ExecuteSQL(Trim(strSql))
If rs.EOF = False Then
MsgBox "已有一个相同的班级名存在!", vbExclamation + vbOKOnly, "警告"
rs.Close
Exit Sub
End If
End If
strSql = "insert into class_info (class_info_name,class_info_teacher,class_info_note) values('" & Trim(classForm.txtName) & "','" & Trim(classForm.txtTeacher) & "','" & Trim(classForm.txtNote) & "')"
If ExecuteUpdateSQL(strSql) = True Then
MsgBox "添加班级信息成功!", vbExclamation + vbOKOnly, "警告"
classForm.classshowdata
Else
MsgBox "添加班级信息失败!", vbExclamation + vbOKOnly, "警告"
classForm.txtNote.Text = strSql
End If
End Sub
Private Sub delBnt_Click()
If classForm.txtNo = "" Then
MsgBox "序号为空!", vbExclamation + vbOKOnly, "警告"
Exit Sub
Else
strSql = "select * from class_info where class_info_id = " & classForm.txtNo
Set rs = ExecuteSQL(Trim(strSql))
If rs.EOF = True Then
MsgBox "序号有误!", vbExclamation + vbOKOnly, "警告"
rs.Close
Exit Sub
End If
End If
strSql = "delete from class_info where class_info_id = " & classForm.txtNo
If ExecuteUpdateSQL(strSql) = True Then
MsgBox "修改班级信息成功!", vbExclamation + vbOKOnly, "警告"
classForm.classshowdata
Else
MsgBox "修改班级信息失败!", vbExclamation + vbOKOnly, "警告"
classForm.txtNote.Text = strSql
End If
End Sub
Private Sub editBnt_Click()
If classForm.txtNo = "" Then
MsgBox "序号为空!", vbExclamation + vbOKOnly, "警告"
Exit Sub
Else
strSql = "select * from class_info where class_info_id = " & classForm.txtNo
Set rs = ExecuteSQL(Trim(strSql))
If rs.EOF = True Then
MsgBox "序号有误!", vbExclamation + vbOKOnly, "警告"
rs.Close
Exit Sub
End If
End If
strSql = "update class_info set class_info_name = '" & Trim(classForm.txtName) & "',class_info_teacher = '" & Trim(classForm.txtTeacher) & "',class_info_note = '" & classForm.txtNote & "' where class_info_id = " & classForm.txtNo
If ExecuteUpdateSQL(strSql) = True Then
MsgBox "修改班级信息成功!", vbExclamation + vbOKOnly, "警告"
classForm.classshowdata
Else
MsgBox "修改班级信息失败!", vbExclamation + vbOKOnly, "警告"
classForm.txtNote.Text = strSql
End If
End Sub
Private Sub MSF_Click()
classForm.txtName = MSF.TextMatrix(MSF.RowSel, 2)
classForm.txtNo = MSF.TextMatrix(MSF.RowSel, 1)
classForm.txtTeacher = MSF.TextMatrix(MSF.RowSel, 3)
classForm.txtNote = MSF.TextMatrix(MSF.RowSel, 4)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -