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

📄 frmtesttype.frm

📁 学生信息管理系统
💻 FRM
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form frmTestType 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "考试类型"
   ClientHeight    =   2850
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   3705
   LinkTopic       =   "Form2"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   2850
   ScaleWidth      =   3705
   Begin VB.TextBox txtTestType 
      BackColor       =   &H80000018&
      Enabled         =   0   'False
      Height          =   375
      Left            =   240
      TabIndex        =   4
      Top             =   1800
      Width           =   3255
   End
   Begin VB.CommandButton cmdModify 
      Caption         =   "修改"
      Height          =   375
      Left            =   240
      TabIndex        =   3
      Top             =   2280
      Width           =   1095
   End
   Begin VB.CommandButton cmdDelete 
      Caption         =   "删除"
      Height          =   375
      Left            =   2400
      TabIndex        =   2
      Top             =   2280
      Width           =   1095
   End
   Begin VB.CommandButton cmdADD 
      Caption         =   "增加"
      Height          =   375
      Left            =   1320
      TabIndex        =   1
      Top             =   2280
      Width           =   1095
   End
   Begin VB.ListBox lstTestType 
      BackColor       =   &H80000018&
      Height          =   1320
      Left            =   240
      TabIndex        =   0
      Top             =   120
      Width           =   3255
   End
   Begin MSAdodcLib.Adodc adoTestType 
      Height          =   375
      Left            =   120
      Top             =   3840
      Visible         =   0   'False
      Width           =   1920
      _ExtentX        =   3387
      _ExtentY        =   661
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      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.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "类型"
      Height          =   180
      Left            =   240
      TabIndex        =   5
      Top             =   1560
      Width           =   360
   End
End
Attribute VB_Name = "frmTestType"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'----------------------------------frmTestType.frm----------------------------------
Option Explicit

'添加考试类型
Private Sub cmdAdd_Click()
    If cmdADD.Caption = "确定" Then
        If txtTestType.Text = "" Then
            MsgBox "类型名称不能为空!", vbOKOnly + vbExclamation, "警告"
            txtTestType.SetFocus
            Exit Sub
        End If
        
        strUserManage = UserManage(4)
        If strUserManage = "ReadOnly" Then
            MsgBox "对不起,你是只读用户不能添加记录,请与管理员联系!", vbInformation + vbOKOnly, " 警告"
            Exit Sub
        End If
        adoTestType.RecordSource = "select * from ExamType where 类型='" & Trim(txtTestType.Text) & "'"
        adoTestType.Refresh
        '如果要添加的考试类型已经存在
        If adoTestType.Recordset.EOF = False Then
            MsgBox "已经存在该类型名称!", vbOKOnly + vbExclamation, "警告"
            txtTestType.SetFocus
            txtTestType.SelStart = 0
            txtTestType.SelLength = Len(txtTestType.Text)
            Exit Sub
        '将考试类型添加到数据库中
        Else
            adoTestType.Recordset.AddNew
            adoTestType.Recordset.Fields(0) = txtTestType.Text
            adoTestType.Recordset.Update
            cmdADD.Caption = "增加"
            cmdDelete.Enabled = True
            cmdModify.Enabled = True
            txtTestType.Text = ""
            txtTestType.Enabled = False
            ShowTestType
        End If
    '进入添加考试类型状态
    Else
        txtTestType.Enabled = True
        txtTestType.Text = ""
        txtTestType.SetFocus
        cmdADD.Caption = "确定"
        cmdDelete.Enabled = False
        cmdModify.Enabled = False
    End If
End Sub

'删除考试类型
Private Sub cmdDelete_Click()
    strUserManage = UserManage(4)
    If strUserManage = "ReadOnly" Then
        MsgBox "对不起,你是只读用户不能添加记录,请与管理员联系!", vbInformation + vbOKOnly, " 警告"
        Exit Sub
    End If
    
    If Trim(txtTestType.Text) = "" Then
        MsgBox "你还没有选择记录!", vbOKOnly + vbExclamation, "警告"
    '删除选择中的考试类型
    Else
        If MsgBox("确定要删除 类型名称 为 " & Trim(lstTestType.List(lstTestType.ListIndex)) & " 的记录吗?", vbOKCancel + vbExclamation, "警告") = vbOK Then
            adoTestType.RecordSource = "select * from ExamType where 类型='" & Trim(lstTestType.List(lstTestType.ListIndex)) & "'"
            adoTestType.Refresh
            adoTestType.Recordset.Delete
            txtTestType.Text = ""
            ShowTestType
        End If
    End If
End Sub

'修改考试类型
Private Sub cmdModify_Click()
    If txtTestType.Text = "" Then
        MsgBox "你还没有选择记录!", vbOKOnly + vbExclamation, "警告"
        Exit Sub
    End If
    
    '将修改过的考试类型更新到数据库
    If cmdModify.Caption = "确定" Then
        If txtTestType.Text = "" Then
            MsgBox "课程名称不能为空!", vbOKOnly + vbExclamation, "警告"
            txtTestType.SetFocus
            Exit Sub
        End If
        
        strUserManage = UserManage(4)
        If strUserManage = "ReadOnly" Then
            MsgBox "对不起,你是只读用户不能修改记录,请与管理员联系!", vbInformation + vbOKOnly, " 警告"
            Exit Sub
        End If
        
        '连接数据库
        adoTestType.RecordSource = "select * from ExamType where 类型='" & Trim(lstTestType.List(lstTestType.ListIndex)) & "'"
        adoTestType.Refresh
        adoTestType.Recordset.Fields(0) = txtTestType.Text
        adoTestType.Recordset.Update
        txtTestType.Text = ""
        ShowTestType
        cmdModify.Caption = "修改"
        cmdADD.Enabled = True
        cmdDelete.Enabled = True
        txtTestType.Enabled = False
    '进入修改状态
    Else
        txtTestType.Enabled = True
        txtTestType.SetFocus
        cmdModify.Caption = "确定"
        cmdADD.Enabled = False
        cmdDelete.Enabled = False
    End If
End Sub

Private Sub Form_Load()
    adoTestType.ConnectionString = ConnectString
    ShowTestType
End Sub

'将数据库中的考试类型显示到列表中
Private Sub ShowTestType()
    Dim objRecordset As ADODB.Recordset
    
    lstTestType.Clear
    adoTestType.RecordSource = "select * from ExamType order by 类型"
    adoTestType.Refresh
    If adoTestType.Recordset.EOF = False Then
        adoTestType.Recordset.MoveFirst
        Do While Not adoTestType.Recordset.EOF
            lstTestType.AddItem adoTestType.Recordset.Fields(0)
            adoTestType.Recordset.MoveNext
        Loop
    End If
End Sub

Private Sub lstTestType_Click()
    txtTestType.Text = lstTestType.List(lstTestType.ListIndex)
End Sub

⌨️ 快捷键说明

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