📄 frm_zhigong_edit.frm
字号:
VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomct2.ocx"
Begin VB.Form Frm_zhigong_edit
BorderStyle = 1 'Fixed Single
Caption = "职工信息修改"
ClientHeight = 3885
ClientLeft = 3330
ClientTop = 2460
ClientWidth = 5715
Icon = "Frm_zhigong_edit.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3885
ScaleWidth = 5715
StartUpPosition = 1 '所有者中心
Begin VB.TextBox Text1
Height = 300
Left = 960
TabIndex = 10
Top = 180
Width = 1755
End
Begin VB.TextBox Text2
Height = 300
Left = 3780
TabIndex = 9
Top = 180
Width = 1755
End
Begin VB.TextBox Text5
Height = 735
Left = 3780
MultiLine = -1 'True
TabIndex = 7
Top = 1440
Width = 1755
End
Begin VB.TextBox Text6
Height = 975
Left = 240
MultiLine = -1 'True
TabIndex = 6
Top = 2280
Width = 5295
End
Begin VB.CommandButton Command1
Caption = "确定"
Height = 315
Left = 900
TabIndex = 5
Top = 3420
Width = 1215
End
Begin VB.CommandButton Command2
Caption = "取消"
Height = 315
Left = 3420
TabIndex = 4
Top = 3420
Width = 1155
End
Begin VB.ComboBox Combo1
Height = 300
Left = 960
Style = 2 'Dropdown List
TabIndex = 3
Top = 600
Width = 1755
End
Begin VB.ComboBox Combo2
Height = 300
Left = 960
Style = 2 'Dropdown List
TabIndex = 2
Top = 1020
Width = 1755
End
Begin VB.ComboBox Combo3
Height = 300
Left = 3780
Style = 2 'Dropdown List
TabIndex = 1
Top = 1020
Width = 1755
End
Begin VB.ComboBox Combo4
Height = 300
Left = 960
Style = 2 'Dropdown List
TabIndex = 0
Top = 1440
Width = 1755
End
Begin MSComCtl2.DTPicker DTPicker1
Height = 300
Left = 3780
TabIndex = 8
Top = 600
Width = 1755
_ExtentX = 3096
_ExtentY = 529
_Version = 393216
CustomFormat = "yyyy-MM-dd"
Format = 16646147
CurrentDate = 38805
End
Begin VB.Label Label1
Caption = "工 号"
Height = 255
Left = 180
TabIndex = 19
Top = 240
Width = 555
End
Begin VB.Label Label2
Caption = "姓 名"
Height = 255
Left = 2880
TabIndex = 18
Top = 180
Width = 555
End
Begin VB.Label Label3
Caption = "性 别"
Height = 255
Left = 180
TabIndex = 17
Top = 660
Width = 495
End
Begin VB.Label Label4
Caption = "出生日期"
Height = 195
Left = 2880
TabIndex = 16
Top = 660
Width = 795
End
Begin VB.Label Label5
Caption = "部 门"
Height = 255
Left = 180
TabIndex = 15
Top = 1080
Width = 615
End
Begin VB.Label Label6
Caption = "学 历"
Height = 255
Left = 2880
TabIndex = 14
Top = 1080
Width = 795
End
Begin VB.Label Label7
Caption = "职 称"
Height = 195
Left = 180
TabIndex = 13
Top = 1500
Width = 735
End
Begin VB.Label Label8
Caption = "家庭住址"
Height = 255
Left = 2880
TabIndex = 12
Top = 1500
Width = 795
End
Begin VB.Label Label9
Caption = "备 注"
Height = 255
Left = 180
TabIndex = 11
Top = 1920
Width = 555
End
End
Attribute VB_Name = "Frm_zhigong_edit"
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
msg = MsgBox("是否保存该修改?", vbYesNo + vbQuestion, "提示")
If msg = vbNo Then Exit Sub
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(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(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) And Text1 <> Frm_zhigong.ListView1.SelectedItem.Text 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) And Text2 <> Frm_zhigong.ListView1.SelectedItem.SubItems(1) 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 = "update zhigong set zgh='" & Trim(Text1) & "',xm='" & Trim(Text2) & "',xb='" & Trim(Combo1) & "',csrq='" & DTPicker1 & "',bmdm='" & Combo2.ItemData(Combo2.ListIndex) & "',xl='" & Trim(Combo3) & "',zc='" & Trim(Combo4) & "',zz='" & Trim(Text5) & "',bz='" & Trim(Text6) & "' where zgh='" & Frm_zhigong.ListView1.SelectedItem.Text & "'"
cn.Execute sql
Frm_zhigong.ListView1.SelectedItem.Text = Text1
Frm_zhigong.ListView1.SelectedItem.SubItems(1) = Text2
Frm_zhigong.ListView1.SelectedItem.SubItems(2) = Combo1
Frm_zhigong.ListView1.SelectedItem.SubItems(3) = DTPicker1
Frm_zhigong.ListView1.SelectedItem.SubItems(4) = Combo2
Frm_zhigong.ListView1.SelectedItem.SubItems(5) = Combo3
Frm_zhigong.ListView1.SelectedItem.SubItems(6) = Combo4
Frm_zhigong.ListView1.SelectedItem.SubItems(7) = Text5
Frm_zhigong.ListView1.SelectedItem.SubItems(8) = Text6
MsgBox "保存成功!", vbExclamation, "提示"
Unload Me
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)
If rst(1) = Frm_zhigong.ListView1.SelectedItem.SubItems(4) Then
Combo2.ListIndex = Combo2.NewIndex
End If
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 = Frm_zhigong.ListView1.SelectedItem.Text
Text2 = Frm_zhigong.ListView1.SelectedItem.SubItems(1)
Combo1 = Frm_zhigong.ListView1.SelectedItem.SubItems(2)
DTPicker1 = Frm_zhigong.ListView1.SelectedItem.SubItems(3)
Combo3 = Frm_zhigong.ListView1.SelectedItem.SubItems(5)
Combo4 = Frm_zhigong.ListView1.SelectedItem.SubItems(6)
Text5 = Frm_zhigong.ListView1.SelectedItem.SubItems(7)
Text6 = Frm_zhigong.ListView1.SelectedItem.SubItems(8)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -