Hi
I have tried but it didnt work.
This is all the code on the form.
Can you add the code appropriately and comment it
thanks
Imports System
Imports System.Data
Imports System.Data.SqlClient
Public Class ScoresForm
Private Sub btnDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
DSSummaries.Clear()
DSSummaries.Dispose()
DSScores.Clear()
DSScores.Dispose()
DSDeptTeacher.Clear()
cboTeachersName.Items.Clear()
dgvScores.Refresh()
dgvScores.DataSource = Nothing
DAScores.Dispose()
DASummaries.Dispose()
Conn.ConnectionString = "Server=blacklaptop\sqlexpress;database=gbDbase;Trusted_Connection=True;"
Try
Conn.Open()
MsgBox("connected")
SQLSummaries = "SELECT SummariesID,summaries.sectionprefix,summaries.Pwd,Subjects.SubjectName,Classes.ClassName,Summaries.SequenceNo,Summaries.Coefficient, Summaries.HrsInPlan ,Summaries.HrsTaught,Summaries.TopicsInPlan, Summaries.TopicsTaught, Summaries.TeachersName, Summaries.Sat, Summaries.Passed, Summaries.Failed, Summaries.BoysPassed, Summaries.BoysFailed, Summaries.GirlsPassed, Summaries.GirlsFailed, Summaries.ClassAverage FROM Summaries INNER JOIN Subjects ON Subjects.SubjectID=Summaries.SubjectID INNER JOIN Classes ON Classes.ClassID=Summaries.ClassID WHERE summaries.Pwd='" & Me.txtPassword.Text & "' "
DASummaries = New SqlDataAdapter(SQLSummaries, Conn)
DASummaries.Fill(DSSummaries, "Summaries")
If DSSummaries.Tables("summaries").Rows.Count = 0 Then
MsgBox("No Such Subject Class exists!!!Password must be 7 characters")
Conn.Close()
Me.txtPassword.Clear()
Me.txtPassword.Focus()
Else
lblSummariesID.Text = DSSummaries.Tables("summaries").Rows(0).Item("summariesID")
lblSectionPrefix.Text = DSSummaries.Tables("summaries").Rows(0).Item("sectionprefix")
txtSubjectName.Text = DSSummaries.Tables("summaries").Rows(0).Item("subjectname")
txtClassName.Text = DSSummaries.Tables("summaries").Rows(0).Item("classname")
txtSequenceNo.Text = DSSummaries.Tables("summaries").Rows(0).Item("sequenceNo")
txtCoeff.Text = DSSummaries.Tables("summaries").Rows(0).Item("coefficient")
txtHrsInPlan.Text = DSSummaries.Tables("summaries").Rows(0).Item("HrsInPlan").ToString
txtHrsTaught.Text = DSSummaries.Tables("summaries").Rows(0).Item("HrsTaught").ToString
txtTopicsInPlan.Text = DSSummaries.Tables("summaries").Rows(0).Item("TopicsInPlan").ToString
txtTopicsTaught.Text = DSSummaries.Tables("summaries").Rows(0).Item("TopicsTaught").ToString
cboTeachersName.SelectedItem = DSSummaries.Tables("summaries").Rows(0).Item("teachersname").ToString
'cboTeachersName.SelectedIndex = DSSummaries.Tables("summaries").Rows(0).Item("teachersname").ToString
txtSat.Text = DSSummaries.Tables("summaries").Rows(0).Item("Sat").ToString
txtPassed.Text = DSSummaries.Tables("summaries").Rows(0).Item("Passed").ToString
txtFailed.Text = DSSummaries.Tables("summaries").Rows(0).Item("Failed").ToString
txtBoysPassed.Text = DSSummaries.Tables("summaries").Rows(0).Item("BoysPassed").ToString
txtBoysFailed.Text = DSSummaries.Tables("summaries").Rows(0).Item("BoysFailed").ToString
txtGirlsPassed.Text = DSSummaries.Tables("summaries").Rows(0).Item("GirlsPassed").ToString
txtGirlsFailed.Text = DSSummaries.Tables("summaries").Rows(0).Item("Girlsfailed").ToString
txtClassAverage.Text = DSSummaries.Tables("summaries").Rows(0).Item("ClassAverage").ToString
'Fill Datagrid with Scores Table
If Me.txtSequenceNo.Text = 1 Then
SQLScores = "SELECT ScoresID,Scores.ClassName,Scores.SubjectName,Scores.RollNo,Scores.StudentNames,Scores.Gender, Scores.Coeff1, Scores.Sequence1, Scores.Sequence2, Scores.Average1, Scores.Total1, Scores.Comment1 FROM Scores WHERE scores.SubjectName='" & Me.txtSubjectName.Text & " ' and scores.ClassName='" & Me.txtClassName.Text & "' "
ElseIf Me.txtSequenceNo.Text = 2 Then
SQLScores = "SELECT ScoresID,Scores.ClassName,Scores.SubjectName,Scores.RollNo,Scores.StudentNames,Scores.Gender, Scores.Coeff1, Scores.Sequence2, Scores.Sequence1, Scores.Average1, Scores.Total1, Scores.Comment1 FROM Scores WHERE scores.SubjectName='" & Me.txtSubjectName.Text & " ' and scores.ClassName='" & Me.txtClassName.Text & "' "
ElseIf Me.txtSequenceNo.Text = 3 Then
SQLScores = "SELECT ScoresID,Scores.ClassName,Scores.SubjectName,Scores.RollNo,Scores.StudentNames,Scores.Gender, Scores.Coeff2, Scores.Sequence3, Scores.Sequence4, Scores.Average2, Scores.Total2, Scores.Comment2 FROM Scores WHERE scores.SubjectName='" & Me.txtSubjectName.Text & " ' and scores.ClassName='" & Me.txtClassName.Text & "' "
ElseIf Me.txtSequenceNo.Text = 4 Then
SQLScores = "SELECT ScoresID,Scores.ClassName,Scores.SubjectName,Scores.RollNo,Scores.StudentNames,Scores.Gender, Scores.Coeff2, Scores.Sequence4, Scores.Sequence3, Scores.Average2, Scores.Total2, Scores.Comment2 FROM Scores WHERE scores.SubjectName='" & Me.txtSubjectName.Text & " ' and scores.ClassName='" & Me.txtClassName.Text & "' "
ElseIf Me.txtSequenceNo.Text = 5 Then
SQLScores = "SELECT ScoresID,Scores.ClassName,Scores.SubjectName,Scores.RollNo,Scores.StudentNames,Scores.Gender, Scores.Coeff3, Scores.Sequence5, Scores.Sequence6, Scores.Average3, Scores.Total3, Scores.Comment3 FROM Scores WHERE scores.SubjectName='" & Me.txtSubjectName.Text & " ' and scores.ClassName='" & Me.txtClassName.Text & "' "
ElseIf Me.txtSequenceNo.Text = 6 Then
SQLScores = "SELECT ScoresID,Scores.ClassName,Scores.SubjectName,Scores.RollNo,Scores.StudentNames,Scores.Gender, Scores.Coeff3, Scores.Sequence6, Scores.Sequence5, Scores.Average3, Scores.Total3, Scores.Comment3 FROM Scores WHERE scores.SubjectName='" & Me.txtSubjectName.Text & " ' and scores.ClassName='" & Me.txtClassName.Text & "' "
End If
'Dim dgvScores As New DataGridView
DAScores = New SqlDataAdapter(SQLScores, Conn)
DAScores.Fill(DSScores, "Scores")
dgvScores.DataSource = DSScores.Tables("Scores")
FillComboTeachersName() 'This subroutine is below
SummaryCounts() 'This subroutine is below
Conn.Close()
MsgBox("connection closed")
dgvScores.ColumnHeadersVisible = True
Me.dgvScores.EnableHeadersVisualStyles = False
Me.dgvScores.Columns(0).HeaderCell.Style.ForeColor = Color.Blue
Me.dgvScores.Columns(0).Visible = False
Me.dgvScores.Columns(8).Visible = False
Me.dgvScores.Columns(9).Visible = False
Me.dgvScores.Columns(10).Visible = False
Me.dgvScores.Columns(11).Visible = False
Me.dgvScores.Columns(0).SortMode = DataGridViewColumnSortMode.NotSortable
Me.dgvScores.Columns(1).SortMode = DataGridViewColumnSortMode.NotSortable
Me.dgvScores.Columns(2).SortMode = DataGridViewColumnSortMode.NotSortable
Me.dgvScores.Columns(3).SortMode = DataGridViewColumnSortMode.NotSortable
Me.dgvScores.Columns(4).SortMode = DataGridViewColumnSortMode.NotSortable
Me.dgvScores.Columns(5).SortMode = DataGridViewColumnSortMode.NotSortable
Me.dgvScores.Columns(6).SortMode = DataGridViewColumnSortMode.NotSortable
Me.dgvScores.Columns(7).SortMode = DataGridViewColumnSortMode.NotSortable
Me.dgvScores.Columns(0).ReadOnly = True
Me.dgvScores.Columns(1).ReadOnly = True
Me.dgvScores.Columns(2).ReadOnly = True
Me.dgvScores.Columns(3).ReadOnly = True
Me.dgvScores.Columns(4).ReadOnly = True
Me.dgvScores.Columns(5).ReadOnly = True
Me.dgvScores.Columns(6).ReadOnly = True
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Sub FillComboTeachersName()
SQLDeptTeacher = "SELECT Teachers.teachersname FROM DeptTeachers INNER JOIN Teachers ON Teachers.TeachersID=DeptTeachers.TeachersID INNER JOIN Depts ON Depts.DeptID=DeptTeachers.DeptID WHERE Depts.DeptName='" & Me.txtSubjectName.Text & "' "
CmdDeptTeacher = New SqlCommand(SQLDeptTeacher, Conn)
DRDeptTeacher = CmdDeptTeacher.ExecuteReader
While (DRDeptTeacher.Read())
With Me.cboTeachersName
.Items.Add(DRDeptTeacher("teachersname"))
End With
End While
CmdDeptTeacher.Dispose()
DRDeptTeacher.Close()
End Sub
Private Sub dgvScores_CellFormatting(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles dgvScores.CellFormatting
If e.ColumnIndex = 7 Then
If Not IsDBNull(Me.dgvScores.Rows(e.RowIndex).Cells(e.ColumnIndex).Value) Then
If Me.dgvScores.Rows(e.RowIndex).Cells(7).Value < 10 Then
Me.dgvScores.Rows(e.RowIndex).Cells(7).Style.ForeColor = Color.Red
Else
Me.dgvScores.Rows(e.RowIndex).Cells(7).Style.ForeColor = Color.Blue
End If
End If
End If
End Sub
Private Sub dgvScores_Cellenter(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvScores.CellEnter
SummaryCounts()
End Sub
Private Sub SummaryCounts()
Dim sat As Integer = 0
txtSat.Text = 0
For i As Integer = 0 To Me.dgvScores.Rows.Count - 1
If Not IsDBNull(Me.dgvScores.Rows(i).Cells(7).Value) Then
sat = sat + 1
txtSat.Text = sat
End If
txtSat.Text = sat
Next
Dim pass As Integer = 0
txtPassed.Text = 0
For i As Integer = 0 To Me.dgvScores.Rows.Count - 1
If Not IsDBNull(Me.dgvScores.Rows(i).Cells(7).Value) AndAlso Me.dgvScores.Rows(i).Cells(7).Value >= 10 Then
pass = pass + 1
txtPassed.Text = pass
End If
Next
Dim fail As Integer = 0
txtFailed.Text = 0
For i As Integer = 0 To Me.dgvScores.Rows.Count - 1
If Not IsDBNull(Me.dgvScores.Rows(i).Cells(7).Value) AndAlso Me.dgvScores.Rows(i).Cells(7).Value < 10 Then
fail = fail + 1
txtFailed.Text = fail
End If
Next
Dim boyspassed As Integer = 0
txtBoysPassed.Text = 0
For i As Integer = 0 To Me.dgvScores.Rows.Count - 1
If Not IsDBNull(Me.dgvScores.Rows(i).Cells(7).Value) AndAlso Me.dgvScores.Rows(i).Cells(7).Value >= 10 AndAlso Me.dgvScores.Rows(i).Cells(5).Value = "M" Then
boyspassed = boyspassed + 1
txtBoysPassed.Text = boyspassed
End If
Next
Dim girlspassed As Integer = 0
txtGirlsPassed.Text = 0
For i As Integer = 0 To Me.dgvScores.Rows.Count - 1
If Not IsDBNull(Me.dgvScores.Rows(i).Cells(7).Value) AndAlso Me.dgvScores.Rows(i).Cells(7).Value >= 10 AndAlso Me.dgvScores.Rows(i).Cells(5).Value = "F" Then
girlspassed = girlspassed + 1
txtGirlsPassed.Text = girlspassed
End If
Next
Dim boysfailed As Integer = 0
txtBoysFailed.Text = 0
For i As Integer = 0 To Me.dgvScores.Rows.Count - 1
If Not IsDBNull(Me.dgvScores.Rows(i).Cells(7).Value) AndAlso Me.dgvScores.Rows(i).Cells(7).Value < 10 AndAlso Me.dgvScores.Rows(i).Cells(5).Value = "M" Then
boysfailed = boysfailed + 1
txtBoysFailed.Text = boysfailed
End If
Next
Dim girlsfailed As Integer = 0
txtGirlsFailed.Text = 0
For i As Integer = 0 To Me.dgvScores.Rows.Count - 1
If Not IsDBNull(Me.dgvScores.Rows(i).Cells(7).Value) AndAlso Me.dgvScores.Rows(i).Cells(7).Value < 10 AndAlso Me.dgvScores.Rows(i).Cells(5).Value = "F" Then
girlsfailed = girlsfailed + 1
txtGirlsFailed.Text = girlsfailed
End If
Next
Dim tot As Double = 0
Dim avg As Double = 0
Me.txtClassAverage.Text = 0
For i As Integer = 0 To Me.dgvScores.Rows.Count - 1
If Not IsDBNull(Me.dgvScores.Rows(i).Cells(7).Value) Then
tot = tot + Me.dgvScores.Rows(i).Cells(7).Value
avg = Math.Round(tot / sat, 2)
Me.txtClassAverage.Text = avg
End If
'If Me.txtClassAverage.Text < 10 Then
' Me.txtClassAverage.ForeColor = Color.Red
'Else
' Me.txtClassAverage.ForeColor = Color.Blue
'End If
Next
End Sub
Private Sub dgvScores_CellValueChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvScores.CellValueChanged
'RESTRICT SCORE VALURES TO 20 OR LESS 20
If e.ColumnIndex = 7 Then
If Not IsDBNull(Me.dgvScores.Rows(e.RowIndex).Cells(e.ColumnIndex).Value) Then
If Me.dgvScores.Rows(e.RowIndex).Cells(7).Value < 0 Or Me.dgvScores.Rows(e.RowIndex).Cells(7).Value > 20 Then
MsgBox("A Score can not be more than 20 or less than 0")
Me.dgvScores.Rows(e.RowIndex).Cells(7).Value = DBNull.Value
End If
End If
End If
'FILL COEFF COLUMN
If e.ColumnIndex = 7 Or e.ColumnIndex = 8 Then
If IsDBNull(Me.dgvScores.Rows(e.RowIndex).Cells(7).Value) And IsDBNull(Me.dgvScores.Rows(e.RowIndex).Cells(8).Value) Then
Me.dgvScores.Rows(e.RowIndex).Cells(6).Value = DBNull.Value
Else
Me.dgvScores.Rows(e.RowIndex).Cells(6).Value = Me.txtCoeff.Text
End If
End If
'FILL AVG COLUMN
If e.ColumnIndex = 7 Or e.ColumnIndex = 8 Then
If IsDBNull(Me.dgvScores.Rows(e.RowIndex).Cells(7).Value) And IsDBNull(Me.dgvScores.Rows(e.RowIndex).Cells(8).Value) Then
Me.dgvScores.Rows(e.RowIndex).Cells(9).Value = DBNull.Value
Me.dgvScores.Rows(e.RowIndex).Cells(10).Value = DBNull.Value
End If
If Not IsDBNull(Me.dgvScores.Rows(e.RowIndex).Cells(7).Value) And IsDBNull(Me.dgvScores.Rows(e.RowIndex).Cells(8).Value) Then
Me.dgvScores.Rows(e.RowIndex).Cells(9).Value = Me.dgvScores.Rows(e.RowIndex).Cells(7).Value
End If
If IsDBNull(Me.dgvScores.Rows(e.RowIndex).Cells(7).Value) And Not IsDBNull(Me.dgvScores.Rows(e.RowIndex).Cells(8).Value) Then
Me.dgvScores.Rows(e.RowIndex).Cells(9).Value = Me.dgvScores.Rows(e.RowIndex).Cells(8).Value
End If
If Not IsDBNull(Me.dgvScores.Rows(e.RowIndex).Cells(7).Value) And Not IsDBNull(Me.dgvScores.Rows(e.RowIndex).Cells(8).Value) Then
Me.dgvScores.Rows(e.RowIndex).Cells(9).Value = Math.Round((Me.dgvScores.Rows(e.RowIndex).Cells(7).Value + Me.dgvScores.Rows(e.RowIndex).Cells(8).Value) / 2, 2)
End If
End If
'FILL TOTAL COLUMN
If Not IsDBNull(Me.dgvScores.Rows(e.RowIndex).Cells(6).Value) And Not IsDBNull(Me.dgvScores.Rows(e.RowIndex).Cells(9).Value) Then
Me.dgvScores.Rows(e.RowIndex).Cells(10).Value = Math.Round(Me.dgvScores.Rows(e.RowIndex).Cells(9).Value * Me.dgvScores.Rows(e.RowIndex).Cells(6).Value, 2)
End If
'FILL THE COMMENT COLUMN
If e.ColumnIndex = 9 Then
If Not IsDBNull(Me.dgvScores.Rows(e.RowIndex).Cells(e.ColumnIndex).Value) AndAlso (Me.dgvScores.Rows(e.RowIndex).Cells(e.ColumnIndex).Value >= 0 AndAlso Me.dgvScores.Rows(e.RowIndex).Cells(e.ColumnIndex).Value <= 5) Then
Me.dgvScores.Rows(e.RowIndex).Cells(11).Value = "Very Poor"
Else
If Not IsDBNull(Me.dgvScores.Rows(e.RowIndex).Cells(e.ColumnIndex).Value) AndAlso (Me.dgvScores.Rows(e.RowIndex).Cells(e.ColumnIndex).Value > 5 AndAlso Me.dgvScores.Rows(e.RowIndex).Cells(e.ColumnIndex).Value < 8) Then
Me.dgvScores.Rows(e.RowIndex).Cells(11).Value = "Poor"
Else
If Not IsDBNull(Me.dgvScores.Rows(e.RowIndex).Cells(e.ColumnIndex).Value) AndAlso (Me.dgvScores.Rows(e.RowIndex).Cells(e.ColumnIndex).Value >= 8 AndAlso Me.dgvScores.Rows(e.RowIndex).Cells(e.ColumnIndex).Value < 10) Then
Me.dgvScores.Rows(e.RowIndex).Cells(11).Value = "Below Average"
Else
If Not IsDBNull(Me.dgvScores.Rows(e.RowIndex).Cells(e.ColumnIndex).Value) AndAlso (Me.dgvScores.Rows(e.RowIndex).Cells(e.ColumnIndex).Value >= 10 AndAlso Me.dgvScores.Rows(e.RowIndex).Cells(e.ColumnIndex).Value < 12) Then
Me.dgvScores.Rows(e.RowIndex).Cells(11).Value = "Average Pass"
Else
If Not IsDBNull(Me.dgvScores.Rows(e.RowIndex).Cells(e.ColumnIndex).Value) AndAlso (Me.dgvScores.Rows(e.RowIndex).Cells(e.ColumnIndex).Value >= 12 AndAlso Me.dgvScores.Rows(e.RowIndex).Cells(e.ColumnIndex).Value < 14) Then
Me.dgvScores.Rows(e.RowIndex).Cells(11).Value = "Fair Pass"
Else
If Not IsDBNull(Me.dgvScores.Rows(e.RowIndex).Cells(e.ColumnIndex).Value) AndAlso (Me.dgvScores.Rows(e.RowIndex).Cells(e.ColumnIndex).Value >= 14 AndAlso Me.dgvScores.Rows(e.RowIndex).Cells(e.ColumnIndex).Value < 16) Then
Me.dgvScores.Rows(e.RowIndex).Cells(11).Value = "Good"
Else
If Not IsDBNull(Me.dgvScores.Rows(e.RowIndex).Cells(e.ColumnIndex).Value) AndAlso (Me.dgvScores.Rows(e.RowIndex).Cells(e.ColumnIndex).Value >= 16 AndAlso Me.dgvScores.Rows(e.RowIndex).Cells(e.ColumnIndex).Value < 18) Then
Me.dgvScores.Rows(e.RowIndex).Cells(11).Value = "Very Good"
Else
If Not IsDBNull(Me.dgvScores.Rows(e.RowIndex).Cells(e.ColumnIndex).Value) AndAlso (Me.dgvScores.Rows(e.RowIndex).Cells(e.ColumnIndex).Value >= 18 AndAlso Me.dgvScores.Rows(e.RowIndex).Cells(e.ColumnIndex).Value <= 20) Then
Me.dgvScores.Rows(e.RowIndex).Cells(11).Value = "Excellent"
Else
Me.dgvScores.Rows(e.RowIndex).Cells(11).Value = DBNull.Value
End If
End If
End If
End If
End If
End If
End If
End If
End If
End Sub
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
SummaryCounts()
Dim CB As New SqlCommandBuilder(DAScores)
If Conn.State = ConnectionState.Open Then
Conn.Close()
End If
Try
Conn.Open()
MsgBox("Connection Open")
CmdSummaries = New SqlCommand("", Conn)
With CmdSummaries
.CommandText = "Update Summaries SET hrsinplan=@hrsinplan,hrstaught=@hrstaught,topicsinplan=@topicsinplan,topicstaught=@topicstaught,teachersName=@teachersname, sat=@sat , passed=@passed, failed=@failed, boyspassed=@boyspassed, boysfailed=@boysfailed, girlspassed=@girlspassed, girlsfailed=@girlsfailed,classaverage=@classaverage WHERE summariesID='" & Me.lblSummariesID.Text & " ' "
'.Parameters.Add("@summariesid", SqlDbType.Int, 3).Value = Me.lblSummariesID.Text
.Parameters.Add("@hrsinplan", SqlDbType.Int, 5).Value = Val(Me.txtHrsInPlan.Text)
.Parameters.Add("@hrstaught", SqlDbType.Int, 5).Value = Val(Me.txtHrsTaught.Text)
.Parameters.Add("@topicsinplan", SqlDbType.Int, 5).Value = Val(Me.txtTopicsInPlan.Text)
.Parameters.Add("@topicstaught", SqlDbType.Int, 5).Value = Val(Me.txtTopicsTaught.Text)
.Parameters.Add("@teachersname", SqlDbType.VarChar, 30).Value = Me.cboTeachersName.SelectedItem
.Parameters.Add("@sat", SqlDbType.Int, 5).Value = Val(Me.txtSat.Text)
.Parameters.Add("@passed", SqlDbType.Int, 5).Value = Val(Me.txtPassed.Text)
.Parameters.Add("@failed", SqlDbType.Int, 5).Value = Val(Me.txtFailed.Text)
.Parameters.Add("@boyspassed", SqlDbType.Int, 5).Value = Val(Me.txtBoysPassed.Text)
.Parameters.Add("@boysfailed", SqlDbType.Int, 5).Value = Val(Me.txtBoysFailed.Text)
.Parameters.Add("@girlspassed", SqlDbType.Int, 5).Value = Val(Me.txtGirlsPassed.Text)
.Parameters.Add("@girlsfailed", SqlDbType.Int, 5).Value = Val(Me.txtGirlsFailed.Text)
.Parameters.Add("@classaverage", SqlDbType.Float, 10).Value = Val(Me.txtClassAverage.Text)
.ExecuteNonQuery()
End With
CmdScores = New SqlCommand(SQLScores, Conn)
DAScores.Update(DSScores.Tables(0))
DSScores.AcceptChanges()
MsgBox("Data Saved Successfully")
Catch
'Finally
Conn.Close()
MsgBox("Connection closed")
End Try
End Sub
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
DSSummaries.Clear()
DSScores.Clear()
DSDeptTeacher.Clear()
cboTeachersName.Items.Clear()
dgvScores.Refresh()
dgvScores.DataSource = Nothing
dgvScores.Columns.Clear()
dgvScores.Rows.Clear()
DAScores.Dispose()
DASummaries.Dispose()
If Conn.State = ConnectionState.Open Then
Conn.Close()
End If
For Each item In Me.GroupBox1.Controls
If TypeOf item Is TextBox Then
item.text = String.Empty
End If
Next
For Each item In Me.GroupBox2.Controls
If TypeOf item Is TextBox Then
item.text = String.Empty
End If
Next
For Each item In Me.GroupBox3.Controls
If TypeOf item Is TextBox Then
item.text = String.Empty
End If
Next
For Each item In Me.GroupBox5.Controls
If TypeOf item Is TextBox Then
item.text = String.Empty
End If
Next
txtPassword.Focus()
End Sub
Private Sub ScoresForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
txtPassword.Focus()
End Sub
End Class