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

📄 frmaddyg.frm

📁 用VB+Access实现的企业人事工资管理系统。
💻 FRM
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form frmAddYg 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "添加员工"
   ClientHeight    =   4425
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   5805
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   4425
   ScaleWidth      =   5805
   ShowInTaskbar   =   0   'False
   Begin MSAdodcLib.Adodc Adodc1 
      Height          =   330
      Left            =   1800
      Top             =   3480
      Visible         =   0   'False
      Width           =   1935
      _ExtentX        =   3413
      _ExtentY        =   582
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   2
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   3
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   "DSN=personnel"
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   "personnel"
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   "info"
      Caption         =   "Adodc1"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin VB.ComboBox ComboBranch 
      Height          =   300
      ItemData        =   "frmAddYg.frx":0000
      Left            =   2400
      List            =   "frmAddYg.frx":0025
      Style           =   2  'Dropdown List
      TabIndex        =   8
      Top             =   2040
      Width           =   1455
   End
   Begin VB.CommandButton Command2 
      Caption         =   "取 消"
      Height          =   495
      Left            =   3360
      TabIndex        =   4
      Top             =   2880
      Width           =   1455
   End
   Begin VB.CommandButton cmdAdd 
      Caption         =   "添 加"
      Height          =   495
      Left            =   960
      TabIndex        =   3
      Top             =   2880
      Width           =   1335
   End
   Begin VB.TextBox txtygname 
      Height          =   375
      Left            =   2400
      TabIndex        =   2
      Top             =   1200
      Width           =   1455
   End
   Begin VB.TextBox txtygid 
      DataSource      =   "Adodc1"
      Height          =   375
      Left            =   2400
      TabIndex        =   1
      Top             =   360
      Width           =   1455
   End
   Begin VB.Label Label4 
      Caption         =   "请选择所在部门:"
      Height          =   375
      Left            =   600
      TabIndex        =   7
      Top             =   2040
      Width           =   1575
   End
   Begin VB.Label Label3 
      Caption         =   "注:若编号为空,系统将自动编号"
      ForeColor       =   &H008080FF&
      Height          =   495
      Left            =   4080
      TabIndex        =   6
      Top             =   360
      Width           =   1695
   End
   Begin VB.Label Label2 
      Caption         =   "请输入员工姓名:"
      Height          =   495
      Left            =   600
      TabIndex        =   5
      Top             =   1320
      Width           =   1455
   End
   Begin VB.Label Label1 
      Caption         =   "请输入员工编号:"
      Height          =   495
      Left            =   600
      TabIndex        =   0
      Top             =   480
      Width           =   1695
   End
End
Attribute VB_Name = "frmAddYg"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub cmdAdd_Click()
Dim num As Integer
num = addNum
If (ComboBranch.Text <> "") And (txtygname.Text <> "") Then
    If nameExist(txtygname.Text) = False Then
        '判断编号是否为空
        If txtygid.Text = "" Then
            Adodc1.Recordset.MoveLast
            Adodc1.Recordset.AddNew
            Adodc1.Recordset("姓名") = txtygname.Text
            Adodc1.Recordset("部门") = ComboBranch.Text
            '若编号为空,则自动添加
            Adodc1.Recordset("编号") = num
            Adodc1.Recordset.UpdateBatch
            MsgBox "添加员工成功!", vbOKOnly + vbInformation, "提示信息"
            Unload Me
        Else
            '判断编号是否是数字且有效
            If IsNumeric(txtygid.Text) Then
                Dim ID As Double
                ID = txtygid.Text
                If (ID > 0) And (ID <= 1000000) Then
                    If (numExist(txtygid.Text) = False) Then
                        Adodc1.Recordset.MoveLast
                        Adodc1.Recordset.AddNew
                        Adodc1.Recordset("姓名") = txtygname.Text
                        Adodc1.Recordset("部门") = ComboBranch.Text
                        '保存输入的编号
                        Adodc1.Recordset("编号") = txtygid.Text
                        Adodc1.Recordset.UpdateBatch
                        MsgBox "添加员工成功!", vbOKOnly + vbInformation, "提示信息"
                        Unload Me
                    Else
                        MsgBox "编号已存在,请重新输入!", vbOKOnly + vbExclamation, "提示信息"
                    End If
                Else
                    MsgBox "编号只能为1~1000000的数字,请重新输入!", vbOKOnly + vbExclamation, "提示信息"
                End If
            
            Else
                MsgBox "编号只能是数字,请重新输入!", vbOKOnly + vbExclamation, "提示信息"
            End If
        End If
    Else
        MsgBox "员工已存在,请重新输入!", vbOKOnly + vbExclamation, "提示信息"
    End If
Else
    MsgBox "请输入完整信息!", vbOKOnly + vbExclamation, "提示信息"
End If
End Sub

Private Sub Command2_Click()
Unload Me
End Sub
'自动计算有效编号
Private Function addNum() As Integer
Dim i As Integer
i = 1
Adodc1.Recordset.MoveFirst
While (Not Adodc1.Recordset.EOF)
    If i = Adodc1.Recordset("编号") Then
        i = i + 1
    End If
    Adodc1.Recordset.MoveNext
Wend
addNum = i
End Function
'判断编号是否存在
Private Function numExist(num As Double) As Boolean
Dim i As Integer
i = 0
Adodc1.Recordset.MoveFirst
While (Not Adodc1.Recordset.EOF)
    If Adodc1.Recordset("编号") = num Then
        i = i + 1
    End If
    Adodc1.Recordset.MoveNext
Wend
If i = 0 Then
    numExist = False
Else
    numExist = True
End If
End Function
'判断员工姓名是否已经存在
Private Function nameExist(name As String) As Boolean
Dim i As Integer
i = 0
Adodc1.Recordset.MoveFirst
While (Not Adodc1.Recordset.EOF)
    If Adodc1.Recordset("姓名") = name Then
        i = i + 1
    End If
    Adodc1.Recordset.MoveNext
Wend
If i = 0 Then
    nameExist = False
Else
    nameExist = True
End If
End Function

⌨️ 快捷键说明

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