|
Can any one reduce this code try!!
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Dim conn1 As New Data.SqlClient.SqlConnection("data source=.\SQLEXPRESS;initial catalog=C:\DOCUMENTS AND SETTINGS\PROJ\APP_DATA\DATABASE.MDF;integrated security = true")
Dim sql1 As New Data.SqlClient.SqlCommand("select status from carpark where Lot_id=101", conn1)
Dim sql2 As New Data.SqlClient.SqlCommand("select status from carpark where Lot_id=102", conn1)
Dim sql3 As New Data.SqlClient.SqlCommand("select status from carpark where Lot_id=103", conn1)
Dim sql4 As New Data.SqlClient.SqlCommand("select status from carpark where Lot_id=104", conn1)
Dim sql5 As New Data.SqlClient.SqlCommand("select status from carpark where Lot_id=201", conn1)
Dim sql6 As New Data.SqlClient.SqlCommand("select status from carpark where Lot_id=202", conn1)
Dim sql7 As New Data.SqlClient.SqlCommand("select status from carpark where Lot_id=203", conn1)
Dim sql8 As New Data.SqlClient.SqlCommand("select status from carpark where Lot_id=204", conn1)
Dim sql9 As New Data.SqlClient.SqlCommand("select status from carpark where Lot_id=301", conn1)
Dim sql10 As New Data.SqlClient.SqlCommand("select status from carpark where Lot_id=302", conn1)
Dim sql11 As New Data.SqlClient.SqlCommand("select status from carpark where Lot_id=303", conn1)
Dim sql12 As New Data.SqlClient.SqlCommand("select status from carpark where Lot_id=304", conn1)
Dim haha1 As String
Dim haha2 As String
Dim haha3 As String
Dim haha4 As String
Dim haha5 As String
Dim haha6 As String
Dim haha7 As String
Dim haha8 As String
Dim haha9 As String
Dim haha10 As String
Dim haha11 As String
Dim haha12 As String
conn1.Open()
haha1 = CStr(sql1.ExecuteScalar)
haha2 = CStr(sql2.ExecuteScalar)
haha3 = CStr(sql3.ExecuteScalar)
haha4 = CStr(sql4.ExecuteScalar)
haha5 = CStr(sql5.ExecuteScalar)
haha6 = CStr(sql6.ExecuteScalar)
haha7 = CStr(sql7.ExecuteScalar)
haha8 = CStr(sql8.ExecuteScalar)
haha9 = CStr(sql9.ExecuteScalar)
haha10 = CStr(sql10.ExecuteScalar)
haha11 = CStr(sql11.ExecuteScalar)
haha12 = CStr(sql12.ExecuteScalar)
If haha1 = "occupied" Then
Label2.BackColor = Drawing.Color.Green
Label1.Text = "101 is available"
Else
Label2.BackColor = Drawing.Color.Red
Label1.Text = "101 is not available"
End If
If haha2 = "occupied" Then
Label4.BackColor = Drawing.Color.Green
Label3.Text = "102 is available"
Else
Label4.BackColor = Drawing.Color.Red
Label3.Text = "102 is not available"
End If
If haha3 = "occupied" Then
Label6.BackColor = Drawing.Color.Green
Label5.Text = "103 is available"
Else
Label6.BackColor = Drawing.Color.Red
Label5.Text = "103 is not available"
End If
If haha4 = "occupied" Then
Label8.BackColor = Drawing.Color.Green
Label7.Text = "104 is available"
Else
Label8.BackColor = Drawing.Color.Red
Label7.Text = "104 is not available"
End If
If haha5 = "occupied" Then
Label10.BackColor = Drawing.Color.Green
Label9.Text = "201` is available"
Else
Label10.BackColor = Drawing.Color.Red
Label9.Text = "201 is not available"
End If
If haha6 = "occupied" Then
Label12.BackColor = Drawing.Color.Green
Label11.Text = "202 is available"
Else
Label12.BackColor = Drawing.Color.Red
Label11.Text = "202 is not available"
End If
If haha7 = "occupied" Then
Label14.BackColor = Drawing.Color.Green
Label13.Text = "203 is available"
Else
Label14.BackColor = Drawing.Color.Red
Label13.Text = "203 is not available"
End If
If haha8 = "occupied" Then
Label16.BackColor = Drawing.Color.Green
Label15.Text = "204 is available"
Else
Label16.BackColor = Drawing.Color.Red
Label15.Text = "204 is not available"
End If
If haha9 = "occupied" Then
Label18.BackColor = Drawing.Color.Green
Label17.Text = "301 is available"
Else
Label18.BackColor = Drawing.Color.Red
Label17.Text = "301 is not available"
End If
If haha10 = "occupied" Then
Label20.BackColor = Drawing.Color.Green
Label19.Text = "302 is available"
Else
Label20.BackColor = Drawing.Color.Red
Label19.Text = "302 is not available"
End If
If haha11 = "occupied" Then
Label22.BackColor = Drawing.Color.Green
Label21.Text = "303 is available"
Else
Label22.BackColor = Drawing.Color.Red
Label21.Text = "303 is not available"
End If
If haha12 = "occupied" Then
Label24.BackColor = Drawing.Color.Green
Label23.Text = "304 is available"
Else
Label24.BackColor = Drawing.Color.Red
Label23.Text = "304 is not available"
End If
conn1.Close()
End If
End Sub
|
|
|
|