📄 formclass.frm
字号:
Index = 3
Left = 240
TabIndex = 7
Top = 2160
Width = 975
End
Begin VB.Label Label3
Caption = "导员姓名"
Height = 255
Index = 2
Left = 240
TabIndex = 6
Top = 1560
Width = 975
End
Begin VB.Label Label3
Caption = "专业"
Height = 255
Index = 1
Left = 240
TabIndex = 5
Top = 960
Width = 975
End
Begin VB.Label Label3
Caption = "班级编号"
Height = 255
Index = 0
Left = 240
TabIndex = 4
Top = 360
Width = 975
End
End
Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1
Height = 4815
Left = 240
TabIndex = 1
Top = 840
Width = 4815
_ExtentX = 8493
_ExtentY = 8493
_Version = 393216
Cols = 4
BackColorBkg = 16777215
Appearance = 0
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
BorderStyle = 1 'Fixed Single
Caption = " 班 级 信 息"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 240
TabIndex = 13
Top = 480
Width = 9255
End
End
Attribute VB_Name = "Formbanjia"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Mrc As ADODB.Recordset
Dim Msgtext As String
Dim tSQL As String
Private Sub Command1_Click()
If Text1(0) = "" Then
MsgBox "班级编号不能为空!", vbOKOnly, "提示"
Text1(0).SetFocus
Exit Sub
End If
If Text1(1) = "" Then
MsgBox "专业不能为空!", vbOKOnly, "提示"
Text1(1).SetFocus
Exit Sub
End If
If Text1(2) = "" Then
MsgBox "导员姓名不能为空!", vbOKOnly, "提示"
Text1(2).SetFocus
Exit Sub
End If
txtSQL = "select * from 班级 where 班号='" & Trim(Text1(0)) & "'"
Set Mrc = ExecuteSQL(txtSQL, Msgtext)
If Mrc.EOF = False Then
MsgBox "此班级编号已存在!", vbOKOnly, "警告"
Text1(0).SetFocus
Exit Sub
End If
Mrc.Close
txtSQL = "select * from 班级"
Set Mrc = ExecuteSQL(txtSQL, Msgtext)
Mrc.AddNew
Mrc.Fields(0) = Trim(Text1(0))
Mrc.Fields(1) = Trim(Text1(1))
Mrc.Fields(2) = Trim(Text1(2))
Mrc.Fields(3) = Trim(Text1(3))
Mrc.Update
Mrc.Close
For i = 0 To 3
Text1(i) = ""
Next
MsgBox "班级信息添加成功!", vbOKOnly, "提示"
ShowData
End Sub
Private Sub Command2_Click()
For i = 0 To 3
Text1(i) = ""
Next
End Sub
Private Sub Command3_Click()
If Text1(5) = "" Then
MsgBox "专业不能为空!", vbOKOnly, "提示"
Text1(5).SetFocus
Exit Sub
End If
If Text1(6) = "" Then
MsgBox "导员姓名不能为空!", vbOKOnly, "提示"
Text1(6).SetFocus
Exit Sub
End If
txtSQL = "delete from 班级 where 班号='" & Trim(Text1(4)) & "'"
Set Mrc = ExecuteSQL(txtSQL, Msgtext)
txtSQL = "select * from 班级"
Set Mrc = ExecuteSQL(txtSQL, Msgtext)
Mrc.AddNew
Mrc.Fields(0) = Trim(Text1(4))
Mrc.Fields(1) = Trim(Text1(5))
Mrc.Fields(2) = Trim(Text1(6))
Mrc.Fields(3) = Trim(Text1(7))
Mrc.Update
Mrc.Close
For i = 4 To 7
Text1(i) = ""
Next
MsgBox "班级信息修改成功!", vbOKOnly, "提示"
ShowData
End Sub
Private Sub Command4_Click()
For i = 4 To 7
Text1(i) = ""
Next
End Sub
Private Sub Command5_Click()
txtSQL = "delete from 班级 where 班号='" & Trim(Text1(8)) & "'"
Set Mrc = ExecuteSQL(txtSQL, Msgtext)
For i = 8 To 11
Text1(i) = ""
Next
MsgBox "班级信息已经删除!", vbOKOnly, "警告"
ShowData
End Sub
Private Sub Command6_Click()
For i = 8 To 11
Text1(i) = ""
Next
End Sub
Private Sub Form_Load()
Picture1(1).Top = Picture1(0).Top
Picture1(1).Left = Picture1(0).Left
Picture1(2).Top = Picture1(0).Top
Picture1(2).Left = Picture1(0).Left
ShowData
End Sub
Private Sub Form_Resize()
dColor.ZOrder 1
End Sub
Private Sub ShowData()
Dim txSQL As String
Dim Mrcc As ADODB.Recordset
txSQL = "select * from 班级"
Set Mrcc = ExecuteSQL(txSQL, Msgtext)
With MSFlexGrid1
.ColWidth(0) = 1200
.ColWidth(1) = 1200
.ColWidth(2) = 1200
.ColWidth(3) = 6000
.TextMatrix(0, 0) = "班级编号"
.TextMatrix(0, 1) = "专业"
.TextMatrix(0, 2) = "导员姓名"
.TextMatrix(0, 3) = "备注"
.Rows = 1
Do While Not Mrcc.EOF
.Rows = .Rows + 1
For i = 0 To Mrcc.Fields.Count - 1
.TextMatrix(.Rows - 1, i) = Mrcc.Fields(i) & ""
Next i
Mrcc.MoveNext
Loop
End With
Mrcc.Close
End Sub
Private Sub MSFlexGrid1_Click()
If Picture1(1).Visible = True Then
Text1(4) = Trim(MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 0))
Text1(5) = Trim(MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 1))
Text1(6) = Trim(MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 2))
Text1(7) = Trim(MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 3))
Command3.Enabled = True
End If
If Picture1(2).Visible = True Then
Text1(8) = Trim(MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 0))
Text1(9) = Trim(MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 1))
Text1(10) = Trim(MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 2))
Text1(11) = Trim(MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 3))
Command5.Enabled = True
End If
End Sub
Private Sub Text1_Change(Index As Integer)
If Index = 4 Then
tSQL = "select * from 班级 where 班号='" & Trim(Text1(Index)) & "'"
Set Mrc = ExecuteSQL(tSQL, Msgtext)
If Mrc.EOF = False Then
Text1(5) = Mrc.Fields(1)
Text1(6) = Mrc.Fields(2)
Text1(7) = Mrc.Fields(3)
Command3.Enabled = True
Exit Sub
Else
Text1(5) = ""
Text1(6) = ""
Text1(7) = ""
Command3.Enabled = False
End If
Mrc.Close
End If
If Index = 8 Then
tSQL = "select * from 班级 where 班号='" & Trim(Text1(Index)) & "'"
Set Mrc = ExecuteSQL(tSQL, Msgtext)
If Mrc.EOF = False Then
Text1(9) = Mrc.Fields(1)
Text1(10) = Mrc.Fields(2)
Text1(11) = Mrc.Fields(3)
Command5.Enabled = True
Exit Sub
Else
Text1(9) = ""
Text1(10) = ""
Text1(11) = ""
Command5.Enabled = False
End If
Mrc.Close
End If
End Sub
Private Sub Text1_GotFocus(Index As Integer)
Text1(Index).SelStart = 0
Text1(Index).SelLength = Len(Text1(Index))
End Sub
Private Sub Text1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
EnterToTab KeyCode
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -