📄 员工信息添加.frm
字号:
VERSION 5.00
Begin VB.Form Form9
Caption = "Form9"
ClientHeight = 5010
ClientLeft = 60
ClientTop = 420
ClientWidth = 8010
LinkTopic = "Form9"
ScaleHeight = 5010
ScaleWidth = 8010
StartUpPosition = 3 '窗口缺省
Begin VB.Frame Frame2
Caption = "操 作"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 1455
Left = 1800
TabIndex = 18
Top = 3360
Width = 4575
Begin VB.CommandButton Command2
Caption = "取 消"
Height = 375
Left = 3000
TabIndex = 20
Top = 600
Width = 975
End
Begin VB.CommandButton Command1
Caption = "添加员工信息"
Height = 375
Left = 840
TabIndex = 19
Top = 600
Width = 1335
End
End
Begin VB.Frame Frame1
Caption = "员工信息"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 2895
Left = 240
TabIndex = 0
Top = 240
Width = 7575
Begin VB.ComboBox Combo1
Height = 300
ItemData = "员工信息添加.frx":0000
Left = 6120
List = "员工信息添加.frx":000A
TabIndex = 21
Text = "男"
Top = 550
Width = 735
End
Begin VB.TextBox Text9
Height = 375
Left = 1200
TabIndex = 17
Top = 2280
Width = 2775
End
Begin VB.TextBox Text8
Height = 375
Left = 4080
TabIndex = 15
Top = 1680
Width = 3255
End
Begin VB.TextBox Text7
Height = 375
Left = 1080
TabIndex = 13
Top = 1680
Width = 1455
End
Begin VB.TextBox Text6
Height = 375
Left = 6120
TabIndex = 11
Top = 1080
Width = 1215
End
Begin VB.TextBox Text5
Height = 375
Left = 3480
TabIndex = 9
Top = 1080
Width = 1335
End
Begin VB.TextBox Text4
Height = 375
Left = 1080
TabIndex = 7
Top = 1080
Width = 975
End
Begin VB.TextBox Text2
Height = 375
Left = 3480
TabIndex = 4
Top = 480
Width = 1215
End
Begin VB.TextBox Text1
Height = 375
Left = 1080
TabIndex = 2
Top = 480
Width = 1215
End
Begin VB.Label Label9
Caption = "联系电话"
Height = 255
Left = 240
TabIndex = 16
Top = 2400
Width = 735
End
Begin VB.Label Label8
Caption = "家庭地址"
Height = 255
Left = 3120
TabIndex = 14
Top = 1800
Width = 735
End
Begin VB.Label Label7
Caption = "职 称"
Height = 255
Left = 240
TabIndex = 12
Top = 1800
Width = 495
End
Begin VB.Label Label6
Caption = "学 历"
Height = 255
Left = 5400
TabIndex = 10
Top = 1200
Width = 495
End
Begin VB.Label Label5
Caption = "籍 贯"
Height = 255
Left = 2760
TabIndex = 8
Top = 1200
Width = 495
End
Begin VB.Label Label4
Caption = "年 龄"
Height = 255
Left = 240
TabIndex = 6
Top = 1200
Width = 495
End
Begin VB.Label Label3
Caption = "性 别"
Height = 255
Left = 5400
TabIndex = 5
Top = 600
Width = 495
End
Begin VB.Label Label2
Caption = "姓 名"
Height = 255
Left = 2760
TabIndex = 3
Top = 600
Width = 495
End
Begin VB.Label Label1
Caption = "职工号"
Height = 255
Left = 240
TabIndex = 1
Top = 600
Width = 615
End
End
End
Attribute VB_Name = "Form9"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim rst As New ADODB.Recordset '定义Recordset对象
Dim strSql As String
Private Sub Command1_Click()
If Text1.Text = "" Then
MsgBox "员工信息不完整,请输入职工号!", vbInformation + vbOKCancel + vbApplicationModal, "提示"
Exit Sub
End If
If Text2.Text = "" Then
MsgBox "员工信息不完整,请输入姓名!", vbInformation + vbOKCancel + vbApplicationModal, "提示"
Exit Sub
End If
If Text4.Text = "" Then
MsgBox "员工信息不完整,请输入年龄!", vbInformation + vbOKCancel + vbApplicationModal, "提示"
Exit Sub
End If
If Not IsNumeric(Text4.Text) Then
MsgBox "年龄必须为数字!", vbInformation + vbOKOnly + vbApplicationModal, "提示"
Text4.Text = ""
Text4.SetFocus
Exit Sub
Else
Dim i As Integer
If Text4.Text <= 0 Or Text4.Text >= 120 Then
i = MsgBox("输入年龄有误!", vbInformation + vbOKOnly + vbApplicationModal, "提示")
Text4.Text = ""
Text4.SetFocus
Exit Sub
End If
End If
If Text5.Text = "" Then
MsgBox "员工信息不完整,请输入籍贯!", vbInformation + vbOKCancel + vbApplicationModal, "提示"
Exit Sub
End If
If Text6.Text = "" Then
MsgBox "员工信息不完整,请输入学历!", vbInformation + vbOKCancel + vbApplicationModal, "提示"
Exit Sub
End If
If Text7.Text = "" Then
MsgBox "员工信息不完整,请输入职称!", vbInformation + vbOKCancel + vbApplicationModal, "提示"
Exit Sub
End If
If Text8.Text = "" Then
MsgBox "员工信息不完整,请输入家庭地址!", vbInformation + vbOKCancel + vbApplicationModal, "提示"
Exit Sub
End If
If Text9.Text = "" Then
MsgBox "员工信息不完整,请输入联系电话!", vbInformation + vbOKCancel + vbApplicationModal, "提示"
Exit Sub
End If
If rst.State = adStateOpen Then
rst.Close
End If
strSql = "select * from ygxx where 职工号='" & Text1.Text & "'"
rst.Open strSql, cnn, 1, 1
If Not rst.EOF Then
MsgBox "该职工号已存在,请重新输入!", vbInformation + vbOKOnly + vbApplicationModal, "提示"
Text1.Text = ""
Text1.SetFocus
Exit Sub
Else
If rst.State = adStateOpen Then
rst.Close
End If
If IsNumeric(Text1.Text) = False Then
MsgBox "职工号必须是数值!请重新输入!", vbInformation + vbOKOnly + vbApplicationModal, "提示"
Text1.Text = ""
Text1.SetFocus
Exit Sub
End If
strSql = "insert into ygxx values('" & Text1.Text & "','" & Text2.Text & "','" & Combo1.Text & "','" & Text4.Text & "','" & Text5.Text & "','" & Text6.Text & "','" & Text7.Text & "','" & Text8.Text & "','" & Text9.Text & "')"
rst.Open strSql, cnn, 1, 1
MsgBox "成功增加员工信息!", vbInformation + vbOKOnly + vbApplicationModal, "提示"
Call Form5.Info
Form5.Show
Unload Me
End If
End Sub
Private Sub Command2_Click()
Unload Me
Form5.Show
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -