📄 main_rsgl_rsdaxx_lr.frm
字号:
TabIndex = 29
Top = 2415
Width = 930
End
Begin VB.Label Label13
Caption = "手机号码:"
Height = 225
Left = 2865
TabIndex = 28
Top = 2100
Width = 930
End
Begin VB.Label Label12
Caption = "联系电话:"
Height = 225
Left = 135
TabIndex = 23
Top = 2085
Width = 930
End
Begin VB.Label Label11
Caption = "籍贯:"
Height = 225
Left = 3165
TabIndex = 22
Top = 1725
Width = 540
End
Begin VB.Label Label10
Caption = "政治面貌:"
Height = 195
Left = 2865
TabIndex = 21
Top = 1365
Width = 915
End
Begin VB.Label Label9
Caption = "婚姻状况:"
Height = 225
Left = 225
TabIndex = 18
Top = 1350
Width = 930
End
Begin VB.Label Label7
Caption = "民族:"
Height = 195
Left = 4470
TabIndex = 17
Top = 990
Width = 570
End
Begin VB.Label Label6
Caption = "出生年月:"
Height = 195
Left = 120
TabIndex = 15
Top = 990
Width = 915
End
Begin VB.Label Label5
Caption = "身份证号:"
Height = 195
Left = 2865
TabIndex = 11
Top = 630
Width = 915
End
Begin VB.Label Label4
Caption = "性别:"
Height = 225
Left = 420
TabIndex = 9
Top = 600
Width = 570
End
Begin VB.Label Label3
Caption = "照片:"
Height = 195
Left = 6630
TabIndex = 8
Top = 330
Width = 585
End
Begin VB.Label Label2
Caption = "姓名:"
Height = 195
Left = 3120
TabIndex = 7
Top = 300
Width = 585
End
Begin VB.Label Label1
Caption = "编号:"
Height = 195
Left = 405
TabIndex = 6
Top = 300
Width = 585
End
End
End
Attribute VB_Name = "main_rsgl_rsdaxx_lr"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim i As Integer '定义整型变量
Dim rs1 As New ADODB.Recordset '定义数据集对象
Public photoFilename As String
Dim mst As New ADODB.Stream
Private Sub cmdDept_Click()
deptMark = 2
Load main_datatree
main_datatree.Show 1
End Sub
Private Sub cmdPhotoAdd_Click()
'添加职工相片
With CommonDialog1
.DialogTitle = "选择要加入的职工相片"
.Filter = "jpg图片|*.jpg"
.ShowOpen '打开对话框
PicPhoto.Picture = LoadPicture(.FileName)
photoFilename = .FileName
End With
End Sub
Private Sub cmdPrint_Click()
Dim A, B, D As Integer
A = 350
B = 500
D = 400
Printer.CurrentX = A + 600
Printer.CurrentY = 200
Printer.FontSize = 16
Printer.Font.Name = "华文行楷"
Printer.Print "员工卡片"
If PicPhoto.Picture <> LoadPicture("") Then
Printer.PaintPicture PicPhoto.Picture, PicPhoto.Left - 1500, PicPhoto.Top + 300
End If
Printer.Font.Name = "宋体"
Printer.FontSize = 10
Printer.CurrentX = A
Printer.CurrentY = B + 200
Printer.Print "编号:" & Txt1(0).text & " 姓名:" & Txt1(1)
B = B + D
Printer.CurrentX = A
Printer.CurrentY = B + 200
Printer.Print "性别:" & Combo1.text & " 身份证号:" & Txt1(2).text
B = B + D
Printer.CurrentX = A
Printer.CurrentY = B + 200
Printer.Print "部门:" & Txt1(11)
B = B + D
Printer.CurrentX = A
Printer.CurrentY = B + 200
Printer.Print "家庭住址:" & Txt1(6).text
B = B + D
Printer.CurrentX = A
Printer.CurrentY = B + 200
Printer.Print "联系电话:" & Txt1(4) & " 手机:" & Txt1(5)
B = B + D
Printer.CurrentX = A
Printer.CurrentY = B + 200
Printer.Print "职务:" & DataCombo5 & " 职称:" & DataCombo6 & " 基本工资:" & Txt1(12)
B = B + D
Printer.CurrentX = A
Printer.CurrentY = B + 200
Printer.Print "调入时间:" & DTP4 & " 登记日期:" & DTP5 & " 登记人:" & Txt1(16)
Printer.EndDoc
End Sub
Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Txt1(2).SetFocus
End Sub
Private Sub Combo2_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then DataCombo2.SetFocus
End Sub
Private Sub DataCombo1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Combo2.SetFocus
End Sub
Private Sub DataCombo2_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then DTP2.SetFocus
End Sub
Private Sub DataCombo3_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Txt1(9).SetFocus
End Sub
Private Sub DataCombo4_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then DataCombo5.SetFocus
End Sub
Private Sub DataCombo5_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then DataCombo6.SetFocus
End Sub
Private Sub DataCombo6_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Txt1(12).SetFocus
End Sub
Private Sub DTP1_Change()
Txt1(17) = DateDiff("yyyy", DTP1.Value, Date)
End Sub
Private Sub DTP1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then DataCombo1.SetFocus
End Sub
Private Sub DTP2_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Txt1(3).SetFocus
End Sub
Private Sub DTP3_Change()
Txt1(10) = Val(Left(Date, 4)) - Val(Left(DTP3, 4))
End Sub
Private Sub DTP3_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Txt1(10).SetFocus
End Sub
Private Sub DTP4_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Txt1(14).SetFocus
End Sub
Private Sub DTP5_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Txt1(16).SetFocus
End Sub
Private Sub Form_Load()
Combo1.AddItem ("男")
Combo1.AddItem ("女")
Combo1.ListIndex = 0
Combo2.AddItem ("未婚")
Combo2.AddItem ("已婚")
Combo2.AddItem ("再婚")
Combo2.ListIndex = 0
If blnAddRS = True Then
Me.Caption = "人事信息添加"
rs1.Open "select * from 人事表 order by 编号", Cnn, adOpenKeyset, adLockOptimistic
If rs1.RecordCount > 0 Then
rs1.MoveLast
Txt1(0) = Format(Val(rs1.Fields("编号")) + 1, "00000")
Else
Txt1(0) = "00001"
End If
rs1.Close
Txt1(16) = czy
Else
Me.Caption = "人事信息修改"
With main_rsgl_rsdaxx.Adodc1.Recordset
If .RecordCount > 0 Then
Txt1(0) = .Fields("编号")
Txt1(1) = .Fields("姓名")
Combo1.text = .Fields("性别")
Txt1(2) = .Fields("身份证号")
DTP1.Value = .Fields("出生年月")
Txt1(17) = .Fields("年龄")
DataCombo1 = .Fields("民族")
Combo2 = .Fields("婚姻状况")
DataCombo2 = .Fields("政治面貌")
DTP2.Value = .Fields("入党团时间")
Txt1(3) = .Fields("籍贯")
Txt1(4) = .Fields("联系电话")
Txt1(5) = .Fields("手机号码")
Txt1(6) = .Fields("家庭地址")
Txt1(7) = .Fields("毕业院校")
Txt1(8) = .Fields("专业")
DataCombo3 = .Fields("文化程度")
Txt1(9) = .Fields("特长")
DTP3.Value = .Fields("参加工作时间")
Txt1(10) = .Fields("总工龄")
Set PicPhoto.DataSource = main_rsgl_rsdaxx.Adodc1
PicPhoto.DataField = "照片"
If .Fields("照片") Is Nothing Then
PicPhoto.Picture = LoadPicture()
End If
Txt1(11) = .Fields("部门")
DataCombo4 = .Fields("工种")
DataCombo5 = .Fields("职务")
DataCombo6 = .Fields("职称")
Txt1(12) = .Fields("基本工资")
Txt1(13) = .Fields("其它工资")
DTP4.Value = .Fields("调入时间")
Txt1(14) = .Fields("本单位工龄")
If .Fields("简历") <> "" Then Txt1(15) = .Fields("简历")
DTP5.Value = .Fields("登记日期")
Txt1(16) = .Fields("登记人")
End If
End With
End If
End Sub
Private Sub Form_Activate()
Txt1(1).SetFocus
If deptMark = 1 Then DataCombo4.SetFocus
End Sub
Private Sub PicPhoto_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then DTP2.SetFocus
End Sub
Private Sub Txt1_GotFocus(index As Integer)
Txt1(index).BackColor = &HFFFF00
Txt1(index).SelStart = 0
Txt1(index).SelLength = Len(Txt1(index))
End Sub
Private Sub Txt1_LostFocus(index As Integer)
Txt1(index).BackColor = &H80000005
End Sub
Private Sub Txt1_KeyDown(index As Integer, KeyCode As Integer, Shift As Integer)
'回车获得焦点
If KeyCode = vbKeyReturn And index > 2 And index < 8 Then Txt1(index + 1).SetFocus
If KeyCode = vbKeyReturn And index = 1 Then Combo1.SetFocus
If KeyCode = vbKeyReturn And index = 2 Then DTP1.SetFocus
If KeyCode = vbKeyReturn And index = 8 Then DataCombo3.SetFocus
If KeyCode = vbKeyReturn And index = 9 Then DTP3.SetFocus
If KeyCode = vbKeyReturn And index = 10 Then Txt1(11).SetFocus
If KeyCode = vbKeyReturn And index = 11 Then cmdDept.SetFocus
If KeyCode = vbKeyReturn And index = 12 Then Txt1(13).SetFocus
If KeyCode = vbKeyReturn And index = 13 Then DTP4.SetFocus
If KeyCode = vbKeyReturn And index = 14 Then Txt1(15).SetFocus
If KeyCode = vbKeyReturn And index = 15 Then DTP5.SetFocus
If KeyCode = vbKeyReturn And index = 16 Then CmdSave.SetFocus
End Sub
Private Sub cmdSave_Click()
Dim A As Long
If blnAddRS = False Then
A = MsgBox("您确实要修改这条数据吗?", vbYesNo)
If A = vbYes Then
rs1.Open "select * from 人事表 where 编号='" + Txt1(0).text + "'", Cnn, adOpenKeyset, adLockOptimistic
If rs1.RecordCount > 0 Then
rs1.Fields("编号") = Txt1(0)
rs1.Fields("姓名") = Txt1(1)
rs1.Fields("性别") = Combo1.text
rs1.Fields("身份证号") = Txt1(2)
rs1.Fields("出生年月") = DTP1.Value
rs1.Fields("年龄") = Txt1(17)
rs1.Fields("民族") = DataCombo1
rs1.Fields("婚姻状况") = Combo2
rs1.Fields("政治面貌") = DataCombo2
rs1.Fields("入党团时间") = DTP2.Value
rs1.Fields("籍贯") = Txt1(3)
rs1.Fields("联系电话") = Txt1(4)
rs1.Fields("手机号码") = Txt1(5)
rs1.Fields("家庭地址") = Txt1(6)
rs1.Fields("毕业院校") = Txt1(7)
rs1.Fields("专业") = Txt1(8)
rs1.Fields("文化程度") = DataCombo3
rs1.Fields("特长") = Txt1(9)
rs1.Fields("参加工作时间") = DTP3.Value
rs1.Fields("总工龄") = Val(Txt1(10))
mst.Type = adTypeBinary
mst.Open
If photoFilename <> "" Then mst.LoadFromFile photoFilename
rs1.Fields("照片") = mst.Read
rs1.Fields("部门") = Txt1(11)
rs1.Fields("工种") = DataCombo4
rs1.Fields("职务") = DataCombo5
rs1.Fields("职称") = DataCombo6
rs1.Fields("基本工资") = Val(Txt1(12))
rs1.Fields("其它工资") = Val(Txt1(13))
rs1.Fields("调入时间") = DTP4.Value
rs1.Fields("本单位工龄") = Val(Txt1(14))
rs1.Fields("简历") = Txt1(15)
rs1.Fields("登记日期") = DTP5.Value
rs1.Fields("登记人") = Txt1(16)
rs1.Update
main_rsgl_rsdaxx.Adodc1.Refresh
End If
rs1.Close
mst.Close
End If
Else
If Txt1(1).text = "" Then
MsgBox "姓名不允许为空!"
Exit Sub
End If
rs1.Open "select * from 人事表", Cnn, adOpenKeyset, adLockOptimistic
'新增人员
rs1.AddNew
rs1.Fields("编号") = Txt1(0)
rs1.Fields("姓名") = Txt1(1)
rs1.Fields("性别") = Combo1.text
rs1.Fields("身份证号") = Txt1(2)
rs1.Fields("出生年月") = DTP1.Value
rs1.Fields("年龄") = Txt1(17)
rs1.Fields("民族") = DataCombo1
rs1.Fields("婚姻状况") = Combo2
rs1.Fields("政治面貌") = DataCombo2
rs1.Fields("入党团时间") = DTP2.Value
rs1.Fields("籍贯") = Txt1(3)
rs1.Fields("联系电话") = Txt1(4)
rs1.Fields("手机号码") = Txt1(5)
rs1.Fields("家庭地址") = Txt1(6)
rs1.Fields("毕业院校") = Txt1(7)
rs1.Fields("专业") = Txt1(8)
rs1.Fields("文化程度") = DataCombo3
rs1.Fields("特长") = Txt1(9)
rs1.Fields("参加工作时间") = DTP3.Value
rs1.Fields("总工龄") = Val(Txt1(10))
mst.Type = adTypeBinary
mst.Open
If photoFilename <> "" Then mst.LoadFromFile photoFilename
rs1.Fields("照片") = mst.Read
rs1.Fields("部门") = Txt1(11)
rs1.Fields("工种") = DataCombo4
rs1.Fields("职务") = DataCombo5
rs1.Fields("职称") = DataCombo6
rs1.Fields("基本工资") = Val(Txt1(12))
rs1.Fields("其它工资") = Val(Txt1(13))
rs1.Fields("调入时间") = DTP4.Value
rs1.Fields("本单位工龄") = Val(Txt1(14))
rs1.Fields("简历") = Txt1(15)
rs1.Fields("登记日期") = DTP5.Value
rs1.Fields("登记人") = Txt1(16)
rs1.Update
main_rsgl_rsdaxx.Adodc1.Refresh
rs1.Close
mst.Close
End If
Unload Me
End Sub
Private Sub CmdEnd_Click()
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -