📄 tjjbxx.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form tjjbxx
BackColor = &H00C0C0C0&
Caption = "Form1"
ClientHeight = 5535
ClientLeft = 60
ClientTop = 345
ClientWidth = 8400
LinkTopic = "Form1"
ScaleHeight = 5535
ScaleWidth = 8400
Begin MSAdodcLib.Adodc Adodc1
Height = 330
Left = 3240
Top = 5040
Visible = 0 'False
Width = 1455
_ExtentX = 2566
_ExtentY = 582
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 2
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=cj.mdb;Persist Security Info=False"
OLEDBString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=cj.mdb;Persist Security Info=False"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "学生表"
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.CommandButton Command2
Caption = "退出(&E)"
Height = 375
Left = 4920
TabIndex = 26
Top = 5040
Width = 975
End
Begin VB.CommandButton Command1
Caption = "添加(&A)"
Height = 375
Left = 2160
TabIndex = 25
Top = 5040
Width = 975
End
Begin VB.Frame Frame1
BackColor = &H00C0C0C0&
Caption = "学生基本信息录入"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF8080&
Height = 4575
Left = 360
TabIndex = 0
Top = 360
Width = 7575
Begin VB.TextBox Text12
DataSource = "Adodc1"
Height = 855
Left = 4200
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 24
Top = 3360
Width = 2775
End
Begin VB.ComboBox Combo3
DataSource = "Adodc1"
Height = 300
Left = 4800
TabIndex = 23
Top = 2760
Width = 1815
End
Begin VB.ComboBox Combo2
DataSource = "Adodc1"
Height = 300
Left = 4800
TabIndex = 22
Top = 2160
Width = 1815
End
Begin VB.TextBox Text9
DataSource = "Adodc1"
Height = 270
Left = 4800
TabIndex = 21
Top = 1680
Width = 1815
End
Begin VB.TextBox Text8
DataSource = "Adodc1"
Height = 270
Left = 4800
TabIndex = 20
Top = 1200
Width = 1815
End
Begin VB.TextBox Text7
DataSource = "Adodc1"
Height = 270
Left = 4440
TabIndex = 19
Top = 600
Width = 2175
End
Begin VB.TextBox Text5
DataSource = "Adodc1"
Height = 270
Left = 1080
TabIndex = 18
Top = 3360
Width = 1575
End
Begin VB.TextBox Text4
DataSource = "Adodc1"
Height = 270
Left = 1080
TabIndex = 17
Top = 2760
Width = 1575
End
Begin VB.ComboBox Combo1
DataSource = "Adodc1"
Height = 300
Left = 1080
TabIndex = 16
Top = 2280
Width = 1575
End
Begin VB.TextBox Text3
DataSource = "Adodc1"
Height = 270
Left = 1080
TabIndex = 15
Top = 1800
Width = 1575
End
Begin VB.TextBox Text2
DataSource = "Adodc1"
Height = 270
Left = 1080
TabIndex = 14
Top = 1200
Width = 1575
End
Begin VB.TextBox Text1
DataSource = "Adodc1"
Height = 270
Left = 1080
TabIndex = 13
Top = 600
Width = 1575
End
Begin VB.Label Label13
BackColor = &H00C0C0C0&
Caption = "备注:"
ForeColor = &H00FF0000&
Height = 375
Left = 3600
TabIndex = 12
Top = 3360
Width = 855
End
Begin VB.Label Label12
BackColor = &H00C0C0C0&
Caption = "专业:"
ForeColor = &H00FF0000&
Height = 495
Left = 3600
TabIndex = 11
Top = 2760
Width = 855
End
Begin VB.Label Label11
BackColor = &H00C0C0C0&
Caption = "院系:"
ForeColor = &H00FF0000&
Height = 255
Left = 3600
TabIndex = 10
Top = 2160
Width = 735
End
Begin VB.Label Label10
BackColor = &H00C0C0C0&
Caption = "电话号码:"
ForeColor = &H00FF0000&
Height = 255
Left = 3600
TabIndex = 9
Top = 1680
Width = 855
End
Begin VB.Label Label9
BackColor = &H00C0C0C0&
Caption = "邮政编码:"
ForeColor = &H00FF0000&
Height = 495
Left = 3600
TabIndex = 8
Top = 1200
Width = 855
End
Begin VB.Label Label8
BackColor = &H00C0C0C0&
Caption = "地址;"
ForeColor = &H00FF0000&
Height = 255
Left = 3600
TabIndex = 7
Top = 600
Width = 1455
End
Begin VB.Label Label6
BackColor = &H00C0C0C0&
Caption = "民族:"
ForeColor = &H00FF0000&
Height = 495
Left = 240
TabIndex = 6
Top = 3360
Width = 735
End
Begin VB.Label Label5
BackColor = &H00C0C0C0&
Caption = "出生年月"
ForeColor = &H00FF0000&
Height = 375
Left = 240
TabIndex = 5
Top = 2760
Width = 735
End
Begin VB.Label Label4
BackColor = &H00C0C0C0&
Caption = "性别"
ForeColor = &H00FF0000&
Height = 375
Left = 240
TabIndex = 4
Top = 2280
Width = 735
End
Begin VB.Label Label3
BackColor = &H00C0C0C0&
Caption = "姓名:"
ForeColor = &H00FF0000&
Height = 375
Left = 240
TabIndex = 3
Top = 1800
Width = 855
End
Begin VB.Label Label2
BackColor = &H00C0C0C0&
Caption = "班级"
ForeColor = &H00FF0000&
Height = 375
Left = 240
TabIndex = 2
Top = 1200
Width = 855
End
Begin VB.Label Label1
BackColor = &H00C0C0C0&
Caption = "学号:"
ForeColor = &H00FF0000&
Height = 375
Left = 240
TabIndex = 1
Top = 600
Width = 855
End
End
End
Attribute VB_Name = "tjjbxx"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim rs As New ADODB.Recordset
Private Sub Command1_Click()
On Error GoTo AddErr
'Text1.Enabled = True
If Text1.Text = "" Then
MsgBox "请输入学号!", vbOKOnly + vbExclamation, "警告"
Text1.SetFocus
Exit Sub
End If
If Text3.Text = "" Then
MsgBox "请输入姓名!", vbOKOnly + vbExclamation, "警告"
Text3.SetFocus
Exit Sub
End If
If Combo1.Text = "" Then
MsgBox "请输入性别!", vbOKOnly + vbExclamation, "警告"
Combo1.SetFocus
Exit Sub
End If
If Text5.Text = "" Then
MsgBox "请输入民族!"
Text5.SetFocus
Exit Sub
End If
If Text4.Text = "" Then
MsgBox "请输入出生年月!出生年月应输入日期格式(YYYY-MM-DD)!", vbOKOnly + vbExclamation, "警告"
Text4.SetFocus
Exit Sub
End If
If Text7.Text = "" Then
MsgBox "请输入地址!", vbOKOnly + vbExclamation, "警告"
Text7.SetFocus
Exit Sub
End If
If Text8.Text = "" Then
MsgBox "请输入邮政编码!", vbOKOnly + vbExclamation, "警告"
Text8.SetFocus
Exit Sub
End If
If Text2.Text = "" Then
MsgBox "请输入班级!", vbOKOnly + vbExclamation, "警告"
Text2.SetFocus
Exit Sub
End If
If Combo3.Text = "" Then
MsgBox "请输入专业!", vbOKOnly + vbExclamation, "警告"
Combo3.SetFocus
Exit Sub
End If
If Combo2.Text = "" Then
MsgBox "请输入院系!", vbOKOnly + vbExclamation, "警告"
Combo2.SetFocus
Exit Sub
End If
If Text9.Text = "" Then
MsgBox "请输入电话号码!", vbOKOnly + vbExclamation, "警告"
Text9.SetFocus
Exit Sub
End If
'txtSQL = "select * from 学生 where 学号='" & Trim(Text1.Text) & "' "
'Set mrc = cn.Execute(txtSQL)
'mrc.LockType = adLockOptimistic
'mrc.CursorType = adOpenKeyset
'mrc.Open txtSQL, cn, adOpenDynamic, adLockOptimistic, adCmdText
'Adodc2.RecordSource = "select * from 学生 where 学号='" & Trim(Text1.Text) & "' "
' mrc.EOF = False Then
If check1 = False Then
MsgBox "学号重复!", vbOKOnly + vbExclamation, "警告"
Text1.SetFocus
Else
'If Text4.Text <> "" Then
'MsgBox "出生年月应输入日期格式(YYYY-MM-DD)!", vbOKOnly + vbExclamation, "O警告"
'Text4.SetFocus
'Else
'Adodc2.RecordSource = "select * from 学生"
'txtSQL = "select * from 学生"
'mrc.LockType = adLockOptimistic
'mrc.CursorType = adOpenKeyset
'mrc.Open txtSQL, cn, adOpenDynamic, adLockOptimistic, adCmdText
'mrc.AddNew
Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields("学号").Value = Text1.Text
Adodc1.Recordset.Fields("姓名").Value = Text3.Text
Adodc1.Recordset.Fields("班级").Value = Text2.Text
Adodc1.Recordset.Fields("性别").Value = Combo1.Text
Adodc1.Recordset.Fields("出生日期").Value = Text4.Text
Adodc1.Recordset.Fields("民族").Value = Text5.Text
Adodc1.Recordset.Fields("地址").Value = Text7.Text
Adodc1.Recordset.Fields("邮政编码").Value = Text8.Text
Adodc1.Recordset.Fields("电话号码").Value = Text9.Text
Adodc1.Recordset.Fields("院系").Value = Combo2.Text
Adodc1.Recordset.Fields("专业").Value = Combo3.Text
Adodc1.Recordset.Fields("备注").Value = Text12.Text
Adodc1.Recordset.Update
'Adodc1.Recordset.Close
MsgBox "添加成功!", vbOKOnly + vbExclamation, "警告"
Exit Sub
End If
AddErr:
MsgBox Err.Description
Exit Sub
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
On Error GoTo errh
MakeCenter tjjbxx
Combo1.AddItem "男"
Combo1.AddItem "女"
Set rs = cn.Execute("SELECT distinct 院系,专业 FROM 学生表")
rs.MoveFirst
Do
Combo2.AddItem rs.Fields(0).Value
Combo3.AddItem rs.Fields(1).Value
rs.MoveNext
Loop Until rs.EOF
Exit Sub
errh:
rs.Close
MsgBox Err.Description
End Sub
Private Function check1() As Boolean '检测添加的课程是否重复
On Error GoTo errh
Set rs = cn.Execute("SELECT 学号 FROM 学生表 WHERE 学号='" & Trim(Text1.Text) & "'")
' Adodc2.RecordSource = "select * from 课程 where 课程号='" & Trim(Text1.Text) & "' and 课程名称='" & Trim(Text2.Text) & "' "
If rs.EOF Then
rs.Close
check1 = True
Exit Function
End If
check1 = False
rs.Close
Exit Function
errh:
rs.Close
MsgBox Err.Description
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -