Please help how can i do this based on the average score if it is less than 50 then the status should indicated failed as indicated in the display below using gridview.
thanks.
ormno: |
Name |
Category: |
Stream |
Eng |
Maths |
Total: |
Average: |
sst |
science |
Entered date: |
Status |
19-07877 |
ONYANGO EMMANUEL ANDREW |
New |
|
60 |
61 |
121 |
60.5 |
|
|
07/12/2019 17:02 |
|
19-07869 |
KOBUSINGYE NOELA |
New |
|
70 |
86 |
156 |
78 |
|
|
07/12/2019 17:02 |
|
|
SENTONGO MARIAM |
New |
|
41 |
36 |
77 |
38.5 |
|
|
07/12/2019 16:58 |
FAILED |
|
NALUBIRA HARRIET |
New |
|
81 |
72 |
153 |
76.5 |
|
|
07/12/2019 16:58 |
|
19-07874 |
NINYIKIRIZA NTABIRWEKI |
New |
|
34 |
39 |
73 |
36.5 |
|
|
07/12/2019 16:51 |
FAILED |
19-07875 |
NTINWA NAEEM RUYONGA |
New |
|
93 |
86 |
179 |
89.5 |
|
|
07/12/2019 16:51 |
|
19-07870 |
MPAGI FAISWAL |
New |
|
20 |
32 |
52 |
26 |
|
|
07/12/2019 16:51 |
FAILED |
19-07871 |
MUBIRU MUHAMMAD |
New |
|
20 |
27 |
47 |
23.5 |
|
|
07/12/2019 16:51 |
FAILED |
|
SSENGALAMA JOSHUA |
New |
|
85 |
77 |
162 |
81 |
|
|
05/10/2019 17:36 |
|
19-07555 |
SENFUKA HASBA |
New |
|
19 |
44 |
63 |
31.5 |
|
|
|
FAILED |
Public Class StudentSearch
Inherits System.Web.UI.Page
Dim conString As String = ConfigurationManager.ConnectionStrings("INTERVIEWSConnectionString").ConnectionString
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Private Function ExecuteQuery(ByVal cmd As SqlCommand, ByVal action As String) As DataTable
'Dim conString As String = conString
Using con As New SqlConnection(conString)
cmd.Connection = con
Select Case action
Case "SELECT"
Using sda As New SqlDataAdapter()
sda.SelectCommand = cmd
Using dt As New DataTable()
sda.Fill(dt)
Return dt
End Using
End Using
Case "UPDATE"
con.Open()
cmd.ExecuteReader()
con.Close()
Exit Select
End Select
Return Nothing
End Using
End Function
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If CheckBox1.Checked = True Then
Dim cmd As New SqlCommand("SELECT Account,upper(Name) as Name,Class,Stream,Category,Intake,Eng,Maths,Sst,Science, ([maths]+[eng])/2 AS Average,([maths]+[eng])AS TotalMarks
FROM student
WHERE (((student.Class)=@c) AND ((student.Intake)=@it)) and (status IS NULL)
ORDER BY class,student.Name, [maths]+[eng]/2 DESC;")
cmd.Parameters.AddWithValue("@c", DropDownList2.SelectedItem.Text)
cmd.Parameters.AddWithValue("@it", DropDownList1.SelectedItem.Text)
Label2.Text = Nothing
Studentgrid.DataSource = Me.ExecuteQuery(cmd, "SELECT")
Studentgrid.DataBind()
'Required for jQuery DataTables to work.
Studentgrid.UseAccessibleHeader = True
Studentgrid.HeaderRow.TableSection = TableRowSection.TableHeader
Else
Dim cmd As New SqlCommand("SELECT Account as Admno,upper(Name) as Name,Class,Stream,Category,Intake,Eng,Maths,([maths]+[eng])/2 AS Average,([maths]+[eng])AS TotalMarks
FROM student
WHERE (((student.Class)=@c) AND ((student.Intake)=@it)) and (status IS NULL)
ORDER BY class,student.Name, [maths]+[eng]/2 DESC;")
cmd.Parameters.AddWithValue("@c", DropDownList2.SelectedItem.Text)
cmd.Parameters.AddWithValue("@it", DropDownList1.SelectedItem.Text)
Label2.Text = Nothing
Studentgrid.DataSource = Me.ExecuteQuery(cmd, "SELECT")
Studentgrid.DataBind()
'Required for jQuery DataTables to work.
Studentgrid.UseAccessibleHeader = True
If Studentgrid.Rows.Count = 0 Then
Response.Write("<script>alert('No Records yet for this Class');</script>")
Exit Sub
Else
Studentgrid.HeaderRow.TableSection = TableRowSection.TableHeader
End If
End If
End Sub
Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim named As String = DropDownList2.SelectedValue
Dim intake As String = DropDownList1.SelectedValue
Dim point As Boolean = CheckBox2.Checked
Response.Redirect(String.Format("~/Reports/DisplayReport.aspx?class={0}&intake={1}&point={2}", named, intake, point))
End Sub
End Class