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

📄 frmduty.frm

📁 企业事务管理系统(程序+打包)是《数据库系统开发项目方案精解系列丛书VB数据库管理》附带CD中的程序。
💻 FRM
字号:
VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Begin VB.Form frmDuty 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "值班资料录入"
   ClientHeight    =   5100
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   6000
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   5100
   ScaleWidth      =   6000
   ShowInTaskbar   =   0   'False
   StartUpPosition =   2  '屏幕中心
   Begin VB.CommandButton cmdOK 
      Height          =   495
      Left            =   1080
      Picture         =   "frmDuty.frx":0000
      Style           =   1  'Graphical
      TabIndex        =   18
      Top             =   4440
      Width           =   1215
   End
   Begin VB.CommandButton cmdCancel 
      Height          =   495
      Left            =   3360
      Picture         =   "frmDuty.frx":0540
      Style           =   1  'Graphical
      TabIndex        =   17
      Top             =   4440
      Width           =   1215
   End
   Begin VB.PictureBox Picture1 
      Height          =   4095
      Left            =   120
      ScaleHeight     =   4035
      ScaleWidth      =   5715
      TabIndex        =   0
      Top             =   120
      Width           =   5775
      Begin VB.TextBox txtDutyID 
         Height          =   615
         Left            =   240
         TabIndex        =   19
         Top             =   2400
         Visible         =   0   'False
         Width           =   735
      End
      Begin VB.TextBox txtContent 
         Appearance      =   0  'Flat
         Height          =   1950
         Left            =   1155
         MultiLine       =   -1  'True
         ScrollBars      =   3  'Both
         TabIndex        =   14
         Top             =   1970
         Width           =   4380
      End
      Begin VB.TextBox txtDutyTopic 
         Appearance      =   0  'Flat
         Height          =   330
         Left            =   1155
         TabIndex        =   5
         Top             =   1503
         Width           =   4380
      End
      Begin VB.TextBox txtCaseNum 
         Appearance      =   0  'Flat
         Height          =   330
         Left            =   3840
         TabIndex        =   4
         Top             =   1057
         Width           =   1695
      End
      Begin VB.ComboBox Combo_DutyEnd 
         Height          =   300
         ItemData        =   "frmDuty.frx":0A92
         Left            =   3840
         List            =   "frmDuty.frx":0AE1
         Style           =   2  'Dropdown List
         TabIndex        =   3
         Top             =   626
         Width           =   1695
      End
      Begin VB.ComboBox Combo_DutyMan 
         Height          =   300
         ItemData        =   "frmDuty.frx":0B8A
         Left            =   1155
         List            =   "frmDuty.frx":0B8C
         Style           =   2  'Dropdown List
         TabIndex        =   2
         Top             =   1072
         Width           =   1695
      End
      Begin VB.ComboBox Combo_DutyStart 
         Height          =   300
         ItemData        =   "frmDuty.frx":0B8E
         Left            =   3840
         List            =   "frmDuty.frx":0BDD
         Style           =   2  'Dropdown List
         TabIndex        =   1
         Top             =   180
         Width           =   1695
      End
      Begin MSComCtl2.DTPicker DTPDutyStart 
         Height          =   330
         Left            =   1155
         TabIndex        =   6
         Top             =   165
         Width           =   1695
         _ExtentX        =   2990
         _ExtentY        =   582
         _Version        =   393216
         Format          =   27000832
         CurrentDate     =   38025
      End
      Begin MSComCtl2.DTPicker DTPDutyEnd 
         Height          =   330
         Left            =   1155
         TabIndex        =   7
         Top             =   615
         Width           =   1695
         _ExtentX        =   2990
         _ExtentY        =   582
         _Version        =   393216
         Format          =   27000832
         CurrentDate     =   38025
      End
      Begin VB.Label Label8 
         AutoSize        =   -1  'True
         Caption         =   "委办事项"
         Height          =   180
         Left            =   240
         TabIndex        =   16
         Top             =   1575
         Width           =   720
      End
      Begin VB.Label Label6 
         AutoSize        =   -1  'True
         Caption         =   "重要记事"
         Height          =   180
         Left            =   240
         TabIndex        =   15
         Top             =   2025
         Width           =   720
      End
      Begin VB.Label Label7 
         AutoSize        =   -1  'True
         Caption         =   "函电总数"
         Height          =   180
         Left            =   3000
         TabIndex        =   13
         Top             =   1125
         Width           =   720
      End
      Begin VB.Label Label5 
         AutoSize        =   -1  'True
         Caption         =   "值班人"
         Height          =   180
         Left            =   420
         TabIndex        =   12
         Top             =   1125
         Width           =   540
      End
      Begin VB.Label Label4 
         AutoSize        =   -1  'True
         Caption         =   "截至日期"
         Height          =   180
         Left            =   240
         TabIndex        =   11
         Top             =   690
         Width           =   720
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         Caption         =   "值班日期"
         Height          =   180
         Left            =   240
         TabIndex        =   10
         Top             =   240
         Width           =   720
      End
      Begin VB.Label Label3 
         AutoSize        =   -1  'True
         Caption         =   "值班时间"
         Height          =   180
         Left            =   3000
         TabIndex        =   9
         Top             =   240
         Width           =   720
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         Caption         =   "截至时间"
         Height          =   180
         Left            =   3000
         TabIndex        =   8
         Top             =   690
         Width           =   720
      End
   End
End
Attribute VB_Name = "frmDuty"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub cmdCancel_Click()
    Unload Me
End Sub

Private Sub cmdOK_Click()
    Dim rst As New ADODB.Recordset
    Dim strsql As String
    Dim intdutyman As Integer                               '值班人编号
    
    If Me.Combo_DutyStart = "" Or Me.Combo_DutyEnd = "" Then '值班时间不为空
        MsgBox "请选择值班时间", vbExclamation, Me.Caption
        Exit Sub
    End If
    If Me.DTPDutyStart.Value < Me.DTPDutyEnd.Value Then     '值班时间输入正确
        MsgBox "值班起始日期不得小于截至日期", vbCritical, Me.Caption
        Exit Sub
    End If
    If Me.DTPDutyStart.Value = Me.DTPDutyEnd.Value Then
        If Me.Combo_DutyStart.ListIndex >= Me.Combo_DutyEnd.ListIndex Then
            MsgBox "同一天内值班的开始时间必须小于截止时间!", vbCritical, Me.Caption
            Exit Sub
        End If
    End If
    If Me.Combo_DutyMan.Text = "" Then                      '选择值班人
        MsgBox "选择值班人", vbExclamation, Me.Caption
        Exit Sub
    End If
    strsql = "select dutyman_id from tbl_dutyman where dutyman_name='" & Me.Combo_DutyMan & "'"
    rst.Open strsql, CnnDataBase, adOpenStatic              '静态打开记录集
    If rst.RecordCount <> 1 Then
        MsgBox "值班人的数据表中存在重复的值班人姓名!", vbCritical, "数据库错误"
        Exit Sub
    End If
    intdutyman = rst!dutyman_id                             '记下值班人的编号
    rst.Close
    
    If Module1.BLduty = 0 Then                              '新增记录的情况
        rst.Open "tbl_duty", CnnDataBase, adOpenStatic, adLockOptimistic
        rst.AddNew                                          '打开记录集添加新记录
    ElseIf Module1.BLduty = 1 Then                          '修改已有记录
        strsql = "select * from tbl_duty where dutyid=" & Me.txtDutyID
        rst.Open strsql, CnnDataBase, adOpenDynamic, adLockOptimistic
    Else
        Exit Sub
    End If
    rst!DateStart = Me.DTPDutyStart.Value
    rst!timestart = CInt(Left(Me.Combo_DutyStart.Text, 1))
    rst!DateEnd = Me.DTPDutyEnd.Value
    rst!timeend = CInt(Left(Me.Combo_DutyEnd.Text, 1))
    rst!DutyManID = intdutyman
    rst!CaseNum = Me.txtCaseNum
    rst!DutyTopic = Me.txtDutyTopic
    rst!Content = Me.txtContent
    rst.Update                                              '新记录添加完成
    MsgBox "记录添加成功!", vbInformation, Me.Caption
    Me.txtCaseNum = ""                                      '函电总数栏置空
    Me.txtDutyTopic = ""                                    '委办事项栏置空
    Me.txtContent = ""                                      '重要记事内容置空
    Me.DTPDutyStart.Value = Date                            '值班开始日期设为当日
    Me.DTPDutyEnd.Value = Date                              '值班结束日期设为当日
    Me.Combo_DutyMan.ListIndex = -1                         '值班人当前选择为空
    Me.Combo_DutyStart.ListIndex = -1                       '值班开始时间当前选择为空
    Me.Combo_DutyEnd.ListIndex = -1                         '值班截止时间当前选择为空
End Sub

Private Sub Form_Load()
    Dim strsql As String
    Dim rst As New ADODB.Recordset
    
    strsql = "select dutyman_name from tbl_dutyman order by dutyman_id"
    rst.Open strsql, CnnDataBase                    '打开数据集
    Do While rst.EOF = False                        '添加“值班人”
        Me.Combo_DutyMan.AddItem rst!dutyman_Name
        rst.MoveNext
    Loop
    Set rst = Nothing
    If Module1.BLduty = 0 Then
        Me.Combo_DutyMan.ListIndex = -1             '默认选择空
        Me.DTPDutyStart.Value = Date                '值班开始日期设为当日
        Me.DTPDutyEnd.Value = Date                  '值班结束日期设为当日
    End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Dim strsql As String
    Dim rst As New ADODB.Recordset
    Dim strsql2 As String
    Dim rst2 As New ADODB.Recordset
    
    strsql = "select * from tbl_duty order by dutyid"
    rst.Open strsql, CnnDataBase                    '打开数据库的记录集
    With frmMain.MSFduty
        .Rows = 1                                   '刷新主窗体的MSFduty
        Do While rst.EOF = False
            .Rows = .Rows + 1                       '增加MSFlex一行空行
            .Row = .Rows - 1
            .TextMatrix(.Row, 0) = rst!DutyID       '向新空行添加记录
            .TextMatrix(.Row, 1) = rst!DateStart
            .TextMatrix(.Row, 2) = rst!timestart & ":00"
            .TextMatrix(.Row, 3) = rst!DateEnd
            .TextMatrix(.Row, 4) = rst!timeend & ":00"
            strsql2 = "select * from tbl_dutyman where dutyman_id=" & rst!DutyManID
            rst2.Open strsql2, CnnDataBase, adOpenStatic
            If rst2.RecordCount <> 1 Then           '查找对应的值班人名
                MsgBox "值班人数据表中有重复!", vbCritical, "数据库错误"
                Exit Sub
            End If
            .TextMatrix(.Row, 5) = rst2!dutyman_Name
            rst2.Close
            .TextMatrix(.Row, 6) = rst!CaseNum
            .TextMatrix(.Row, 7) = rst!DutyTopic
            .TextMatrix(.Row, 8) = rst!Content
            rst.MoveNext
        Loop
        .Row = 0                                    '设置MSFlex默认指向固定行
    End With
    rst.Close
End Sub

⌨️ 快捷键说明

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