📄 frm_bg.frm
字号:
VERSION 5.00
Begin VB.Form frm_bg
AutoRedraw = -1 'True
BorderStyle = 3 'Fixed Dialog
Caption = "人事变更"
ClientHeight = 5055
ClientLeft = 45
ClientTop = 330
ClientWidth = 5160
Icon = "frm_bg.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 5055
ScaleWidth = 5160
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 = 4560
Visible = 0 'False
Width = 1140
End
Begin VB.Frame Frame2
Height = 615
Left = 960
TabIndex = 27
Top = 3720
Width = 1695
Begin VB.OptionButton Option4
Caption = "否"
Height = 180
Left = 960
TabIndex = 12
Top = 240
Value = -1 'True
Width = 615
End
Begin VB.OptionButton Option3
Caption = "是"
Height = 180
Left = 240
TabIndex = 11
Top = 240
Width = 615
End
End
Begin VB.TextBox Text3
Height = 375
Left = 960
TabIndex = 10
Top = 3240
Width = 3975
End
Begin VB.TextBox Text1
Height = 375
Left = 960
TabIndex = 0
Top = 120
Width = 1335
End
Begin VB.TextBox Text2
Height = 375
Left = 960
TabIndex = 1
Top = 720
Width = 1335
End
Begin VB.TextBox Text4
Enabled = 0 'False
Height = 375
Left = 960
TabIndex = 4
Top = 1920
Width = 1335
End
Begin VB.TextBox Text5
Enabled = 0 'False
Height = 375
Left = 3600
TabIndex = 8
Top = 1920
Width = 1335
End
Begin VB.TextBox Text6
Enabled = 0 'False
Height = 375
Left = 960
TabIndex = 9
Top = 2640
Width = 3975
End
Begin VB.TextBox Text7
Enabled = 0 'False
Height = 375
Left = 3600
TabIndex = 5
Top = 120
Width = 1335
End
Begin VB.TextBox Text8
Enabled = 0 'False
Height = 375
Left = 3600
TabIndex = 6
Top = 600
Width = 1335
End
Begin VB.TextBox Text9
Enabled = 0 'False
Height = 375
Left = 3600
TabIndex = 7
Top = 1320
Width = 1335
End
Begin VB.Frame Frame1
Height = 615
Left = 960
TabIndex = 14
Top = 1200
Width = 1335
Begin VB.OptionButton Option1
Caption = "男"
Enabled = 0 'False
Height = 180
Left = 120
TabIndex = 2
Top = 240
Value = -1 'True
Width = 495
End
Begin VB.OptionButton Option2
Caption = "女"
Enabled = 0 'False
Height = 180
Left = 720
TabIndex = 3
Top = 240
Width = 495
End
End
Begin VB.CommandButton Command1
Caption = "变更"
Height = 495
Left = 480
TabIndex = 13
Top = 4440
Width = 1215
End
Begin VB.CommandButton Command2
Caption = "返回"
Height = 495
Left = 3600
TabIndex = 15
Top = 4440
Width = 1215
End
Begin VB.Label Label11
Caption = "退休"
Height = 375
Left = 120
TabIndex = 26
Top = 3840
Width = 615
End
Begin VB.Label Label10
Caption = "调离到"
Height = 375
Left = 120
TabIndex = 25
Top = 3240
Width = 615
End
Begin VB.Label Label1
Caption = "工号"
Height = 375
Left = 120
TabIndex = 24
Top = 120
Width = 615
End
Begin VB.Label Label2
Caption = "姓名"
Height = 375
Left = 120
TabIndex = 23
Top = 720
Width = 615
End
Begin VB.Label Label3
Caption = "性别"
Height = 375
Left = 120
TabIndex = 22
Top = 1320
Width = 615
End
Begin VB.Label Label4
Caption = "年龄"
Height = 375
Left = 120
TabIndex = 21
Top = 1920
Width = 615
End
Begin VB.Label Label5
Caption = "电话"
Height = 375
Left = 2760
TabIndex = 20
Top = 1920
Width = 615
End
Begin VB.Label Label6
Caption = "住址"
Height = 375
Left = 120
TabIndex = 19
Top = 2640
Width = 615
End
Begin VB.Label Label7
Caption = "部门"
Height = 375
Left = 2760
TabIndex = 18
Top = 120
Width = 615
End
Begin VB.Label Label8
Caption = "职务"
Height = 375
Left = 2760
TabIndex = 17
Top = 600
Width = 615
End
Begin VB.Label Label9
Caption = "政治面貌"
Height = 375
Left = 2760
TabIndex = 16
Top = 1320
Width = 735
End
End
Attribute VB_Name = "frm_bg"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
If Text1.Text <> "" And MsgBox("你确认要变更这条记录吗?", vbInformation Or vbOKCancel) = vbOK Then
Data1.Recordset.Edit
Data1.Recordset.Fields("调离到") = Text3.Text
Data1.Recordset.Fields("退休") = IIf(Option3.Value = True, "是", "否")
Data1.Recordset.Update
MsgBox "记录变更成功!", vbInformation
Text1.Text = ""
Text2.Text = ""
Option1.Value = True
Text4.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
Text5.Text = ""
Text6.Text = ""
Text3.Text = ""
Option4.Value = True
Text1.SetFocus
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
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
Text1.Text = Data1.Recordset.Fields("工号")
Text2.Text = Data1.Recordset.Fields("姓名")
If Data1.Recordset.Fields("性别") = "男" Then
Option1.Value = True
Else
Option2.Value = True
End If
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("住址")
Text3.Text = Data1.Recordset.Fields("调离到")
If Data1.Recordset.Fields("退休") = "是" Then
Option3.Value = True
Else
Option4.Value = True
End If
Else
MsgBox "没有这条记录!", vbCritical
Text1.Text = ""
End If
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Data1.RecordSource = "select * from 员工表 where 姓名='" + Text2.Text + "'"
Data1.Refresh
If Data1.Recordset.RecordCount > 0 Then
Text1.Text = Data1.Recordset.Fields("工号")
Text2.Text = Data1.Recordset.Fields("姓名")
If Data1.Recordset.Fields("性别") = "男" Then
Option1.Value = True
Else
Option2.Value = True
End If
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("住址")
Text3.Text = Data1.Recordset.Fields("调离到")
If Data1.Recordset.Fields("退休") = "是" Then
Option3.Value = True
Else
Option4.Value = True
End If
Else
MsgBox "没有这条记录!", vbCritical
Text2.Text = ""
End If
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -