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

📄 frmmodify.frm

📁 用VB+Access实现的企业人事工资管理系统。
💻 FRM
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form FrmModify 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "员工信息修改"
   ClientHeight    =   4425
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   5115
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   4425
   ScaleWidth      =   5115
   ShowInTaskbar   =   0   'False
   Begin MSAdodcLib.Adodc Adodc1 
      Height          =   330
      Left            =   1800
      Top             =   3960
      Visible         =   0   'False
      Width           =   1575
      _ExtentX        =   2778
      _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.CommandButton Command2 
      Caption         =   "取消"
      Height          =   375
      Left            =   3000
      TabIndex        =   5
      Top             =   3240
      Width           =   1215
   End
   Begin VB.CommandButton Command1 
      Caption         =   "修改"
      Height          =   375
      Left            =   960
      TabIndex        =   4
      Top             =   3240
      Width           =   1215
   End
   Begin VB.ComboBox ComboNewBranch 
      Height          =   300
      ItemData        =   "FrmModify.frx":0000
      Left            =   2880
      List            =   "FrmModify.frx":0025
      Style           =   2  'Dropdown List
      TabIndex        =   3
      Top             =   2400
      Width           =   1575
   End
   Begin VB.TextBox txtNewID 
      DataSource      =   "Adodc1"
      Height          =   375
      Left            =   2880
      TabIndex        =   2
      Top             =   1440
      Width           =   1575
   End
   Begin VB.ComboBox ComboName 
      Height          =   300
      Left            =   2880
      Style           =   2  'Dropdown List
      TabIndex        =   1
      Top             =   480
      Width           =   1575
   End
   Begin VB.Label Label3 
      Caption         =   "选择新部门:"
      Height          =   375
      Left            =   600
      TabIndex        =   7
      Top             =   2400
      Width           =   1695
   End
   Begin VB.Label Label2 
      Caption         =   "输入新编号:"
      Height          =   375
      Left            =   600
      TabIndex        =   6
      Top             =   1440
      Width           =   1575
   End
   Begin VB.Label Label1 
      Caption         =   "请选择一个员工:"
      Height          =   495
      Left            =   600
      TabIndex        =   0
      Top             =   480
      Width           =   1695
   End
End
Attribute VB_Name = "FrmModify"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'添加姓名列表
Private Sub addNameList()
Adodc1.Recordset.MoveFirst
While (Not Adodc1.Recordset.EOF)
    ComboName.AddItem Adodc1.Recordset("姓名")
    Adodc1.Recordset.MoveNext
Wend
End Sub
'判断姓名是否存在
Private Function numExist(num As Integer) 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 updateBranch()
Dim name As String
name = ComboName.Text
name = "'" & name & "'"
Adodc1.Recordset.MoveFirst
Adodc1.Recordset.Find "姓名=" & name
Adodc1.Recordset("部门") = ComboNewBranch.Text
End Function

Private Sub Command1_Click()
If (ComboName.Text <> "") And (ComboNewBranch.Text <> "") And (txtNewID.Text <> "") Then
    '判断编号是否为数字
    If IsNumeric(txtNewID.Text) Then
        Dim ID As Double
        ID = txtNewID.Text
        If (ID > 0) And (ID <= 1000000) Then
            '编号不存在时,可以保存
            If numExist(txtNewID.Text) = False Then
                updateBranch
                Adodc1.Recordset("编号") = txtNewID.Text
                Adodc1.Recordset.UpdateBatch
                MsgBox "修改信息成功!", vbOKOnly + vbInformation, "提示信息"
                Unload Me
            Else
                updateBranch
                '编号与原来的相同,则忽略,若不相同,则要求重新输入
                If Adodc1.Recordset("编号") <> txtNewID.Text Then
                    MsgBox "编号已存在,请重新输入!", vbOKOnly + vbExclamation, "提示信息"
                Else
                    updateBranch
                    Adodc1.Recordset.UpdateBatch
                    MsgBox "修改信息成功!", vbOKOnly + vbInformation, "提示信息"
                    Unload Me
                End If
            End If
        Else
            MsgBox "编号只能为1~1000000的数字,请重新输入!", vbOKOnly + vbExclamation, "提示信息"
        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 Sub Form_Load()
addNameList
End Sub

⌨️ 快捷键说明

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