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

📄 frmteacherinfo.frm

📁 这是一个选课系统
💻 FRM
📖 第 1 页 / 共 2 页
字号:
      Height          =   450
      Left            =   1080
      Picture         =   "frmteacherinfo.frx":6318
      Top             =   0
      Width           =   285
   End
   Begin VB.Image imgTitleRight 
      Height          =   450
      Left            =   1680
      Picture         =   "frmteacherinfo.frx":6A62
      Top             =   0
      Width           =   285
   End
   Begin VB.Image imgWindowBottomLeft 
      Height          =   450
      Left            =   2160
      Picture         =   "frmteacherinfo.frx":71AC
      Top             =   0
      Width           =   285
   End
   Begin VB.Image imgWindowBottomRight 
      Height          =   450
      Left            =   2880
      Picture         =   "frmteacherinfo.frx":78F6
      Top             =   0
      Width           =   285
   End
   Begin VB.Line Line1 
      X1              =   0
      X2              =   10080
      Y1              =   1200
      Y2              =   1200
   End
   Begin VB.Label Label1 
      Caption         =   "查询条件"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   240
      TabIndex        =   0
      Top             =   600
      Width           =   1455
   End
End
Attribute VB_Name = "frmteacherinfo"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim txtSQL As String





Private Sub Form_Load()
 MakeWindow Me
 SmartNetXpButton4.Enabled = False
 Dim mrc As ADODB.Recordset
 Dim MsgText As String
 Dim i As Integer
 txtSQL = "select tno,tname from teacher"
 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 teacher 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 & "Tno = '" & 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 Tname= '" & Trim(Combo2.Text) & "'"
            Else
                txtSQL = txtSQL & " Tname= '" & 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 Tno"
       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) = "职称"
           .TextMatrix(1, 5) = "联系方式"
           .TextMatrix(1, 6) = "地址"
           .TextMatrix(1, 7) = "备注"
       
           
        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)
            .TextMatrix(.Rows - 1, 5) = mrc.Fields(4)
            .TextMatrix(.Rows - 1, 6) = mrc.Fields(5)
            .TextMatrix(.Rows - 1, 7) = mrc.Fields(6)
            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
    SmartNetXpButton4.Enabled = True
    txtSQL = "select * from teacher order by Tno"
   Set mrc = MyDB.ExecuteSQL(txtSQL, MsgText)
   
    With MSFlexGrid1
           .Rows = 2
           .CellAlignment = 4
           .TextMatrix(1, 1) = "教师编号"
           .TextMatrix(1, 2) = "姓名"
           .TextMatrix(1, 3) = "性别"
           .TextMatrix(1, 4) = "职称"
           .TextMatrix(1, 5) = "联系方式"
           .TextMatrix(1, 6) = "地址"
           .TextMatrix(1, 7) = "备注"
     
        
           
        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)
            .TextMatrix(.Rows - 1, 5) = mrc.Fields(4)
            .TextMatrix(.Rows - 1, 6) = mrc.Fields(5)
            .TextMatrix(.Rows - 1, 7) = mrc.Fields(6)
          
            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 + -