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

📄 frmquery_student.frm

📁 用VB开发的一个学生管理系统
💻 FRM
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form Frmquery_student 
   Caption         =   "学生管理-查询"
   ClientHeight    =   5310
   ClientLeft      =   60
   ClientTop       =   420
   ClientWidth     =   8895
   LinkTopic       =   "Form1"
   ScaleHeight     =   5310
   ScaleWidth      =   8895
   StartUpPosition =   2  '屏幕中心
   Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1 
      Height          =   2415
      Left            =   600
      TabIndex        =   10
      Top             =   2760
      Width           =   8055
      _ExtentX        =   14208
      _ExtentY        =   4260
      _Version        =   393216
   End
   Begin VB.CommandButton cmd_cancel 
      Caption         =   "返回"
      Height          =   375
      Left            =   4920
      TabIndex        =   6
      Top             =   2160
      Width           =   1455
   End
   Begin VB.CommandButton cmd_query 
      Caption         =   "查询"
      Height          =   375
      Left            =   2280
      TabIndex        =   5
      Top             =   2160
      Width           =   1575
   End
   Begin VB.Frame Frame1 
      Caption         =   "查询条件"
      Height          =   1575
      Left            =   480
      TabIndex        =   0
      Top             =   360
      Width           =   7815
      Begin VB.ComboBox stu_class 
         Height          =   300
         Left            =   2160
         TabIndex        =   9
         Top             =   1080
         Width           =   1455
      End
      Begin VB.TextBox stu_name 
         Height          =   375
         Left            =   5880
         TabIndex        =   8
         Top             =   960
         Width           =   1575
      End
      Begin VB.TextBox stu_no 
         Height          =   375
         Left            =   5880
         TabIndex        =   7
         Top             =   360
         Width           =   1575
      End
      Begin VB.OptionButton Option_stuname 
         Caption         =   "按姓名查询"
         Height          =   255
         Left            =   4200
         TabIndex        =   4
         Top             =   960
         Width           =   1455
      End
      Begin VB.OptionButton Option_stuno 
         Caption         =   "按学号查询"
         Height          =   255
         Left            =   4200
         TabIndex        =   3
         Top             =   360
         Width           =   1455
      End
      Begin VB.OptionButton Option_stuclass 
         Caption         =   "按班级查询"
         Height          =   255
         Left            =   720
         TabIndex        =   2
         Top             =   1080
         Width           =   1335
      End
      Begin VB.OptionButton Option_all 
         Caption         =   "查询全部"
         Height          =   255
         Left            =   720
         TabIndex        =   1
         Top             =   480
         Width           =   1215
      End
   End
End
Attribute VB_Name = "Frmquery_student"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmd_cancel_Click()
Unload Me
End Sub
Sub initClass()
Dim rstclass As ADODB.Recordset
sqlStr = "select className from Classes"
Set rstclass = executesql(sqlStr, msgText)
Stu_class.Clear
If Not rstclass.EOF Then
Do While Not rstclass.EOF
    Stu_class.AddItem Trim(rstclass.Fields(0))
    rstclass.MoveNext
Loop
Stu_class.ListIndex = 0
Else
MsgBox "请添加班级", vbOKOnly + vbExclamation, "警告"
Exit Sub
End If
rstclass.Close

End Sub

Private Sub cmd_query_Click()
Dim rs As ADODB.Recordset
Dim i As Integer
Dim j As Integer

If Option_all.Value = True Then
 Option_stuclass.Value = False
 Option_stuno.Value = False
 Option_stuname.Value = False
 sqlStr = "select * from students "
 End If

If Option_stuclass.Value = True Then
 Option_all.Value = False
 Option_stuno.Value = False
 Option_stuname.Value = False
 Stu_no.Text = ""
 Stu_name.Text = ""
 sqlStr = "select * from students where class_no like  '%" & Stu_class.Text & "%'"
 End If
 
If Option_stuno.Value = True Then
 Option_all.Value = False
 Option_stuclass.Value = False
 Option_stuname.Value = False
 Stu_class.Text = ""
 Stu_name.Text = ""
 sqlStr = "select * from students where stu_no like '%" & Stu_no.Text & "%'"
End If

If Option_stuname.Value = True Then
 Option_all.Value = False
 Option_stuclass.Value = False
 Option_stuno.Value = False
 Stu_class.Text = ""
 Stu_no.Text = ""
 sqlStr = "select * from students where Name like '%" & Stu_name.Text & "%'"
 End If
 
 Set rs = executesql(sqlStr, msgText)
If rs.RecordCount = 0 Then
MsgBox "没有查找满足条件的数据!", vbExclamation, "提示"
MSFlexGrid1.Rows = 1
Else
MSFlexGrid1.Rows = rs.RecordCount + 1
MSFlexGrid1.Cols = 8
End If
For i = 0 To MSFlexGrid1.Rows - 1
MSFlexGrid1.RowHeight(i) = 280
 Next i
 MSFlexGrid1.Row = 0
 For i = 0 To MSFlexGrid1.Cols - 1
 MSFlexGrid1.Col = i
 MSFlexGrid1.FixedAlignment(i) = 4
 Select Case i
 Case 0
 MSFlexGrid1.ColWidth(i) = 800
 MSFlexGrid1.Text = "序号"
 Case 1
 MSFlexGrid1.ColWidth(i) = 1200
 MSFlexGrid1.Text = "学号"
 Case 2
 MSFlexGrid1.ColWidth(i) = 800
 MSFlexGrid1.Text = "姓名"
 Case 3
 MSFlexGrid1.ColWidth(i) = 1000
 MSFlexGrid1.Text = "出生日期"
 Case 4
 MSFlexGrid1.ColWidth(i) = 1500
 MSFlexGrid1.Text = "班级"
 Case 5
 MSFlexGrid1.ColWidth(i) = 600
 MSFlexGrid1.Text = "性别"
 Case 6
 MSFlexGrid1.ColWidth(i) = 2000
 MSFlexGrid1.Text = "地址"
 Case 7
 MSFlexGrid1.ColWidth(i) = 1500
 MSFlexGrid1.Text = "电话"
End Select
Next i

 i = 1
While (Not rs.EOF)
MSFlexGrid1.Row = i

For j = 0 To MSFlexGrid1.Cols - 1
MSFlexGrid1.Col = j
MSFlexGrid1.CellAlignment = 4
Select Case j
Case 0
MSFlexGrid1.Text = i
Case 1
MSFlexGrid1.Text = rs.Fields("stu_no")
Case 2
MSFlexGrid1.Text = rs.Fields("Name")
Case 3
MSFlexGrid1.Text = rs.Fields("Birthdate")
Case 4
MSFlexGrid1.Text = rs.Fields("class_no")
Case 5
MSFlexGrid1.Text = rs.Fields("Sex")
Case 6
MSFlexGrid1.Text = rs.Fields("Address")
Case 7
MSFlexGrid1.Text = rs.Fields("Telno")
End Select
Next j
i = i + 1
rs.MoveNext

Wend
rs.Close
End Sub

Private Sub Form_Load()
 initClass
 Stu_class.Text = ""
 Option_all.Value = False
 Option_stuclass.Value = False
 Option_stuno.Value = False
 Option_stuname.Value = False
 
 
End Sub
'Private Sub stu_no_lostfocus()

  ' Call getStudentInfo

'End Sub

⌨️ 快捷键说明

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