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

📄 frmmanapp1.frm

📁 这是本人用vb配合access数据库开发的一个部门人事管理的一个小软件的源码。
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmManApp1 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   " Project"
   ClientHeight    =   3120
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   7695
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   3120
   ScaleWidth      =   7695
   ShowInTaskbar   =   0   'False
   StartUpPosition =   1  'CenterOwner
   Begin VB.TextBox txtItem 
      Height          =   270
      Index           =   0
      Left            =   1560
      MaxLength       =   50
      TabIndex        =   0
      Top             =   720
      Width           =   1935
   End
   Begin VB.TextBox txtItem 
      Height          =   270
      Index           =   1
      Left            =   5160
      MaxLength       =   50
      TabIndex        =   1
      Top             =   720
      Width           =   1935
   End
   Begin VB.Frame Frame1 
      Caption         =   "Project Information"
      Height          =   1935
      Left            =   240
      TabIndex        =   5
      Top             =   360
      Width           =   7215
      Begin VB.TextBox txtItem 
         Height          =   270
         Index           =   4
         Left            =   4920
         MaxLength       =   50
         TabIndex        =   4
         Top             =   1320
         Width           =   1935
      End
      Begin VB.TextBox txtItem 
         Height          =   270
         Index           =   3
         Left            =   1320
         MaxLength       =   50
         TabIndex        =   3
         Top             =   1320
         Width           =   1935
      End
      Begin VB.TextBox txtItem 
         Height          =   270
         Index           =   2
         Left            =   1320
         MaxLength       =   100
         TabIndex        =   2
         Top             =   840
         Width           =   5535
      End
      Begin VB.Label Label2 
         Caption         =   "End time:"
         Height          =   255
         Index           =   16
         Left            =   3720
         TabIndex        =   12
         Top             =   1320
         Width           =   975
      End
      Begin VB.Label Label2 
         Caption         =   "Begin time:"
         Height          =   255
         Index           =   3
         Left            =   240
         TabIndex        =   11
         Top             =   1320
         Width           =   975
      End
      Begin VB.Label Label2 
         Caption         =   "Description:"
         Height          =   255
         Index           =   2
         Left            =   240
         TabIndex        =   10
         Top             =   840
         Width           =   975
      End
      Begin VB.Label Label2 
         Caption         =   "Project Name:"
         Height          =   255
         Index           =   1
         Left            =   3600
         TabIndex        =   9
         Top             =   360
         Width           =   1335
      End
      Begin VB.Label Label2 
         Caption         =   "Project ID:"
         Height          =   255
         Index           =   0
         Left            =   240
         TabIndex        =   8
         Top             =   360
         Width           =   975
      End
   End
   Begin VB.CommandButton cmdExit 
      Caption         =   "Cancel"
      Height          =   375
      Left            =   6120
      TabIndex        =   7
      Top             =   2520
      Width           =   1215
   End
   Begin VB.CommandButton cmdSave 
      Caption         =   "Save (&S)"
      Height          =   375
      Left            =   4320
      TabIndex        =   6
      Top             =   2520
      Width           =   1215
   End
End
Attribute VB_Name = "frmManApp1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'是否改动过记录,ture为改过
Dim mblChange As Boolean
Dim mrc As ADODB.Recordset
Public txtSQL As String
Dim MsgText As String
'操作的表名称





Private Sub cmdExit_Click()
    If mblChange And cmdSave.Enabled Then
        If MsgBox("保存当前记录的变化吗?", vbOKCancel + vbExclamation, "警告") = vbOK Then
            '保存
            Call cmdSave_Click
        End If
    End If
    Unload Me
End Sub

Private Sub cmdSave_Click()
  Dim intCount As Integer
    Dim txtSQL As String
    Dim MsgText As String
    Dim sMeg As String
    Dim i As Integer
  
    For intCount = 0 To 4
        If Trim(txtItem(intCount) & " ") = "" Then
            Select Case intCount
                Case 0
                    sMeg = "项目编号"
                Case 1
                    sMeg = "项目名称"
                Case 2
                    sMeg = "项目描述"
                Case 3
                    sMeg = "开始时间"
                Case 4
                    sMeg = "结束时间"
            End Select
            sMeg = sMeg & "不能为空!"
            MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
            txtItem(intCount).SetFocus
            
            Exit Sub
        End If
    Next intCount
    
    If Trim(txtItem(3) & " ") <> "" Then
       If Not IsDate(txtItem(3)) Then
           MsgBox "开始日期(yyyy-mm-dd)!", vbOKOnly + vbExclamation, "警告"
           txtItem(3).SetFocus
        
            Exit Sub
        Else
           txtItem(3) = Format(txtItem(3), "yyyy-mm-dd")
        End If
    End If
    
    
    If Trim(txtItem(4) & " ") <> "" Then
       If Not IsDate(txtItem(4)) Then
           MsgBox "结束日期(yyyy-mm-dd)!", vbOKOnly + vbExclamation, "警告"
           txtItem(4).SetFocus
        
            Exit Sub
        Else
           txtItem(4) = Format(txtItem(4), "yyyy-mm-dd")
        End If
    End If
 '   If Trim(txtItem(7) & " ") <> "" Then
    '    If Not IsDate(txtItem(7)) Then
    '    MsgBox "参加工作时间应输入日期(yyyy-mm-dd)!", vbOKOnly + vbExclamation, "警告"
    '        txtItem(7).SetFocus
        
    '        Exit Sub
    '    Else
    '        txtItem(7) = Format(txtItem(7), "yyyy-mm-dd")
    '    End If
   ' End If
    
   '  If Trim(txtItem(8) & " ") <> "" Then
   '     If Not IsDate(txtItem(8)) Then
   '         MsgBox "入党时间应输入日期(yyyy-mm-dd)!", vbOKOnly + vbExclamation, "警告"
    '        txtItem(8).SetFocus

    '        Exit Sub
  '      Else
    '        txtItem(8) = Format(txtItem(8), "yyyy-mm-dd")
   '     End If
  '  End If
    
   ' If Trim(txtItem(10) & "") <> "" Then
   '     If Not IsDate(txtItem(10)) Then
     '       MsgBox "职称时间应输入日期(yyyy-mm-dd)!", vbOKOnly + vbExclamation, "警告"
     '       txtItem(10).SetFocus
  
      '      Exit Sub
    '    Else
      '      txtItem(10) = Format(txtItem(10), "yyyy-mm-dd")
     '   End If
  '  End If
    
 '   If Trim(txtItem(14) & "") <> "" Then
   '     If Not IsDate(txtItem(14)) Then
    '        MsgBox "进入公司时间应输入日期(yyyy-mm-dd)!", vbOKOnly + vbExclamation, "警告"
    '        txtItem(14).SetFocus
       
    '        Exit Sub
    '    Else
    '        txtItem(14) = Format(txtItem(14), "yyyy-mm-dd")
    '    End If
  '  End If
    
  '  If Trim(txtItem(15) & "") <> "" Then
   '     If Not IsDate(txtItem(15)) Then
   '         MsgBox "起薪时间应输入日期(yyyy-mm-dd)!", vbOKOnly + vbExclamation, "警告"
   '         txtItem(15).SetFocus
      
   '         Exit Sub
   '     Else
   '         txtItem(15) = Format(txtItem(15), "yyyy-mm-dd")
   '     End If
  '  End If
    
   ' If Trim(txtItem(16) & "") <> "" Then
   '     If Not IsDate(txtItem(16)) Then
    '        MsgBox "调入时间应输入日期(yyyy-mm-dd)!", vbOKOnly + vbExclamation, "警告"
    '        txtItem(16).SetFocus
  
    '        Exit Sub
    '    Else
      '      txtItem(16) = Format(txtItem(16), "yyyy-mm-dd")
    '    End If
   ' End If
    
    '添加判断是否有相同的ID记录
    If gintMode = 1 Then
        txtSQL = "select * from ProjectTable where Pro_id='" & Trim(txtItem(0)) & "'"
        Set mrc = ExecuteSQL(txtSQL, MsgText)
        If mrc.EOF = False Then
            MsgBox "已经存在此项目编号的记录!", vbOKOnly + vbExclamation, "警告"
            txtItem(0).SetFocus
            txtItem(0).SelStart = 0
            txtItem(0).SelLength = Len(txtItem(0))
            Exit Sub
        End If
        mrc.Close
    End If
        
  
       
    '先删除已有记录
    txtSQL = "delete from ProjectTable where Pro_id='" & Trim(txtItem(0)) & "'"
    Set mrc = ExecuteSQL(txtSQL, MsgText)
    
    '再加入新记录
    
    txtSQL = "select * from ProjectTable"
    Set mrc = ExecuteSQL(txtSQL, MsgText)
    mrc.AddNew
    
    For intCount = 0 To 4
        mrc.Fields(intCount) = Trim(txtItem(intCount))
    Next intCount
    

        
 '   For intCount = 3 To 18
      '  mrc.Fields(intCount + 1) = Trim(txtItem(intCount))
    
 '   Next intCount
    
    mrc.Update
    
    If gintMode = 1 Then
        MsgBox "项目添加成功!", vbOKOnly + vbExclamation, "警告"
        For i = 0 To 4
            txtItem(i).Text = ""
            mblChange = False
        Next i
        
        'txtItem(4).Text = ""
      '  mblChange = False
       ' txtItem(18).Text = ""
      '  mblChange = False
        frmManApp1.Show
        frmManApp1.ZOrder 0
        frmManApp.ShowTitle
        frmManApp.txtSQL = "select * from ProjectTable"
        frmManApp.Showdata
        frmManApp.ZOrder 1
        
    Else
        MsgBox "记录修改成功!", vbOKOnly + vbExclamation, "警告"
        Unload Me
        frmManApp.ShowTitle
        frmManApp.txtSQL = "select * from ProjectTable"
        frmManApp.Showdata
        frmManApp.ZOrder 0
    End If
    
    gintMode = 0
End Sub

Private Sub Form_Load()
      Dim MsgText As String
    Dim intCount As Integer
 
    
    If gintMode = 1 Then
        Me.Caption = "Input New" & Me.Caption
        
      '  cboItem.ListIndex = 0
    ElseIf gintMode = 2 Then

        
        
        Set mrc = ExecuteSQL(txtSQL, MsgText)
        
        If mrc.EOF = False Then
            With mrc
                For intCount = 0 To 4
                    txtItem(intCount) = .Fields(intCount)
                Next intCount
            
            End With
        '    txtItem(0).Enabled = False
        End If
        mrc.Close
        
        Me.Caption = Me.Caption & "Modify"
            
       
    End If
    
    mblChange = False

    
End Sub

Private Sub txtItem_Change(Index As Integer)
    '有变化设置gblchange
    mblChange = True
End Sub

Private Sub txtItem_GotFocus(Index As Integer)
    txtItem(Index).SelStart = 0
    txtItem(Index).SelLength = Len(txtItem(Index))
End Sub

Private Sub txtItem_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
    
        EnterToTab KeyCode
    
End Sub

Private Function GetNo() As String
    GetNo = Format(Now, "yymmddhhmmss")
    Randomize
    GetNo = GetNo & Int((99 - 10 + 1) * Rnd + 10)
End Function

⌨️ 快捷键说明

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