⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmholiday.frm

📁 人事管理系统的一个比较不错的VB软件 有管理系统的功能
💻 FRM
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomct2.ocx"
Begin VB.Form frmHoliday 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "请假维护"
   ClientHeight    =   4395
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   6495
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4395
   ScaleWidth      =   6495
   StartUpPosition =   3  '窗口缺省
   Begin MSComctlLib.ImageList ImageList1 
      Left            =   1440
      Top             =   2640
      _ExtentX        =   1005
      _ExtentY        =   1005
      BackColor       =   -2147483643
      ImageWidth      =   38
      ImageHeight     =   38
      MaskColor       =   12632256
      _Version        =   393216
      BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
         NumListImages   =   1
         BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmHoliday.frx":0000
            Key             =   ""
         EndProperty
      EndProperty
   End
   Begin VB.ComboBox ComboItem 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FF0000&
      Height          =   330
      Index           =   1
      Left            =   3720
      TabIndex        =   10
      Top             =   240
      Width           =   1575
   End
   Begin MSComctlLib.ListView LViewHoliday 
      Height          =   2535
      Left            =   120
      TabIndex        =   9
      Top             =   1800
      Width           =   6255
      _ExtentX        =   11033
      _ExtentY        =   4471
      View            =   3
      LabelWrap       =   -1  'True
      HideSelection   =   -1  'True
      FullRowSelect   =   -1  'True
      GridLines       =   -1  'True
      _Version        =   393217
      Icons           =   "ImageList1"
      SmallIcons      =   "ImageList1"
      ColHdrIcons     =   "ImageList1"
      ForeColor       =   -2147483640
      BackColor       =   -2147483643
      BorderStyle     =   1
      Appearance      =   1
      NumItems        =   0
   End
   Begin VB.CommandButton cmdDelete 
      Caption         =   "删除"
      Height          =   375
      Left            =   3480
      TabIndex        =   8
      Top             =   1350
      Width           =   975
   End
   Begin VB.CommandButton cmdSave 
      Caption         =   "保存"
      Height          =   375
      Left            =   1680
      TabIndex        =   7
      Top             =   1350
      Width           =   855
   End
   Begin MSComCtl2.DTPicker DTPDate 
      Height          =   375
      Index           =   1
      Left            =   4800
      TabIndex        =   6
      Top             =   840
      Width           =   1575
      _ExtentX        =   2778
      _ExtentY        =   661
      _Version        =   393216
      Format          =   27000833
      CurrentDate     =   38133
   End
   Begin MSComCtl2.DTPicker DTPDate 
      Height          =   375
      Index           =   0
      Left            =   1680
      TabIndex        =   5
      Top             =   840
      Width           =   1575
      _ExtentX        =   2778
      _ExtentY        =   661
      _Version        =   393216
      Format          =   27000833
      CurrentDate     =   38133
   End
   Begin VB.ComboBox ComboItem 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FF0000&
      Height          =   330
      Index           =   0
      Left            =   960
      TabIndex        =   4
      Top             =   240
      Width           =   1455
   End
   Begin VB.Label Label4 
      AutoSize        =   -1  'True
      Caption         =   "请假始止日期"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   210
      Left            =   3360
      TabIndex        =   3
      Top             =   960
      Width           =   1350
   End
   Begin VB.Label Label3 
      AutoSize        =   -1  'True
      Caption         =   "请假起始日期"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   210
      Left            =   240
      TabIndex        =   2
      Top             =   960
      Width           =   1350
   End
   Begin VB.Label Label2 
      AutoSize        =   -1  'True
      Caption         =   "请假原因"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   210
      Left            =   2520
      TabIndex        =   1
      Top             =   360
      Width           =   900
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "员工"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   210
      Left            =   240
      TabIndex        =   0
      Top             =   360
      Width           =   450
   End
End
Attribute VB_Name = "frmHoliday"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public mrc As ADODB.Recordset
Dim txtSql As String
Dim arrayWhys() As String
Dim arrayEmployee() As String
Dim nWhys, nEmployee As Integer



Private Sub ShowListHoliday()
   Dim i, n As Integer
   Dim LvDate As ListItem
   
   LViewHoliday.ListItems.Clear
   
   txtSql = "select * from holiday where Id ='" & arrayEmployee(ComboItem(0).ListIndex, 0) & "'"
   
   
   Set mrc = Nothing
   Set mrc = ExecuteSQL(txtSql)
   i = 1
   Do While Not mrc.EOF
       Set LvData = LViewHoliday.ListItems.Add(, "d" & i, i, 1, 1)
           LvData.SubItems(1) = mrc.Fields(1).Value
           LvData.SubItems(2) = mrc.Fields(2).Value
           For n = 0 To nWhys - 1
              If arrayWhys(n, 0) = mrc.Fields(3).Value Then
                 Exit For
              End If
           Next n
           LvData.SubItems(3) = arrayWhys(n, 1)
           i = i + 1
       mrc.MoveNext
    Loop
     
    mrc.Close
End Sub



Private Sub cmdDelete_Click()
   If Not check_Holiday Then
      Exit Sub
   End If
   txtSql = "delete  from holiday where  Id='" & arrayEmployee(ComboItem(0).ListIndex, 0) & "' and BeginDate='" & DTPDate(0).Value & "'"
   
   Set mrc = Nothing
    
   Set mrc = ExecuteSQL(txtSql)
     
   Set mrc = Nothing
   
    
   ShowListHoliday   ' 刷新数据
    
   Cleartxt   '清除文本中的数据
   
End Sub

Private Sub cmdSave_Click()
   If Not check_Holiday Then
      Exit Sub
   End If
   
   txtSql = "select * from holiday where  Id='" & arrayEmployee(ComboItem(0).ListIndex, 0) & "' and BeginDate='" & DTPDate(0).Value & "'"
   
   Set mrc = Nothing
    
   Set mrc = ExecuteSQL(txtSql)
    
   If mrc.EOF = False Then   '修改
      
       mrc.Fields(2) = DTPDate(1).Value
       mrc.Fields(3) = arrayWhys(ComboItem(1).ListIndex, 0)
       mrc.Update
       
    Else                    '新增
       txtSql = "select * from holiday"
       Set mrc = Nothing
       Set mrc = ExecuteSQL(txtSql)
       mrc.AddNew
       mrc.Fields(0) = arrayEmployee(ComboItem(0).ListIndex, 0)
       mrc.Fields(1) = DTPDate(0).Value
       mrc.Fields(2) = DTPDate(1).Value
       mrc.Fields(3) = arrayWhys(ComboItem(1).ListIndex, 0)
       mrc.Update
       
    End If
    
    Set mrc = Nothing
   
    
    ShowListHoliday   ' 刷新数据
    
    Cleartxt   '清除文本中的数据
   
End Sub

Private Sub Cleartxt()
   'ComboItem(0).Text = ""
   ComboItem(1).Text = ""
   DTPDate(0).Value = Date
   DTPDate(1).Value = Date
   
End Sub



Private Sub ComboItem_KeyPress(Index As Integer, KeyAscii As Integer)
   If KeyAscii = 13 Then
      
      If Index < 1 Then
         ComboItem(Index + 1).SetFocus
      Else
         DTPDate(0).SetFocus
      End If
      
      
   End If
End Sub

Private Sub ComboItem_Validate(Index As Integer, Cancel As Boolean)
   Dim i As Integer
   If Index = 0 Then
      For i = 0 To nEmployee - 1
         If arrayEmployee(i, 1) = ComboItem(Index).Text Then
            Exit For
         End If
      Next i
     If i >= nEmployee Then
         MsgBox "输入的数据不能不正确", vbCritical + vbOKOnly, "错误提示:"
         ComboItem(Index).SetFocus
     Else
        Call ShowListHoliday
     End If
   Else
      For i = 0 To nWhys - 1
         If arrayWhys(i, 1) = ComboItem(Index).Text Then
            Exit For
         End If
      Next i
     If i >= nWhys Then
         MsgBox "输入的数据不能不正确", vbCritical + vbOKOnly, "错误提示:"
         ComboItem(Index).SetFocus
     End If
   End If
   
   
  
   
End Sub



Private Sub DTPDate_KeyPress(Index As Integer, KeyAscii As Integer)
   If KeyAscii = 13 Then
   
      If Index < 1 Then
         DTPDate(Index + 1).SetFocus
      Else
         ComboItem(0).SetFocus
         
      End If
      
   End If
End Sub

Private Sub Form_Load()
   Dim FlagEnabled As Boolean
   
   Me.Left = (Screen.Width - Me.Width) / 2
   Me.Top = (Screen.Height - Me.Height) / 2
   
   FlagEnabled = CheckProgramLimit("hrd203")
   cmdSave.Enabled = FlagEnabled
   cmdDelete.Enabled = FlagEnabled
   
   Call Init
End Sub
Private Sub Init()
   Dim i As Integer
   Dim TvHead As ColumnHeader
         
   Set TvHead = LViewHoliday.ColumnHeaders.Add(, "h01", "序号", 0)
   Set TvHead = LViewHoliday.ColumnHeaders.Add(, "h02", "请假起始日期", 2000)
   Set TvHead = LViewHoliday.ColumnHeaders.Add(, "h03", "请假始止日期", 2000)
   Set TvHead = LViewHoliday.ColumnHeaders.Add(, "h04", "请假原因", 1000)
   
 
   DTPDate(0).Value = Date
   DTPDate(1).Value = Date
   
   '找员工工号
   txtSql = "select Id,Name from employee"
   Set mrc = Nothing
   Set mrc = ExecuteSQL(txtSql)
   nEmployee = mrc.RecordCount
   ReDim arrayEmployee(nEmployee, 2)
   i = 0
   Do While Not mrc.EOF
       ComboItem(0).AddItem mrc.Fields(1).Value
       arrayEmployee(i, 0) = mrc.Fields(0).Value
       arrayEmployee(i, 1) = mrc.Fields(1).Value
       i = i + 1
       
       mrc.MoveNext
   Loop
   
   '找请假原因
   txtSql = "select * from whys"
   Set mrc = Nothing
   Set mrc = ExecuteSQL(txtSql)
   nWhys = mrc.RecordCount
   ReDim arrayWhys(nWhys, 2)
   i = 0
   Do While Not mrc.EOF
       ComboItem(1).AddItem mrc.Fields(1).Value
       arrayWhys(i, 0) = mrc.Fields(0).Value
       arrayWhys(i, 1) = mrc.Fields(1).Value
       i = i + 1
       mrc.MoveNext
   Loop
   
   
End Sub

Private Sub LViewHoliday_BeforeLabelEdit(Cancel As Integer)
   Cancel = 1
End Sub

Private Sub LViewHoliday_ItemClick(ByVal Item As MSComctlLib.ListItem)
   ComboItem(1).Text = Item.SubItems(3)
   DTPDate(0).Value = Item.SubItems(1)
   DTPDate(1).Value = Item.SubItems(2)
End Sub

Private Function check_Holiday() As Boolean
   Dim i As Integer
   check_Holiday = True
   For i = 0 To 1
      If ComboItem(i).Text = "" Then
         MsgBox "输入的数据不能为空", vbCritical + vbOKOnly, "错误提示:"
         check_Holiday = False
         ComboItem(i).SetFocus
         Exit Function
      End If
      If DTPDate(i).Value = "" Then
         MsgBox "输入的数据不能为空", vbCritical + vbOKOnly, "错误提示:"
         check_Holiday = False
         DTPDate(i).SetFocus
         Exit Function
      End If
   Next i
   
   For i = 0 To nEmployee - 1
       If arrayEmployee(i, 1) = ComboItem(0).Text Then
          Exit For
       End If
   Next i
   If i >= nEmployee Then
      MsgBox "输入的数据不能不正确", vbCritical + vbOKOnly, "错误提示:"
      ComboItem(0).SetFocus
      check_Holiday = False
      Exit Function
     
   End If
   
   For i = 0 To nWhys - 1
       If arrayWhys(i, 1) = ComboItem(1).Text Then
          Exit For
       End If
   Next i
   If i >= nWhys Then
      MsgBox "输入的数据不能不正确", vbCritical + vbOKOnly, "错误提示:"
      ComboItem(Index).SetFocus
      check_Holiday = False
      Exit Function
   End If
   
   
End Function

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -