www.pudn.com > stu_rag.rar > frmAddQ.frm, change:2003-03-16,size:21280b


VERSION 5.00 
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX" 
Begin VB.Form frmTestLib  
   BackColor       =   &H00C0C000& 
   BorderStyle     =   0  'None 
   ClientHeight    =   6612 
   ClientLeft      =   0 
   ClientTop       =   0 
   ClientWidth     =   5136 
   LinkTopic       =   "Form1" 
   ScaleHeight     =   6612 
   ScaleWidth      =   5136 
   ShowInTaskbar   =   0   'False 
   StartUpPosition =   2  'CenterScreen 
   Begin VB.Frame FrameChoice  
      Caption         =   "试题选择" 
      Height          =   975 
      Left            =   120 
      TabIndex        =   23 
      Top             =   4680 
      Width           =   4935 
      Begin VB.ComboBox CmbType  
         Height          =   315 
         ItemData        =   "frmAddQ.frx":0000 
         Left            =   240 
         List            =   "frmAddQ.frx":0002 
         Style           =   2  'Dropdown List 
         TabIndex        =   29 
         Top             =   360 
         Width           =   1215 
      End 
      Begin VB.CommandButton CmdFilter  
         Caption         =   "查询设置" 
         Height          =   375 
         Left            =   3840 
         TabIndex        =   28 
         Top             =   360 
         Width           =   975 
      End 
      Begin VB.CommandButton CmdFirst  
         Caption         =   "|<" 
         Height          =   375 
         Left            =   1800 
         TabIndex        =   27 
         Top             =   360 
         Width           =   495 
      End 
      Begin VB.CommandButton CmdPrev  
         Caption         =   "<" 
         Height          =   375 
         Left            =   2280 
         TabIndex        =   26 
         Top             =   360 
         Width           =   495 
      End 
      Begin VB.CommandButton CmdNext  
         Caption         =   ">" 
         Height          =   375 
         Left            =   2760 
         TabIndex        =   25 
         Top             =   360 
         Width           =   495 
      End 
      Begin VB.CommandButton CmdLast  
         Caption         =   ">|" 
         Height          =   375 
         Left            =   3240 
         TabIndex        =   24 
         Top             =   360 
         Width           =   495 
      End 
   End 
   Begin VB.Frame FrameOpt  
      Caption         =   "操作" 
      Height          =   735 
      Left            =   120 
      TabIndex        =   1 
      Top             =   5760 
      Width           =   4935 
      Begin VB.CommandButton CmdExit  
         Caption         =   "退出" 
         Height          =   375 
         Left            =   3960 
         TabIndex        =   5 
         Top             =   240 
         Width           =   855 
      End 
      Begin VB.CommandButton CmdUpdate  
         Caption         =   "修改" 
         Height          =   375 
         Left            =   2760 
         TabIndex        =   4 
         Top             =   240 
         Width           =   855 
      End 
      Begin VB.CommandButton CmdDel  
         Caption         =   "删除" 
         Height          =   375 
         Left            =   1560 
         TabIndex        =   3 
         Top             =   240 
         Width           =   855 
      End 
      Begin VB.CommandButton CmdAdd  
         Caption         =   "添加" 
         Height          =   375 
         Left            =   360 
         TabIndex        =   2 
         Top             =   240 
         Width           =   855 
      End 
   End 
   Begin VB.Frame FrameMain  
      Height          =   4455 
      Left            =   120 
      TabIndex        =   0 
      Top             =   120 
      Width           =   4935 
      Begin MSDataGridLib.DataGrid DataLibs  
         Height          =   4332 
         Left            =   0 
         TabIndex        =   30 
         Top             =   120 
         Visible         =   0   'False 
         Width           =   4932 
         _ExtentX        =   8700 
         _ExtentY        =   7641 
         _Version        =   393216 
         AllowUpdate     =   0   'False 
         HeadLines       =   1 
         RowHeight       =   15 
         BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}  
            Name            =   "MS Sans Serif" 
            Size            =   7.8 
            Charset         =   0 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}  
            Name            =   "MS Sans Serif" 
            Size            =   7.8 
            Charset         =   0 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         ColumnCount     =   2 
         BeginProperty Column00  
            DataField       =   "" 
            Caption         =   "" 
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}  
               Type            =   0 
               Format          =   "" 
               HaveTrueFalseNull=   0 
               FirstDayOfWeek  =   0 
               FirstWeekOfYear =   0 
               LCID            =   2052 
               SubFormatType   =   0 
            EndProperty 
         EndProperty 
         BeginProperty Column01  
            DataField       =   "" 
            Caption         =   "" 
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}  
               Type            =   0 
               Format          =   "" 
               HaveTrueFalseNull=   0 
               FirstDayOfWeek  =   0 
               FirstWeekOfYear =   0 
               LCID            =   2052 
               SubFormatType   =   0 
            EndProperty 
         EndProperty 
         SplitCount      =   1 
         BeginProperty Split0  
            BeginProperty Column00  
            EndProperty 
            BeginProperty Column01  
            EndProperty 
         EndProperty 
      End 
      Begin VB.TextBox txtFields  
         Height          =   285 
         Index           =   7 
         Left            =   960 
         TabIndex        =   20 
         Top             =   3600 
         Width           =   3735 
      End 
      Begin VB.TextBox txtFields  
         Height          =   285 
         Index           =   6 
         Left            =   960 
         TabIndex        =   18 
         Top             =   3120 
         Width           =   3735 
      End 
      Begin VB.TextBox txtFields  
         Height          =   285 
         Index           =   5 
         Left            =   960 
         TabIndex        =   16 
         Top             =   2640 
         Width           =   3735 
      End 
      Begin VB.TextBox txtFields  
         Height          =   285 
         Index           =   4 
         Left            =   960 
         TabIndex        =   14 
         Top             =   2160 
         Width           =   3735 
      End 
      Begin VB.TextBox txtFields  
         Height          =   285 
         Index           =   3 
         Left            =   960 
         TabIndex        =   12 
         Top             =   1680 
         Width           =   3735 
      End 
      Begin VB.TextBox txtFields  
         Height          =   855 
         Index           =   2 
         Left            =   960 
         MultiLine       =   -1  'True 
         ScrollBars      =   2  'Vertical 
         TabIndex        =   10 
         Top             =   720 
         Width           =   3735 
      End 
      Begin VB.TextBox txtFields  
         Height          =   285 
         Index           =   1 
         Left            =   3240 
         TabIndex        =   9 
         Top             =   240 
         Width           =   1455 
      End 
      Begin VB.TextBox txtFields  
         Height          =   285 
         Index           =   0 
         Left            =   960 
         TabIndex        =   7 
         Top             =   240 
         Width           =   1335 
      End 
      Begin VB.CommandButton CmdOk  
         Caption         =   "确定" 
         Height          =   375 
         Left            =   2880 
         TabIndex        =   32 
         Top             =   3960 
         Visible         =   0   'False 
         Width           =   855 
      End 
      Begin VB.CommandButton CmdCancel  
         Caption         =   "取消" 
         Height          =   375 
         Left            =   3840 
         TabIndex        =   31 
         Top             =   3960 
         Visible         =   0   'False 
         Width           =   855 
      End 
      Begin VB.Label LblWelcome  
         Alignment       =   2  'Center 
         Caption         =   "请首先选择试题库" 
         BeginProperty Font  
            Name            =   "方正舒体" 
            Size            =   21.6 
            Charset         =   134 
            Weight          =   700 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         ForeColor       =   &H000000FF& 
         Height          =   495 
         Left            =   240 
         TabIndex        =   22 
         Top             =   3840 
         Visible         =   0   'False 
         Width           =   4575 
      End 
      Begin VB.Label LblFields  
         Caption         =   "答案" 
         BeginProperty Font  
            Name            =   "华文行楷" 
            Size            =   18 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         ForeColor       =   &H000000C0& 
         Height          =   375 
         Index           =   7 
         Left            =   120 
         TabIndex        =   21 
         Top             =   3600 
         Width           =   855 
      End 
      Begin VB.Label LblFields  
         Caption         =   "选项" 
         BeginProperty Font  
            Name            =   "华文行楷" 
            Size            =   18 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         ForeColor       =   &H000000C0& 
         Height          =   375 
         Index           =   6 
         Left            =   120 
         TabIndex        =   19 
         Top             =   3120 
         Width           =   855 
      End 
      Begin VB.Label LblFields  
         Caption         =   "选项" 
         BeginProperty Font  
            Name            =   "华文行楷" 
            Size            =   18 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         ForeColor       =   &H000000C0& 
         Height          =   375 
         Index           =   5 
         Left            =   120 
         TabIndex        =   17 
         Top             =   2640 
         Width           =   855 
      End 
      Begin VB.Label LblFields  
         Caption         =   "选项" 
         BeginProperty Font  
            Name            =   "华文行楷" 
            Size            =   18 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         ForeColor       =   &H000000C0& 
         Height          =   375 
         Index           =   4 
         Left            =   120 
         TabIndex        =   15 
         Top             =   2160 
         Width           =   855 
      End 
      Begin VB.Label LblFields  
         Caption         =   "选项" 
         BeginProperty Font  
            Name            =   "华文行楷" 
            Size            =   18 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         ForeColor       =   &H000000C0& 
         Height          =   375 
         Index           =   3 
         Left            =   120 
         TabIndex        =   13 
         Top             =   1680 
         Width           =   855 
      End 
      Begin VB.Label LblFields  
         Caption         =   "问题" 
         BeginProperty Font  
            Name            =   "华文行楷" 
            Size            =   18 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         ForeColor       =   &H000000C0& 
         Height          =   375 
         Index           =   2 
         Left            =   120 
         TabIndex        =   11 
         Top             =   840 
         Width           =   855 
      End 
      Begin VB.Label LblFields  
         Caption         =   "分值" 
         BeginProperty Font  
            Name            =   "华文行楷" 
            Size            =   18 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         ForeColor       =   &H000000C0& 
         Height          =   375 
         Index           =   1 
         Left            =   2520 
         TabIndex        =   8 
         Top             =   240 
         Width           =   855 
      End 
      Begin VB.Label LblFields  
         Caption         =   "教师号" 
         BeginProperty Font  
            Name            =   "华文行楷" 
            Size            =   18 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         ForeColor       =   &H000000C0& 
         Height          =   375 
         Index           =   0 
         Left            =   120 
         TabIndex        =   6 
         Top             =   240 
         Width           =   855 
      End 
   End 
End 
Attribute VB_Name = "frmTestLib" 
Attribute VB_GlobalNameSpace = False 
Attribute VB_Creatable = False 
Attribute VB_PredeclaredId = True 
Attribute VB_Exposed = False 
Dim dbrs As ADODB.Recordset 
Dim cmdType As Byte 
Private Sub CmbType_Click() 
    Dim i As Integer 
    If Not dbrs Is Nothing Then 
        dbrs.Close 
    End If 
    For i = 0 To 7 
       LblFields(i).Visible = True 
       txtFields(i).Visible = True 
    Next 
    CmdOk.Visible = True 
    CmdCancel.Visible = True 
    LblWelcome.Visible = False 
    DataLibs.Visible = True 
    CmdFirst.Enabled = True 
    CmdPrev.Enabled = True 
    CmdNext.Enabled = True 
    CmdLast.Enabled = True 
    CmdFilter.Enabled = True 
    CmdAdd.Enabled = True 
    CmdDel.Enabled = True 
    CmdUpdate.Enabled = True 
    Select Case CmbType.ListIndex 
        Case 0 
            Set dbrs = Nothing 
            For i = 0 To 7 
            LblFields(i).Visible = False 
            txtFields(i).Visible = False 
            Next 
            LblWelcome.Visible = True 
            DataLibs.Visible = False 
            CmdFirst.Enabled = False 
            CmdPrev.Enabled = False 
            CmdNext.Enabled = False 
            CmdLast.Enabled = False 
            CmdFilter.Enabled = False 
            CmdAdd.Enabled = False 
            CmdDel.Enabled = False 
            CmdUpdate.Enabled = False 
            CmdOk.Visible = False 
            CmdCancel.Visible = False 
        Case 1 
            Set dbrs = DataEnv.rsFillingQ 
            For i = 3 To 6 
                LblFields(i).Visible = False 
                txtFields(i).Visible = False 
            Next 
        Case 2 
            Set dbrs = DataEnv.rsRorWQ 
            For i = 3 To 6 
                LblFields(i).Visible = False 
                txtFields(i).Visible = False 
            Next 
        Case 3 
            Set dbrs = DataEnv.rsSingleSelQ 
        Case 4 
            Set dbrs = DataEnv.rsMultiSelQ 
        Case 5 
            Set dbrs = DataEnv.rsEssayQ 
            For i = 3 To 6 
                LblFields(i).Visible = False 
                txtFields(i).Visible = False 
            Next 
    End Select 
    If Not dbrs Is Nothing Then 
        DataLibs.Visible = True 
        dbrs.Open 
        Set DataLibs.DataSource = dbrs 
        DataLibs.Refresh 
    End If 
End Sub 
 
Private Sub CmdAdd_Click() 
    DataLibs.Visible = False 
    FrameChoice.Enabled = False 
    FrameOpt.Enabled = False 
    CmdOk.Visible = True 
    CmdCancel.Visible = True 
    cmdType = 1 
    Dim i As Integer 
    For i = 0 To 7 
        txtFields(i).Text = "" 
    Next 
End Sub 
 
Private Sub CmdCancel_Click() 
    FrameOpt.Enabled = True 
    FrameChoice.Enabled = True 
    DataLibs.Visible = True 
End Sub 
 
Private Sub CmdDel_Click() 
    If Not dbrs Is Nothing Then 
        If Not dbrs.BOF And Not dbrs.EOF Then 
            dbrs.Delete adAffectCurrent 
        End If 
    End If 
End Sub 
 
Private Sub CmdExit_Click() 
    Unload Me 
End Sub 
 
Private Sub CmdFilter_Click() 
    If Not dbrs Is Nothing Then 
        Set frmQuerryS.dbrs = dbrs 
        frmQuerryS.Show vbModal 
        dbrs.Filter = frmQuerryS.QuerryString 
        Unload frmQuerryS 
    End If 
End Sub 
 
Private Sub CmdFirst_Click() 
    If dbrs.RecordCount > 0 Then 
        dbrs.MoveFirst 
    End If 
End Sub 
 
Private Sub CmdLast_Click() 
    If dbrs.RecordCount > 0 Then 
        dbrs.MoveLast 
    End If 
End Sub 
 
Private Sub CmdNext_Click() 
    If Not dbrs.EOF Then 
        dbrs.MoveNext 
    Else 
        MsgBox "已经达到数据表的末尾", vbCritical, "操作错误" 
    End If 
End Sub 
 
Private Sub CmdOk_Click() 
    If cmdType = 1 Then 
        dbrs.AddNew 
        dbrs.Fields("QuestionID") = dbrs.RecordCount + 1 
    End If 
    dbrs.Fields("TeacherID") = CLng(txtFields(0).Text) 
    dbrs.Fields("Score") = CSng(txtFields(1).Text) 
    dbrs.Fields("Question") = txtFields(2).Text 
    Select Case CmbType.ListIndex 
        Case 1, 5 
            dbrs.Fields("Answer") = txtFields(7).Text 
        Case 2 
            dbrs.Fields("Answer") = CBool(txtFields(7).Text) 
        Case 3 
            dbrs.Fields("Choice1") = txtFields(3).Text 
            dbrs.Fields("Choice2") = txtFields(4).Text 
            dbrs.Fields("Choice3") = txtFields(5).Text 
            dbrs.Fields("Choice4") = txtFields(6).Text 
            dbrs.Fields("Answer") = CByte(txtFields(7).Text) 
        Case 4 
            dbrs.Fields("Choice1") = txtFields(3).Text 
            dbrs.Fields("Choice2") = txtFields(4).Text 
            dbrs.Fields("Choice3") = txtFields(5).Text 
            dbrs.Fields("Choice4") = txtFields(6).Text 
            dbrs.Fields("Answer") = txtFields(7).Text 
    End Select 
    dbrs.Update 
    FrameOpt.Enabled = True 
    FrameChoice.Enabled = True 
    DataLibs.Visible = True 
End Sub 
 
Private Sub CmdPrev_Click() 
    If Not dbrs.BOF Then 
        dbrs.MovePrevious 
    Else 
        MsgBox "已经达到数据表的开头", vbCritical, "操作错误" 
    End If 
End Sub 
 
Private Sub CmdUpdate_Click() 
    On Error Resume Next 
    DataLibs.Visible = False 
    FrameChoice.Enabled = False 
    FrameOpt.Enabled = False 
    CmdOk.Visible = True 
    CmdCancel.Visible = True 
    cmdType = 2 
    txtFields(0).Text = dbrs.Fields("TeacherID") 
    txtFields(1).Text = dbrs.Fields("Score") 
    txtFields(2).Text = dbrs.Fields("Question") 
    If CmbType.ListIndex = 3 Or CmbType.ListIndex = 4 Then 
        txtFields(3).Text = dbrs.Fields("Choice1") 
        txtFields(4).Text = dbrs.Fields("Choice2") 
        txtFields(5).Text = dbrs.Fields("Choice3") 
        txtFields(6).Text = dbrs.Fields("Choice4") 
    End If 
    txtFields(7).Text = dbrs.Fields("Answer") 
End Sub 
 
Private Sub Form_Load() 
    CmbType.AddItem "---题库---" 
    CmbType.AddItem " 填空题库 " 
    CmbType.AddItem " 判断题库 " 
    CmbType.AddItem " 单选题库 " 
    CmbType.AddItem " 多选题库 " 
    CmbType.AddItem " 问答题库 " 
    CmbType.ListIndex = 0 
    LblWelcome.Left = FrameMain.Width / 2 - LblWelcome.Width / 2 
    LblWelcome.Top = FrameMain.Height / 2 - LblWelcome.Height / 2 
    LblWelcome.Visible = True 
End Sub 
 
Private Sub Form_Unload(Cancel As Integer) 
    If Not dbrs Is Nothing Then 
         dbrs.Close 
    End If 
    Set dbrs = Nothing 
End Sub