📄 frm_zhigong_add.frm
字号:
VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomct2.ocx"
Begin VB.Form Frm_zhigong_add
BorderStyle = 1 'Fixed Single
Caption = "职工添加"
ClientHeight = 3870
ClientLeft = 3330
ClientTop = 2580
ClientWidth = 5715
Icon = "Frm_zhigong_add.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3870
ScaleWidth = 5715
StartUpPosition = 1 '所有者中心
Begin VB.ComboBox Combo4
Height = 300
Left = 960
Style = 2 'Dropdown List
TabIndex = 19
Top = 1440
Width = 1755
End
Begin VB.ComboBox Combo3
Height = 300
Left = 3780
Style = 2 'Dropdown List
TabIndex = 18
Top = 1020
Width = 1755
End
Begin VB.ComboBox Combo2
Height = 300
Left = 960
Style = 2 'Dropdown List
TabIndex = 17
Top = 1020
Width = 1755
End
Begin VB.ComboBox Combo1
Height = 300
Left = 960
Style = 2 'Dropdown List
TabIndex = 16
Top = 600
Width = 1755
End
Begin VB.CommandButton Command2
Caption = "取消"
Height = 315
Left = 3420
TabIndex = 15
Top = 3420
Width = 1155
End
Begin VB.CommandButton Command1
Caption = "确定"
Height = 315
Left = 900
TabIndex = 14
Top = 3420
Width = 1215
End
Begin VB.TextBox Text6
Height = 975
Left = 240
MultiLine = -1 'True
TabIndex = 13
Top = 2280
Width = 5295
End
Begin VB.TextBox Text5
Height = 735
Left = 3780
MultiLine = -1 'True
TabIndex = 11
Top = 1440
Width = 1755
End
Begin MSComCtl2.DTPicker DTPicker1
Height = 300
Left = 3780
TabIndex = 6
Top = 600
Width = 1755
_ExtentX = 3096
_ExtentY = 529
_Version = 393216
CustomFormat = "yyyy-MM-dd"
Format = 16646147
CurrentDate = 38805
End
Begin VB.TextBox Text2
Height = 300
Left = 3780
TabIndex = 3
Top = 180
Width = 1755
End
Begin VB.TextBox Text1
Height = 300
Left = 960
TabIndex = 1
Top = 180
Width = 1755
End
Begin VB.Label Label9
Caption = "备 注"
Height = 255
Left = 180
TabIndex = 12
Top = 1920
Width = 555
End
Begin VB.Label Label8
Caption = "家庭住址"
Height = 255
Left = 2880
TabIndex = 10
Top = 1500
Width = 795
End
Begin VB.Label Label7
Caption = "职 称"
Height = 195
Left = 180
TabIndex = 9
Top = 1500
Width = 735
End
Begin VB.Label Label6
Caption = "学 历"
Height = 255
Left = 2880
TabIndex = 8
Top = 1080
Width = 795
End
Begin VB.Label Label5
Caption = "部 门"
Height = 255
Left = 180
TabIndex = 7
Top = 1080
Width = 615
End
Begin VB.Label Label4
Caption = "出生日期"
Height = 195
Left = 2880
TabIndex = 5
Top = 660
Width = 795
End
Begin VB.Label Label3
Caption = "性 别"
Height = 255
Left = 180
TabIndex = 4
Top = 660
Width = 495
End
Begin VB.Label Label2
Caption = "姓 名"
Height = 255
Left = 2880
TabIndex = 2
Top = 180
Width = 555
End
Begin VB.Label Label1
Caption = "学 号"
Height = 255
Left = 180
TabIndex = 0
Top = 240
Width = 555
End
End
Attribute VB_Name = "Frm_zhigong_add"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
On Error GoTo myerr
Dim cn As ADODB.Connection
Dim rst As New ADODB.Recordset
Dim sql As String
If Combo2.ListIndex = -1 Then
MsgBox "部门信息尚未添加,请先添加部门信息!", vbExclamation, "提示"
Exit Sub
End If
If Trim(Text1) = "" Then
MsgBox "学号不能为空!"
Text1.SetFocus
Exit Sub
End If
If Trim(Text2) = "" Then
MsgBox "姓名不能为空!"
Text2.SetFocus
Exit Sub
End If
' If Trim(combo2) = "" Then
' MsgBox "部门不能为空!"
' combo2.SetFocus
' Exit Sub
' End If
' If Trim(combo3) = "" Then
' MsgBox "学历不能为空!"
' combo3.SetFocus
' Exit Sub
' End If
' If Trim(combo4) = "" Then
' MsgBox "职称不能为空!"
' combo4.SetFocus
' Exit Sub
' End If
If Trim(Text5) = "" Then
MsgBox "家庭住址不能为空!"
Text5.SetFocus
Exit Sub
End If
If Len(Text1) > 20 Then
MsgBox "学号不能超过20个字符!"
Text1.SetFocus
End If
If Len(Text2) > 8 Then
MsgBox "姓名不能超过8个字符!"
Text2.SetFocus
End If
' If Len(combo2) > 20 Then
' MsgBox "部门不能超过20个字符!"
' combo2.SetFocus
' End If
' If Len(combo3) > 20 Then
' MsgBox "学历不能超过20个字符!"
' combo3.SetFocus
' End If
' If Len(combo4) > 20 Then
' MsgBox "职称不能超过20个字符!"
' combo4.SetFocus
' End If
If Len(Text5) > 200 Then
MsgBox "家庭住址不能超过200个字符!"
Text5.SetFocus
End If
Set cn = GetCn
rst.Open "select * from zhigong where zgh='" & Trim(Text1) & "'", cn, 0, 1
If Not (rst.BOF And rst.EOF) Then
MsgBox "该职工号已存在!", vbExclamation, "提示"
Text1.SetFocus
rst.Close
cn.Close
Exit Sub
End If
rst.Close
rst.Open "select * from zhigong where xm='" & Trim(Text2) & "'", cn, 0, 1
If Not (rst.BOF And rst.EOF) Then
msg = MsgBox("该职工姓名已存在!" & vbCrLf & "是否继续保存?", vbYesNo + vbQuestion, "提示")
If msg = vbNo Then
Text2.SetFocus
rst.Close
cn.Close
Exit Sub
End If
End If
rst.Close
sql = "insert into zhigong (zgh,xm,xb,csrq,bmdm,xl,zc,zz,bz) values ('" & Trim(Text1) & "','" & Trim(Text2) & "','" & Trim(Combo1) & "','" & Trim(DTPicker1) & "','" & Combo2.ItemData(Combo2.ListIndex) & "','" & Trim(Combo3) & "','" & Trim(Combo4) & "','" & Trim(Text5) & "','" & Trim(Text6) & "')"
cn.Execute sql
MsgBox "保存成功!", vbExclamation, "提示"
Form_Load
Exit Sub
myerr:
MsgBox Error, vbExclamation, "提示"
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Dim cn As ADODB.Connection
Dim rst As New ADODB.Recordset
Set cn = GetCn
Combo1.Clear
Combo2.Clear
Combo3.Clear
Combo4.Clear
rst.Open "select * from bumen", cn, 0, 1
If Not (rst.BOF And rst.EOF) Then
Do While Not rst.EOF
Combo2.AddItem rst(1)
Combo2.ItemData(Combo2.NewIndex) = rst(0)
rst.MoveNext
Loop
Combo2.ListIndex = 0
Else
MsgBox "部门信息尚未添加,请先添加部门信息!", vbExclamation, "提示"
End If
DTPicker1.Value = DateAdd("YYYY", -20, Date)
Combo1.AddItem "男"
Combo1.AddItem "女"
Combo1.ListIndex = 0
Combo3.AddItem "高中"
Combo3.AddItem "大专"
Combo3.AddItem "大本"
Combo3.AddItem "硕士"
Combo3.AddItem "博士"
Combo3.ListIndex = 0
Combo4.AddItem "一级职称"
Combo4.AddItem "二级职称"
Combo4.AddItem "三级职称"
Combo4.ListIndex = 0
Text1 = ""
Text2 = ""
Text5 = ""
Text6 = ""
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -