📄 addmajor.frm
字号:
VERSION 5.00
Begin VB.Form addMajor
BorderStyle = 1 'Fixed Single
Caption = "添加班级"
ClientHeight = 3120
ClientLeft = 45
ClientTop = 330
ClientWidth = 4560
ControlBox = 0 'False
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 3120
ScaleWidth = 4560
Begin VB.CommandButton Command2
Caption = "返回(&B)"
Height = 495
Left = 2760
TabIndex = 5
Top = 2400
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "保存(&O)"
Height = 495
Left = 480
TabIndex = 4
Top = 2400
Width = 1215
End
Begin VB.ComboBox Combo1
Height = 300
Left = 840
Style = 2 'Dropdown List
TabIndex = 3
Top = 1560
Width = 2895
End
Begin VB.Frame Frame2
Caption = "选择所在系"
Height = 975
Left = 240
TabIndex = 2
Top = 1200
Width = 4095
End
Begin VB.Frame Frame1
Caption = "班级名称"
Height = 975
Left = 240
TabIndex = 0
Top = 120
Width = 4095
Begin VB.TextBox Text1
Height = 375
Left = 600
TabIndex = 1
Top = 360
Width = 2895
End
End
End
Attribute VB_Name = "addMajor"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public DeptID As Integer
Private Sub Combo1_Click()
Dim txtSQL As String
Dim MsgText As String
Dim MRC As ADODB.Recordset
txtSQL = "SELECT * FROM Department WHERE DeptName='" & Combo1.Text & "'"
Set MRC = ExecuteSQL(txtSQL, MsgText)
DeptID = MRC.Fields(0).Value
End Sub
Private Sub Command1_Click()
Dim txtSQL As String
Dim MsgText As String
Dim MRC As ADODB.Recordset
Dim insSQL As String
Dim InsText As String
Dim INS As ADODB.Recordset
Dim MajorID As Integer
If Not (Testtxt(Text1) And Testtxt(Combo1)) Then
MsgBox "请填写班级名称以及所在系名称!", vbOKOnly + vbExclamation, "成绩管理系统"
Exit Sub
End If
txtSQL = "SELECT * FROM Major WHERE MajorName='" & Text1.Text & "'"
Set MRC = ExecuteSQL(txtSQL, MsgText)
If Not (MRC.EOF) Then
MsgBox "该班级已经写入数据库中!", vbOKOnly + vbExclamation, "成绩管理系统"
Text1.Text = ""
Text1.SetFocus
Exit Sub
End If
txtSQL = "SELECT COUNT(*) FROM Major WHERE DeptID=" & DeptID & ""
Set MRC = ExecuteSQL(txtSQL, MsgText)
If (MRC.Fields(0).Value = 0) Then
MajorID = 1
Else
MajorID = MRC.Fields(0).Value + 1
End If
insSQL = "INSERT INTO Major VALUES(" & MajorID & ",'" & Text1.Text & "'," & DeptID & " )"
Set INS = ExecuteSQL(insSQL, InsText)
Call Module1.JUDGE(InsText, addMajor)
Text1.Text = ""
Combo1.Clear
txtSQL = "SELECT DeptName FROM Department"
Call Module1.DataList(txtSQL, Combo1)
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Dim txtSQL As String
Me.Move (frmMain.ScaleWidth - Me.Width) / 2, (frmMain.ScaleHeight - Me.Height) / 2
txtSQL = "SELECT DeptName FROM Department WHERE DeptID>0"
Call Module1.DataList(txtSQL, Combo1)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -