Imports MySql.Data.MySqlClient Imports System.Drawing.Printing Public Class databypurok Public sCon As MySqlConnection = New MySqlConnection Public sComand As MySqlDataAdapter = New MySqlDataAdapter Public ds As New DataSet Dim scrollVal As Integer Dim pagingAdapter As New MySqlDataAdapter Dim pagingDS As New DataSet Dim pagingDS2 As New DataSet Private sRecord_Count As Integer 'Dim conn As New MySqlConnection Dim cmd As New MySqlCommand Dim dr As MySqlDataReader Dim connStrr As String = "server=10.10.0.6;user id=corpadmin;password=admincorp2024;database=caragavotersdb;port=3706" Dim connectionString As New MySqlConnection("server=10.10.0.6;user id=corpadmin;password=admincorp2024;database=caragavotersdb;port=3706") 'Private Sub conns() ' 'Try ' conn = New MySqlConnection("server=10.10.0.6;user id=corpadmin;password=admincorp2024;database=caragavotersdb;port=3706") ' conn.Open() ' 'Catch ex As Exception ' ' MsgBox(ex.Message) ' 'End Try 'End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click 'If CheckBox1.Checked = True Then ' CheckBox1.Checked = False 'Else ' CheckBox1.Checked = True 'End If 'Application.Restart() Me.Controls.Clear() 'removes all the controls on the form InitializeComponent() 'load all the controls again Graph_Load(e, e) 'MsgBox("Thank you for sending report", vbInformation, "") Refresh() End Sub Private Sub Graph_Load(sender As Object, e As EventArgs) Handles MyBase.Load selecbrgy() 'alvar() 'CheckBox1.Checked = True CheckBox1.Visible = False 'totalalldata() totalalldatabypurok() totalremainbypurok() totalpercentrecbypurok() End Sub Sub totalalldatabypurok() Label90.Text = Val(r1.Text) + Val(r2.Text) + Val(r3.Text) + Val(r4.Text) + Val(r5.Text) + Val(r6.Text) + Val(r7.Text) + Val(r8.Text) + Val(r9.Text) + Val(r10.Text) + Val(r11.Text) + Val(r12.Text) + Val(r13.Text) + Val(r14.Text) + Val(r15.Text) + Val(r16.Text) + Val(r17.Text) + Val(r18.Text) Label92.Text = Val(t1.Text) + Val(t2.Text) + Val(t3.Text) + Val(t4.Text) + Val(t5.Text) + Val(t6.Text) + Val(t7.Text) + Val(t8.Text) + Val(t9.Text) + Val(t10.Text) + Val(t11.Text) + Val(t12.Text) + Val(t13.Text) + Val(t14.Text) + Val(t15.Text) + Val(t16.Text) + Val(t17.Text) + Val(t18.Text) End Sub Sub totalremainbypurok() Label93.Text = Val(rem1.Text) + Val(rem2.Text) + Val(rem3.Text) + Val(rem4.Text) + Val(rem5.Text) + Val(rem6.Text) + Val(rem7.Text) + Val(rem8.Text) + Val(rem9.Text) + Val(rem10.Text) + Val(rem11.Text) + Val(rem12.Text) + Val(rem13.Text) + Val(rem14.Text) + Val(rem15.Text) + Val(rem16.Text) + Val(rem17.Text) + Val(rem18.Text) End Sub Sub totalpercentrecbypurok() totalremainbypurok() 'Label7.Text = Label92.Text - Label90.Text Dim Total = Val(Label90.Text) / Val(Label92.Text) * 100 + 1 Total = Math.Floor(Total) Label91.Text = Total Label91.Text = Label91.Text + "%" totalpercentremainbypurok() End Sub Private Sub totalpercentremainbypurok() totalremainbypurok() 'Label7.Text = Label92.Text - Label90.Text Dim Total = Val(Label93.Text) / Val(Label92.Text) * 100 Total = Math.Floor(Total) Label95.Text = Total Label95.Text = Label95.Text + "%" End Sub Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged loadleaders() End Sub Sub loadleaders() loadingform.Show() loadingform.Label4.Text = "leadersbypurok" loadingform.Timer1.Enabled = True loadingform.Timer1.Start() End Sub Private Sub selecbrgy() Try Dim adapter As New MySqlDataAdapter("SELECT * FROM purok ORDER BY barangay ASC", connectionString) Dim table As New DataTable() adapter.Fill(table) barangay.DataSource = table barangay.ValueMember = "barangay" barangay.DisplayMember = "barangay" Dim lst = (From row In table.AsEnumerable Select row.Field(Of String)(2)).Distinct.ToList barangay.DataSource = lst Catch ex As Exception MsgBox(ex.Message) Finally connectionString.Close() connectionString.Dispose() End Try End Sub Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles barangay.SelectedIndexChanged CheckBox1.Checked = False fillistperpurok() If DataGridView1.Rows.Count <= 6 Then t7.Text = "0" t8.Text = "0" t9.Text = "0" t10.Text = "0" t11.Text = "0" t12.Text = "0" t13.Text = "0" t14.Text = "0" t15.Text = "0" t16.Text = "0" t17.Text = "0" t18.Text = "0" ElseIf DataGridView1.Rows.Count <= 7 Then t8.Text = "0" t9.Text = "0" t10.Text = "0" t11.Text = "0" t12.Text = "0" t13.Text = "0" t14.Text = "0" t15.Text = "0" t16.Text = "0" t17.Text = "0" t18.Text = "0" ElseIf DataGridView1.Rows.Count <= 8 Then t9.Text = "0" t10.Text = "0" t11.Text = "0" t12.Text = "0" t13.Text = "0" t14.Text = "0" t15.Text = "0" t16.Text = "0" t17.Text = "0" t18.Text = "0" ElseIf DataGridView1.Rows.Count <= 9 Then t10.Text = "0" t11.Text = "0" t12.Text = "0" t13.Text = "0" t14.Text = "0" t15.Text = "0" t16.Text = "0" t17.Text = "0" t18.Text = "0" ElseIf DataGridView1.Rows.Count <= 10 Then t11.Text = "0" t12.Text = "0" t13.Text = "0" t14.Text = "0" t15.Text = "0" t16.Text = "0" t17.Text = "0" t18.Text = "0" ElseIf DataGridView1.Rows.Count <= 11 Then t12.Text = "0" t13.Text = "0" t14.Text = "0" t15.Text = "0" t16.Text = "0" t17.Text = "0" t18.Text = "0" ElseIf DataGridView1.Rows.Count <= 12 Then t13.Text = "0" t14.Text = "0" t15.Text = "0" t16.Text = "0" t17.Text = "0" t18.Text = "0" ElseIf DataGridView1.Rows.Count <= 13 Then t14.Text = "0" t15.Text = "0" t16.Text = "0" t17.Text = "0" t18.Text = "0" ElseIf DataGridView1.Rows.Count <= 14 Then t15.Text = "0" t16.Text = "0" t17.Text = "0" t18.Text = "0" End If If DataGridView1.Rows.Count <= 6 Then r7.Text = "0" r8.Text = "0" r9.Text = "0" r10.Text = "0" r11.Text = "0" r12.Text = "0" r13.Text = "0" r14.Text = "0" r15.Text = "0" r16.Text = "0" r17.Text = "0" r18.Text = "0" ElseIf DataGridView1.Rows.Count <= 7 Then r8.Text = "0" r9.Text = "0" r10.Text = "0" r11.Text = "0" r12.Text = "0" r13.Text = "0" r14.Text = "0" r15.Text = "0" r16.Text = "0" r17.Text = "0" r18.Text = "0" ElseIf DataGridView1.Rows.Count <= 8 Then r9.Text = "0" r10.Text = "0" r11.Text = "0" r12.Text = "0" r13.Text = "0" r14.Text = "0" r15.Text = "0" r16.Text = "0" r17.Text = "0" r18.Text = "0" ElseIf DataGridView1.Rows.Count <= 9 Then r10.Text = "0" r11.Text = "0" r12.Text = "0" r13.Text = "0" r14.Text = "0" r15.Text = "0" r16.Text = "0" r17.Text = "0" r18.Text = "0" ElseIf DataGridView1.Rows.Count <= 10 Then r11.Text = "0" r12.Text = "0" r13.Text = "0" r14.Text = "0" r15.Text = "0" r16.Text = "0" r17.Text = "0" r18.Text = "0" ElseIf DataGridView1.Rows.Count <= 11 Then r12.Text = "0" r13.Text = "0" r14.Text = "0" r15.Text = "0" r16.Text = "0" r17.Text = "0" r18.Text = "0" ElseIf DataGridView1.Rows.Count <= 12 Then r13.Text = "0" r14.Text = "0" r15.Text = "0" r16.Text = "0" r17.Text = "0" r18.Text = "0" ElseIf DataGridView1.Rows.Count <= 13 Then r14.Text = "0" r15.Text = "0" r16.Text = "0" r17.Text = "0" r18.Text = "0" ElseIf DataGridView1.Rows.Count <= 14 Then r15.Text = "0" r16.Text = "0" r17.Text = "0" r18.Text = "0" End If CheckBox1.Checked = True End Sub Sub perpurokpercentclear() If DataGridView1.Rows.Count <= 6 Then p7.Text = "0" p8.Text = "0" p9.Text = "0" p10.Text = "0" p11.Text = "0" p12.Text = "0" p13.Text = "0" p14.Text = "0" p15.Text = "0" p16.Text = "0" p17.Text = "0" p18.Text = "0" ElseIf DataGridView1.Rows.Count <= 7 Then p8.Text = "0" p9.Text = "0" p10.Text = "0" p11.Text = "0" p12.Text = "0" p13.Text = "0" p14.Text = "0" p15.Text = "0" p16.Text = "0" p17.Text = "0" p18.Text = "0" ElseIf DataGridView1.Rows.Count <= 8 Then p9.Text = "0" p10.Text = "0" p11.Text = "0" p12.Text = "0" p13.Text = "0" p14.Text = "0" p15.Text = "0" p16.Text = "0" p17.Text = "0" p18.Text = "0" ElseIf DataGridView1.Rows.Count <= 9 Then p10.Text = "0" p11.Text = "0" p12.Text = "0" p13.Text = "0" p14.Text = "0" p15.Text = "0" p16.Text = "0" p17.Text = "0" p18.Text = "0" ElseIf DataGridView1.Rows.Count <= 10 Then p11.Text = "0" p12.Text = "0" p13.Text = "0" p14.Text = "0" p15.Text = "0" p16.Text = "0" p17.Text = "0" p18.Text = "0" ElseIf DataGridView1.Rows.Count <= 11 Then p12.Text = "0" p13.Text = "0" p14.Text = "0" p15.Text = "0" p16.Text = "0" p17.Text = "0" p18.Text = "0" ElseIf DataGridView1.Rows.Count <= 12 Then p13.Text = "0" p14.Text = "0" p15.Text = "0" p16.Text = "0" p17.Text = "0" p18.Text = "0" ElseIf DataGridView1.Rows.Count <= 13 Then p14.Text = "0" p15.Text = "0" p16.Text = "0" p17.Text = "0" p18.Text = "0" ElseIf DataGridView1.Rows.Count <= 14 Then p15.Text = "0" p16.Text = "0" p17.Text = "0" p18.Text = "0" End If End Sub 'SELECT * FROM `purok` WHERE `barangay`='ALVAR' ORDER by purok ASC 'SELECT * FROM `full_data` WHERE `barangay`='ALVAR' AND `address`='CALACHUCHI' ORDER by `address` ASC 'WHERE `barangay`='ALVAR' AND `purok`='CALACHUCHI' ORDER by `purok` ASC Private Sub fillistperpurok() Dim table As New DataTable() Try conns() Dim adapter As New MySqlDataAdapter("SELECT purok FROM purok where barangay = '" & barangay.Text & "' ORDER BY purok ASC", conn1) adapter.Fill(table) DataGridView1.DataSource = table With DataGridView1 .Columns(0).HeaderCell.Value = "PUROK" End With DataGridView1.Columns(0).AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill DataGridView1.DefaultCellStyle.Font = New Font("arial narrow", 12) Catch ex As Exception 'MsgBox(ex.Message) Finally conn1.Close() conn1.Dispose() End Try fillistT1full() fillistR1full() End Sub '==================================================================== '==================================================================== '==================================================================== '==================================================================== '==================================================================== Sub remm1() rem1.Text = t1.Text - r1.Text Dim Total = Val(r1.Text) / Val(t1.Text) * 100 Total = Math.Floor(Total) p1.Text = Total p1.Text = p1.Text + "%" remm2() End Sub Private Sub remm2() rem2.Text = t2.Text - r2.Text Dim Total = Val(r2.Text) / Val(t2.Text) * 100 Total = Math.Floor(Total) p2.Text = Total p2.Text = p2.Text + "%" remm3() End Sub Private Sub remm3() rem3.Text = t3.Text - r3.Text Dim Total = Val(r3.Text) / Val(t3.Text) * 100 Total = Math.Floor(Total) p3.Text = Total p3.Text = p3.Text + "%" remm4() End Sub Private Sub remm4() rem4.Text = t4.Text - r4.Text Dim Total = Val(r4.Text) / Val(t4.Text) * 100 Total = Math.Floor(Total) p4.Text = Total p4.Text = p4.Text + "%" remm5() End Sub Private Sub remm5() rem5.Text = t5.Text - r5.Text Dim Total = Val(r5.Text) / Val(t5.Text) * 100 Total = Math.Floor(Total) p5.Text = Total p5.Text = p5.Text + "%" remm6() End Sub Private Sub remm6() rem6.Text = t6.Text - r6.Text 'PALMAGIL() Dim Total = Val(r6.Text) / Val(t6.Text) * 100 Total = Math.Floor(Total) p6.Text = Total p6.Text = p6.Text + "%" remm7() End Sub Private Sub remm7() rem7.Text = t7.Text - r7.Text 'PICHON() Dim Total = Val(r7.Text) / Val(t7.Text) * 100 Total = Math.Floor(Total) p7.Text = Total p7.Text = p7.Text + "%" remm8() End Sub Private Sub remm8() rem8.Text = t8.Text - r8.Text 'SOBRECAREY() Dim Total = Val(r8.Text) / Val(t8.Text) * 100 Total = Math.Floor(Total) p8.Text = Total p8.Text = p8.Text + "%" remm9() End Sub Private Sub remm9() rem9.Text = t9.Text - r9.Text 'POBLACION() Dim Total = Val(r9.Text) / Val(t9.Text) * 100 Total = Math.Floor(Total) p9.Text = Total p9.Text = p9.Text + "%" remm10() End Sub Private Sub remm10() rem10.Text = t10.Text - r10.Text 'SANANTONIO() Dim Total = Val(r10.Text) / Val(t10.Text) * 100 Total = Math.Floor(Total) p10.Text = Total p10.Text = p10.Text + "%" remm11() End Sub Private Sub remm11() rem11.Text = t11.Text - r11.Text 'SANJOSE() Dim Total = Val(r11.Text) / Val(t11.Text) * 100 Total = Math.Floor(Total) p11.Text = Total p11.Text = p11.Text + "%" remm12() End Sub Private Sub remm12() rem12.Text = t12.Text - r12.Text 'SANLUIS() Dim Total = Val(r12.Text) / Val(t12.Text) * 100 Total = Math.Floor(Total) p12.Text = Total p12.Text = p12.Text + "%" remm13() End Sub Private Sub remm13() rem13.Text = t13.Text - r13.Text 'SANMIGUEL() Dim Total = Val(r13.Text) / Val(t13.Text) * 100 Total = Math.Floor(Total) p13.Text = Total p13.Text = p13.Text + "%" remm14() End Sub Private Sub remm14() rem14.Text = t14.Text - r14.Text 'SANPEDRO() Dim Total = Val(r14.Text) / Val(t14.Text) * 100 Total = Math.Floor(Total) p14.Text = Total p14.Text = p14.Text + "%" remm15() End Sub Private Sub remm15() rem15.Text = t15.Text - r15.Text 'SANTIAGO() Dim Total = Val(r15.Text) / Val(t15.Text) * 100 Total = Math.Floor(Total) p15.Text = Total p15.Text = p15.Text + "%" remm16() End Sub Private Sub remm16() rem16.Text = t16.Text - r16.Text 'STAFE() Dim Total = Val(r16.Text) / Val(t16.Text) * 100 Total = Math.Floor(Total) p16.Text = Total p16.Text = p16.Text + "%" remm17() End Sub Private Sub remm17() rem17.Text = t17.Text - r17.Text Dim Total = Val(r17.Text) / Val(t17.Text) * 100 Total = Math.Floor(Total) p17.Text = Total p17.Text = p17.Text + "%" remm18() End Sub Private Sub remm18() rem18.Text = t18.Text - r18.Text Dim Total = Val(r18.Text) / Val(t18.Text) * 100 Total = Math.Floor(Total) p18.Text = Total p18.Text = p18.Text + "%" End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click 'Button2.Visible = False '' Set the PrintAction to display a Print Preview dialog 'PrintForm1.PrintAction = Printing.PrintAction.PrintToPreview '' This prints a copy of the form as it appears in the PrintPreview 'PrintForm1.Print() '' Display the print button again on the form Button1.Visible = False Button2.Visible = False CheckBox1.Visible = False PrintForm1.Form = Me PrintForm1.PrinterSettings.Copies = 1 PrintForm1.PrinterSettings.DefaultPageSettings.Margins = New Printing.Margins(10, 10, 10, 10) PrintForm1.PrinterSettings.DefaultPageSettings.PaperSize.RawKind = Printing.PaperKind.Letter PrintForm1.PrintAction = Printing.PrintAction.PrintToPreview PrintForm1.Print() Button1.Visible = True Button2.Visible = True CheckBox1.Visible = False End Sub '==================================================================== '==================================================================== '==================================================================== '==================================================================== '==================================================================== '==================================================================== '==================================================================== '==================================================================== '==================================================================== '==================================================================== '==================================================================== '==================================================================== '==================================================================== '==================================================================== '==================================================================== '==================================================================== Sub r1hhl() Try Dim querry As String = "SELECT COUNT(*) FROM hhl where purok = '" & DataGridView1.Rows(0).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'" Using conn As New MySqlConnection(connStrr) Using cmd As New MySqlCommand() With cmd .Connection = conn .CommandText = querry .CommandType = CommandType.Text End With Try conn.Open() Dim count As Int16 = Convert.ToInt16(cmd.ExecuteScalar()) If CheckBox1.Checked = True Then r1.Text = r1.Text + count Else r1.Text = r1.Text - count End If 'Label14.Text = count ' MsgBox(count.ToString()) conn1.Close() Catch ex As Exception MsgBox(ex.Message) End Try End Using End Using Catch ex As Exception End Try 'Try ' Dim table As New DataTable() ' conns() ' Dim adapter As New MySqlDataAdapter("SELECT names FROM hhl where purok = '" & DataGridView1.Rows(0).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) ' adapter.Fill(table) ' If DataGridView1.RowCount > -1 Then ' Dim lst = (From row In table.AsEnumerable ' Select row.Field(Of String)(0)).Count ' Dim counthhl As Double ' counthhl = lst ' If CheckBox1.Checked = True Then ' r1.Text = r1.Text + counthhl ' Else ' r1.Text = r1.Text - counthhl ' End If ' End If ' conn1.Close() ' conn1.Dispose() 'Catch ex As Exception ' 'MsgBox(ex.Message) 'Finally 'End Try r2hhl() End Sub Private Sub r2hhl() Try Dim querry As String = "SELECT COUNT(*) FROM hhl where purok = '" & DataGridView1.Rows(1).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'" Using conn As New MySqlConnection(connStrr) Using cmd As New MySqlCommand() With cmd .Connection = conn .CommandText = querry .CommandType = CommandType.Text End With Try conn.Open() Dim count As Int16 = Convert.ToInt16(cmd.ExecuteScalar()) If CheckBox1.Checked = True Then r2.Text = r2.Text + count Else r2.Text = r2.Text - count End If 'Label14.Text = count ' MsgBox(count.ToString()) conn1.Close() Catch ex As Exception MsgBox(ex.Message) End Try End Using End Using Catch ex As Exception End Try 'Try ' Dim table As New DataTable() ' conns() ' Dim adapter As New MySqlDataAdapter("SELECT names FROM hhl where purok = '" & DataGridView1.Rows(1).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) ' adapter.Fill(table) ' If DataGridView1.RowCount > -1 Then ' Dim lst = (From row In table.AsEnumerable ' Select row.Field(Of String)(0)).Count ' Dim counthhl As Double ' counthhl = lst ' If CheckBox1.Checked = True Then ' r2.Text = r2.Text + counthhl ' Else ' r2.Text = r2.Text - counthhl ' End If ' End If ' conn1.Close() ' conn1.Dispose() 'Catch ex As Exception ' 'MsgBox(ex.Message) 'Finally 'End Try r3hhl() End Sub Private Sub r3hhl() Try Dim querry As String = "SELECT COUNT(*) FROM hhl where purok = '" & DataGridView1.Rows(2).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'" Using conn As New MySqlConnection(connStrr) Using cmd As New MySqlCommand() With cmd .Connection = conn .CommandText = querry .CommandType = CommandType.Text End With Try conn.Open() Dim count As Int16 = Convert.ToInt16(cmd.ExecuteScalar()) If CheckBox1.Checked = True Then r3.Text = r3.Text + count Else r3.Text = r3.Text - count End If 'Label14.Text = count ' MsgBox(count.ToString()) conn1.Close() Catch ex As Exception MsgBox(ex.Message) End Try End Using End Using Catch ex As Exception End Try 'Try ' Dim table As New DataTable() ' conns() ' Dim adapter As New MySqlDataAdapter("SELECT names FROM hhl where purok = '" & DataGridView1.Rows(2).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) ' adapter.Fill(table) ' If DataGridView1.RowCount > -1 Then ' Dim lst = (From row In table.AsEnumerable ' Select row.Field(Of String)(0)).Count ' Dim counthhl As Double ' counthhl = lst ' If CheckBox1.Checked = True Then ' r3.Text = r3.Text + counthhl ' Else ' r3.Text = r3.Text - counthhl ' End If ' End If ' conn1.Close() ' conn1.Dispose() 'Catch ex As Exception ' 'MsgBox(ex.Message) 'Finally 'End Try r4hhl() End Sub Private Sub r4hhl() Try Dim querry As String = "SELECT COUNT(*) FROM hhl where purok = '" & DataGridView1.Rows(3).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'" Using conn As New MySqlConnection(connStrr) Using cmd As New MySqlCommand() With cmd .Connection = conn .CommandText = querry .CommandType = CommandType.Text End With Try conn.Open() Dim count As Int16 = Convert.ToInt16(cmd.ExecuteScalar()) If CheckBox1.Checked = True Then r4.Text = r4.Text + count Else r4.Text = r4.Text - count End If 'Label14.Text = count ' MsgBox(count.ToString()) conn1.Close() Catch ex As Exception MsgBox(ex.Message) End Try End Using End Using Catch ex As Exception End Try 'Try ' Dim table As New DataTable() ' conns() ' Dim adapter As New MySqlDataAdapter("SELECT names FROM hhl where purok = '" & DataGridView1.Rows(3).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) ' adapter.Fill(table) ' If DataGridView1.RowCount > -1 Then ' Dim lst = (From row In table.AsEnumerable ' Select row.Field(Of String)(0)).Count ' Dim counthhl As Double ' counthhl = lst ' If CheckBox1.Checked = True Then ' r4.Text = r4.Text + counthhl ' Else ' r4.Text = r4.Text - counthhl ' End If ' End If ' conn1.Close() ' conn1.Dispose() 'Catch ex As Exception ' 'MsgBox(ex.Message) 'Finally 'End Try r5hhl() End Sub Private Sub r5hhl() Try Dim querry As String = "SELECT COUNT(*) FROM hhl where purok = '" & DataGridView1.Rows(4).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'" Using conn As New MySqlConnection(connStrr) Using cmd As New MySqlCommand() With cmd .Connection = conn .CommandText = querry .CommandType = CommandType.Text End With Try conn.Open() Dim count As Int16 = Convert.ToInt16(cmd.ExecuteScalar()) If CheckBox1.Checked = True Then r5.Text = r5.Text + count Else r5.Text = r5.Text - count End If 'Label14.Text = count ' MsgBox(count.ToString()) conn1.Close() Catch ex As Exception MsgBox(ex.Message) End Try End Using End Using Catch ex As Exception End Try 'Try ' Dim table As New DataTable() ' conns() ' Dim adapter As New MySqlDataAdapter("SELECT names FROM hhl where purok = '" & DataGridView1.Rows(4).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) ' adapter.Fill(table) ' If DataGridView1.RowCount > -1 Then ' Dim lst = (From row In table.AsEnumerable ' Select row.Field(Of String)(0)).Count ' Dim counthhl As Double ' counthhl = lst ' If CheckBox1.Checked = True Then ' r5.Text = r5.Text + counthhl ' Else ' r5.Text = r5.Text - counthhl ' End If ' End If ' conn1.Close() ' conn1.Dispose() 'Catch ex As Exception ' 'MsgBox(ex.Message) 'Finally 'End Try r6hhl() End Sub Private Sub r6hhl() Try Dim querry As String = "SELECT COUNT(*) FROM hhl where purok = '" & DataGridView1.Rows(5).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'" Using conn As New MySqlConnection(connStrr) Using cmd As New MySqlCommand() With cmd .Connection = conn .CommandText = querry .CommandType = CommandType.Text End With Try conn.Open() Dim count As Int16 = Convert.ToInt16(cmd.ExecuteScalar()) If CheckBox1.Checked = True Then r6.Text = r6.Text + count Else r6.Text = r6.Text - count End If 'Label14.Text = count ' MsgBox(count.ToString()) conn1.Close() Catch ex As Exception MsgBox(ex.Message) End Try End Using End Using Catch ex As Exception End Try 'Try ' Dim table As New DataTable() ' conns() ' Dim adapter As New MySqlDataAdapter("SELECT names FROM hhl where purok = '" & DataGridView1.Rows(5).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) ' adapter.Fill(table) ' If DataGridView1.RowCount > -1 Then ' Dim lst = (From row In table.AsEnumerable ' Select row.Field(Of String)(0)).Count ' Dim counthhl As Double ' counthhl = lst ' If CheckBox1.Checked = True Then ' r6.Text = r6.Text + counthhl ' Else ' r6.Text = r6.Text - counthhl ' End If ' End If ' conn1.Close() ' conn1.Dispose() 'Catch ex As Exception ' 'MsgBox(ex.Message) 'Finally 'End Try r7hhl() End Sub Private Sub r7hhl() Try Dim querry As String = "SELECT COUNT(*) FROM hhl where purok = '" & DataGridView1.Rows(6).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'" Using conn As New MySqlConnection(connStrr) Using cmd As New MySqlCommand() With cmd .Connection = conn .CommandText = querry .CommandType = CommandType.Text End With Try conn.Open() Dim count As Int16 = Convert.ToInt16(cmd.ExecuteScalar()) If CheckBox1.Checked = True Then r7.Text = r7.Text + count Else r7.Text = r7.Text - count End If 'Label14.Text = count ' MsgBox(count.ToString()) conn1.Close() Catch ex As Exception MsgBox(ex.Message) End Try End Using End Using Catch ex As Exception End Try 'Try ' Dim table As New DataTable() ' conns() ' Dim adapter As New MySqlDataAdapter("SELECT names FROM hhl where purok = '" & DataGridView1.Rows(6).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) ' adapter.Fill(table) ' If DataGridView1.RowCount > -1 Then ' Dim lst = (From row In table.AsEnumerable ' Select row.Field(Of String)(0)).Count ' Dim counthhl As Double ' counthhl = lst ' If CheckBox1.Checked = True Then ' r7.Text = r7.Text + counthhl ' Else ' r7.Text = r7.Text - counthhl ' End If ' End If ' conn1.Close() ' conn1.Dispose() 'Catch ex As Exception ' ' MsgBox(ex.Message) 'Finally 'End Try r8hhl() End Sub Private Sub r8hhl() Try Dim querry As String = "SELECT COUNT(*) FROM hhl where purok = '" & DataGridView1.Rows(7).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'" Using conn As New MySqlConnection(connStrr) Using cmd As New MySqlCommand() With cmd .Connection = conn .CommandText = querry .CommandType = CommandType.Text End With Try conn.Open() Dim count As Int16 = Convert.ToInt16(cmd.ExecuteScalar()) If CheckBox1.Checked = True Then r8.Text = r8.Text + count Else r8.Text = r8.Text - count End If 'Label14.Text = count ' MsgBox(count.ToString()) conn1.Close() Catch ex As Exception MsgBox(ex.Message) End Try End Using End Using Catch ex As Exception End Try 'Try ' Dim table As New DataTable() ' conns() ' Dim adapter As New MySqlDataAdapter("SELECT names FROM hhl where purok = '" & DataGridView1.Rows(7).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) ' adapter.Fill(table) ' If DataGridView1.RowCount > -1 Then ' Dim lst = (From row In table.AsEnumerable ' Select row.Field(Of String)(0)).Count ' Dim counthhl As Double ' counthhl = lst ' If CheckBox1.Checked = True Then ' r8.Text = r8.Text + counthhl ' Else ' r8.Text = r8.Text - counthhl ' End If ' End If ' conn1.Close() ' conn1.Dispose() 'Catch ex As Exception ' 'MsgBox(ex.Message) 'Finally 'End Try r9hhl() End Sub Private Sub r9hhl() Try Dim querry As String = "SELECT COUNT(*) FROM hhl where purok = '" & DataGridView1.Rows(8).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'" Using conn As New MySqlConnection(connStrr) Using cmd As New MySqlCommand() With cmd .Connection = conn .CommandText = querry .CommandType = CommandType.Text End With Try conn.Open() Dim count As Int16 = Convert.ToInt16(cmd.ExecuteScalar()) If CheckBox1.Checked = True Then r9.Text = r9.Text + count Else r9.Text = r9.Text - count End If 'Label14.Text = count ' MsgBox(count.ToString()) conn1.Close() Catch ex As Exception MsgBox(ex.Message) End Try End Using End Using Catch ex As Exception End Try 'Try ' Dim table As New DataTable() ' conns() ' Dim adapter As New MySqlDataAdapter("SELECT names FROM hhl where purok = '" & DataGridView1.Rows(8).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) ' adapter.Fill(table) ' If DataGridView1.RowCount > -1 Then ' Dim lst = (From row In table.AsEnumerable ' Select row.Field(Of String)(0)).Count ' Dim counthhl As Double ' counthhl = lst ' If CheckBox1.Checked = True Then ' r9.Text = r9.Text + counthhl ' Else ' r9.Text = r9.Text - counthhl ' End If ' End If ' conn1.Close() ' conn1.Dispose() 'Catch ex As Exception ' 'MsgBox(ex.Message) 'Finally 'End Try r10hhl() End Sub Private Sub r10hhl() Try Dim querry As String = "SELECT COUNT(*) FROM hhl where purok = '" & DataGridView1.Rows(9).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'" Using conn As New MySqlConnection(connStrr) Using cmd As New MySqlCommand() With cmd .Connection = conn .CommandText = querry .CommandType = CommandType.Text End With Try conn.Open() Dim count As Int16 = Convert.ToInt16(cmd.ExecuteScalar()) If CheckBox1.Checked = True Then r10.Text = r10.Text + count Else r10.Text = r10.Text - count End If conn1.Close() Catch ex As Exception MsgBox(ex.Message) End Try End Using End Using Catch ex As Exception End Try 'Try ' Dim table As New DataTable() ' conns() ' Dim adapter As New MySqlDataAdapter("SELECT names FROM hhl where purok = '" & DataGridView1.Rows(9).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) ' adapter.Fill(table) ' If DataGridView1.RowCount > -1 Then ' Dim lst = (From row In table.AsEnumerable ' Select row.Field(Of String)(0)).Count ' Dim counthhl As Double ' counthhl = lst ' If CheckBox1.Checked = True Then ' r10.Text = r10.Text + counthhl ' Else ' r10.Text = r10.Text - counthhl ' End If ' End If ' conn1.Close() ' conn1.Dispose() 'Catch ex As Exception ' 'MsgBox(ex.Message) 'Finally 'End Try r11hhl() End Sub Private Sub r11hhl() Try Dim querry As String = "SELECT COUNT(*) FROM hhl where purok = '" & DataGridView1.Rows(10).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'" Using conn As New MySqlConnection(connStrr) Using cmd As New MySqlCommand() With cmd .Connection = conn .CommandText = querry .CommandType = CommandType.Text End With Try conn.Open() Dim count As Int16 = Convert.ToInt16(cmd.ExecuteScalar()) If CheckBox1.Checked = True Then r11.Text = r11.Text + count Else r11.Text = r11.Text - count End If conn1.Close() Catch ex As Exception MsgBox(ex.Message) End Try End Using End Using Catch ex As Exception End Try 'Try ' Dim table As New DataTable() ' conns() ' Dim adapter As New MySqlDataAdapter("SELECT names FROM hhl where purok = '" & DataGridView1.Rows(10).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) ' adapter.Fill(table) ' If DataGridView1.RowCount > -1 Then ' Dim lst = (From row In table.AsEnumerable ' Select row.Field(Of String)(0)).Count ' Dim counthhl As Double ' counthhl = lst ' If CheckBox1.Checked = True Then ' r11.Text = r11.Text + counthhl ' Else ' r11.Text = r11.Text - counthhl ' End If ' End If ' conn1.Close() ' conn1.Dispose() 'Catch ex As Exception ' 'MsgBox(ex.Message) 'Finally 'End Try r12hhl() End Sub Private Sub r12hhl() Try Dim querry As String = "SELECT COUNT(*) FROM hhl where purok = '" & DataGridView1.Rows(11).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'" Using conn As New MySqlConnection(connStrr) Using cmd As New MySqlCommand() With cmd .Connection = conn .CommandText = querry .CommandType = CommandType.Text End With Try conn.Open() Dim count As Int16 = Convert.ToInt16(cmd.ExecuteScalar()) If CheckBox1.Checked = True Then r12.Text = r12.Text + count Else r12.Text = r12.Text - count End If conn1.Close() Catch ex As Exception MsgBox(ex.Message) End Try End Using End Using Catch ex As Exception End Try 'Try ' Dim table As New DataTable() ' conns() ' Dim adapter As New MySqlDataAdapter("SELECT names FROM hhl where purok = '" & DataGridView1.Rows(11).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) ' adapter.Fill(table) ' If DataGridView1.RowCount > -1 Then ' Dim lst = (From row In table.AsEnumerable ' Select row.Field(Of String)(0)).Count ' Dim counthhl As Double ' counthhl = lst ' If CheckBox1.Checked = True Then ' r12.Text = r12.Text + counthhl ' Else ' r12.Text = r12.Text - counthhl ' End If ' End If ' conn1.Close() ' conn1.Dispose() 'Catch ex As Exception ' 'MsgBox(ex.Message) 'Finally 'End Try r13hhl() End Sub Private Sub r13hhl() Try Dim querry As String = "SELECT COUNT(*) FROM hhl where purok = '" & DataGridView1.Rows(12).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'" Using conn As New MySqlConnection(connStrr) Using cmd As New MySqlCommand() With cmd .Connection = conn .CommandText = querry .CommandType = CommandType.Text End With Try conn.Open() Dim count As Int16 = Convert.ToInt16(cmd.ExecuteScalar()) If CheckBox1.Checked = True Then r13.Text = r13.Text + count Else r13.Text = r13.Text - count End If conn1.Close() Catch ex As Exception MsgBox(ex.Message) End Try End Using End Using Catch ex As Exception End Try 'Try ' Dim table As New DataTable() ' conns() ' Dim adapter As New MySqlDataAdapter("SELECT names FROM hhl where purok = '" & DataGridView1.Rows(12).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) ' adapter.Fill(table) ' If DataGridView1.RowCount > -1 Then ' Dim lst = (From row In table.AsEnumerable ' Select row.Field(Of String)(0)).Count ' Dim counthhl As Double ' counthhl = lst ' If CheckBox1.Checked = True Then ' r13.Text = r13.Text + counthhl ' Else ' r13.Text = r13.Text - counthhl ' End If ' End If ' conn1.Close() ' conn1.Dispose() 'Catch ex As Exception ' 'MsgBox(ex.Message) 'Finally 'End Try r14hhl() End Sub Private Sub r14hhl() Try Dim querry As String = "SELECT COUNT(*) FROM hhl where purok = '" & DataGridView1.Rows(13).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'" Using conn As New MySqlConnection(connStrr) Using cmd As New MySqlCommand() With cmd .Connection = conn .CommandText = querry .CommandType = CommandType.Text End With Try conn.Open() Dim count As Int16 = Convert.ToInt16(cmd.ExecuteScalar()) If CheckBox1.Checked = True Then r14.Text = r14.Text + count Else r14.Text = r14.Text - count End If conn1.Close() Catch ex As Exception MsgBox(ex.Message) End Try End Using End Using Catch ex As Exception End Try 'Try ' Dim table As New DataTable() ' conns() ' Dim adapter As New MySqlDataAdapter("SELECT names FROM hhl where purok = '" & DataGridView1.Rows(13).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) ' adapter.Fill(table) ' If DataGridView1.RowCount > -1 Then ' Dim lst = (From row In table.AsEnumerable ' Select row.Field(Of String)(0)).Count ' Dim counthhl As Double ' counthhl = lst ' If CheckBox1.Checked = True Then ' r14.Text = r14.Text + counthhl ' Else ' r14.Text = r14.Text - counthhl ' End If ' End If ' conn1.Close() ' conn1.Dispose() 'Catch ex As Exception ' 'MsgBox(ex.Message) 'Finally 'End Try r15hhl() End Sub Private Sub r15hhl() Try Dim querry As String = "SELECT COUNT(*) FROM hhl where purok = '" & DataGridView1.Rows(14).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'" Using conn As New MySqlConnection(connStrr) Using cmd As New MySqlCommand() With cmd .Connection = conn .CommandText = querry .CommandType = CommandType.Text End With Try conn.Open() Dim count As Int16 = Convert.ToInt16(cmd.ExecuteScalar()) If CheckBox1.Checked = True Then r15.Text = r15.Text + count Else r15.Text = r15.Text - count End If conn1.Close() Catch ex As Exception MsgBox(ex.Message) End Try End Using End Using Catch ex As Exception End Try 'Try ' Dim table As New DataTable() ' conns() ' Dim adapter As New MySqlDataAdapter("SELECT names FROM hhl where purok = '" & DataGridView1.Rows(14).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) ' adapter.Fill(table) ' If DataGridView1.RowCount > -1 Then ' Dim lst = (From row In table.AsEnumerable ' Select row.Field(Of String)(0)).Count ' Dim counthhl As Double ' counthhl = lst ' If CheckBox1.Checked = True Then ' r15.Text = r15.Text + counthhl ' Else ' r15.Text = r15.Text - counthhl ' End If ' End If ' conn1.Close() ' conn1.Dispose() 'Catch ex As Exception ' 'MsgBox(ex.Message) 'Finally 'End Try r16hhl() End Sub Private Sub r16hhl() Try Dim querry As String = "SELECT COUNT(*) FROM hhl where purok = '" & DataGridView1.Rows(15).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'" Using conn As New MySqlConnection(connStrr) Using cmd As New MySqlCommand() With cmd .Connection = conn .CommandText = querry .CommandType = CommandType.Text End With Try conn.Open() Dim count As Int16 = Convert.ToInt16(cmd.ExecuteScalar()) If CheckBox1.Checked = True Then r16.Text = r16.Text + count Else r16.Text = r16.Text - count End If conn1.Close() Catch ex As Exception MsgBox(ex.Message) End Try End Using End Using Catch ex As Exception End Try 'Try ' Dim table As New DataTable() ' conns() ' Dim adapter As New MySqlDataAdapter("SELECT names FROM hhl where purok = '" & DataGridView1.Rows(15).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) ' adapter.Fill(table) ' If DataGridView1.RowCount > -1 Then ' Dim lst = (From row In table.AsEnumerable ' Select row.Field(Of String)(0)).Count ' Dim counthhl As Double ' counthhl = lst ' If CheckBox1.Checked = True Then ' r16.Text = r16.Text + counthhl ' Else ' r16.Text = r16.Text - counthhl ' End If ' End If ' conn1.Close() ' conn1.Dispose() 'Catch ex As Exception ' 'MsgBox(ex.Message) 'Finally 'End Try r17hhl() End Sub Private Sub r17hhl() Try Dim querry As String = "SELECT COUNT(*) FROM hhl where purok = '" & DataGridView1.Rows(16).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'" Using conn As New MySqlConnection(connStrr) Using cmd As New MySqlCommand() With cmd .Connection = conn .CommandText = querry .CommandType = CommandType.Text End With Try conn.Open() Dim count As Int16 = Convert.ToInt16(cmd.ExecuteScalar()) If CheckBox1.Checked = True Then r17.Text = r17.Text + count Else r17.Text = r17.Text - count End If conn1.Close() Catch ex As Exception MsgBox(ex.Message) End Try End Using End Using Catch ex As Exception End Try 'Try ' Dim table As New DataTable() ' conns() ' Dim adapter As New MySqlDataAdapter("SELECT names FROM hhl where purok = '" & DataGridView1.Rows(16).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) ' adapter.Fill(table) ' If DataGridView1.RowCount > -1 Then ' Dim lst = (From row In table.AsEnumerable ' Select row.Field(Of String)(0)).Count ' Dim counthhl As Double ' counthhl = lst ' If CheckBox1.Checked = True Then ' r17.Text = r17.Text + counthhl ' Else ' r17.Text = r17.Text - counthhl ' End If ' End If ' conn1.Close() ' conn1.Dispose() 'Catch ex As Exception ' 'MsgBox(ex.Message) 'Finally 'End Try r18hhl() End Sub Private Sub r18hhl() Try Dim querry As String = "SELECT COUNT(*) FROM hhl where purok = '" & DataGridView1.Rows(17).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'" Using conn As New MySqlConnection(connStrr) Using cmd As New MySqlCommand() With cmd .Connection = conn .CommandText = querry .CommandType = CommandType.Text End With Try conn.Open() Dim count As Int16 = Convert.ToInt16(cmd.ExecuteScalar()) If CheckBox1.Checked = True Then r18.Text = r18.Text + count Else r18.Text = r18.Text - count End If conn1.Close() Catch ex As Exception MsgBox(ex.Message) End Try End Using End Using Catch ex As Exception End Try 'Try ' Dim table As New DataTable() ' conns() ' Dim adapter As New MySqlDataAdapter("SELECT names FROM hhl where purok = '" & DataGridView1.Rows(17).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) ' adapter.Fill(table) ' If DataGridView1.RowCount > -1 Then ' Dim lst = (From row In table.AsEnumerable ' Select row.Field(Of String)(0)).Count ' Dim counthhl As Double ' counthhl = lst ' If CheckBox1.Checked = True Then ' r18.Text = r18.Text + counthhl ' Else ' r18.Text = r18.Text - counthhl ' End If ' End If ' conn1.Close() ' conn1.Dispose() 'Catch ex As Exception ' 'MsgBox(ex.Message) 'Finally 'End Try remm1() End Sub '==================================================================== '==================================================================== '==================================================================== '==================================================================== '==================================================================== '==================================================================== '==================================================================== '==================================================================== '==================================================================== '==================================================================== '==================================================================== Sub alvarpco() Try Dim querry As String = "SELECT COUNT(*) FROM pco where purok = '" & DataGridView1.Rows(0).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'" Using conn As New MySqlConnection(connStrr) Using cmd As New MySqlCommand() With cmd .Connection = conn .CommandText = querry .CommandType = CommandType.Text End With Try conn.Open() Dim count As Int16 = Convert.ToInt16(cmd.ExecuteScalar()) If CheckBox1.Checked = True Then r1.Text = r1.Text + count Else r1.Text = r1.Text - count End If conn1.Close() Catch ex As Exception MsgBox(ex.Message) End Try End Using End Using Catch ex As Exception End Try 'Try ' Dim table As New DataTable() ' conns() ' Dim adapter As New MySqlDataAdapter("SELECT names FROM pco where purok = '" & DataGridView1.Rows(0).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) ' adapter.Fill(table) ' If DataGridView1.RowCount > -1 Then ' Dim lst = (From row In table.AsEnumerable ' Select row.Field(Of String)(0)).Count ' Dim counthhl As Double ' counthhl = lst ' If CheckBox1.Checked = True Then ' r1.Text = r1.Text + counthhl ' Else ' r1.Text = r1.Text - counthhl ' End If ' End If ' conn1.Close() ' conn1.Dispose() 'Catch ex As Exception ' MsgBox(ex.Message) 'Finally 'End Try r2pco() End Sub Private Sub r2pco() Try Dim querry As String = "SELECT COUNT(*) FROM pco where purok = '" & DataGridView1.Rows(1).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'" Using conn As New MySqlConnection(connStrr) Using cmd As New MySqlCommand() With cmd .Connection = conn .CommandText = querry .CommandType = CommandType.Text End With Try conn.Open() Dim count As Int16 = Convert.ToInt16(cmd.ExecuteScalar()) If CheckBox1.Checked = True Then r2.Text = r2.Text + count Else r2.Text = r2.Text - count End If conn1.Close() Catch ex As Exception MsgBox(ex.Message) End Try End Using End Using Catch ex As Exception End Try 'Try ' Dim table As New DataTable() ' conns() ' Dim adapter As New MySqlDataAdapter("SELECT names FROM pco where purok = '" & DataGridView1.Rows(1).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) ' adapter.Fill(table) ' If DataGridView1.RowCount > -1 Then ' Dim lst = (From row In table.AsEnumerable ' Select row.Field(Of String)(0)).Count ' Dim counthhl As Double ' counthhl = lst ' If CheckBox1.Checked = True Then ' r2.Text = r2.Text + counthhl ' Else ' r2.Text = r2.Text - counthhl ' End If ' End If ' conn1.Close() ' conn1.Dispose() 'Catch ex As Exception ' MsgBox(ex.Message) 'Finally 'End Try r3pco() End Sub Private Sub r3pco() Try Dim querry As String = "SELECT COUNT(*) FROM pco where purok = '" & DataGridView1.Rows(2).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'" Using conn As New MySqlConnection(connStrr) Using cmd As New MySqlCommand() With cmd .Connection = conn .CommandText = querry .CommandType = CommandType.Text End With Try conn.Open() Dim count As Int16 = Convert.ToInt16(cmd.ExecuteScalar()) If CheckBox1.Checked = True Then r3.Text = r3.Text + count Else r3.Text = r3.Text - count End If conn1.Close() Catch ex As Exception MsgBox(ex.Message) End Try End Using End Using Catch ex As Exception End Try 'Try ' Dim table As New DataTable() ' conns() ' Dim adapter As New MySqlDataAdapter("SELECT names FROM pco where purok = '" & DataGridView1.Rows(2).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) ' adapter.Fill(table) ' If DataGridView1.RowCount > -1 Then ' Dim lst = (From row In table.AsEnumerable ' Select row.Field(Of String)(0)).Count ' Dim counthhl As Double ' counthhl = lst ' If CheckBox1.Checked = True Then ' r3.Text = r3.Text + counthhl ' Else ' r3.Text = r3.Text - counthhl ' End If ' End If ' conn1.Close() ' conn1.Dispose() 'Catch ex As Exception ' MsgBox(ex.Message) 'Finally 'End Try r4pco() End Sub Private Sub r4pco() Try Dim querry As String = "SELECT COUNT(*) FROM pco where purok = '" & DataGridView1.Rows(3).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'" Using conn As New MySqlConnection(connStrr) Using cmd As New MySqlCommand() With cmd .Connection = conn .CommandText = querry .CommandType = CommandType.Text End With Try conn.Open() Dim count As Int16 = Convert.ToInt16(cmd.ExecuteScalar()) If CheckBox1.Checked = True Then r4.Text = r4.Text + count Else r4.Text = r4.Text - count End If conn1.Close() Catch ex As Exception MsgBox(ex.Message) End Try End Using End Using Catch ex As Exception End Try 'Try ' Dim table As New DataTable() ' conns() ' Dim adapter As New MySqlDataAdapter("SELECT names FROM pco where purok = '" & DataGridView1.Rows(3).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) ' adapter.Fill(table) ' If DataGridView1.RowCount > -1 Then ' Dim lst = (From row In table.AsEnumerable ' Select row.Field(Of String)(0)).Count ' Dim counthhl As Double ' counthhl = lst ' If CheckBox1.Checked = True Then ' r4.Text = r4.Text + counthhl ' Else ' r4.Text = r4.Text - counthhl ' End If ' End If ' conn1.Close() ' conn1.Dispose() 'Catch ex As Exception ' MsgBox(ex.Message) 'Finally 'End Try r5pco() End Sub Private Sub r5pco() Try Dim querry As String = "SELECT COUNT(*) FROM pco where purok = '" & DataGridView1.Rows(4).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'" Using conn As New MySqlConnection(connStrr) Using cmd As New MySqlCommand() With cmd .Connection = conn .CommandText = querry .CommandType = CommandType.Text End With Try conn.Open() Dim count As Int16 = Convert.ToInt16(cmd.ExecuteScalar()) If CheckBox1.Checked = True Then r5.Text = r5.Text + count Else r5.Text = r5.Text - count End If conn1.Close() Catch ex As Exception MsgBox(ex.Message) End Try End Using End Using Catch ex As Exception End Try 'Try ' Dim table As New DataTable() ' conns() ' Dim adapter As New MySqlDataAdapter("SELECT names FROM pco where purok = '" & DataGridView1.Rows(4).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) ' adapter.Fill(table) ' If DataGridView1.RowCount > -1 Then ' Dim lst = (From row In table.AsEnumerable ' Select row.Field(Of String)(0)).Count ' Dim counthhl As Double ' counthhl = lst ' If CheckBox1.Checked = True Then ' r5.Text = r5.Text + counthhl ' Else ' r5.Text = r5.Text - counthhl ' End If ' End If ' conn1.Close() ' conn1.Dispose() 'Catch ex As Exception ' MsgBox(ex.Message) 'Finally 'End Try r6pco() End Sub Private Sub r6pco() Try Dim table As New DataTable() conns() Dim adapter As New MySqlDataAdapter("SELECT names FROM pco where purok = '" & DataGridView1.Rows(5).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) adapter.Fill(table) If DataGridView1.RowCount > -1 Then Dim lst = (From row In table.AsEnumerable Select row.Field(Of String)(0)).Count Dim counthhl As Double counthhl = lst If CheckBox1.Checked = True Then r6.Text = r6.Text + counthhl Else r6.Text = r6.Text - counthhl End If End If conn1.Close() conn1.Dispose() Catch ex As Exception ' MsgBox(ex.Message) Finally End Try r7pco() End Sub Private Sub r7pco() Try Dim table As New DataTable() conns() Dim adapter As New MySqlDataAdapter("SELECT names FROM pco where purok = '" & DataGridView1.Rows(6).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) adapter.Fill(table) If DataGridView1.RowCount > -1 Then Dim lst = (From row In table.AsEnumerable Select row.Field(Of String)(0)).Count Dim counthhl As Double counthhl = lst If CheckBox1.Checked = True Then r7.Text = r7.Text + counthhl Else r7.Text = r7.Text - counthhl End If End If conn1.Close() conn1.Dispose() Catch ex As Exception 'MsgBox(ex.Message) Finally End Try r8pco() End Sub Private Sub r8pco() Try Dim table As New DataTable() conns() Dim adapter As New MySqlDataAdapter("SELECT names FROM pco where purok = '" & DataGridView1.Rows(7).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) adapter.Fill(table) If DataGridView1.RowCount > -1 Then Dim lst = (From row In table.AsEnumerable Select row.Field(Of String)(0)).Count Dim counthhl As Double counthhl = lst If CheckBox1.Checked = True Then r8.Text = r8.Text + counthhl Else r8.Text = r8.Text - counthhl End If End If conn1.Close() conn1.Dispose() Catch ex As Exception 'MsgBox(ex.Message) Finally End Try r9pco() End Sub Private Sub r9pco() Try Dim table As New DataTable() conns() Dim adapter As New MySqlDataAdapter("SELECT names FROM pco where purok = '" & DataGridView1.Rows(8).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) adapter.Fill(table) If DataGridView1.RowCount > -1 Then Dim lst = (From row In table.AsEnumerable Select row.Field(Of String)(0)).Count Dim counthhl As Double counthhl = lst If CheckBox1.Checked = True Then r9.Text = r9.Text + counthhl Else r9.Text = r9.Text - counthhl End If End If conn1.Close() conn1.Dispose() Catch ex As Exception 'MsgBox(ex.Message) Finally End Try r10pco() End Sub Private Sub r10pco() Try Dim table As New DataTable() conns() Dim adapter As New MySqlDataAdapter("SELECT names FROM pco where purok = '" & DataGridView1.Rows(9).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) adapter.Fill(table) If DataGridView1.RowCount > -1 Then Dim lst = (From row In table.AsEnumerable Select row.Field(Of String)(0)).Count Dim counthhl As Double counthhl = lst If CheckBox1.Checked = True Then r10.Text = r10.Text + counthhl Else r10.Text = r10.Text - counthhl End If End If conn1.Close() conn1.Dispose() Catch ex As Exception 'MsgBox(ex.Message) Finally End Try r11pco() End Sub Private Sub r11pco() Try Dim table As New DataTable() conns() Dim adapter As New MySqlDataAdapter("SELECT names FROM pco where purok = '" & DataGridView1.Rows(10).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) adapter.Fill(table) If DataGridView1.RowCount > -1 Then Dim lst = (From row In table.AsEnumerable Select row.Field(Of String)(0)).Count Dim counthhl As Double counthhl = lst If CheckBox1.Checked = True Then r11.Text = r11.Text + counthhl Else r11.Text = r11.Text - counthhl End If End If conn1.Close() conn1.Dispose() Catch ex As Exception 'MsgBox(ex.Message) Finally End Try r12pco() End Sub Private Sub r12pco() Try Dim table As New DataTable() conns() Dim adapter As New MySqlDataAdapter("SELECT names FROM pco where purok = '" & DataGridView1.Rows(11).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) adapter.Fill(table) If DataGridView1.RowCount > -1 Then Dim lst = (From row In table.AsEnumerable Select row.Field(Of String)(0)).Count Dim counthhl As Double counthhl = lst If CheckBox1.Checked = True Then r12.Text = r12.Text + counthhl Else r12.Text = r12.Text - counthhl End If End If conn1.Close() conn1.Dispose() Catch ex As Exception 'MsgBox(ex.Message) Finally End Try r13pco() End Sub Private Sub r13pco() Try Dim table As New DataTable() conns() Dim adapter As New MySqlDataAdapter("SELECT names FROM pco where purok = '" & DataGridView1.Rows(12).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) adapter.Fill(table) If DataGridView1.RowCount > -1 Then Dim lst = (From row In table.AsEnumerable Select row.Field(Of String)(0)).Count Dim counthhl As Double counthhl = lst If CheckBox1.Checked = True Then r13.Text = r13.Text + counthhl Else r13.Text = r13.Text - counthhl End If End If conn1.Close() conn1.Dispose() Catch ex As Exception 'MsgBox(ex.Message) Finally End Try r14pco() End Sub Private Sub r14pco() Try Dim table As New DataTable() conns() Dim adapter As New MySqlDataAdapter("SELECT names FROM pco where purok = '" & DataGridView1.Rows(13).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) adapter.Fill(table) If DataGridView1.RowCount > -1 Then Dim lst = (From row In table.AsEnumerable Select row.Field(Of String)(0)).Count Dim counthhl As Double counthhl = lst If CheckBox1.Checked = True Then r14.Text = r14.Text + counthhl Else r14.Text = r14.Text - counthhl End If End If conn1.Close() conn1.Dispose() Catch ex As Exception 'MsgBox(ex.Message) Finally End Try r15pco() End Sub Private Sub r15pco() Try Dim table As New DataTable() conns() Dim adapter As New MySqlDataAdapter("SELECT names FROM pco where purok = '" & DataGridView1.Rows(14).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) adapter.Fill(table) If DataGridView1.RowCount > -1 Then Dim lst = (From row In table.AsEnumerable Select row.Field(Of String)(0)).Count Dim counthhl As Double counthhl = lst If CheckBox1.Checked = True Then r15.Text = r15.Text + counthhl Else r15.Text = r15.Text - counthhl End If End If conn1.Close() conn1.Dispose() Catch ex As Exception 'MsgBox(ex.Message) Finally End Try r16pco() End Sub Private Sub r16pco() Try Dim table As New DataTable() conns() Dim adapter As New MySqlDataAdapter("SELECT names FROM pco where purok = '" & DataGridView1.Rows(15).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) adapter.Fill(table) If DataGridView1.RowCount > -1 Then Dim lst = (From row In table.AsEnumerable Select row.Field(Of String)(0)).Count Dim counthhl As Double counthhl = lst If CheckBox1.Checked = True Then r16.Text = r16.Text + counthhl Else r16.Text = r16.Text - counthhl End If End If conn1.Close() conn1.Dispose() Catch ex As Exception 'MsgBox(ex.Message) Finally End Try r17pco() End Sub Private Sub r17pco() Try Dim table As New DataTable() conns() Dim adapter As New MySqlDataAdapter("SELECT names FROM pco where purok = '" & DataGridView1.Rows(16).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) adapter.Fill(table) If DataGridView1.RowCount > -1 Then Dim lst = (From row In table.AsEnumerable Select row.Field(Of String)(0)).Count Dim counthhl As Double counthhl = lst If CheckBox1.Checked = True Then r17.Text = r17.Text + counthhl Else r17.Text = r17.Text - counthhl End If End If conn1.Close() conn1.Dispose() Catch ex As Exception 'MsgBox(ex.Message) Finally End Try r18pco() End Sub Private Sub r18pco() Try Dim table As New DataTable() conns() Dim adapter As New MySqlDataAdapter("SELECT names FROM pco where purok = '" & DataGridView1.Rows(17).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) adapter.Fill(table) If DataGridView1.RowCount > -1 Then Dim lst = (From row In table.AsEnumerable Select row.Field(Of String)(0)).Count Dim counthhl As Double counthhl = lst If CheckBox1.Checked = True Then r18.Text = r18.Text + counthhl Else r18.Text = r18.Text - counthhl End If End If conn1.Close() conn1.Dispose() Catch ex As Exception 'MsgBox(ex.Message) Finally End Try 'r1bcc() End Sub '====================================================================== '====================================================================== '====================================================================== '====================================================================== '====================================================================== '====================================================================== '====================================================================== '====================================================================== '====================================================================== '====================================================================== '====================================================================== '====================================================================== '====================================================================== '====================================================================== '====================================================================== 'BCC Sub r1bcc() Try Dim table As New DataTable() conns() Dim adapter As New MySqlDataAdapter("SELECT names FROM bcc where purok = '" & DataGridView1.Rows(0).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) adapter.Fill(table) If DataGridView1.RowCount > -1 Then Dim lst = (From row In table.AsEnumerable Select row.Field(Of String)(0)).Count Dim counthhl As Double counthhl = lst If CheckBox1.Checked = True Then r1.Text = r1.Text + counthhl Else r1.Text = r1.Text - counthhl End If End If conn1.Close() conn1.Dispose() Catch ex As Exception ' MsgBox(ex.Message) Finally End Try r2bcc() End Sub Private Sub r2bcc() Try Dim table As New DataTable() conns() Dim adapter As New MySqlDataAdapter("SELECT names FROM bcc where purok = '" & DataGridView1.Rows(1).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) adapter.Fill(table) If DataGridView1.RowCount > -1 Then Dim lst = (From row In table.AsEnumerable Select row.Field(Of String)(0)).Count Dim counthhl As Double counthhl = lst If CheckBox1.Checked = True Then r2.Text = r2.Text + counthhl Else r2.Text = r2.Text - counthhl End If End If conn1.Close() conn1.Dispose() Catch ex As Exception ' MsgBox(ex.Message) Finally End Try r3bcc() End Sub Private Sub r3bcc() Try Dim table As New DataTable() conns() Dim adapter As New MySqlDataAdapter("SELECT names FROM bcc where purok = '" & DataGridView1.Rows(2).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) adapter.Fill(table) If DataGridView1.RowCount > -1 Then Dim lst = (From row In table.AsEnumerable Select row.Field(Of String)(0)).Count Dim counthhl As Double counthhl = lst If CheckBox1.Checked = True Then r3.Text = r3.Text + counthhl Else r3.Text = r3.Text - counthhl End If End If conn1.Close() conn1.Dispose() Catch ex As Exception 'MsgBox(ex.Message) Finally End Try r4bcc() End Sub Private Sub r4bcc() Try Dim table As New DataTable() conns() Dim adapter As New MySqlDataAdapter("SELECT names FROM bcc where purok = '" & DataGridView1.Rows(3).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) adapter.Fill(table) If DataGridView1.RowCount > -1 Then Dim lst = (From row In table.AsEnumerable Select row.Field(Of String)(0)).Count Dim counthhl As Double counthhl = lst If CheckBox1.Checked = True Then r4.Text = r4.Text + counthhl Else r4.Text = r4.Text - counthhl End If End If conn1.Close() conn1.Dispose() Catch ex As Exception 'MsgBox(ex.Message) Finally End Try r5bcc() End Sub Private Sub r5bcc() Try Dim table As New DataTable() conns() Dim adapter As New MySqlDataAdapter("SELECT names FROM bcc where purok = '" & DataGridView1.Rows(4).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) adapter.Fill(table) If DataGridView1.RowCount > -1 Then Dim lst = (From row In table.AsEnumerable Select row.Field(Of String)(0)).Count Dim counthhl As Double counthhl = lst If CheckBox1.Checked = True Then r5.Text = r5.Text + counthhl Else r5.Text = r5.Text - counthhl End If End If conn1.Close() conn1.Dispose() Catch ex As Exception ' MsgBox(ex.Message) Finally End Try r6bcc() End Sub Private Sub r6bcc() Try Dim table As New DataTable() conns() Dim adapter As New MySqlDataAdapter("SELECT names FROM bcc where purok = '" & DataGridView1.Rows(5).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) adapter.Fill(table) If DataGridView1.RowCount > -1 Then Dim lst = (From row In table.AsEnumerable Select row.Field(Of String)(0)).Count Dim counthhl As Double counthhl = lst If CheckBox1.Checked = True Then r6.Text = r6.Text + counthhl Else r6.Text = r6.Text - counthhl End If End If conn1.Close() conn1.Dispose() Catch ex As Exception 'MsgBox(ex.Message) Finally End Try r7bcc() End Sub Private Sub r7bcc() Try Dim table As New DataTable() conns() Dim adapter As New MySqlDataAdapter("SELECT names FROM bcc where purok = '" & DataGridView1.Rows(6).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) adapter.Fill(table) If DataGridView1.RowCount > -1 Then Dim lst = (From row In table.AsEnumerable Select row.Field(Of String)(0)).Count Dim counthhl As Double counthhl = lst If CheckBox1.Checked = True Then r7.Text = r7.Text + counthhl Else r7.Text = r7.Text - counthhl End If End If conn1.Close() conn1.Dispose() Catch ex As Exception 'MsgBox(ex.Message) Finally End Try r8bcc() End Sub Private Sub r8bcc() Try Dim table As New DataTable() conns() Dim adapter As New MySqlDataAdapter("SELECT names FROM bcc where purok = '" & DataGridView1.Rows(7).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) adapter.Fill(table) If DataGridView1.RowCount > -1 Then Dim lst = (From row In table.AsEnumerable Select row.Field(Of String)(0)).Count Dim counthhl As Double counthhl = lst If CheckBox1.Checked = True Then r8.Text = r8.Text + counthhl Else r8.Text = r8.Text - counthhl End If End If conn1.Close() conn1.Dispose() Catch ex As Exception 'MsgBox(ex.Message) Finally End Try r9bcc() End Sub Private Sub r9bcc() Try Dim table As New DataTable() conns() Dim adapter As New MySqlDataAdapter("SELECT names FROM bcc where purok = '" & DataGridView1.Rows(8).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) adapter.Fill(table) If DataGridView1.RowCount > -1 Then Dim lst = (From row In table.AsEnumerable Select row.Field(Of String)(0)).Count Dim counthhl As Double counthhl = lst If CheckBox1.Checked = True Then r9.Text = r9.Text + counthhl Else r9.Text = r9.Text - counthhl End If End If conn1.Close() conn1.Dispose() Catch ex As Exception 'MsgBox(ex.Message) Finally End Try r10bcc() End Sub Private Sub r10bcc() Try Dim table As New DataTable() conns() Dim adapter As New MySqlDataAdapter("SELECT names FROM bcc where purok = '" & DataGridView1.Rows(9).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) adapter.Fill(table) If DataGridView1.RowCount > -1 Then Dim lst = (From row In table.AsEnumerable Select row.Field(Of String)(0)).Count Dim counthhl As Double counthhl = lst If CheckBox1.Checked = True Then r10.Text = r10.Text + counthhl Else r10.Text = r10.Text - counthhl End If End If conn1.Close() conn1.Dispose() Catch ex As Exception 'MsgBox(ex.Message) Finally End Try r11bcc() End Sub Private Sub r11bcc() Try Dim table As New DataTable() conns() Dim adapter As New MySqlDataAdapter("SELECT names FROM bcc where purok = '" & DataGridView1.Rows(10).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) adapter.Fill(table) If DataGridView1.RowCount > -1 Then Dim lst = (From row In table.AsEnumerable Select row.Field(Of String)(0)).Count Dim counthhl As Double counthhl = lst If CheckBox1.Checked = True Then r11.Text = r11.Text + counthhl Else r11.Text = r11.Text - counthhl End If End If conn1.Close() conn1.Dispose() Catch ex As Exception 'MsgBox(ex.Message) Finally End Try r12bcc() End Sub Private Sub r12bcc() Try Dim table As New DataTable() conns() Dim adapter As New MySqlDataAdapter("SELECT names FROM bcc where purok = '" & DataGridView1.Rows(11).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) adapter.Fill(table) If DataGridView1.RowCount > -1 Then Dim lst = (From row In table.AsEnumerable Select row.Field(Of String)(0)).Count Dim counthhl As Double counthhl = lst If CheckBox1.Checked = True Then r12.Text = r12.Text + counthhl Else r12.Text = r12.Text - counthhl End If End If conn1.Close() conn1.Dispose() Catch ex As Exception 'MsgBox(ex.Message) Finally End Try r13bcc() End Sub Private Sub r13bcc() Try Dim table As New DataTable() conns() Dim adapter As New MySqlDataAdapter("SELECT names FROM bcc where purok = '" & DataGridView1.Rows(12).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) adapter.Fill(table) If DataGridView1.RowCount > -1 Then Dim lst = (From row In table.AsEnumerable Select row.Field(Of String)(0)).Count Dim counthhl As Double counthhl = lst If CheckBox1.Checked = True Then r13.Text = r13.Text + counthhl Else r13.Text = r13.Text - counthhl End If End If conn1.Close() conn1.Dispose() Catch ex As Exception 'MsgBox(ex.Message) Finally End Try r14bcc() End Sub Private Sub r14bcc() Try Dim table As New DataTable() conns() Dim adapter As New MySqlDataAdapter("SELECT names FROM bcc where purok = '" & DataGridView1.Rows(13).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) adapter.Fill(table) If DataGridView1.RowCount > -1 Then Dim lst = (From row In table.AsEnumerable Select row.Field(Of String)(0)).Count Dim counthhl As Double counthhl = lst If CheckBox1.Checked = True Then r14.Text = r14.Text + counthhl Else r14.Text = r14.Text - counthhl End If End If conn1.Close() conn1.Dispose() Catch ex As Exception 'MsgBox(ex.Message) Finally End Try r15bcc() End Sub Private Sub r15bcc() Try Dim table As New DataTable() conns() Dim adapter As New MySqlDataAdapter("SELECT names FROM bcc where purok = '" & DataGridView1.Rows(14).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) adapter.Fill(table) If DataGridView1.RowCount > -1 Then Dim lst = (From row In table.AsEnumerable Select row.Field(Of String)(0)).Count Dim counthhl As Double counthhl = lst If CheckBox1.Checked = True Then r15.Text = r15.Text + counthhl Else r15.Text = r15.Text - counthhl End If End If conn1.Close() conn1.Dispose() Catch ex As Exception 'MsgBox(ex.Message) Finally End Try r16bcc() End Sub Private Sub r16bcc() Try Dim table As New DataTable() conns() Dim adapter As New MySqlDataAdapter("SELECT names FROM bcc where purok = '" & DataGridView1.Rows(15).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) adapter.Fill(table) If DataGridView1.RowCount > -1 Then Dim lst = (From row In table.AsEnumerable Select row.Field(Of String)(0)).Count Dim counthhl As Double counthhl = lst If CheckBox1.Checked = True Then r16.Text = r16.Text + counthhl Else r16.Text = r16.Text - counthhl End If End If conn1.Close() conn1.Dispose() Catch ex As Exception 'MsgBox(ex.Message) Finally End Try r17bcc() End Sub Private Sub r17bcc() Try Dim table As New DataTable() conns() Dim adapter As New MySqlDataAdapter("SELECT names FROM bcc where purok = '" & DataGridView1.Rows(16).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) adapter.Fill(table) If DataGridView1.RowCount > -1 Then Dim lst = (From row In table.AsEnumerable Select row.Field(Of String)(0)).Count Dim counthhl As Double counthhl = lst If CheckBox1.Checked = True Then r17.Text = r17.Text + counthhl Else r17.Text = r17.Text - counthhl End If End If conn1.Close() conn1.Dispose() Catch ex As Exception ' MsgBox(ex.Message) Finally End Try r18bcc() End Sub Private Sub r18bcc() Try Dim table As New DataTable() conns() Dim adapter As New MySqlDataAdapter("SELECT names FROM bcc where purok = '" & DataGridView1.Rows(17).Cells(0).Value & "' AND barangay = '" & barangay.Text & "'", conn1) adapter.Fill(table) If DataGridView1.RowCount > -1 Then Dim lst = (From row In table.AsEnumerable Select row.Field(Of String)(0)).Count Dim counthhl As Double counthhl = lst If CheckBox1.Checked = True Then r18.Text = r18.Text + counthhl Else r18.Text = r18.Text - counthhl End If End If conn1.Close() conn1.Dispose() Catch ex As Exception 'MsgBox(ex.Message) Finally End Try End Sub Private Sub STAFEbcc() Try Dim table As New DataTable() conns() Dim adapter As New MySqlDataAdapter("SELECT names FROM bcc where barangay LIKE 'STA. FE' ", conn1) adapter.Fill(table) Dim lst = (From row In table.AsEnumerable Select row.Field(Of String)(0)).Count Dim counthhl As Double counthhl = lst If CheckBox1.Checked = True Then r17.Text = r17.Text + counthhl Else r17.Text = r17.Text - counthhl End If conn1.Close() conn1.Dispose() Catch ex As Exception MsgBox(ex.Message) Finally End Try 'r1hhl() End Sub End Class