📄 queryexamresult.vb
字号:
Me.GroupBox3.Controls.Add(Me.Label5)
Me.GroupBox3.Controls.Add(Me.ComboBox3)
Me.GroupBox3.Controls.Add(Me.Button1)
Me.GroupBox3.Font = New System.Drawing.Font("宋体", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.GroupBox3.ForeColor = System.Drawing.Color.IndianRed
Me.GroupBox3.Location = New System.Drawing.Point(312, 8)
Me.GroupBox3.Name = "GroupBox3"
Me.GroupBox3.Size = New System.Drawing.Size(208, 80)
Me.GroupBox3.TabIndex = 10
Me.GroupBox3.TabStop = False
Me.GroupBox3.Text = "按学号统计"
'
'Label6
'
Me.Label6.Location = New System.Drawing.Point(80, 56)
Me.Label6.Name = "Label6"
Me.Label6.Size = New System.Drawing.Size(32, 23)
Me.Label6.TabIndex = 13
Me.Label6.Text = "学期"
'
'TextBox4
'
Me.TextBox4.Location = New System.Drawing.Point(136, 16)
Me.TextBox4.Name = "TextBox4"
Me.TextBox4.Size = New System.Drawing.Size(64, 21)
Me.TextBox4.TabIndex = 12
Me.TextBox4.Text = ""
'
'Label5
'
Me.Label5.Location = New System.Drawing.Point(80, 16)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(40, 23)
Me.Label5.TabIndex = 11
Me.Label5.Text = "学号"
'
'ComboBox3
'
Me.ComboBox3.Items.AddRange(New Object() {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "研1-1", "研1-2", "研2-1", "研2-2", "研3-1", "研3-2"})
Me.ComboBox3.Location = New System.Drawing.Point(136, 56)
Me.ComboBox3.Name = "ComboBox3"
Me.ComboBox3.Size = New System.Drawing.Size(64, 20)
Me.ComboBox3.TabIndex = 10
'
'Form17
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.BackColor = System.Drawing.Color.Teal
Me.ClientSize = New System.Drawing.Size(552, 349)
Me.Controls.Add(Me.GroupBox3)
Me.Controls.Add(Me.DataGrid1)
Me.Controls.Add(Me.GroupBox2)
Me.Controls.Add(Me.GroupBox1)
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.MaximizeBox = False
Me.Name = "Form17"
Me.Text = "成绩查询"
Me.GroupBox1.ResumeLayout(False)
Me.GroupBox2.ResumeLayout(False)
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
Me.GroupBox3.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
If TextBox1.Text = "" Or ComboBox1.Text = "" Then
MsgBox("不能为空!")
Else
queryExam()
TextBox1.Text = ""
ComboBox1.Text = ""
End If
End Sub
Sub queryExam()
Dim str As String
Dim ds As New DataSet
Dim da As SqlDataAdapter
' Dim da1 As SqlDataAdapter
'Dim frmName As String = "欢迎您"
str = "Data Source=localhost;Initial Catalog = Student;integrated Security=true"
Dim con As New SqlConnection(str)
con.Open()
Dim sql As String = "select * from result_Info where exam_No='" & TextBox1.Text.ToString().Trim() & "' and tearm='" & ComboBox1.Text.ToString.Trim() & "' "
' Dim sql1 As String = "select * from result_Info where exam_No='" & TextBox1.Text.ToString().Trim() & "' and tearm='" & ComboBox1.Text.ToString.Trim() & "' "
da = New SqlDataAdapter(sql, con)
da.Fill(ds)
DataGrid1.DataSource = ds.Tables(0)
End Sub
Sub queryExam1()
Dim str As String
Dim ds As New DataSet
Dim da As SqlDataAdapter
' Dim da1 As SqlDataAdapter
'Dim frmName As String = "欢迎您"
str = "Data Source=localhost;Initial Catalog = Student;integrated Security=true"
Dim con As New SqlConnection(str)
con.Open()
Dim sql As String = "select * from result_Info where student_ID='" & TextBox2.Text.ToString().Trim() & "' and tearm='" & ComboBox2.Text.ToString.Trim() & "' "
' Dim sql1 As String = "select * from result_Info where exam_No='" & TextBox1.Text.ToString().Trim() & "' and tearm='" & ComboBox1.Text.ToString.Trim() & "' "
da = New SqlDataAdapter(sql, con)
da.Fill(ds)
DataGrid1.DataSource = ds.Tables(0)
End Sub
Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
If TextBox2.Text = "" Or ComboBox2.Text = "" Then
MsgBox("不能为空!")
Else
queryExam1()
TextBox2.Text = ""
ComboBox2.Text = ""
End If
End Sub
'Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' If TextBox1.Text = "" Or ComboBox1.Text = "" Then
'MsgBox("不能为空!")
' ElseIf TextBox1.Text <> "" And TextBox2.Text <> "" Then
' MsgBox("一次只能利用一个查询条件")
' TextBox1.Text = ""
' TextBox2.Text = ""
' ComboBox1.Text = ""
' ComboBox2.Text = ""
' ElseIf TextBox1.Text <> "" And ComboBox1.Text <> "" Then
'queryExam()
' TextBox1.Text = ""
' TextBox2.Text = ""
' ComboBox1.Text = ""
' ComboBox2.Text = ""
'Else
' queryExam1()
' TextBox1.Text = ""
' TextBox2.Text = ""
' ComboBox1.Text = ""
' ComboBox2.Text = ""
' End If
'End Sub
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'If TextBox1.Text = "" Or ComboBox1.Text = "" Then
' MsgBox("请输入学号和学期号!")
'Else
If TextBox4.Text = "" And ComboBox3.Text <> "" Then
sum()
ElseIf TextBox4.Text <> "" And ComboBox3.Text <> "" Then
sum1()
Else
End If
'End If
End Sub
Sub sum1()
Dim str As String
Dim ds As New DataSet
Dim da As SqlDataAdapter
' Dim da1 As SqlDataAdapter
'Dim frmName As String = "欢迎您"
str = "Data Source=localhost;Initial Catalog = Student;integrated Security=true"
Dim con As New SqlConnection(str)
con.Open()
Dim sql As String = "select student_ID,student_Name,sum(result) as '总分',avg(result)as '平均分' from result_Info where student_ID='" & TextBox4.Text.ToString().Trim() & "' and tearm='" & ComboBox3.Text.ToString.Trim() & "' group by student_ID,student_Name"
' Dim sql1 As String = "select * from result_Info where exam_No='" & TextBox1.Text.ToString().Trim() & "' and tearm='" & ComboBox1.Text.ToString.Trim() & "' "
da = New SqlDataAdapter(sql, con)
da.Fill(ds)
DataGrid1.DataSource = ds.Tables(0)
End Sub
Sub sum()
Dim str As String
Dim ds As New DataSet
Dim da As SqlDataAdapter
' Dim da1 As SqlDataAdapter
'Dim frmName As String = "欢迎您"
str = "Data Source=localhost;Initial Catalog = Student;integrated Security=true"
Dim con As New SqlConnection(str)
con.Open()
Dim sql As String = "select student_ID,student_Name,sum(result) as '总分',avg(result)as '平均分' from result_Info where tearm='" & ComboBox3.Text.ToString.Trim() & "' group by student_ID,student_Name"
' Dim sql1 As String = "select * from result_Info where exam_No='" & TextBox1.Text.ToString().Trim() & "' and tearm='" & ComboBox1.Text.ToString.Trim() & "' "
da = New SqlDataAdapter(sql, con)
da.Fill(ds)
DataGrid1.DataSource = ds.Tables(0)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -