www.pudn.com > textmanager.rar > FrmSeachTM.frm, change:2005-04-12,size:19266b


VERSION 5.00 
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX" 
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX" 
Begin VB.Form FrmSeachTM  
   Caption         =   "题目查询" 
   ClientHeight    =   5025 
   ClientLeft      =   60 
   ClientTop       =   345 
   ClientWidth     =   10410 
   LinkTopic       =   "Form1" 
   LockControls    =   -1  'True 
   ScaleHeight     =   5025 
   ScaleWidth      =   10410 
   StartUpPosition =   3  '窗口缺省 
   WindowState     =   2  'Maximized 
   Begin VB.Frame Frame1  
      Caption         =   "试卷查询条件" 
      Height          =   1725 
      Left            =   105 
      TabIndex        =   2 
      Top             =   6120 
      Width           =   11415 
      Begin VB.CheckBox CheView  
         Caption         =   "(浏览时显示答案)" 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   10.5 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         ForeColor       =   &H00C00000& 
         Height          =   255 
         Left            =   7470 
         TabIndex        =   20 
         Top             =   705 
         Value           =   1  'Checked 
         Width           =   2025 
      End 
      Begin VB.Frame Frame3  
         Height          =   660 
         Left            =   6015 
         TabIndex        =   15 
         Top             =   945 
         Width           =   5325 
         Begin VB.CommandButton Command3  
            Caption         =   "浏览试卷" 
            BeginProperty Font  
               Name            =   "宋体" 
               Size            =   10.5 
               Charset         =   134 
               Weight          =   400 
               Underline       =   0   'False 
               Italic          =   0   'False 
               Strikethrough   =   0   'False 
            EndProperty 
            Height          =   420 
            Left            =   1470 
            TabIndex        =   19 
            Top             =   165 
            Width           =   1200 
         End 
         Begin VB.CommandButton Command2  
            Caption         =   "关 闭" 
            BeginProperty Font  
               Name            =   "宋体" 
               Size            =   10.5 
               Charset         =   134 
               Weight          =   400 
               Underline       =   0   'False 
               Italic          =   0   'False 
               Strikethrough   =   0   'False 
            EndProperty 
            Height          =   420 
            Left            =   4305 
            TabIndex        =   18 
            Top             =   165 
            Width           =   930 
         End 
         Begin VB.CommandButton Command1  
            Caption         =   "删除试卷" 
            BeginProperty Font  
               Name            =   "宋体" 
               Size            =   10.5 
               Charset         =   134 
               Weight          =   400 
               Underline       =   0   'False 
               Italic          =   0   'False 
               Strikethrough   =   0   'False 
            EndProperty 
            Height          =   420 
            Left            =   2895 
            TabIndex        =   17 
            Top             =   165 
            Width           =   1200 
         End 
         Begin VB.CommandButton CmdSeach  
            Caption         =   "查 询" 
            BeginProperty Font  
               Name            =   "宋体" 
               Size            =   10.5 
               Charset         =   134 
               Weight          =   400 
               Underline       =   0   'False 
               Italic          =   0   'False 
               Strikethrough   =   0   'False 
            EndProperty 
            Height          =   420 
            Left            =   300 
            TabIndex        =   16 
            Top             =   165 
            Width           =   930 
         End 
      End 
      Begin VB.TextBox TXTScore  
         Appearance      =   0  'Flat 
         BackColor       =   &H00E8F4F8& 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   10.5 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         Height          =   315 
         Left            =   1590 
         TabIndex        =   12 
         Top             =   1305 
         Width           =   510 
      End 
      Begin VB.ComboBox CmbCZS  
         BackColor       =   &H00E8F4F8& 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   10.5 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         Height          =   330 
         ItemData        =   "FrmSeachTM.frx":0000 
         Left            =   885 
         List            =   "FrmSeachTM.frx":0010 
         Style           =   2  'Dropdown List 
         TabIndex        =   11 
         Top             =   1290 
         Width           =   675 
      End 
      Begin VB.TextBox TXTID  
         Appearance      =   0  'Flat 
         BackColor       =   &H00E8F4F8& 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   10.5 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         Height          =   315 
         Left            =   1425 
         TabIndex        =   6 
         Top             =   255 
         Width           =   690 
      End 
      Begin VB.TextBox TXTTitle  
         Appearance      =   0  'Flat 
         BackColor       =   &H00E8F4F8& 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   10.5 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         Height          =   315 
         Left            =   3735 
         TabIndex        =   5 
         Top             =   225 
         Width           =   7515 
      End 
      Begin VB.ComboBox CmbKeMu  
         BackColor       =   &H00E8F4F8& 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   10.5 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         Height          =   330 
         ItemData        =   "FrmSeachTM.frx":0021 
         Left            =   750 
         List            =   "FrmSeachTM.frx":0023 
         Style           =   2  'Dropdown List 
         TabIndex        =   4 
         Top             =   825 
         Width           =   2025 
      End 
      Begin VB.ComboBox CmbNianJi  
         BackColor       =   &H00E8F4F8& 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   10.5 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         Height          =   330 
         ItemData        =   "FrmSeachTM.frx":0025 
         Left            =   3540 
         List            =   "FrmSeachTM.frx":0027 
         Style           =   2  'Dropdown List 
         TabIndex        =   3 
         Top             =   825 
         Width           =   1635 
      End 
      Begin MSComCtl2.UpDown UDScore  
         Height          =   315 
         Left            =   2085 
         TabIndex        =   13 
         Top             =   1305 
         Width           =   270 
         _ExtentX        =   476 
         _ExtentY        =   556 
         _Version        =   393216 
         BuddyControl    =   "TXTScore" 
         BuddyDispid     =   196616 
         OrigLeft        =   1995 
         OrigTop         =   705 
         OrigRight       =   2265 
         OrigBottom      =   1020 
         Max             =   300 
         SyncBuddy       =   -1  'True 
         BuddyProperty   =   0 
         Enabled         =   -1  'True 
      End 
      Begin VB.Label Label6  
         AutoSize        =   -1  'True 
         Caption         =   "总分:" 
         Height          =   180 
         Index           =   0 
         Left            =   405 
         TabIndex        =   14 
         Top             =   1380 
         Width           =   540 
      End 
      Begin VB.Label Label1  
         Caption         =   "试卷ID:" 
         Height          =   165 
         Index           =   0 
         Left            =   765 
         TabIndex        =   10 
         Top             =   345 
         Width           =   720 
      End 
      Begin VB.Label Label2  
         AutoSize        =   -1  'True 
         Caption         =   "试卷标题关键字:" 
         Height          =   180 
         Left            =   2325 
         TabIndex        =   9 
         Top             =   300 
         Width           =   1440 
      End 
      Begin VB.Label Label1  
         BackStyle       =   0  'Transparent 
         Caption         =   "科目:" 
         Height          =   165 
         Index           =   3 
         Left            =   270 
         TabIndex        =   8 
         Top             =   930 
         Width           =   540 
      End 
      Begin VB.Label Label1  
         BackStyle       =   0  'Transparent 
         Caption         =   "年级:" 
         Height          =   165 
         Index           =   4 
         Left            =   2940 
         TabIndex        =   7 
         Top             =   900 
         Width           =   540 
      End 
   End 
   Begin VB.Frame Frame2  
      Caption         =   "试卷查询结果" 
      Height          =   5850 
      Left            =   105 
      TabIndex        =   0 
      Top             =   135 
      Width           =   11415 
      Begin MSDataGridLib.DataGrid DGSJ  
         Height          =   5460 
         Left            =   105 
         TabIndex        =   1 
         Top             =   255 
         Width           =   11190 
         _ExtentX        =   19738 
         _ExtentY        =   9631 
         _Version        =   393216 
         AllowUpdate     =   0   'False 
         BackColor       =   15267064 
         HeadLines       =   1 
         RowHeight       =   18 
         BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}  
            Name            =   "宋体" 
            Size            =   12 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}  
            Name            =   "宋体" 
            Size            =   12 
            Charset         =   134 
            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  
            MarqueeStyle    =   3 
            BeginProperty Column00  
            EndProperty 
            BeginProperty Column01  
            EndProperty 
         EndProperty 
      End 
   End 
End 
Attribute VB_Name = "FrmSeachTM" 
Attribute VB_GlobalNameSpace = False 
Attribute VB_Creatable = False 
Attribute VB_PredeclaredId = True 
Attribute VB_Exposed = False 
Option Explicit 
Dim KeMuIdArr() As Long '科目id数组 
Dim NianJiIdArr() As Long 
Function GetTJStr() As String 
   '定义查询条件,保存各个查询条件 
 Dim SqlID As String 
 Dim SqlTitle As String 
 Dim SqlKeMu As String 
 Dim SqlNianJi As String 
 Dim SqlScore As String 
 
 '设置ID查询条件 
 If TXTID.Text <> "" Then 
   SqlID = " and test.id=" + TXTID.Text 
  Else 
   SqlID = "" 
 End If 
 '设置问题关键子 
 If TXTTitle.Text <> "" Then 
   SqlTitle = " and title like '%" + TXTTitle.Text + "%'" 
  Else 
   SqlTitle = "" 
 End If 
'设置年级 
 If CmbNianJi.ListIndex = 0 Then 
   SqlNianJi = "" 
  Else 
   SqlNianJi = " and nianjiid=" & NianJiIdArr(CmbNianJi.ListIndex - 1) 
 End If 
 '设置科目 
 If CmbKeMu.ListIndex = 0 Then 
   SqlKeMu = "" 
  Else 
   SqlKeMu = " and kemuid=" & KeMuIdArr(CmbKeMu.ListIndex - 1) 
 End If 
 '设置分数 
 If TXTScore.Text <> "" Then 
   SqlScore = " and zscore" + CmbCZS.Text + TXTScore.Text 
  Else 
   SqlScore = "" 
 End If 
 GetTJStr = SqlID + SqlTitle + SqlKeMu + SqlNianJi + SqlScore 
End Function 
Private Sub CmdSeach_Click() 
  Dim adoTMRs As Recordset 
   Dim sql As String 
 Set adoTMRs = New Recordset 
 
 '========================================== 
 sql = "select test.id as 试卷ID,test.title as 试卷标题,kemu.name as 科目,nianji.name as 年级,test.zscore as 试卷总分 from test,kemu,nianji where test.kemuid=kemu.id and test.nianjiid=nianji.id" 
 sql = sql + GetTJStr() 
 adoTMRs.Open sql, DB, adOpenStatic, adLockOptimistic 
 Set DGSJ.DataSource = adoTMRs 
 
End Sub 
 
Private Sub Command2_Click() 
  Unload Me 
End Sub 
 
Private Sub Command3_Click() 
If DGSJ.Row < 0 Then 
  MsgBox "请选择考试的试卷名称", vbExclamation, "提示" 
  Exit Sub 
End If 
Dim sql As String 
Dim adoRs As Recordset 
Dim strid As String '题目 ID 
Dim adoTMRs As Recordset 
Dim adoTMRsd As Recordset 
Dim adoTMTK As Recordset 
Dim adoTMPD As Recordset 
Dim adoTMWD As Recordset 
Dim adoTMZW As Recordset 
 
Dim sqld As String 
'查询试卷 
Set adoRs = New Recordset 
sql = "select * from test where id=" + DGSJ.Columns(0).Text 
adoRs.Open sql, DB, adOpenStatic, adLockOptimistic 
'预览试卷 
'单选 
strid = adoRs.Fields("danxuan").Value 
If strid = "" Then strid = "0" 
Set adoTMRs = New Recordset 
sql = "select * from question where id in (" + strid + ")" ' 
adoTMRs.Open sql, DB, adOpenStatic, adLockOptimistic 
'多选 
strid = adoRs.Fields("duoxuan").Value 
If strid = "" Then strid = "0" 
Set adoTMRsd = New Recordset 
sqld = "select * from question where id in (" + strid + ") " 
adoTMRsd.Open sqld, DB, adOpenStatic, adLockOptimistic 
'填空 
strid = adoRs.Fields("tiankong").Value 
If strid = "" Then strid = "0" 
Set adoTMTK = New Recordset 
sqld = "select * from questionTK where id in (" + strid + ") " 
adoTMTK.Open sqld, DB, adOpenStatic, adLockOptimistic 
'判断 
strid = adoRs.Fields("panduan").Value 
If strid = "" Then strid = "0" 
Set adoTMPD = New Recordset 
sqld = "select * from questionPD where id in (" + strid + ") " 
adoTMPD.Open sqld, DB, adOpenStatic, adLockOptimistic 
'问答 
strid = adoRs.Fields("wenda").Value 
If strid = "" Then strid = "0" 
Set adoTMWD = New Recordset 
sqld = "select * from questionWD where id in (" + strid + ") " 
adoTMWD.Open sqld, DB, adOpenStatic, adLockOptimistic 
'作文 
strid = adoRs.Fields("zuowen").Value 
If strid = "" Then strid = "0" 
Set adoTMZW = New Recordset 
sqld = "select * from questionZW where id in (" + strid + ") " 
adoTMZW.Open sqld, DB, adOpenStatic, adLockOptimistic 
 
'生成HTML文件 
Dim DaView As Boolean 
DaView = False 
If CheView = 1 Then 
   DaView = True 
End If 
CreateHTML App.Path + "\temp.html", DGSJ.Columns(1).Text, DaView, adoTMRs, adoTMRsd, adoTMTK, adoTMPD, adoTMWD, adoTMZW 
   'FrmView.Web.LocationURL = App.Path + "\temp.html" 
   Set adoTMRs = Nothing 
   Set adoTMRsd = Nothing 
   Set adoTMTK = Nothing 
   Set adoTMPD = Nothing 
   Set adoTMWD = Nothing 
   Set adoTMZW = Nothing 
FrmView.Web.Navigate App.Path + "\temp.html" 
FrmView.Show 1 
End Sub 
 
Private Sub Form_Load() 
 Dim adoRs As Recordset 
 Set adoRs = New Recordset 
 Dim i As Integer 
 '添加总类到下来框 
   
'年级 
adoRs.Open "select id,name from nianji", DB, adOpenStatic, adLockOptimistic 
CmbNianJi.AddItem "所有年级" 
If Not adoRs.EOF Then 
  adoRs.MoveLast 
  adoRs.MoveFirst 
  ReDim NianJiIdArr(adoRs.RecordCount) As Long 
  For i = 0 To adoRs.RecordCount - 1 
     CmbNianJi.AddItem adoRs.Fields("name").Value 
     NianJiIdArr(i) = adoRs.Fields("id").Value 
     adoRs.MoveNext 
  Next i 
End If 
adoRs.Close 
'科目 
adoRs.Open "kemu", DB, adOpenStatic, adLockOptimistic 
CmbKeMu.AddItem "所有科目" 
If Not adoRs.EOF Then 
  adoRs.MoveLast 
  adoRs.MoveFirst 
  ReDim KeMuIdArr(adoRs.RecordCount) As Long 
  For i = 0 To adoRs.RecordCount - 1 
     CmbKeMu.AddItem adoRs.Fields("name").Value 
     KeMuIdArr(i) = adoRs.Fields("id").Value 
     adoRs.MoveNext 
  Next i 
End If 
CmbKeMu.ListIndex = 0 
CmbNianJi.ListIndex = 0 
CmbCZS.ListIndex = 0 
adoRs.Close 
  '查询显示所有试卷 
 adoRs.Open "select test.id as 试卷ID,test.title as 试卷标题,kemu.name as 科目,nianji.name as 年级,test.zscore as 试卷总分 from test,kemu,nianji where test.kemuid=kemu.id and test.nianjiid=nianji.id", DB, adOpenStatic, adLockOptimistic 
 Set DGSJ.DataSource = adoRs 
 
End Sub 
 
Private Sub TXTID_KeyPress(KeyAscii As Integer) 
    If Not ((KeyAscii >= 48 And KeyAscii <= 57) Or KeyAscii = 8 Or KeyAscii = 46) Then 
  KeyAscii = 0 
 End If 
 
End Sub 
 
Private Sub TXTScore_KeyPress(KeyAscii As Integer) 
    If Not ((KeyAscii >= 48 And KeyAscii <= 57) Or KeyAscii = 8 Or KeyAscii = 46) Then 
  KeyAscii = 0 
 End If 
 
End Sub 
 
Private Sub TxTTitle_KeyPress(KeyAscii As Integer) 
   If KeyAscii = 39 Then KeyAscii = -24145 
 
End Sub