📄 frm_dj.frm
字号:
VERSION 5.00
Begin VB.Form frm_dj
AutoRedraw = -1 'True
BorderStyle = 3 'Fixed Dialog
Caption = "登记"
ClientHeight = 4170
ClientLeft = 45
ClientTop = 330
ClientWidth = 5325
Icon = "frm_dj.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4170
ScaleWidth = 5325
ShowInTaskbar = 0 'False
StartUpPosition = 1 '所有者中心
Begin VB.Data Data1
Caption = "Data1"
Connect = "Access"
DatabaseName = "db.mdb"
DefaultCursorType= 0 '缺省游标
DefaultType = 2 '使用 ODBC
Exclusive = 0 'False
Height = 285
Left = 2040
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = "员工表"
Top = 3480
Visible = 0 'False
Width = 1215
End
Begin VB.CommandButton Command2
Caption = "返回"
Height = 495
Left = 3315
TabIndex = 11
Top = 3480
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "登记"
Height = 495
Left = 795
TabIndex = 10
Top = 3480
Width = 1215
End
Begin VB.Frame Frame1
Height = 615
Left = 1080
TabIndex = 21
Top = 1440
Width = 1335
Begin VB.OptionButton Option2
Caption = "女"
Height = 180
Left = 720
TabIndex = 3
Top = 240
Width = 495
End
Begin VB.OptionButton Option1
Caption = "男"
Height = 180
Left = 120
TabIndex = 2
Top = 240
Value = -1 'True
Width = 495
End
End
Begin VB.TextBox Text9
Height = 375
Left = 3720
TabIndex = 7
Top = 1560
Width = 1335
End
Begin VB.TextBox Text8
Height = 375
Left = 3720
TabIndex = 6
Top = 840
Width = 1335
End
Begin VB.TextBox Text7
Height = 375
Left = 3720
TabIndex = 5
Top = 360
Width = 1335
End
Begin VB.TextBox Text6
Height = 375
Left = 1080
TabIndex = 9
Top = 2880
Width = 3975
End
Begin VB.TextBox Text5
Height = 375
Left = 3720
TabIndex = 8
Top = 2160
Width = 1335
End
Begin VB.TextBox Text4
Height = 375
Left = 1080
TabIndex = 4
Top = 2160
Width = 1335
End
Begin VB.TextBox Text2
Height = 375
Left = 1080
TabIndex = 1
Top = 960
Width = 1335
End
Begin VB.TextBox Text1
Height = 375
Left = 1080
TabIndex = 0
Top = 360
Width = 1335
End
Begin VB.Label Label9
Caption = "政治面貌"
Height = 375
Left = 2880
TabIndex = 20
Top = 1560
Width = 735
End
Begin VB.Label Label8
Caption = "职务"
Height = 375
Left = 2880
TabIndex = 19
Top = 840
Width = 615
End
Begin VB.Label Label7
Caption = "部门"
Height = 375
Left = 2880
TabIndex = 18
Top = 360
Width = 615
End
Begin VB.Label Label6
Caption = "住址"
Height = 375
Left = 240
TabIndex = 17
Top = 2880
Width = 615
End
Begin VB.Label Label5
Caption = "电话"
Height = 375
Left = 2880
TabIndex = 16
Top = 2160
Width = 615
End
Begin VB.Label Label4
Caption = "年龄"
Height = 375
Left = 240
TabIndex = 15
Top = 2160
Width = 615
End
Begin VB.Label Label3
Caption = "性别"
Height = 375
Left = 240
TabIndex = 14
Top = 1560
Width = 615
End
Begin VB.Label Label2
Caption = "姓名"
Height = 375
Left = 240
TabIndex = 13
Top = 960
Width = 615
End
Begin VB.Label Label1
Caption = "工号"
Height = 375
Left = 240
TabIndex = 12
Top = 360
Width = 615
End
End
Attribute VB_Name = "frm_dj"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
For i = 1 To Len(Text1.Text)
If Asc(Mid(Text1.Text, i, 1)) < 48 Or Asc(Mid(Text1.Text, i, 1)) > 57 Then
MsgBox "工号输入数据不合法!请输入数字!", vbCritical
Exit Sub
End If
Next
Data1.RecordSource = "select * from 员工表 where 工号=" + Text1.Text
Data1.Refresh
If Data1.Recordset.RecordCount <> 0 Then
MsgBox "已有此工号!", vbCritical
Text1.SetFocus
Exit Sub
Else
If MsgBox("你确认要添加一条记录吗?", vbInformation Or vbOKCancel) = vbOK Then
Data1.Recordset.AddNew
Data1.Recordset.Fields("工号") = Val(Text1.Text)
Data1.Recordset.Fields("姓名") = Text2.Text
Data1.Recordset.Fields("性别") = IIf(Option1.Value = True, "男", "女")
Data1.Recordset.Fields("年龄") = Val(Text4.Text)
Data1.Recordset.Fields("部门") = Text7.Text
Data1.Recordset.Fields("职务") = Text8.Text
Data1.Recordset.Fields("政治面貌") = Text9.Text
Data1.Recordset.Fields("电话") = Text5.Text
Data1.Recordset.Fields("住址") = Text6.Text
Data1.Recordset.Fields("调离到") = " "
Data1.Recordset.Fields("退休") = "否"
Data1.Recordset.Update
MsgBox "记录添加成功!", vbInformation
Text1.Text = ""
Text2.Text = ""
Option1.Value = True
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
Text1.SetFocus
End If
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -