资源名称:ERPSYS.zip [点击查看]
上传用户:zhpu1995
上传日期:2013-09-06
资源大小:61151k
文件大小:70k
源码类别:
企业管理
开发平台:
Visual Basic
- VERSION 5.00
- Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
- Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "TABCTL32.OCX"
- Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "comdlg32.ocx"
- Begin VB.Form Ed_EmpArInfoFrm
- BorderStyle = 1 'Fixed Single
- Caption = "人事信息维护"
- ClientHeight = 8475
- ClientLeft = 1035
- ClientTop = 1155
- ClientWidth = 11910
- HelpContextID = 2213001
- Icon = "处理_个人档案维护.frx":0000
- KeyPreview = -1 'True
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 8475
- ScaleMode = 0 'User
- ScaleWidth = 11910
- StartUpPosition = 2 '屏幕中心
- Begin MSComctlLib.Toolbar SzToolbar
- Align = 1 'Align Top
- Height = 555
- Left = 0
- TabIndex = 5
- Top = 0
- Width = 11910
- _ExtentX = 21008
- _ExtentY = 979
- ButtonWidth = 820
- ButtonHeight = 926
- Appearance = 1
- Style = 1
- ImageList = "ImageList1"
- _Version = 393216
- BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628}
- NumButtons = 23
- BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "设置"
- Key = "PrinterSet"
- ImageIndex = 2
- EndProperty
- BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "打印"
- Key = "Printer"
- ImageIndex = 6
- EndProperty
- BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "预览"
- Key = "Preview"
- ImageIndex = 7
- EndProperty
- BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Style = 3
- EndProperty
- BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "新增"
- Key = "New"
- Object.ToolTipText = "快捷键 Ctrl-A"
- ImageIndex = 8
- EndProperty
- BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "修改"
- Key = "Modi"
- Object.ToolTipText = "快捷键 Ctrl-E"
- ImageIndex = 9
- EndProperty
- BeginProperty Button7 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "删除"
- Key = "Del"
- Object.ToolTipText = "快捷键 Del"
- ImageIndex = 10
- EndProperty
- BeginProperty Button8 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Style = 3
- EndProperty
- BeginProperty Button9 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "保存"
- Key = "Save"
- Object.ToolTipText = "快捷键 Ctrl-S"
- ImageIndex = 13
- EndProperty
- BeginProperty Button10 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "取消"
- Key = "Cancel"
- Object.ToolTipText = "快捷键 Esc"
- ImageIndex = 19
- EndProperty
- BeginProperty Button11 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Object.Visible = 0 'False
- ImageIndex = 11
- Style = 3
- EndProperty
- BeginProperty Button12 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Object.Visible = 0 'False
- Caption = "刷新"
- Key = "Refresh"
- ImageIndex = 11
- EndProperty
- BeginProperty Button13 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Key = "sp"
- Style = 3
- EndProperty
- BeginProperty Button14 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "首个"
- Key = "First"
- Object.ToolTipText = "快捷键 Ctrl-Home"
- ImageIndex = 14
- EndProperty
- BeginProperty Button15 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "向前"
- Key = "Previous"
- Object.ToolTipText = "快捷键 Ctrl-PageUp"
- ImageIndex = 15
- EndProperty
- BeginProperty Button16 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "向后"
- Key = "Next"
- Object.ToolTipText = "快捷键 Ctrl-PageDown"
- ImageIndex = 16
- EndProperty
- BeginProperty Button17 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "末尾"
- Key = "Last"
- Object.ToolTipText = "快捷键 Ctrl-End"
- ImageIndex = 17
- EndProperty
- BeginProperty Button18 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Style = 3
- EndProperty
- BeginProperty Button19 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Object.Visible = 0 'False
- Caption = "过滤"
- Key = "Filt"
- ImageIndex = 5
- EndProperty
- BeginProperty Button20 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "设定"
- Key = "Set"
- ImageIndex = 4
- EndProperty
- BeginProperty Button21 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Style = 3
- EndProperty
- BeginProperty Button22 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "帮助"
- Key = "Help"
- ImageIndex = 18
- EndProperty
- BeginProperty Button23 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "退出"
- Key = "Exit"
- ImageIndex = 12
- EndProperty
- EndProperty
- BorderStyle = 1
- Begin MSComctlLib.ImageList ImageList1
- Left = 8910
- Top = 135
- _ExtentX = 1005
- _ExtentY = 1005
- BackColor = -2147483643
- ImageWidth = 16
- ImageHeight = 16
- MaskColor = 12632256
- _Version = 393216
- BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
- NumListImages = 19
- BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "处理_个人档案维护.frx":1042
- Key = "RelationAr"
- EndProperty
- BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "处理_个人档案维护.frx":13DC
- Key = "PrinterSet"
- EndProperty
- BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "处理_个人档案维护.frx":1776
- Key = ""
- EndProperty
- BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "处理_个人档案维护.frx":1B10
- Key = "Set"
- EndProperty
- BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "处理_个人档案维护.frx":1EAA
- Key = "Filt"
- EndProperty
- BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "处理_个人档案维护.frx":2244
- Key = "Printer"
- EndProperty
- BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "处理_个人档案维护.frx":25DE
- Key = "Preview"
- EndProperty
- BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "处理_个人档案维护.frx":2978
- Key = "New"
- EndProperty
- BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "处理_个人档案维护.frx":2D12
- Key = "Modi"
- EndProperty
- BeginProperty ListImage10 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "处理_个人档案维护.frx":30AC
- Key = "Del"
- EndProperty
- BeginProperty ListImage11 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "处理_个人档案维护.frx":3446
- Key = "Refresh"
- EndProperty
- BeginProperty ListImage12 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "处理_个人档案维护.frx":37E0
- Key = "Exit"
- EndProperty
- BeginProperty ListImage13 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "处理_个人档案维护.frx":3B7A
- Key = "Save"
- EndProperty
- BeginProperty ListImage14 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "处理_个人档案维护.frx":3F14
- Key = "First"
- EndProperty
- BeginProperty ListImage15 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "处理_个人档案维护.frx":42AE
- Key = "Previous"
- EndProperty
- BeginProperty ListImage16 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "处理_个人档案维护.frx":4648
- Key = "Next"
- EndProperty
- BeginProperty ListImage17 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "处理_个人档案维护.frx":49E2
- Key = "Last"
- EndProperty
- BeginProperty ListImage18 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "处理_个人档案维护.frx":4D7C
- Key = "Help"
- EndProperty
- BeginProperty ListImage19 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "处理_个人档案维护.frx":5116
- Key = ""
- EndProperty
- EndProperty
- End
- End
- Begin TabDlg.SSTab SSTab1
- Height = 7860
- Left = 0
- TabIndex = 1
- TabStop = 0 'False
- Top = 630
- Width = 11850
- _ExtentX = 20902
- _ExtentY = 13864
- _Version = 393216
- Style = 1
- Tabs = 1
- TabsPerRow = 4
- TabHeight = 520
- MouseIcon = "处理_个人档案维护.frx":54B0
- BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
- Name = "宋体"
- Size = 9
- Charset = 134
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- TabCaption(0) = "基本信息"
- TabPicture(0) = "处理_个人档案维护.frx":54CC
- Tab(0).ControlEnabled= -1 'True
- Tab(0).Control(0)= "lID"
- Tab(0).Control(0).Enabled= 0 'False
- Tab(0).Control(1)= "lpId"
- Tab(0).Control(1).Enabled= 0 'False
- Tab(0).Control(2)= "Picture1"
- Tab(0).Control(2).Enabled= 0 'False
- Tab(0).ControlCount= 3
- Begin VB.PictureBox Picture1
- Height = 7365
- Left = 90
- ScaleHeight = 7305
- ScaleWidth = 11595
- TabIndex = 2
- TabStop = 0 'False
- Top = 390
- Width = 11655
- Begin VB.VScrollBar VScBar
- Height = 7305
- Left = 11250
- Max = 3
- TabIndex = 6
- TabStop = 0 'False
- Top = 0
- Width = 286
- End
- Begin VB.PictureBox Pict
- BackColor = &H00E9F2F3&
- BorderStyle = 0 'None
- Height = 50000
- Left = 0
- ScaleHeight = 49995
- ScaleMode = 0 'User
- ScaleWidth = 11475
- TabIndex = 3
- TabStop = 0 'False
- Top = -30
- Width = 11475
- Begin VB.CheckBox Chk_YNStop
- BackColor = &H00E9F2F3&
- Height = 285
- Left = 3330
- TabIndex = 9
- Top = 750
- Visible = 0 'False
- Width = 2610
- End
- Begin MSComDlg.CommonDialog CommDlg_pic
- Left = 6525
- Top = 2655
- _ExtentX = 847
- _ExtentY = 847
- _Version = 393216
- Filter = "Pictures (*.bmp)|*.bmp"
- End
- Begin VB.PictureBox Pic_Emp
- BackColor = &H80000018&
- Height = 1395
- Left = 9840
- ScaleHeight = 1335
- ScaleWidth = 1110
- TabIndex = 8
- TabStop = 0 'False
- ToolTipText = "双击鼠标左键更改照片信息"
- Top = 270
- Width = 1170
- End
- Begin VB.CommandButton Cmd_CommHlp
- Height = 300
- Index = 0
- Left = 2310
- Picture = "处理_个人档案维护.frx":54E8
- Style = 1 'Graphical
- TabIndex = 7
- TabStop = 0 'False
- Top = 780
- Visible = 0 'False
- Width = 300
- End
- Begin VB.TextBox Txt_RsItm
- BackColor = &H00FFFFFF&
- BeginProperty DataFormat
- Type = 0
- Format = "tt hh:mm:ss"
- HaveTrueFalseNull= 0
- FirstDayOfWeek = 0
- FirstWeekOfYear = 0
- LCID = 2052
- SubFormatType = 0
- EndProperty
- ForeColor = &H00000000&
- Height = 300
- Index = 0
- Left = 858
- TabIndex = 0
- Top = 769
- Visible = 0 'False
- Width = 1474
- End
- Begin VB.Label Lbl_ItmName
- AutoSize = -1 'True
- BackColor = &H00E9F2F3&
- BackStyle = 0 'Transparent
- Caption = "编号"
- Height = 180
- Index = 0
- Left = 405
- TabIndex = 4
- Top = 810
- Visible = 0 'False
- Width = 360
- End
- End
- End
- Begin VB.Label lpId
- BackColor = &H000000FF&
- Caption = "PrevEmpId"
- BeginProperty Font
- Name = "宋体"
- Size = 9
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H8000000E&
- Height = 225
- Left = 2520
- TabIndex = 11
- Top = 30
- Visible = 0 'False
- Width = 1425
- End
- Begin VB.Label lID
- BackColor = &H00FF80FF&
- Caption = "CurrentEmpID"
- BeginProperty Font
- Name = "宋体"
- Size = 9
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H00FFFFFF&
- Height = 225
- Left = 4470
- TabIndex = 10
- Top = 30
- Visible = 0 'False
- Width = 1425
- End
- End
- End
- Attribute VB_Name = "Ed_EmpArInfoFrm"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Option Explicit
- Dim H_MoveInt As Integer '当前鼠标所处的位置
- Dim Com_ListIndexTF As Boolean
- Dim ReportTitle As String '报表主标题(Fixed)
- Dim Saved As Boolean '已经保存
- Dim PrintSetFrm As New DY_Dyymsz
- Dim ScollBarIsEffect As Boolean '滚动条是否有效
- Dim VScLastP As Integer '上一次滚动的值
- Dim Str_RightEdit As String '编辑(新增、修改、删除)权限索引
- Dim Str_RightCase As String '档案权限索引
- Dim tIsCode() '二维数组,一维存储是否编码(1是0否),2维存储编码
- Dim tSysROnly() As Boolean '工资只读
- Dim tReserved() As Boolean '是否是保留项,对应项目表里的YNRserve字段
- Dim tFixed() As Boolean '固定字段,这里用来区分不同表
- Dim tItmId() As Integer '人事项目表里的项目代号 对应原来的帮助按钮.tag
- Dim tDataType() As Integer '数据类型 对应原来的文本框.tag
- Dim tFieldName() As String '字段名称 对应原来的标签.tag
- Dim FileName As String '存储图片文件的文件名
- Dim Lrzt As Integer '录入状态标志(0-非录入状态 1-增加 2-修改)
- Public EmpID As Integer
- Dim QuerySet As New ADODB.Recordset '保存查询结果的记录集
- Public ReserveId As Integer
- Public QuerySql As String
- Public FormOwner As String '标示本窗体的调用者 Self // Query
- Public SysOwner As Integer '标示本窗体是人事系统还是工资系统 0--rs,1--pm
- Public ReserveIsOn As Boolean '表示保留项目功能状态
- Private Sub Chk_YNStop_GotFocus()
- Dim i As Integer
- If Lrzt = 0 Then
- Exit Sub
- End If
- '隐藏失去焦点的帮助按钮
- For i = 1 To Cmd_CommHlp.UBound
- Cmd_CommHlp(i).Visible = False
- Next i
- End Sub
- Private Sub Chk_YNStop_KeyPress(KeyAscii As Integer)
- If KeyAscii = 13 Then
- SendKeys "{Tab}"
- End If
- End Sub
- Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
- If Shift = 2 Then
- With Me.SzToolbar
- Select Case KeyCode
- Case vbKeyA '新增 Ctrl-A
- If .Buttons("New").Visible And .Buttons("New").Enabled Then
- Call SzToolbar_ButtonClick(.Buttons("New"))
- End If
- Case vbKeyE '修改 Ctrl-E
- If .Buttons("Modi").Visible And .Buttons("Modi").Enabled Then
- Call SzToolbar_ButtonClick(.Buttons("Modi"))
- End If
- Case vbKeyS '保存 Ctrl-S
- If .Buttons("Save").Visible And .Buttons("Save").Enabled Then
- Call SzToolbar_ButtonClick(.Buttons("Save"))
- End If
- Case vbKeyHome '首个 Ctrl-Home
- If .Buttons("First").Visible And .Buttons("First").Enabled Then
- Call SzToolbar_ButtonClick(.Buttons("First"))
- End If
- Case vbKeyPageUp '上个 Ctrl-PageUp
- If .Buttons("Previous").Visible And .Buttons("Previous").Enabled Then
- Call SzToolbar_ButtonClick(.Buttons("Previous"))
- End If
- Case vbKeyPageDown '下个 Ctrl-PageDown
- If .Buttons("Next").Visible And .Buttons("Next").Enabled Then
- Call SzToolbar_ButtonClick(.Buttons("Next"))
- End If
- Case vbKeyEnd '末尾 Ctrl-End
- If .Buttons("Last").Visible And .Buttons("Last").Enabled Then
- Call SzToolbar_ButtonClick(.Buttons("Last"))
- End If
- End Select
- End With
- End If
- If KeyCode = vbKeyEscape Then '取消 Escape
- If SzToolbar.Buttons("Cancel").Visible And SzToolbar.Buttons("Cancel").Enabled Then
- Call SzToolbar_ButtonClick(SzToolbar.Buttons("Cancel"))
- End If
- End If
- If KeyCode = vbKeyDelete Then '删除 Delete
- If SzToolbar.Buttons("Del").Visible And SzToolbar.Buttons("Del").Enabled Then
- Call SzToolbar_ButtonClick(SzToolbar.Buttons("Del"))
- End If
- End If
- End Sub
- '=========================通用部分==================================
- Public Sub Form_Load()
- Dim i As Integer
- Dim tmpRs As New ADODB.Recordset
- '--------------------------两种调用共有----------------------------
- ReportTitle = "人事基本信息"
- XtReportCode = "Rs_EdArInfo"
- ReserveIsOn = False
- Call CreateCtrls(SysOwner)
- ReserveIsOn = False
- '--------------------------直接调用处理----------------------------
- If FormOwner = "Self" Then
- Me.Tag = "Init"
- EmpID = 0
- lID.Caption = EmpID
- SwitchToolBar ("0")
- SzToolbar.Buttons("First").Visible = False '首张
- SzToolbar.Buttons("Previous").Visible = False '上张
- SzToolbar.Buttons("Next").Visible = False '下张
- SzToolbar.Buttons("Last").Visible = False '末张
- SzToolbar.Buttons("sp").Visible = False '分隔
- Call SetTxtStatus(False, True, False, Lrzt)
- End If
- '------------------------查询调用处理--------------------------------
- If FormOwner = "Query" Then
- lID.Caption = EmpID
- lpId.Caption = lID.Caption
- Xtfhcs = ""
- Set QuerySet = Cw_DataEnvi.DataConnect.Execute(QuerySql)
- QuerySet.Find "Rs_BasicInfo#EmpID = " & EmpID
- Call SetTxtStatus(True, True, False, Lrzt)
- LoadData (EmpID)
- SwitchToolBar ("0")
- End If
- '-----------------------------其他-----------------------------------
- If SysOwner = 1 Then
- SzToolbar.Buttons("New").Visible = False
- SzToolbar.Buttons("Del").Visible = False
- End If
- Set tmpRs = Cw_DataEnvi.DataConnect.Execute("SELECT ItemParameter FROM Rs_OtherSet WHERE ItemName = 'ReserveID' ")
- If Not tmpRs.EOF Then ReserveId = tmpRs.Fields("ItemParameter")
- '编辑(新增、修改、删除)权限索引
- Str_RightEdit = "Rs_Ed_EmpArInfo_Edit"
- '档案权限
- Str_RightCase = "Rs_Ed_EmpArInfo_archives"
- End Sub
- Private Sub Txt_RsItm_GotFocus(Index As Integer)
- Dim i As Integer
- If Lrzt = 0 Then
- Exit Sub
- End If
- '使文本框可见
- Pi_move Txt_RsItm(Index)
- '首先隐藏失去焦点的帮助按钮
- For i = 1 To Cmd_CommHlp.UBound
- If Cmd_CommHlp(i).Visible = True Then
- Cmd_CommHlp(i).Visible = False
- End If
- Next i
- '然后根据帮助按钮的有效与否,在得到焦点的文本框旁边显示帮助按钮
- If (Cmd_CommHlp(Index).Tag = 1) Or (Cmd_CommHlp(Index).Tag = 2 And Lrzt = 2) Then Cmd_CommHlp(Index).Visible = True
- End Sub
- Private Sub Pic_Emp_DblClick()
- '调用通用打开文件对话框,选定文件
- CommDlg_pic.ShowOpen
- On Error GoTo errD
- If Trim(CommDlg_pic.FileName) <> "" Then
- Pic_Emp.Picture = LoadPicture(CommDlg_pic.FileName)
- Pic_Emp.Tag = Trim(CommDlg_pic.FileName)
- End If
- errD:
- End Sub
- Public Sub Txt_RsItm_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
- '焦点移动处理 KeyCode=113 是 F2
- Dim tmpRs As New ADODB.Recordset
- Dim EmpNo As String
- If KeyCode = 113 And Cmd_CommHlp(Index).Tag <> 0 Then
- Cmd_CommHlp_Click (Index)
- End If
- If KeyCode = 13 Then
- If UCase(tFieldName(Index)) = "EMPNO" And Cmd_CommHlp(Index).Visible = True Then
- EmpNo = Trim(Txt_RsItm(Index).Text)
- EmpID = GetIdByNo(EmpNo)
- If EmpID = 0 Then Call Xtxxts("该职工号无效!", 0, 1): Exit Sub
- Call LoadData(EmpID)
- Call SetTxtStatus(False, False, False, Lrzt)
- Exit Sub
- End If
- SendKeys "{Tab}", True
- End If
- End Sub
- Private Sub Txt_RsItm_KeyPress(Index As Integer, KeyAscii As Integer)
- '判断输入的有效性
- If KeyAscii = 39 Then KeyAscii = 0
- Select Case tDataType(Index)
- Case 2
- Call InputFieldLimit(Txt_RsItm(Index), 7, KeyAscii)
- Case 1
- Call InputFieldLimit(Txt_RsItm(Index), 6, KeyAscii)
- Case 5 '控制数字型录入
- Call InputFieldLimit(Txt_RsItm(Index), 5, KeyAscii)
- End Select
- End Sub
- Private Sub Txt_RsItm_LostFocus(Index As Integer)
- '失去焦点时作有效判断
- Call DataIsEffect(Index)
- End Sub
- Private Sub Pi_move(ob As Object) '屏幕滚动
- Dim i As Integer
- Dim lPos As Long
- For i = Me.VScBar.Min To Me.VScBar.Max
- If ob.Top >= i * (Me.Height - 2000) And ob.Top <= (i + 1) * (Me.Height - 2000) Then
- Exit For
- End If
- Next i
- If i <= Me.VScBar.Max And i <> Me.VScBar Then
- Me.VScBar.Value = i
- End If
- End Sub
- Private Sub Cmd_CommHlp_MouseMove(Index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single)
- H_MoveInt = Index
- End Sub
- Private Function SavePic2DB(ByVal rs As ADODB.Recordset, ByVal emp_id As String) As Boolean
- '把图片文件以字节形式存储进数据库
- ' note: this requires the record to already exist - it will insert the
- ' picture at the current position in the recordset
- ' Returns true if success - false otherwise
- Const BlockSize = 15000
- Dim ByteData() As Byte '存储图片文件的字节数组
- Dim SourceFile As Integer
- Dim FileLength As Long
- Dim Numblocks As Integer
- Dim LeftOver As Long: Dim s As Integer
- On Error GoTo Line1
- With Pic_Emp
- SourceFile = FreeFile
- '以二进制形式打开文件
- Open .Tag For Binary Access Read As SourceFile
- '获得文件长度
- FileLength = LOF(SourceFile)
- If FileLength = 0 Then '字节数为0,退出
- Close SourceFile
- SavePic2DB = False
- Exit Function
- Else
- '首先分解图片为几块
- Numblocks = FileLength BlockSize
- LeftOver = FileLength Mod BlockSize
- ReDim ByteData(LeftOver)
- '读取文件到数组
- Get SourceFile, , ByteData()
- rs.Fields("Pic").AppendChunk ByteData()
- ReDim ByteData(BlockSize)
- For s = 1 To Numblocks
- Get SourceFile, , ByteData()
- rs.Fields("Pic").AppendChunk ByteData()
- Next s
- rs.Update
- '存储成功,返回true
- Close SourceFile
- SavePic2DB = True
- End If
- End With
- Line1:
- End Function
- Public Function getPicture(strPicField As String, ByVal rs As ADODB.Recordset) As Boolean
- '从数据库读取图片,生成磁盘文件
- Const BlockSize = 15000
- Dim ByteData() As Byte '以二进制形式存储图片的字节数组
- Dim DestFileNum As Integer
- Dim DiskFile As String
- Dim FileLength As Long '图片文件的长度
- Dim Numblocks As Integer '图片的块数
- Dim LeftOver As Long '剩余部分
- Dim i As Integer
- On Error GoTo Line1
- '删除已存在的图形文件
- DiskFile = App.Path & "temp.bmp"
- If Len(Dir$(DiskFile)) > 0 Then
- Kill DiskFile
- End If
- '把图片文件分解成几部分
- DestFileNum = FreeFile
- FileLength = rs.Fields(strPicField).ActualSize
- Numblocks = FileLength BlockSize
- LeftOver = FileLength Mod BlockSize
- '打开文件,开始按块存入数据库
- Open DiskFile For Binary As DestFileNum
- rs.Move 0, adBookmarkCurrent
- ByteData() = rs.Fields(strPicField).GetChunk(LeftOver)
- Put DestFileNum, , ByteData()
- For i = 1 To Numblocks
- ByteData() = rs.Fields(strPicField).GetChunk(BlockSize)
- Put DestFileNum, , ByteData()
- Next i
- Close DestFileNum
- getPicture = True
- Line1:
- End Function
- Private Sub Cmd_CommHlp_Click(Index As Integer)
- '基本信息输入调用帮助,通用根据情况调用不同类型的帮助
- Dim s As String
- Dim i As Integer
- ' ------------------------工号选人----------------------------------------
- If UCase(tFieldName(Index)) = "EMPNO" Then
- SsqlHelp = "Emp"
- Ed_EmpArInfoCorHlp.Show 1
- If Trim(P_Code) <> "" Then
- Txt_RsItm(Index).Text = P_Code
- EmpID = Xtfhcs
- Xtfhcs = ""
- LoadData (EmpID)
- Else
- Exit Sub
- End If
- Call SetTxtStatus(False, False, False, Lrzt)
- For i = 1 To Lbl_ItmName.UBound
- If Txt_RsItm(i).Enabled Then Txt_RsItm(i).SetFocus: Exit For
- Next i
- Exit Sub
- End If
- ' ------------------------日期性帮助--------------------------------------
- If tDataType(Index) = 7 Then
- Xtfhcs = ""
- XT_calendar.Show 1
- If Xtfhcs <> "" Then
- Txt_RsItm(Index).Text = Xtfhcs
- Xtfhcs = ""
- End If
- Txt_RsItm(Index).SetFocus
- Exit Sub
- End If
- ' ---------------------------其他帮助------------------------------------
- SsqlHelp = Str(tItmId(Index))
- Ed_EmpArInfoCorHlp.Show 1
- If P_Name <> "" Then
- Txt_RsItm(Index).Text = P_Name
- tIsCode(2, Index) = P_Code
- P_Name = ""
- P_Code = ""
- End If
- If Txt_RsItm(Index).Enabled = True Then Txt_RsItm(Index).SetFocus
- End Sub
- Private Sub VScBar_Change() '滚动条
- If ScollBarIsEffect = True Then
- Me.Pict.Top = -(Me.VScBar.Value * (Me.Height - 2000))
- End If
- End Sub
- '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- Private Sub SzToolbar_ButtonClick(ByVal Button As MSComctlLib.Button)
- '对工具条按钮的不同处理
- Dim i As Integer
- Select Case Button.Key
- Case "PrinterSet" '打印设置
- PrintSetFrm.Show 1
- Case "Printer" '打印
- DY_DytsFrm.Show 1
- Case "Preview" '预览
- Print_EmpInfo
- Case "New" '新增
- '判断用户是否有此功能执行权限,如有则写上机日志(进入)
- If Not Security_Log(Str_RightEdit, Xtczybm, 1, True) Then
- Exit Sub
- End If
- Call MF_New
- Case "Modi" '修改
- '判断用户是否有此功能执行权限,如有则写上机日志(进入)
- If Not Security_Log(Str_RightEdit, Xtczybm, 1, True) Then
- Exit Sub
- End If
- Call MF_Modi
- Case "Del" '删除
- '判断用户是否有此功能执行权限,如有则写上机日志(进入)
- If Not Security_Log(Str_RightEdit, Xtczybm, 1, True) Then
- Exit Sub
- End If
- Call MF_Del
- Case "Save" '保存
- Call MF_Save
- Case "Cancel" '取消
- Call MF_Cancel
- Case "Refresh"
- Case "First" '首个
- Move_Cursor (Button.Key)
- Case "Previous" '上一个
- Move_Cursor (Button.Key)
- Case "Next" '下一个
- Move_Cursor (Button.Key)
- Case "Last" '末尾
- Move_Cursor (Button.Key)
- Case "Set" '设定
- '判断用户是否有此功能执行权限,如有则写上机日志(进入)
- If Not Security_Log(Str_RightEdit, Xtczybm, 1, True) Then
- Exit Sub
- End If
- Ed_EmpArInfoSetFrm.Show 1
- Call SetReserve
- Case "Help" '帮助
- Call F1bz
- Case "Exit" '退出
- Unload Me
- End Select
- Exit Sub
- Err_Del:
- End Sub
- '========================自定义过程=================================
- Private Function MF_New() As Boolean
- '供工具条按钮调用的函数(新增记录),成功返回真,否则假
- MF_New = False
- On Error GoTo errD
- Lrzt = 1
- EmpID = 0
- SwitchToolBar ("1")
- Call SetTxtStatus(True, False, False, Lrzt)
- ReserveItmRefurbish
- With Me.Txt_RsItm(1)
- If .Enabled And .Visible Then
- .SetFocus
- End If
- End With
- MF_New = True
- errD:
- End Function
- Private Function MF_Del() As Boolean
- '供工具条按钮调用的函数(删除记录),成功返回真,否则假
- MF_Del = False
- On Error GoTo errD
- If Not DelArRec(EmpID) Then Exit Function
- Lrzt = 0
- If UCase(FormOwner) = "SELF" Then
- Call SetTxtStatus(True, True, False, Lrzt)
- Else
- lID.Caption = lpId.Caption
- EmpID = lID.Caption
- LoadData (EmpID)
- Call SetTxtStatus(False, True, False, Lrzt)
- If QuerySet.State = 1 Then QuerySet.Close
- Set QuerySet = Cw_DataEnvi.DataConnect.Execute(QuerySql)
- QuerySet.Find "Rs_BasicInfo#EmpID = " & EmpID
- Qr_RsBasicFrm.BeenModify = True
- End If
- MF_Del = True
- errD:
- End Function
- Private Function MF_Modi() As Boolean
- '供工具条按钮调用的函数(删除记录),成功返回真,否则假
- Dim i As Integer
- MF_Modi = False
- On Error GoTo errD
- Lrzt = 2
- SwitchToolBar (Lrzt)
- If UCase(FormOwner) = "SELF" Then '窗体是自己打开的
- Call SetTxtStatus(False, True, True, Lrzt)
- Else '窗体是经过查询结果调用生成的
- Call SetTxtStatus(False, False, False, Lrzt)
- End If
- For i = 1 To Lbl_ItmName.UBound
- If Txt_RsItm(i).Enabled Then Txt_RsItm(i).SetFocus: Exit For
- Next i
- MF_Modi = True
- Exit Function
- errD:
- End Function
- Private Function MF_Cancel() As Boolean
- '供工具条按钮调用的函数(取消动作处理),成功返回真,否则假
- MF_Cancel = False
- On Error GoTo errD
- If UCase(FormOwner) = "SELF" Then '窗体是自己打开的
- EmpID = 0
- SwitchToolBar (0)
- Call SetTxtStatus(True, True, False, Lrzt)
- Else '窗体是经过查询结果调用生成的
- If Lrzt = 1 Then '从增加状态返回
- SwitchToolBar (0)
- EmpID = lID.Caption
- LoadData (EmpID)
- Call SetTxtStatus(False, True, False, Lrzt)
- End If
- If Lrzt = 2 Then '从修改状态返回
- SwitchToolBar (0)
- Call SetTxtStatus(False, True, False, Lrzt)
- End If
- End If
- Lrzt = 0
- MF_Cancel = True
- errD:
- End Function
- Private Function MF_Save() As Boolean
- '供工具条按钮调用的函数(保存记录),成功返回真,否则假
- MF_Save = False
- On Error GoTo errD
- If Lrzt = 2 And EmpID = 0 Then Exit Function '修改并且还没有选人的时候
- If DataIsEffect(0) Then Call Save
- If Saved Then
- Call Xtxxts("保存成功!", 0, 4)
- SwitchToolBar (0)
- lpId.Caption = lID.Caption
- lID.Caption = EmpID
- Call SetTxtStatus(False, True, False, Lrzt)
- Lrzt = 0
- ' 如果是查询模式,要刷新记录集a
- If FormOwner = "Query" Then
- If QuerySet.State = 1 Then QuerySet.Close
- Set QuerySet = Cw_DataEnvi.DataConnect.Execute(QuerySql)
- QuerySet.Find "Rs_BasicInfo#EmpID = " & EmpID
- Qr_RsBasicFrm.BeenModify = True
- End If
- Saved = False
- MF_Save = True
- Else
- Call Xtxxts("保存失败!", 0, 1)
- End If
- errD:
- End Function
- Private Function CorHlpIsEffect(sItmID As String, StrText As String) As Boolean
- '校验相关项填写的正确性
- '参数说明:sItmID是项目编号,StrText是要校验的内容,可以是编码或是对应条目
- Dim RsRec As New Recordset
- Dim sSql As String
- Dim RsItm As New Recordset
- CorHlpIsEffect = False
- '选取文本框对应的人事项目,得到相关项的信息
- Set RsItm = Cw_DataEnvi.DataConnect.Execute("SELECT * FROM Rs_Items WHERE itemId=" & sItmID)
- If Not IsNumeric(Trim(StrText)) Then '对数字型的相关明细代号 '相关项当对应文本框输入编码的情况
- If Trim(RsItm!CorTable) = "Rs_CorSub" Then '首先根据项目名进行查询
- sSql = "SELECT * FROM Rs_CorMain m,Rs_CorSub s WHERE " _
- & "m.SortId=s.SortId AND m.SortId='" & Trim(RsItm!Correlation) & "' AND listname='" & Trim(StrText) & "'"
- Else
- If UCase(Trim(RsItm!CorTable)) <> "GY_DEPARTMENT" Then
- sSql = "SELECT * FROM " & RsItm!CorTable & " WHERE " & RsItm!IndexName & "='" & Trim(StrText) & "'"
- Else
- sSql = "SELECT * FROM " & RsItm!CorTable & " WHERE " & RsItm!IndexName & " like '" & Trim(StrText) & "'"
- End If
- End If
- Else '相关项当文本框输入编码对应文本的情况
- If Trim(RsItm!CorTable) = "Rs_CorSub" Then
- sSql = "SELECT * FROM Rs_CorMain m,Rs_CorSub s WHERE " _
- & "m.SortId=s.SortId AND m.SortId='" & Trim(RsItm!Correlation) & "' AND convert(int,(right(convert(varchar(12),listid),3)))='" & Trim(StrText) & "'"
- Else
- If UCase(Trim(RsItm!CorTable)) <> "GY_DEPARTMENT" Then
- sSql = "SELECT * FROM " & Trim(RsItm!CorTable) & " WHERE " & RsItm!IndexCode & "='" & Trim(StrText) & "'"
- Else
- sSql = "SELECT * FROM " & Trim(RsItm!CorTable) & " WHERE " & RsItm!IndexCode & " like '" & Trim(StrText) & "%'"
- End If
- End If
- End If
- Set RsRec = Cw_DataEnvi.DataConnect.Execute(sSql)
- If UCase(Trim(RsItm!CorTable)) = "GY_DEPARTMENT" Then '部门组织的相关帮助必须录入末级节点,所以 >1是不可以的
- If RsRec.RecordCount = 1 Then CorHlpIsEffect = True
- Else
- If RsRec.RecordCount > 0 Then CorHlpIsEffect = True
- End If
- If CorHlpIsEffect Then '找到相关项时
- If Trim(RsItm!CorTable) = "Rs_CorSub" Then '标准情况:相关项存在Rs_CorSub里
- P_Name = RsRec!ListName
- P_Code = RsRec!ListID
- Else '相关项存在其他表里
- P_Name = Trim(RsRec(Trim(RsItm!IndexName)))
- P_Code = RsRec(Trim(RsItm!IndexCode))
- End If
- End If
- If RsItm.State = 1 Then
- RsItm.Close
- Set RsItm = Nothing
- End If
- '关闭记录集,退出
- RsRec.Close
- Exit Function
- End Function
- Private Function DataIsEffect(Index As Integer) As Boolean
- '有效性判定,控制较松,除工号,姓名,部门以外其他都可以不录
- 'index 表示需要做有效性校验的对象序号,如果index=0 则表示对所有的文本框做有效性校验
- Dim i As Integer
- Dim Tsxx As String
- DataIsEffect = False
- '文本框有效性判定
- If Index = 0 Then '对所有文本框进行校验
- For i = 1 To Lbl_ItmName.UBound
- If UCase(tFieldName(i)) = "EMPNO" And (Trim(Txt_RsItm(i).Text) = "") Then
- Call Xtxxts("职工号不能为空!", 0, 1)
- If Txt_RsItm(i).Enabled Then Txt_RsItm(i).SetFocus
- Exit Function
- End If
- If Lrzt = 1 Then
- If UCase(tFieldName(i)) = "EMPNO" And GetIdByNo(Trim(Txt_RsItm(i).Text)) <> 0 Then
- Call Xtxxts("职工号重复!", 0, 1): Exit Function
- End If
- End If
- If UCase(tFieldName(i)) = "EMPNAME" And (Trim(Txt_RsItm(i).Text) = "") Then
- Call Xtxxts("职工姓名不能为空!", 0, 1)
- If Txt_RsItm(i).Enabled Then Txt_RsItm(i).SetFocus
- Exit Function
- End If
- If UCase(tFieldName(i)) = "DEPTCODE" And Trim(Txt_RsItm(i).Text) = "" Then
- Call Xtxxts("部门不能为空!", 0, 1)
- If Txt_RsItm(i).Enabled Then Txt_RsItm(i).SetFocus
- Exit Function
- End If
- If tDataType(i) = 7 And Trim(Txt_RsItm(i).Text) <> "" Then
- If IsDate(Txt_RsItm(i)) = False Then
- Call Xtxxts("非法日期格式! ——" & Format(Date, "yyyy-mm-dd"), 0, 1)
- If Txt_RsItm(i).Enabled Then Txt_RsItm(i).SetFocus
- Exit Function
- End If
- End If
- If tDataType(i) = 5 And Trim(Txt_RsItm(i).Text) <> "" Then
- If IsNumeric(Txt_RsItm(i)) = False Then
- Call Xtxxts("录入数据不是数字!", 0, 1)
- If Txt_RsItm(i).Enabled Then Txt_RsItm(i).SetFocus
- Exit Function
- End If
- End If
- If tIsCode(1, i) = 1 Then '对编码型的数据只要不为空,就要检测有效性
- If tDataType(i) <> 7 Then
- If Trim(Txt_RsItm(i).Text) <> "" Then
- If CorHlpIsEffect(Str(tItmId(i)), Trim(Txt_RsItm(i).Text)) = True Then
- Txt_RsItm(i).Text = Trim(P_Name)
- tIsCode(2, i) = Trim(P_Code)
- Else
- Call Xtxxts("非法录入,没有此" & Lbl_ItmName(Index).Caption, 0, 1)
- If Txt_RsItm(i).Enabled Then Txt_RsItm(i).SetFocus
- Exit Function
- End If
- Else
- tIsCode(2, i) = ""
- End If
- End If
- End If
- Next i
- Else '只对txt_RsItm(index)校验
- If Cmd_CommHlp(Index).Tag = 1 Then ' 备注: 除此以外 还要针对职工号检查
- If tDataType(Index) = 7 And Trim(Txt_RsItm(Index).Text) <> "" Then
- If IsDate(Txt_RsItm(Index)) = False Then
- Call Xtxxts("非法日期格式! ——" & Format(Date, "yyyy-mm-dd"), 0, 1)
- If Txt_RsItm(Index).Enabled Then Txt_RsItm(Index).SetFocus
- Exit Function
- End If
- End If
- If tIsCode(1, Index) = 1 Then '对编码型的数据只要不为空,就要检测有效性
- If tDataType(Index) <> 7 Then
- If Trim(Txt_RsItm(Index).Text) <> "" Then
- If CorHlpIsEffect(Str(tItmId(Index)), Trim(Txt_RsItm(Index).Text)) = True Then
- Txt_RsItm(Index).Text = Trim(P_Name)
- tIsCode(2, Index) = Trim(P_Code)
- Else
- Tsxx = "非法录入,没有此" & Lbl_ItmName(Index).Caption
- If UCase(Trim(tFieldName(Index))) = "DEPTCODE" Then Tsxx = Tsxx + "或者录入的不是末级节点!"
- Call Xtxxts(Tsxx, 0, 1)
- If Txt_RsItm(Index).Enabled Then Txt_RsItm(Index).Text = "": Txt_RsItm(Index).SetFocus
- Exit Function
- End If
- Else
- tIsCode(2, i) = ""
- End If
- End If
- End If
- End If
- End If
- DataIsEffect = True
- End Function
- Private Function SetReserve() As Boolean
- Dim tmpRs As New ADODB.Recordset
- Dim i As Integer
- Set tmpRs = Cw_DataEnvi.DataConnect.Execute("SELECT * FROM Rs_Items WHERE (SID='1' AND YNShow='1') ORDER BY Tab")
- ReDim Preserve tReserved(tmpRs.RecordCount)
- i = 1
- While Not tmpRs.EOF
- If IsNull(tmpRs.Fields("YNReserve")) Or tmpRs.Fields("YNReserve") = False Then tReserved(i) = False
- If tmpRs.Fields("YNReserve") = True Then tReserved(i) = True
- tmpRs.MoveNext
- i = i + 1
- Wend
- End Function
- Private Function DelArRec(emp_id As Integer) As Boolean
- '删除人事档案基本信息,如果删除成功返回真,否则返回假
- Dim yn As String
- DelArRec = False
- If EmpID = 0 Then Exit Function
- yn = Xtxxts("真的要删除此档案? ", 2, 2)
- If yn = vbCancel Then Exit Function
- On Error GoTo Err_Del
- Cw_DataEnvi.DataConnect.BeginTrans
- '自定义
- Cw_DataEnvi.DataConnect.Execute "DELETE Rs_ExtendInfo WHERE EmpID=" & EmpID
- Cw_DataEnvi.DataConnect.Execute "DELETE Rs_BasicInfo WHERE EmpID=" & EmpID
- Cw_DataEnvi.DataConnect.CommitTrans
- EmpID = 0
- DelArRec = True
- Exit Function
- Err_Del:
- Cw_DataEnvi.DataConnect.CommitTrans
- If Err.Number = -2147217873 Then '(-2147217873 为SQL Server 2000通过建立外键产生的错误号)
- Call Xtxxts("该人员档案已经被使用,不能删除!", 0, 1)
- Exit Function
- Else
- Call Xtxxts("出现未知情况,该人员档案不能被删除!", 0, 1)
- Exit Function
- End If
- End Function
- Private Sub Save() '保存数据
- Dim i As Integer
- Dim EmpNo As String '职工号
- Dim Ssql1 As String '对应非固定项(Rs_ExtendInfo中的字段)的名称(FieldName)
- Dim Ssql2 As String '对应非固定项(Rs_ExtendInfo中的字段)的值
- Dim Ssql3 As String '对应固定项(Rs_BasicInfo中的字段)的名称(FieldName)
- Dim Ssql4 As String '对应固定项(Rs_BasicInfo中的字段)的值
- Dim SsqlR As String '专门针对保留项目的查询语句
- Dim tmpRs As New Recordset: Dim MAXID_Z As Integer
- Saved = False
- If Lbl_ItmName.Count < 2 Then Call Xtxxts("没有项目!", 0, 1): Exit Sub
- EmpNo = Trim(Txt_RsItm(1).Text) '工号
- For i = 1 To Lbl_ItmName.UBound
- If tFixed(i) = True Then '首先整理固定字段 Rs_BasicInfo,将字段名和值的sql语句拼好
- If Lrzt = 1 Then '增加
- Ssql3 = Ssql3 & tFieldName(i) & ","
- If tIsCode(1, i) = 1 Then '是编码型的就存编码,否则存名称,这里的数组的初值是根据有无相关项决定的
- Ssql4 = Ssql4 & "'" & tIsCode(2, i) & "',"
- Else
- Select Case tDataType(i)
- Case 7
- If Trim(Txt_RsItm(i).Text) = "" Then
- '没填的日期型字段存NULL
- Ssql4 = Ssql4 & "null,"
- Else
- Ssql4 = Ssql4 & "'" & Format(Trim(Txt_RsItm(i).Text), "yyyy-mm-dd") & "',"
- End If
- Case 5
- If Trim(Txt_RsItm(i).Text) = "" Then
- '没填的数字型字段存0
- Ssql4 = Ssql4 & "0,"
- Else
- Ssql4 = Ssql4 & Trim(Txt_RsItm(i).Text) & ","
- End If
- Case Else
- If UCase(tFieldName(i)) = "YNSTOP" Then
- Ssql4 = Ssql4 & "'" & Chk_YNStop.Value & "',"
- Else
- Ssql4 = Ssql4 & "'" & Trim(Txt_RsItm(i).Text) & "',"
- End If
- End Select
- End If
- Else '修改
- If tIsCode(1, i) = 1 Then
- Ssql3 = Ssql3 & tFieldName(i) & "='" & tIsCode(2, i) & "',"
- Else
- Select Case tDataType(i)
- Case 7
- If Trim(Txt_RsItm(i).Text) = "" Then
- '没填的日期型字段存NULL
- Ssql3 = Ssql3 & tFieldName(i) & "= null,"
- Else
- Ssql3 = Ssql3 & tFieldName(i) & "='" & Format(Trim(Txt_RsItm(i).Text), "yyyy-mm-dd") & "',"
- End If
- Case 5
- If Trim(Txt_RsItm(i).Text) = "" Then
- '没填的数字型字段存0
- Ssql3 = Ssql3 & tFieldName(i) & "= 0,"
- Else
- Ssql3 = Ssql3 & tFieldName(i) & "=" & Trim(Txt_RsItm(i).Text) & ","
- End If
- Case Else
- If UCase(tFieldName(i)) = "YNSTOP" Then
- Ssql3 = Ssql3 & tFieldName(i) & "='" & Chk_YNStop.Value & "',"
- Else
- Ssql3 = Ssql3 & tFieldName(i) & "='" & Trim(Txt_RsItm(i).Text) & "',"
- End If
- End Select
- End If
- End If
- Else
- '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- '然后整理非固定字段 Rs_ExtendInfo,将字段名和值的sql语句拼好
- If Lrzt = 1 Then '新增状态的sql
- Ssql1 = Ssql1 & tFieldName(i) & ","
- If tIsCode(1, i) = 1 Then '编码
- Ssql2 = Ssql2 & "'" & tIsCode(2, i) & "',"
- Else '非编码
- Select Case tDataType(i)
- Case 7
- If Trim(Txt_RsItm(i).Text) = "" Then
- '没填的日期型字段存NULL
- Ssql2 = Ssql2 & " null,"
- Else
- Ssql2 = Ssql2 & "'" & Format(Trim(Txt_RsItm(i).Text), "yyyy-mm-dd") & "',"
- End If
- Case 5
- If Trim(Txt_RsItm(i).Text) = "" Then
- '没填的数字型字段存0
- Ssql2 = Ssql2 & " 0,"
- Else
- Ssql2 = Ssql2 & Trim(Txt_RsItm(i).Text) & ","
- End If
- Case Else
- Ssql2 = Ssql2 & "'" & Trim(Txt_RsItm(i).Text) & "',"
- End Select
- End If
- Else '修改状态的sql
- If tIsCode(1, i) = 1 Then '编码
- Ssql1 = Ssql1 & tFieldName(i) & "='" & tIsCode(2, i) & "',"
- Else '非编码
- Select Case tDataType(i)
- Case 7
- If Trim(Txt_RsItm(i).Text) = "" Then
- '没填的日期型字段存NULL
- Ssql1 = Ssql1 & tFieldName(i) & "= null, "
- Else
- Ssql1 = Ssql1 & tFieldName(i) & "='" & Format(Trim(Txt_RsItm(i).Text), "yyyy-mm-dd") & "',"
- End If
- Case 5
- If Trim(Txt_RsItm(i).Text) = "" Then
- '没填的数字型字段存0
- Ssql1 = Ssql1 & tFieldName(i) & "= 0, "
- Else
- Ssql1 = Ssql1 & tFieldName(i) & "=" & Trim(Txt_RsItm(i).Text) & ","
- End If
- Case Else
- Ssql1 = Ssql1 & tFieldName(i) & "='" & Trim(Txt_RsItm(i).Text) & "',"
- End Select
- End If
- End If
- End If
- Next i
- On Error GoTo Quit_Err
- '去掉最后的逗号
- If Trim(Ssql1) <> "" Then Ssql1 = Mid(Trim(Ssql1), 1, Len(Trim(Ssql1)) - 1)
- If Trim(Ssql3) <> "" Then Ssql3 = Mid(Trim(Ssql3), 1, Len(Trim(Ssql3)) - 1)
- Cw_DataEnvi.DataConnect.BeginTrans
- If Lrzt = 1 Then
- '新增记录
- Set tmpRs = Cw_DataEnvi.DataConnect.Execute("SELECT MAXID=MAX(EmpID) from Rs_BasicInfo")
- MAXID_Z = Val("" & tmpRs!maxid) + 1
- EmpID = MAXID_Z
- If Trim(Ssql1) <> "" Then
- Ssql1 = "INSERT INTO Rs_ExtendInfo( EmpID," & Ssql1 & ") VALUES ( " & MAXID_Z & "," & Mid(Ssql2, 1, Len(Ssql2) - 1) & ")"
- Else
- Ssql1 = "INSERT INTO Rs_ExtendInfo( EmpID) VALUES ( " & MAXID_Z & ")"
- End If
- Ssql3 = "INSERT INTO Rs_BasicInfo( EmpID," & Ssql3 & ") VALUES( " & MAXID_Z & "," & Mid(Ssql4, 1, Len(Ssql4) - 1) & ") "
- tmpRs.Close
- Else
- '修改记录
- Ssql3 = "UPDATE Rs_BasicInfo SET " & Ssql3 & " WHERE EmpID=" & EmpID
- If Trim(Ssql1) <> "" Then
- Ssql1 = "UPDATE Rs_ExtendInfo SET " & Ssql1 & " WHERE EmpID=" & EmpID
- End If
- End If
- Cw_DataEnvi.DataConnect.Execute Ssql3
- If Trim(Ssql1) <> "" Then Cw_DataEnvi.DataConnect.Execute Ssql1
- ' 设置辅助保留项目
- SsqlR = "UPDATE Rs_OtherSet SET ItemParameter = '" & EmpID & "' WHERE ItemName= 'ReserveID'"
- Cw_DataEnvi.DataConnect.Execute SsqlR
- '存储图片
- If Trim(Pic_Emp.Tag) <> "" Then
- Cw_DataEnvi.DataConnect.Execute ("UPDATE Rs_BasicInfo SET pic = Null WHERE EmpId = '" & EmpID & "'")
- Dim map As New ADODB.Recordset
- map.Open "SELECT * FROM Rs_BasicInfo WHERE EmpId='" & EmpID & "'", Cw_DataEnvi.DataConnect, adOpenStatic, adLockOptimistic
- SavePic2DB map, EmpID
- map.Close
- End If
- Cw_DataEnvi.DataConnect.CommitTrans
- Saved = True
- Exit Sub
- Quit_Err:
- Saved = False
- End Sub
- Private Function GetIdByNo(emp_No As String) As Integer
- '根据职工号获取id的函数,未停用的
- Dim tmpDataRs As New ADODB.Recordset
- Dim tmpStr As String
- GetIdByNo = 0
- tmpStr = "SELECT EmpId FROM Rs_BasicInfo WHERE empNo = '" & Trim(emp_No) & "' AND YNStop = 0"
- Set tmpDataRs = Cw_DataEnvi.DataConnect.Execute(tmpStr)
- If Not tmpDataRs.EOF Then
- GetIdByNo = tmpDataRs.Fields("EmpId")
- End If
- Set tmpDataRs = Nothing
- End Function
- Private Function LoadData(emp_id As Integer) As Boolean
- '取出数据填充文本框
- Dim tmpDataRs As New ADODB.Recordset
- Dim tmpStr As String
- Dim i As Integer
- LoadData = True
- On Error GoTo ErrDeal
- '打开记录集,获得数据
- tmpStr = Item_Info(SysOwner) & " where b.EmpId=" & emp_id & " and b.EmpId=e.EmpId"
- Set tmpDataRs = Cw_DataEnvi.DataConnect.Execute(tmpStr)
- If tmpDataRs.EOF Then LoadData = False: Exit Function
- '--清空文本框和图片栏
- For i = 1 To Lbl_ItmName.UBound
- Txt_RsItm(i).Text = ""
- Next i
- Chk_YNStop.Value = 0
- Pic_Emp.Picture = LoadPicture("")
- Pic_Emp.Tag = ""
- '--填充文本框
- For i = 1 To Lbl_ItmName.Count - 1
- If tIsCode(1, i) = 1 Then '编码型的显示编码对应的值
- Txt_RsItm(i).Text = Trim("" & tmpDataRs.Fields("N_" + tFieldName(i)))
- tIsCode(2, i) = "" & tmpDataRs.Fields(tFieldName(i))
- Else '非编码的直接显示
- Txt_RsItm(i).Text = Trim("" & tmpDataRs.Fields(tFieldName(i)))
- If tDataType(i) = 7 And Not IsNull(tmpDataRs.Fields(tFieldName(i))) Then Txt_RsItm(i).Text = Format(tmpDataRs.Fields(tFieldName(i)), "yyyy-mm-dd")
- If UCase(tFieldName(i)) = "YNSTOP" Then '对停用复选框单独处理
- If tmpDataRs.Fields(tFieldName(i)) Then
- Chk_YNStop.Value = 1
- Else
- Chk_YNStop.Value = 0
- End If
- End If
- End If
- Next
- '--填充图片内容
- Set tmpDataRs = Cw_DataEnvi.DataConnect.Execute("SELECT Pic FROM Rs_BasicInfo WHERE EmpId = '" & EmpID & "'")
- If Not tmpDataRs.EOF Then
- If tmpDataRs.Fields("Pic").ActualSize = 0 Then Exit Function
- Call getPicture("Pic", tmpDataRs)
- Pic_Emp.Picture = LoadPicture(App.Path & "temp.bmp")
- End If
- Set tmpDataRs = Nothing
- Exit Function
- ErrDeal:
- LoadData = False
- End Function
- Private Function SetTxtStatus(aClear As Boolean, aLock As Boolean, modi As Boolean, aLrzt As Integer) As Boolean
- '根据需要设置文本框的状态,aClear 清空文本框,aLock 锁定文本框, modi 针对修改时工号帮助的锁定
- Dim i As Integer
- SetTxtStatus = True
- On Error GoTo ErrDeal
- If aClear Then '对文本框清空的处理
- For i = 1 To Lbl_ItmName.UBound
- Txt_RsItm(i).Text = ""
- tIsCode(2, i) = "" '对应的编码也清掉
- Next i
- Chk_YNStop.Value = 0
- Pic_Emp.Picture = LoadPicture("")
- Pic_Emp.Tag = ""
- End If
- If aLock Then '对文本框锁定的处理
- For i = 1 To Lbl_ItmName.UBound
- Txt_RsItm(i).Enabled = False
- Cmd_CommHlp(i).Visible = False
- Next i
- Chk_YNStop.Enabled = False
- Pic_Emp.Enabled = False
- Else '解锁
- For i = 1 To Lbl_ItmName.UBound
- Txt_RsItm(i).Enabled = True
- Next i
- Chk_YNStop.Enabled = True
- Pic_Emp.Enabled = True
- End If
- If aLrzt = 1 Then Exit Function '对新增状态不需要对工号文本框单独关照
- If modi Then
- For i = 1 To Lbl_ItmName.UBound
- Txt_RsItm(i).Enabled = False
- If UCase(tFieldName(i)) = "EMPNO" Then
- Txt_RsItm(i).Enabled = True
- Cmd_CommHlp(i).Visible = True
- Cmd_CommHlp(i).Enabled = True
- Exit For
- End If
- Next i
- Else
- For i = 1 To Lbl_ItmName.UBound
- If UCase(tFieldName(i)) = "EMPNO" Then
- Txt_RsItm(i).Enabled = False
- Cmd_CommHlp(i).Visible = False
- Cmd_CommHlp(i).Enabled = False
- Exit For
- End If
- Next i
- End If
- '如果是工资系统,则有部分文本框被锁定
- For i = 1 To Lbl_ItmName.UBound
- If SysOwner = 1 And tSysROnly(i) = True And UCase(tFieldName(i)) <> "EMPNO" Then
- Txt_RsItm(i).Enabled = False
- End If
- Next i
- If SysOwner = 1 Then Pic_Emp.Enabled = False
- Exit Function
- ErrDeal:
- SetTxtStatus = False
- End Function
- Private Sub Move_Cursor(Direct As String)
- '参数:设置游标的移动方向,用4个单词来识别
- Dim i As Integer
- With QuerySet
- If .RecordCount = 0 Then Exit Sub
- Select Case UCase(Trim(Direct))
- Case "FIRST"
- .MoveFirst
- Case "PREVIOUS"
- .MovePrevious
- If .BOF Then
- .MoveFirst
- Exit Sub
- End If
- Case "NEXT"
- .MoveNext
- If .EOF Then
- .MoveLast
- Exit Sub
- End If
- Case "LAST"
- .MoveLast
- End Select
- EmpID = .Fields("Rs_BasicInfo#EmpID")
- lpId.Caption = lID.Caption
- lID.Caption = EmpID
- Call LoadData(EmpID)
- Call SetTxtStatus(False, True, False, Lrzt)
- End With
- End Sub
- Private Sub SwitchToolBar(Status As Integer)
- '设置工具栏状态 0.非编辑状态 1.编辑状态(新增) 2.编辑状态(修改)
- With SzToolbar
- Select Case Status
- Case 0: '浏览((列表)调入单据处理时的进入状态、(列表)新增状态时放弃录入)
- '工具条
- Me.Caption = "人事信息维护"
- .Buttons("PrinterSet").Enabled = True '打印设置
- .Buttons("Printer").Enabled = True '打印
- .Buttons("Preview").Enabled = True '预览
- .Buttons("New").Enabled = True '新增
- .Buttons("Modi").Enabled = True '修改
- .Buttons("Del").Enabled = True '删除
- .Buttons("Save").Enabled = False '保存
- .Buttons("Cancel").Enabled = False '放弃
- .Buttons("First").Enabled = True '首张
- .Buttons("Previous").Enabled = True '上张
- .Buttons("Next").Enabled = True '下张
- .Buttons("Last").Enabled = True '末张
- .Buttons("Set").Enabled = True '设定
- .Buttons("Help").Enabled = True '帮助
- .Buttons("Exit").Enabled = True '退出
- Case 1, 2: '1.新增单据((录入)新增一张单据 、(列表)新增一张单据)
- '2.修改((录入)调入修改功能、(列表)调入修改功能)
- '工具条
- If Status = 1 Then Me.Caption = "人事信息维护——新增"
- If Status = 2 Then Me.Caption = "人事信息维护——修改"
- .Buttons("PrinterSet").Enabled = False '打印设置
- .Buttons("Printer").Enabled = False '打印
- .Buttons("Preview").Enabled = False '预览
- .Buttons("New").Enabled = False '新增
- .Buttons("Modi").Enabled = False '修改
- .Buttons("Del").Enabled = False '删除
- .Buttons("Save").Enabled = True '保存
- .Buttons("Cancel").Enabled = True '放弃
- .Buttons("First").Enabled = False '首张
- .Buttons("Previous").Enabled = False '上张
- .Buttons("Next").Enabled = False '下张
- .Buttons("Last").Enabled = False '末张
- .Buttons("Set").Enabled = True '设定
- .Buttons("Help").Enabled = True '帮助
- .Buttons("Exit").Enabled = True '退出
- End Select
- End With
- End Sub
- Private Function SetPicBox(sys As Integer) As Boolean
- '设置图片框的位置
- Dim aStr As String
- Dim PicSet As New ADODB.Recordset
- If sys = 0 Then
- aStr = "SELECT pTop as tmpTop,pLeft as tmpLeft FROM Rs_Items WHERE FieldName='Pic'"
- Else
- aStr = "SELECT sTop as tmpTop,sLeft as tmpLeft FROM Rs_Items WHERE FieldName='Pic'"
- End If
- Set PicSet = Cw_DataEnvi.DataConnect.Execute(aStr)
- With PicSet
- If Not .EOF Then
- If Val(Trim("" & .Fields("tmpTop"))) <> 0 And Val(Trim("" & .Fields("tmpLeft"))) <> 0 Then
- Pic_Emp.Top = Val(Trim("" & .Fields("tmpTop")))
- Pic_Emp.Left = Val(Trim("" & .Fields("tmpLeft")))
- End If
- End If
- .Close
- End With
- Set PicSet = Nothing
- End Function
- Private Function CreateCtrls(sys As Integer) As Boolean
- '生成界面上的各种控件,主要针对动态的文本框录入
- Dim i As Integer: Dim j As Integer
- Dim aStr As String
- Dim ItmInfo As New ADODB.Recordset
- '--设置面板位置和滚动条位置
- ScollBarIsEffect = False
- Pict.Top = 0: Pict.Left = 0: VScBar.Value = 0
- ScollBarIsEffect = True
- '--------------------------
- '卸载界面控件
- For i = 1 To Txt_RsItm.Count - 1
- Unload Txt_RsItm(i): Unload Lbl_ItmName(i): Unload Cmd_CommHlp(i): Unload Chk_YNStop
- Next i
- '赋初值
- i = 1: j = 1
- If sys = 0 Then
- aStr = "SELECT * FROM Rs_Items WHERE (SID='1' AND YNShow='1') ORDER BY Tab"
- Else
- aStr = "SELECT * FROM Rs_Items WHERE (SID='2' OR Pm='1') AND sYNShow='1' ORDER BY sTab"
- End If
- Call SetPicBox(sys)
- Set ItmInfo = Cw_DataEnvi.DataConnect.Execute(aStr)
- Do While Not ItmInfo.EOF
- ' =======创建标签
- Load Lbl_ItmName(i)
- ReDim Preserve tFieldName(i + 1)
- If sys = 0 Then
- Lbl_ItmName(i).Left = Val(ItmInfo!pLeft & "")
- Lbl_ItmName(i).Top = Val(ItmInfo!pTop & "")
- Else
- Lbl_ItmName(i).Left = Val(ItmInfo!sLeft & "")
- Lbl_ItmName(i).Top = Val(ItmInfo!Stop & "")
- End If
- Lbl_ItmName(i).Caption = ItmInfo!ChName
- tFieldName(i) = Trim(ItmInfo!FieldName & "")
- ' =======创建文本框并设置相关属性
- Load Txt_RsItm(i)
- ReDim Preserve tIsCode(2, i + 1)
- ReDim Preserve tReserved(i + 1)
- ReDim Preserve tFixed(i + 1)
- ReDim Preserve tDataType(i + 1)
- ReDim Preserve tItmId(i + 1)
- ReDim Preserve tSysROnly(i + 1)
- ' 是否保留,在辅助保留中使用
- If IsNull(ItmInfo!YnReserve) Then
- tReserved(i) = False
- Else
- tReserved(i) = ItmInfo!YnReserve
- End If
- ' 文本框对应字段的数据类型
- tDataType(i) = ItmInfo!FieldType
- ' 是否编码
- If Trim(ItmInfo!CorTable) <> "" Then
- tIsCode(1, i) = 1
- Else
- tIsCode(1, i) = 0
- End If
- ' 项目编号
- tItmId(i) = ItmInfo!ItemId
- ' 是否固定,存储在人事信息基本表里的是固定的
- If Trim(ItmInfo!TableName) = "Rs_BasicInfo" Then
- tFixed(i) = 1
- Else
- tFixed(i) = 0
- End If
- Txt_RsItm(i).Left = Lbl_ItmName(i).Left + Lbl_ItmName(i).Width + 100
- Txt_RsItm(i).Top = Lbl_ItmName(i).Top - 50
- Txt_RsItm(i).Width = ItmInfo!FieldLength * 105
- Txt_RsItm(i).MaxLength = ItmInfo!FieldLength
- If sys = 0 Then
- Txt_RsItm(i).TabIndex = Val("" & ItmInfo!Tab) - 1
- Else
- Txt_RsItm(i).TabIndex = Val("" & ItmInfo!sTab) - 1
- End If
- ' 是否只读 (只针对工资)
- If ItmInfo.Fields("SID") = 1 And ItmInfo.Fields("Pm") = True Then
- tSysROnly(i) = True
- End If
- ' =======创建帮助按钮 帮助按钮的tag值存储该按钮是否可用 (为保持文本框、标签、帮助按钮和各数组下标一致)
- Load Cmd_CommHlp(i)
- Cmd_CommHlp(i).Top = Txt_RsItm(i).Top
- Cmd_CommHlp(i).Left = Txt_RsItm(i).Width + Txt_RsItm(i).Left
- If ItmInfo!FieldName = "EmpNo" Then '单独设定工号的帮助
- Cmd_CommHlp(i).Tag = 2 '2是工号的特殊标志,其他帮助按钮有效的为1,否则为0
- Else
- If ((Trim(ItmInfo!Correlation) = 0 And Trim(ItmInfo!CorTable) <> "") _
- Or (Trim(ItmInfo!Correlation) <> 0) Or (ItmInfo!FieldType = 7)) Then
- Cmd_CommHlp(i).Tag = 1
- Else
- Cmd_CommHlp(i).Tag = 0
- End If
- End If
- Txt_RsItm(i).Visible = True
- Lbl_ItmName(i).Visible = True
- 'a1 begin end
- i = i + 1
- ItmInfo.MoveNext
- Loop
- For i = 1 To Txt_RsItm.UBound
- If UCase(tFieldName(i)) = "YNSTOP" Then
- Chk_YNStop.Top = Txt_RsItm(i).Top
- Chk_YNStop.Left = Txt_RsItm(i).Left
- Chk_YNStop.TabIndex = Txt_RsItm(i).TabIndex
- Chk_YNStop.Caption = Me.Lbl_ItmName(i).Caption
- Me.Lbl_ItmName(i).Caption = ""
- Txt_RsItm(i).Visible = False
- Txt_RsItm(i).Enabled = False
- Chk_YNStop.Visible = True
- Exit For
- End If
- Next
- ItmInfo.Close
- End Function
- Private Sub ReserveItmRefurbish()
- '针对保留项目填充文本框
- Dim tmpRs As New ADODB.Recordset
- Dim i As Integer: Dim sSql As String
- On Error GoTo ErrDeal
- '保留功能没有启用,退出
- If Not Me.ReserveIsOn Then Exit Sub
- ''对修改状态的刷新,不提供支持
- 'If Me.Tag = "Modi" Then Exit Sub
- sSql = "SELECT ItemParameter FROM Rs_OtherSet WHERE ItemName = 'ReserveID'"
- Set tmpRs = Cw_DataEnvi.DataConnect.Execute(sSql)
- If tmpRs.EOF Then Exit Sub
- ReserveId = tmpRs.Fields("ItemParameter")
- sSql = Item_Info(SysOwner) & " WHERE B.EmpId= " & ReserveId & " AND B.EmpId=E.EmpId"
- If tmpRs.State = 1 Then tmpRs.Close
- tmpRs.Open sSql, Cw_DataEnvi.DataConnect, adOpenStatic, adLockOptimistic
- If Not tmpRs.EOF Then
- For i = 1 To Lbl_ItmName.UBound
- If tReserved(i) = True Then
- If tIsCode(1, i) = 1 Then
- Txt_RsItm(i).Text = "" & tmpRs.Fields("N_" & tFieldName(i))
- tIsCode(2, i) = Trim("" & tmpRs.Fields(tFieldName(i)))
- Else
- Txt_RsItm(i).Text = "" & tmpRs.Fields(tFieldName(i))
- End If
- If Trim(tFieldName(i)) = "EmpNo" Or Trim(tFieldName(i)) = "EmpName" Then Txt_RsItm(i).Text = ""
- End If
- Next
- End If
- tmpRs.Close
- Exit Sub
- ErrDeal:
- Call Xtxxts("辅助保留项目功能暂不可用!", 0, 3)
- End Sub