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

📄 frmquerymaintain.frm

📁 数据库课程设计
💻 FRM
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "Msflxgrd.ocx"
Begin VB.Form frmQueryMaintain 
   Caption         =   "维修查询"
   ClientHeight    =   3705
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   6600
   LinkTopic       =   "Form1"
   ScaleHeight     =   3705
   ScaleWidth      =   6600
   StartUpPosition =   3  'Windows Default
   Begin MSFlexGridLib.MSFlexGrid fgHistory 
      Height          =   1695
      Left            =   120
      TabIndex        =   6
      Top             =   1920
      Width           =   6375
      _ExtentX        =   11245
      _ExtentY        =   2990
      _Version        =   393216
   End
   Begin VB.Frame Frame1 
      Caption         =   "查询方式"
      Height          =   1455
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   6375
      Begin VB.CommandButton cmdCancel 
         Caption         =   "返回(&C)"
         Height          =   375
         Left            =   4920
         TabIndex        =   9
         Top             =   840
         Width           =   1215
      End
      Begin VB.CommandButton cmdQuery 
         Caption         =   "查询(&Q)"
         Height          =   375
         Left            =   4920
         TabIndex        =   8
         Top             =   360
         Width           =   1215
      End
      Begin VB.ComboBox cboDate 
         Height          =   315
         Left            =   1440
         TabIndex        =   5
         Text            =   "Combo1"
         Top             =   840
         Width           =   1575
      End
      Begin VB.TextBox txtNo 
         Height          =   375
         Left            =   1440
         TabIndex        =   4
         Text            =   "Text1"
         Top             =   360
         Width           =   1575
      End
      Begin VB.OptionButton optQuery 
         Caption         =   "全部维修信息"
         Height          =   375
         Index           =   2
         Left            =   3240
         TabIndex        =   3
         Top             =   360
         Width           =   1455
      End
      Begin VB.OptionButton optQuery 
         Caption         =   "按维修日期"
         Height          =   255
         Index           =   1
         Left            =   240
         TabIndex        =   2
         Top             =   840
         Width           =   1575
      End
      Begin VB.OptionButton optQuery 
         Caption         =   "按设备编号"
         Height          =   375
         Index           =   0
         Left            =   240
         TabIndex        =   1
         Top             =   360
         Width           =   1455
      End
   End
   Begin VB.Label Label1 
      Caption         =   "查询结果:"
      Height          =   255
      Left            =   120
      TabIndex        =   7
      Top             =   1680
      Width           =   1935
   End
End
Attribute VB_Name = "frmQueryMaintain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Public sqlStr As String
Public msgText As String

Private Sub cmdCancel_Click()
Unload Me
End Sub

Private Sub cmdQuery_Click()
queryMaintainInfo
End Sub

Sub queryMaintainInfo()
    Dim rs As ADODB.Recordset
    Dim i As Integer
    Dim j As Integer
    
    If optQuery(0).Value = True Then
         If txtNo = "" Then
            MsgBox "设备名称不能为空,请输入查询条件!!"
            Exit Sub
         End If
         sqlStr = "select * from maintainence where" _
         & " deviceNo='" & txtNo.Text & "'"
    End If
    
    If optQuery(1).Value = True Then
         sqlStr = "select * from maintainence where" _
         & " maintainDate=#" & cboDate.Text & "#"
    End If
    
    If optQuery(2).Value = True Then
         sqlStr = "select * from maintainence"
    End If
    
    Set rs = ExecuteSQL(sqlStr, msgText)
    
    If rs.RecordCount = 0 Then
    
        MsgBox "没有查找满足条件的数据!", vbExclamation, "提示"
        fgHistory.Rows = 1
       
    Else
        
        fgHistory.Rows = rs.RecordCount + 1
        
        fgHistory.Cols = 5
        
        '设定行高
        For i = 0 To fgHistory.Rows - 1
           fgHistory.RowHeight(i) = 280
        Next i
        
        '设定列的属性
        fgHistory.Row = 0
        
        For i = 0 To fgHistory.Cols - 1
           fgHistory.Col = i  '指定当前列为第i列
           fgHistory.FixedAlignment(i) = 4  '每列内容居中显示
           Select Case i
               Case 0
                  fgHistory.ColWidth(i) = 600  '设定列宽
                  fgHistory.Text = "序号"
               Case 1
                  fgHistory.ColWidth(i) = 1200  '设定列宽
                  fgHistory.Text = "设备编号"
               Case 2
                  fgHistory.ColWidth(i) = 2000  '设定列宽
                  fgHistory.Text = "维修内容"
               Case 3
                  fgHistory.ColWidth(i) = 1200  '设定列宽
                  fgHistory.Text = "维修日期"
               Case 4
                  fgHistory.ColWidth(i) = 1000  '设定列宽
                  fgHistory.Text = "备注"
            End Select
               
        Next i
           
           
        'rs.MoveFirst
        
        i = 1
        
        While (Not rs.EOF)
        
           fgHistory.Row = i
           For j = 0 To fgHistory.Cols - 1
           
            fgHistory.Col = j '设置当前为列为第j列
            fgHistory.CellAlignment = 4  '每列内容居中显示
        
            
            Select Case j
               Case 0
                  fgHistory.Text = "" & i
               Case 1
                  fgHistory.Text = rs.Fields("deviceNo")
               Case 2
                  fgHistory.Text = rs.Fields("contents")
               Case 3
                  fgHistory.Text = rs.Fields("maintainDate")
               Case 4
                  fgHistory.Text = rs.Fields("memo")
            End Select
          Next j
        
            rs.MoveNext
            i = i + 1
        Wend
    
    End If
    
    rs.Close

End Sub


Private Sub Form_Load()

'窗体居中显示
Me.Top = (Screen.Height - Me.Height) \ 2
Me.Left = (Screen.Width - Me.Width) \ 2

txtNo = ""
cboDate.Text = ""
initDate
End Sub

Sub initDate()
'将所有维修日期添加到组合列表框中
Dim rstDate As ADODB.Recordset

    '从维修记录表中读取所有维修日期并添加到组合列表框中
    sqlStr = "select distinct maintainDate from maintainence"
    Set rstDate = ExecuteSQL(sqlStr, msgText)
    cboDate.Clear
    
    If Not rstDate.EOF Then
            Do While Not rstDate.EOF
                cboDate.AddItem Trim(rstDate.Fields(0))
                rstDate.MoveNext
            Loop
            cboDate.ListIndex = 0
    Else
        MsgBox "没有找到相关信息,请添加!", vbOKOnly + vbExclamation, "警告"
        
        Exit Sub
    End If
    rstDate.Close

End Sub

⌨️ 快捷键说明

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