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

📄 frmcourseinfo.frm

📁 在VB应用程序平台上开发的SQL学生选课数据库系统。可以实现学生选择自己要上的课
💻 FRM
📖 第 1 页 / 共 2 页
字号:
      Top             =   0
      Width           =   285
   End
   Begin VB.Image imgWindowBottom 
      Height          =   450
      Left            =   2040
      Picture         =   "frmcourseinfo.frx":333B
      Stretch         =   -1  'True
      Top             =   0
      Width           =   285
   End
   Begin VB.Image imgWindowRight 
      Height          =   450
      Left            =   2400
      Picture         =   "frmcourseinfo.frx":3A85
      Stretch         =   -1  'True
      Top             =   0
      Width           =   285
   End
   Begin VB.Image imgWindowLeft 
      Height          =   450
      Left            =   2760
      Picture         =   "frmcourseinfo.frx":41CF
      Stretch         =   -1  'True
      Top             =   0
      Width           =   285
   End
   Begin VB.Label Label1 
      BackStyle       =   0  'Transparent
      Caption         =   "查询条件:"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   360
      TabIndex        =   8
      Top             =   480
      Width           =   1335
   End
   Begin VB.Image Imageicon 
      Height          =   315
      Left            =   3720
      Picture         =   "frmcourseinfo.frx":4919
      Stretch         =   -1  'True
      Top             =   120
      Width           =   315
   End
   Begin VB.Line Line1 
      X1              =   0
      X2              =   8760
      Y1              =   960
      Y2              =   960
   End
End
Attribute VB_Name = "frmcourseinfo"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim txtSQL As String



Private Sub Form_Load()
 MakeWindow Me
 Dim MsgText As String
 Dim mrc As ADODB.Recordset
 Dim i As Integer
 SmartNetXpButton4.Enabled = False
 txtSQL = "select cno,cname from course "
 Set mrc = MyDB.ExecuteSQL(txtSQL, MsgText)
 For i = 0 To mrc.RecordCount - 1
  Combo1.AddItem mrc.Fields(0)
  
  Combo2.AddItem mrc.Fields(1)
  mrc.MoveNext
 Next i
 
 End Sub

Private Sub SmartNetXpButton1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
 Dim MsgText As String
    Dim dd(2) As Boolean
    Dim mrc As ADODB.Recordset
    Dim rs As Boolean
    Dim sMeg As String
    rs = True
       
    On Error Resume Next
    
    txtSQL = "select * from course where "
    If Check1.Value Then
        If Trim(Combo1.Text) = "" Then
            sMeg = "课程号不能为空"
            MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
            Combo1.SetFocus
            Exit Sub
        Else
            
            dd(0) = True
            txtSQL = txtSQL & "Cno = '" & Trim(Combo1.Text) & "'"
        End If
    End If
    
    If Check2.Value Then
        If Trim(Combo2.Text) = "" Then
            sMeg = "课程名不能为空"
            MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
            Combo2.SetFocus
            Exit Sub
        Else
            dd(1) = True
            If dd(0) Then
                txtSQL = txtSQL & "and Cname= '" & Trim(Combo2.Text) & "'"
            Else
                txtSQL = txtSQL & " Cname= '" & Trim(Combo2.Text) & "'"
            End If
        End If
    End If
    
   
    
    
    
    If Not (dd(0) Or dd(1)) Then
        MsgBox "请设置查询方式!", vbOKOnly + vbExclamation, "警告"
        Exit Sub
    End If
    
    If rs = True Then
    
       txtSQL = txtSQL & " order by Cno"
       Set mrc = MyDB.ExecuteSQL(txtSQL, MsgText)
         If mrc.RecordCount > 0 Then                     '设置打印功能
           SmartNetXpButton4.Enabled = True
        Else
           SmartNetXpButton4.Enabled = False
        End If
            
       With MSFlexGrid1
           .Rows = 2
           .CellAlignment = 4
           .TextMatrix(1, 1) = "课程号"
           .TextMatrix(1, 2) = "课程名"
           .TextMatrix(1, 3) = "学时"
           .TextMatrix(1, 4) = "学分"
        
       
           
        Do While Not mrc.EOF
            
          
            .Rows = .Rows + 1
            .CellAlignment = 4
            .TextMatrix(.Rows - 1, 1) = mrc.Fields(0)
            .TextMatrix(.Rows - 1, 2) = mrc.Fields(1)
            .TextMatrix(.Rows - 1, 3) = mrc.Fields(2)
            .TextMatrix(.Rows - 1, 4) = mrc.Fields(3)
        
            mrc.MoveNext
         Loop
        
       End With
    
    mrc.Close
   End If
End Sub



Private Sub SmartNetXpButton2_Click()
   Dim mrc As ADODB.Recordset
   Dim MsgText As String
   'Dim txtstring As String
   txtSQL = "select * from course order by Cno"
   Set mrc = MyDB.ExecuteSQL(txtSQL, MsgText)
   SmartNetXpButton4.Enabled = True
    With MSFlexGrid1
           .Rows = 2
           .CellAlignment = 4
           .TextMatrix(1, 1) = "课程号"
           .TextMatrix(1, 2) = "课程名"
           .TextMatrix(1, 3) = "学时"
           .TextMatrix(1, 4) = "学分"
     
        
           
        Do While Not mrc.EOF
            
          
            .Rows = .Rows + 1
            .CellAlignment = 4
            .TextMatrix(.Rows - 1, 1) = mrc.Fields(0)
            .TextMatrix(.Rows - 1, 2) = mrc.Fields(1)
            .TextMatrix(.Rows - 1, 3) = mrc.Fields(2)
            .TextMatrix(.Rows - 1, 4) = mrc.Fields(3)
          
            mrc.MoveNext
         Loop
        
       End With
    
    mrc.Close
End Sub

Private Sub SmartNetXpButton3_Click()
 Unload Me
End Sub


Private Sub Image2_Click()
   Unload Me
End Sub

Private Sub imgTitleclose_Click()
 Unload Me
End Sub

Private Sub imgTitleLeft_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    DoDrag Me
End Sub

Private Sub imgTitleMain_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    DoDrag Me
End Sub

Private Sub imgTitleMinimize_Click()
    Me.WindowState = 1
End Sub

Private Sub imgTitleRestore_Click()
 Me.WindowState = 2
End Sub

Private Sub imgTitleRight_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    DoDrag Me
End Sub


Private Sub lblTitle_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    DoDrag Me
End Sub


Private Sub SmartNetXpButton4_Click()
  Dim i As Integer, j As Integer
   
    Dim MsgText As String
    Dim expworkbook As Excel.Workbook
    Dim expexcel As Excel.Application
    Dim mrc As ADODB.Recordset
    Set expexcel = New Excel.Application
    expexcel.Visible = True
    expexcel.SheetsInNewWorkbook = 1
    Set expworkbook = expexcel.Workbooks.Add
  

    Set mrc = MyDB.ExecuteSQL(txtSQL, MsgText)

     
    For i = 0 To mrc.Fields.Count - 1
        expexcel.Cells(2, i + 1) = mrc.Fields(i).Name
    Next
    mrc.MoveFirst
    For j = 1 To MSFlexGrid1.Rows
        For i = 0 To mrc.Fields.Count - 1
            expexcel.Cells(j + 2, i + 1) = CStr(mrc.Fields(i))
        Next
        mrc.MoveNext
        If mrc.EOF Then Exit For
    Next
        
    Set expexcel = Nothing
End Sub

⌨️ 快捷键说明

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