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

📄 frmquery_score.frm

📁 用VB开发的一个学生管理系统
💻 FRM
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form Frmquery_score 
   Caption         =   "成绩查询"
   ClientHeight    =   4770
   ClientLeft      =   60
   ClientTop       =   420
   ClientWidth     =   7065
   LinkTopic       =   "Form1"
   ScaleHeight     =   4770
   ScaleWidth      =   7065
   StartUpPosition =   2  '屏幕中心
   Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1 
      Height          =   1815
      Left            =   480
      TabIndex        =   10
      Top             =   2760
      Width           =   6495
      _ExtentX        =   11456
      _ExtentY        =   3201
      _Version        =   393216
   End
   Begin VB.CommandButton cmd_cancel 
      Caption         =   "取消"
      Height          =   375
      Left            =   3480
      TabIndex        =   9
      Top             =   2160
      Width           =   855
   End
   Begin VB.CommandButton cmd_query 
      Caption         =   "查询"
      Height          =   375
      Left            =   2040
      TabIndex        =   8
      Top             =   2160
      Width           =   975
   End
   Begin VB.Frame Frame1 
      Caption         =   "Frame1"
      Height          =   1815
      Left            =   480
      TabIndex        =   0
      Top             =   240
      Width           =   6375
      Begin VB.TextBox course_name 
         Height          =   375
         Left            =   4800
         TabIndex        =   15
         Top             =   840
         Width           =   1455
      End
      Begin VB.TextBox stu_name 
         Height          =   375
         Left            =   4800
         TabIndex        =   14
         Top             =   360
         Width           =   1095
      End
      Begin VB.TextBox score2 
         Height          =   375
         Left            =   5520
         TabIndex        =   11
         Top             =   1320
         Width           =   615
      End
      Begin VB.TextBox score1 
         Height          =   375
         Left            =   3960
         TabIndex        =   7
         Top             =   1320
         Width           =   615
      End
      Begin VB.ComboBox score_option 
         Height          =   300
         Left            =   2040
         TabIndex        =   6
         Top             =   1320
         Width           =   1455
      End
      Begin VB.ComboBox course_no 
         Height          =   300
         Left            =   2040
         TabIndex        =   5
         Top             =   840
         Width           =   1575
      End
      Begin VB.ComboBox stu_no 
         Height          =   300
         Left            =   2040
         TabIndex        =   4
         Top             =   360
         Width           =   1575
      End
      Begin VB.CheckBox Check_score 
         Caption         =   "按成绩"
         Height          =   255
         Left            =   600
         TabIndex        =   3
         Top             =   1320
         Width           =   975
      End
      Begin VB.CheckBox Check_courseno 
         Caption         =   "按课程编号"
         Height          =   255
         Left            =   600
         TabIndex        =   2
         Top             =   840
         Width           =   1335
      End
      Begin VB.CheckBox Check_stuno 
         Caption         =   "按学号"
         Height          =   255
         Left            =   600
         TabIndex        =   1
         Top             =   360
         Width           =   975
      End
      Begin VB.Label Label4 
         Caption         =   "课程名称:"
         Height          =   255
         Left            =   3720
         TabIndex        =   17
         Top             =   960
         Width           =   975
      End
      Begin VB.Label Label3 
         Caption         =   "学生姓名:"
         Height          =   255
         Left            =   3720
         TabIndex        =   16
         Top             =   360
         Width           =   975
      End
      Begin VB.Label Label2 
         Caption         =   "值2:"
         Height          =   255
         Left            =   4920
         TabIndex        =   13
         Top             =   1440
         Width           =   495
      End
      Begin VB.Label Label1 
         Caption         =   "值1:"
         Height          =   255
         Left            =   3480
         TabIndex        =   12
         Top             =   1440
         Width           =   495
      End
   End
End
Attribute VB_Name = "Frmquery_score"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Sub initcourse_no()
Dim rstcourse As ADODB.Recordset
sqlStr = "select Course_no from courses "
Set rstcourse = executesql(sqlStr, msgText)
course_no.Clear
If Not rstcourse.EOF Then
Do While Not rstcourse.EOF
   course_no.AddItem Trim(rstcourse.Fields(0))
   rstcourse.MoveNext
Loop
course_no.ListIndex = 0
Else
MsgBox "请添加课程编号", vbOKOnly + vbExclamation, "警告"
Exit Sub
End If
rstcourse.Close
End Sub
Sub initform()
stu_no = ""
stu_name = ""
course_no = ""
course_name = ""
score_option = ""
score1 = ""
score2 = ""
Check_stuno.Value = False
Check_courseno.Value = False
Check_score.Value = False
End Sub
Sub initstu_no()
Dim rststudent As ADODB.Recordset
sqlStr = "select stu_no from students "
Set rststudent = executesql(sqlStr, msgText)
stu_no.Clear
If Not rststudent.EOF Then
Do While Not rststudent.EOF
   stu_no.AddItem Trim(rststudent.Fields(0))
   rststudent.MoveNext
Loop
stu_no.ListIndex = 0
Else
MsgBox "请添加学生编号", vbOKOnly + vbExclamation, "警告"
Exit Sub
End If
rststudent.Close
End Sub
Private Sub cmd_cancel_Click()
Unload Me
End Sub

Private Sub cmd_query_Click()
Dim rs As ADODB.Recordset
Dim sqlstr1 As String
Dim sqlcond1 As String
Dim sqlcond2 As String
Dim sqlcond3 As String
Dim sign As Boolean

sqlcond1 = ""
sqlcond2 = ""
sqlcond3 = ""
sign = False
sqlStr = "select students.stu_no as stu_no,students.name as stu_name," & "courses.course_name as course_name,score.score as score " & " from students,courses,score where "
If Check_stuno.Value <> 1 And Check_courseno.Value <> 1 And Check_score.Value <> 1 Then
MsgBox "请选择查询条件!"
Exit Sub
End If
If Check_stuno.Value = 1 Then
sqlcond1 = " students.stu_no='" & Trim(stu_no.Text) & "'"
End If
If Check_courseno.Value = 1 Then
sqlcond2 = " score.course_no='" & Trim(course_no) & "'"
End If
If Check_score.Value = 1 Then
  If score_option.Text <> "between" Then
  score2.Enabled = True
  sqlcond3 = " score.score " & score_option.Text & Trim(score1.Text)
  Else
  sqlcond3 = " Score.score " & score_option.Text & " " & Trim(score1.Text) & " and " & Trim(score2.Text)
  End If
End If
 If sqlcond1 <> "" Then
 sqlStr = sqlStr & sqlcond1
 sign = True
 End If
 If sqlcond2 <> "" Then
     If sign = True Then
        sqlStr = sqlStr & " and " & sqlcond2
     Else
     sqlStr = sqlStr & sqlcond2
     End If
End If
 If sqlcond3 <> "" Then
   If sign = True Then
      sqlStr = sqlStr & " and " & sqlcond3
   Else
       sqlStr = sqlStr & sqlcond3
   End If
 End If
 
 sqlStr = sqlStr & " and students.stu_no=score.stu_no " & " and  courses.course_no=score.course_no"
 Set rs = executesql(sqlStr, msgText)
 
  If rs.RecordCount = 0 Then
MsgBox "没有查找到满足条件的数据!", vbExclamation, "提示"
MSFlexGrid1.Rows = 1
Else
MSFlexGrid1.Rows = rs.RecordCount + 1
MSFlexGrid1.Cols = 5
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) = 1200
 MSFlexGrid1.Text = "姓名"
 Case 3
 MSFlexGrid1.ColWidth(i) = 1500
 MSFlexGrid1.Text = "课程"
 Case 4
 MSFlexGrid1.ColWidth(i) = 800
 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("stu_Name")
Case 3
MSFlexGrid1.Text = rs.Fields("course_name")
Case 4
MSFlexGrid1.Text = rs.Fields("score")


End Select
Next j
i = i + 1
rs.MoveNext

Wend
rs.Close
'initform
End Sub

Private Sub Form_Load()
initstu_no
initcourse_no
score_option.AddItem ("<")
score_option.AddItem ("<=")
score_option.AddItem (">")
score_option.AddItem (">=")
score_option.AddItem ("=")
score_option.AddItem ("between")
initform

End Sub
Private Sub stu_no_click()
Dim rststudent As ADODB.Recordset
sqlStr = "select name from students where stu_no='" & stu_no.Text & "'"
Set rststudent = executesql(sqlStr, msgText)
If Not rststudent.EOF Then
stu_name.Text = rststudent.Fields(0)
rststudent.Close
End If
End Sub
Private Sub course_no_click()
Dim rstcourse As ADODB.Recordset
sqlStr = "select Course_name from courses where Course_no='" & course_no.Text & "'"
Set rstcourse = executesql(sqlStr, msgText)
If Not rstcourse.EOF Then
course_name.Text = rstcourse.Fields(0)
rstcourse.Close
End If
End Sub

⌨️ 快捷键说明

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