📄 增加班级.frm
字号:
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 1680
TabIndex = 5
Top = 960
Width = 2175
End
Begin VB.TextBox Text2
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 6240
TabIndex = 3
Top = 360
Width = 2175
End
Begin VB.TextBox Text1
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 1680
TabIndex = 1
Top = 360
Width = 2175
End
Begin VB.Label Label5
Caption = "备注:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 120
TabIndex = 8
Top = 1560
Width = 735
End
Begin VB.Label Label4
Caption = "辅导员:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 5280
TabIndex = 6
Top = 1080
Width = 855
End
Begin VB.Label Label3
Caption = "人数:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 840
TabIndex = 4
Top = 960
Width = 735
End
Begin VB.Label Label2
Caption = "专业:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 5520
TabIndex = 2
Top = 480
Width = 735
End
Begin VB.Label Label1
Caption = "年级:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 840
TabIndex = 0
Top = 360
Width = 735
End
End
Attribute VB_Name = "Frm_AddClass"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim myCon As New ADODB.Connection
Dim myRs As New ADODB.Recordset
Private Sub Command1_Click()
Dim NianJi, ZhuanYe, RenShu, FuDaoYuan, BeiZu As String
NianJi = Text1.Text
ZhuanYe = Text2.Text
RenShu = Text3.Text
FuDaoYuan = Text4.Text
BeiZu = Text5.Text
Command1.Enabled = True
If Trim(NianJi) = "" Or Trim(ZhuanYe) = "" Or Trim(RenShu) = "" Or Trim(FuDaoYuan) = "" Then
MsgBox "班级资料不能为空,请填写完整!"
Exit Sub
End If
myCon.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=信息.mdb;"
myRs.Open "select * from 班级表 where 年级='" & Trim(Text1.Text) & "' and 专业='" & Trim(Text2.Text) & "' ", myCon
If myRs.EOF = False Then
MsgBox "该班级已经存在,请重新输入!"
myRs.Close
myCon.Close
Text1.SetFocus
Exit Sub
End If
myRs.Close
myRs.Open "班级表", myCon, 3, 2
myRs.AddNew
myRs.Fields("年级") = Text1.Text
myRs.Fields("专业") = Text2.Text
myRs.Fields("人数") = Text3.Text
myRs.Fields("辅导员") = Text4.Text
If Text5.Text = "" Then
myRs.Fields("备注") = " "
Else
myRs.Fields("备注") = Text5.Text
End If
myRs.Update
myRs.Close
myCon.Close
MsgBox "添加成功!"
Adodc1.RecordSource = "select * from 班级表 order by 年级"
Frm_AddClass.Adodc1.Refresh
Frm_AddClass.DataGrid1.Refresh
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
End Sub
Private Sub Command2_Click()
Dim NianJi, xi, RenShu, FuDaoYuan, BeiZu As String
NianJi = Text1.Text
ZhuanYe = Text2.Text
RenShu = Text3.Text
FuDaoYuan = Text4.Text
BeiZu = Text5.Text
If Trim(NianJi) = "" Or Trim(ZhuanYe) = "" Or Trim(RenShu) = "" Or Trim(FuDaoYuan) = "" Then
MsgBox "请填写要删除班级的资料!"
Exit Sub
End If
If myCon.State = 1 Then
myCon.Close
End If
myCon.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=信息.mdb;"
Dim n As Integer
myRs.Open "select * from 班级表 where 年级='" & Trim(Text1.Text) & "'", myCon, 3, 2
n = MsgBox("您确定要删除吗?", vbYesNo, "提示")
If n = 6 Then
myRs.Delete
myRs.Close
myCon.Close
End If
'MsgBox "您确定要删除吗?", vbYesNo, "提示"
Adodc1.RecordSource = "select * from 班级表 order by 年级"
Frm_AddClass.Adodc1.Refresh
Frm_AddClass.DataGrid1.Refresh
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
End Sub
Private Sub Command3_Click()
Unload Me
End Sub
Private Sub DataGrid1_Click()
Frm_AddClass.Adodc1.RecordSource = "select * from 班级表 where 年级 = '" & Trim(DataGrid1.Row) & "'"
Text1.Text = Frm_AddClass.Adodc1.Recordset.Fields("年级")
Text2.Text = Frm_AddClass.Adodc1.Recordset.Fields("专业")
Text3.Text = Frm_AddClass.Adodc1.Recordset.Fields("人数")
Text4.Text = Frm_AddClass.Adodc1.Recordset.Fields("辅导员")
Text5.Text = Frm_AddClass.Adodc1.Recordset.Fields("备注")
Command1.Enabled = False
Command2.Enabled = True
End Sub
Private Sub Form_Load()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
'Frm_AddClass.Adodc1.Refresh
'Frm_AddClass.DataGrid1.Refresh
End Sub
Private Sub Text1_Change()
Command1.Enabled = True
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -