0% found this document useful (0 votes)
16 views442 pages

Mathias Source Code

The document is a Visual Basic .NET code for a user form in a student attendance system. It includes various functionalities such as managing student and staff records, handling SMS notifications, and monitoring device connections. The code also contains event handlers for form loading, closing, and timer events, as well as database connection management.

Uploaded by

ngisolutionsja
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views442 pages

Mathias Source Code

The document is a Visual Basic .NET code for a user form in a student attendance system. It includes various functionalities such as managing student and staff records, handling SMS notifications, and monitoring device connections. The code also contains event handlers for form loading, closing, and timer events, as well as database connection management.

Uploaded by

ngisolutionsja
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 442

Imports System.Runtime.

InteropServices

Imports System.Math

Imports System.Data.OleDb

Imports System.Management

Imports System.IO

Imports System.Configuration

Imports System.Threading

Imports System.Windows.Threading

Imports System.IO.Ports

Imports System.ComponentModel

Imports System.Net

Imports System.Threading.Tasks

Imports System.Net.Http

Imports System.Windows

Imports System.Timers

Imports System.Text

Imports Twilio

Imports Twilio.Rest.Api.V2010.Account

Imports Twilio.Types

Imports System.Data.Odbc

Public Class Userform

Private timeLeft As Integer

Dim second As Integer

Dim provider As String


Dim datafile As String

Dim constring As String

Dim myconnection As OleDbConnection = New OleDbConnection

Dim psms As String = ""

Dim a As String

Dim newitem As String

Dim h As Integer

Dim c As Integer

Dim cnt1 As Integer = 0

Dim fname As String

Dim Sname As String

Dim picpath As String

Dim rcvdata As String = ""

Dim eDS As DataSet = New DataSet

Dim eDA As OleDbDataAdapter = New OleDbDataAdapter

Dim eDR As DataRow

Dim dDS As DataSet = New DataSet

Dim dDA As OleDbDataAdapter = New OleDbDataAdapter

Dim dDR As DataRow

Dim ftime As String

Dim FirstDate As Date

Dim secondDate As Date

Dim rptoption As String

Dim cmd As OleDbCommand


Dim early As String

Dim late As String

Dim absent As String

Dim cls, cls1, status As String

Dim drpt, drpt1, drpt2 As String

Dim StartTerm, EndTerm As String

Private strSQL As String = ""

Private targetTime As DateTime

Dim scheduledTime As String

Private WithEvents Tmr As New System.Windows.Forms.Timer

Private command As OleDbCommand

Private command2 As OleDbCommand

Private targetTime1 As DateTime

Dim scheduledTime1 As String

Private WithEvents Tmr1 As New System.Windows.Forms.Timer

Dim male, p, q As String

Dim staffmale As String

Dim staffsms As String

Public number As String

Public number2 As String

Dim sValue As String

Private Workers() As BackgroundWorker

Private NumWorkers As String = 0

Private numbers As List(Of Long) = New List(Of Long)

Dim rxd As Char


Dim male2 As String

Dim ganderstaff As String

Dim pusms As String

Dim staffsms2 As String

Dim gtimeLeft As Integer

Public hr, mn, se, cnt As Integer

Dim myPort As Array 'var to store all COM ports

Delegate Sub SetTextCallback(ByVal [text] As String) 'Added to prevent threading errors during
receiveing of data

Dim idd, ids, b_in, sstd, b_out, srbd As String

Private aTimer As System.Timers.Timer

Private bTimer As System.Timers.Timer

Dim ss(200) As String

Public tempDate As List(Of Date) = New List(Of Date)

Dim VID_PID_device = "VID_067B&PID_2303" ' Change to your's

Dim endText As String = "5&744228E&0&2"

Dim WithEvents pluggedInWatcher As ManagementEventWatcher

Dim WithEvents pluggedOutWatcher As ManagementEventWatcher

Dim pluggedInQuery As WqlEventQuery

Dim pluggedOutQuery As WqlEventQuery

Dim imgbox As String = My.Application.Info.DirectoryPath & "\images\emptyimage.png"

Public imgboxreplace As String = My.Application.Info.DirectoryPath & "\images\emptyimage.png"

Private Sub Form2_FormClosing(ByVal sender As Object, ByVal e As


System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
If MessageBox.Show("Are you sure you want to Log-out?", "CLOSE", MessageBoxButtons.OKCancel,
MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

myconnection.Close()

Login.Show()

Else

e.Cancel = True

End If

End Sub

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


MyBase.Load

provider = "provider = microsoft.ace.oledb.12.0; data source=studentattendancesystem.accdb;


Persist Security Info=False;"

myconnection.ConnectionString = provider

generate_student_id()

generate_staff_id()

ActiveControl = txtid

txtid.Focus()

RadioButton2.Checked = True

BunifuLabel186.Text = Format(Now, "MMMM d, yyyy h:mm:ss tt")

Timer1.Enabled = True

Button2.Dispose()

insertimagelogo()
retrieveSignout()

retrieveAbsentOut()

retrieveTime()

retrieveDpt()

Tmr.Interval = 1000

Tmr.Enabled = False

SetTarget()

activiteSms()

RetrieveToCombo1()

BunifuTextBox1.Text = My.Application.Info.DirectoryPath & "\images\emptyimage.png"

retrieveMessages()

staffRetrieveMessages()

retrieveSubject()

retrieveTitle()

retrieveTerm()

Me.BindGrid()

Me.BindGrid1()

refreshModerm()

If ComboBox2.Items.Count = 0 Then

Label13.Text = "Unknown: Connect modem to PC and select COM port"

'Label90.Text = "Unknown: Connect modem to PC and select COM port"

End If

'Button22.Enabled = False

initilizeLogoutTime()
RetrieveChkSms()

RetrieveStaffChkSms()

DataGridView4.Hide()

dgvStaff.Hide()

Tmr1.Interval = 1000

Tmr1.Enabled = False

SetTarget1()

checkRelog()

retrieveExcludedates()

checkWeekends()

filldb()

TestSwitch()

SmsSwitch()

activateDashboard()

If BunifuPages1.TabPages(1).Enabled = True Then

mainGraph()

'refreshDashboard()

dailyGraphs()

Else

dummyChartsData()

End If

Dim rpt As New CrystalReport1

rpt.Refresh()
rpt.SetParameterValue(0, Date.Now.ToString("MM /dd/ yy"))

rpt.SetParameterValue(1, Date.Now.ToString("MM /dd/ yy"))

rpt.SetParameterValue(2, "Default") 'assign some default value

rpt.SetParameterValue(3, Date.Now.ToString("hh:mm tt"))

rpt.SetParameterValue(4, Date.Now.ToString("hh:mm tt"))

CrystalReportViewer1.ReportSource = rpt 'dynamically assigned report source

'gtimeLeft = 180

'Timer4.Start()

update_linked_table()

check_ODBC_status()

Try

pluggedInQuery = New WqlEventQuery

pluggedInQuery.QueryString = "SELECT * FROM Win32_DeviceChangeEvent WHERE EventType =


2"

pluggedInWatcher = New ManagementEventWatcher(pluggedInQuery)

pluggedInWatcher.Start()

pluggedOutQuery = New WqlEventQuery

pluggedOutQuery.QueryString = "SELECT * FROM Win32_DeviceChangeEvent WHERE EventType =


3"

pluggedOutWatcher = New ManagementEventWatcher(pluggedOutQuery)

pluggedOutWatcher.Start()

Catch ex As Exception

MsgBox(ex.Message)
End Try

getYearAndTerm()

If Find_Device_By_VID_PID(VID_PID_device, endText) Then

SetLabel30Text("Connected")

Else

SetLabel30Text("Disconnected")

End If

updateGlobalAndActive()

dbRegistryType.SelectedIndex = 0

dbRecordType.SelectedIndex = 0

dbStudentFilter.SelectedIndex = 0

ddRegistryTypeFilter.SelectedIndex = 1

ddAttendanceType.SelectedIndex = 0

RadioButton11.Checked = True

rdFilterByMnth.Checked = True

BunifuButton18_Click_2(Nothing, Nothing)

updateScanLogReset()
End Sub

'Protected Overloads Overrides ReadOnly Property CreateParams() As CreateParams

' Get

' Dim cp As CreateParams = MyBase.CreateParams

' cp.ExStyle = cp.ExStyle Or 33554432

' Return cp

' End Get

'End Property

Public Sub activiteSms()

Dim Cstate As String = ""

Dim flag As String = "smsState"

myconnection.Open()

Dim cmd As OleDbCommand = New OleDbCommand("SELECT timeset FROM controlsignout WHERE


flag='" & flag & "'", myconnection)

Dim dr As OleDbDataReader = cmd.ExecuteReader

While dr.Read

Cstate = dr("timeset")

End While

myconnection.Close()

Panel25.Enabled = Cstate

End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Timer1.Tick

BunifuLabel185.Text = Format(Now, "MMMM d, yyyy ")

BunifuLabel186.Text = Format(Now, "h:mm:ss tt ")

End Sub

Public Sub studentrec()

'Dim sql1 As String

'sql1 = "SELECT ID, Firstname, lastname, Gender,Guardiannumber1,Address, City, Parish, Age, Class,
Department FROM students"

'Dim adapter1 As New OleDbDataAdapter(sql1, myconnection)

'Dim cmd1 As New OleDbCommand(sql1, myconnection)

'Dim dt1 As New DataTable("users")

'adapter1.Fill(dt1)

'DataGridView1.DataSource = dt1

'BunifuDataGridView1.ColumnHeadersDefaultCellStyle.Font = New Font(DataGridView.DefaultFont,


FontStyle.Bold)

End Sub

#Region "Constants"

Private Const WM_DEVICECHANGE As Integer = &H219

Private Const DBT_DEVICEARRIVAL As Integer = &H8000


Private Const DBT_DEVICEREMOVECOMPLETE As Integer = &H8004

Private Const DBT_DEVTYP_VOLUME As Integer = &H2

#End Region

#Region "Structures"

Private Structure DEV_BROADCAST_HDR

Public dbch_size As Int32

Public dbch_devicetype As Int32

Public dbch_reserved As Int32

End Structure

Private Structure DEV_BROADCAST_VOLUME

Public dbcv_size As Int32

Public dbcv_devicetype As Int32

Public dbcv_reserved As Int32

Public dbcv_unitmask As Int32

Public dbcv_flags As Int32

End Structure
#End Region

#Region "WndProc (SUB)"

'Protected Overrides Sub WndProc(ByRef m As Message)

' ' Windows MESSAGE

' If m.Msg = WM_DEVICECHANGE Then

' ' Check to see if device was plugged in

' If m.WParam.ToInt32() = DBT_DEVICEARRIVAL Then

' Dim hdr As DEV_BROADCAST_HDR =

' CType(Marshal.PtrToStructure(m.LParam, GetType(DEV_BROADCAST_HDR)),

' DEV_BROADCAST_HDR)

' ' See if the device is a USB Flash Drive etc.

' If hdr.dbch_devicetype = DBT_DEVTYP_VOLUME Then

' ' Declare volume as structure

' Dim vol As DEV_BROADCAST_VOLUME =

' CType(Marshal.PtrToStructure(m.LParam, GetType(DEV_BROADCAST_VOLUME)),


' DEV_BROADCAST_VOLUME)

' ' Get volume number

' Dim mask As Int32 = vol.dbcv_unitmask

' ' Get the drive letter

' Dim chDriveLetter As Char() = GetDriveLetter(mask)

' ' Display the drive letter

' 'lblDrive.Text = String.Format("USB Flash Drive Plugged Into {0}:",


chDriveLetter(0).ToString().ToUpper())

' End If

' ElseIf m.WParam.ToInt32() = DBT_DEVICEREMOVECOMPLETE Then

' ' Flash Drive Unplugged

' ' lblDrive.Text = "USB Flash Drive Removed"

' Label13.Text = "Disconnected"

' Label90.Text = "Disconnected"

' End If

' End If

' Try

' MyBase.WndProc(m)

' Catch ex As Exception

' MsgBox(ex)

' End Try

'End Sub

#End Region
#Region "Get Drive Letter (FUNCTION)"

Private Function GetDriveLetter(ByVal iChar As Int32) As Char()

Dim cnt As Integer = 0

Dim intTemp As Int32 = iChar

Dim i As Integer

For i = 0 To 31

If (intTemp And 1) = 1 Then

cnt += 1

End If

intTemp = (intTemp > 1)

If intTemp = 0 Then

Exit For

End If

Next

Dim chResult(0) As Char

Dim ii As Integer

For ii = 0 To 31

If (iChar And 1) = 1 Then

chResult(0) = Chr(97 + ii)

End If
iChar = (iChar > 1)

If iChar = 0 Then

Exit For

End If

Next

Return chResult

End Function

#End Region

Private Sub register()

myconnection.Open()

End Sub

Private Sub TextBox22_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles


TextBox22.GotFocus

TextBox22.Clear()

End Sub

Private Sub TextBox3_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles


TextBox3.GotFocus

TextBox3.Clear()

End Sub
Private Sub txtfirstname_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles txtsurname.TextChanged, txtmiddlename.TextChanged, txtfirstname.TextChanged,
txtaddress.TextChanged, TextBox7.TextChanged, TextBox6.TextChanged, TextBox4.TextChanged,
TextBox3.TextChanged, TextBox22.TextChanged, TextBox2.TextChanged, TextBox19.TextChanged,
TextBox18.TextChanged

If txtfirstname.Text <> "" Then

Dim a As String = txtfirstname.Text

txtfirstname.Text = (StrConv(a, VbStrConv.ProperCase))

txtfirstname.Select(txtfirstname.Text.Length, 0)

End If

If TextBox3.Text <> "" Then

Dim a As String = TextBox3.Text

TextBox3.Text = (StrConv(a, VbStrConv.ProperCase))

TextBox3.Select(TextBox3.Text.Length, 0)

End If

'If TextBox22.Text <> "" Then

' Dim a As String = TextBox22.Text

' TextBox22.Text = (StrConv(a, VbStrConv.ProperCase))

' TextBox22.Select(TextBox22.Text.Length, 0)

'End If

If txtaddress.Text <> "" Then

Dim a As String = txtaddress.Text

txtaddress.Text = (StrConv(a, VbStrConv.ProperCase))

txtaddress.Select(txtaddress.Text.Length, 0)

End If

If txtsurname.Text <> "" Then


Dim a As String = txtsurname.Text

txtsurname.Text = (StrConv(a, VbStrConv.ProperCase))

txtsurname.Select(txtsurname.Text.Length, 0)

End If

If txtmiddlename.Text <> "" Then

Dim a As String = txtmiddlename.Text

txtmiddlename.Text = (StrConv(a, VbStrConv.ProperCase))

txtmiddlename.Select(txtmiddlename.Text.Length, 0)

End If

If TextBox2.Text <> "" Then

Dim a As String = TextBox2.Text

TextBox2.Text = (StrConv(a, VbStrConv.ProperCase))

TextBox2.Select(TextBox2.Text.Length, 0)

End If

If TextBox4.Text <> "" Then

Dim a As String = TextBox4.Text

TextBox4.Text = (StrConv(a, VbStrConv.ProperCase))

TextBox4.Select(TextBox4.Text.Length, 0)

End If

If TextBox6.Text <> "" Then

Dim a As String = TextBox6.Text

TextBox6.Text = (StrConv(a, VbStrConv.ProperCase))

TextBox6.Select(TextBox6.Text.Length, 0)

End If

If TextBox7.Text <> "" Then


Dim a As String = TextBox7.Text

TextBox7.Text = (StrConv(a, VbStrConv.ProperCase))

TextBox7.Select(TextBox7.Text.Length, 0)

End If

If TextBox18.Text <> "" Then

Dim a As String = TextBox18.Text

TextBox18.Text = (StrConv(a, VbStrConv.ProperCase))

TextBox18.Select(TextBox18.Text.Length, 0)

End If

If TextBox19.Text <> "" Then

Dim a As String = TextBox19.Text

TextBox19.Text = (StrConv(a, VbStrConv.ProperCase))

TextBox19.Select(TextBox19.Text.Length, 0)

End If

End Sub

#Region "Student Scan methods"

Private Sub check_info()

If String.IsNullOrEmpty(myconnection.ConnectionString) Then

provider = "provider = microsoft.ace.oledb.12.0; data source=studentattendancesystem.accdb;


Persist Security Info=False;"

myconnection.ConnectionString = provider

Else

If myconnection.State = ConnectionState.Open Then

Else
myconnection.Open()

End If

End If

eDA.SelectCommand = New OleDbCommand("SELECT firstname, lastname, count, id FROM students


WHERE tag_ID='" & txtid.Text & "'", myconnection)

eDS.Clear()

eDA.Fill(eDS)

If eDS.Tables(0).Rows.Count > 0 Then

eDR = eDS.Tables(0).Rows(0)

txtname.Text = eDR("Firstname")

'txtsurname.Text = eDR("lastname").ToString()

TextBox25.Text = eDR("id")

a = eDR("count")

Dim userfound As Boolean = False

userfound = True

If userfound = True Then

insertimage()

End If

dDA.SelectCommand = New OleDbCommand("SELECT * FROM studentsrecords WHERE tag_id='"


& txtid.Text & "' AND date_in=#" & DateTime.Now.ToString("MM/d/yyyy") & "# AND flag='" & 1 & "' AND
time_out IS NULL", myconnection)

dDS.Clear()

dDA.Fill(dDS)

If dDS.Tables(0).Rows.Count > 0 Then

dDR = dDS.Tables(0).Rows(0)

Button2.Enabled = True
Button2.Text = "&Time Out"

txttimein.Text = dDR("time_in") ' Format(dDR("time_in"), "HH:mm:ss tt")

idd = txtid.Text

insertstd() 'found

If RadioButton7.Checked = True Then

'InsertSmsData(txtid.Text, ids, b_in)

Else

End If

Else

dDA.SelectCommand = New OleDbCommand("SELECT * FROM studentsrecords WHERE


tag_id='" & txtid.Text & "' AND date_in=#" & DateTime.Now.ToString("MM/d/yyyy") & "# AND flag='" & 1
& "' AND time_out IS NOT NULL AND time_out IS NOT NULL", myconnection)

dDS.Clear()

dDA.Fill(dDS)

If dDS.Tables(0).Rows.Count > 0 Then

dDR = dDS.Tables(0).Rows(0)

Label23.Text = "Already Signed-In"

Else

Button2.Enabled = True

Button2.Text = "&Time In"

idd = txtid.Text

insertstd()
If RadioButton7.Checked = True Then

'InsertSmsData(txtid.Text, ids, b_in)

Else

End If

makeThemAbsent()

End If

End If

dDR = Nothing

dDS.Dispose()

dDA.Dispose()

cleartimer()

Else

'cleartimer()

'Button2.Enabled = False

'myconnection.Close()

check_info_staff()

End If

eDR = Nothing

eDS.Dispose()

eDA.Dispose()

myconnection.Close()
updateScanLog()

End Sub

Private Sub makeThemAbsent()

Dim strSQL As String = ""

Dim strSQ As String

If String.IsNullOrEmpty(myconnection.ConnectionString) Then

provider = "provider = microsoft.ace.oledb.12.0; data source=studentattendancesystem.accdb;


Persist Security Info=False;"

myconnection.ConnectionString = provider

Else

If myconnection.State = ConnectionState.Open Then

Else

myconnection.Open()

End If

End If

Dim cmd As OleDbCommand = New OleDbCommand("select date_in from [studentsrecords] where


date_in=#" & Format(Now, "MM/d/yyyy") & "# AND flag='1' AND (select top 1 date_in from
[studentsrecords] where date_in=#" & Format(Now, "MM/d/yyyy") & "# AND time_in IS NULL and
time_out IS NULL and Flag IS Null)", myconnection)

Dim dr As OleDbDataReader = cmd.ExecuteReader

Dim userfound As Boolean = False

While dr.Read

userfound = True
End While

If userfound = True Then

Dim b As String = "0"

strSQ = "UPDATE studentsrecords SET flag='0' WHERE date_in = #" & Format(Now, "MM/d/yyyy")
& "# and time_in IS NULL and time_out IS NULL and Flag IS Null"

Dim comm As OleDbCommand = New OleDbCommand(strSQ, myconnection)

comm.ExecuteNonQuery()

myconnection.Close()

Else

myconnection.Close()

End If

End Sub

Private Sub insertstd()

' Time-in and Time-out button

Dim datey As String = DateTime.Now.ToString("MM/d/yyyy")

Dim flag As Integer = 1

Dim strSQL As String

If Button2.Text = "&Time In" Then

dDR = dDS.Tables(0).NewRow()

ftime = DateTime.Now.ToString("hh:mm:ss tt")

txttimein.Text = ftime
insertd(txtid.Text, datey, txtname.Text, txtsurname.Text, ftime)

Label23.Text = "Signed-In"

ids = "Signed In"

strSQL = "UPDATE studentsrecords SET time_in=#" & txttimein.Text & "#, flag='" & flag & "' WHERE
tag_id='" & txtid.Text & "' AND date_in=#" & datey & "#"

Button2.Text = "&Time Out"

Dim SigninMsg As String = ""

Dim tag As String = "signin"

Try

Dim cmd As OleDbCommand = New OleDbCommand("SELECT timeset FROM controlsignout


WHERE flag='" & tag & "'", myconnection)

Dim dr As OleDbDataReader = cmd.ExecuteReader

Dim userfound As Boolean = False

While dr.Read

SigninMsg = dr("timeset")

End While

sValue = SigninMsg

Catch ex As Exception

MsgBox(ex.Message)

myconnection.Close()

End Try

If Panel25.Enabled = True Then


Try

Dim n As String = "1"

Dim cmd As OleDbCommand = New OleDbCommand("SELECT Guardiannumber1,


Guardiannumber2 FROM students WHERE Tag_ID='" & txtid.Text & "' And ReceiveSms='" & n & "'",
myconnection)

Dim dr As OleDbDataReader = cmd.ExecuteReader

Dim userfound As Boolean = False

While dr.Read

number = dr("Guardiannumber1")

number2 = dr("Guardiannumber2")

End While

Catch ex As Exception

MsgBox(ex.Message)

End Try

If number = Nothing Then

Else

If ChkEnableAll.Checked = True Then

numbers.Clear()

numbers.Add(number)

'numbers.Add(number2)
b_in = 1

'c += 1

Label3.Text = c

'Label4.Text = c

NumWorkers = NumWorkers + 1

ReDim Workers(NumWorkers)

Workers(NumWorkers) = New BackgroundWorker

Workers(NumWorkers).WorkerReportsProgress = True

Workers(NumWorkers).WorkerSupportsCancellation = True

AddHandler Workers(NumWorkers).DoWork, AddressOf WorkerDoWork

AddHandler Workers(NumWorkers).ProgressChanged, AddressOf WorkerProgressChanged

AddHandler Workers(NumWorkers).RunWorkerCompleted, AddressOf WorkerCompleted

Workers(NumWorkers).RunWorkerAsync()

'sendSmS(SigninMsg)

ElseIf chkSignin.Checked = True Then

numbers.Clear()

numbers.Add(number)

NumWorkers = NumWorkers + 1

ReDim Workers(NumWorkers)

Workers(NumWorkers) = New BackgroundWorker

Workers(NumWorkers).WorkerReportsProgress = True

Workers(NumWorkers).WorkerSupportsCancellation = True

AddHandler Workers(NumWorkers).DoWork, AddressOf WorkerDoWork

AddHandler Workers(NumWorkers).ProgressChanged, AddressOf WorkerProgressChanged


AddHandler Workers(NumWorkers).RunWorkerCompleted, AddressOf WorkerCompleted

Workers(NumWorkers).RunWorkerAsync()

'sendSmS(SigninMsg)

ElseIf chkDisableAuto.Checked = True Then

End If

End If

number = 0

End If

Else

ftime = DateTime.Now.ToString("hh:mm:ss tt")

txttimeout.Text = ftime

Label23.Text = "Signed-Out"

strSQL = "UPDATE studentsrecords SET time_out=#" & txttimeout.Text & "# WHERE tag_id='" &
txtid.Text & "' AND date_in=#" & datey & "# and time_in=#" & txttimein.Text & "#"

'Button2.Text = "&Time In"

Dim SigninMsg1 As String = ""

Dim tag As String = "signout"

Try

Dim cmd As OleDbCommand = New OleDbCommand("SELECT timeset FROM controlsignout


WHERE flag='" & tag & "'", myconnection)

Dim dr As OleDbDataReader = cmd.ExecuteReader

Dim userfound As Boolean = False


While dr.Read

SigninMsg1 = dr("timeset")

End While

sValue = SigninMsg1

Catch ex As Exception

MsgBox(ex.Message)

myconnection.Close()

End Try

If Panel25.Enabled = True Then

Try

Dim ny As String = "1"

Dim cmd As OleDbCommand = New OleDbCommand("SELECT Guardiannumber1,


Guardiannumber2 FROM students WHERE Tag_ID='" & txtid.Text & "' AND ReceiveSms='" & ny & "'",
myconnection)

Dim dr As OleDbDataReader = cmd.ExecuteReader

Dim userfound As Boolean = False

While dr.Read

number = dr("Guardiannumber1")

number2 = dr("Guardiannumber2")

End While

Catch ex As Exception

MsgBox(ex.Message)
End Try

If number = Nothing Then

Else

If ChkEnableAll.Checked = True Then

numbers.Clear()

numbers.Add(number)

b_in = 1

c += 1

Label3.Text = c

'Label4.Text = c

NumWorkers = NumWorkers + 1

ReDim Workers(NumWorkers)

Workers(NumWorkers) = New BackgroundWorker

Workers(NumWorkers).WorkerReportsProgress = True

Workers(NumWorkers).WorkerSupportsCancellation = True

AddHandler Workers(NumWorkers).DoWork, AddressOf WorkerDoWork

AddHandler Workers(NumWorkers).ProgressChanged, AddressOf WorkerProgressChanged

AddHandler Workers(NumWorkers).RunWorkerCompleted, AddressOf WorkerCompleted

Workers(NumWorkers).RunWorkerAsync()

'sendSmS(SigninMsg1)

ElseIf chkSignout.Checked = True Then

numbers.Clear()

numbers.Add(number)
NumWorkers = NumWorkers + 1

ReDim Workers(NumWorkers)

Workers(NumWorkers) = New BackgroundWorker

Workers(NumWorkers).WorkerReportsProgress = True

Workers(NumWorkers).WorkerSupportsCancellation = True

AddHandler Workers(NumWorkers).DoWork, AddressOf WorkerDoWork

AddHandler Workers(NumWorkers).ProgressChanged, AddressOf WorkerProgressChanged

AddHandler Workers(NumWorkers).RunWorkerCompleted, AddressOf WorkerCompleted

Workers(NumWorkers).RunWorkerAsync()

'sendSmS(SigninMsg1)

ElseIf chkDisableAuto.Checked = True Then

End If

End If

number = 0

End If

End If

Dim dCmd As OleDbCommand = New OleDbCommand(strSQL, myconnection)

dCmd.ExecuteNonQuery()

dCmd.Dispose()

dDR = Nothing

dDS.Dispose()
dDA.Dispose()

myconnection.Close()

Button2.Enabled = False

End Sub

#End Region

#Region "Staff Scan methods"

Private Sub check_info_staff()

'If Not myconnection Is Nothing Then

'' If myconnection.State = ConnectionState.Open Then

' Else

' myconnection.Open()

' End If

'Else

' provider = "provider = microsoft.ace.oledb.12.0; data source=studentattendancesystem.accdb;


Persist Security Info=False;"

' myconnection.ConnectionString = provider

'End If

'myconnection.Open()

eDA.SelectCommand = New OleDbCommand("SELECT firstname, lastname, count, staff_id FROM


staff WHERE tag_ID='" & txtid.Text & "'", myconnection)

eDS.Clear()

eDA.Fill(eDS)

If eDS.Tables(0).Rows.Count > 0 Then


eDR = eDS.Tables(0).Rows(0)

txtname.Text = eDR("Firstname")

txtsurname.Text = eDR("lastname")

TextBox25.Text = eDR("staff_id")

a = eDR("count")

Dim userfound As Boolean = False

userfound = True

If userfound = True Then

insertstaffimage()

End If

dDA.SelectCommand = New OleDbCommand("SELECT * FROM studentsrecords WHERE tag_id='"


& txtid.Text & "' AND date_in=#" & DateTime.Now.ToString("MM/d/yyyy") & "# AND flag='" & 1 & "' AND
time_out IS NULL", myconnection)

dDS.Clear()

dDA.Fill(dDS)

If dDS.Tables(0).Rows.Count > 0 Then

dDR = dDS.Tables(0).Rows(0)

Button2.Enabled = True

Button2.Text = "&Time Out"

txttimein.Text = dDR("time_in") ' Format(dDR("time_in"), "HH:mm:ss tt")

idd = txtid.Text

insertstaff() 'found

If RadioButton7.Checked = True Then

'InsertSmsData(txtid.Text, ids, b_in)


Else

End If

Else

dDA.SelectCommand = New OleDbCommand("SELECT * FROM studentsrecords WHERE


tag_id='" & txtid.Text & "' AND date_in=#" & DateTime.Now.ToString("MM/d/yyyy") & "# AND flag='" & 1
& "' AND time_out IS NOT NULL AND time_out IS NOT NULL", myconnection)

dDS.Clear()

dDA.Fill(dDS)

If dDS.Tables(0).Rows.Count > 0 Then

dDR = dDS.Tables(0).Rows(0)

Label23.Text = "Already Signed-In"

Else

Button2.Enabled = True

Button2.Text = "&Time In"

idd = txtid.Text

insertstaff()

If RadioButton7.Checked = True Then

'InsertSmsData(txtid.Text, ids, b_in)

Else

End If

makeStaffAbsent()
End If

End If

dDR = Nothing

dDS.Dispose()

dDA.Dispose()

cleartimer()

Else

cleartimer()

Button2.Enabled = False

End If

eDR = Nothing

eDS.Dispose()

eDA.Dispose()

myconnection.Close()

updateScanLog()

End Sub

Private Sub makeStaffAbsent()

Dim strSQL As String = ""

Dim strSQ As String

If Not myconnection Is Nothing Then

If myconnection.State = ConnectionState.Open Then

Else
myconnection.Open()

End If

Else

provider = "provider = microsoft.ace.oledb.12.0; data source=studentattendancesystem.accdb;


Persist Security Info=False;"

myconnection.ConnectionString = provider

End If

Dim cmd As OleDbCommand = New OleDbCommand("select date_in from [studentsrecords] where


date_in=#" & Format(Now, "MM/d/yyyy") & "# AND flag='1' AND (select top 1 date_in from
[studentsrecords] where date_in=#" & Format(Now, "MM/d/yyyy") & "# AND time_in IS NULL and
time_out IS NULL and Flag IS Null)", myconnection)

Dim dr As OleDbDataReader = cmd.ExecuteReader

Dim userfound As Boolean = False

While dr.Read

userfound = True

End While

If userfound = True Then

Dim b As String = "0"

strSQ = "UPDATE studentsrecords SET flag='0' WHERE date_in = #" & Format(Now, "MM/d/yyyy")
& "# and time_in IS NULL and time_out IS NULL and Flag IS Null"

Dim comm As OleDbCommand = New OleDbCommand(strSQ, myconnection)

comm.ExecuteNonQuery()
myconnection.Close()

Else

myconnection.Close()

End If

End Sub

Private Sub insertstaff()

Console.WriteLine("status 1st " & myconnection.State)

If Not myconnection Is Nothing Then

If myconnection.State = ConnectionState.Open Then

Else

myconnection.Open()

End If

Else

provider = "provider = microsoft.ace.oledb.12.0; data source=studentattendancesystem.accdb;


Persist Security Info=False;"

myconnection.ConnectionString = provider

End If

' Time-in and Time-out button

Dim datey As String = DateTime.Now.ToString("MM/d/yyyy")


Dim flag As Integer = 1

Dim strSQL As String

If Button2.Text = "&Time In" Then

dDR = dDS.Tables(0).NewRow()

ftime = DateTime.Now.ToString("hh:mm:ss tt")

txttimein.Text = ftime

insertd(txtid.Text, datey, txtname.Text, txtsurname.Text, ftime)

Label23.Text = "Signed-In"

ids = "Signed In"

strSQL = "UPDATE studentsrecords SET time_in=#" & txttimein.Text & "#, flag='" & flag & "' WHERE
tag_id='" & txtid.Text & "' AND date_in=#" & datey & "#"

Button2.Text = "&Time Out"

Dim SigninMsg As String = ""

Dim tag As String = "staff_signin"

Try

Dim cmd As OleDbCommand = New OleDbCommand("SELECT timeset FROM controlsignout


WHERE flag='" & tag & "'", myconnection)

Dim dr As OleDbDataReader = cmd.ExecuteReader

Dim userfound As Boolean = False

While dr.Read

SigninMsg = dr("timeset")

End While

sValue = SigninMsg

Catch ex As Exception
MsgBox(ex.Message)

myconnection.Close()

End Try

If Panel25.Enabled = True Then

Try

Dim n As String = "1"

Dim cmd As OleDbCommand = New OleDbCommand("SELECT contactnumber FROM staff


WHERE Tag_ID='" & txtid.Text & "' And ReceiveSms='" & n & "'", myconnection)

Dim dr As OleDbDataReader = cmd.ExecuteReader

Dim userfound As Boolean = False

While dr.Read

number = dr("contactnumber")

End While

Catch ex As Exception

MsgBox(ex.Message)

End Try

If number = Nothing Then

Else

If rbStaffEnableAll.Checked = True Then


numbers.Clear()

numbers.Add(number)

'numbers.Add(number2)

b_in = 1

'c += 1

Label3.Text = c

'Label4.Text = c

NumWorkers = NumWorkers + 1

ReDim Workers(NumWorkers)

Workers(NumWorkers) = New BackgroundWorker

Workers(NumWorkers).WorkerReportsProgress = True

Workers(NumWorkers).WorkerSupportsCancellation = True

AddHandler Workers(NumWorkers).DoWork, AddressOf WorkerDoWork

AddHandler Workers(NumWorkers).ProgressChanged, AddressOf WorkerProgressChanged

AddHandler Workers(NumWorkers).RunWorkerCompleted, AddressOf WorkerCompleted

Workers(NumWorkers).RunWorkerAsync()

'sendSmS(SigninMsg)

ElseIf rbStaffSignin.Checked = True Then

numbers.Clear()

numbers.Add(number)

NumWorkers = NumWorkers + 1

ReDim Workers(NumWorkers)

Workers(NumWorkers) = New BackgroundWorker

Workers(NumWorkers).WorkerReportsProgress = True
Workers(NumWorkers).WorkerSupportsCancellation = True

AddHandler Workers(NumWorkers).DoWork, AddressOf WorkerDoWork

AddHandler Workers(NumWorkers).ProgressChanged, AddressOf WorkerProgressChanged

AddHandler Workers(NumWorkers).RunWorkerCompleted, AddressOf WorkerCompleted

Workers(NumWorkers).RunWorkerAsync()

'sendSmS(SigninMsg)

ElseIf rbStaffDisableAuto.Checked = True Then

End If

End If

number = 0

End If

Else

ftime = DateTime.Now.ToString("hh:mm:ss tt")

txttimeout.Text = ftime

Label23.Text = "staff_signout"

strSQL = "UPDATE studentsrecords SET time_out=#" & txttimeout.Text & "# WHERE tag_id='" &
txtid.Text & "' AND date_in=#" & datey & "# and time_in=#" & txttimein.Text & "#"

'Button2.Text = "&Time In"

Dim SigninMsg1 As String = ""

Dim tag As String = "staff_signout"

Try

Dim cmd As OleDbCommand = New OleDbCommand("SELECT timeset FROM controlsignout


WHERE flag='" & tag & "'", myconnection)

Dim dr As OleDbDataReader = cmd.ExecuteReader


Dim userfound As Boolean = False

While dr.Read

SigninMsg1 = dr("timeset")

End While

sValue = SigninMsg1

Catch ex As Exception

MsgBox(ex.Message)

myconnection.Close()

End Try

If Panel25.Enabled = True Then

Try

Dim ny As String = "1"

Dim cmd As OleDbCommand = New OleDbCommand("SELECT contactnumber FROM staff


WHERE Tag_ID='" & txtid.Text & "' AND ReceiveSms='" & ny & "'", myconnection)

Dim dr As OleDbDataReader = cmd.ExecuteReader

Dim userfound As Boolean = False

While dr.Read

number = dr("contactnumber")

End While

Catch ex As Exception
MsgBox(ex.Message)

End Try

If number = Nothing Then

Else

If rbStaffEnableAll.Checked = True Then

numbers.Clear()

numbers.Add(number)

b_in = 1

c += 1

Label3.Text = c

'Label4.Text = c

NumWorkers = NumWorkers + 1

ReDim Workers(NumWorkers)

Workers(NumWorkers) = New BackgroundWorker

Workers(NumWorkers).WorkerReportsProgress = True

Workers(NumWorkers).WorkerSupportsCancellation = True

AddHandler Workers(NumWorkers).DoWork, AddressOf WorkerDoWork

AddHandler Workers(NumWorkers).ProgressChanged, AddressOf WorkerProgressChanged

AddHandler Workers(NumWorkers).RunWorkerCompleted, AddressOf WorkerCompleted

Workers(NumWorkers).RunWorkerAsync()

'sendSmS(SigninMsg1)

ElseIf rbStaffSignin.Checked = True Then


numbers.Clear()

numbers.Add(number)

NumWorkers = NumWorkers + 1

ReDim Workers(NumWorkers)

Workers(NumWorkers) = New BackgroundWorker

Workers(NumWorkers).WorkerReportsProgress = True

Workers(NumWorkers).WorkerSupportsCancellation = True

AddHandler Workers(NumWorkers).DoWork, AddressOf WorkerDoWork

AddHandler Workers(NumWorkers).ProgressChanged, AddressOf WorkerProgressChanged

AddHandler Workers(NumWorkers).RunWorkerCompleted, AddressOf WorkerCompleted

Workers(NumWorkers).RunWorkerAsync()

'sendSmS(SigninMsg1)

ElseIf rbStaffDisableAuto.Checked = True Then

End If

End If

number = 0

End If

End If

Dim dCmd As OleDbCommand = New OleDbCommand(strSQL, myconnection)

dCmd.ExecuteNonQuery()

dCmd.Dispose()
dDR = Nothing

dDS.Dispose()

dDA.Dispose()

myconnection.Close()

Button2.Enabled = False

End Sub

#End Region

Public Sub sendSmS(ByVal sValue As String)

Dim number As Long

Try

Dim cmd As OleDbCommand = New OleDbCommand("SELECT Guardiannumber1 FROM students


WHERE Tag_ID='" & txtid.Text & "'", myconnection)

Dim dr As OleDbDataReader = cmd.ExecuteReader

Dim userfound As Boolean = False

While dr.Read

number = dr("Guardiannumber1")

End While

Catch ex As Exception

MsgBox(ex.Message)

End Try

Try
If SerialPort1.IsOpen() = True Then

SerialPort1.Write("AT" & vbCrLf)

Thread.Sleep(1000)

SerialPort1.Write("AT+CMGF=1" & vbCrLf)

Thread.Sleep(1000)

SerialPort1.Write("AT+CMGS=" & Chr(34) & (number) & Chr(34) & vbCrLf)

Thread.Sleep(1000)

SerialPort1.Write(sValue & Chr(26))

Thread.Sleep(2000)

Else

'Example()

End If

number = 0

Catch ex As Exception

MsgBox(ex.Message)

End Try

End Sub

Private Async Sub WorkerDoWork(ByVal sender As Object, ByVal e As


System.ComponentModel.DoWorkEventArgs)

cnt = 0

If smsApi = True Then

If CheckForInternetConnection() = True Then

For Each num In numbers.ToList

'Console.WriteLine("number of items " & numbers.Count)

For b As Integer = 0 To 0
' Using HttpClient to send SMS

Using client As New HttpClient()

Dim url As String = "https://api.easysendsms.app/bulksms"

Dim payload As String = "username=sherngisoi7od2024&password=No8K2GpI&to=" &


num & "&from=test&text=" & sValue & "&type=0"

Dim content As New StringContent(payload, Encoding.UTF8, "application/x-www-form-


urlencoded")

Try

Dim response As HttpResponseMessage = Await client.PostAsync(url, content)

response.EnsureSuccessStatusCode()

Dim responseBody As String = Await response.Content.ReadAsStringAsync()

MessageBox.Show(responseBody, "SMS Response")

Catch ex As HttpRequestException

MessageBox.Show($"Request error: {ex.Message}", "Error")

cnt += 1

If cnt = 3 Then

cnt = 0

b=1

Else

b -= 1

End If

End Try

End Using

Next
'Console.WriteLine("inBuffer " & num & " number on " & sValue)

numbers.Remove(num)

Thread.Sleep(2000)

Next

dailyGraphs()

Else

Console.WriteLine("no internet connection")

For Each num In numbers.ToList

'InsertApiData(num, sValue, DateTime.Now.ToString("MM/d/yyyy"),


DateTime.Now.ToString("hh:mm:ss tt"))

numbers.Remove(num)

Thread.Sleep(2000)

Next

aTimer = New System.Timers.Timer(1000)

' Hook up the Elapsed event for the timer.

AddHandler aTimer.Elapsed, AddressOf OnTimedEvent

' Set the Interval to 1 seconds (1000 milliseconds).

aTimer.Interval = 10000

aTimer.Enabled = True

End If

ElseIf gsm = True Then

Else

End If
End Sub

Private Sub WorkerProgressChanged(ByVal sender As Object, ByVal e As


System.ComponentModel.ProgressChangedEventArgs)

' I did something!

End Sub

Private Sub WorkerCompleted(ByVal sender As Object, ByVal e As


System.ComponentModel.RunWorkerCompletedEventArgs)

' I'm done!

c=0

End Sub

Private Sub OnTimedEvent(ByVal source As Object, ByVal e As ElapsedEventArgs)

'Console.WriteLine("The Elapsed event was raised at {0}", e.SignalTime)

If CheckForInternetConnection() = True Then

selectfailedsmsData()

aTimer.Stop()

End If

End Sub

Private Sub OnTimedEventNotSend(ByVal source As Object, ByVal e As ElapsedEventArgs)

cnt1 += 1

'Console.WriteLine("The Elapsed event was raised at {0}", e.SignalTime)


Console.WriteLine("number iz " & cnt1)

If cnt1 = 2 Then

bTimer.Stop()

Else

selectfailedsmsData()

End If

End Sub

Public Shared Function CheckForInternetConnection() As Boolean

Try

Using client = New WebClient()

Using stream = client.OpenRead("http://www.google.com")

Return True

End Using

End Using

Catch

Return False

End Try

End Function

Public Async Function CheckForInternetConnectionLoop() As Task(Of Boolean)

Dim finished As Boolean = False

While finished = False

Await Task.CompletedTask

Try

Using client = New WebClient()


Using stream = client.OpenRead("http://www.google.com")

finished = True

End Using

End Using

Catch ex As Exception

finished = False

End Try

Thread.Sleep(20000)

End While

Return finished

End Function

Private Sub Button7_Click_1(sender As Object, e As EventArgs)

numbers.Clear()

For a As Integer = 1 To 4

numbers.Add(a)

Next

NumWorkers = NumWorkers + 1

ReDim Workers(NumWorkers)

Workers(NumWorkers) = New BackgroundWorker

Workers(NumWorkers).WorkerReportsProgress = True

Workers(NumWorkers).WorkerSupportsCancellation = True

AddHandler Workers(NumWorkers).DoWork, AddressOf WorkerDoWork


AddHandler Workers(NumWorkers).ProgressChanged, AddressOf WorkerProgressChanged

AddHandler Workers(NumWorkers).RunWorkerCompleted, AddressOf WorkerCompleted

Workers(NumWorkers).RunWorkerAsync()

End Sub

Private Sub Button8_Click(sender As Object, e As EventArgs)

For a As Integer = 1 To 4

For Each nn In numbers.ToList

Console.WriteLine("check buff " & nn)

Next

Next

End Sub

Public Sub sendtobuffer(ByVal num As String, ByVal sms As String, ByVal id As Integer)

Console.WriteLine(num & " " & sms)

numbers.Add(num)

sValue = sms

'NumWorkers = NumWorkers + 1

'ReDim Workers(NumWorkers)

'Workers(NumWorkers) = New BackgroundWorker

'Workers(NumWorkers).WorkerReportsProgress = True

'Workers(NumWorkers).WorkerSupportsCancellation = True

'AddHandler Workers(NumWorkers).DoWork, AddressOf WorkerDoWork


'AddHandler Workers(NumWorkers).ProgressChanged, AddressOf WorkerProgressChanged

'AddHandler Workers(NumWorkers).RunWorkerCompleted, AddressOf WorkerCompleted

'Workers(NumWorkers).RunWorkerAsync()

'deleteSmsForFailed(id)

End Sub

Public Sub selectfailedsmsData()

Try

myconnection.Open()

Dim cmd1 As OleDbCommand = New OleDbCommand("SELECT * FROM tempsms",


myconnection)

Dim dr1 As OleDbDataReader = cmd1.ExecuteReader

Dim userfound1 As Boolean = False

While dr1.Read

numbers.Add(dr1.GetString(1))

sValue = dr1.GetString(2)

deleteSmsForFailed(dr1.GetInt32(0))

End While

NumWorkers = NumWorkers + 1

ReDim Workers(NumWorkers)

Workers(NumWorkers) = New BackgroundWorker

Workers(NumWorkers).WorkerReportsProgress = True

Workers(NumWorkers).WorkerSupportsCancellation = True

AddHandler Workers(NumWorkers).DoWork, AddressOf WorkerDoWork

AddHandler Workers(NumWorkers).ProgressChanged, AddressOf WorkerProgressChanged


AddHandler Workers(NumWorkers).RunWorkerCompleted, AddressOf WorkerCompleted

Workers(NumWorkers).RunWorkerAsync()

myconnection.Close()

cmd1.Dispose()

Catch ex As Exception

myconnection.Close()

End Try

End Sub

Private Sub SetLabel(ByVal [text] As String)

' InvokeRequired required compares the thread ID of the'

' calling thread to the thread ID of the creating thread.'

' If these threads are different, it returns true.'

If Me.Label5.InvokeRequired Then

Dim d As New SetTextCallback(AddressOf SetLabel)

Me.Invoke(d, New Object() {[text]})

Else

Me.Label5.Text = [text]

sstd = [text]

End If

End Sub

Private Sub SetBufferOut(ByVal [text] As String)

' InvokeRequired required compares the thread ID of the'


' calling thread to the thread ID of the creating thread.'

' If these threads are different, it returns true.'

If Me.Label10.InvokeRequired Then

Dim d As New SetTextCallback(AddressOf SetBufferOut)

Me.Invoke(d, New Object() {[text]})

Else

Me.Label10.Text = [text]

b_out = [text]

End If

End Sub

Private Sub insertimage()

Dim cnn As New OleDb.OleDbConnection

cnn = New OleDb.OleDbConnection

cnn.ConnectionString = "provider = microsoft.ace.oledb.12.0; data


source=studentattendancesystem.accdb; Persist Security Info=False;"

If cnn.State = ConnectionState.Open Then

cnn.Open()

End If

Dim da As New OleDb.OleDbDataAdapter("SELECT * FROM students WHERE count = " & a, cnn)

Dim dt As New DataTable

da.Fill(dt)

Me.TextBoxPictureFilePath.Text = dt.Rows(0).Item("PicturePath")

Try

BunifuPictureBox3.Image = System.Drawing.Bitmap.FromFile(TextBoxPictureFilePath.Text)
cnn.Close()

Catch ex As Exception

picMessage(ex.Message)

cnn.Close()

myconnection.Close()

End Try

End Sub

Private Sub insertstaffimage()

Dim cnn As New OleDb.OleDbConnection

cnn = New OleDb.OleDbConnection

cnn.ConnectionString = "provider = microsoft.ace.oledb.12.0; data


source=studentattendancesystem.accdb; Persist Security Info=False;"

If cnn.State = ConnectionState.Open Then

cnn.Open()

End If

Dim da As New OleDb.OleDbDataAdapter("SELECT * FROM staff WHERE count = " & a, cnn)

Dim dt As New DataTable

da.Fill(dt)

Me.TextBoxPictureFilePath.Text = dt.Rows(0).Item("PicturePath")

Try

BunifuPictureBox3.Image = System.Drawing.Bitmap.FromFile(TextBoxPictureFilePath.Text)

cnn.Close()

Catch ex As Exception
picMessage(ex.Message)

cnn.Close()

myconnection.Close()

End Try

End Sub

'Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

' ' Time-in and Time-out button

' Dim flag As Integer = 1

' Dim strSQL As String

' myconnection.Open()

' If Button2.Text = "&Time In" Then

' dDR = dDS.Tables(0).NewRow()

' txttimein.Text = Format(Now, "h:mm:ss tt")

' strSQL = "UPDATE studentsrecords SET time_in=#" & txttimein.Text & "#, flag='" & flag & "'
WHERE id='" & txtid.Text & "' AND date_in=#" & Format(Now, "MM/d/yyyy") & "# "

' Button2.Text = "&Time Out"

' Else

' txttimeout.Text = Format(Now, "h:mm:ss tt")

' strSQL = "UPDATE studentsrecords SET time_out=#" & txttimeout.Text & "# WHERE id='" &
txtid.Text & "' AND date_in=#" & Format(Now, "MM/d/yyyy") & "# and time_in=#" & txttimein.Text & "#"

' Button2.Text = "&Time In"

' End If

' Dim dCmd As OleDbCommand = New OleDbCommand(strSQL, myconnection)


' dCmd.ExecuteNonQuery()

' dCmd.Dispose()

' dDR = Nothing

' dDS.Dispose()

' dDA.Dispose()

' myconnection.Close()

' Button2.Enabled = False

'End Sub

'Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles txtid.TextChanged

' check_info()

'End Sub

Public Sub checkWeekends()

If Now.DayOfWeek = DayOfWeek.Saturday Or Now.DayOfWeek = DayOfWeek.Sunday Or Not


Now.Date.ToShortDateString >= StartTerm And Now.Date.ToShortDateString <= EndTerm Then

txtid.Enabled = False

Button29.Enabled = False

End If

End Sub

Private Sub filldb()

Dim cnt As Integer

Dim nam = "excludedDays"


Try

myconnection.Open()

Dim cmd As OleDbCommand = New OleDbCommand("SELECT timeset FROM controlsignout


WHERE flag='" & nam & "'", myconnection)

Dim dr As OleDbDataReader = cmd.ExecuteReader

While dr.Read

Dim str As String() = dr("timeset").ToString.Split(",")

For j As Integer = 0 To str.Length - 1

If Now.Date.ToShortDateString = str(j).ToString() Then

cnt += 1

End If

Next

End While

myconnection.Close()

Catch ex As Exception

MsgBox(ex.Message)

myconnection.Close()

End Try

If cnt > 0 Then


Else

If Now.DayOfWeek = DayOfWeek.Saturday Or Now.DayOfWeek = DayOfWeek.Sunday Or Not


Now.Date.ToShortDateString >= StartTerm And Now.Date.ToShortDateString <= EndTerm Then

Else

Dim strSQL As String = ""

Dim strSQ As String

Dim strSQLStaff As String = ""

myconnection.Open()

Dim cmd As OleDbCommand = New OleDbCommand(" select date_in from [studentsrecords]


where date_in=#" & Format(Now, "MM/d/yyyy") & "#", myconnection)

Dim dr As OleDbDataReader = cmd.ExecuteReader

Dim userfound As Boolean = False

While dr.Read

userfound = True

' = dr("fulname").ToString

' Form2.Label8.Text = dr("lastname").ToString

End While

If userfound = True Then

'strSQL = "INSERT INTO studentsrecords ([id],[firstname],[lastname],[parentnumber]) SELECT


[id], [firstname],[lastname],[Guardiannumber1] FROM students"
Dim customerOrders = "INSERT INTO studentsrecords ([Tag_ID],[id],[Firstname],[lastname],
[Department],[Class],[ReceiveSms],[userType],[status]) SELECT [Tag_ID],[id],[Firstname],[lastname],
[Department],[Class],[ReceiveSms],[userType],[status] FROM [students] WHERE [students.tag_id] NOT IN
(SELECT [studentsrecords.tag_id] FROM [studentsrecords])"

Dim stafforder = "INSERT INTO studentsrecords ([Tag_ID],[id],[Firstname],[lastname],


[Department],[Class],[ReceiveSms],[userType],[status]) SELECT [Tag_ID],[staff_id],[Firstname],[lastname],
[Department],'None',[ReceiveSms],[userType],[status] FROM [staff] WHERE [staff.tag_id] NOT IN (SELECT
[studentsrecords.tag_id] FROM [studentsrecords])"

strSQ = "UPDATE studentsrecords SET date_in=#" & Format(Now, "MM/d/yyyy") & "# WHERE
date_in IS NULL and time_in IS NULL and time_out IS NULL and Flag IS Null and tag_id IS NOT NULL"

'Dim sql1 As String

'sql1 = "SELECT [id],[firstname],[lastname],[Guardiannumber1] FROM [students] WHERE


[students.id] NOT IN (SELECT [studentsrecords.id] FROM [studentsrecords])"

'Dim adapter1 As New OleDbDataAdapter(sql1, myconnection)

'Dim cmd1 As New OleDbCommand(sql1, myconnection)

'Dim dt1 As New DataTable("users")

'adapter1.Fill(dt1)

'DataGridView1.DataSource = dt1

command = New OleDbCommand(customerOrders, myconnection)

command2 = New OleDbCommand(stafforder, myconnection)

Dim commUpdate As OleDbCommand = New OleDbCommand(strSQ, myconnection)

command.ExecuteNonQuery()

command2.ExecuteNonQuery()

commUpdate.ExecuteNonQuery()

myconnection.Close()
Else

strSQL = "INSERT INTO studentsrecords ([Tag_ID],[id],[Firstname],[lastname],[Department],


[Class],[ReceiveSms],[userType],[status]) SELECT [Tag_ID],[ID],[Firstname],[lastname],[Department],
[class],[ReceiveSms],[userType],[status] FROM students "

strSQLStaff = "INSERT INTO studentsrecords ([Tag_ID],[id],[Firstname],[lastname],


[Department],[Class],[ReceiveSms],[userType],[status]) SELECT [Tag_ID],[Staff_ID],[Firstname],
[lastname],[Department], 'None',[ReceiveSms],[userType],[status] FROM staff "

strSQ = "UPDATE studentsrecords SET date_in=#" & Format(Now, "MM/d/yyyy") & "# WHERE
date_in IS NULL and time_in IS NULL and time_out IS NULL and Flag IS Null and tag_id IS NOT NULL"

'strSQStaff = "UPDATE studentsrecords SET date_in=#" & Format(Now, "MM/d/yyyy") & "#
WHERE date_in IS NULL and time_in IS NULL and time_out IS NULL and Flag IS Null and tag_id IS NOT
NULL"

command = New OleDbCommand(strSQL, myconnection)

Dim com As OleDbCommand = New OleDbCommand(strSQLStaff, myconnection)

Dim comm As OleDbCommand = New OleDbCommand(strSQ, myconnection)

command.ExecuteNonQuery()

com.ExecuteNonQuery()

comm.ExecuteNonQuery()

myconnection.Close()
End If

End If

End If

End Sub

' Private Sub btnlogout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


btnlogout.Click

'Me.Close()

' End Sub

Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


Timer2.Tick

If timeLeft > 0 Then

timeLeft -= 1

'Label16.Text = timeLeft & " seconds"

Else

Timer2.[Stop]()

txtid.Clear()

txtid.ReadOnly = False

txtname.Clear()

txtsurname.Clear()
txtname.Clear()

TextBox25.Clear()

txttimein.Clear()

txttimeout.Clear()

BunifuPictureBox3.ImageLocation = My.Application.Info.DirectoryPath & "\images\


emptyimage.png"

TextBoxPictureFilePath.Clear()

txtid.Focus()

'Label12.Text = ""

'Label16.Text = ""

Label23.Text = "..."

End If

End Sub

Public Sub cleartimer()

' Start the timer.

timeLeft = 3

Label12.Text = "3 seconds"

Timer2.Start()

End Sub

Private Sub insertimagelogo()

Dim cnn As New OleDb.OleDbConnection

cnn = New OleDb.OleDbConnection


Dim pic As String = "logopic"

Dim picview As String

cnn.ConnectionString = "provider = microsoft.ace.oledb.12.0; data


source=studentattendancesystem.accdb; Persist Security Info=False;"

If cnn.State = ConnectionState.Open Then

cnn.Open()

End If

Dim da As New OleDb.OleDbDataAdapter("SELECT * FROM controlsignout WHERE flag='" & pic &
"'", cnn)

Dim dt As New DataTable

da.Fill(dt)

picview = dt.Rows(0).Item("timeset")

Try

PictureBox1.Image = System.Drawing.Bitmap.FromFile(picview)

cnn.Close()

Catch ex As Exception

cnn.Close()

End Try

End Sub

Private Sub BunifuDatePicker2_CloseUp(ByVal sender As Object, ByVal e As System.EventArgs)

If (BunifuDatePicker2.Value.DayOfWeek = DayOfWeek.Saturday) Or
(BunifuDatePicker2.Value.DayOfWeek = DayOfWeek.Sunday) Then

'
'Now just add the right amount of days to make it
Monday...........................................................................................................................................................
........................................................................................................................................................................
........................................................................................................................................................................
.......................................................................................00.02222222222222222222222222222222222222
22222222222222222222222222222222222222222222221111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111.5

'

Select Case BunifuDatePicker2.Value.DayOfWeek

Case DayOfWeek.Saturday

BunifuDatePicker2.Value = BunifuDatePicker2.Value.AddDays(2)

Case DayOfWeek.Sunday

BunifuDatePicker2.Value = BunifuDatePicker2.Value.AddDays(1)

End Select

MsgBox("You can not select a Saturday or Sunday. The following Monday, " &

DateTimePicker1.Value.ToShortDateString & ", has been selected.",

MsgBoxStyle.OkOnly, "Invalid selection")


End If

End Sub

Private Sub BunifuDatePicker3_CloseUp(ByVal sender As Object, ByVal e As System.EventArgs)

If (BunifuDatePicker3.Value.DayOfWeek = DayOfWeek.Saturday) Or
(BunifuDatePicker3.Value.DayOfWeek = DayOfWeek.Sunday) Then

'

'Now just add the right amount of days to make it Monday

'

Select Case BunifuDatePicker3.Value.DayOfWeek

Case DayOfWeek.Saturday

BunifuDatePicker3.Value = BunifuDatePicker3.Value.AddDays(2)

Case DayOfWeek.Sunday

BunifuDatePicker3.Value = BunifuDatePicker3.Value.AddDays(1)

End Select

MsgBox("You can not select a Saturday or Sunday. The following Monday, " &

BunifuDatePicker3.Value.ToShortDateString & ", has been selected.",

MsgBoxStyle.OkOnly, "Invalid selection")

End If

End Sub

Private Sub BunifuButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


BunifuButton2.Click

Dim str As String


Dim strArr() As String

str = BunifuDatePicker2.Value

strArr = str.Split(" ")

FirstDate = strArr(0)

Dim str1 As String

Dim strArr1() As String

str1 = BunifuDatePicker3.Value

strArr1 = str1.Split(" ")

secondDate = strArr1(0)

If secondDate >= FirstDate Then

'ElseIf rdAbsent.Checked = False And rdLate.Checked = False And rdNotSigned.Checked = False


And rdAll.Checked = False And rdEarly.Checked = False Then

' MsgBox("Please select a Report Type.")

'ElseIf rdIdRpt.Checked = False And rdDpt.Checked = False And rdClass.Checked = False And
RadioButton2.Checked = False Then

' MsgBox("Please select a Department")

Dim report As New CrystalReport1

Try

If rdEarly.Checked = True Then

If rdClass.Checked = True Then

If ComboBox8.SelectedIndex >= 0 Then

Dim sql As String

sql = "SELECT * FROM studentsrecords INNER JOIN controls ON studentsrecords.time_in


<= controls.late_time WHERE studentsrecords.date_in between #" & FirstDate & "# AND #" &
secondDate & "# AND status='" & status & "' AND userType='" & ddAttendanceType.SelectedItem & "'
AND class='" & cls & "' order by date_in DESC"

Dim adapter As New OleDbDataAdapter(sql, myconnection)

Dim dt As New DataTable("students")

adapter.Fill(dt)

Dim dsd As New DataSet

Dim rpt As New CrystalReport1

rpt.SetDataSource(dt)

rpt.SetParameterValue("startDate", BunifuDatePicker2.Text)

rpt.SetParameterValue("endDate", BunifuDatePicker3.Text)

rpt.SetParameterValue("option", rptoption)

rpt.SetParameterValue(3, BunifuTextBox11.Text)

rpt.SetParameterValue(4, BunifuTextBox10.Text)

CrystalReportViewer1.ReportSource = rpt

Else

MsgBox("Please select a specific Class from the dropdown box.")

End If

ElseIf rdIdRpt.Checked = True Then

If TextBox21.Text IsNot "" Then

Dim sql As String

sql = "SELECT * FROM studentsrecords INNER JOIN controls ON studentsrecords.time_in


<= controls.late_time WHERE studentsrecords.date_in between #" & FirstDate & "# AND #" &
secondDate & "# AND status='" & status & "' AND userType='" & ddAttendanceType.SelectedItem & "'
AND studentsrecords.id LIKE '" & TextBox21.Text & "' order by date_in DESC"

Dim adapter As New OleDbDataAdapter(sql, myconnection)

Dim dt As New DataTable("students")


adapter.Fill(dt)

If dt.Rows.Count = 0 Then

MsgBox("Student ID not found. Please try again.")

Else

Dim dsd As New DataSet

Dim rpt As New CrystalReport1

rpt.SetDataSource(dt)

rpt.SetParameterValue("startDate", BunifuDatePicker2.Text)

rpt.SetParameterValue("endDate", BunifuDatePicker3.Text)

rpt.SetParameterValue("option", rptoption)

rpt.SetParameterValue(3, BunifuTextBox11.Text)

rpt.SetParameterValue(4, BunifuTextBox10.Text)

CrystalReportViewer1.ReportSource = rpt

End If

Else

MsgBox("Please enter a specific Student ID.")

End If

ElseIf rdDpt.Checked = True Then

If ComboBox9.SelectedIndex >= 0 Then

Dim sql As String

sql = "SELECT * FROM studentsrecords INNER JOIN controls ON studentsrecords.time_in


<= controls.late_time WHERE studentsrecords.date_in between #" & FirstDate & "# AND #" &
secondDate & "# AND status='" & status & "' AND userType='" & ddAttendanceType.SelectedItem & "'
AND department='" & drpt & "' order by date_in DESC"

Dim adapter As New OleDbDataAdapter(sql, myconnection)

Dim dt As New DataTable("students")

adapter.Fill(dt)
Dim dsd As New DataSet

Dim rpt As New CrystalReport1

rpt.SetDataSource(dt)

rpt.SetParameterValue("startDate", BunifuDatePicker2.Text)

rpt.SetParameterValue("endDate", BunifuDatePicker3.Text)

rpt.SetParameterValue("option", rptoption)

rpt.SetParameterValue(3, BunifuTextBox11.Text)

rpt.SetParameterValue(4, BunifuTextBox10.Text)

CrystalReportViewer1.ReportSource = rpt

Else

MsgBox("Please select a specific Level from the dropdown box.")

End If

Else

Dim sql As String

sql = "SELECT * FROM studentsrecords INNER JOIN controls ON studentsrecords.time_in <=


controls.late_time WHERE studentsrecords.date_in between #" & FirstDate & "# AND #" & secondDate &
"# AND status='" & status & "' AND userType='" & ddAttendanceType.SelectedItem & "' order by date_in
DESC"

Dim adapter As New OleDbDataAdapter(sql, myconnection)

Dim dt As New DataTable("students")

adapter.Fill(dt)

Dim dsd As New DataSet

Dim rpt As New CrystalReport1

rpt.SetDataSource(dt)

rpt.SetParameterValue("startDate", BunifuDatePicker2.Text)

rpt.SetParameterValue("endDate", BunifuDatePicker3.Text)

rpt.SetParameterValue("option", rptoption)
rpt.SetParameterValue(3, BunifuTextBox11.Text)

rpt.SetParameterValue(4, BunifuTextBox10.Text)

CrystalReportViewer1.ReportSource = rpt

End If

ElseIf rdLate.Checked = True Then

If rdClass.Checked = True Then

If ComboBox8.SelectedIndex >= 0 Then

Dim sql As String

sql = "SELECT * FROM studentsrecords INNER JOIN controls ON studentsrecords.time_in


>= controls.late_time WHERE studentsrecords.date_in between #" & FirstDate & "# AND #" &
secondDate & "# AND status='" & status & "' AND userType='" & ddAttendanceType.SelectedItem & "'
AND class='" & cls & "' order by date_in DESC"

Dim adapter As New OleDbDataAdapter(sql, myconnection)

Dim dt As New DataTable("students")

adapter.Fill(dt)

Dim dsd As New DataSet

Dim rpt As New CrystalReport1

rpt.SetDataSource(dt)

rpt.SetParameterValue("startDate", BunifuDatePicker2.Text)

rpt.SetParameterValue("endDate", BunifuDatePicker3.Text)

rpt.SetParameterValue("option", rptoption)

rpt.SetParameterValue(3, BunifuTextBox11.Text)

rpt.SetParameterValue(4, BunifuTextBox10.Text)

CrystalReportViewer1.ReportSource = rpt

Else

MsgBox("Please select a specific Class from the dropdown box.")

End If
ElseIf rdIdRpt.Checked = True Then

If TextBox21.Text IsNot "" Then

Dim sql As String

sql = "SELECT * FROM studentsrecords INNER JOIN controls ON studentsrecords.time_in


>= controls.late_time WHERE studentsrecords.date_in between #" & FirstDate & "# AND #" &
secondDate & "# AND status='" & status & "' AND userType='" & ddAttendanceType.SelectedItem & "'
AND id LIKE '" & TextBox21.Text & "' order by date_in DESC"

Dim adapter As New OleDbDataAdapter(sql, myconnection)

Dim dt As New DataTable("students")

adapter.Fill(dt)

If dt.Rows.Count = 0 Then

MsgBox("Student ID not found. Please try again.")

Else

Dim dsd As New DataSet

Dim rpt As New CrystalReport1

rpt.SetDataSource(dt)

rpt.SetParameterValue("startDate", BunifuDatePicker2.Text)

rpt.SetParameterValue("endDate", BunifuDatePicker3.Text)

rpt.SetParameterValue("option", rptoption)

rpt.SetParameterValue(3, BunifuTextBox11.Text)

rpt.SetParameterValue(4, BunifuTextBox10.Text)

CrystalReportViewer1.ReportSource = rpt

End If

Else

MsgBox("Please enter a specific Student ID.")

End If

ElseIf rdDpt.Checked = True Then


If ComboBox9.SelectedIndex >= 0 Then

Dim sql As String

sql = "SELECT * FROM studentsrecords INNER JOIN controls ON studentsrecords.time_in


>= controls.late_time WHERE studentsrecords.date_in between #" & FirstDate & "# AND #" &
secondDate & "# AND status='" & status & "' AND userType='" & ddAttendanceType.SelectedItem & "'
AND department='" & drpt & "' order by date_in DESC"

Dim adapter As New OleDbDataAdapter(sql, myconnection)

Dim dt As New DataTable("students")

adapter.Fill(dt)

Dim dsd As New DataSet

Dim rpt As New CrystalReport1

rpt.SetDataSource(dt)

rpt.SetParameterValue("startDate", BunifuDatePicker2.Text)

rpt.SetParameterValue("endDate", BunifuDatePicker3.Text)

rpt.SetParameterValue("option", rptoption)

rpt.SetParameterValue(3, BunifuTextBox11.Text)

rpt.SetParameterValue(4, BunifuTextBox10.Text)

CrystalReportViewer1.ReportSource = rpt

Else

MsgBox("Please select a specific Level from the dropdown box.")

End If

Else

Dim sql As String

sql = "SELECT * FROM studentsrecords INNER JOIN controls ON studentsrecords.time_in >=


controls.late_time WHERE studentsrecords.date_in between #" & FirstDate & "# AND #" & secondDate &
"# AND status='" & status & "' AND userType='" & ddAttendanceType.SelectedItem & "' order by date_in
DESC"

Dim adapter As New OleDbDataAdapter(sql, myconnection)


Dim dt As New DataTable("students")

adapter.Fill(dt)

Dim dsd As New DataSet

Dim rpt As New CrystalReport1

rpt.SetDataSource(dt)

rpt.SetParameterValue("startDate", BunifuDatePicker2.Text)

rpt.SetParameterValue("endDate", BunifuDatePicker3.Text)

rpt.SetParameterValue("option", rptoption)

rpt.SetParameterValue(3, BunifuTextBox11.Text)

rpt.SetParameterValue(4, BunifuTextBox10.Text)

CrystalReportViewer1.ReportSource = rpt

End If

ElseIf rdAbsent.Checked = True Then

If rdClass.Checked = True Then

If ComboBox8.SelectedIndex >= 0 Then

Dim sql As String

sql = " SELECT * FROM studentsrecords WHERE flag='0' AND studentsrecords.date_in


between #" & FirstDate & "# AND #" & secondDate & "# AND status='" & status & "' AND userType='" &
ddAttendanceType.SelectedItem & "' AND class='" & cls & "' order by date_in DESC"

Dim adapter As New OleDbDataAdapter(sql, myconnection)

Dim dt As New DataTable("students")

adapter.Fill(dt)

Dim dsd As New DataSet

Dim rpt As New CrystalReport1

rpt.SetDataSource(dt)
rpt.SetParameterValue("startDate", BunifuDatePicker2.Text)

rpt.SetParameterValue("endDate", BunifuDatePicker3.Text)

rpt.SetParameterValue("option", rptoption)

rpt.SetParameterValue(3, BunifuTextBox11.Text)

rpt.SetParameterValue(4, BunifuTextBox10.Text)

CrystalReportViewer1.ReportSource = rpt

Else

MsgBox("Please select a specific Class from the dropdown box.")

End If

ElseIf rdIdRpt.Checked = True Then

If TextBox21.Text IsNot "" Then

Dim sql As String

sql = " SELECT * FROM studentsrecords WHERE flag='0' AND studentsrecords.date_in


between #" & FirstDate & "# AND #" & secondDate & "# AND status='" & status & "' AND userType='" &
ddAttendanceType.SelectedItem & "' AND id LIKE & TextBox21.Text & " ' order by date_in DESC"

Dim adapter As New OleDbDataAdapter(sql, myconnection)

Dim dt As New DataTable("students")

adapter.Fill(dt)

If dt.Rows.Count = 0 Then

MsgBox("Student ID not found. Please try again.")

Else

Dim dsd As New DataSet

Dim rpt As New CrystalReport1

rpt.SetDataSource(dt)

rpt.SetParameterValue("startDate", BunifuDatePicker2.Text)

rpt.SetParameterValue("endDate", BunifuDatePicker3.Text)
rpt.SetParameterValue("option", rptoption)

rpt.SetParameterValue(3, BunifuTextBox11.Text)

rpt.SetParameterValue(4, BunifuTextBox10.Text)

CrystalReportViewer1.ReportSource = rpt

End If

Else

MsgBox("Please enter a specific Student ID.")

End If

ElseIf rdDpt.Checked = True Then

If ComboBox9.SelectedIndex >= 0 Then

Dim sql As String

sql = " SELECT * FROM studentsrecords WHERE flag='0' AND studentsrecords.date_in


between #" & FirstDate & "# AND #" & secondDate & "# AND status='" & status & "' AND userType='" &
ddAttendanceType.SelectedItem & "' AND department='" & drpt & "' order by date_in DESC"

Dim adapter As New OleDbDataAdapter(sql, myconnection)

Dim dt As New DataTable("students")

adapter.Fill(dt)

Dim dsd As New DataSet

Dim rpt As New CrystalReport1

rpt.SetDataSource(dt)

rpt.SetParameterValue("startDate", BunifuDatePicker2.Text)

rpt.SetParameterValue("endDate", BunifuDatePicker3.Text)

rpt.SetParameterValue("option", rptoption)

rpt.SetParameterValue(3, BunifuTextBox11.Text)

rpt.SetParameterValue(4, BunifuTextBox10.Text)

CrystalReportViewer1.ReportSource = rpt
Else

MsgBox("Please select a specific Level from the dropdown box.")

End If

Else

Dim sql As String

sql = " SELECT * FROM studentsrecords WHERE flag='0' AND studentsrecords.date_in


between #" & FirstDate & "# AND #" & secondDate & "# AND status='" & status & "' AND userType='" &
ddAttendanceType.SelectedItem & "' order by date_in DESC"

Dim adapter As New OleDbDataAdapter(sql, myconnection)

Dim dt As New DataTable("students")

adapter.Fill(dt)

Dim dsd As New DataSet

Dim rpt As New CrystalReport1

rpt.SetDataSource(dt)

rpt.SetParameterValue("startDate", BunifuDatePicker2.Text)

rpt.SetParameterValue("endDate", BunifuDatePicker3.Text)

rpt.SetParameterValue("option", rptoption)

rpt.SetParameterValue(3, BunifuTextBox11.Text)

rpt.SetParameterValue(4, BunifuTextBox10.Text)

CrystalReportViewer1.ReportSource = rpt

End If

ElseIf rdNotSigned.Checked = True Then

If rdClass.Checked = True Then

If ComboBox8.SelectedIndex >= 0 Then

Dim sql As String

sql = "SELECT * FROM notsignout WHERE notsignout.date_in between #" & FirstDate &
"# AND #" & secondDate & "# AND status='" & status & "' AND userType='" &
ddAttendanceType.SelectedItem & "' AND class='" & cls & "' order by date_in DESC"

Dim adapter As New OleDbDataAdapter(sql, myconnection)

Dim dt As New DataTable("students")

adapter.Fill(dt)

Dim dsd As New DataSet

Dim rpt As New CrystalReport1

rpt.SetDataSource(dt)

rpt.SetParameterValue("startDate", BunifuDatePicker2.Text)

rpt.SetParameterValue("endDate", BunifuDatePicker3.Text)

rpt.SetParameterValue("option", rptoption)

rpt.SetParameterValue(3, BunifuTextBox11.Text)

rpt.SetParameterValue(4, BunifuTextBox10.Text)

CrystalReportViewer1.ReportSource = rpt

Else

MsgBox("Please select a specific Class from the dropdown box.")

End If

ElseIf rdIdRpt.Checked = True Then

If TextBox21.Text IsNot "" Then

Dim sql As String

sql = "SELECT * FROM notsignout WHERE notsignout.date_in between #" & FirstDate &
"# AND #" & secondDate & "# AND status='" & status & "' AND userType='" &
ddAttendanceType.SelectedItem & "' AND id LIKE & TextBox21.Text & " ' order by date_in DESC"

Dim adapter As New OleDbDataAdapter(sql, myconnection)

Dim dt As New DataTable("students")

adapter.Fill(dt)

If dt.Rows.Count = 0 Then
MsgBox("Student ID not found. Please try again.")

Else

Dim dsd As New DataSet

Dim rpt As New CrystalReport1

rpt.SetDataSource(dt)

rpt.SetParameterValue("startDate", BunifuDatePicker2.Text)

rpt.SetParameterValue("endDate", BunifuDatePicker3.Text)

rpt.SetParameterValue("option", rptoption)

rpt.SetParameterValue(3, BunifuTextBox11.Text)

rpt.SetParameterValue(4, BunifuTextBox10.Text)

CrystalReportViewer1.ReportSource = rpt

End If

Else

MsgBox("Please enter a specific Student ID.")

End If

ElseIf rdDpt.Checked = True Then

If ComboBox9.SelectedIndex >= 0 Then

Dim sql As String

sql = "SELECT * FROM notsignout WHERE notsignout.date_in between #" & FirstDate &
"# AND #" & secondDate & "# AND status='" & status & "' AND userType='" &
ddAttendanceType.SelectedItem & "' AND department='" & drpt & "' order by date_in DESC"

Dim adapter As New OleDbDataAdapter(sql, myconnection)

Dim dt As New DataTable("students")

adapter.Fill(dt)

Dim dsd As New DataSet

Dim rpt As New CrystalReport1


rpt.SetDataSource(dt)

rpt.SetParameterValue("startDate", BunifuDatePicker2.Text)

rpt.SetParameterValue("endDate", BunifuDatePicker3.Text)

rpt.SetParameterValue("option", rptoption)

rpt.SetParameterValue(3, BunifuTextBox11.Text)

rpt.SetParameterValue(4, BunifuTextBox10.Text)

CrystalReportViewer1.ReportSource = rpt

Else

MsgBox("Please select a specific Level from the dropdown box.")

End If

Else

Dim sql As String

sql = " SELECT * FROM notsignout WHERE notsignout.date_in between #" & FirstDate & "#
AND #" & secondDate & "# AND status='" & status & "' AND userType='" &
ddAttendanceType.SelectedItem & "' order by date_in DESC"

Dim adapter As New OleDbDataAdapter(sql, myconnection)

Dim dt As New DataTable("students")

adapter.Fill(dt)

Dim dsd As New DataSet

Dim rpt As New CrystalReport1

rpt.SetDataSource(dt)

rpt.SetParameterValue("startDate", BunifuDatePicker2.Text)

rpt.SetParameterValue("endDate", BunifuDatePicker3.Text)

rpt.SetParameterValue("option", rptoption)

rpt.SetParameterValue(3, BunifuTextBox11.Text)

rpt.SetParameterValue(4, BunifuTextBox10.Text)
CrystalReportViewer1.ReportSource = rpt

End If

ElseIf rdAll.Checked = True Then

If rdClass.Checked = True Then

If ComboBox8.SelectedIndex >= 0 Then

Dim sql As String

sql = "SELECT * FROM studentsrecords WHERE studentsrecords.date_in between #" &


FirstDate & "# AND #" & secondDate & "# AND status='" & status & "' AND userType='" &
ddAttendanceType.SelectedItem & "' AND class='" & cls & "' AND flag IS NOT NULL order by date_in
DESC"

Dim adapter As New OleDbDataAdapter(sql, myconnection)

Dim dt As New DataTable("students")

adapter.Fill(dt)

Dim dsd As New DataSet

Dim rpt As New CrystalReport1

rpt.SetDataSource(dt)

rpt.SetParameterValue("startDate", BunifuDatePicker2.Text)

rpt.SetParameterValue("endDate", BunifuDatePicker3.Text)

rpt.SetParameterValue("option", rptoption)

rpt.SetParameterValue(3, BunifuTextBox11.Text)

rpt.SetParameterValue(4, BunifuTextBox10.Text)

CrystalReportViewer1.ReportSource = rpt

Else

MsgBox("Please select a specific Class from the dropdown box.")

End If

ElseIf rdIdRpt.Checked = True Then

If TextBox21.Text IsNot "" Then


Dim sql As String

sql = "SELECT * FROM studentsrecords WHERE studentsrecords.date_in between #" &


FirstDate & "# AND #" & secondDate & "# AND status='" & status & "' AND userType='" &
ddAttendanceType.SelectedItem & "' AND id LIKE '" & TextBox21.Text & "' AND flag IS NOT NULL order by
date_in DESC"

Dim adapter As New OleDbDataAdapter(sql, myconnection)

Dim dt As New DataTable("students")

adapter.Fill(dt)

If dt.Rows.Count = 0 Then

MsgBox("Student ID not found. Please try again.")

Else

Dim dsd As New DataSet

Dim rpt As New CrystalReport1

rpt.SetDataSource(dt)

rpt.SetParameterValue("startDate", BunifuDatePicker2.Text)

rpt.SetParameterValue("endDate", BunifuDatePicker3.Text)

rpt.SetParameterValue("option", rptoption)

rpt.SetParameterValue(3, BunifuTextBox11.Text)

rpt.SetParameterValue(4, BunifuTextBox10.Text)

CrystalReportViewer1.ReportSource = rpt

End If

Else

MsgBox("Please enter a specific Student ID.")

End If

ElseIf rdDpt.Checked = True Then

If ComboBox9.SelectedIndex >= 0 Then

Dim sql As String


sql = "SELECT * FROM studentsrecords WHERE studentsrecords.date_in between #" &
FirstDate & "# AND #" & secondDate & "# AND status='" & status & "' AND userType='" &
ddAttendanceType.SelectedItem & "' AND department='" & drpt & "' AND flag IS NOT NULL order by
date_in DESC"

Dim adapter As New OleDbDataAdapter(sql, myconnection)

Dim dt As New DataTable("students")

adapter.Fill(dt)

Dim dsd As New DataSet

Dim rpt As New CrystalReport1

rpt.SetDataSource(dt)

rpt.SetParameterValue("startDate", BunifuDatePicker2.Text)

rpt.SetParameterValue("endDate", BunifuDatePicker3.Text)

rpt.SetParameterValue("option", rptoption)

rpt.SetParameterValue(3, BunifuTextBox11.Text)

rpt.SetParameterValue(4, BunifuTextBox10.Text)

CrystalReportViewer1.ReportSource = rpt

Else

MsgBox("Please select a specific Level from the dropdown box.")

End If

Else

Dim sql As String

sql = " SELECT * FROM studentsrecords WHERE studentsrecords.date_in between #" &
FirstDate & "# AND #" & secondDate & "# AND status='" & status & "' AND userType='" &
ddAttendanceType.SelectedItem & "' AND flag IS NOT NULL order by date_in DESC"

Dim adapter As New OleDbDataAdapter(sql, myconnection)

Dim dt As New DataTable("students")

adapter.Fill(dt)
Dim dsd As New DataSet

Dim rpt As New CrystalReport1

rpt.SetDataSource(dt)

rpt.SetParameterValue("startDate", BunifuDatePicker2.Text)

rpt.SetParameterValue("endDate", BunifuDatePicker3.Text)

rpt.SetParameterValue("option", rptoption)

rpt.SetParameterValue(3, BunifuTextBox11.Text)

rpt.SetParameterValue(4, BunifuTextBox10.Text)

CrystalReportViewer1.ReportSource = rpt

End If

End If

Catch ex As Exception

MsgBox(ex.Message)

End Try

Else

MsgBox("The End Date cannot be less that the Start Date")

End If

End Sub

Public Sub RetrieveToCombo1()

ComboBox1.Items.Clear()

BunifuDropdown1.Items.Clear()
ComboBox8.Items.Clear()

ComboBox12.Items.Clear()

Try

myconnection.Open()

Dim cmd As OleDbCommand = New OleDbCommand("SELECT ClassCombo FROM controls",


myconnection)

Dim dr As OleDbDataReader = cmd.ExecuteReader

Dim userfound As Boolean = False

While dr.Read

ComboBox1.Items.Add(dr.GetString(0))

BunifuDropdown1.Items.Add(dr.GetString(0))

ComboBox8.Items.Add(dr.GetString(0))

ComboBox12.Items.Add(dr.GetString(0))

End While

myconnection.Close()

Catch ex As Exception

MsgBox(ex.Message)

End Try

'BunifuDropdown1.Sorted = True

End Sub

Private Sub rdEarly_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles rdEarly.CheckedChanged

rptoption = rdEarly.Text

End Sub
Private Sub rdLate_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles rdLate.CheckedChanged

rptoption = rdLate.Text

End Sub

Private Sub rdAll_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles rdAll.CheckedChanged

rptoption = rdAll.Text

rptoption = "All"

' updateAbsent()

End Sub

Private Sub ComboBox9_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles ComboBox9.SelectedIndexChanged

drpt = ComboBox9.SelectedItem

End Sub

Private Sub updateAbsent()

' CODE INSERT

myconnection.Open()

Dim sqlupdate As String

Dim word As Char = "A"

sqlupdate = "UPDATE studentsrecords SET time_in=@time_in, time_out=@time_out WHERE flag IS


NULL AND time_in IS NULL"

Dim cmd As New OleDbCommand(sqlupdate, myconnection)


cmd.Parameters.Add(New OleDbParameter("@time_in", word))

cmd.Parameters.Add(New OleDbParameter("@time_out", word))

Try

cmd.ExecuteNonQuery()

myconnection.Close()

Catch ex As Exception

MsgBox(ex.Message)

Finally

myconnection.Close()

End Try

End Sub

Private Sub RadioButton4_CheckedChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs)

rptoption = rdAbsent.Text

Dim dtt As New DataTable("studentss")

eDA.SelectCommand = New OleDbCommand("SELECT tag_ID, firstname, lastname, class, date_in


FROM studentsrecords WHERE flag IS NULL", myconnection)

eDS.Clear()

eDA.Fill(dtt)

' DataGridView5.DataSource = dtt

'Dim dsd As New DataSet1

'Dim rpt As New CrystalReport1

'rpt.SetDataSource(dtt)
'CrystalReportViewer1.ReportSource = rpt

End Sub

Private Sub ComboBox8_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles ComboBox8.SelectedIndexChanged

cls = ComboBox8.SelectedItem

End Sub

Private Sub Button43_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


BunifuButton43.Click

Dim abt As DateTime = TextBox27.Text

Dim et As DateTime = DateTimePicker5.Value.ToLongTimeString

Dim auto_sgnt As DateTime = TextBox5.Text.Trim

If et.TimeOfDay > abt.TimeOfDay And et.TimeOfDay <= auto_sgnt.TimeOfDay Then

Dim dialog As passwordPrompt = New passwordPrompt()

If dialog.ShowDialog() = DialogResult.OK Then

If dialog.BunifuTextBox1.Text = "" And dialog.BunifuTextBox2.Text = "" Then

MsgBox("Please enter Username and Password.")

Else

Dim userfound As Integer = LoginFunc(dialog.BunifuTextBox1.Text,


dialog.BunifuTextBox2.Text)
If userfound = 1 Then

' CODE INSERT

Dim sqlupdate As String

Dim time As String = "duration"

sqlupdate = "UPDATE controls SET end_time=@end_time WHERE time_flag='" & time & "'"

Dim cmd As New OleDbCommand(sqlupdate, myconnection)

cmd.Parameters.Add(New OleDbParameter("@end_time", DateTimePicker5.Text))

Try

myconnection.Open()

If MessageBox.Show("Are you sure you want to update the School's End Time?",
"Change", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK
Then

If (cmd.ExecuteNonQuery() > 0) Then

MsgBox("The End Time was updated successfully.")

myconnection.Close()

retrieveTime()

End If

End If

Catch ex As Exception
MsgBox(ex.Message)

Finally

myconnection.Close()

End Try

ElseIf userfound = 2 Then

MsgBox("Please enter the Local Admin user credentials.")

Else

MsgBox("The Username or Password is incorrenct.")

End If

End If

End If

dialog.Dispose()

myconnection.Close()

Else

MsgBox("The End Time must be later than the current Absent Time and earlier than the current
Auto Sign-Out Time.")

End If

End Sub

Public Sub retrieveSignout()

Dim nam = "duration"

Try

myconnection.Open()
Dim cmd As OleDbCommand = New OleDbCommand("SELECT signout_time FROM controls
WHERE time_flag='" & nam & "'", myconnection)

Dim dr As OleDbDataReader = cmd.ExecuteReader

Dim userfound As Boolean = False

While dr.Read

Dim x As DateTime = dr("signout_time")

TextBox5.Text = x.ToString("hh:mm tt")

scheduledTime = dr("signout_time")

End While

myconnection.Close()

Catch ex As Exception

MsgBox(ex.Message)

myconnection.Close()

End Try

End Sub

Public Sub retrieveAbsentOut()

Dim nam = "duration"

Try

myconnection.Open()

Dim cmd As OleDbCommand = New OleDbCommand("SELECT absent_time FROM controls


WHERE time_flag='" & nam & "'", myconnection)

Dim dr As OleDbDataReader = cmd.ExecuteReader


Dim userfound As Boolean = False

While dr.Read

Dim x As DateTime = dr("absent_time")

TextBox27.Text = x.ToString("hh:mm tt")

scheduledTime1 = dr("absent_time")

End While

myconnection.Close()

Catch ex As Exception

MsgBox(ex.Message)

myconnection.Close()

End Try

End Sub

Public Sub retrieveDpt()

ComboBox7.Items.Clear()

ComboBox6.Items.Clear()

ComboBox13.Items.Clear()

ddStaffSms.Items.Clear()

ComboBox9.Items.Clear()

cbLevelStaff.Items.Clear()

Try

myconnection.Open()
Dim cmd1 As OleDbCommand = New OleDbCommand("SELECT DptCombo FROM controlsdpt",
myconnection)

Dim dr1 As OleDbDataReader = cmd1.ExecuteReader

Dim userfound1 As Boolean = False

While dr1.Read

ComboBox7.Items.Add(dr1.GetString(0))

ComboBox6.Items.Add(dr1.GetString(0))

ComboBox13.Items.Add(dr1.GetString(0))

ddStaffSms.Items.Add(dr1.GetString(0))

ComboBox9.Items.Add(dr1.GetString(0))

cbLevelStaff.Items.Add(dr1.GetString(0))

End While

myconnection.Close()

Catch ex As Exception

MsgBox(ex.Message)

myconnection.Close()

End Try

End Sub

Public Sub retrieveSubject()

cbSubjectsPreview.Items.Clear()

Try
myconnection.Open()

Dim cmd1 As OleDbCommand = New OleDbCommand("SELECT subject FROM subjects",


myconnection)

Dim dr1 As OleDbDataReader = cmd1.ExecuteReader

Dim userfound1 As Boolean = False

While dr1.Read

cbSubjectsPreview.Items.Add(dr1.GetString(0))

End While

myconnection.Close()

Catch ex As Exception

MsgBox(ex.Message)

myconnection.Close()

End Try

End Sub

Public Sub retrieveTitle()

cbTitlePreview.Items.Clear()

cbStaffType.Items.Clear()

dbTitleStaff.Items.Clear()

dbTitleStaff2.Items.Clear()

Try
myconnection.Open()

Dim cmd1 As OleDbCommand = New OleDbCommand("SELECT title FROM titles", myconnection)

Dim dr1 As OleDbDataReader = cmd1.ExecuteReader

Dim userfound1 As Boolean = False

While dr1.Read

cbTitlePreview.Items.Add(dr1.GetString(0))

cbStaffType.Items.Add(dr1.GetString(0))

dbTitleStaff.Items.Add(dr1.GetString(0))

dbTitleStaff2.Items.Add(dr1.GetString(0))

End While

myconnection.Close()

Catch ex As Exception

MsgBox(ex.Message)

myconnection.Close()

End Try

End Sub

Public Sub retrieveTerm()

dpTermPreview.Items.Clear()

Dim stDT As String = ""

Dim endDT As String = ""


Try

myconnection.Open()

Dim cmd1 As OleDbCommand = New OleDbCommand("SELECT * FROM terms", myconnection)

Dim dr1 As OleDbDataReader = cmd1.ExecuteReader

Dim userfound1 As Boolean = False

While dr1.Read

stDT = dr1.GetDateTime(1).ToString("MM/dd/yyyy")

endDT = dr1.GetDateTime(2).ToString("MM/dd/yyyy")

dpTermPreview.Items.Add("Term " & dr1.GetInt32(0).ToString + " (" + stDT + " - " + endDT + ")")

If Now.Date >= dr1.GetValue(1) And Now.Date <= dr1.GetValue(2) Then

lblTermStatus.Text = "Term " & dr1.GetInt32(0).ToString

lblStaffCurrentSchTerm.Text = "Term " & dr1.GetInt32(0).ToString

lblStudCurrentSchTerm.Text = "Term " & dr1.GetInt32(0).ToString

End If

End While

myconnection.Close()

Catch ex As Exception

MsgBox(ex.Message)

myconnection.Close()

End Try

End Sub
Public Sub retrieveTime()

Dim nam = "duration"

Try

myconnection.Open()

Dim cmd As OleDbCommand = New OleDbCommand("SELECT start_time, end_time, late_time,


user_logintime, term_start, term_end, absent_time, signout_time FROM controls WHERE time_flag='" &
nam & "'", myconnection)

Dim dr As OleDbDataReader = cmd.ExecuteReader

Dim userfound As Boolean = False

While dr.Read

'ComboBox2.Items.Add(dr.GetString(0))

DateTimePicker4.Value = dr("start_time")

BunifuTextBox11.Text = dr("start_time")

DateTimePicker5.Value = dr("end_time")

BunifuTextBox12.Text = dr("end_time")

DateTimePicker6.Value = dr("late_time")

BunifuTextBox10.Text = dr("late_time")

Dim y As DateTime = dr("absent_time")

DateTimePicker9.Text = y.ToString("hh:mm tt")


TextBox27.Text = y

Dim ss As DateTime = dr("signout_time")

TextBox5.Text = ss

DateTimePicker8.Text = ss.ToString("hh:mm tt")

'DateTimePicker11.Value = dr("term_start")

StartTerm = dr("term_start")

'DateTimePicker12.Value = dr("term_end")

EndTerm = dr("term_end")

Dim x As DateTime = dr("user_logintime") 'convert back to 12 notation

DateTimePicker7.Value = dr("user_logintime")

BunifuTextBox13.Text = dr("user_logintime")

hr = x.ToString("HH:mm:ss tt").Substring(0, 2)

mn = x.ToString("HH:mm:ss tt").Substring(3, 2)

se = x.ToString("HH:mm:ss tt").Substring(6, 2)

End While

myconnection.Close()

Catch ex As Exception
MsgBox(ex.Message)

myconnection.Close()

End Try

End Sub

Private Sub SetTarget()

' allow various time formats and attempt to parse the scheduled time: (with or without leading
zeroes, allow am/pm or 24 hour format)

Dim allowed() As String = {"h:mm", "hh:mm", "h:mm tt", "hh:mm tt", "H:mm", "HH:mm"}

If DateTime.TryParseExact(scheduledTime, allowed, Nothing, Globalization.DateTimeStyles.None,


targetTime) Then

If targetTime < DateTime.Now Then

' we're already past the target time, schedule it for tomorrow at the same time:

targetTime = targetTime.AddDays(1)

End If

Tmr.Start()

End If

End Sub

Private Sub Tmr_Tick(ByVal sender As Object, ByVal e As EventArgs) Handles Tmr.Tick

Dim ts As TimeSpan = targetTime.Subtract(DateTime.Now)

If ts.TotalMilliseconds <= 0 Then

Tmr.Stop()

signout()

SetTarget()
Else

' display time remaining?

'Label32.Text = "Trigger Time: " & scheduledTime

'Label33.Text = "Current Date/Time: " & DateTime.Now

'Label34.Text = "Time Remaining: -" & ts.ToString

End If

End Sub

Public Sub signout()

Dim strSQL As String = ""

Dim strSQ As String

Dim strqq As String

Dim flag As Integer = 1

myconnection.Open()

Dim cmd As OleDbCommand = New OleDbCommand(" select date_in, time_out, flag from
[studentsrecords] where date_in=#" & Format(Now, "MM/d/yyyy") & "# AND time_out IS NULL AND flag
IS NOT NULL", myconnection)

Dim dr As OleDbDataReader = cmd.ExecuteReader

Dim userfound As Boolean = False

While dr.Read

userfound = True

End While
If userfound = True Then

strSQL = "INSERT INTO notsignout ([Tag_ID],[ID],[Firstname],[lastname],[Department],[Class],


[Date_in],[Time_in]) SELECT [Tag_ID], [ID],[Firstname],[lastname],[Department],[Class],[Date_in],
[Time_in] FROM studentsrecords WHERE date_in=#" & Format(Now, "MM/d/yyyy") & "# and time_out
IS NULL and time_in IS NOT NULL and Flag IS NOT Null "

strSQ = "UPDATE studentsrecords SET time_out='" & DateTime.Now.ToString("hh:mm tt") & "',
flag='" & flag & "' WHERE date_in=#" & Format(Now, "MM/d/yyyy") & "# and time_out IS NULL and
time_in IS NOT NULL and Flag IS NOT Null "

strqq = "UPDATE studentsrecords INNER JOIN notsignout ON studentsrecords.tag_id =


notsignout.tag_id SET notsignout.time_out = [studentsrecords].[time_out] WHERE
studentsrecords.date_in = notsignout.date_in"

command = New OleDbCommand(strSQL, myconnection)

Dim comm As OleDbCommand = New OleDbCommand(strSQ, myconnection)

Dim comlast As OleDbCommand = New OleDbCommand(strqq, myconnection)

Try

command.ExecuteNonQuery()

comm.ExecuteNonQuery()

comlast.ExecuteNonQuery()

myconnection.Close()

Button29.Enabled = False

txtid.Enabled = False

Catch ex As Exception

myconnection.Close()
End Try

'' CODE INSERT

'If Button29.Enabled = False Then

' Dim sqlrelog As String

' Dim opt As String = "relog"

' Dim state As String = "False"

' sqlrelog = "UPDATE controlsignout SET timeset=@timeset WHERE flag='" & opt & "'"

' Dim relog As New OleDbCommand(sqlrelog, myconnection)

' cmd.Parameters.Add(New OleDbParameter("@timeset", state))

' Try

' myconnection.Open()

' cmd.ExecuteNonQuery()

' Catch ex As Exception

' MsgBox(ex.Message)

' Finally

' myconnection.Close()

' End Try

'Else

' myconnection.Close()

'End If

Else
End If

End Sub

Private Sub rdClass_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles rdClass.CheckedChanged

cls = "class"

If rdClass.Checked = True Then

ComboBox8.Enabled = True

ComboBox9.Enabled = False

TextBox21.Enabled = False

Else

ComboBox8.Enabled = False

ComboBox8.Text = ""

ComboBox9.Enabled = True

TextBox21.Enabled = True

End If

End Sub

Private Sub rdDpt_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles rdDpt.CheckedChanged

drpt = "department"
If rdDpt.Checked = True Then

ComboBox9.Enabled = True

ComboBox8.Enabled = False

TextBox21.Enabled = False

Else

ComboBox9.Enabled = False

ComboBox9.Text = ""

ComboBox8.Enabled = True

TextBox21.Enabled = True

End If

End Sub

Private Sub rdAbsent_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles rdAbsent.CheckedChanged

rptoption = rdAbsent.Text

' updateAbsent()

End Sub

Private Sub SetTarget1()

' allow various time formats and attempt to parse the scheduled time: (with or without leading
zeroes, allow am/pm or 24 hour format)

Dim allowed() As String = {"h:mm", "hh:mm", "h:mm tt", "hh:mm tt", "H:mm", "HH:mm"}

If DateTime.TryParseExact(scheduledTime1, allowed, Nothing, Globalization.DateTimeStyles.None,


targetTime1) Then

If targetTime1 < DateTime.Now Then

' we're already past the target time, schedule it for tomorrow at the same time:
targetTime1 = targetTime1.AddDays(1)

End If

Tmr1.Start()

End If

End Sub

Private Sub Tmr1_Tick(ByVal sender As Object, ByVal e As EventArgs) Handles Tmr1.Tick

Dim ts As TimeSpan = targetTime1.Subtract(DateTime.Now)

If ts.TotalMilliseconds <= 0 Then

Tmr1.Stop()

sendAbsentsms()

sendStaffAbsentsms()

absentNotification("Auto Absent messages were successfully sent.")

SetTarget1()

Else

' display time remaining?

'Label35.Text = "Trigger Time: " & scheduledTime1

'Label36.Text = "Current Date/Time: " & DateTime.Now

'Label37.Text = "Time Remaining: -" & ts.ToString

End If

End Sub

Public Sub sendAbsentsms()

If Panel25.Enabled = True Then

Dim strSQL As String = ""


'Dim strSQ As String

'Dim strqq As String

Dim flag As Integer = 1

myconnection.Open()

Dim cmd As OleDbCommand = New OleDbCommand("select Guardiannumber1 from


[studentsrecords] INNER JOIN students ON studentsrecords.tag_id = students.tag_id where
studentsrecords.date_in=#" & Format(Now, "MM/d/yyyy") & "# AND studentsrecords.time_IN IS NULL
AND studentsrecords.flag='0' AND studentsrecords.ReceiveSms='" & flag & "'", myconnection)

Dim dr As OleDbDataReader = cmd.ExecuteReader

Dim a As Integer = 0

Dim userfound As Boolean = False

numbers.Clear()

While dr.Read

If smsApi = True Then

numbers.Add(dr("Guardiannumber1"))

sValue = TextBox9.Text

userfound = True

ElseIf gsm = True Then

'Dosms(dr("Guardiannumber1"), TextBox9.Text)

'Console.WriteLine(dr("Guardiannumber1"))

End If

End While

If userfound = True Then

NumWorkers = NumWorkers + 1
ReDim Workers(NumWorkers)

Workers(NumWorkers) = New BackgroundWorker

Workers(NumWorkers).WorkerReportsProgress = True

Workers(NumWorkers).WorkerSupportsCancellation = True

AddHandler Workers(NumWorkers).DoWork, AddressOf WorkerDoWork

AddHandler Workers(NumWorkers).ProgressChanged, AddressOf WorkerProgressChanged

AddHandler Workers(NumWorkers).RunWorkerCompleted, AddressOf WorkerCompleted

Workers(NumWorkers).RunWorkerAsync()

myconnection.Close()

Else

End If

End If

End Sub

Public Sub sendStaffAbsentsms()

If Panel25.Enabled = True Then

Dim strSQL As String = ""

'Dim strSQ As String

'Dim strqq As String

Dim flag As Integer = 1

myconnection.Open()

Dim cmd As OleDbCommand = New OleDbCommand("select contactnumber from


[studentsrecords] INNER JOIN staff ON studentsrecords.tag_id = staff.tag_id where
studentsrecords.date_in=#" & Format(Now, "MM/d/yyyy") & "# AND studentsrecords.time_IN IS NULL
AND studentsrecords.flag='0' AND studentsrecords.ReceiveSms='" & flag & "'", myconnection)

Dim dr As OleDbDataReader = cmd.ExecuteReader

Dim a As Integer = 0

Dim userfound As Boolean = False

numbers.Clear()

While dr.Read

If smsApi = True Then

numbers.Add(dr("contactnumber"))

sValue = tbAbsentMessage.Text

userfound = True

ElseIf gsm = True Then

'Dosms(dr("Guardiannumber1"), tbAbsentMessage.Text)

'Console.WriteLine(dr("Guardiannumber1"))

End If

End While

If userfound = True Then

NumWorkers = NumWorkers + 1

ReDim Workers(NumWorkers)

Workers(NumWorkers) = New BackgroundWorker

Workers(NumWorkers).WorkerReportsProgress = True

Workers(NumWorkers).WorkerSupportsCancellation = True

AddHandler Workers(NumWorkers).DoWork, AddressOf WorkerDoWork

AddHandler Workers(NumWorkers).ProgressChanged, AddressOf WorkerProgressChanged


AddHandler Workers(NumWorkers).RunWorkerCompleted, AddressOf WorkerCompleted

Workers(NumWorkers).RunWorkerAsync()

myconnection.Close()

Else

End If

End If

End Sub

Function MessageTimeOut(ByVal sMessage As String, ByVal sTitle As String, ByVal iSeconds As Integer)
As Boolean

Dim Shell

Shell = CreateObject("WScript.Shell")

Shell.Run("mshta.exe vbscript:close(CreateObject(""WScript.shell"").Popup(""" & sMessage & ""","


& iSeconds & ",""" & sTitle & """))")

MessageTimeOut = True

End Function

Sub Example()

Dim chk As Boolean

chk = MessageTimeOut("SMS dongle not connected", "Dongle Status", 1) 'if chk returned FALSE that
means the function was not executed successfully

End Sub

Sub Example1()

Dim chk As Boolean

chk = MessageTimeOut("Record entry is successful", "Student Registration", 1) 'if chk returned


FALSE that means the function was not executed successfully

End Sub
Sub picMessage(ByVal mes)

Dim chk As Boolean

chk = MessageTimeOut(mes, "System Notification", 1) 'if chk returned FALSE that means the
function was not executed successfully

End Sub

Sub absentNotification(ByVal mess)

Dim chk As Boolean

chk = MessageTimeOut(mess, "System Absent Notification", 1) 'if chk returned FALSE that means the
function was not executed successfully

End Sub

Sub DeleteNotification(ByVal del, ByVal title)

Dim chk As Boolean

chk = MessageTimeOut(del, title, 1) 'if chk returned FALSE that means the function was not executed
successfully

End Sub

Private Sub txtsearch_OnIconLeftClick(ByVal sender As System.Object, ByVal e As System.EventArgs)

'If txtsearch.Text.Trim = "" Then

' MsgBox("The Search field cannot be empty!")

'ElseIf rdId.Checked = False And rdName.Checked = False And rdGaurdian.Checked = False Then

' MsgBox("The Search field cannot be empty!")

'Else

' Dim tempid As String = ""

' Dim found As Boolean = False

' If rdId.Checked = True Then

' Try
' myconnection.Open()

' Dim cmd As OleDbCommand = New OleDbCommand("SELECT tag_id, id, firstname,


lastname, middlename, gender,Guardiannumber1, Guardiannumber2, address, address2, city, parish,
birthday, age, class, department, ReceiveSms FROM students WHERE id='" & txtsearch.Text & "'",
myconnection)

' Dim dr As OleDbDataReader = cmd.ExecuteReader

' While dr.Read

' found = True

' TextBox10.Text = dr("id")

' tempid = dr("tag_id")

' TextBox11.Text = dr("firstname") + " " + dr("middlename") + " " + dr("lastname")

' TextBox12.Text = dr("address") + " " + dr("address2") + " " + dr("city") + " " + dr("parish")

' TextBox13.Text = dr("birthday")

' TextBox14.Text = dr("class")

' TextBox15.Text = dr("department")

' TextBox16.Text = dr("Guardiannumber1")

' TextBox17.Text = dr("Guardiannumber2")

' TextBox23.Text = dr("gender")

' TextBox20.Text = dr("age")

' If (dr("ReceiveSms") = "1") Then

' TextBox24.Text = "Yes"

' Else

' TextBox24.Text = "No"

' End If

' viewImage(tempid)

' End While


' If found = False Then

' myconnection.Close()

' MsgBox("Student ID not found!")

' Else

' myconnection.Close()

' End If

' Catch ex As Exception

' MsgBox(ex.Message)

' myconnection.Close()

' End Try

' ElseIf rdName.Checked = True Then

' Try

' myconnection.Open()

' Dim cmd As OleDbCommand = New OleDbCommand("SELECT Tag_ID, id, Firstname,


lastname, Middlename, Gender, Guardiannumber1, Guardiannumber2, Address, Address2, City, Parish,
Birthday, Age, Class, Department, ReceiveSms FROM students WHERE firstname='" & txtsearch.Text & "'
or lastname='" & txtsearch.Text & "'", myconnection)

' Dim dr As OleDbDataReader = cmd.ExecuteReader

' While dr.Read

' found = True

' TextBox10.Text = dr("id")

' tempid = dr("tag_id")

' TextBox11.Text = dr("firstname") + " " + dr("middlename") + " " + dr("lastname")


' TextBox12.Text = dr("address") + " " + dr("address2") + " " + dr("city") + " " + dr("parish")

' TextBox13.Text = dr("birthday")

' TextBox14.Text = dr("class")

' TextBox15.Text = dr("department")

' TextBox16.Text = dr("Guardiannumber1")

' TextBox17.Text = dr("Guardiannumber2")

' TextBox23.Text = dr("gender")

' TextBox20.Text = dr("age")

' TextBox20.Text = dr("age")

' If (dr("ReceiveSms") = "1") Then

' TextBox24.Text = "Yes"

' Else

' TextBox24.Text = "No"

' End If

' viewImage(tempid)

' End While

' If found = False Then

' myconnection.Close()

' MsgBox("Name not found!")

' Else

' myconnection.Close()

' End If

' Catch ex As Exception


' MsgBox(ex.Message)

' myconnection.Close()

' End Try

' ElseIf rdGaurdian.Checked = True Then

' Try

' myconnection.Open()

' Dim cmd As OleDbCommand = New OleDbCommand("SELECT Tag_ID, id, Firstname,


lastname, Middlename, Gender, Guardiannumber1, Guardiannumber2, Address, Address2, City, Parish,
Birthday, Age, Class, Department, ReceiveSms FROM students WHERE Guardiannumber1='" &
txtsearch.Text & "' or Guardiannumber2='" & txtsearch.Text & "'", myconnection)

' Dim dr As OleDbDataReader = cmd.ExecuteReader

' While dr.Read

' found = True

' TextBox10.Text = dr("id")

' tempid = dr("tag_id")

' TextBox11.Text = dr("firstname") + " " + dr("middlename") + " " + dr("lastname")

' TextBox12.Text = dr("address") + " " + dr("address2") + " " + dr("city") + " " + dr("parish")

' TextBox13.Text = dr("birthday")

' TextBox14.Text = dr("class")

' TextBox15.Text = dr("department")

' TextBox16.Text = dr("Guardiannumber1")

' TextBox17.Text = dr("Guardiannumber2")

' TextBox23.Text = dr("gender")

' TextBox20.Text = dr("age")

' TextBox20.Text = dr("age")


' If (dr("ReceiveSms") = "1") Then

' TextBox24.Text = "Yes"

' Else

' TextBox24.Text = "No"

' End If

' viewImage(tempid)

' End While

' If found = False Then

' myconnection.Close()

' MsgBox("Phone number not found!")

' Else

' myconnection.Close()

' End If

' Catch ex As Exception

' MsgBox(ex.Message)

' myconnection.Close()

' End Try

' End If

'End If

End Sub
Private Sub viewImage(ByVal image As String)

Dim cnn As New OleDb.OleDbConnection

cnn = New OleDb.OleDbConnection

Dim picview As String

cnn.ConnectionString = "provider = microsoft.ace.oledb.12.0; data


source=studentattendancesystem.accdb; Persist Security Info=False;"

If cnn.State = ConnectionState.Open Then

cnn.Open()

End If

Dim da As New OleDb.OleDbDataAdapter("SELECT * FROM students WHERE tag_id='" & image & "'",
cnn)

Dim dt As New DataTable

da.Fill(dt)

picview = dt.Rows(0).Item("PicturePath")

cnn.Close()

BunifuPictureBox8.Image = System.Drawing.Bitmap.FromFile(picview)

End Sub

Private Sub viewImageStaff(ByVal image As String)

Dim cnn As New OleDb.OleDbConnection

cnn = New OleDb.OleDbConnection

Dim picview As String

cnn.ConnectionString = "provider = microsoft.ace.oledb.12.0; data


source=studentattendancesystem.accdb; Persist Security Info=False;"
If cnn.State = ConnectionState.Open Then

cnn.Open()

End If

Dim da As New OleDb.OleDbDataAdapter("SELECT * FROM staff WHERE tag_id='" & image & "'",
cnn)

Dim dt As New DataTable

da.Fill(dt)

picview = dt.Rows(0).Item("PicturePath")

cnn.Close()

BunifuPictureBox8.Image = System.Drawing.Bitmap.FromFile(picview)

End Sub

Public Sub clearfields()

txtaddress.Clear()

txtage.Clear()

txtfirstname.Clear()

txtmiddlename.Clear()

txtsurname.Clear()

txtparentsname.Clear()

BunifuTextBox1.Text = My.Application.Info.DirectoryPath & "\images\emptyimage.png"

TextBox2.Clear()

TextBox3.Clear()

TextBox4.Clear()
TextBox8.Clear()

TextBox6.Clear()

TextBox7.Clear()

'TextBox20.Clear()

'TextBox23.Clear()

ComboBox1.Text = ""

ComboBox7.Text = ""

BunifuToggleSwitch1.Value = False

DateTimePicker1.Value = Now

RetrieveToCombo1()

BunifuPictureBox6.Image = Nothing

rdmale.Checked = False

rdfemale.Checked = False

End Sub

Private Sub clearfieldsnew()

txtStaffID.Clear()

txtContactStaff.Clear()

txtFirstNameStaff.Clear()

txtLastNameStaff.Clear()

txtAddressStaff.Clear()

txtTagIdStaff.Clear()

txtPostOfficeStaff.Clear()

txtCityStaff.Clear()
txtParishStaff.Clear()

pbStaffPhoto.ImageLocation = My.Application.Info.DirectoryPath & "\images\emptyimage.png"

cbStaffType.Text = ""

cbLevelStaff.Text = ""

dbTitleStaff.Text = ""

txtAgeStaff.Clear()

dtpDobStaff.Value = Now

BunifuToggleSwitch3.Value = True

rbMaleStaff.Checked = False

rbFemaleStaff.Checked = False

End Sub

Private Sub clearfieldsrecordlookup()

dbRegistryType.SelectedIndex = 0

dbRecordType.SelectedIndex = 0

dbStudentFilter.SelectedIndex = 0

dbStaffFilter.Text = ""

txtsearch.Text = ""

BunifuDataGridView3.DataSource = Nothing

Label25.Text = "0"

BunifuPictureBox8.Image = Nothing

End Sub
Private Sub rdmale_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles rdmale.CheckedChanged

If rdmale.Checked = True Then

male = "Male"

End If

End Sub

Private Sub rdfemale_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles rdfemale.CheckedChanged

If rdfemale.Checked = True Then

male = "Female"

End If

End Sub

Private Sub rdFemaleUpdate_CheckedChanged(sender As Object, e As EventArgs) Handles


rdFemaleUpdate.CheckedChanged

If rdFemaleUpdate.Checked Then

male2 = "Female"

End If

End Sub

Private Sub rdMaleUpdate_CheckedChanged(sender As Object, e As EventArgs) Handles


rdMaleUpdate.CheckedChanged

If rdMaleUpdate.Checked Then

male2 = "Male"

End If

End Sub
Private Sub rbFemaleStaff2_CheckedChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles rbFemaleStaff2.CheckedChanged

If rbFemaleStaff2.Checked = True Then

ganderstaff = "Female"

End If

End Sub

Private Sub rbMaleStaff2_CheckedChanged(sender As Object, e As EventArgs) Handles


rbMaleStaff2.CheckedChanged

If rbMaleStaff2.Checked Then

ganderstaff = "Male"

End If

End Sub

Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles DateTimePicker1.ValueChanged

Dim iDagdag As Integer

iDagdag = CInt(DateDiff(DateInterval.Year, DateTimePicker1.Value.Date, Now) / 4)

txtage.Text = Floor((DateDiff(DateInterval.Day, DateTimePicker1.Value.Date, Now) - iDagdag) / 365)

End Sub

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles ComboBox1.SelectedIndexChanged

q = ComboBox1.SelectedItem

End Sub

Private Sub ComboBox7_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles ComboBox7.SelectedIndexChanged

p = ComboBox7.SelectedItem

End Sub

Private Sub BunifuButton16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles BunifuButton16.Click

'UpdateClearfields()

'rdId.Checked = False

'rdName.Checked = False

'rdGaurdian.Checked = False

clearfieldsrecordlookup()

End Sub

Private Sub BunifuButton13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles BunifuButton13.Click

Dim img As String

Dim myStream As Stream = Nothing

Dim openFileDialog1 As New OpenFileDialog()

openFileDialog1.InitialDirectory = "c:\"

openFileDialog1.Filter = Nothing

openFileDialog1.FilterIndex = 2

openFileDialog1.RestoreDirectory = True

openFileDialog1.FileName = ""
If openFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then

Try

myStream = openFileDialog1.OpenFile()

If (myStream IsNot Nothing) Then

BunifuTextBox1.Text = ""

img = openFileDialog1.FileName

BunifuPictureBox6.Image = System.Drawing.Bitmap.FromFile(img)

BunifuTextBox1.Text = openFileDialog1.FileName

End If

Catch Ex As Exception

MessageBox.Show("Cannot read file from disk. Original error: " & Ex.Message)

Finally

If (myStream IsNot Nothing) Then

myStream.Close()

End If

End Try

End If

End Sub

Public Sub cleartxt()

TextBox10.Clear()

TextBox11.Clear()
TextBox12.Clear()

TextBox13.Clear()

TextBox14.Clear()

txtsearch.Clear()

TextBox15.Clear()

TextBox16.Clear()

TextBox17.Clear()

TextBox24.Clear()

'TextBox20.Clear()

TextBox23.Clear()

BunifuPictureBox8.Image = Nothing

End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


BunifuButton16.Click

End Sub

Private Sub BunifuButton15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles BunifuButton15.Click

If txtsearch.Text.Trim = "" Then

MsgBox("You must first search for a record.")

Else

If dbRecordType.SelectedItem = "Student" Then

If showstudent(txtsearch.Text) = True Then


BunifuPages1.SetPage("Editpage")

retrieveDptUpdate()

RetrieveToComboUpdate1()

cleartxt()

Else

MsgBox("Student ID not found.")

End If

ElseIf dbRecordType.SelectedItem = "Staff" Then

If showstaff(txtsearch.Text) = True Then

BunifuPages1.SetPage("Editpage2")

retrieveDptUpdate()

RetrieveToComboUpdate1()

cleartxt()

Else

MsgBox("Student ID not found.")

End If

End If
End If

End Sub

Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


BunifuButton29.Click

If TextBox18.Text = "" Then

MessageBox.Show("Please enter a specific Class to be added.", "KADTRACK")

Else

Dim sql As String = "INSERT INTO controls (ClassCombo) VALUES(@ClassCombo)"

cmd = New OleDbCommand(sql, myconnection)

cmd.Parameters.AddWithValue("@ClassCombo", TextBox18.Text)

Try

If MessageBox.Show("Are you sure you want to add this new Class to the database?",
"WARNING", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) =
Windows.Forms.DialogResult.OK Then

myconnection.Open()

If cmd.ExecuteNonQuery() > 0 Then

MsgBox("Successfully Entered Class!")

End If

myconnection.Close()

RetrieveToCombo1()

TextBox18.Text = ""

dailyGraphs()

End If

Catch ex As Exception
MsgBox(ex.Message)

myconnection.Close()

RetrieveToCombo1()

End Try

End If

End Sub

Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


BunifuButton26.Click

If TextBox19.Text = "" Then

MessageBox.Show("Please enter a specific Level to be added.", "KADTRACK")

Else

Dim sql As String = "INSERT INTO controlsdpt (DptCombo) VALUES(@DptCombo)"

cmd = New OleDbCommand(sql, myconnection)

cmd.Parameters.AddWithValue("@DptCombo", TextBox19.Text)

Try

myconnection.Open()

If MessageBox.Show("Are you sure you want to add this new Level to the database?",
"WARNING", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) =
Windows.Forms.DialogResult.OK Then

If cmd.ExecuteNonQuery() > 0 Then

MsgBox("Successfully Entered Department! ")

End If

myconnection.Close()

retrieveDpt()
dailyGraphs()

TextBox19.Text = ""

End If

Catch ex As Exception

MsgBox(ex.Message)

myconnection.Close()

retrieveDpt()

End Try

End If

End Sub

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


BunifuButton28.Click

If TextBox18.Text = "" Or BunifuDropdown1.SelectedIndex < 0 Then

MessageBox.Show("Please select a specific Class from the dropdown box.", "KADTRACK")

Else

Dim sql As String = "DELETE * FROM controls WHERE ClassCombo='" & TextBox18.Text & "'"

cmd = New OleDbCommand(sql, myconnection)

Dim dialog As passwordPrompt = New passwordPrompt()

If dialog.ShowDialog() = DialogResult.OK Then

If dialog.BunifuTextBox1.Text = "" And dialog.BunifuTextBox2.Text = "" Then

MsgBox("Please enter Username and Password.")


Else

Dim userfound As Integer = LoginFunc(dialog.BunifuTextBox1.Text,


dialog.BunifuTextBox2.Text)

If userfound = 1 Then

Try

myconnection.Open()

If MessageBox.Show("Are you sure you want to delete this Class?", "DELETE",


MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

If (cmd.ExecuteNonQuery() > 0) Then

MsgBox("Successfully Deleted!")

TextBox18.Text = ""

BunifuDropdown1.Text = ""

End If

End If

myconnection.Close()

RetrieveToCombo1()

Catch ex As Exception

MsgBox(ex.Message)

myconnection.Close()

RetrieveToCombo1()

End Try

ElseIf userfound = 2 Then

MsgBox("Please enter the Local Admin user credentials.")


Else

MsgBox("The Username or Password is incorrenct.")

End If

End If

End If

dialog.Dispose()

End If

End Sub

Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


BunifuButton27.Click

If TextBox19.Text = "" Or ComboBox6.SelectedIndex < 0 Then

MessageBox.Show("Please select a specific Level from the dropdown box.", "KADTRACK")

Else

Dim sql As String = "DELETE * FROM controlsdpt WHERE DptCombo='" & TextBox19.Text & "'"

cmd = New OleDbCommand(sql, myconnection)

Dim dialog As passwordPrompt = New passwordPrompt()

If dialog.ShowDialog() = DialogResult.OK Then

If dialog.BunifuTextBox1.Text = "" And dialog.BunifuTextBox2.Text = "" Then

MsgBox("Please enter Username and Password.")

Else
Dim userfound As Integer = LoginFunc(dialog.BunifuTextBox1.Text,
dialog.BunifuTextBox2.Text)

If userfound = 1 Then

Try

myconnection.Open()

If MessageBox.Show("Are you sure you want to delete this Level?", "DELETE",


MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

If (cmd.ExecuteNonQuery() > 0) Then

MsgBox("Successfully Deleted!")

TextBox19.Text = ""

ComboBox6.Text = ""

End If

End If

myconnection.Close()

retrieveDpt()

Catch ex As Exception

MsgBox(ex.Message)

myconnection.Close()

retrieveDpt()

End Try

ElseIf userfound = 2 Then

MsgBox("Please enter the Local Admin user credentials.")

Else
MsgBox("The Username or Password is incorrenct.")

End If

End If

End If

dialog.Dispose()

End If

End Sub

Private Sub ComboBox6_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles ComboBox6.SelectedIndexChanged

TextBox19.Text = ComboBox6.SelectedItem

End Sub

Private Sub ComboBox3_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles BunifuDropdown1.SelectedIndexChanged

TextBox18.Text = BunifuDropdown1.SelectedItem

End Sub

Private Sub rdIdRpt_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles rdIdRpt.CheckedChanged

If rdIdRpt.Checked = True Then

TextBox21.Enabled = True

ComboBox8.Enabled = False

ComboBox9.Enabled = False

Else
TextBox21.Enabled = False

TextBox21.Text = ""

ComboBox8.Enabled = False

ComboBox9.Enabled = False

End If

End Sub

Public Sub clearSmsCon()

rdtoall.Checked = False

rdToSelected.Checked = True

TextBox38.Clear()

TextBox37.Clear()

'TextBox32.Clear()

End Sub

Private Sub btnsend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


btnsend.Click

Dim num As Integer = 0

Dim gridCheck As Boolean = False

For Each oRow As DataGridViewRow In DataGridView4.Rows

If oRow.Cells(0).Value = True Then

num += 1

Else

End If
Next

If num >= 1 Then

gridCheck = True

Else

gridCheck = False

End If

If rdToSelected.Checked = True And Not TextBox37.Text.Trim = "" And gridCheck = True Then

If smsApi = True Then

If MessageBox.Show("Are you sure you want to send this message?", "Message",


MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

numbers.Clear()

btnsend.Enabled = False

For Each oRow As DataGridViewRow In DataGridView4.Rows

If oRow.Cells(0).Value = True Then

numbers.Add(oRow.Cells("Guardiannumber1").Value)

'ss(oRow.Cells(0).ColumnIndex) = TextBox37.Text

sValue = TextBox37.Text

End If

Next

NumWorkers = NumWorkers + 1

ReDim Workers(NumWorkers)

Workers(NumWorkers) = New BackgroundWorker

Workers(NumWorkers).WorkerReportsProgress = True

Workers(NumWorkers).WorkerSupportsCancellation = True
AddHandler Workers(NumWorkers).DoWork, AddressOf WorkerDoWork

AddHandler Workers(NumWorkers).ProgressChanged, AddressOf WorkerProgressChanged

AddHandler Workers(NumWorkers).RunWorkerCompleted, AddressOf WorkerCompleted

Workers(NumWorkers).RunWorkerAsync()

MsgBox("The message was successfully sent to the selected records.")

Else

End If

ElseIf gsm = True Then

If MessageBox.Show("Are you sure you want to send this message?", "Message",


MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

btnsend.Enabled = False

'Dosms(oRow.Cells("Guardiannumber1").Value, TextBox37.Text)

MsgBox("The message was successfully sent to the selected records.")

Else

End If

Else

End If

btnsend.Enabled = True

clearSmsCon()

ElseIf rdtoall.Checked = True And Not TextBox37.Text.Trim = "" Then

If smsApi = True Then

If MessageBox.Show("Are you sure you want to send this message?", "Message",


MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then
numbers.Clear()

myconnection.Open()

eDA.SelectCommand = New OleDbCommand("SELECT Guardiannumber1 FROM students ",


myconnection)

eDS.Clear()

eDA.Fill(eDS)

btnsend.Enabled = False

For i As Integer = 0 To eDS.Tables(0).Rows.Count - 1

eDR = eDS.Tables(0).Rows(i)

numbers.Add(eDR("Guardiannumber1"))

sValue = TextBox37.Text

Next

NumWorkers = NumWorkers + 1

ReDim Workers(NumWorkers)

Workers(NumWorkers) = New BackgroundWorker

Workers(NumWorkers).WorkerReportsProgress = True

Workers(NumWorkers).WorkerSupportsCancellation = True

AddHandler Workers(NumWorkers).DoWork, AddressOf WorkerDoWork

AddHandler Workers(NumWorkers).ProgressChanged, AddressOf WorkerProgressChanged

AddHandler Workers(NumWorkers).RunWorkerCompleted, AddressOf WorkerCompleted

Workers(NumWorkers).RunWorkerAsync()

btnsend.Enabled = True

MsgBox("Your custom message was successfully sent to all recipients")

clearSmsCon()

Else
End If

ElseIf gsm = True Then

If MessageBox.Show("Are you sure you want to send this message?", "Message",


MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

myconnection.Open()

eDA.SelectCommand = New OleDbCommand("SELECT Guardiannumber1 FROM students ",


myconnection)

eDS.Clear()

eDA.Fill(eDS)

btnsend.Enabled = False

For i As Integer = 0 To eDS.Tables(0).Rows.Count - 1

eDR = eDS.Tables(0).Rows(i)

Dosms(eDR("Guardiannumber1"), TextBox37.Text)

Next

btnsend.Enabled = True

MsgBox("Your custom message was successfully sent to all recipients")

clearSmsCon()

Else

End If

End If

ElseIf TextBox37.Text.Trim = "" Then

MsgBox("The SMS Body field cannot be empty.")

Else

MsgBox("Please enter all required information.")


End If

End Sub

Public Sub Dosms(ByVal number As String, ByVal body As String)

Try

SerialPort1.Write("AT+CMGS=" & Chr(34) & number & Chr(34) & vbCr)

'Timer1.Enabled = True

'Timer1.Interval = 1000

'Timer1.Start()

'Thread.Sleep(1000)

Delay(5) 'delay to send sms for custom/manual

SerialPort1.Write(body & Chr(26) & vbCr)

'Dim Clicks As String

''Clicks = DirectCast(sender, Button).Name

''txtRX.AppendText(Clicks & vbCrLf)

'If Clicks = "btnSendCmd" Then

' 'SerialPort1.Write(txtTX.Text)

' 'If chkCR.Checked = True Then

' ' SerialPort1.Write(vbCr)

' 'End If

' 'If chkLF.Checked = True Then

' ' SerialPort1.Write(vbCr)


' 'End If

'ElseIf Clicks = "btnAT" Then

' 'SerialPort1.Write(txtAT.Text & vbCr)

'ElseIf Clicks = "btnSendSMS" Then

' SerialPort1.Write("AT+CMGS=" & Chr(34) & number & Chr(34) & vbCr)

' 'Timer1.Enabled = True

' 'Timer1.Interval = 1000

' 'Timer1.Start()

' 'Thread.Sleep(1000)

' Delay(5)

' SerialPort1.Write(body & Chr(26) & vbCr)

'ElseIf Clicks = "btnReset" Then

' ' SerialPort1.Write(txtReset.Text & vbCr)

'ElseIf Clicks = "btnSave" Then

' ' SerialPort1.Write(txtSave.Text & vbCr)

'End If

Catch ex As Exception

MsgBox(ex.Message)

End Try

End Sub

Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As


System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived

'ReceivedText(SerialPort1.ReadExisting()) 'event call for data receving, read until data is


completed
'ReceivedText(SerialPort1.ReadLine()) ' read until line end

Dim datain As String = ""

Dim numbytes As Integer = SerialPort1.BytesToRead

For i As Integer = 1 To numbytes

datain &= Chr(SerialPort1.ReadChar)

Next

test(datain)

End Sub

Private Sub SetText(ByVal [text] As String)

' InvokeRequired required compares the thread ID of the'

' calling thread to the thread ID of the creating thread.'

' If these threads are different, it returns true.'

If Me.TextBox26.InvokeRequired Then

Dim d As New SetTextCallback(AddressOf SetText)

Me.Invoke(d, New Object() {[text]})

Else

Me.TextBox26.Text = [text]

End If

End Sub

Private Sub test(ByVal indata As String)

rcvdata &= indata

SetText(rcvdata)

End Sub
Private Sub ReceivedText(ByVal [text] As String)

'compares the ID of the creating Thread to the ID of the calling Thread

If TextBox26.InvokeRequired Then

Dim x As New SetTextCallback(AddressOf ReceivedText)

Me.Invoke(x, New Object() {(text)})

Else

'Me.txtRX.Text &= [text]

TextBox26.AppendText(text & vbCrLf)

'txtRX2.AppendText(Convert.ToInt32(text, 16) & vbCrLf)

'txtRX2.AppendText(Hex(text) & vbCrLf)

txtRX2.AppendText(StrToHex(text) & vbCrLf)

rxd = text

If rxd = "#" Then

MsgBox("This is a test")

End If

End If

End Sub

Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles ComboBox2.SelectedIndexChanged

If ComboBox2.Text = "" Then

Else

If SerialPort1.IsOpen = False Then


SerialPort1.PortName = ComboBox2.Text

Else

MsgBox("Port is in use", vbCritical)

End If

End If

End Sub

' # debug test

'Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


Timer1.Tick

' 'Timer1.Stop()

' 'add delayed code here

' 'SerialPort1.Write(txtSMS.Text & Chr(26) & vbCr)

'End Sub

' # debug test for breaking events

Sub Delay(ByVal dblSecs As Double)

'From http://pastebin.com/2bSWZ16p

Const OneSec As Double = 1.0# / (1440.0# * 60.0#)

Dim dblWaitTil As Date

Now.AddSeconds(OneSec)

dblWaitTil = Now.AddSeconds(OneSec).AddSeconds(dblSecs)

Do Until Now > dblWaitTil

Application.DoEvents() 'Allow windows messages to be processed

Loop
End Sub

Private Function ByteArrayToHexString(ByVal data() As Byte) As String

Dim sb As New System.Text.StringBuilder(data.Length * 3)

For Each b As Byte In data

sb.Append(Convert.ToString(b, 16).PadLeft(2, "0"c).PadRight(3, " "c))

Next

Return sb.ToString.ToUpper

End Function

Public Function StrToHex(ByRef Data As String) As String

Dim sVal As String

Dim sHex As String = ""

While Data.Length > 0

sVal = Conversion.Hex(Strings.Asc(Data.Substring(0, 1).ToString()))

Data = Data.Substring(1, Data.Length - 1)

sHex = sHex & " " & sVal

End While

Return sHex

End Function

Public Sub retrieveMessages()

Dim nam = "signin"


Try

myconnection.Open()

Dim cmd As OleDbCommand = New OleDbCommand("SELECT timeset FROM controlsignout


WHERE flag='" & nam & "'", myconnection)

Dim dr As OleDbDataReader = cmd.ExecuteReader

Dim userfound As Boolean = False

While dr.Read

TextBox39.Text = dr("timeset")

End While

myconnection.Close()

Catch ex As Exception

MsgBox(ex.Message)

myconnection.Close()

End Try

Dim nam1 = "signout"

Try

myconnection.Open()

Dim cmd1 As OleDbCommand = New OleDbCommand("SELECT timeset FROM controlsignout


WHERE flag='" & nam1 & "'", myconnection)

Dim dr1 As OleDbDataReader = cmd1.ExecuteReader

Dim userfound1 As Boolean = False


While dr1.Read

TextBox40.Text = dr1("timeset")

End While

myconnection.Close()

Catch ex As Exception

MsgBox(ex.Message)

myconnection.Close()

End Try

Dim nam2 = "absentsms"

Try

myconnection.Open()

Dim cmd2 As OleDbCommand = New OleDbCommand("SELECT timeset FROM controlsignout


WHERE flag='" & nam2 & "'", myconnection)

Dim dr2 As OleDbDataReader = cmd2.ExecuteReader

Dim userfound2 As Boolean = False

While dr2.Read

TextBox9.Text = dr2("timeset")

End While

myconnection.Close()

Catch ex As Exception

MsgBox(ex.Message)

myconnection.Close()

End Try
End Sub

Public Sub staffRetrieveMessages()

Dim nam = "staff_signin"

Try

myconnection.Open()

Dim cmd As OleDbCommand = New OleDbCommand("SELECT timeset FROM controlsignout


WHERE flag='" & nam & "'", myconnection)

Dim dr As OleDbDataReader = cmd.ExecuteReader

Dim userfound As Boolean = False

While dr.Read

tbStaffSignin.Text = dr("timeset")

End While

myconnection.Close()

Catch ex As Exception

MsgBox(ex.Message)

myconnection.Close()

End Try

Dim nam1 = "staff_signout"

Try

myconnection.Open()

Dim cmd1 As OleDbCommand = New OleDbCommand("SELECT timeset FROM controlsignout


WHERE flag='" & nam1 & "'", myconnection)
Dim dr1 As OleDbDataReader = cmd1.ExecuteReader

Dim userfound1 As Boolean = False

While dr1.Read

tbStaffSignOut.Text = dr1("timeset")

End While

myconnection.Close()

Catch ex As Exception

MsgBox(ex.Message)

myconnection.Close()

End Try

Dim nam2 = "staff_absent"

Try

myconnection.Open()

Dim cmd2 As OleDbCommand = New OleDbCommand("SELECT timeset FROM controlsignout


WHERE flag='" & nam2 & "'", myconnection)

Dim dr2 As OleDbDataReader = cmd2.ExecuteReader

Dim userfound2 As Boolean = False

While dr2.Read

tbAbsentMessage.Text = dr2("timeset")

End While

myconnection.Close()
Catch ex As Exception

MsgBox(ex.Message)

myconnection.Close()

End Try

End Sub

Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


BunifuButton19.Click

If TextBox39.Text.Trim = "" Then

MsgBox("The Sign-In message field cannot be empty.")

Else

' CODE INSERT

Dim sqlupdate As String

Dim time As String = "signin"

sqlupdate = "UPDATE controlsignout SET timeset=@timeset WHERE flag='" & time & "'"

Dim cmd As New OleDbCommand(sqlupdate, myconnection)

cmd.Parameters.Add(New OleDbParameter("@timeset", TextBox39.Text))

Try

myconnection.Open()

If MessageBox.Show("Are you sure you want to update the Sign-In message?", "Change",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then
If (cmd.ExecuteNonQuery() > 0) Then

MsgBox("The Sign-In message was updated successfully.")

myconnection.Close()

retrieveMessages()

End If

End If

Catch ex As Exception

MsgBox(ex.Message)

Finally

myconnection.Close()

End Try

End If

End Sub

Private Sub Button18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


BunifuButton20.Click

If TextBox40.Text.Trim = "" Then

MsgBox("The Sign-Out message field cannot be empty.")

Else

' CODE INSERT

Dim sqlupdate As String

Dim time As String = "signout"

sqlupdate = "UPDATE controlsignout SET timeset=@timeset WHERE flag='" & time & "'"
Dim cmd As New OleDbCommand(sqlupdate, myconnection)

cmd.Parameters.Add(New OleDbParameter("@timeset", TextBox40.Text))

Try

myconnection.Open()

If MessageBox.Show("Are you sure you want to update the Sign-Out message?", "Change",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

If (cmd.ExecuteNonQuery() > 0) Then

MsgBox("The Sign-Out message was updated successfully.")

myconnection.Close()

retrieveMessages()

End If

End If

Catch ex As Exception

MsgBox(ex.Message)

Finally

myconnection.Close()

End Try

End If

End Sub

Private Sub ComboBox12_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles ComboBox12.SelectedIndexChanged

Label66.Text = 0

cls1 = ComboBox12.SelectedItem

If RadioButton9.Checked = True Then

Dim sql As String

sql = "SELECT Id, Firstname, lastname, Gender, Guardiannumber1, Department, class FROM
students WHERE class='" & cls1 & "'"

Dim adapter As New OleDbDataAdapter(sql, myconnection)

Dim dt As New DataTable("students")

adapter.Fill(dt)

DataGridView4.DataSource = dt

End If

End Sub

Private Sub ComboBox13_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles ComboBox13.SelectedIndexChanged

Label66.Text = 0

drpt1 = ComboBox13.SelectedItem

If RadioButton10.Checked = True Then

Dim sql As String

sql = "SELECT Id, Firstname, lastname, Gender, Guardiannumber1, Department, class FROM
students WHERE department='" & drpt1 & "'"

Dim adapter As New OleDbDataAdapter(sql, myconnection)

Dim dt As New DataTable("students")

adapter.Fill(dt)

DataGridView4.DataSource = dt
End If

End Sub

Private Sub RadioButton10_CheckedChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles RadioButton10.CheckedChanged

Label66.Text = 0

Dim dtt As New DataTable("studentss")

eDA.SelectCommand = New OleDbCommand("SELECT Id, Firstname, lastname, Gender,


Guardiannumber1, Department as [Level], class FROM students", myconnection)

eDS.Clear()

eDA.Fill(dtt)

DataGridView4.DataSource = dtt

If RadioButton10.Checked = True Then

DataGridView4.Show()

ComboBox13.Enabled = True

ComboBox12.Enabled = False

TextBox38.Enabled = False

Else

DataGridView4.Hide()

ComboBox13.Enabled = False

ComboBox13.Text = ""

ComboBox12.Enabled = True
TextBox38.Enabled = True

End If

End Sub

Private Sub RadioButton9_CheckedChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles RadioButton9.CheckedChanged

Label66.Text = 0

Dim dtt As New DataTable("studentss")

eDA.SelectCommand = New OleDbCommand("SELECT Id, Firstname, lastname, Gender,


Guardiannumber1, Department as [Level], Class FROM students", myconnection)

eDS.Clear()

eDA.Fill(dtt)

DataGridView4.DataSource = dtt

If RadioButton9.Checked = True Then

DataGridView4.Show()

ComboBox12.Enabled = True

ComboBox13.Enabled = False

TextBox38.Enabled = False

Else

DataGridView4.Hide()

ComboBox12.Enabled = False

ComboBox12.Text = ""
ComboBox13.Enabled = True

TextBox38.Enabled = True

End If

End Sub

Private Sub RadioButton8_CheckedChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs)

Label66.Text = 0

Dim dtt As New DataTable("studentss")

eDA.SelectCommand = New OleDbCommand("SELECT Id, Firstname, lastname, Gender,


Guardiannumber1, Department, class FROM students", myconnection)

eDS.Clear()

eDA.Fill(dtt)

DataGridView4.DataSource = dtt

End Sub

Private Sub DataGridView4_CellClick1(ByVal sender As Object, ByVal e As


System.Windows.Forms.DataGridViewCellEventArgs)

Try

If RadioButton5.Checked = True Then

TextBox38.Text = DataGridView4.Rows(e.RowIndex).Cells(1).Value.ToString

End If

'TextBox32.Text = DataGridView4.Rows(e.RowIndex).Cells(2).Value.ToString

Catch ex As Exception

'MsgBox(ex.Message)

End Try

End Sub
#Region "header 1 for gridview4"

Private headerCheckBox As CheckBox = New CheckBox()

Private Sub BindGrid()

Using con As OleDbConnection = New OleDbConnection(provider)

Using cmd As OleDbCommand = New OleDbCommand("SELECT Id, Firstname, lastname, Gender,


Guardiannumber1, Department, Class FROM students", con)

cmd.CommandType = CommandType.Text

Using sda As OleDbDataAdapter = New OleDbDataAdapter(cmd)

Using dt As DataTable = New DataTable()

sda.Fill(dt)

DataGridView4.DataSource = dt

End Using

End Using

End Using

End Using

'Add a CheckBox Column to the DataGridView Header Cell.

'Find the Location of Header Cell.

'Dim headerCellLocation As Point = Me.DataGridView4.GetCellDisplayRectangle(0, -1, True).Location

''Place the Header CheckBox in the Location of the Header Cell.

'headerCheckBox.Location = New Point(headerCellLocation.X + 8, headerCellLocation.Y + 2)

headerCheckBox.BackColor = Color.White

'headerCheckBox.Size = New Size(18, 18)


headerCheckBox.Width = 15

'Assign Click event to the Header CheckBox.

AddHandler headerCheckBox.Click, AddressOf HeaderCheckBox_Clicked

DataGridView4.Controls.Add(headerCheckBox)

'Add a CheckBox Column to the DataGridView at the first position.

Dim checkBoxColumn As DataGridViewCheckBoxColumn = New DataGridViewCheckBoxColumn()

checkBoxColumn.HeaderText = ""

checkBoxColumn.Width = 30

checkBoxColumn.Name = "checkBoxColumn"

DataGridView4.Columns.Insert(0, checkBoxColumn)

'Assign Click event to the DataGridView Cell.

AddHandler DataGridView4.CellContentClick, AddressOf DataGridView_CellClick

End Sub

Private Sub HeaderCheckBox_Clicked(ByVal sender As Object, ByVal e As EventArgs)

'Necessary to end the edit mode of the Cell.

DataGridView4.EndEdit()

'Loop and check and uncheck all row CheckBoxes based on Header Cell CheckBox.

For Each row As DataGridViewRow In DataGridView4.Rows

Dim checkBox As DataGridViewCheckBoxCell = (TryCast(row.Cells("checkBoxColumn"),


DataGridViewCheckBoxCell))

checkBox.Value = headerCheckBox.Checked

Next
End Sub

Private Sub DataGridView_CellClick(ByVal sender As Object, ByVal e As DataGridViewCellEventArgs)

'Check to ensure that the row CheckBox is clicked.

If e.RowIndex >= 0 AndAlso e.ColumnIndex = 0 Then

'Loop to verify whether all row CheckBoxes are checked or not.

Dim isChecked As Boolean = True

For Each row As DataGridViewRow In DataGridView4.Rows

If Convert.ToBoolean(row.Cells("checkBoxColumn").EditedFormattedValue) = False Then

isChecked = False

Exit For

End If

Next

headerCheckBox.Checked = isChecked

End If

End Sub

Sub DataGridView4_CurrentCellDirtyStateChanged(

ByVal sender As Object, ByVal e As EventArgs) Handles DataGridView4.CurrentCellDirtyStateChanged

If DataGridView4.IsCurrentCellDirty Then

DataGridView4.CommitEdit(DataGridViewDataErrorContexts.Commit)

End If
End Sub

Public Sub DataGridView4_CellValueChanged(ByVal sender As Object, ByVal e As


DataGridViewCellEventArgs) Handles DataGridView4.CellValueChanged

Console.WriteLine("we involked")

If DataGridView4.Columns(e.ColumnIndex).Name = "checkBoxColumn" Then

Dim count1 As Integer = 0

For Each row As DataGridViewRow In DataGridView4.Rows

Console.WriteLine("number yoo" & count1)

If row.Cells("checkBoxColumn").Value IsNot Nothing And row.Cells("checkBoxColumn").Value =


True Then

count1 += 1

Else

End If

Next

Label66.Text = count1

End If

End Sub

#End Region

Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

'Label2.Text = Trim(Mid(ComboBox2.Text, 1, 5))

If SerialPort1.IsOpen Then
SerialPort1.Close()

If SerialPort1.IsOpen Then

Label13.Text = "CONNECTED"

Else

Label13.Text = "DISCONNECTED"

ActiveControl = txtid

End If

Else

Try

With SerialPort1

.PortName = "COM4"

.BaudRate = 9600

.Parity = IO.Ports.Parity.None

.DataBits = 8

.StopBits = IO.Ports.StopBits.One

.Handshake = IO.Ports.Handshake.None

.RtsEnable = True

.ReceivedBytesThreshold = 1

.NewLine = vbCr

.ReadTimeout = 1000

.Open()

End With

If SerialPort1.IsOpen Then

Label13.Text = "Connected"
ActiveControl = txtid

' Txtid.Focus()

Else

Label13.Text = "got some errors"

End If

Catch ex As Exception

MsgBox(ex.Message)

End Try

End If

End Sub

Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


Button16.Click

If ComboBox2.Text = "" Then

MsgBox("A COM Port must be selected.")

Else

SerialPort1.PortName = ComboBox2.Text 'Set COM port

SerialPort1.BaudRate = "115200" 'Set Baud rate

'Other Serial Port Property

SerialPort1.Parity = IO.Ports.Parity.None

SerialPort1.StopBits = IO.Ports.StopBits.One

SerialPort1.DataBits = 8 'Open serial port

SerialPort1.ReadTimeout = 2000

SerialPort1.WriteTimeout = 2000

Try
SerialPort1.Open()

Catch ex As Exception

MsgBox("Please check that the right COM Port is selected and make sure that the modem is
powered and connected.")

End Try

If SerialPort1.IsOpen Then

Label13.Text = "Connected"

'Label90.Text = "Connected"

Button16.Enabled = False

ComboBox2.Enabled = False

Label13.ForeColor = Color.Green

'Label90.ForeColor = Color.Green

Else

'Label13.Text = "Disconnected"

'Label90.Text = "Disconnected"

End If

End If

End Sub

Private Sub BunifuButton12_Click(sender As Object, e As EventArgs) Handles BunifuButton12.Click

Try

SerialPort1.Close()
If SerialPort1.IsOpen Then

'Label13.Text = "Connected"

'Label90.Text = "Connected"

Else

Label13.Text = "Disconnected"

'Label90.Text = "Disconnected"

Button16.Enabled = True

ComboBox2.Enabled = True

ComboBox2.Text = ""

Label13.ForeColor = Color.Red

'Label90.ForeColor = Color.Red

End If

Catch ex As Exception

End Try

End Sub

Private Sub rdToSelected_CheckedChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles rdToSelected.CheckedChanged

Label66.Text = 0

Dim dtt As New DataTable("studentss")

eDA.SelectCommand = New OleDbCommand("SELECT Id, Firstname, lastname, Gender,


Guardiannumber1, Department as [Level], class FROM students", myconnection)

eDS.Clear()

eDA.Fill(dtt)
DataGridView4.DataSource = dtt

If rdToSelected.Checked = True Then

DataGridView4.Show()

Else

DataGridView4.Hide()

End If

End Sub

Private Sub chkEnableAuto_CheckedChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles chkEnableAuto.CheckedChanged

If chkEnableAuto.Checked = True Then

chkDisableAuto.Checked = False

ChkEnableAll.Checked = False

chkSignin.Checked = True

chkSignout.Checked = False

CheckBox1.Checked = False

chkSignin.Enabled = True

chkSignout.Enabled = True

CheckBox1.Enabled = True

Button20.Enabled = True

' CODE INSERT


Dim sqlupdate As String

Dim opt As String = "EnableSms"

Dim state As String = "True"

sqlupdate = "UPDATE controlsignout SET timeset=@timeset WHERE flag='" & opt & "'"

Dim cmd As New OleDbCommand(sqlupdate, myconnection)

cmd.Parameters.Add(New OleDbParameter("@timeset", state))

Try

myconnection.Open()

cmd.ExecuteNonQuery()

Catch ex As Exception

MsgBox(ex.Message)

Finally

myconnection.Close()

End Try

Else

' CODE INSERT

Dim sqlupdate As String

Dim opt As String = "EnableSms"

Dim state As String = "False"

sqlupdate = "UPDATE controlsignout SET timeset=@timeset WHERE flag='" & opt & "'"
Dim cmd As New OleDbCommand(sqlupdate, myconnection)

cmd.Parameters.Add(New OleDbParameter("@timeset", state))

Try

myconnection.Open()

cmd.ExecuteNonQuery()

Catch ex As Exception

MsgBox(ex.Message)

Finally

myconnection.Close()

End Try

End If

End Sub

Private Sub chkDisableAuto_CheckedChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles chkDisableAuto.CheckedChanged

If chkDisableAuto.Checked = True Then

chkSignin.Checked = False

chkSignout.Checked = False

CheckBox1.Checked = False

ChkEnableAll.Checked = False

chkEnableAuto.Checked = False
chkSignin.Enabled = False

chkSignout.Enabled = False

CheckBox1.Enabled = False

Button20.Enabled = False

' CODE INSERT

Dim sqlupdate As String

Dim opt As String = "DisableSms"

Dim state As String = "True"

sqlupdate = "UPDATE controlsignout SET timeset=@timeset WHERE flag='" & opt & "'"

Dim cmd As New OleDbCommand(sqlupdate, myconnection)

cmd.Parameters.Add(New OleDbParameter("@timeset", state))

Try

myconnection.Open()

cmd.ExecuteNonQuery()

Catch ex As Exception

MsgBox(ex.Message)

Finally

myconnection.Close()

End Try

Else

' CODE INSERT


Dim sqlupdate As String

Dim opt As String = "DisableSms"

Dim state As String = "False"

sqlupdate = "UPDATE controlsignout SET timeset=@timeset WHERE flag='" & opt & "'"

Dim cmd As New OleDbCommand(sqlupdate, myconnection)

cmd.Parameters.Add(New OleDbParameter("@timeset", state))

Try

myconnection.Open()

cmd.ExecuteNonQuery()

Catch ex As Exception

MsgBox(ex.Message)

Finally

myconnection.Close()

End Try

End If

End Sub

Private Sub chkSignin_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles chkSignin.CheckedChanged

If chkSignin.Checked = True Then


' CODE INSERT

Dim sqlupdate As String

Dim opt As String = "SigninSms"

Dim state As String = "True"

sqlupdate = "UPDATE controlsignout SET timeset=@timeset WHERE flag='" & opt & "'"

Dim cmd As New OleDbCommand(sqlupdate, myconnection)

cmd.Parameters.Add(New OleDbParameter("@timeset", state))

Try

myconnection.Open()

cmd.ExecuteNonQuery()

Catch ex As Exception

MsgBox(ex.Message)

Finally

myconnection.Close()

End Try

Else

' CODE INSERT

Dim sqlupdate As String

Dim opt As String = "SigninSms"

Dim state As String = "False"


sqlupdate = "UPDATE controlsignout SET timeset=@timeset WHERE flag='" & opt & "'"

Dim cmd As New OleDbCommand(sqlupdate, myconnection)

cmd.Parameters.Add(New OleDbParameter("@timeset", state))

Try

myconnection.Open()

cmd.ExecuteNonQuery()

Catch ex As Exception

MsgBox(ex.Message)

Finally

myconnection.Close()

End Try

If Not chkSignin.Checked And Not CheckBox1.Checked And Not chkSignout.Checked Then

'MsgBox("At least 1 checkbox must be checked")

chkSignin.Checked = True

Exit Sub

End If

End If

End Sub

Private Sub chkSignout_CheckedChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles chkSignout.CheckedChanged

If chkSignout.Checked = True Then


' CODE INSERT

Dim sqlupdate As String

Dim opt As String = "SignoutSms"

Dim state As String = "True"

sqlupdate = "UPDATE controlsignout SET timeset=@timeset WHERE flag='" & opt & "'"

Dim cmd As New OleDbCommand(sqlupdate, myconnection)

cmd.Parameters.Add(New OleDbParameter("@timeset", state))

Try

myconnection.Open()

cmd.ExecuteNonQuery()

Catch ex As Exception

MsgBox(ex.Message)

Finally

myconnection.Close()

End Try

Else

' CODE INSERT

Dim sqlupdate As String

Dim opt As String = "SignoutSms"


Dim state As String = "False"

sqlupdate = "UPDATE controlsignout SET timeset=@timeset WHERE flag='" & opt & "'"

Dim cmd As New OleDbCommand(sqlupdate, myconnection)

cmd.Parameters.Add(New OleDbParameter("@timeset", state))

Try

myconnection.Open()

cmd.ExecuteNonQuery()

Catch ex As Exception

MsgBox(ex.Message)

Finally

myconnection.Close()

End Try

If Not chkSignout.Checked And Not chkSignin.Checked And Not CheckBox1.Checked Then

'MsgBox("At least 1 checkbox must be checked")

chkSignout.Checked = True

Exit Sub

End If

End If

End Sub

Public Sub RetrieveChkSms()


Dim rdcheck As String = ""

Dim nam = "EnableSms"

Try

myconnection.Open()

Dim cmd As OleDbCommand = New OleDbCommand("SELECT timeset FROM controlsignout


WHERE flag='" & nam & "'", myconnection)

Dim dr As OleDbDataReader = cmd.ExecuteReader

Dim userfound As Boolean = False

While dr.Read

rdcheck = dr("timeset")

End While

myconnection.Close()

Catch ex As Exception

MsgBox(ex.Message)

myconnection.Close()

End Try

'disable code

Dim rdcheck1 As String = ""

Dim nam1 = "DisableSms"

Try

myconnection.Open()
Dim cmd1 As OleDbCommand = New OleDbCommand("SELECT timeset FROM controlsignout
WHERE flag='" & nam1 & "'", myconnection)

Dim dr1 As OleDbDataReader = cmd1.ExecuteReader

Dim userfound As Boolean = False

While dr1.Read

rdcheck1 = dr1("timeset")

End While

myconnection.Close()

Catch ex As Exception

MsgBox(ex.Message)

myconnection.Close()

End Try

'signin code

Dim rdcheck2 As String = ""

Dim nam2 = "SigninSms"

Try

myconnection.Open()

Dim cmd2 As OleDbCommand = New OleDbCommand("SELECT timeset FROM controlsignout


WHERE flag='" & nam2 & "'", myconnection)

Dim dr2 As OleDbDataReader = cmd2.ExecuteReader


Dim userfound As Boolean = False

While dr2.Read

rdcheck2 = dr2("timeset")

End While

myconnection.Close()

Catch ex As Exception

MsgBox(ex.Message)

myconnection.Close()

End Try

Dim rdcheck3 As String = ""

Dim nam3 = "SignoutSms"

Try

myconnection.Open()

Dim cmd3 As OleDbCommand = New OleDbCommand("SELECT timeset FROM controlsignout


WHERE flag='" & nam3 & "'", myconnection)

Dim dr3 As OleDbDataReader = cmd3.ExecuteReader

Dim userfound As Boolean = False

While dr3.Read

rdcheck3 = dr3("timeset")

End While
myconnection.Close()

Catch ex As Exception

MsgBox(ex.Message)

myconnection.Close()

End Try

Dim rdcheck4 As String = ""

Dim nam4 = "absentchk"

Try

myconnection.Open()

Dim cmd4 As OleDbCommand = New OleDbCommand("SELECT timeset FROM controlsignout


WHERE flag='" & nam4 & "'", myconnection)

Dim dr4 As OleDbDataReader = cmd4.ExecuteReader

Dim userfound As Boolean = False

While dr4.Read

rdcheck4 = dr4("timeset")

End While

myconnection.Close()

Catch ex As Exception

MsgBox(ex.Message)

myconnection.Close()

End Try
Dim rdcheck5 As String = ""

Dim nam5 = "Enableall"

Try

myconnection.Open()

Dim cmd5 As OleDbCommand = New OleDbCommand("SELECT timeset FROM controlsignout


WHERE flag='" & nam5 & "'", myconnection)

Dim dr5 As OleDbDataReader = cmd5.ExecuteReader

Dim userfound As Boolean = False

While dr5.Read

rdcheck5 = dr5("timeset")

End While

myconnection.Close()

Catch ex As Exception

MsgBox(ex.Message)

myconnection.Close()

End Try

If rdcheck = "True" Then

chkEnableAuto.Checked = True

chkSignin.Checked = True

chkSignout.Checked = True

Else

chkEnableAuto.Checked = False
End If

If rdcheck1 = "True" Then

chkDisableAuto.Checked = True

Else

chkDisableAuto.Checked = False

End If

If rdcheck2 = "True" Then

chkSignin.Checked = True

Else

chkSignin.Checked = False

End If

If rdcheck3 = "True" Then

chkSignout.Checked = True

Else

chkSignout.Checked = False

End If

If rdcheck4 = "True" Then

CheckBox1.Checked = True

Else

CheckBox1.Checked = False

End If
If rdcheck5 = "True" Then

ChkEnableAll.Checked = True

Else

ChkEnableAll.Checked = False

End If

End Sub

Public Sub RetrieveStaffChkSms()

Dim rdcheck As String = ""

Dim nam = "enableManualSMS"

Try

myconnection.Open()

Dim cmd As OleDbCommand = New OleDbCommand("SELECT timeset FROM controlsignout


WHERE flag='" & nam & "'", myconnection)

Dim dr As OleDbDataReader = cmd.ExecuteReader

Dim userfound As Boolean = False

While dr.Read

rdcheck = dr("timeset")

End While

myconnection.Close()

Catch ex As Exception

MsgBox(ex.Message)
myconnection.Close()

End Try

'disable code

Dim rdcheck1 As String = ""

Dim nam1 = "disableAllSMS"

Try

myconnection.Open()

Dim cmd1 As OleDbCommand = New OleDbCommand("SELECT timeset FROM controlsignout


WHERE flag='" & nam1 & "'", myconnection)

Dim dr1 As OleDbDataReader = cmd1.ExecuteReader

Dim userfound As Boolean = False

While dr1.Read

rdcheck1 = dr1("timeset")

End While

myconnection.Close()

Catch ex As Exception

MsgBox(ex.Message)

myconnection.Close()

End Try

'signin code
Dim rdcheck2 As String = ""

Dim nam2 = "staffSigninChk"

Try

myconnection.Open()

Dim cmd2 As OleDbCommand = New OleDbCommand("SELECT timeset FROM controlsignout


WHERE flag='" & nam2 & "'", myconnection)

Dim dr2 As OleDbDataReader = cmd2.ExecuteReader

Dim userfound As Boolean = False

While dr2.Read

rdcheck2 = dr2("timeset")

End While

myconnection.Close()

Catch ex As Exception

MsgBox(ex.Message)

myconnection.Close()

End Try

Dim rdcheck3 As String = ""

Dim nam3 = "staffSignoutChk"

Try

myconnection.Open()

Dim cmd3 As OleDbCommand = New OleDbCommand("SELECT timeset FROM controlsignout


WHERE flag='" & nam3 & "'", myconnection)

Dim dr3 As OleDbDataReader = cmd3.ExecuteReader

Dim userfound As Boolean = False

While dr3.Read

rdcheck3 = dr3("timeset")

End While

myconnection.Close()

Catch ex As Exception

MsgBox(ex.Message)

myconnection.Close()

End Try

Dim rdcheck4 As String = ""

Dim nam4 = "staffAbsentchk"

Try

myconnection.Open()

Dim cmd4 As OleDbCommand = New OleDbCommand("SELECT timeset FROM controlsignout


WHERE flag='" & nam4 & "'", myconnection)

Dim dr4 As OleDbDataReader = cmd4.ExecuteReader

Dim userfound As Boolean = False

While dr4.Read
rdcheck4 = dr4("timeset")

End While

myconnection.Close()

Catch ex As Exception

MsgBox(ex.Message)

myconnection.Close()

End Try

Dim rdcheck5 As String = ""

Dim nam5 = "enableALLStaffSMS"

Try

myconnection.Open()

Dim cmd5 As OleDbCommand = New OleDbCommand("SELECT timeset FROM controlsignout


WHERE flag='" & nam5 & "'", myconnection)

Dim dr5 As OleDbDataReader = cmd5.ExecuteReader

Dim userfound As Boolean = False

While dr5.Read

rdcheck5 = dr5("timeset")

End While

myconnection.Close()

Catch ex As Exception

MsgBox(ex.Message)
myconnection.Close()

End Try

If rdcheck = "True" Then

rbStaffEnableAuto.Checked = True

rbStaffSignin.Checked = True

rbStaffSignout.Checked = True

Else

rbStaffEnableAuto.Checked = False

End If

If rdcheck1 = "True" Then

rbStaffDisableAuto.Checked = True

Else

rbStaffDisableAuto.Checked = False

End If

If rdcheck2 = "True" Then

rbStaffSignin.Checked = True

Else

rbStaffSignin.Checked = False

End If

If rdcheck3 = "True" Then

rbStaffSignout.Checked = True
Else

rbStaffSignout.Checked = False

End If

If rdcheck4 = "True" Then

rbStaffAbsentSms.Checked = True

Else

rbStaffAbsentSms.Checked = False

End If

If rdcheck5 = "True" Then

rbStaffEnableAll.Checked = True

Else

rbStaffEnableAll.Checked = False

End If

End Sub

'Private Sub BunifuToggleSwitch1_CheckedChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles BunifuToggleSwitch1.CheckedChanged

' If BunifuToggleSwitch1.Checked = True Then

' BunifuToggleSwitch1.Checked = False

' psms = "0"

' Else

' End If

'End Sub
'Private Sub BunifuToggleSwitch2_CheckedChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles BunifuToggleSwitch1.CheckedChanged

' If BunifuToggleSwitch1.Checked = True Then

' BunifuToggleSwitch1.Checked = False

' psms = "1"

' Else

' End If

'End Sub

Private Sub BunifuToggleSwitch2_OnValuechange(sender As Object, e As EventArgs) Handles


BunifuToggleSwitch2.OnValuechange

If BunifuToggleSwitch2.Value = True Then

pusms = "1"

Else

pusms = "o"

End If

End Sub

Private Sub twSmsStaff_OnValuechange(sender As Object, e As EventArgs) Handles


twSmsStaff.OnValuechange

If BunifuToggleSwitch2.Value = True Then

staffsms2 = "1"

Else

staffsms2 = "o"

End If

End Sub

Private Sub BunifuToggleSwitch1_OnValuechange(sender As Object, e As EventArgs) Handles


BunifuToggleSwitch1.OnValuechange

If BunifuToggleSwitch1.Value = True Then

psms = "1"

Else

psms = "o"

End If

End Sub

Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


BunifuButton21.Click

If TextBox9.Text.Trim = "" Then

MsgBox("The Absent message field cannot be empty.")

Else

' CODE INSERT

Dim sqlupdate As String

Dim time As String = "absentsms"

sqlupdate = "UPDATE controlsignout SET timeset=@timeset WHERE flag='" & time & "'"

Dim cmd As New OleDbCommand(sqlupdate, myconnection)

cmd.Parameters.Add(New OleDbParameter("@timeset", TextBox9.Text))

Try

myconnection.Open()

If MessageBox.Show("Are you sure you want to update the Absent message?", "Change",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

If (cmd.ExecuteNonQuery() > 0) Then

MsgBox("The Absent message was updated successfully.")

myconnection.Close()

retrieveMessages()

End If

End If

Catch ex As Exception

MsgBox(ex.Message)

Finally

myconnection.Close()

End Try

End If

End Sub

Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles CheckBox1.CheckedChanged

If CheckBox1.Checked = True Then

' CODE INSERT

Dim sqlupdate As String

Dim opt As String = "absentchk"

Dim state As String = "True"

sqlupdate = "UPDATE controlsignout SET timeset=@timeset WHERE flag='" & opt & "'"
Dim cmd As New OleDbCommand(sqlupdate, myconnection)

cmd.Parameters.Add(New OleDbParameter("@timeset", state))

Try

myconnection.Open()

cmd.ExecuteNonQuery()

Catch ex As Exception

MsgBox(ex.Message)

Finally

myconnection.Close()

End Try

Button20.Enabled = False

Else

' CODE INSERT

Dim sqlupdate As String

Dim opt As String = "absentchk"

Dim state As String = "False"

sqlupdate = "UPDATE controlsignout SET timeset=@timeset WHERE flag='" & opt & "'"

Dim cmd As New OleDbCommand(sqlupdate, myconnection)

cmd.Parameters.Add(New OleDbParameter("@timeset", state))


Try

myconnection.Open()

cmd.ExecuteNonQuery()

Catch ex As Exception

MsgBox(ex.Message)

Finally

myconnection.Close()

End Try

Button20.Enabled = True

If Not CheckBox1.Checked And Not chkSignin.Checked And Not chkSignout.Checked Then

'MsgBox("At least 1 checkbox must be checked")

CheckBox1.Checked = True

Exit Sub

End If

End If

End Sub

Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

sendAbsentsms()

End Sub

Private Sub Button15_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


BunifuButton24.Click
Dim et As DateTime = BunifuTextBox12.Text

Dim auto_sgnt As DateTime = DateTimePicker8.Value.ToLongTimeString

Dim sdrt As DateTime = BunifuTextBox13.Text

If auto_sgnt.TimeOfDay > et.TimeOfDay And auto_sgnt.TimeOfDay < sdrt.TimeOfDay Then

Dim dialog As passwordPrompt = New passwordPrompt()

If dialog.ShowDialog() = DialogResult.OK Then

If dialog.BunifuTextBox1.Text = "" And dialog.BunifuTextBox2.Text = "" Then

MsgBox("Please enter Username and Password.")

Else

Dim userfound As Integer = LoginFunc(dialog.BunifuTextBox1.Text,


dialog.BunifuTextBox2.Text)

If userfound = 1 Then

Dim a As String = DateTimePicker8.Value.ToString("HH:mm")

' CODE INSERT

Dim sqlupdate As String

Dim time As String = "duration"

sqlupdate = "UPDATE controls SET signout_time=@signout_time WHERE time_flag='" &


time & "'"

Dim cmd As New OleDbCommand(sqlupdate, myconnection)


cmd.Parameters.Add(New OleDbParameter("@signout_time", a))

Try

myconnection.Open()

If MessageBox.Show("Are you sure you want to update the Auto Sign-Out Time?",
"Change", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK
Then

If (cmd.ExecuteNonQuery() > 0) Then

MsgBox("The Auto Sign-Out Time was updated successfully.")

myconnection.Close()

retrieveSignout()

SetTarget()

retrieveTime()

End If

End If

Catch ex As Exception

MsgBox(ex.Message)

Finally

myconnection.Close()

End Try

ElseIf userfound = 2 Then

MsgBox("Please enter the Local Admin user credentials.")

Else

MsgBox("The Username or Password is incorrenct.")

End If
End If

End If

dialog.Dispose()

myconnection.Close()

Else

MsgBox("The Auto Sign-Out Time must be later than the current End Time and earlier than the
current Daily Reset Time.")

End If

End Sub

Private Sub Button19_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


BunifuButton25.Click

Dim lt As DateTime = BunifuTextBox10.Text

Dim abt As DateTime = DateTimePicker9.Value.ToLongTimeString

Dim et As DateTime = BunifuTextBox12.Text

If abt.TimeOfDay > lt.TimeOfDay And abt.TimeOfDay <= et.TimeOfDay Then

Dim dialog As passwordPrompt = New passwordPrompt()

If dialog.ShowDialog() = DialogResult.OK Then

If dialog.BunifuTextBox1.Text = "" And dialog.BunifuTextBox2.Text = "" Then

MsgBox("Please enter Username and Password.")

Else
Dim userfound As Integer = LoginFunc(dialog.BunifuTextBox1.Text,
dialog.BunifuTextBox2.Text)

If userfound = 1 Then

Dim a As String = DateTimePicker9.Value.ToString("HH:mm")

'Dim abtym = TextBox5.Text

'Dim dtAM As DateTime = DateTime.Parse(a)

'Dim dtPM As DateTime = DateTime.Parse(abtym)

'If dtAM < dtPM Then

Dim sqlupdate As String

Dim time As String = "duration"

sqlupdate = "UPDATE controls SET absent_time=@absent_time WHERE time_flag='" & time


& "'"

Dim cmd As New OleDbCommand(sqlupdate, myconnection)

cmd.Parameters.Add(New OleDbParameter("@absent_time", a))

Try

myconnection.Open()

If MessageBox.Show("Are you sure you want to update the School's Absent Time?",
"Change", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK
Then

If (cmd.ExecuteNonQuery() > 0) Then

MsgBox("The Absent Time was updated successfully.")

myconnection.Close()
retrieveAbsentOut()

SetTarget1()

retrieveTime()

End If

End If

Catch ex As Exception

MsgBox(ex.Message)

Finally

myconnection.Close()

End Try

'Else

' MsgBox("the value can not be greater than logout time")

'End If

ElseIf userfound = 2 Then

MsgBox("Please enter the Local Admin user credentials.")

Else

MsgBox("The Username or Password is incorrenct.")

End If

End If

End If

dialog.Dispose()

myconnection.Close()

Else
MsgBox("The Absent Time must be later than the current Late Time and earlier than the current
End Time.")

End If

End Sub

Private Sub rdNotSigned_CheckedChanged_1(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles rdNotSigned.CheckedChanged

rptoption = rdNotSigned.Text

End Sub

' Private Sub TabPage8_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles


TabPage8.Enter

' RadioButton1.Checked = True

'' End Sub

Private Sub ChkEnableAll_CheckedChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles ChkEnableAll.CheckedChanged

If ChkEnableAll.Checked = True Then

chkDisableAuto.Checked = False

chkEnableAuto.Checked = False

chkSignin.Checked = True

chkSignout.Checked = True
CheckBox1.Checked = True

chkSignin.Enabled = False

chkSignout.Enabled = False

CheckBox1.Enabled = False

' CODE INSERT

Dim sqlupdate As String

Dim opt As String = "Enableall"

Dim state As String = "True"

sqlupdate = "UPDATE controlsignout SET timeset=@timeset WHERE flag='" & opt & "'"

Dim cmd As New OleDbCommand(sqlupdate, myconnection)

cmd.Parameters.Add(New OleDbParameter("@timeset", state))

Try

myconnection.Open()

cmd.ExecuteNonQuery()

Catch ex As Exception

MsgBox(ex.Message)

Finally

myconnection.Close()

End Try

Else
' CODE INSERT

Dim sqlupdate As String

Dim opt As String = "Enableall"

Dim state As String = "False"

sqlupdate = "UPDATE controlsignout SET timeset=@timeset WHERE flag='" & opt & "'"

Dim cmd As New OleDbCommand(sqlupdate, myconnection)

cmd.Parameters.Add(New OleDbParameter("@timeset", state))

Try

myconnection.Open()

cmd.ExecuteNonQuery()

Catch ex As Exception

MsgBox(ex.Message)

Finally

myconnection.Close()

End Try

End If

End Sub

Private Sub Button20_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


Button20.Click

If TextBox9.Text.Trim = "" Then

MsgBox("The SMS Body field cannot be empty.")


Else

sendAbsentsms()

MsgBox("The absent message was successfully sent.")

myconnection.Close()

End If

End Sub

'Private Sub Button24_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


Button24.Click

'Me.Close()

' End Sub

Private Sub RadioButton5_CheckedChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles RadioButton5.CheckedChanged

Label66.Text = 0

Dim dtt As New DataTable("studentss")

eDA.SelectCommand = New OleDbCommand("SELECT Id, Firstname, lastname, Gender,


Guardiannumber1, Department as [Level], class FROM students", myconnection)

eDS.Clear()

eDA.Fill(dtt)

DataGridView4.DataSource = dtt

If RadioButton5.Checked = True Then

DataGridView4.Show()

TextBox38.Enabled = True

ComboBox12.Enabled = False

ComboBox13.Enabled = False
Else

DataGridView4.Hide()

TextBox38.Enabled = False

TextBox38.Text = ""

ComboBox12.Enabled = True

ComboBox13.Enabled = True

End If

End Sub

Private Sub TextBox38_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles TextBox38.TextChanged

provider = "provider = microsoft.ace.oledb.12.0; data source=studentattendancesystem.accdb;


Persist Security Info=False;"

myconnection.ConnectionString = provider

' SQL Statement so our User can search for either FirstName or LastName

Dim sqlsearch As String

sqlsearch = "SELECT Id, Firstname, lastname, Gender, Guardiannumber1, Department, class FROM
students WHERE id LIKE '%" & TextBox38.Text & "%'" & ""

' Once again we execute the SQL statements against our DataBase

Dim adapter As New OleDbDataAdapter(sqlsearch, myconnection)

' Shows the records and updates the DataGridView

Dim dt As New DataTable("students")

adapter.Fill(dt)

DataGridView4.DataSource = dt

End Sub
' Private Sub Button21_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button21.Click

' Me.Close()

' End Sub

'Private Sub Button23_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


Button23.Click

'Me.Close()

' End Sub

Private Sub Button29_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


Button29.Click

Dim dialog As passwordPrompt = New passwordPrompt()

If dialog.ShowDialog() = DialogResult.OK Then

If dialog.BunifuTextBox1.Text = "" And dialog.BunifuTextBox2.Text = "" Then

MsgBox("please enter username and password")

Else

Dim userfound As Integer = LoginFunc(dialog.BunifuTextBox1.Text, dialog.BunifuTextBox2.Text)

If userfound = 1 Then

BunifuPages1.SetPage("relog")

BunifuTextBox7.Focus()

ElseIf userfound = 2 Then


MsgBox("Please enter the Local Admin user credentials.")

Else

MsgBox("The Username or Password is incorrenct.")

End If

End If

End If

dialog.Dispose()

myconnection.Close()

End Sub

'Private Sub Button25_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


Button25.Click

'Me.Close()

' End Sub

' Private Sub Button26_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


Button26.Click

' Me.Close()

' End Sub

'Private Sub Button27_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


Button27.Click

'Me.Close()

' End Sub

' Private Sub Button28_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


Button28.Click

'Me.Close()

' End Sub

Public Sub usbcon()

'ComboBox4.Items.Clear()

'Dim ports() As String

'ports = Split(ModemsConnected(), "***")

'For i As Integer = 0 To ports.Length - 2

' ComboBox4.Items.Add(ports(i))

'Next

End Sub

#Region "Sending SMS"

Public Function ModemsConnected() As String

Dim modems As String = ""

Try

Dim searcher As New ManagementObjectSearcher(

"root\CIMV2",

"SELECT * FROM Win32_POTSModem")

For Each queryObj As ManagementObject In searcher.Get()

If queryObj("Status") = "OK" Then

modems = modems & (queryObj("AttachedTo") & " - " & queryObj("Description") & "***")

End If
Next

Catch err As ManagementException

MessageBox.Show("An error occurred while querying for WMI data: " & err.Message)

Return ""

End Try

Return modems

End Function

Private Sub Button12_Click_1(sender As Object, e As EventArgs) Handles BunifuButton17.Click

Dim sdrtT As DateTime = BunifuTextBox13.Text

Dim sdrt As DateTime = DateTimePicker7.Value.ToLongTimeString

Dim strt As DateTime = TextBox5.Text

If sdrt.TimeOfDay > sdrtT.TimeOfDay Or sdrt.TimeOfDay > strt.TimeOfDay Then

Dim dialog As passwordPrompt = New passwordPrompt()

If dialog.ShowDialog() = DialogResult.OK Then

If dialog.BunifuTextBox1.Text = "" And dialog.BunifuTextBox2.Text = "" Then

MsgBox("Please enter Username and Password.")

Else

Dim userfound As Integer = LoginFunc(dialog.BunifuTextBox1.Text,


dialog.BunifuTextBox2.Text)

If userfound = 1 Then
' CODE INSERT

Dim sqlupdate As String

Dim time As String = "duration"

Dim a As String = DateTimePicker7.Value.ToString("HH:mm tt") 'change to 24

sqlupdate = "UPDATE controls SET user_logintime=@user_logintime WHERE time_flag='" &


time & "'"

Dim cmd As New OleDbCommand(sqlupdate, myconnection)

cmd.Parameters.Add(New OleDbParameter("@user_logintime", a))

Try

myconnection.Open()

If MessageBox.Show("Are you sure you want to update the School's Daily Reset Time?",
"Change", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK
Then

If (cmd.ExecuteNonQuery() > 0) Then

MsgBox("The School's Daily Reset Time was updated successfully.")

myconnection.Close()

retrieveTime()

initilizeLogoutTime()

End If

End If

Catch ex As Exception

MsgBox(ex.Message)

Finally
End Try

ElseIf userfound = 2 Then

MsgBox("Please enter the Local Admin user credentials.")

Else

MsgBox("The Username or Password is incorrenct.")

End If

End If

End If

dialog.Dispose()

myconnection.Close()

Else

MsgBox("The Daily Reset Time must be later than the current Auto Sign-Out Time and also the
current School Start Time.")

End If

End Sub

Private Sub Student_Click(sender As Object, e As EventArgs) Handles Student.Click

If BunifuPages1.SelectedTab Is Editpage Then

If MessageBox.Show("Are you sure you want to leave this page now? Changes will not be saved if
not updated", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) =
Windows.Forms.DialogResult.OK Then

BunifuPages1.SetPage("Dashboard")
For b As Integer = 0 To 3

YearStart.Items.Add(Date.Now.Year - b)

YearEnd.Items.Add(Date.Now.Year - b)

Next

YearStart.Sorted = True

YearEnd.Sorted = True

Me.YearEnd.SelectedIndex = 3

End If

ElseIf BunifuPages1.SelectedTab Is Add Then

If MessageBox.Show("Are you sure you want to leave this page now?", "Warning",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

BunifuPages1.SetPage("Dashboard")

For b As Integer = 0 To 3

YearStart.Items.Add(Date.Now.Year - b)

YearEnd.Items.Add(Date.Now.Year - b)

Next

YearStart.Sorted = True

YearEnd.Sorted = True

Me.YearEnd.SelectedIndex = 3

End If

ElseIf BunifuPages1.SelectedTab Is Relog Then

If MessageBox.Show("Are you sure you want to leave this page now?", "Warning",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

BunifuPages1.SetPage("Dashboard")

For b As Integer = 0 To 3

YearStart.Items.Add(Date.Now.Year - b)
YearEnd.Items.Add(Date.Now.Year - b)

Next

YearStart.Sorted = True

YearEnd.Sorted = True

Me.YearEnd.SelectedIndex = 3

End If

ElseIf BunifuPages1.SelectedTab Is tpAddStuff Then

If MessageBox.Show("Are you sure you want to leave this page now?", "Warning",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

BunifuPages1.SetPage("Dashboard")

For b As Integer = 0 To 3

YearStart.Items.Add(Date.Now.Year - b)

YearEnd.Items.Add(Date.Now.Year - b)

Next

YearStart.Sorted = True

YearEnd.Sorted = True

Me.YearEnd.SelectedIndex = 3

End If

Else

BunifuPages1.SetPage("Dashboard")

For b As Integer = 0 To 3

YearStart.Items.Add(Date.Now.Year - b)

YearEnd.Items.Add(Date.Now.Year - b)

Next

YearStart.Sorted = True

YearEnd.Sorted = True
Me.YearEnd.SelectedIndex = 3

End If

End Sub

Private Sub Dashboard_Click(sender As Object, e As EventArgs) Handles Dashboard.Click

If BunifuPages1.SelectedTab Is Relog Then

If MessageBox.Show("Are you sure you want to leave this page now? Changes will not be saved if
not updated", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) =
Windows.Forms.DialogResult.OK Then

BunifuPages1.SetPage("Student")

End If

ElseIf BunifuPages1.SelectedTab Is Add Then

If MessageBox.Show("Are you sure you want to leave this page now?", "Warning",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

BunifuPages1.SetPage("Student")

End If

ElseIf BunifuPages1.SelectedTab Is Editpage Then

If MessageBox.Show("Are you sure you want to leave this page now?", "Warning",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

BunifuPages1.SetPage("Student")

End If

ElseIf BunifuPages1.SelectedTab Is tpAddStuff Then

If MessageBox.Show("Are you sure you want to leave this page now?", "Warning",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

BunifuPages1.SetPage("Student")

End If

Else
BunifuPages1.SetPage("Student")

End If

End Sub

Private Sub BunifuButton3_Click(sender As Object, e As EventArgs) Handles BunifuButton3.Click

If BunifuPages1.SelectedTab Is Editpage Then

If MessageBox.Show("Are you sure you want to leave this page now? Changes will not be saved if
not updated", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) =
Windows.Forms.DialogResult.OK Then

BunifuPages1.SetPage("AddStudent")

End If

'ElseIf BunifuPages1.SelectedTab Is Add Then

' If MessageBox.Show("Are you sure you want to leave this page now?", "Warning",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

' BunifuPages1.SetPage("AddStudent")

' End If

ElseIf BunifuPages1.SelectedTab Is Relog Then

If MessageBox.Show("Are you sure you want to leave this page now?", "Warning",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

BunifuPages1.SetPage("AddStudent")

End If

ElseIf BunifuPages1.SelectedTab Is tpAddStuff Then

If MessageBox.Show("Are you sure you want to leave this page now?", "Warning",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

BunifuPages1.SetPage("AddStudent")

End If
Else

BunifuPages1.SetPage("AddStudent")

End If

End Sub

Private Sub BunifuButton4_Click(sender As Object, e As EventArgs) Handles BunifuButton4.Click

If BunifuPages1.SelectedTab Is Editpage Then

If MessageBox.Show("Are you sure you want to leave this page now? Changes will not be saved if
not updated", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) =
Windows.Forms.DialogResult.OK Then

BunifuPages1.SetPage("Reports")

End If

ElseIf BunifuPages1.SelectedTab Is Add Then

If MessageBox.Show("Are you sure you want to leave this page now?", "Warning",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

BunifuPages1.SetPage("Reports")

End If

ElseIf BunifuPages1.SelectedTab Is Relog Then

If MessageBox.Show("Are you sure you want to leave this page now?", "Warning",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

BunifuPages1.SetPage("Reports")

End If

ElseIf BunifuPages1.SelectedTab Is tpAddStuff Then

If MessageBox.Show("Are you sure you want to leave this page now?", "Warning",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

BunifuPages1.SetPage("Reports")

End If
Else

BunifuPages1.SetPage("Reports")

End If

End Sub

Private Sub BunifuButton5_Click(sender As Object, e As EventArgs) Handles BunifuButton5.Click

If BunifuPages1.SelectedTab Is Relog Then

If MessageBox.Show("Are you sure you want to leave this page now? Changes will not be saved if
not updated", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) =
Windows.Forms.DialogResult.OK Then

BunifuPages1.SetPage("Sms")

End If

ElseIf BunifuPages1.SelectedTab Is Add Then

If MessageBox.Show("Are you sure you want to leave this page now?", "Warning",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

BunifuPages1.SetPage("Sms")

End If

ElseIf BunifuPages1.SelectedTab Is Editpage Then

If MessageBox.Show("Are you sure you want to leave this page now?", "Warning",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

BunifuPages1.SetPage("Sms")

End If

ElseIf BunifuPages1.SelectedTab Is tpAddStuff Then

If MessageBox.Show("Are you sure you want to leave this page now?", "Warning",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

BunifuPages1.SetPage("Sms")

End If
Else

BunifuPages1.SetPage("Sms")

End If

End Sub

Private Sub BunifuButton6_Click(sender As Object, e As EventArgs) Handles BunifuButton6.Click

If BunifuPages1.SelectedTab Is Relog Then

If MessageBox.Show("Are you sure you want to leave this page now? Changes will not be saved if
not updated", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) =
Windows.Forms.DialogResult.OK Then

BunifuPages1.SetPage("Donglesettings")

End If

ElseIf BunifuPages1.SelectedTab Is Add Then

If MessageBox.Show("Are you sure you want to leave this page now?", "Warning",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

BunifuPages1.SetPage("Donglesettings")

End If

ElseIf BunifuPages1.SelectedTab Is Editpage Then

If MessageBox.Show("Are you sure you want to leave this page now?", "Warning",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

BunifuPages1.SetPage("Donglesettings")

End If

ElseIf BunifuPages1.SelectedTab Is tpAddStuff Then

If MessageBox.Show("Are you sure you want to leave this page now?", "Warning",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

BunifuPages1.SetPage("Donglesettings")

End If
Else

BunifuPages1.SetPage("Donglesettings")

End If

End Sub

Private Sub BunifuButton7_Click(sender As Object, e As EventArgs) Handles BunifuButton7.Click

If BunifuPages1.SelectedTab Is Editpage Then

If MessageBox.Show("Are you sure you want to leave this page now? Changes will not be saved if
not updated", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) =
Windows.Forms.DialogResult.OK Then

BunifuPages1.SetPage("Timesettings")

End If

ElseIf BunifuPages1.SelectedTab Is Add Then

If MessageBox.Show("Are you sure you want to leave this page now?", "Warning",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

BunifuPages1.SetPage("Timesettings")

End If

ElseIf BunifuPages1.SelectedTab Is Relog Then

If MessageBox.Show("Are you sure you want to leave this page now?", "Warning",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

BunifuPages1.SetPage("Timesettings")

End If

ElseIf BunifuPages1.SelectedTab Is tpAddStuff Then

If MessageBox.Show("Are you sure you want to leave this page now?", "Warning",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

BunifuPages1.SetPage("Timesettings")

End If
Else

BunifuPages1.SetPage("Timesettings")

End If

End Sub

Private Sub BunifuButton8_Click(sender As Object, e As EventArgs) Handles BunifuButton8.Click

If BunifuPages1.SelectedTab Is Editpage Then

If MessageBox.Show("Are you sure you want to leave this page now? Changes will not be saved if
not updated", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) =
Windows.Forms.DialogResult.OK Then

BunifuPages1.SetPage("Department")

End If

ElseIf BunifuPages1.SelectedTab Is Add Then

If MessageBox.Show("Are you sure you want to leave this page now?", "Warning",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

BunifuPages1.SetPage("Department")

End If

ElseIf BunifuPages1.SelectedTab Is Relog Then

If MessageBox.Show("Are you sure you want to leave this page now?", "Warning",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

BunifuPages1.SetPage("Department")

End If

ElseIf BunifuPages1.SelectedTab Is tpAddStuff Then

If MessageBox.Show("Are you sure you want to leave this page now?", "Warning",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

BunifuPages1.SetPage("Department")

End If
Else

BunifuPages1.SetPage("Department")

End If

End Sub

Private Sub BunifuButton9_Click(sender As Object, e As EventArgs)

BunifuPages1.SetPage("studentrecords")

End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs)

BunifuPages1.SetPage("Donglesettings")

End Sub

Private Sub Button1_Click_1(sender As Object, e As EventArgs)

BunifuPages1.SetPage("Donglesettings")

End Sub

'Private Sub btnAddstudent_Click_1(sender As Object, e As EventArgs) Handles btnAddstudent.Click

' If txtfirstname.Text.Trim = "" Or txtparentsname.Text.Trim = "" Or TextBox2.Text.Trim = "" Or


txtage.Text.Trim = "" Or TextBox3.Text.Trim = "" Or txtaddress.Text.Trim = "" Or TextBox22.Text.Trim = "" Or
TextBox6.Text.Trim = "" Or TextBox7.Text.Trim = "" Or ComboBox1.Text = "" Or ComboBox7.Text = "" Or
rdmale.Checked = False And rdfemale.Checked = False Then

' MsgBox("Please fill in all required fields marked with ' * '")

' Else

' CODE INSERT

' Dim sqlinsert As String


' We use the INSERT statement which tells our program to add the information

' From the Forms Text fields into the Databases columns.

' sqlinsert = "INSERT INTO students(tag_id, id, firstname, lastname, middlename, gender,
Guardiannumber1,Guardiannumber2, address, address2, city, parish, birthday, age, class,
department,ReceiveSms,PicturePath )" &

' "VALUES( @tag_id, @id, @firstname, @lastname, @middlename, @gender,


@Guardiannumber1,@Guardiannumber2, @address, @address2, @city, @parish, @birthday, @age,
@class, @department, @ReceiveSms,'" & Replace$(BunifuTextBox1.Text, "'", "''") & "' )"

' Dim cmd As New OleDbCommand(sqlinsert, myconnection)

' This assigns the values for our columns in the DataBase.

' To ensure the correct values are written to the correct column

' cmd.Parameters.Add(New OleDbParameter("@tag_id", TextBox3.Text))

' cmd.Parameters.Add(New OleDbParameter("@id", TextBox22.Text))

' cmd.Parameters.Add(New OleDbParameter("@firstname", txtfirstname.Text))

' cmd.Parameters.Add(New OleDbParameter("@lastname", TextBox2.Text))

' cmd.Parameters.Add(New OleDbParameter("@middlename", txtmiddlename.Text))

' cmd.Parameters.Add(New OleDbParameter("@gender", male))

' cmd.Parameters.Add(New OleDbParameter("@Guardiannumber1", txtparentsname.Text))

' cmd.Parameters.Add(New OleDbParameter("@Guardiannumber2", TextBox8.Text))

' cmd.Parameters.Add(New OleDbParameter("@address", txtaddress.Text))

' cmd.Parameters.Add(New OleDbParameter("@address2", TextBox4.Text))

' cmd.Parameters.Add(New OleDbParameter("@city", TextBox6.Text))

' cmd.Parameters.Add(New OleDbParameter("@parish", TextBox7.Text))

' cmd.Parameters.Add(New OleDbParameter("@birthday", DateTimePicker1.Value.Date))

' cmd.Parameters.Add(New OleDbParameter("@age", txtage.Text))

' cmd.Parameters.Add(New OleDbParameter("@class", q))

' cmd.Parameters.Add(New OleDbParameter("@department", p))


' cmd.Parameters.Add(New OleDbParameter("@ReceiveSms", psms))

' This Is what actually writes our changes to the DataBase.

' You have To open the connection, execute the commands And

' then close connection.

' Try

' myconnection.Open()

' If MessageBox.Show("Are you sure the information has been entered correctly?", "Save",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

' If (cmd.ExecuteNonQuery() > 0) Then

' myconnection.Close()

' MsgBox("Student registered successfully!")

' Example1()

' clearfields()

' generate_student_id()

' dailyGraphs()

' update_linked_table()

' RefreshDGV()

' End If

' End If

' Catch ex As Exception

' MsgBox(ex.Message)

' myconnection.Close()

' Finally
' myconnection.Close()

' End Try

' End If

'End Sub

Private Sub btnRecords_Click(sender As Object, e As EventArgs) Handles btnRecords.Click

BunifuPages1.SetPage("records")

End Sub

Private Sub addstudent2_Click(sender As Object, e As EventArgs) Handles addstudent2.Click

BunifuPages1.SetPage("AddStudent")

End Sub

Private Sub BunifuButton34_Click(sender As Object, e As EventArgs) Handles BunifuButton34.Click

If BunifuTextBox52.Text.Trim = "" Or BunifuTextBox18.Text.Trim = "" Or BunifuTextBox44.Text.Trim =


"" Or BunifuTextBox43.Text.Trim = "" Or BunifuTextBox48.Text.Trim = "" Or BunifuTextBox47.Text.Trim = ""
Or BunifuTextBox46.Text.Trim = "" Or BunifuTextBox17.Text.Trim = "" Or BunifuTextBox45.Text.Trim = "" Or
BunifuTextBox54.Text.Trim = "" Or BunifuDropdown11.Text = "" Or BunifuDropdown10.Text = "" Then

MsgBox("Please fill in all required fields marked with ' * '")

Else

Dim sqlupdate As String

sqlupdate = "UPDATE students SET id=@id, firstname=@firstname, lastname=@lastname,


Guardiannumber1=@Guardiannumber1, Guardiannumber2=@Guardiannumber2,
middlename=@middlename, gender=@gender, address=@address," &

"city=@city, postoffice=@postoffice, parish=@parish, birthday=@birthday, age=@age,


class=@class, department=@department, PicturePath=@PicturePath, ReceiveSms=@ReceiveSms
WHERE tag_id='" & BunifuTextBox50.Text & "'"

Dim cmd As New OleDbCommand(sqlupdate, myconnection)

cmd.Parameters.Add(New OleDbParameter("@id", BunifuTextBox49.Text))

cmd.Parameters.Add(New OleDbParameter("@firstname", BunifuTextBox52.Text))

cmd.Parameters.Add(New OleDbParameter("@lastname", BunifuTextBox18.Text))

cmd.Parameters.Add(New OleDbParameter("@Guardiannumber1", BunifuTextBox44.Text))

cmd.Parameters.Add(New OleDbParameter("@Guardiannumber2", BunifuTextBox43.Text))

cmd.Parameters.Add(New OleDbParameter("@middlename", BunifuTextBox51.Text))

cmd.Parameters.Add(New OleDbParameter("@gender", male2))

cmd.Parameters.Add(New OleDbParameter("@address", BunifuTextBox48.Text))

cmd.Parameters.Add(New OleDbParameter("@city", BunifuTextBox46.Text))

cmd.Parameters.Add(New OleDbParameter("@postoffice", BunifuTextBox47.Text))

cmd.Parameters.Add(New OleDbParameter("@parish", BunifuTextBox17.Text))

cmd.Parameters.Add(New OleDbParameter("@birthday", BunifuDatePicker1.Value.Date))

cmd.Parameters.Add(New OleDbParameter("@age", BunifuTextBox45.Text))

cmd.Parameters.Add(New OleDbParameter("@class", BunifuDropdown11.Text))

cmd.Parameters.Add(New OleDbParameter("@department", BunifuDropdown10.Text))

cmd.Parameters.Add(New OleDbParameter("@PicturePath", Replace$(BunifuTextBox54.Text, "'",


"''")))

cmd.Parameters.Add(New OleDbParameter("@ReceiveSms", pusms))


Try

'cmd.ExecuteNonQuery()

'MsgBox("Record updated successfully!")

' BunifuPages1.SetPage("records")

If String.IsNullOrEmpty(myconnection.ConnectionString) Then

provider = "provider = microsoft.ace.oledb.12.0; data


source=studentattendancesystem.accdb; Persist Security Info=False;"

myconnection.ConnectionString = provider

Else

If myconnection.State = ConnectionState.Open Then

Else

myconnection.Open()

End If

End If

If MessageBox.Show("Are you sure you want to update this record?", "UPDATE",


MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

If (cmd.ExecuteNonQuery() > 0) Then

'DeleteNotification("Report successfully deleted!", "System Delete Notification")

MsgBox("Record updated successfully.")

myconnection.Close()

' BunifuPages1.SetPage("records")

End If

Else

myconnection.Close()

End If
Catch ex As Exception

MsgBox(ex.Message)

Finally

myconnection.Close()

End Try

' This are subs in Module1, to clear all the TextBoxes on the form

' and refresh the DataGridView on the MainFsorm to show our new records.

ClearTextBox(Me)

RefreshDGV()

End If

End Sub

Private Sub BunifuButton33_Click(sender As Object, e As EventArgs) Handles BunifuButton33.Click

If MessageBox.Show("Are you sure you want to exit?", "Exit", MessageBoxButtons.OKCancel,


MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

BunifuPages1.SetPage("records")

UpdateClearfields()

Else

End If

End Sub

Public Sub UpdateClearfields()

BunifuTextBox52.Clear()
BunifuTextBox51.Clear()

BunifuTextBox18.Clear()

BunifuTextBox50.Clear()

BunifuTextBox49.Clear()

BunifuTextBox48.Clear()

BunifuTextBox54.Text = My.Application.Info.DirectoryPath & "\images\emptyimage.png"

BunifuTextBox47.Clear()

BunifuTextBox46.Clear()

BunifuTextBox45.Clear()

BunifuTextBox44.Clear()

BunifuTextBox43.Clear()

BunifuTextBox54.Clear()

Label25.Text = 0

txtsearch.Clear()

BunifuDropdown10.Text = ""

BunifuDropdown11.Text = ""

BunifuToggleSwitch2.Value = False

DateTimePicker1.Value = Now

BunifuPictureBox15.Image = Nothing

rdFemaleUpdate.Checked = False

rdMaleUpdate.Checked = False

'BunifuRadioButton1.Checked = True

'retrieveDptUpdate()

'RetrieveToComboUpdate1()

End Sub
Public Sub UpdateClearfieldsNew()

txtStaffID2.Clear()

txtFirstNameStaff2.Clear()

txtLastNameStaff2.Clear()

txtContactStaff2.Clear()

txtAddressStaff2.Clear()

txtAgeStaff2.Clear()

' txtsearch = My.Application.Info.DirectoryPath & "\images\emptyimage.png"

dbLevelStaff.Text = ""

imgboxreplace = ""

Label25.Text = 0

txtsearch.Clear()

twSmsStaff.Value = False

dtpDobStaff2.Value = Now

pbStaffPhoto2.Image = Nothing

rbFemaleStaff2.Checked = False

rbMaleStaff2.Checked = False

End Sub

Private Sub BunifuButton11_Click(sender As Object, e As EventArgs) Handles BunifuButton11.Click

clearfields()

End Sub
Private Sub CheckBox3_CheckedChanged(sender As Object, e As
Bunifu.UI.WinForms.BunifuToggleSwitch.CheckedChangedEventArgs)

End Sub

Private Sub BunifuButton1_Click(sender As Object, e As EventArgs)

BunifuPages1.SetPage("student")

'BunifuTextBox55.Text = ""

End Sub

Private Sub txtid_TextChanged(sender As Object, e As EventArgs) Handles txtid.TextChanged

check_info()

End Sub

Private Sub BunifuButton42_Click(sender As Object, e As EventArgs) Handles BunifuButton42.Click

Me.Close()

End Sub

Private Sub BunifuButton22_Click(sender As Object, e As EventArgs) Handles BunifuButton22.Click

Dim num As Integer = 0

For Each n In ListBox2.Items

If n <> DateTimePicker10.Value.ToShortDateString Then

num += 0

Else

num += 1

End If
Next

If num = 0 Then

ListBox2.Items.Add(DateTimePicker10.Value.ToShortDateString)

End If

End Sub

Private Sub RadioButton7_CheckedChanged(sender As Object, e As EventArgs) Handles


RadioButton7.CheckedChanged

If RadioButton7.Checked = True Then

' CODE INSERT

Dim sqlupdate As String

Dim opt As String = "testmode"

Dim state As String = "True"

sqlupdate = "UPDATE controlsignout SET timeset=@timeset WHERE flag='" & opt & "'"

Dim cmd As New OleDbCommand(sqlupdate, myconnection)

cmd.Parameters.Add(New OleDbParameter("@timeset", state))

Try

myconnection.Open()

cmd.ExecuteNonQuery()

Catch ex As Exception
MsgBox(ex.Message)

Finally

myconnection.Close()

End Try

End If

End Sub

Private Sub RadioButton8_CheckedChanged_1(sender As Object, e As EventArgs) Handles


RadioButton8.CheckedChanged

If RadioButton8.Checked = True Then

' CODE INSERT

Dim sqlupdate As String

Dim opt As String = "testmode"

Dim state As String = "False"

sqlupdate = "UPDATE controlsignout SET timeset=@timeset WHERE flag='" & opt & "'"

Dim cmd As New OleDbCommand(sqlupdate, myconnection)

cmd.Parameters.Add(New OleDbParameter("@timeset", state))

Try

myconnection.Open()

cmd.ExecuteNonQuery()

Catch ex As Exception
MsgBox(ex.Message)

Finally

myconnection.Close()

End Try

End If

End Sub

Private Sub Button5_Click(sender As Object, e As EventArgs)

SerialPort1.Write("AT+CSMP?" & vbCr)

SerialPort1.Write("AT+CSMP=17,167,0,16" & vbCr)

SerialPort1.Write("AT+CNMI=1,2,0,0,0" & vbCr)

End Sub

Private Sub BunifuButton18_Click(sender As Object, e As EventArgs)

Me.Close()

End Sub

Private Sub BunifuButton41_Click(sender As Object, e As EventArgs) Handles BunifuButton41.Click

Dim dialog As passwordPrompt = New passwordPrompt()

If dialog.ShowDialog() = DialogResult.OK Then

If dialog.BunifuTextBox1.Text = "" And dialog.BunifuTextBox2.Text = "" Then


MsgBox("Please enter Username and Password.")

Else

Dim userfound As Integer = LoginFunc(dialog.BunifuTextBox1.Text, dialog.BunifuTextBox2.Text)

If userfound = 1 Then

Try

myconnection.Open()

Dim sqldelete As String

Dim sqldelete1 As String

sqldelete = "DELETE * FROM studentsrecords WHERE date_in=#" &


BunifuDatePicker4.Value.Date & "# "

sqldelete1 = "DELETE * FROM notsignout WHERE date_in=#" &


BunifuDatePicker4.Value.Date & "# "

Dim Dcommand As New OleDbCommand(sqldelete, myconnection)

Dim Dcommand1 As New OleDbCommand(sqldelete1, myconnection)

If MessageBox.Show("Are you sure you want to delete the attendance data for the selected
date?", "DELETE", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) =
Windows.Forms.DialogResult.OK Then

If (Dcommand.ExecuteNonQuery() > 0) Then

Dcommand1.ExecuteNonQuery()

DeleteNotification("Report successfully deleted!", "System Delete Notification")

myconnection.Close()

filldb()

End If

Else

myconnection.Close()
End If

dailyGraphs()

Catch ex As Exception

DeleteNotification("There is Report Data to Delete", "System Delete Notification")

myconnection.Close()

End Try

ElseIf userfound = 2 Then

MsgBox("Please enter the Local Admin user credentials.")

Else

MsgBox("The Username or Password is incorrenct.")

End If

End If

End If

dialog.Dispose()

End Sub

Private Sub BunifuTextBox7_TextChanged_1(sender As Object, e As EventArgs) Handles


BunifuTextBox7.TextChanged

check_info_relog()

End Sub

Private Sub BunifuButton1_Click_1(sender As Object, e As EventArgs) Handles BunifuButton1.Click

BunifuPages1.SetPage("student")

End Sub
Private Sub rdSmsapi_CheckedChanged(sender As Object, e As EventArgs)

If smsApi = True Then

' CODE INSERT

Dim sqlupdate As String

Dim opt As String = "switch"

Dim state As String = "True"

sqlupdate = "UPDATE controlsignout SET timeset=@timeset WHERE flag='" & opt & "'"

Dim cmd As New OleDbCommand(sqlupdate, myconnection)

cmd.Parameters.Add(New OleDbParameter("@timeset", state))

Try

myconnection.Open()

cmd.ExecuteNonQuery()

Catch ex As Exception

MsgBox(ex.Message)

Finally

myconnection.Close()

End Try

End If

End Sub
Private Sub rdGSM_CheckedChanged(sender As Object, e As EventArgs)

If gsm = True Then

' CODE INSERT

Dim sqlupdate As String

Dim opt As String = "switch"

Dim state As String = "False"

sqlupdate = "UPDATE controlsignout SET timeset=@timeset WHERE flag='" & opt & "'"

Dim cmd As New OleDbCommand(sqlupdate, myconnection)

cmd.Parameters.Add(New OleDbParameter("@timeset", state))

Try

myconnection.Open()

cmd.ExecuteNonQuery()

Catch ex As Exception

MsgBox(ex.Message)

Finally

myconnection.Close()

End Try

End If

End Sub
Private Sub Button5_Click_1(sender As Object, e As EventArgs)

'BunifuPages1.SetPage("TabPage2")

End Sub

Private Sub Button6_Click_2(sender As Object, e As EventArgs)

'Dim randomData = New Random()

'Dim data1 As List(Of Double) = New List(Of Double)()

'Dim data2 As List(Of Double) = New List(Of Double)()

'Dim data3 As List(Of Double) = New List(Of Double)()

''bar 1 late

'Dim sql1 As String

'sql1 = "SELECT TOP 6 COUNT(*) as mpn FROM studentsrecords INNER JOIN controls ON
studentsrecords.time_in >= controls.late_time WHERE YEAR(date_in) GROUP BY MONTH(date_in),
YEAR(date_in) ORDER BY MONTH(date_in), YEAR(date_in)"

'Dim adapter1 As New OleDbDataAdapter(sql1, myconnection)

'Dim dt1 As New DataTable("students")

'adapter1.Fill(dt1)

'data1.Add(dt1.Rows(0).Item(0).ToString)

'BunifuBarChart1.Data = data1

'data1.Add(dt1.Rows(1).Item(0).ToString)

'BunifuBarChart1.Data = data1
'data1.Add(dt1.Rows(2).Item(0).ToString)

'BunifuBarChart1.Data = data1

'data1.Add(dt1.Rows(3).Item(0).ToString)

'BunifuBarChart1.Data = data1

'data1.Add(dt1.Rows(4).Item(0).ToString)

'BunifuBarChart1.Data = data1

'data1.Add(dt1.Rows(5).Item(0).ToString)

'BunifuBarChart1.Data = data1

''bar 2 early

'Dim sql2 As String

'sql2 = "SELECT TOP 6 COUNT(*) as mpn FROM studentsrecords INNER JOIN controls ON
studentsrecords.time_in <= controls.late_time WHERE YEAR(date_in) GROUP BY MONTH(date_in),
YEAR(date_in) ORDER BY MONTH(date_in), YEAR(date_in)"

'Dim adapter2 As New OleDbDataAdapter(sql2, myconnection)

'Dim dt2 As New DataTable("students")

'adapter2.Fill(dt2)

'data2.Add(dt2.Rows(0).Item(0).ToString)

'BunifuBarChart1.Data = data2

'data2.Add(dt2.Rows(1).Item(0).ToString)

'BunifuBarChart1.Data = data2

'data2.Add(dt2.Rows(2).Item(0).ToString)

'BunifuBarChart1.Data = data2

'data2.Add(dt2.Rows(3).Item(0).ToString)
'BunifuBarChart1.Data = data2

'data2.Add(dt2.Rows(4).Item(0).ToString)

'BunifuBarChart1.Data = data2

'data2.Add(dt2.Rows(5).Item(0).ToString)

'BunifuBarChart1.Data = data2

'''bar 3 absent

'Dim sql3 As String

'sql3 = "SELECT COUNT(*) as numb FROM studentsrecords WHERE flag ='0' and YEAR(date_in)
GROUP BY MONTH(date_in), YEAR(date_in) ORDER BY MONTH(date_in), YEAR(date_in)"

'Dim adapter3 As New OleDbDataAdapter(sql3, myconnection)

'Dim dt3 As New DataTable("students")

'adapter3.Fill(dt3)

'data3.Add(dt3.Rows(0).Item(0).ToString)

'BunifuBarChart1.Data = data3

'data3.Add(dt3.Rows(1).Item(0).ToString)

'BunifuBarChart1.Data = data3

'data3.Add(dt3.Rows(2).Item(0).ToString)

'BunifuBarChart1.Data = data3

'data3.Add(dt3.Rows(3).Item(0).ToString)

'BunifuBarChart1.Data = data3

'data3.Add(dt3.Rows(4).Item(0).ToString)

'BunifuBarChart1.Data = data3

'data3.Add(dt3.Rows(5).Item(0).ToString)
'BunifuBarChart1.Data = data3

'Dim sqlyear As String

'sqlyear = "SELECT TOP 6 MonthName(MONTH(date_in), true) FROM studentsrecords WHERE


YEAR(date_in) GROUP BY MONTH(date_in), YEAR(date_in) ORDER BY MONTH(date_in), YEAR(date_in)"

'Dim adapterYear As New OleDbDataAdapter(sqlyear, myconnection)

'Dim dtYear As New DataTable("students")

'adapterYear.Fill(dtYear)

'BunifuChartCanvas2.Labels = New String() {dtYear.Rows(0).Item(0).ToString(),


dtYear.Rows(1).Item(0).ToString(), dtYear.Rows(2).Item(0).ToString(), dtYear.Rows(3).Item(0).ToString(),
dtYear.Rows(4).Item(0).ToString(), dtYear.Rows(5).Item(0).ToString()}

'Dim sqlyear2 As String

'sqlyear2 = "SELECT YEAR(date_in) FROM studentsrecords WHERE YEAR(date_in) = YEAR(date())


GROUP BY YEAR(date_in) UNION SELECT YEAR(date_in) FROM studentsrecords WHERE YEAR(date_in) =
YEAR(date())-1 GROUP BY YEAR(date_in)"

'Dim adapterYear2 As New OleDbDataAdapter(sqlyear2, myconnection)

'Dim dtYear2 As New DataTable("students")

'adapterYear2.Fill(dtYear2)

'BunifuChartCanvas2.XAxesLabel = "Year " & dtYear2.Rows(1).Item(0).ToString() & "-" &


dtYear2.Rows(0).Item(0).ToString()

'BunifuLineChart1.Data = data1

'BunifuLineChart2.Data = data2

'BunifuLineChart3.Data = data3
'BunifuChartCanvas2.Update()

End Sub

Private Sub Button7_Click_2(sender As Object, e As EventArgs)

Dim data1 As List(Of Double) = New List(Of Double)()

Dim data2 As List(Of Double) = New List(Of Double)()

Dim data3 As List(Of Double) = New List(Of Double)()

'bar 1 late

Dim sql1 As String

sql1 = "SELECT COUNT(*) as numb FROM studentsrecords INNER JOIN controls ON


studentsrecords.time_in >= controls.late_time WHERE YEAR(date_in) = YEAR(date()) GROUP BY
YEAR(date_in) UNION SELECT COUNT(*) as numb FROM studentsrecords INNER JOIN controls ON
studentsrecords.time_in >= controls.late_time WHERE YEAR(date_in) = YEAR(date())-1 GROUP BY
YEAR(date_in)"

Dim adapter1 As New OleDbDataAdapter(sql1, myconnection)

Dim dt1 As New DataTable("students")

adapter1.Fill(dt1)

data1.Add(dt1.Rows(0).Item(0).ToString)

BunifuBarChart1.Data = data1

data1.Add(dt1.Rows(1).Item(0).ToString)

BunifuBarChart1.Data = data1

'bar 2 early

Dim sql2 As String

sql2 = "SELECT COUNT(*) as numb FROM studentsrecords INNER JOIN controls ON


studentsrecords.time_in <= controls.late_time WHERE YEAR(date_in) = YEAR(date()) GROUP BY
YEAR(date_in) UNION SELECT COUNT(*) as numb FROM studentsrecords INNER JOIN controls ON
studentsrecords.time_in <= controls.late_time WHERE YEAR(date_in) = YEAR(date())-1 GROUP BY
YEAR(date_in)"

Dim adapter2 As New OleDbDataAdapter(sql2, myconnection)

Dim dt2 As New DataTable("students")

adapter2.Fill(dt2)

data2.Add(dt2.Rows(0).Item(0).ToString())

BunifuBarChart2.Data = data2

data2.Add(dt2.Rows(1).Item(0).ToString())

BunifuBarChart2.Data = data2

'bar 3 absent

Dim sql3 As String

sql3 = "SELECT COUNT(*) as numb FROM studentsrecords WHERE flag ='0' and YEAR(date_in) =
YEAR(date()) GROUP BY YEAR(date_in) UNION SELECT COUNT(*) as b FROM studentsrecords WHERE
flag ='0' and YEAR(date_in) = YEAR(date())-1 GROUP BY YEAR(date_in) "

Dim adapter3 As New OleDbDataAdapter(sql3, myconnection)

Dim dt3 As New DataTable("students")

adapter3.Fill(dt3)

data3.Add(dt3.Rows(0).Item(0).ToString())

BunifuBarChart3.Data = data3

data3.Add(dt3.Rows(1).Item(0).ToString())

BunifuBarChart3.Data = data3
Dim sqlyear As String

sqlyear = "SELECT YEAR(date_in) FROM studentsrecords WHERE YEAR(date_in) = YEAR(date())


GROUP BY YEAR(date_in) UNION SELECT YEAR(date_in) FROM studentsrecords WHERE YEAR(date_in) =
YEAR(date())-1 GROUP BY YEAR(date_in)"

Dim adapterYear As New OleDbDataAdapter(sqlyear, myconnection)

Dim dtYear As New DataTable("students")

adapterYear.Fill(dtYear)

'BunifuChartCanvas3.Labels = New String() {dtYear.Rows(0).Item(0).ToString(),


dtYear.Rows(1).Item(0).ToString()}

'BunifuChartCanvas3.Update()

End Sub

Private Sub Button3_Click_1(sender As Object, e As EventArgs)

BunifuPages1.SetPage("TabPage1")

End Sub

Private Sub Button4_Click_2(sender As Object, e As EventArgs)

Dim data1 As List(Of Double) = New List(Of Double)()

Dim data2 As List(Of Double) = New List(Of Double)()

Dim data3 As List(Of Double) = New List(Of Double)()


'bar 1 late

Dim sql1 As String

sql1 = "SELECT COUNT(*) as numb FROM studentsrecords INNER JOIN controls ON


studentsrecords.time_in >= controls.late_time WHERE YEAR(date_in) = YEAR(date()) GROUP BY
YEAR(date_in) UNION SELECT COUNT(*) as numb FROM studentsrecords INNER JOIN controls ON
studentsrecords.time_in >= controls.late_time WHERE YEAR(date_in) = YEAR(date())-1 GROUP BY
YEAR(date_in)"

Dim adapter1 As New OleDbDataAdapter(sql1, myconnection)

Dim dt1 As New DataTable("students")

adapter1.Fill(dt1)

data1.Add(dt1.Rows(0).Item(0).ToString)

BunifuBarChart1.Data = data1

data1.Add(dt1.Rows(1).Item(0).ToString)

BunifuBarChart1.Data = data1

'bar 2 early

Dim sql2 As String

sql2 = "SELECT COUNT(*) as numb FROM studentsrecords INNER JOIN controls ON


studentsrecords.time_in <= controls.late_time WHERE YEAR(date_in) = YEAR(date()) GROUP BY
YEAR(date_in) UNION SELECT COUNT(*) as numb FROM studentsrecords INNER JOIN controls ON
studentsrecords.time_in <= controls.late_time WHERE YEAR(date_in) = YEAR(date())-1 GROUP BY
YEAR(date_in)"

Dim adapter2 As New OleDbDataAdapter(sql2, myconnection)

Dim dt2 As New DataTable("students")

adapter2.Fill(dt2)

data2.Add(dt2.Rows(0).Item(0).ToString())
BunifuBarChart2.Data = data2

data2.Add(dt2.Rows(1).Item(0).ToString())

BunifuBarChart2.Data = data2

'bar 3 absent

Dim sql3 As String

sql3 = "SELECT COUNT(*) as numb FROM studentsrecords WHERE flag ='0' and YEAR(date_in) =
YEAR(date()) GROUP BY YEAR(date_in) UNION SELECT COUNT(*) as b FROM studentsrecords WHERE
flag ='0' and YEAR(date_in) = YEAR(date())-1 GROUP BY YEAR(date_in) "

Dim adapter3 As New OleDbDataAdapter(sql3, myconnection)

Dim dt3 As New DataTable("students")

adapter3.Fill(dt3)

data3.Add(dt3.Rows(0).Item(0).ToString())

BunifuBarChart3.Data = data3

data3.Add(dt3.Rows(1).Item(0).ToString())

BunifuBarChart3.Data = data3

Dim sqlyear As String

sqlyear = "SELECT YEAR(date_in) FROM studentsrecords WHERE YEAR(date_in) = YEAR(date())


GROUP BY YEAR(date_in) UNION SELECT YEAR(date_in) FROM studentsrecords WHERE YEAR(date_in) =
YEAR(date())-1 GROUP BY YEAR(date_in)"

Dim adapterYear As New OleDbDataAdapter(sqlyear, myconnection)

Dim dtYear As New DataTable("students")

adapterYear.Fill(dtYear)
'BunifuChartCanvas3.Labels = New String() {dtYear.Rows(0).Item(0).ToString(),
dtYear.Rows(1).Item(0).ToString()}

'BunifuChartCanvas3.Update()

End Sub

Private Sub rdFilterByDay_CheckedChanged(sender As Object, e As EventArgs) Handles


rdFilterByDay.CheckedChanged

If rdFilterByDay.Checked = True Then

MonthlyDropdown.Enabled = False

MonthlyDropdown2.Enabled = False

Else

MonthlyDropdown.Enabled = True

MonthlyDropdown2.Enabled = True

End If

End Sub

Private Sub rdFilterByMnth_CheckedChanged(sender As Object, e As EventArgs) Handles


rdFilterByMnth.CheckedChanged

If rdFilterByMnth.Checked = True Then

DashboardDatePicker.Enabled = False

DashboardDatePicker2.Enabled = False

Else

DashboardDatePicker.Enabled = True
DashboardDatePicker2.Enabled = True

End If

End Sub

Private Sub mainGraph()

rdFilterByMnth.Checked = True

'Me.MonthlyDropdown.SelectedIndex = 1

'Me.MonthlyDropdown2.SelectedIndex = If(Now.Date.Month - 1 = 0, Now.Date.Month,


Now.Date.Month) - 1

'Dim sender As Object = New Object

'BunifuButton18_Click_2(sender, New EventArgs())

Me.MonthlyDropdown2.SelectedIndex = 11 'Now.Date.Month - 1 'If(Now.Date.Month - 1 = 0,


Now.Date.Month, Now.Date.Month) - 1

Me.MonthlyDropdown.SelectedIndex = 0

End Sub

Private Sub Button1_Click_4(sender As Object, e As EventArgs)

'rdFilterByMnth.Checked = True

'Me.MonthlyDropdown.SelectedIndex = If(Now.Date.Month - 1 = 0, Now.Date.Month,


Now.Date.Month - 1) - 1

'Call BunifuThinButton21_Click(sender, e)

'MsgBox(If(Now.Date.Month - 1 = 0, Now.Date.Month, Now.Date.Month - 1))

End Sub

Private Sub Button1_Click_5(sender As Object, e As EventArgs)


dummyChartsData()

End Sub

Private Sub RadioButton11_CheckedChanged(sender As Object, e As EventArgs) Handles


RadioButton11.CheckedChanged

If RadioButton11.Checked = True Then

YearStart.Enabled = False

YearEnd.Enabled = False

BunifuButton35.Enabled = False

monthlyGraph()

Else

End If

End Sub

Private Sub renderBarchart()

'BunifuChartCanvas3.Clear()

'

' For this example we will use random numbers

'

Dim r = New Random()

'

' Add your data from your source - accepts double list

' Below is an example from a random number


'

Dim data As List(Of Double) = New List(Of Double)()

For i As Integer = 0 To 5 - 1

data.Add(r.[Next](0, 50))

Next

'

' Set your data

'

BunifuBarChart1.Data = data

'

' Specify the target canvas

'

'BunifuBarChart1.TargetCanvas = BunifuChartCanvas3

'

' Add labels to your canvas

' Label count should correspond to data count for charts like Bar charts

'

'BunifuChartCanvas3.Labels = New String() {"Label1", "Label2", "Label3", "Label4", "Label5"}

'

' Beautify the chart by sepcifying the colors


' Color count should correspond to data count

'

Dim bgColors As List(Of Color) = New List(Of Color)()

For i As Integer = 0 To data.Count - 1

bgColors.Add(Color.FromArgb(r.[Next](256), r.[Next](256), r.[Next](256)))

Next

BunifuBarChart1.BackgroundColor = bgColors

End Sub

Private Sub RadioButton12_CheckedChanged(sender As Object, e As EventArgs) Handles


RadioButton12.CheckedChanged

If RadioButton12.Checked = True Then

YearStart.Enabled = True

YearEnd.Enabled = True

BunifuButton35.Enabled = True

Else

End If

End Sub

Private Sub renderHorizontalChart()

'BunifuChartCanvas3.Clear()

'Dim bunifuHChart As Bunifu.Charts.WinForms.ChartTypes.BunifuHorizontalBarChart = New


Bunifu.Charts.WinForms.ChartTypes.BunifuHorizontalBarChart()

'

' For this example we will use random numbers

'

Dim r = New Random()

'

' Add your data from your source - accepts double list

' Below is an example from a random number

'

Dim data As List(Of Double) = New List(Of Double)()

For i As Integer = 0 To 5 - 1

data.Add(r.NextDouble())

Next

'

' Set your data

'

BunifuBarChart1.Data = data

'

' Specify the target canvas

'

'BunifuBarChart1.TargetCanvas = BunifuChartCanvas3
'

' Add labels to your canvas

' Label count should correspond to data count for charts like Bar charts

'

'BunifuChartCanvas3.Labels = New String() {"Label1", "Label2", "Label3", "Label4", "Label5"}

'

' Beautify the chart by sepcifying the colors

' Color count should correspond to data count

'

Dim bgColors As List(Of Color) = New List(Of Color)()

bgColors.Add(Color.Red)

bgColors.Add(Color.Blue)

bgColors.Add(Color.Green)

bgColors.Add(Color.Gray)

bgColors.Add(Color.Purple)

BunifuBarChart1.BackgroundColor = bgColors

End Sub

Private Sub Button1_Click_3(sender As Object, e As EventArgs)

'monthlyGraph()

'For a As Integer = 9 To 0 Step -1

' MsgBox(a)

'Next
'BunifuDataGridView2.Rows.Clear()

''bar 3 absent

'Dim sql3 As String

''sql3 = "SELECT COUNT(*) as numb FROM studentsrecords WHERE flag ='0' and YEAR(date_in)
YEAR(date()) GROUP BY YEAR(date_in) UNION SELECT COUNT(*) as b FROM studentsrecords WHERE
flag ='0' and YEAR(date_in) = YEAR(date())-1 GROUP BY YEAR(date_in) "

''sql3 = "SELECT COUNT(*) as numb FROM studentsrecords WHERE flag ='0' and YEAR(date_in)
BETWEEN YEAR(#" & YearStart.Text & "#) AND YEAR(#" & YearEnd.Text & "#)"

'sql3 = "SELECT COUNT(*) as numb FROM studentsrecords WHERE flag ='0' and YEAR(date_in)
BETWEEN YEAR(#" & YearStart.Text & "#) AND YEAR(#" & YearEnd.Text & "#) GROUP BY YEAR(date_in)
UNION SELECT COUNT(*) as b FROM studentsrecords WHERE flag ='0' and YEAR(date_in) BETWEEN
YEAR(#" & YearStart.Text & "#) AND YEAR(#" & YearEnd.Text & "#) GROUP BY YEAR(date_in);"

'Dim adapter3 As New OleDbDataAdapter(sql3, myconnection)

'Dim dt3 As New DataTable("students")

'adapter3.Fill(dt3)

'For n As Integer = 0 To dt3.Rows.Count - 1

' MsgBox(dt3.Rows(n).Item(0).ToString())

'Next

End Sub

Private Sub BunifuChartCanvas4_Load(sender As Object, e As EventArgs)

End Sub
Private Sub BunifuThinButton22_Click(sender As Object, e As EventArgs)

End Sub

Private Sub BunifuShadowPanel14_ControlAdded(sender As Object, e As ControlEventArgs)

End Sub

Private Sub RadioButton13_CheckedChanged(sender As Object, e As EventArgs) Handles


RadioButton13.CheckedChanged

If RadioButton13.Checked = True Then

YearStart.Enabled = False

YearEnd.Enabled = False

BunifuButton35.Enabled = False

ALLyearlyGraph()

Else

End If

End Sub

Private Sub BunifuButton18_Click_2(sender As Object, e As EventArgs) Handles BunifuButton18.Click

BunifuChartCanvas3.Labels = New String() {}

BunifuChartCanvas3.Clear()
BunifuDataGridView2.Rows.Clear()

Dim dCount As Integer

Dim randomData = New Random()

Dim data1 As List(Of Double) = New List(Of Double)()

Dim data2 As List(Of Double) = New List(Of Double)()

Dim data3 As List(Of Double) = New List(Of Double)()

If rdFilterByMnth.Checked = True Then

If ClassDepDropdown.Text = "Class" Then

Dim sqlDepartment As String

sqlDepartment = "SELECT ClassCombo FROM controls GROUP BY ClassCombo"

Dim adapterDepartment As New OleDbDataAdapter(sqlDepartment, myconnection)

Dim dtDepartment As New DataTable("Class")

adapterDepartment.Fill(dtDepartment)

dCount = dtDepartment.Rows.Count - 1

BunifuChartCanvas3.Labels = New String(dCount) {}

'bar 3 absent

Dim sql3 As String

sql3 = "SELECT COUNT(*) as numb, class FROM studentsrecords WHERE flag ='0' AND
MONTH(date_in) BETWEEN " & MonthlyDropdown.SelectedIndex + 1 & " AND " &
MonthlyDropdown2.SelectedIndex + 1 & " AND YEAR(date_in) = YEAR(DATE()) GROUP BY class"

Dim adapter3 As New OleDbDataAdapter(sql3, myconnection)

Dim dt3 As New DataTable("students")


adapter3.Fill(dt3)

For vb As Integer = 0 To dCount

data3.Add(0)

Next

For n As Integer = 0 To dtDepartment.Rows.Count - 1

BunifuChartCanvas3.Labels(n) = dtDepartment.Rows(n).Item(0).ToString()

BunifuDataGridView2.DataSource = Nothing

BunifuDataGridView2.AutoGenerateColumns = False

BunifuDataGridView2.ColumnCount = 5

BunifuDataGridView2.Columns(0).Name = "Name"

BunifuDataGridView2.Columns(1).Name = "Early"

BunifuDataGridView2.Columns(2).Name = "Late"

BunifuDataGridView2.Columns(3).Name = "Absent"

BunifuDataGridView2.Columns(4).Name = "Grand Total"

Dim row As String() = New String() {dtDepartment.Rows(n).Item(0).ToString()}

BunifuDataGridView2.Rows.Add(row)

For m As Integer = 0 To dt3.Rows.Count - 1

If dtDepartment.Rows(n).Item(0).ToString() = dt3.Rows(m).Item(1).ToString() Then


data3.Insert(n, dt3.Rows(m).Item(0).ToString)

' BunifuDataGridView2.Rows(n).Cells("Absent").Value = dt3.Rows(m).Item(0).ToString()

Else

End If

stackedbar3.Data = data3

Next

Next

'bar 1 late

Dim sql1 As String

sql1 = "SELECT COUNT(*) as mpn, class FROM studentsrecords INNER JOIN controls ON
studentsrecords.time_in >= controls.late_time WHERE MONTH(date_in) BETWEEN " &
MonthlyDropdown.SelectedIndex + 1 & " AND " & MonthlyDropdown2.SelectedIndex + 1 & " AND
YEAR(date_in) = YEAR(DATE()) GROUP BY class"

Dim adapter1 As New OleDbDataAdapter(sql1, myconnection)

Dim dt1 As New DataTable("students")

adapter1.Fill(dt1)

For vb As Integer = 0 To dCount

data1.Add(0)

Next

For n As Integer = 0 To dtDepartment.Rows.Count - 1

BunifuChartCanvas3.Labels(n) = dtDepartment.Rows(n).Item(0).ToString()

For m As Integer = 0 To dt1.Rows.Count - 1


If dtDepartment.Rows(n).Item(0).ToString() = dt1.Rows(m).Item(1).ToString() Then

data1.Insert(n, dt1.Rows(m).Item(0).ToString)

BunifuDataGridView2.Rows(n).Cells("Absent").Value = dt3.Rows(m).Item(0).ToString()

Else

End If

stackedbar1.Data = data1

Next

Next

'bar 2 early

Dim sql2 As String

sql2 = "SELECT COUNT(*) as mpn, class FROM studentsrecords INNER JOIN controls ON
studentsrecords.time_in <= controls.late_time WHERE MONTH(date_in) BETWEEN " &
MonthlyDropdown.SelectedIndex + 1 & " AND " & MonthlyDropdown2.SelectedIndex + 1 & " AND
YEAR(date_in) = YEAR(DATE()) GROUP BY class"

Dim adapter2 As New OleDbDataAdapter(sql2, myconnection)

Dim dt2 As New DataTable("students")

adapter2.Fill(dt2)

For vb As Integer = 0 To dCount

data2.Add(0)

Next

For n As Integer = 0 To dtDepartment.Rows.Count - 1

BunifuChartCanvas3.Labels(n) = dtDepartment.Rows(n).Item(0).ToString()
For m As Integer = 0 To dt2.Rows.Count - 1

If dtDepartment.Rows(n).Item(0).ToString() = dt2.Rows(m).Item(1).ToString() Then

data2.Insert(n, dt2.Rows(m).Item(0).ToString)

BunifuDataGridView2.Rows(n).Cells("Absent").Value = dt3.Rows(m).Item(0).ToString()

Else

End If

stackedbar2.Data = data2

Next

Next

BunifuChartCanvas3.XAxesLabel = MonthlyDropdown.Text & " " & Date.Now.Year & " To " &
MonthlyDropdown2.Text & " " & Date.Now.Year

ElseIf ClassDepDropdown.Text = "Level" Then

Dim sqlDepartment As String

sqlDepartment = "SELECT DptCombo FROM controlsdpt GROUP BY DptCombo"

Dim adapterDepartment As New OleDbDataAdapter(sqlDepartment, myconnection)

Dim dtDepartment As New DataTable("Department")

adapterDepartment.Fill(dtDepartment)

dCount = dtDepartment.Rows.Count - 1

BunifuChartCanvas3.Labels = New String(dCount) {}

'bar 1 late
Dim sql1 As String

sql1 = "SELECT COUNT(*) as mpn, department FROM studentsrecords INNER JOIN controls ON
studentsrecords.time_in >= controls.late_time WHERE MONTH(date_in) BETWEEN " &
MonthlyDropdown.SelectedIndex + 1 & " AND " & MonthlyDropdown2.SelectedIndex + 1 & " AND
YEAR(date_in) = YEAR(DATE()) GROUP BY department"

Dim adapter1 As New OleDbDataAdapter(sql1, myconnection)

Dim dt1 As New DataTable("students")

adapter1.Fill(dt1)

For vb As Integer = 0 To dCount

data1.Add(0)

Next

For n As Integer = 0 To dtDepartment.Rows.Count - 1

BunifuChartCanvas3.Labels(n) = dtDepartment.Rows(n).Item(0).ToString()

BunifuDataGridView2.DataSource = Nothing

BunifuDataGridView2.AutoGenerateColumns = False

BunifuDataGridView2.ColumnCount = 5

BunifuDataGridView2.Columns(0).Name = "Name"

BunifuDataGridView2.Columns(1).Name = "Early"

BunifuDataGridView2.Columns(2).Name = "Late"

BunifuDataGridView2.Columns(3).Name = "Absent"

BunifuDataGridView2.Columns(4).Name = "Grand Total"

Dim row As String() = New String() {dtDepartment.Rows(n).Item(0).ToString()}


BunifuDataGridView2.Rows.Add(row)

For m As Integer = 0 To dt1.Rows.Count - 1

If dtDepartment.Rows(n).Item(0).ToString() = dt1.Rows(m).Item(1).ToString() Then

data1.Insert(n, dt1.Rows(m).Item(0).ToString)

Else

End If

stackedbar1.Data = data1

Next

Next

'bar 2 early

Dim sql2 As String

sql2 = "SELECT COUNT(*) as mpn, department FROM studentsrecords INNER JOIN controls ON
studentsrecords.time_in <= controls.late_time WHERE MONTH(date_in) BETWEEN " &
MonthlyDropdown.SelectedIndex + 1 & " AND " & MonthlyDropdown2.SelectedIndex + 1 & " AND
YEAR(date_in) = YEAR(DATE()) GROUP BY Department"

Dim adapter2 As New OleDbDataAdapter(sql2, myconnection)

Dim dt2 As New DataTable("students")

adapter2.Fill(dt2)

For vb As Integer = 0 To dCount

data2.Add(0)

Next
For n As Integer = 0 To dtDepartment.Rows.Count - 1

BunifuChartCanvas3.Labels(n) = dtDepartment.Rows(n).Item(0).ToString()

For m As Integer = 0 To dt2.Rows.Count - 1

If dtDepartment.Rows(n).Item(0).ToString() = dt2.Rows(m).Item(1).ToString() Then

data2.Insert(n, dt2.Rows(m).Item(0).ToString)

Else

End If

stackedbar2.Data = data2

Next

Next

'bar 3 absent

Dim sql3 As String

sql3 = "SELECT COUNT(*) as numb, department FROM studentsrecords WHERE flag ='0' AND
MONTH(date_in) BETWEEN " & MonthlyDropdown.SelectedIndex + 1 & " AND " &
MonthlyDropdown2.SelectedIndex + 1 & " AND YEAR(date_in) = YEAR(DATE()) GROUP BY Department"

Dim adapter3 As New OleDbDataAdapter(sql3, myconnection)

Dim dt3 As New DataTable("students")

adapter3.Fill(dt3)

For vb As Integer = 0 To dCount

data3.Add(0)
Next

For n As Integer = 0 To dtDepartment.Rows.Count - 1

BunifuChartCanvas3.Labels(n) = dtDepartment.Rows(n).Item(0).ToString()

For m As Integer = 0 To dt3.Rows.Count - 1

If dtDepartment.Rows(n).Item(0).ToString() = dt3.Rows(m).Item(1).ToString() Then

data3.Insert(n, dt3.Rows(m).Item(0).ToString)

Else

End If

stackedbar3.Data = data3

Next

Next

End If

BunifuChartCanvas3.XAxesLabel = MonthlyDropdown.Text & " " & Date.Now.Year & " - " &
MonthlyDropdown2.Text & " " & Date.Now.Year

ElseIf rdFilterByDay.Checked = True Then

If ClassDepDropdown.Text = "Class" Then

Dim sqlDepartment As String

sqlDepartment = "SELECT ClassCombo FROM controls GROUP BY ClassCombo"

Dim adapterDepartment As New OleDbDataAdapter(sqlDepartment, myconnection)

Dim dtDepartment As New DataTable("Class")

adapterDepartment.Fill(dtDepartment)
dCount = dtDepartment.Rows.Count - 1

BunifuChartCanvas3.Labels = New String(dCount) {}

'bar 3 absent

Dim sql3 As String

sql3 = "SELECT COUNT(*) as numb, class FROM studentsrecords WHERE flag ='0' AND date_in
BETWEEN #" & DashboardDatePicker.Value.Date & "# AND #" & DashboardDatePicker2.Value.Date & "#
GROUP BY class"

Dim adapter3 As New OleDbDataAdapter(sql3, myconnection)

Dim dt3 As New DataTable("students")

adapter3.Fill(dt3)

For vb As Integer = 0 To dCount

data3.Add(0)

Next

For n As Integer = 0 To dtDepartment.Rows.Count - 1

BunifuChartCanvas3.Labels(n) = dtDepartment.Rows(n).Item(0).ToString()

BunifuDataGridView2.DataSource = Nothing

BunifuDataGridView2.AutoGenerateColumns = False

BunifuDataGridView2.ColumnCount = 5

BunifuDataGridView2.Columns(0).Name = "Name"

BunifuDataGridView2.Columns(1).Name = "Early"

BunifuDataGridView2.Columns(2).Name = "Late"
BunifuDataGridView2.Columns(3).Name = "Absent"

BunifuDataGridView2.Columns(4).Name = "Grand Total"

Dim row As String() = New String() {dtDepartment.Rows(n).Item(0).ToString()}

BunifuDataGridView2.Rows.Add(row)

For m As Integer = 0 To dt3.Rows.Count - 1

If dtDepartment.Rows(n).Item(0).ToString() = dt3.Rows(m).Item(1).ToString() Then

data3.Insert(n, dt3.Rows(m).Item(0).ToString)

Else

End If

stackedbar3.Data = data3

Next

Next

'bar 1 late

Dim sql1 As String

sql1 = "SELECT COUNT(*) as mpn, class FROM studentsrecords INNER JOIN controls ON
studentsrecords.time_in >= controls.late_time WHERE date_in BETWEEN #" &
DashboardDatePicker.Value.Date & "# AND #" & DashboardDatePicker2.Value.Date & "# GROUP BY class"

Dim adapter1 As New OleDbDataAdapter(sql1, myconnection)

Dim dt1 As New DataTable("students")

adapter1.Fill(dt1)
For vb As Integer = 0 To dCount

data1.Add(0)

Next

For n As Integer = 0 To dtDepartment.Rows.Count - 1

BunifuChartCanvas3.Labels(n) = dtDepartment.Rows(n).Item(0).ToString()

For m As Integer = 0 To dt1.Rows.Count - 1

If dtDepartment.Rows(n).Item(0).ToString() = dt1.Rows(m).Item(1).ToString() Then

data1.Insert(n, dt1.Rows(m).Item(0).ToString)

Else

End If

stackedbar1.Data = data1

Next

Next

'bar 2 early

Dim sql2 As String

sql2 = "SELECT COUNT(*) as mpn, class FROM studentsrecords INNER JOIN controls ON
studentsrecords.time_in <= controls.late_time WHERE date_in BETWEEN #" &
DashboardDatePicker.Value.Date & "# AND #" & DashboardDatePicker2.Value.Date & "# GROUP BY class"

Dim adapter2 As New OleDbDataAdapter(sql2, myconnection)

Dim dt2 As New DataTable("students")

adapter2.Fill(dt2)
For vb As Integer = 0 To dCount

data2.Add(0)

Next

For n As Integer = 0 To dtDepartment.Rows.Count - 1

BunifuChartCanvas3.Labels(n) = dtDepartment.Rows(n).Item(0).ToString()

For m As Integer = 0 To dt2.Rows.Count - 1

If dtDepartment.Rows(n).Item(0).ToString() = dt2.Rows(m).Item(1).ToString() Then

data2.Insert(n, dt2.Rows(m).Item(0).ToString)

Else

End If

stackedbar2.Data = data2

Next

Next

ElseIf ClassDepDropdown.Text = "Level" Then

Dim sqlDepartment As String

sqlDepartment = "SELECT DptCombo FROM controlsdpt GROUP BY DptCombo"

Dim adapterDepartment As New OleDbDataAdapter(sqlDepartment, myconnection)

Dim dtDepartment As New DataTable("Department")

adapterDepartment.Fill(dtDepartment)
dCount = dtDepartment.Rows.Count - 1

BunifuChartCanvas3.Labels = New String(dCount) {}

'bar 1 late

Dim sql1 As String

sql1 = "SELECT COUNT(*) as mpn, department FROM studentsrecords INNER JOIN controls ON
studentsrecords.time_in >= controls.late_time WHERE date_in BETWEEN #" &
DashboardDatePicker.Value.Date & "# AND #" & DashboardDatePicker2.Value.Date & "# GROUP BY
department"

Dim adapter1 As New OleDbDataAdapter(sql1, myconnection)

Dim dt1 As New DataTable("students")

adapter1.Fill(dt1)

For vb As Integer = 0 To dCount

data1.Add(0)

Next

For n As Integer = 0 To dtDepartment.Rows.Count - 1

BunifuChartCanvas3.Labels(n) = dtDepartment.Rows(n).Item(0).ToString()

BunifuDataGridView2.DataSource = Nothing

BunifuDataGridView2.AutoGenerateColumns = False

BunifuDataGridView2.ColumnCount = 5

BunifuDataGridView2.Columns(0).Name = "Name"

BunifuDataGridView2.Columns(1).Name = "Early"

BunifuDataGridView2.Columns(2).Name = "Late"
BunifuDataGridView2.Columns(3).Name = "Absent"

BunifuDataGridView2.Columns(4).Name = "Grand Total"

Dim row As String() = New String() {dtDepartment.Rows(n).Item(0).ToString()}

BunifuDataGridView2.Rows.Add(row)

For m As Integer = 0 To dt1.Rows.Count - 1

If dtDepartment.Rows(n).Item(0).ToString() = dt1.Rows(m).Item(1).ToString() Then

data1.Insert(n, dt1.Rows(m).Item(0).ToString)

Else

End If

stackedbar1.Data = data1

Next

Next

'bar 2 early

Dim sql2 As String

sql2 = "SELECT COUNT(*) as mpn, department FROM studentsrecords INNER JOIN controls ON
studentsrecords.time_in <= controls.late_time WHERE date_in BETWEEN #" &
DashboardDatePicker.Value.Date & "# AND #" & DashboardDatePicker2.Value.Date & "# GROUP BY
Department"

Dim adapter2 As New OleDbDataAdapter(sql2, myconnection)

Dim dt2 As New DataTable("students")

adapter2.Fill(dt2)
For vb As Integer = 0 To dCount

data2.Add(0)

Next

For n As Integer = 0 To dtDepartment.Rows.Count - 1

BunifuChartCanvas3.Labels(n) = dtDepartment.Rows(n).Item(0).ToString()

For m As Integer = 0 To dt2.Rows.Count - 1

If dtDepartment.Rows(n).Item(0).ToString() = dt2.Rows(m).Item(1).ToString() Then

data2.Insert(n, dt2.Rows(m).Item(0).ToString)

Else

End If

stackedbar2.Data = data2

Next

Next

'bar 3 absent

Dim sql3 As String

sql3 = "SELECT COUNT(*) as numb, department FROM studentsrecords WHERE flag ='0' AND
date_in BETWEEN #" & DashboardDatePicker.Value.Date & "# AND #" &
DashboardDatePicker2.Value.Date & "# GROUP BY Department"

Dim adapter3 As New OleDbDataAdapter(sql3, myconnection)

Dim dt3 As New DataTable("students")


adapter3.Fill(dt3)

For vb As Integer = 0 To dCount

data3.Add(0)

Next

For n As Integer = 0 To dtDepartment.Rows.Count - 1

BunifuChartCanvas3.Labels(n) = dtDepartment.Rows(n).Item(0).ToString()

For m As Integer = 0 To dt3.Rows.Count - 1

If dtDepartment.Rows(n).Item(0).ToString() = dt3.Rows(m).Item(1).ToString() Then

data3.Insert(n, dt3.Rows(m).Item(0).ToString)

Else

End If

stackedbar3.Data = data3

Next

Next

End If

BunifuChartCanvas3.XAxesLabel = DashboardDatePicker.Text & " - " & DashboardDatePicker2.Text

End If

stackedbar1.Data = data1
stackedbar2.Data = data2

stackedbar3.Data = data3

BunifuChartCanvas3.Update()

Dim wcnt As Integer = 0

Dim w As Integer = 0

For Each nb In data3

If w <= dCount Then

BunifuDataGridView2.Rows(w).Cells("Absent").Value = nb

wcnt += nb

w += 1

End If

Next

Dim xcnt As Integer = 0

Dim x As Integer = 0

For Each nb In data2

If x <= dCount Then

BunifuDataGridView2.Rows(x).Cells("Early").Value = nb

xcnt += nb

x += 1

End If
Next

Dim y As Integer = 0

Dim tcnt As Integer = 0

For Each nb In data1

If y <= dCount Then

BunifuDataGridView2.Rows(y).Cells("Late").Value = nb

tcnt += nb

y += 1

End If

Next

BunifuDataGridView2.Rows.Add("SubTotal", xcnt, tcnt, wcnt)

Dim grandtotal As Integer = 0

For mnm As Integer = 0 To BunifuDataGridView2.RowCount - 2

grandtotal = 0

For u As Integer = 1 To BunifuDataGridView2.ColumnCount - 2

grandtotal += BunifuDataGridView2.Rows(mnm).Cells(u).Value

Next

BunifuDataGridView2.Rows(mnm).Cells("Grand Total").Value = grandtotal

Next
data1.Clear()

data2.Clear()

data3.Clear()

End Sub

Private Sub BunifuButton35_Click_1(sender As Object, e As EventArgs)

If YearStart.SelectedIndex < 0 Or YearEnd.SelectedIndex < 0 Then

Else

yearlyGraph()

End If

End Sub

Private Sub BunifuShadowPanel24_ControlAdded(sender As Object, e As ControlEventArgs)

End Sub

Private Sub Button1_Click_6(sender As Object, e As EventArgs)

End Sub

'Private Sub Button1_Click_7(sender As Object, e As EventArgs) Handles Button1.Click

' BunifuChartCanvas2.Clear()

' BunifuChartCanvas2.Labels = New String() {"Room1", "Room2", "Room3", "Room4", "Room5"}


' BunifuChartCanvas2.Update()

'End Sub

'Private Sub Button3_Click_3(sender As Object, e As EventArgs) Handles Button3.Click

' BunifuChartCanvas2.Labels = New String() {}

' BunifuChartCanvas2.Clear()

' BunifuChartCanvas2.Labels = New String() {"Jan", "Feb", "Mar"}

' BunifuChartCanvas2.Update()

'End Sub

'Private Sub Button4_Click_3(sender As Object, e As EventArgs) Handles Button4.Click

' BunifuChartCanvas2.Labels = New String() {}

'End Sub

Private Sub ClassDepDropdown_SelectedIndexChanged(sender As Object, e As EventArgs)

End Sub

Private Sub Label11_Click(sender As Object, e As EventArgs)

End Sub

'Private Sub Button6_Click_3(sender As Object, e As EventArgs) Handles Button6.Click


' Dim sqlinsert1 As String

' ' We use the INSERT statement which tells our program to add the information

' ' from the Forms Text fields into the Databases columns.

' sqlinsert1 = "INSERT INTO schools_schools1_register( firstname, lastname, id, created, student_id,
Class, ReceiveSms, department, tag_id)" &

' "VALUES( @firstname, @lastname, @id, @created, @student_id, @Class, @ReceiveSms,


@department, @tag_id )"

' Dim cmd1 As New OleDbCommand(sqlinsert1, myconnection)

' ' This assigns the values for our columns in the DataBase.

' ' To ensure the correct values are written to the correct column

' Dim z As Integer = z + 1

' cmd1.Parameters.Add(New OleDbParameter("@firstname", txtfirstname.Text))

' cmd1.Parameters.Add(New OleDbParameter("@lastname", TextBox2.Text))

' cmd1.Parameters.Add(New OleDbParameter("@id", z))

' cmd1.Parameters.Add(New OleDbParameter("@created", Now()))

' cmd1.Parameters.Add(New OleDbParameter("@student_id", TextBox22.Text))

' cmd1.Parameters.Add(New OleDbParameter("@Class", q))

' cmd1.Parameters.Add(New OleDbParameter("@ReceiveSms", psms))

' cmd1.Parameters.Add(New OleDbParameter("@department", p))

' cmd1.Parameters.Add(New OleDbParameter("@tag_id", TextBox3.Text))

' 'Try

' myconnection.Open()

' cmd1.ExecuteNonQuery()
' myconnection.Close()

' 'MsgBox("Student registered successfully!")

' 'Catch ex As Exception

' ' MsgBox(ex.Message)

' ' myconnection.Close()

' 'Finally

' ' myconnection.Close()

' 'End Try

'End Sub

Private Sub Button6_Click_1(sender As Object, e As EventArgs)

selectfailedsmsData()

'InsertApiData("4324", "gdfgf", Now.Date, Now.TimeOfDay)

'deleteSmsForFailed(2)

End Sub

Private Sub BunifuDatePicker2_ValueChanged(sender As Object, e As EventArgs)

If BunifuDatePicker2.Value <= BunifuDatePicker3.Value Then

Else
End If

End Sub

' Private Sub Button33_Click(sender As Object, e As EventArgs) Handles Button33.Click

' If RadioButton7.Checked = True Then

' ListBox2.Items.Add(DateTimePicker10.Value.ToShortDateString)

' End If

' End Sub

'Public Sub Save(sender As Object, e As EventArgs) Handles Button36.Click

' Dim b As String = ""

' For Each a As String In ListBox2.Items

' b += a & ","

' Next

' SaveData(b)

'End Sub
'This code will be repeated till all the data[i] values inserted

Private Sub SaveData(id As String)

' CODE INSERT

Dim str As String

str = id.Remove(id.Length - 1)

Dim sqlupdate As String

sqlupdate = "UPDATE controlsignout SET timeset=@timeset WHERE flag='excludedDays'"

Dim cmd As New OleDbCommand(sqlupdate, myconnection)

cmd.Parameters.Add(New OleDbParameter("@timeset", str))

Try

myconnection.Open()

If MessageBox.Show("Are you sure you want to save this list?", "Change",


MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

If (cmd.ExecuteNonQuery() > 0) Then

MsgBox("The Off-Days list was updated successfully.")

End If

End If

myconnection.Close()

retrieveExcludedates()

Catch ex As Exception
MsgBox(ex.Message)

myconnection.Close()

Finally

End Try

End Sub

Private Sub BunifuButton10_Click(sender As Object, e As EventArgs) Handles BunifuButton10.Click

If txtfirstname.Text.Trim = "" Or txtparentsname.Text.Trim = "" Or TextBox2.Text.Trim = "" Or


txtage.Text.Trim = "" Or TextBox3.Text.Trim = "" Or txtaddress.Text.Trim = "" Or TextBox22.Text.Trim = "" Or
TextBox6.Text.Trim = "" Or TextBox7.Text.Trim = "" Or ComboBox1.Text = "" Or ComboBox7.Text = "" Or
rdmale.Checked = False And rdfemale.Checked = False Then

MsgBox("Please fill in all required fields marked with ' * '")

Else

' CODE INSERT

Dim sqlinsert As String

' We use the INSERT statement which tells our program to add the information

' from the Forms Text fields into the Databases columns.

sqlinsert = "INSERT INTO students(tag_id, id, firstname, lastname, middlename, gender,


Guardiannumber1,Guardiannumber2, address, city, postoffice, parish, birthday, age, class,
department,ReceiveSms, userType, status, PicturePath )" &

"VALUES( @tag_id, @id, @firstname, @lastname, @middlename, @gender,


@Guardiannumber1,@Guardiannumber2, @address, @city, @postoffice, @parish, @birthday, @age,
@class, @department, @ReceiveSms, 'student', '1', '" & Replace$(BunifuTextBox1.Text, "'", "''") & "' )"

Dim cmd As New OleDbCommand(sqlinsert, myconnection)

' This assigns the values for our columns in the DataBase.

' To ensure the correct values are written to the correct column

cmd.Parameters.Add(New OleDbParameter("@tag_id", TextBox3.Text))

cmd.Parameters.Add(New OleDbParameter("@id", TextBox22.Text))

cmd.Parameters.Add(New OleDbParameter("@firstname", txtfirstname.Text))

cmd.Parameters.Add(New OleDbParameter("@lastname", TextBox2.Text))

cmd.Parameters.Add(New OleDbParameter("@middlename", txtmiddlename.Text))

cmd.Parameters.Add(New OleDbParameter("@gender", male))

cmd.Parameters.Add(New OleDbParameter("@Guardiannumber1", txtparentsname.Text))

cmd.Parameters.Add(New OleDbParameter("@Guardiannumber2", TextBox8.Text))

cmd.Parameters.Add(New OleDbParameter("@address", txtaddress.Text))

cmd.Parameters.Add(New OleDbParameter("@city", TextBox6.Text))

cmd.Parameters.Add(New OleDbParameter("@postoffice", TextBox4.Text))

cmd.Parameters.Add(New OleDbParameter("@parish", TextBox7.Text))

cmd.Parameters.Add(New OleDbParameter("@birthday", DateTimePicker1.Value.Date))

cmd.Parameters.Add(New OleDbParameter("@age", txtage.Text))

cmd.Parameters.Add(New OleDbParameter("@class", q))

cmd.Parameters.Add(New OleDbParameter("@department", p))

cmd.Parameters.Add(New OleDbParameter("@ReceiveSms", psms))

' This is what actually writes our changes to the DataBase.

' You have to open the connection, execute the commands and

' then close connection.


Dim sqlinsertg As String

' We use the INSERT statement which tells our program to add the information

' from the Forms Text fields into the Databases columns.

sqlinsertg = "INSERT INTO global_students(tag_id, id, firstname, lastname, middlename, gender,


Guardiannumber1,Guardiannumber2, address, city, parish, birthday, age, class, department,ReceiveSms,
userType, status, PicturePath )" &

"VALUES( @tag_id, @id, @firstname, @lastname, @middlename, @gender,


@Guardiannumber1,@Guardiannumber2, @address, @city, @parish, @birthday, @age, @class,
@department, @ReceiveSms, 'student', '1', '" & Replace$(BunifuTextBox1.Text, "'", "''") & "' )"

Dim cmdg As New OleDbCommand(sqlinsertg, myconnection)

' This assigns the values for our columns in the DataBase.

' To ensure the correct values are written to the correct column

cmdg.Parameters.Add(New OleDbParameter("@tag_id", TextBox3.Text))

cmdg.Parameters.Add(New OleDbParameter("@id", TextBox22.Text))

cmdg.Parameters.Add(New OleDbParameter("@firstname", txtfirstname.Text))

cmdg.Parameters.Add(New OleDbParameter("@lastname", TextBox2.Text))

cmdg.Parameters.Add(New OleDbParameter("@middlename", txtmiddlename.Text))

cmdg.Parameters.Add(New OleDbParameter("@gender", male))

cmdg.Parameters.Add(New OleDbParameter("@Guardiannumber1", txtparentsname.Text))

cmdg.Parameters.Add(New OleDbParameter("@Guardiannumber2", TextBox8.Text))

cmdg.Parameters.Add(New OleDbParameter("@address", txtaddress.Text))

cmdg.Parameters.Add(New OleDbParameter("@city", TextBox6.Text))

cmdg.Parameters.Add(New OleDbParameter("@parish", TextBox7.Text))

cmdg.Parameters.Add(New OleDbParameter("@birthday", DateTimePicker1.Value.Date))

cmdg.Parameters.Add(New OleDbParameter("@age", txtage.Text))


cmdg.Parameters.Add(New OleDbParameter("@class", q))

cmdg.Parameters.Add(New OleDbParameter("@department", p))

cmdg.Parameters.Add(New OleDbParameter("@ReceiveSms", psms))

'Try

myconnection.Open()

If MessageBox.Show("Are you sure the information has been entered correctly?", "Save",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

If (cmd.ExecuteNonQuery() > 0) Then

cmdg.ExecuteNonQuery()

myconnection.Close()

'MsgBox("Student registered successfully!")

Example1()

clearfields()

generate_student_id()

dailyGraphs()

update_linked_table()

' RefreshDGV()

filldb()

End If

End If

'Catch ex As Exception

' MsgBox(ex.Message)

' myconnection.Close()
'Finally

' myconnection.Close()

'End Try

End If

End Sub

Private Sub BunifuButton35_Click_2(sender As Object, e As EventArgs) Handles BunifuButton35.Click

If YearStart.SelectedIndex < 0 Or YearEnd.SelectedIndex < 0 Then

Else

yearlyGraph()

End If

End Sub

Private Sub Button1_Click_7(sender As Object, e As EventArgs) Handles Button1.Click

update_linked_table()

End Sub

Private Sub BunifuButton36_Click(sender As Object, e As EventArgs) Handles BunifuButton36.Click

If dbStudentFilter.SelectedIndex < 0 And dbStaffFilter.SelectedIndex < 0 Then

MsgBox("The entry field cannot be empty.")


ElseIf txtsearch.Text = "" And dbStaffFilter.SelectedItem IsNot "All" And dbStudentFilter.Enabled =
False Or txtsearch.Text = "" And dbStudentFilter.SelectedItem IsNot "All" And dbStaffFilter.Enabled =
False Then

MsgBox("The entry field cannot be empty.")

Else

If dbRegistryType.SelectedItem = "Active" Then

If dbRecordType.SelectedItem = "Student" Then

If dbStudentFilter.SelectedItem = "All" Then

refreshRegGrid()

ElseIf dbStudentFilter.SelectedItem = "Student ID" And txtsearch.Text.Trim IsNot "" Then

If TabControl1.SelectedTab Is tbTableView Then

Dim sqlsearch As String

sqlsearch = "SELECT ID as [Student-ID], Tag_id as [Tag-ID], Firstname as Firstname,


lastname as Lastname, Gender as Gender, birthday as D_O_B, Age as Age, Department as [Level], Class
as Class, Guardiannumber1 as [Guardian_1#], ReceiveSms as SMS FROM students WHERE id LIKE '%" &
txtsearch.Text & "%'" & ""

' Once again we execute the SQL statements against our DataBase

Dim adapter As New OleDbDataAdapter(sqlsearch, myconnection)

' Shows the records and updates the DataGridView

Dim dt As New DataTable("students")


adapter.Fill(dt)

BunifuDataGridView3.DataSource = dt

Label25.Text = dt.Rows.Count

If dt.Rows.Count = 0 Then

MsgBox("The entered information was not found. Please try again.")

End If

ElseIf TabControl1.SelectedTab Is tbReportView Then

Dim sqlsearch1 As String

sqlsearch1 = "SELECT ID, Tag_id, Firstname as Firstname, lastname as Lastname,


middlename, Gender as Gender, birthday, Age as Age, Department, Class as Class, Guardiannumber1,
address, city, parish, ReceiveSms FROM students WHERE id LIKE '%" & txtsearch.Text & "%'" & ""

Dim crystalReport1 As New CrystalReport5()

Dim dsCustomers1 As students = GetActiveStudentData(sqlsearch1)

crystalReport1.SetDataSource(dsCustomers1)

Me.CrystalReportViewer2.ReportSource = crystalReport1

Me.CrystalReportViewer2.RefreshReport()

ElseIf TabControl1.SelectedTab Is tbGraphView Then

End If
ElseIf dbStudentFilter.SelectedItem = "Student Name" And txtsearch.Text.Trim IsNot "" Then

If TabControl1.SelectedTab Is tbTableView Then

Dim sqlsearch As String

sqlsearch = "SELECT ID as [Student-ID], Tag_id as [Tag-ID], Firstname as Firstname,


lastname as Lastname, Gender as Gender, birthday as D_O_B, Age as Age, Department as [Level], Class
as Class, Guardiannumber1 as [Guardian_1#], ReceiveSms as SMS FROM students WHERE firstname LIKE
'%" & txtsearch.Text & "%'" & " OR lastname LIKE '%" & txtsearch.Text & "%'" & ""

' Once again we execute the SQL statements against our DataBase

Dim adapter As New OleDbDataAdapter(sqlsearch, myconnection)

' Shows the records and updates the DataGridView

Dim dt As New DataTable("students")

adapter.Fill(dt)

BunifuDataGridView3.DataSource = dt

Label25.Text = dt.Rows.Count

If dt.Rows.Count = 0 Then

MsgBox("The entered information was not found. Please try again.")

End If

ElseIf TabControl1.SelectedTab Is tbReportView Then

Dim sqlsearch1 As String


sqlsearch1 = "SELECT ID, Tag_id, Firstname as Firstname, lastname as Lastname,
middlename, Gender as Gender, birthday, Age as Age, Department, Class as Class, Guardiannumber1,
address, city, parish, ReceiveSms FROM students WHERE firstname LIKE '%" & txtsearch.Text & "%'" & "
OR lastname LIKE '%" & txtsearch.Text & "%'" & ""

Dim crystalReport1 As New CrystalReport5()

Dim dsCustomers1 As students = GetActiveStudentData(sqlsearch1)

crystalReport1.SetDataSource(dsCustomers1)

Me.CrystalReportViewer2.ReportSource = crystalReport1

Me.CrystalReportViewer2.RefreshReport()

ElseIf TabControl1.SelectedTab Is tbGraphView Then

End If

ElseIf dbStudentFilter.SelectedItem = "Guardian_1 #" And txtsearch.Text.Trim IsNot "" Then

If TabControl1.SelectedTab Is tbTableView Then

Dim sqlsearch As String

sqlsearch = "SELECT ID as [Student-ID], Tag_id as [Tag-ID], Firstname as Firstname,


lastname as Lastname, Gender as Gender, birthday as D_O_B, Age as Age, Department as [Level], Class
as Class, Guardiannumber1 as [Guardian_1#], ReceiveSms as SMS FROM students WHERE
Guardiannumber1 LIKE '%" & txtsearch.Text & "%'" & ""

' Once again we execute the SQL statements against our DataBase

Dim adapter As New OleDbDataAdapter(sqlsearch, myconnection)

' Shows the records and updates the DataGridView


Dim dt As New DataTable("students")

adapter.Fill(dt)

BunifuDataGridView3.DataSource = dt

Label25.Text = dt.Rows.Count

If dt.Rows.Count = 0 Then

MsgBox("The entered information was not found. Please try again.")

End If

ElseIf TabControl1.SelectedTab Is tbReportView Then

Dim sqlsearch1 As String

sqlsearch1 = "SELECT ID, Tag_id, Firstname as Firstname, lastname as Lastname,


middlename, Gender as Gender, birthday, Age as Age, Department, Class as Class, Guardiannumber1,
address, city, parish, ReceiveSms FROM students WHERE Guardiannumber1 LIKE '%" & txtsearch.Text &
"%'" & ""

Dim crystalReport1 As New CrystalReport5()

Dim dsCustomers1 As students = GetActiveStudentData(sqlsearch1)

crystalReport1.SetDataSource(dsCustomers1)

Me.CrystalReportViewer2.ReportSource = crystalReport1

Me.CrystalReportViewer2.RefreshReport()

ElseIf TabControl1.SelectedTab Is tbGraphView Then

End If
End If

ElseIf dbRecordType.SelectedItem = "Staff" Then

If dbStaffFilter.SelectedItem = "All" Then

refreshRegGridStaff()

ElseIf dbStaffFilter.SelectedItem = "Staff ID" And txtsearch.Text.Trim IsNot "" Then

If TabControl1.SelectedTab Is tbTableView Then

Dim sqlsearch As String

sqlsearch = "SELECT staff_id as [Staff-ID], Tag_id as [Tag-ID], Firstname as Firstname,


lastname as Lastname, Gender as Gender, stafftype as [Staff Type], Department as [Level],
contactnumber as [Contact #] FROM staff WHERE staff_id LIKE '%" & txtsearch.Text & "%'" & ""

' Once again we execute the SQL statements against our DataBase

Dim adapter As New OleDbDataAdapter(sqlsearch, myconnection)

' Shows the records and updates the DataGridView

Dim dt As New DataTable("staff")

adapter.Fill(dt)

BunifuDataGridView3.DataSource = dt

Label25.Text = dt.Rows.Count

If dt.Rows.Count = 0 Then

MsgBox("The entered information was not found. Please try again.")


End If

ElseIf TabControl1.SelectedTab Is tbReportView Then

Dim sqlsearch1 As String

sqlsearch1 = "SELECT Tag_id, staff_id, Firstname as Firstname, lastname as Lastname,


Gender as Gender, stafftype, Department, contactnumber, address, postoffice, city, age, birthday, parish,
title, ReceiveSms FROM staff WHERE staff_id LIKE '%" & txtsearch.Text & "%'" & ""

Dim crystalReport1 As New CrystalReport6()

Dim dsCustomers1 As staff = GetActiveStaffData(sqlsearch1)

crystalReport1.SetDataSource(dsCustomers1)

Me.CrystalReportViewer2.ReportSource = crystalReport1

Me.CrystalReportViewer2.RefreshReport()

ElseIf TabControl1.SelectedTab Is tbGraphView Then

End If

ElseIf dbStaffFilter.SelectedItem = "Staff Name" And txtsearch.Text.Trim IsNot "" Then

If TabControl1.SelectedTab Is tbTableView Then

Dim sqlsearch As String


sqlsearch = "SELECT Tag_id as [Tag-ID], staff_id as [Staff-ID], Firstname as Firstname,
lastname as Lastname, Gender as Gender, stafftype as [Staff Type], Department as [Level],
contactnumber as [Contact #] FROM staff WHERE firstname LIKE '%" & txtsearch.Text & "%'" & " OR
lastname LIKE '%" & txtsearch.Text & "%'" & ""

' Once again we execute the SQL statements against our DataBase

Dim adapter As New OleDbDataAdapter(sqlsearch, myconnection)

' Shows the records and updates the DataGridView

Dim dt As New DataTable("staff")

adapter.Fill(dt)

BunifuDataGridView3.DataSource = dt

Label25.Text = dt.Rows.Count

If dt.Rows.Count = 0 Then

MsgBox("The entered information was not found. Please try again.")

End If

ElseIf TabControl1.SelectedTab Is tbReportView Then

Dim sqlsearch1 As String

sqlsearch1 = "SELECT Tag_id, staff_id, Firstname as Firstname, lastname as Lastname,


Gender as Gender, stafftype, Department, contactnumber, address, postoffice, city, age, birthday, parish,
title, ReceiveSms FROM staff WHERE firstname LIKE '%" & txtsearch.Text & "%'" & " OR lastname LIKE '%"
& txtsearch.Text & "%'" & ""

Dim crystalReport1 As New CrystalReport6()

Dim dsCustomers1 As staff = GetActiveStaffData(sqlsearch1)


crystalReport1.SetDataSource(dsCustomers1)

Me.CrystalReportViewer2.ReportSource = crystalReport1

Me.CrystalReportViewer2.RefreshReport()

ElseIf TabControl1.SelectedTab Is tbGraphView Then

End If

ElseIf dbStaffFilter.SelectedItem = "Contact #" And txtsearch.Text.Trim IsNot "" Then

If TabControl1.SelectedTab Is tbTableView Then

Dim sqlsearch As String

sqlsearch = "SELECT Tag_id as [Tag-ID], staff_id as [Staff-ID], Firstname as Firstname,


lastname as Lastname, Gender as Gender, stafftype as [Staff Type], Department as [Level],
contactnumber as [Contact #] FROM staff WHERE contactnumber LIKE '%" & txtsearch.Text & "%'" & ""

' Once again we execute the SQL statements against our DataBase

Dim adapter As New OleDbDataAdapter(sqlsearch, myconnection)

' Shows the records and updates the DataGridView

Dim dt As New DataTable("staff")

adapter.Fill(dt)

BunifuDataGridView3.DataSource = dt

Label25.Text = dt.Rows.Count

If dt.Rows.Count = 0 Then
MsgBox("The entered information was not found. Please try again.")

End If

ElseIf TabControl1.SelectedTab Is tbReportView Then

Dim sqlsearch1 As String

sqlsearch1 = "SELECT Tag_id, staff_id, Firstname as Firstname, lastname as Lastname,


Gender as Gender, stafftype, Department, contactnumber, address, postoffice, city, age, birthday, parish,
title, ReceiveSms FROM staff WHERE contactnumber LIKE '%" & txtsearch.Text & "%'" & ""

Dim crystalReport1 As New CrystalReport6()

Dim dsCustomers1 As staff = GetActiveStaffData(sqlsearch1)

crystalReport1.SetDataSource(dsCustomers1)

Me.CrystalReportViewer2.ReportSource = crystalReport1

Me.CrystalReportViewer2.RefreshReport()

ElseIf TabControl1.SelectedTab Is tbGraphView Then

End If

End If
End If

ElseIf dbRegistryType.SelectedItem = "Global" Then

If dbRecordType.SelectedItem = "Student" Then

If dbStudentFilter.SelectedItem = "All" Then

globalRegGridStudents()

ElseIf dbStudentFilter.SelectedItem = "Student ID" And txtsearch.Text.Trim IsNot "" Then

If TabControl1.SelectedTab Is tbTableView Then

Dim sqlsearch As String

sqlsearch = "SELECT ID as [Student-ID], Tag_id as [Tag-ID], Firstname as Firstname,


lastname as Lastname, Gender as Gender, birthday as D_O_B, Age as Age, Department as [Level], Class
as Class, Guardiannumber1 as [Guardian_1#], ReceiveSms as SMS FROM global_students WHERE id LIKE
'%" & txtsearch.Text & "%'" & ""

'Once again we execute the SQL statements against our DataBase

Dim adapter As New OleDbDataAdapter(sqlsearch, myconnection)

'Shows the records And updates the DataGridView

Dim dt As New DataTable("global_students")

adapter.Fill(dt)

BunifuDataGridView3.DataSource = dt

Label25.Text = dt.Rows.Count

If dt.Rows.Count = 0 Then

MsgBox("The entered information was not found. Please try again.")

End If
ElseIf TabControl1.SelectedTab Is tbReportView Then

Dim sqlsearch1 As String

sqlsearch1 = "SELECT ID, Tag_id, Firstname as Firstname, lastname as Lastname,


middlename, Gender as Gender, birthday, Age as Age, Department, Class as Class, Guardiannumber1,
address, city, parish, ReceiveSms FROM global_students WHERE id LIKE '%" & txtsearch.Text & "%'" & ""

Dim crystalReport1 As New CrystalReport3()

Dim dsCustomers1 As global_students = GetGlobalStudentData(sqlsearch1)

crystalReport1.SetDataSource(dsCustomers1)

Me.CrystalReportViewer2.ReportSource = crystalReport1

Me.CrystalReportViewer2.RefreshReport()

ElseIf TabControl1.SelectedTab Is tbGraphView Then

End If

ElseIf dbStudentFilter.SelectedItem = "Student Name" And txtsearch.Text.Trim IsNot "" Then

If TabControl1.SelectedTab Is tbTableView Then

Dim sqlsearch As String

sqlsearch = "SELECT ID as [Student-ID], Tag_id as [Tag-ID], Firstname as Firstname,


lastname as Lastname, Gender as Gender, birthday as D_O_B, Age as Age, Department as [Level], Class
as Class, Guardiannumber1 as [Guardian_1#], ReceiveSms as SMS FROM global_students WHERE
firstname LIKE '%" & txtsearch.Text & "%'" & " OR lastname LIKE '%" & txtsearch.Text & "%'" & ""

' Once again we execute the SQL statements against our DataBase

Dim adapter As New OleDbDataAdapter(sqlsearch, myconnection)

' Shows the records and updates the DataGridView

Dim dt As New DataTable("global_students")


adapter.Fill(dt)

BunifuDataGridView3.DataSource = dt

Label25.Text = dt.Rows.Count

If dt.Rows.Count = 0 Then

MsgBox("The entered information was not found. Please try again.")

End If

ElseIf TabControl1.SelectedTab Is tbReportView Then

Dim sqlsearch1 As String

sqlsearch1 = "SELECT ID, Tag_id, Firstname as Firstname, lastname as Lastname,


middlename, Gender as Gender, birthday, Age as Age, Department, Class as Class, Guardiannumber1,
address, city, parish, ReceiveSms FROM global_students WHERE firstname LIKE '%" & txtsearch.Text &
"%'" & " OR lastname LIKE '%" & txtsearch.Text & "%'" & ""

Dim crystalReport1 As New CrystalReport3()

Dim dsCustomers1 As global_students = GetGlobalStudentData(sqlsearch1)

crystalReport1.SetDataSource(dsCustomers1)

Me.CrystalReportViewer2.ReportSource = crystalReport1

Me.CrystalReportViewer2.RefreshReport()

ElseIf TabControl1.SelectedTab Is tbGraphView Then

End If

ElseIf dbStudentFilter.SelectedItem = "Guardian_1 #" And txtsearch.Text.Trim IsNot "" Then

If TabControl1.SelectedTab Is tbTableView Then


Dim sqlsearch As String

sqlsearch = "SELECT ID as [Student-ID], Tag_id as [Tag-ID], Firstname as Firstname,


lastname as Lastname, Gender as Gender, birthday as D_O_B, Age as Age, Department as [Level], Class
as Class, Guardiannumber1 as [Guardian_1#], ReceiveSms as SMS FROM global_students WHERE
Guardiannumber1 LIKE '%" & txtsearch.Text & "%'" & ""

' Once again we execute the SQL statements against our DataBase

Dim adapter As New OleDbDataAdapter(sqlsearch, myconnection)

' Shows the records and updates the DataGridView

Dim dt As New DataTable("global_students")

adapter.Fill(dt)

BunifuDataGridView3.DataSource = dt

Label25.Text = dt.Rows.Count

If dt.Rows.Count = 0 Then

MsgBox("The entered information was not found. Please try again.")

End If

ElseIf TabControl1.SelectedTab Is tbReportView Then

Dim sqlsearch1 As String

sqlsearch1 = "SELECT ID, Tag_id, Firstname as Firstname, lastname as Lastname,


middlename, Gender as Gender, birthday, Age as Age, Department, Class as Class, Guardiannumber1,
address, city, parish, ReceiveSms FROM global_students WHERE Guardiannumber1 LIKE '%" &
txtsearch.Text & "%'" & ""

Dim crystalReport1 As New CrystalReport3()

Dim dsCustomers1 As global_students = GetGlobalStudentData(sqlsearch1)

crystalReport1.SetDataSource(dsCustomers1)

Me.CrystalReportViewer2.ReportSource = crystalReport1

Me.CrystalReportViewer2.RefreshReport()

ElseIf TabControl1.SelectedTab Is tbGraphView Then


End If

End If

ElseIf dbRecordType.SelectedItem = "Staff" Then

If dbStaffFilter.SelectedItem = "All" Then

globalRegGridStaff()

ElseIf dbStaffFilter.SelectedItem = "Staff ID" And txtsearch.Text.Trim IsNot "" Then

If TabControl1.SelectedTab Is tbTableView Then

Dim sqlsearch As String

sqlsearch = "SELECT Tag_id as [Tag-ID], staff_id as [Staff-ID], Firstname as Firstname,


lastname as Lastname, Gender as Gender, stafftype as [Staff Type], Department as [Level],
contactnumber as [Contact #] FROM global_staff WHERE staff_id LIKE '%" & txtsearch.Text & "%'" & ""

' Once again we execute the SQL statements against our DataBase

Dim adapter As New OleDbDataAdapter(sqlsearch, myconnection)

' Shows the records and updates the DataGridView

Dim dt As New DataTable("global_staff")

adapter.Fill(dt)

BunifuDataGridView3.DataSource = dt

Label25.Text = dt.Rows.Count

If dt.Rows.Count = 0 Then
MsgBox("The entered information was not found. Please try again.")

End If

ElseIf TabControl1.SelectedTab Is tbReportView Then

Dim sqlsearch1 As String

sqlsearch1 = "SELECT Tag_id, staff_id, Firstname as Firstname, lastname as Lastname,


Gender as Gender, stafftype, Department, contactnumber, address, postoffice, city, age, birthday, parish,
title, ReceiveSms FROM global_staff WHERE staff_id LIKE '%" & txtsearch.Text & "%'" & ""

Dim crystalReport1 As New CrystalReport4()

Dim dsCustomers1 As global_staff = GetGlobalStaffData(sqlsearch1)

crystalReport1.SetDataSource(dsCustomers1)

Me.CrystalReportViewer2.ReportSource = crystalReport1

Me.CrystalReportViewer2.RefreshReport()

ElseIf TabControl1.SelectedTab Is tbGraphView Then

End If

ElseIf dbStaffFilter.SelectedItem = "Staff Name" And txtsearch.Text.Trim IsNot "" Then

If TabControl1.SelectedTab Is tbTableView Then

Dim sqlsearch As String

sqlsearch = "SELECT Tag_id as [Tag-ID], staff_id as [Staff-ID], Firstname as Firstname,


lastname as Lastname, Gender as Gender, stafftype as [Staff Type], Department as [Level],
contactnumber as [Contact #] FROM global_staff WHERE firstname LIKE '%" & txtsearch.Text & "%'" & "
OR lastname LIKE '%" & txtsearch.Text & "%'" & ""
' Once again we execute the SQL statements against our DataBase

Dim adapter As New OleDbDataAdapter(sqlsearch, myconnection)

' Shows the records and updates the DataGridView

Dim dt As New DataTable("global_staff")

adapter.Fill(dt)

BunifuDataGridView3.DataSource = dt

Label25.Text = dt.Rows.Count

If dt.Rows.Count = 0 Then

MsgBox("The entered information was not found. Please try again.")

End If

ElseIf TabControl1.SelectedTab Is tbReportView Then

Dim sqlsearch1 As String

sqlsearch1 = "SELECT Tag_id, staff_id, Firstname as Firstname, lastname as Lastname,


Gender as Gender, stafftype, Department, contactnumber, address, postoffice, city, age, birthday, parish,
title, ReceiveSms FROM global_staff WHERE firstname LIKE '%" & txtsearch.Text & "%'" & " OR lastname
LIKE '%" & txtsearch.Text & "%'" & ""

Dim crystalReport1 As New CrystalReport4()

Dim dsCustomers1 As global_staff = GetGlobalStaffData(sqlsearch1)

crystalReport1.SetDataSource(dsCustomers1)
Me.CrystalReportViewer2.ReportSource = crystalReport1

Me.CrystalReportViewer2.RefreshReport()

ElseIf TabControl1.SelectedTab Is tbGraphView Then

End If

ElseIf dbStaffFilter.SelectedItem = "Contact #" And txtsearch.Text.Trim IsNot "" Then

If TabControl1.SelectedTab Is tbTableView Then

Dim sqlsearch As String

sqlsearch = "SELECT Tag_id as [Tag-ID], staff_id as [Staff-ID], Firstname as Firstname,


lastname as Lastname, Gender as Gender, stafftype as [Staff Type], Department as [Level],
contactnumber as [Contact #] FROM global_staff WHERE contactnumber LIKE '%" & txtsearch.Text & "%'"
& ""

' Once again we execute the SQL statements against our DataBase

Dim adapter As New OleDbDataAdapter(sqlsearch, myconnection)

' Shows the records and updates the DataGridView

Dim dt As New DataTable("global_staff")

adapter.Fill(dt)

BunifuDataGridView3.DataSource = dt

Label25.Text = dt.Rows.Count

If dt.Rows.Count = 0 Then

MsgBox("The entered information was not found. Please try again.")


End If

ElseIf TabControl1.SelectedTab Is tbReportView Then

Dim sqlsearch1 As String

sqlsearch1 = "SELECT Tag_id, staff_id, Firstname as Firstname, lastname as Lastname,


Gender as Gender, stafftype, Department, contactnumber, address, postoffice, city, age, birthday, parish,
title, ReceiveSms FROM global_staff WHERE contactnumber LIKE '%" & txtsearch.Text & "%'" & ""

Dim crystalReport1 As New CrystalReport4()

Dim dsCustomers1 As global_staff = GetGlobalStaffData(sqlsearch1)

crystalReport1.SetDataSource(dsCustomers1)

Me.CrystalReportViewer2.ReportSource = crystalReport1

Me.CrystalReportViewer2.RefreshReport()

ElseIf TabControl1.SelectedTab Is tbGraphView Then

End If

End If
Else

End If

End If

End If

End Sub

Private Function GetGlobalStudentData(ByVal sqlsearch As String) As global_students

Dim adapter As New OleDbDataAdapter(sqlsearch, myconnection)

Dim dt As New global_students()

adapter.Fill(dt, "global_students")

Return dt

End Function

Private Function GetActiveStudentData(ByVal sqlsearch As String) As students

Dim adapter As New OleDbDataAdapter(sqlsearch, myconnection)

Dim dt As New students()

adapter.Fill(dt, "students")

Return dt

End Function

Private Function GetGlobalStaffData(ByVal sqlsearch As String) As global_staff

Dim adapter As New OleDbDataAdapter(sqlsearch, myconnection)

Dim dt As New global_staff()


adapter.Fill(dt, "global_staff")

Return dt

End Function

Private Function GetActiveStaffData(ByVal sqlsearch As String) As staff

Dim adapter As New OleDbDataAdapter(sqlsearch, myconnection)

Dim dt As New staff()

adapter.Fill(dt, "staff")

Return dt

End Function

Private Sub Button34_Click(sender As Object, e As EventArgs)

'retrieveExcludedates()

End Sub

' Private Sub Button34_Click_1(sender As Object, e As EventArgs) Handles Button34.Click

' CODE INSERT

' Dim sqlupdate As String


' Dim time As String = "duration"

' sqlupdate = "UPDATE controls SET term_start=@term_start, term_end=@term_end WHERE


time_flag='" & time & "'"

'Dim cmd As New OleDbCommand(sqlupdate, myconnection)

' cmd.Parameters.Add(New OleDbParameter("@term_start", DateTimePicker11.Text))

' cmd.Parameters.Add(New OleDbParameter("@term_end", DateTimePicker12.Text))

' Try

' myconnection.Open()

'If MessageBox.Show("Are you sure you want to Term Dates?", "Change",


MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

'If (cmd.ExecuteNonQuery() > 0) Then

' MsgBox("Term Date was Updated")

'End If

' End If

' Catch ex As Exception

' MsgBox(ex.Message)

' Finally

' myconnection.Close()

' End Try

' End Sub

'Private Sub serialport1_datareceived(ByVal sender As Object, ByVal e As


System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived

' Dim datain As String = ""


' Dim numbytes As Integer = SerialPort1.BytesToRead

' For i As Integer = 1 To numbytes

' datain &= Chr(SerialPort1.ReadChar)

' Next

' test(datain)

'End Sub

'Private Sub test(ByVal indata As String)

' rcvdata &= indata

'End Sub

#End Region

Private Sub ComboBox4_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs)

'Label93.Text = Trim(Mid(ComboBox4.Text, 1, 5))

If SerialPort1.IsOpen Then

SerialPort1.Close()

If SerialPort1.IsOpen Then

'Label86.Text = "CONNECTED"

Else

'Label86.Text = "DISCONNECTED"

ActiveControl = txtid

End If

Else

Try
With SerialPort1

'.PortName = Label93.Text

.BaudRate = 9600

.Parity = IO.Ports.Parity.None

.DataBits = 8

.StopBits = IO.Ports.StopBits.One

.Handshake = IO.Ports.Handshake.None

.RtsEnable = True

.ReceivedBytesThreshold = 1

.NewLine = vbCr

.ReadTimeout = 1000

.Open()

End With

If SerialPort1.IsOpen Then

'Label86.Text = "CONNECTED"

ActiveControl = txtid

' txtid.Focus()

Else

' Label86.Text = "got some errors"

End If

Catch ex As Exception

MsgBox(ex.Message)

End Try

End If

End Sub
Private Sub rdtoall_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles rdtoall.CheckedChanged

If rdtoall.Checked = True Then

RadioButton10.Enabled = False

RadioButton9.Enabled = False

RadioButton5.Enabled = False

ComboBox13.Enabled = False

ComboBox12.Enabled = False

TextBox38.Enabled = False

Else

RadioButton10.Enabled = True

RadioButton5.Enabled = True

RadioButton9.Enabled = True

ComboBox13.Enabled = True

ComboBox12.Enabled = True

TextBox38.Enabled = True

End If

End Sub

'Private Sub DateTimePicker7_ValueChanged(sender As Object, e As EventArgs) Handles


BunifuDatePicker21.ValueChanged

' 'Dim myDayString As String = System.DateTime.Now.DayOfWeek.ToString()


' 'Dim i As System.DayOfWeek = DateTimePicker7.Value.DayOfWeek

' 'If i = System.DayOfWeek.Sunday Or i = System.DayOfWeek.Saturday Then

' ' 'MessageBox.Show("Please try again, can't select a weekend day")

' ' Return

' 'Else

' ' myDayString = DateTimePicker7.Value.DayOfWeek.ToString()

' 'End If

' 'Return

'End Sub

' Private Sub Button30_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


Button30.Click

' txtRX.Clear()

' txtRX2.Clear()

' SerialPort1.Write("at" & vbCr)

'If Label13.Text.ToLower = "connected" Then

'End If

' End Sub


' Private Sub Button31_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button31.Click

' SerialPort1.Write("AT+CSMP?" & vbCr)

' SerialPort1.Write("AT+CSMP=17,167,0,16" & vbCr)

'If Label13.Text.ToLower = "connected" Then

'End If

' End Sub

Private Sub Timer4_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


Timer4.Tick

If gtimeLeft > 0 Then

gtimeLeft -= 1

Console.WriteLine(gtimeLeft & " seconds")

Else

Timer4.[Stop]()

Console.WriteLine("running")

BackgroundWorker1.RunWorkerAsync()

End If

End Sub

Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As


System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork

Console.WriteLine("working")

update_from_linked_table()

check_ODBC_status()
End Sub

Private Sub BackgroundWorker1_RunWorkerCompleted(ByVal sender As Object, ByVal e As


System.ComponentModel.RunWorkerCompletedEventArgs) Handles
BackgroundWorker1.RunWorkerCompleted

Timer4.Start()

Console.WriteLine("done")

gtimeLeft = 60

End Sub

Public Sub check_ODBC_status()

Dim dbConnectionInfo As String = "DESCRIPTION=;DSN=Production_DB_Connection;"

Try

'Connection

Dim MyConnection As New OdbcConnection(dbConnectionInfo)

MyConnection.Open()

Console.WriteLine("Connection State::" & MyConnection.State.ToString)

SetODBCLabel("Connected")

Catch MyOdbcException As OdbcException

'dim i as integer

'Console.WriteLine(MyOdbcException.ToString)

Console.WriteLine("connetion is closed")

SetODBCLabel("Disconnected")

End Try
End Sub

Private Sub SetODBCLabel(ByVal [text] As String)

' InvokeRequired required compares the thread ID of the'

' calling thread to the thread ID of the creating thread.'

' If these threads are different, it returns true.'

If Me.Label17.InvokeRequired Then

Dim d As New SetTextCallback(AddressOf SetODBCLabel)

Me.Invoke(d, New Object() {[text]})

Else

Me.Label17.Text = [text]

sstd = [text]

End If

End Sub

Public Sub dailyGraphs()

'provider = "provider = microsoft.ace.oledb.12.0; data source=studentattendancesystem.accdb;


Persist Security Info=False;"

'myconnection.ConnectionString = provider

Dim sql As String

sql = "SELECT tag_id FROM students"

Dim adapter As New OleDbDataAdapter(sql, myconnection)

Dim dt As New DataTable("students")

adapter.Fill(dt)

'BunifuLabel10.Text = dt.Rows.Count

SetLabel10(dt.Rows.Count)
Dim totalstudent As Integer = dt.Rows.Count

Dim sql2 As String

sql2 = "SELECT tag_id FROM studentsrecords INNER JOIN controls ON studentsrecords.time_in <=
controls.late_time WHERE studentsrecords.date_in = #" & DateTime.Now.ToString("MM/d/yyyy") & "#"

Dim adapter2 As New OleDbDataAdapter(sql2, myconnection)

Dim dt2 As New DataTable("students")

adapter2.Fill(dt2)

BunifuLabel163.Text = dt2.Rows.Count

SetLabel163(dt2.Rows.Count)

'late sql

Dim sql3 As String

sql3 = "SELECT tag_id FROM studentsrecords INNER JOIN controls ON studentsrecords.time_in >=
controls.late_time WHERE studentsrecords.date_in = #" & DateTime.Now.ToString("MM/d/yyyy") & "#"

Dim adapter3 As New OleDbDataAdapter(sql3, myconnection)

Dim dt3 As New DataTable("students")

adapter3.Fill(dt3)

'BunifuLabel161.Text = dt3.Rows.Count

SetLabel161(dt3.Rows.Count)

'absent

Dim sql4 As String

sql4 = "SELECT tag_id FROM studentsrecords WHERE flag ='0' AND studentsrecords.date_in = #" &
DateTime.Now.ToString("MM/d/yyyy") & "#"

Dim adapter4 As New OleDbDataAdapter(sql4, myconnection)


Dim dt4 As New DataTable("students")

adapter4.Fill(dt4)

'BunifuLabel159.Text = dt4.Rows.Count

SetLabel159(dt4.Rows.Count)

'boys

Dim sql5 As String

sql5 = "SELECT tag_id FROM students WHERE gender='Male'"

Dim adapter5 As New OleDbDataAdapter(sql5, myconnection)

Dim dt5 As New DataTable("students")

adapter5.Fill(dt5)

'Label7.Text = dt5.Rows.Count

SetLabel7(dt5.Rows.Count)

Dim boy As Integer = dt5.Rows.Count

'girls

Dim sql6 As String

sql6 = "SELECT tag_id FROM students WHERE gender='Female'"

Dim adapter6 As New OleDbDataAdapter(sql6, myconnection)

Dim dt6 As New DataTable("students")

adapter6.Fill(dt6)

'Label8.Text = dt6.Rows.Count

SetLabel8(dt6.Rows.Count)
'BunifuCircleProgress1.Value = boy / totalstudent * 100

'BunifuCircleProgress1.Text = BunifuCircleProgress1.Value.ToString()

'BunifuCircleProgress1.Update()

Dim data As List(Of Double) = New List(Of Double)()

Dim data1 As List(Of Double) = New List(Of Double)()

'# of departments

Dim sql7 As String

sql7 = "SELECT DptCombo FROM controlsdpt"

Dim adapter7 As New OleDbDataAdapter(sql7, myconnection)

Dim dt7 As New DataTable("students")

adapter7.Fill(dt7)

'BunifuLabel156.Text = dt7.Rows.Count

Dim department As Integer = dt7.Rows.Count

'Label9.Text = dt7.Rows.Count

SetLabel9(dt7.Rows.Count)

'# of classes

Dim sql8 As String

sql8 = "SELECT ClassCombo FROM controls"

Dim adapter8 As New OleDbDataAdapter(sql8, myconnection)

Dim dt8 As New DataTable("students")


adapter8.Fill(dt8)

Dim classes As Integer = dt8.Rows.Count

'Label1.Text = dt8.Rows.Count

SetLabel1(dt8.Rows.Count)

'BunifuProgressBar1.Value = department

'BunifuProgressBar2.Value = classes

End Sub

Public Sub SetLabel10(ByVal [text] As String)

' InvokeRequired required compares the thread ID of the'

' calling thread to the thread ID of the creating thread.'

' If these threads are different, it returns true.'

If Me.BunifuLabel10.InvokeRequired Then

Dim d As New SetTextCallback(AddressOf SetLabel10)

Me.Invoke(d, New Object() {[text]})

Else

Me.BunifuLabel10.Text = [text]

End If

End Sub

Public Sub SetLabel163(ByVal [text] As String)

If Me.BunifuLabel163.InvokeRequired Then

Dim d As New SetTextCallback(AddressOf SetLabel163)

Me.Invoke(d, New Object() {[text]})

Else
Me.BunifuLabel163.Text = [text]

End If

End Sub

Private Sub Button3_Click_2(sender As Object, e As EventArgs)

MsgBox(myconnection.State.ToString)

End Sub

Private Sub MonthlyDropdown2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles


MonthlyDropdown2.SelectedIndexChanged

If MonthlyDropdown2.SelectedIndex < MonthlyDropdown.SelectedIndex Then

MsgBox("The months selected cannot occur in the past.")

MonthlyDropdown2.Text = MonthlyDropdown.Text

End If

End Sub

Private Sub YearEnd_SelectedIndexChanged(sender As Object, e As EventArgs) Handles


YearEnd.SelectedIndexChanged

If YearEnd.SelectedIndex < YearStart.SelectedIndex Then

MsgBox("The years selected cannot occur in the past.")

YearEnd.Text = YearStart.Text

End If
End Sub

Private Sub DashboardDatePicker2_ValueChanged(sender As Object, e As EventArgs) Handles


DashboardDatePicker2.ValueChanged

If DashboardDatePicker2.Value.Date < DashboardDatePicker.Value.Date Then

MsgBox("The dates selected cannot occur in the past.")

DashboardDatePicker2.Value = DashboardDatePicker.Value.Date

End If

End Sub

Private Sub MonthlyDropdown_SelectedIndexChanged(sender As Object, e As EventArgs) Handles


MonthlyDropdown.SelectedIndexChanged

If MonthlyDropdown.SelectedIndex > MonthlyDropdown2.SelectedIndex Then

MsgBox("The months selected cannot occur in the future.")

MonthlyDropdown.Text = MonthlyDropdown2.Text

End If

End Sub

Private Sub DashboardDatePicker_ValueChanged(sender As Object, e As EventArgs) Handles


DashboardDatePicker.ValueChanged

If DashboardDatePicker.Value.Date > DashboardDatePicker2.Value.Date Then

MsgBox("The dates selected cannot occur in the future.")

DashboardDatePicker.Value = DashboardDatePicker2.Value.Date

End If

End Sub

Private Sub YearStart_SelectedIndexChanged(sender As Object, e As EventArgs) Handles


YearStart.SelectedIndexChanged

If YearStart.SelectedIndex > YearEnd.SelectedIndex Then

MsgBox("The years selected cannot occur in the past.")

YearStart.Text = YearEnd.Text

End If

End Sub

Private Sub BunifuRadioButton1_CheckedChanged2(sender As Object, e As


Bunifu.UI.WinForms.BunifuRadioButton.CheckedChangedEventArgs)

'If BunifuRadioButton1.Checked = True Then

' txtsearch.Enabled = False

' txtsearch.Clear()

'Else

' txtsearch.Enabled = True

'End If

End Sub

Public Sub refreshRegGrid()

If TabControl1.SelectedTab Is tbTableView Then

Dim sqlsearch As String

sqlsearch = "SELECT ID as [Student-ID], Tag_id as [Tag-ID], Firstname as Firstname, lastname as


Lastname, Gender as Gender, birthday as D_O_B, Age as Age, Department as [Level], Class as Class,
Guardiannumber1 as [Guardian_1#], ReceiveSms as SMS FROM students"

'sqlsearch = "SELECT ID as [Student-ID], Tag_id as [Tag-ID], Firstname as Firstname, lastname as


Lastname FROM students"
' Once again we execute the SQL statements against our DataBase

Dim adapter As New OleDbDataAdapter(sqlsearch, myconnection)

' Shows the records and updates the DataGridView

Dim dt As New DataTable("students")

adapter.Fill(dt)

BunifuDataGridView3.DataSource = dt

Label25.Text = dt.Rows.Count

ElseIf TabControl1.SelectedTab Is tbReportView Then

Dim sqlsearch1 As String

sqlsearch1 = "SELECT ID, Tag_id, Firstname as Firstname, lastname as Lastname, middlename,


Gender as Gender, birthday, Age as Age, Department, Class as Class, Guardiannumber1, address, city,
parish, ReceiveSms FROM students"

Dim crystalReport1 As New CrystalReport5()

Dim dsCustomers1 As students = GetActiveStudentData(sqlsearch1)

crystalReport1.SetDataSource(dsCustomers1)

Me.CrystalReportViewer2.ReportSource = crystalReport1

Me.CrystalReportViewer2.RefreshReport()

ElseIf TabControl1.SelectedTab Is tbGraphView Then


End If

End Sub

Public Sub refreshRegGridStaff()

If TabControl1.SelectedTab Is tbTableView Then

Dim sqlsearchstaff As String

sqlsearchstaff = "SELECT staff_id as [Staff-ID], Tag_id as [Tag-ID], Firstname as Firstname, lastname


as Lastname, Gender as Gender, stafftype as [Staff Type], Department as [Level], contactnumber as
[Contact #] FROM staff"

' Once again we execute the SQL statements against our DataBase

Dim adapter As New OleDbDataAdapter(sqlsearchstaff, myconnection)

' Shows the records and updates the DataGridView

Dim dt As New DataTable("staff")

adapter.Fill(dt)

BunifuDataGridView3.DataSource = dt

Label25.Text = dt.Rows.Count

ElseIf TabControl1.SelectedTab Is tbReportView Then

Dim sqlsearch1 As String

sqlsearch1 = "SELECT Tag_id, staff_id, Firstname as Firstname, lastname as Lastname, Gender as


Gender, stafftype, Department, contactnumber, address, postoffice, city, age, birthday, parish, title,
ReceiveSms FROM staff"

Dim crystalReport1 As New CrystalReport6()

Dim dsCustomers1 As staff = GetActiveStaffData(sqlsearch1)

crystalReport1.SetDataSource(dsCustomers1)

Me.CrystalReportViewer2.ReportSource = crystalReport1

Me.CrystalReportViewer2.RefreshReport()

ElseIf TabControl1.SelectedTab Is tbGraphView Then

End If

End Sub

Public Sub globalRegGridStudents()

If TabControl1.SelectedTab Is tbTableView Then

Dim sqlsearchstaff As String

sqlsearchstaff = "SELECT ID as [Student-ID], Tag_id as [Tag-ID], Firstname as Firstname, lastname


as Lastname, Gender as Gender, birthday as D_O_B, Age as Age, Department as [Level], Class as Class,
Guardiannumber1 as [Guardian_1#], ReceiveSms as SMS FROM global_students"

' Once again we execute the SQL statements against our DataBase
Dim adapter As New OleDbDataAdapter(sqlsearchstaff, myconnection)

' Shows the records and updates the DataGridView

Dim dt As New DataTable("global_students")

adapter.Fill(dt)

BunifuDataGridView3.DataSource = dt

Label25.Text = dt.Rows.Count

ElseIf TabControl1.SelectedTab Is tbReportView Then

Dim sqlsearch1 As String

sqlsearch1 = "SELECT ID, Tag_id, Firstname as Firstname, lastname as Lastname, middlename,


Gender as Gender, birthday, Age as Age, Department, Class as Class, Guardiannumber1, address, city,
parish, ReceiveSms FROM global_students"

Dim crystalReport1 As New CrystalReport3()

Dim dsCustomers1 As global_students = GetGlobalStudentData(sqlsearch1)

crystalReport1.SetDataSource(dsCustomers1)

Me.CrystalReportViewer2.ReportSource = crystalReport1

Me.CrystalReportViewer2.RefreshReport()

ElseIf TabControl1.SelectedTab Is tbGraphView Then

End If

End Sub

Public Sub globalRegGridStaff()

If TabControl1.SelectedTab Is tbTableView Then


Dim sqlsearchstaff As String

sqlsearchstaff = "SELECT staff_id as [Staff-ID], Tag_id as [Tag-ID], Firstname as Firstname, lastname


as Lastname, Gender as Gender, stafftype as [Staff Type], Department as [Level], contactnumber as
[Contact #] FROM global_staff"

' Once again we execute the SQL statements against our DataBase

Dim adapter As New OleDbDataAdapter(sqlsearchstaff, myconnection)

' Shows the records and updates the DataGridView

Dim dt As New DataTable("global_staff")

adapter.Fill(dt)

BunifuDataGridView3.DataSource = dt

Label25.Text = dt.Rows.Count

ElseIf TabControl1.SelectedTab Is tbReportView Then

Dim sqlsearch1 As String

sqlsearch1 = "SELECT Tag_id, staff_id, Firstname as Firstname, lastname as Lastname, Gender as


Gender, stafftype, Department, contactnumber, address, postoffice, city, age, birthday, parish, title,
ReceiveSms FROM global_staff"

Dim crystalReport1 As New CrystalReport4()

Dim dsCustomers1 As global_staff = GetGlobalStaffData(sqlsearch1)

crystalReport1.SetDataSource(dsCustomers1)

Me.CrystalReportViewer2.ReportSource = crystalReport1

Me.CrystalReportViewer2.RefreshReport()
ElseIf TabControl1.SelectedTab Is tbGraphView Then

End If

End Sub

Private Sub rdId_CheckedChanged2(sender As Object, e As


Bunifu.UI.WinForms.BunifuRadioButton.CheckedChangedEventArgs)

End Sub

Public Sub SetLabel161(ByVal [text] As String)

If Me.BunifuLabel161.InvokeRequired Then

Dim d As New SetTextCallback(AddressOf SetLabel161)

Me.Invoke(d, New Object() {[text]})

Else

Me.BunifuLabel161.Text = [text]

End If

End Sub

Private Sub BunifuButton32_Click(sender As Object, e As EventArgs) Handles BunifuButton32.Click

Dim img As String


Dim myStream As Stream = Nothing

Dim openFileDialog1 As New OpenFileDialog()

openFileDialog1.InitialDirectory = "c:\"

openFileDialog1.Filter = Nothing

openFileDialog1.FilterIndex = 2

openFileDialog1.RestoreDirectory = True

openFileDialog1.FileName = ""

If openFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then

Try

myStream = openFileDialog1.OpenFile()

If (myStream IsNot Nothing) Then

BunifuTextBox54.Text = ""

img = openFileDialog1.FileName

BunifuPictureBox15.Image = System.Drawing.Bitmap.FromFile(img)

BunifuTextBox54.Text = openFileDialog1.FileName

End If

Catch Ex As Exception

MessageBox.Show("Cannot read file from disk. Original error: " & Ex.Message)
Finally

If (myStream IsNot Nothing) Then

myStream.Close()

End If

End Try

End If

End Sub

Private Sub Button6_Click_3(sender As Object, e As EventArgs)

Dim num As Integer = 0

For Each oRow As DataGridViewRow In DataGridView4.Rows

If oRow.Cells(0).Value = True Then

num += 1

Else

End If

Next

If num >= 1 Then

Console.WriteLine("pane zviripo")

Else

Console.WriteLine("no no no")

End If

End Sub
Private Sub BunifuButton37_Click(sender As Object, e As EventArgs) Handles BunifuButton37.Click

Dim num As Integer = 0

For Each dat In tempDate.ToList

If dat <> ListBox2.SelectedItem Then

num += 0

Else

num += 1

End If

Next

If num = 0 Then

ListBox2.Items.Remove(ListBox2.SelectedItem)

End If

End Sub

Public Sub tempSaveDatesForExcluding()

For Each dat In tempDate.ToList

If dat = ListBox2.SelectedItem Then

ListBox2.Items.Remove(ListBox2.SelectedItem)

End If

Next

End Sub

Private Sub BunifuButton39_Click_1(sender As Object, e As EventArgs) Handles BunifuButton39.Click


Dim b As String = ""

For Each a As String In ListBox2.Items

b += a & ","

Next

Dim dialog As passwordPrompt = New passwordPrompt()

If dialog.ShowDialog() = DialogResult.OK Then

If dialog.BunifuTextBox1.Text = "" And dialog.BunifuTextBox2.Text = "" Then

MsgBox("Please enter Username and Password.")

Else

Dim userfound As Integer = LoginFunc(dialog.BunifuTextBox1.Text, dialog.BunifuTextBox2.Text)

If userfound = 1 Then

SaveData(b)

ElseIf userfound = 2 Then

MsgBox("Please enter the Local Admin user credentials.")

Else

MsgBox("The Username or Password is incorrenct.")

End If

End If

End If

dialog.Dispose()

myconnection.Close()
End Sub

Private Sub BunifuButton31_Click_1(sender As Object, e As EventArgs) Handles BunifuButton31.Click

If ListBox2.SelectedIndex >= 0 Then

Dim dialog As passwordPrompt = New passwordPrompt()

If dialog.ShowDialog() = DialogResult.OK Then

If dialog.BunifuTextBox1.Text = "" And dialog.BunifuTextBox2.Text = "" Then

MsgBox("Please enter Username and Password.")

Else

Dim userfound As Integer = LoginFunc(dialog.BunifuTextBox1.Text,


dialog.BunifuTextBox2.Text)

If userfound = 1 Then

If MessageBox.Show("Are you sure you want to delete the selected dates?", "DELETE",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

Dim i As Integer

For i = 0 To ListBox2.SelectedIndices.Count - 1

ListBox2.Items.RemoveAt(ListBox2.SelectedIndices(0))

Next

Dim b As String = ""


For Each a As String In ListBox2.Items

b += a & ","

Next

SaveData(b)

End If

ElseIf userfound = 2 Then

MsgBox("Please enter the Local Admin user credentials.")

Else

MsgBox("The Username or Password is incorrenct.")

End If

End If

End If

dialog.Dispose()

myconnection.Close()

Else

MsgBox("At least one date from the list must be selected.")

End If

End Sub

Private Sub BunifuButton30_Click(sender As Object, e As EventArgs) Handles BunifuButton30.Click


Dim st As DateTime = BunifuTextBox11.Text

Dim lt As DateTime = DateTimePicker6.Value.ToLongTimeString

Dim ab As DateTime = TextBox27.Text

If lt.TimeOfDay > st.TimeOfDay And lt.TimeOfDay <= ab.TimeOfDay Then

Dim dialog As passwordPrompt = New passwordPrompt()

If dialog.ShowDialog() = DialogResult.OK Then

If dialog.BunifuTextBox1.Text = "" And dialog.BunifuTextBox2.Text = "" Then

MsgBox("please enter username and password")

Else

Dim userfound As Integer = LoginFunc(dialog.BunifuTextBox1.Text,


dialog.BunifuTextBox2.Text)

If userfound = 1 Then

' CODE INSERT

Dim sqlupdate As String

Dim time As String = "duration"

sqlupdate = "UPDATE controls SET late_time=@late_time WHERE time_flag='" & time & "'"

Dim cmd As New OleDbCommand(sqlupdate, myconnection)

cmd.Parameters.Add(New OleDbParameter("@late_time", DateTimePicker6.Text))


Try

myconnection.Open()

If MessageBox.Show("Are you sure you want to update the School's Late Time?",
"Change", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK
Then

If (cmd.ExecuteNonQuery() > 0) Then

MsgBox("The School's Late Time was updated successfully.")

myconnection.Close()

retrieveTime()

End If

End If

Catch ex As Exception

MsgBox(ex.Message)

Finally

myconnection.Close()

End Try

ElseIf userfound = 2 Then

MsgBox("Please enter the Local Admin user credentials.")

Else

MsgBox("The Username or Password is incorrenct.")

End If

End If

End If
dialog.Dispose()

myconnection.Close()

Else

MsgBox("The Late Time must be later than the current Start Time and earlier than the current
Absent Time.")

End If

End Sub

Private Sub BunifuButton23_Click(sender As Object, e As EventArgs) Handles BunifuButton23.Click

Dim st As DateTime = DateTimePicker4.Value.ToLongTimeString

Dim lt As DateTime = BunifuTextBox10.Text

If st.TimeOfDay <= lt.TimeOfDay Then

Dim dialog As passwordPrompt = New passwordPrompt()

If dialog.ShowDialog() = DialogResult.OK Then

If dialog.BunifuTextBox1.Text = "" And dialog.BunifuTextBox2.Text = "" Then

MsgBox("Please enter Username and Password.")

Else

Dim userfound As Integer = LoginFunc(dialog.BunifuTextBox1.Text,


dialog.BunifuTextBox2.Text)

If userfound = 1 Then

' CODE INSERT


Dim sqlupdate As String

Dim time As String = "duration"

sqlupdate = "UPDATE controls SET start_time=@start_time WHERE time_flag='" & time &
"'"

Dim cmd As New OleDbCommand(sqlupdate, myconnection)

cmd.Parameters.Add(New OleDbParameter("@start_time", DateTimePicker4.Text))

Try

myconnection.Open()

If MessageBox.Show("Are you sure you want to update the School's Start Time?",
"Change", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK
Then

If (cmd.ExecuteNonQuery() > 0) Then

MsgBox("The School's Start Time was updated successfully.")

myconnection.Close()

retrieveTime()

End If

End If

Catch ex As Exception

MsgBox(ex.Message)

End Try

ElseIf userfound = 2 Then

MsgBox("Please enter the Local Admin user credentials.")


Else

MsgBox("The Username or Password is incorrenct.")

End If

End If

End If

dialog.Dispose()

myconnection.Close()

Else

MsgBox("The Start Time must be earlier than the current Late Time.")

End If

End Sub

Private Sub Button6_Click_5(sender As Object, e As EventArgs)

Dim i As Integer

For i = 0 To ListBox2.SelectedIndices.Count - 1

ListBox2.Items.RemoveAt(ListBox2.SelectedIndices(0))

Next

End Sub

Private Sub RadioButton2_CheckedChanged(sender As Object, e As EventArgs) Handles


RadioButton2.CheckedChanged

If RadioButton2.Checked = True Then


TextBox21.Enabled = False

ComboBox8.Enabled = False

ComboBox9.Enabled = False

Else

TextBox21.Enabled = True

TextBox21.Text = ""

ComboBox8.Enabled = True

ComboBox9.Enabled = True

End If

End Sub

Public Sub SetLabel159(ByVal [text] As String)

If Me.BunifuLabel159.InvokeRequired Then

Dim d As New SetTextCallback(AddressOf SetLabel159)

Me.Invoke(d, New Object() {[text]})

Else

Me.BunifuLabel159.Text = [text]

End If

End Sub

Public Sub SetLabel7(ByVal [text] As String)

If Me.Label7.InvokeRequired Then

Dim d As New SetTextCallback(AddressOf SetLabel7)


Me.Invoke(d, New Object() {[text]})

Else

Me.Label7.Text = [text]

End If

End Sub

Public Sub SetLabel8(ByVal [text] As String)

If Me.Label8.InvokeRequired Then

Dim d As New SetTextCallback(AddressOf SetLabel8)

Me.Invoke(d, New Object() {[text]})

Else

Me.Label8.Text = [text]

End If

End Sub

Public Sub SetLabel9(ByVal [text] As String)

If Me.Label9.InvokeRequired Then

Dim d As New SetTextCallback(AddressOf SetLabel9)

Me.Invoke(d, New Object() {[text]})

Else

Me.Label9.Text = [text]

End If

End Sub

Public Sub SetLabel1(ByVal [text] As String)

If Me.Label1.InvokeRequired Then

Dim d As New SetTextCallback(AddressOf SetLabel1)


Me.Invoke(d, New Object() {[text]})

Else

Me.Label1.Text = [text]

End If

End Sub

Private Sub pluggedInWatcher_EventArrived(sender As Object, e As EventArrivedEventArgs) Handles


pluggedInWatcher.EventArrived

Console.WriteLine("Plugged In")

If Find_Device_By_VID_PID(VID_PID_device, endText) Then

SetLabel30Text("Connected")

Else

SetLabel30Text("Disconnected")

End If

End Sub

Private Sub pluggedOutWatcher_EventArrived(sender As Object, e As EventArrivedEventArgs) Handles


pluggedOutWatcher.EventArrived

If SerialPort1.IsOpen Then

Else

Label13.Text = "Disconnected"

'Label90.Text = "Disconnected"
SetControlEnabled(Button16, True)

SetControlEnabled(ComboBox2, True)

SetCombo2("")

Label13.ForeColor = Color.Red

'Label90.ForeColor = Color.Red

End If

If Find_Device_By_VID_PID(VID_PID_device, endText) Then

SetLabel30Text("Connected")

Else

SetLabel30Text("Disconnected")

End If

End Sub

Private Sub SetControlEnabled(ByVal ctl As Control, ByVal enabled As Boolean)

If ctl.InvokeRequired Then

ctl.BeginInvoke(New Action(Of Control, Boolean)(AddressOf SetControlEnabled), ctl, enabled)

Else

ctl.Enabled = enabled

End If

End Sub

Private Sub Timesettings_Click(sender As Object, e As EventArgs) Handles Timesettings.Click

End Sub
Public Sub SetCombo2(ByVal [text] As String)

If Me.ComboBox2.InvokeRequired Then

Dim d As New SetTextCallback(AddressOf SetCombo2)

Me.Invoke(d, New Object() {[text]})

Else

Me.ComboBox2.Text = [text]

End If

End Sub

Public Sub SetLabel30Text(ByVal [text] As String)

If Me.Label30.InvokeRequired Then

Dim d As New SetTextCallback(AddressOf SetLabel30Text)

Me.Invoke(d, New Object() {[text]})

Else

Me.Label30.Text = [text]

End If

End Sub

Private Sub btnSchoolYear_Click(sender As Object, e As EventArgs) Handles btnSchoolYear.Click

Dim currentDate As Date = "8/15/" + Now.Date.Year.ToString()

Dim yr As String = Now.Date.Year + 1

Dim endNextYear As Date = "7/31/" + yr


If dtpSchoolStart.Value.Date > currentDate And dtpSchoolEnd.Value.Date < endNextYear Then

If DateDiff("M", dtpSchoolStart.Value.Date, dtpSchoolEnd.Value.Date) > 7 Then

If dtpSchoolStart.Value.Date < dtpSchoolEnd.Value.Date Then

Dim dialog As passwordPrompt = New passwordPrompt()

If dialog.ShowDialog() = DialogResult.OK Then

If dialog.BunifuTextBox1.Text = "" And dialog.BunifuTextBox2.Text = "" Then

MsgBox("Please enter Username and Password.")

Else

Dim userfound As Integer = LoginFunc(dialog.BunifuTextBox1.Text,


dialog.BunifuTextBox2.Text)

If userfound = 1 Then

'' CODE INSERT

Dim sqlupdate As String

Dim time As String = "duration"

sqlupdate = "UPDATE controls SET school_year_start=@school_year_start,


school_year_end=@school_year_end WHERE time_flag='" & time & "'"

Dim cmd As New OleDbCommand(sqlupdate, myconnection)

cmd.Parameters.Add(New OleDbParameter("@school_year_start",
dtpSchoolStart.Value.Date))

cmd.Parameters.Add(New OleDbParameter("@school_year_end ",


dtpSchoolEnd.Value.Date))
Try

myconnection.Open()

If MessageBox.Show("Are you sure you set this School Year?", "KADTRACK",


MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

If (cmd.ExecuteNonQuery() > 0) Then

MsgBox("The School Year was updated successfully.")

myconnection.Close()

getYearAndTerm()

' retrieveSignout()

' SetTarget()

' retrieveTime()

End If

End If

myconnection.Close()

Catch ex As Exception

MsgBox(ex.Message)

Finally

myconnection.Close()

End Try

ElseIf userfound = 2 Then

MsgBox("Please enter the Local Admin user credentials.")

Else

MsgBox("The Username or Password is incorrenct.")

End If

End If
End If

dialog.Dispose()

Else

MessageBox.Show("School Year cannot be less than the current year", "KADTRACK")

End If

Else

MessageBox.Show("End Date cannot be less than Start Date", "KADTRACK")

End If

End If

End Sub

Private Sub btnAddTitles_Click(sender As Object, e As EventArgs) Handles btnAddTitles.Click

If txtTitle.Text = "" Then

MessageBox.Show("Please enter a specific Title to be added.", "KADTRACK")

Else

Dim sql As String = "INSERT INTO titles (title) VALUES(@title)"

cmd = New OleDbCommand(sql, myconnection)

cmd.Parameters.AddWithValue("@title", txtTitle.Text)

Try

myconnection.Open()

If MessageBox.Show("Are you sure you want to add this Title to the database?", "WARNING",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

If cmd.ExecuteNonQuery() > 0 Then

MsgBox("Successfully Entered a Title. ")


End If

myconnection.Close()

retrieveTitle()

dailyGraphs()

txtTitle.Text = ""

End If

Catch ex As Exception

MsgBox(ex.Message)

myconnection.Close()

retrieveTitle()

End Try

End If

End Sub

Private Sub btnTitleDelete_Click(sender As Object, e As EventArgs) Handles btnTitleDelete.Click

If txtTitle.Text = "" Or cbTitlePreview.SelectedIndex < 0 Then

MessageBox.Show("Please select a specific Title from the dropdown box.", "KADTRACK")

Else

Dim sql As String = "DELETE * FROM titles WHERE title='" & txtTitle.Text & "'"

cmd = New OleDbCommand(sql, myconnection)

Dim dialog As passwordPrompt = New passwordPrompt()

If dialog.ShowDialog() = DialogResult.OK Then


If dialog.BunifuTextBox1.Text = "" And dialog.BunifuTextBox2.Text = "" Then

MsgBox("Please enter Username and Password.")

Else

Dim userfound As Integer = LoginFunc(dialog.BunifuTextBox1.Text,


dialog.BunifuTextBox2.Text)

If userfound = 1 Then

Try

myconnection.Open()

If MessageBox.Show("Are you sure you want to delete this Title?", "DELETE",


MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

If (cmd.ExecuteNonQuery() > 0) Then

MsgBox("The Title was successfully deleted.")

txtTitle.Text = ""

cbTitlePreview.Text = ""

End If

End If

myconnection.Close()

retrieveTitle()

Catch ex As Exception

MsgBox(ex.Message)

myconnection.Close()

retrieveTitle()
End Try

ElseIf userfound = 2 Then

MsgBox("Please enter the Local Admin user credentials.")

Else

MsgBox("The Username or Password is incorrenct.")

End If

End If

End If

dialog.Dispose()

End If

End Sub

Private Sub btnDeleteSubjects_Click(sender As Object, e As EventArgs) Handles


btnDeleteSubjects.Click

If txtSubjects.Text = "" Or cbSubjectsPreview.SelectedIndex < 0 Then

MessageBox.Show("Please select a specific Subject from the dropdown box.", "KADTRACK")

Else

Dim sql As String = "DELETE * FROM subjects WHERE subject='" & txtSubjects.Text & "'"

cmd = New OleDbCommand(sql, myconnection)

Dim dialog As passwordPrompt = New passwordPrompt()

If dialog.ShowDialog() = DialogResult.OK Then

If dialog.BunifuTextBox1.Text = "" And dialog.BunifuTextBox2.Text = "" Then


MsgBox("Please enter Username and Password.")

Else

Dim userfound As Integer = LoginFunc(dialog.BunifuTextBox1.Text,


dialog.BunifuTextBox2.Text)

If userfound = 1 Then

Try

myconnection.Open()

If MessageBox.Show("Are you sure you want to delete this Subject?", "DELETE",


MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

If (cmd.ExecuteNonQuery() > 0) Then

MsgBox("The Subject was successfully deleted.")

txtSubjects.Text = ""

cbSubjectsPreview.Text = ""

End If

End If

myconnection.Close()

retrieveSubject()

Catch ex As Exception

MsgBox(ex.Message)

myconnection.Close()

retrieveSubject()

End Try
ElseIf userfound = 2 Then

MsgBox("Please enter the Local Admin user credentials.")

Else

MsgBox("The Username or Password is incorrenct.")

End If

End If

End If

dialog.Dispose()

End If

End Sub

Private Sub btnAddSubjects_Click(sender As Object, e As EventArgs) Handles btnAddSubjects.Click

If txtSubjects.Text = "" Then

MessageBox.Show("Please enter a specific Subject to be added.", "KADTRACK")

Else

Dim sql As String = "INSERT INTO subjects (subject) VALUES(@subject)"

cmd = New OleDbCommand(sql, myconnection)

cmd.Parameters.AddWithValue("@subject", txtSubjects.Text)

Try

myconnection.Open()

If MessageBox.Show("Are you sure you want to add this Subject to the database?",
"WARNING", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) =
Windows.Forms.DialogResult.OK Then

If cmd.ExecuteNonQuery() > 0 Then


MsgBox("Successfully Entered a Subject.")

End If

myconnection.Close()

retrieveSubject()

dailyGraphs()

txtSubjects.Text = ""

End If

Catch ex As Exception

MsgBox(ex.Message)

myconnection.Close()

retrieveSubject()

End Try

End If

End Sub

Private Sub cbTitlePreview_SelectedIndexChanged(sender As Object, e As EventArgs) Handles


cbTitlePreview.SelectedIndexChanged

txtTitle.Text = cbTitlePreview.SelectedItem

End Sub

Private Sub cbSubjectsPreview_SelectedIndexChanged(sender As Object, e As EventArgs) Handles


cbSubjectsPreview.SelectedIndexChanged

txtSubjects.Text = cbSubjectsPreview.SelectedItem

End Sub

Private Sub btnAddTerms_Click(sender As Object, e As EventArgs) Handles btnAddTerms.Click


Dim strtDate As DateTime

Dim endDate As DateTime

Dim preEndTerm As DateTime

strtDate = dtpTermStart.Value.Date

endDate = dtpTermEnd.Value.Date

Dim sql1 As String

sql1 = "SELECT * FROM terms"

Dim adapter As New OleDbDataAdapter(sql1, myconnection)

Dim dt As New DataTable("students")

adapter.Fill(dt)

If dt.Rows.Count = 0 Then

strtDate = dtpSchoolStart.Value.Date

Else

Dim cnt As Integer = dt.Rows().Count

preEndTerm = dt.Rows(cnt - 1).Item("End_date")

End If

If dtpTermStart.Value.Date = Date.Today Or dtpTermEnd.Value.Date = Date.Today Or


cbTermAdd.SelectedIndex < 0 Then

MessageBox.Show("Please Enter a valid Start Or End date.", "KADTRACK")

Else

If dtpTermStart.Value > dtpSchoolStart.Value And dtpTermEnd.Value < dtpSchoolEnd.Value Then

If dtpTermStart.Value.Date < dtpTermEnd.Value.Date Then


If dtpTermStart.Value.Date > preEndTerm.Date Then

Dim sql As String = "INSERT INTO terms (id_number, start_date, end_date)


VALUES(id_number, start_date, end_date)"

cmd = New OleDbCommand(sql, myconnection)

cmd.Parameters.AddWithValue("@id_number", cbTermAdd.SelectedItem)

cmd.Parameters.AddWithValue("@start_date", strtDate)

cmd.Parameters.AddWithValue("@end_date", endDate)

Try

myconnection.Open()

If MessageBox.Show("Are you sure you want to add this Term?", "WARNING",


MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

If cmd.ExecuteNonQuery() > 0 Then

MsgBox("Successfully Entered a term.")

End If

myconnection.Close()

dailyGraphs()

retrieveTerm()

cbTermAdd.Text = ""

dtpTermStart.Value = Now

dtpTermEnd.Value = Now

End If

Catch ex As Exception

MsgBox(ex.Message)

Finally
myconnection.Close()

End Try

Else

MessageBox.Show("The Start date of a term cannot be earlier than the End Date of the
previous term", "KADTRACK")

End If

Else

MessageBox.Show("The End date cannot be earlier than the Start date.", "KADTRACK")

End If

Else

MessageBox.Show("Term cannot be less than the start date of the School Year. Or Term cannot
be greater than the end date of the School Year.", "KADTRACK")

End If

End If

End Sub

Private Sub addStaffStudent_Click(sender As Object, e As EventArgs) Handles addStaffStudent.Click

BunifuPages1.SetPage("Add Staff")

End Sub

'Private Sub BunifuButton50_Click(sender As Object, e As EventArgs) Handles BunifuButton50.Click

' BunifuPages1.SetPage("records")

'End Sub
'Private Sub BunifuButton47_Click(sender As Object, e As EventArgs) Handles BunifuButton47.Click

' BunifuPages1.SetPage("AddStudent")

'End Sub

'Private Sub BunifuButton44_Click(sender As Object, e As EventArgs) Handles BunifuButton44.Click

' BunifuPages1.SetPage("Add Stuff")

'End Sub

Private Sub btnDeleteTerm_Click(sender As Object, e As EventArgs) Handles btnDeleteTerm.Click

If dpTermPreview.SelectedItem = "" Or dpTermPreview.SelectedIndex < 0 Then

MessageBox.Show("Please select a specific Term from the dropdown box", "KADTRACK")

Else

Dim sql As String = "DELETE * FROM terms WHERE id_number=" & dpTermPreview.SelectedIndex
+ 1 & ""

cmd = New OleDbCommand(sql, myconnection)

Dim dialog As passwordPrompt = New passwordPrompt()

If dialog.ShowDialog() = DialogResult.OK Then

If dialog.BunifuTextBox1.Text = "" And dialog.BunifuTextBox2.Text = "" Then

MsgBox("Please enter Username and Password.")

Else

Dim userfound As Integer = LoginFunc(dialog.BunifuTextBox1.Text,


dialog.BunifuTextBox2.Text)
If userfound = 1 Then

Try

myconnection.Open()

If MessageBox.Show("Are you sure you want to delete this Term?", "DELETE",


MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

If (cmd.ExecuteNonQuery() > 0) Then

MsgBox("The Term was successfully deleted.")

dpTermPreview.Text = ""

End If

End If

myconnection.Close()

retrieveTerm()

Catch ex As Exception

MsgBox(ex.Message)

myconnection.Close()

retrieveTerm()

End Try

ElseIf userfound = 2 Then

MsgBox("Please enter the Local Admin user credentials.")

Else

MsgBox("The Username or Password is incorrenct.")

End If
End If

End If

dialog.Dispose()

End If

End Sub

Private Sub txtFirstNameStaff_TextChanged(sender As Object, e As EventArgs) Handles


txtFirstNameStaff.TextChanged, txtTagIdStaff.TextChanged, txtLastNameStaff.TextChanged,
txtContactStaff.TextChanged, txtStaffID.TextChanged, txtAddressStaff.TextChanged,
txtPostOfficeStaff.TextChanged, txtCityStaff.TextChanged, txtParishStaff.TextChanged

If txtFirstNameStaff.Text <> "" Then

Dim a As String = txtFirstNameStaff.Text

txtFirstNameStaff.Text = (StrConv(a, VbStrConv.ProperCase))

txtFirstNameStaff.Select(txtFirstNameStaff.Text.Length, 0)

End If

If txtTagIdStaff.Text <> "" Then

Dim a As String = txtTagIdStaff.Text

txtTagIdStaff.Text = (StrConv(a, VbStrConv.ProperCase))

txtTagIdStaff.Select(txtTagIdStaff.Text.Length, 0)

End If

If txtLastNameStaff.Text <> "" Then

Dim a As String = txtLastNameStaff.Text


txtLastNameStaff.Text = (StrConv(a, VbStrConv.ProperCase))

txtLastNameStaff.Select(txtLastNameStaff.Text.Length, 0)

End If

If txtContactStaff.Text <> "" Then

Dim a As String = txtContactStaff.Text

txtContactStaff.Text = (StrConv(a, VbStrConv.ProperCase))

txtContactStaff.Select(txtContactStaff.Text.Length, 0)

End If

'If txtStaffID.Text <> "" Then

' Dim a As String = txtStaffID.Text

' txtStaffID.Text = (StrConv(a, VbStrConv.ProperCase))

' txtStaffID.Select(txtStaffID.Text.Length, 0)

'End If

If txtAddressStaff.Text <> "" Then

Dim a As String = txtAddressStaff.Text

txtAddressStaff.Text = (StrConv(a, VbStrConv.ProperCase))

txtAddressStaff.Select(txtAddressStaff.Text.Length, 0)

End If

If txtPostOfficeStaff.Text <> "" Then

Dim a As String = txtPostOfficeStaff.Text

txtPostOfficeStaff.Text = (StrConv(a, VbStrConv.ProperCase))


txtPostOfficeStaff.Select(txtPostOfficeStaff.Text.Length, 0)

End If

If txtCityStaff.Text <> "" Then

Dim a As String = txtCityStaff.Text

txtCityStaff.Text = (StrConv(a, VbStrConv.ProperCase))

txtCityStaff.Select(txtCityStaff.Text.Length, 0)

End If

If txtParishStaff.Text <> "" Then

Dim a As String = txtParishStaff.Text

txtParishStaff.Text = (StrConv(a, VbStrConv.ProperCase))

txtParishStaff.Select(txtParishStaff.Text.Length, 0)

End If

End Sub

Private Sub btnAddRecordStaff_Click(sender As Object, e As EventArgs) Handles


btnAddRecordStaff.Click

If txtFirstNameStaff.Text.Trim = "" Or txtContactStaff.Text.Trim = "" Or txtLastNameStaff.Text.Trim = ""


Or txtTagIdStaff.Text.Trim = "" Or txtAddressStaff.Text.Trim = "" Or txtAgeStaff.Text.Trim = "" Or
txtStaffID.Text.Trim = "" Or txtCityStaff.Text.Trim = "" Or txtParishStaff.Text.Trim = "" Or
txtPostOfficeStaff.Text.Trim = "" Or cbStaffType.Text = "" Or dbTitleStaff.Text = "" Or cbLevelStaff.Text = ""
Or rbMaleStaff.Checked = False And rbFemaleStaff.Checked = False Then

MsgBox("Please fill in all required fields marked with ' * '")


Else

' CODE INSERT

Dim sqlinsert As String

' We use the INSERT statement which tells our program to add the information

' from the Forms Text fields into the Databases columns.

'sqlinsert = "INSERT INTO Staff (tag_id, staff_id, contactnumber, firstname, lastname, gender,
address, city, parish, postoffice, stafftype, department, ReceiveSms )" &

' "VALUES( @tag_id, @staff_id, @contactnumber, @firstname, @lastname, @gender, @address,


@city, @parish, @postoffice, @stafftype, @level, @ReceiveSms )"

'sqlinsert = "INSERT INTO Staff (tag_id, staff_id, contactnumber, firstname, lastname, gender,
address, postoffice, city, parish, stafftype, department, ReceiveSms )" &

' "VALUES( @tag_id, @staff_id, @contactnumber, @firstname, @lastname, @gender, @address,


@postoffice, @city, @parish, @stafftype, @department, @ReceiveSms )"

sqlinsert = "INSERT INTO staff (tag_id, staff_id, contactnumber, firstname, lastname, gender,
address, postoffice, city, parish, stafftype, department, ReceiveSms, age, birthday, title, userType, status,
PicturePath )" &

"VALUES( @tag_id, @staff_id, @contactnumber, @firstname, @lastname, @gender, @address,


@postoffice, @city, @parish, @stafftype, @department, @ReceiveSms, @age, @birthday, @title, 'staff',
'1', '" & Replace$(imgbox, "'", "''") & "' )"

Dim cmd As New OleDbCommand(sqlinsert, myconnection)

'Dim cmd As New OleDbCommand(sqlinsert, myconnection)

' This assigns the values for our columns in the DataBase.

' To ensure the correct values are written to the correct column

cmd.Parameters.Add(New OleDbParameter("@tag_id", txtTagIdStaff.Text))


cmd.Parameters.Add(New OleDbParameter("@staff_id", txtStaffID.Text))

cmd.Parameters.Add(New OleDbParameter("@contactnumber", txtContactStaff.Text))

cmd.Parameters.Add(New OleDbParameter("@firstname", txtFirstNameStaff.Text))

cmd.Parameters.Add(New OleDbParameter("@lastname", txtLastNameStaff.Text))

cmd.Parameters.Add(New OleDbParameter("@gender", staffmale))

cmd.Parameters.Add(New OleDbParameter("@address", txtAddressStaff.Text))

cmd.Parameters.Add(New OleDbParameter("@postoffice", txtPostOfficeStaff.Text))

cmd.Parameters.Add(New OleDbParameter("@city", txtCityStaff.Text))

cmd.Parameters.Add(New OleDbParameter("@parish", txtParishStaff.Text))

cmd.Parameters.Add(New OleDbParameter("@stafftype", cbStaffType.SelectedItem))

cmd.Parameters.Add(New OleDbParameter("@department", cbLevelStaff.SelectedItem))

cmd.Parameters.Add(New OleDbParameter("@ReceiveSms", staffsms))

cmd.Parameters.Add(New OleDbParameter("@age", txtAgeStaff.Text))

cmd.Parameters.Add(New OleDbParameter("@birthday", dtpDobStaff.Value.Date))

cmd.Parameters.Add(New OleDbParameter("@title", dbTitleStaff.SelectedItem))

Dim sqlinsertg As String

sqlinsertg = "INSERT INTO global_staff (tag_id, staff_id, contactnumber, firstname, lastname,


gender, address, postoffice, city, parish, stafftype, department, ReceiveSms, age, birthday, title, userType,
status, PicturePath )" &

"VALUES( @tag_id, @staff_id, @contactnumber, @firstname, @lastname, @gender, @address,


@postoffice, @city, @parish, @stafftype, @department, @ReceiveSms, @age, @birthday, @title, 'staff',
'1' '" & Replace$(imgbox, "'", "''") & "' )"

Dim cmdsg As New OleDbCommand(sqlinsertg, myconnection)

cmdsg.Parameters.Add(New OleDbParameter("@tag_id", txtTagIdStaff.Text))

cmdsg.Parameters.Add(New OleDbParameter("@staff_id", txtStaffID.Text))

cmdsg.Parameters.Add(New OleDbParameter("@contactnumber", txtContactStaff.Text))

cmdsg.Parameters.Add(New OleDbParameter("@firstname", txtFirstNameStaff.Text))

cmdsg.Parameters.Add(New OleDbParameter("@lastname", txtLastNameStaff.Text))

cmdsg.Parameters.Add(New OleDbParameter("@gender", staffmale))

cmdsg.Parameters.Add(New OleDbParameter("@address", txtAddressStaff.Text))

cmdsg.Parameters.Add(New OleDbParameter("@postoffice", txtPostOfficeStaff.Text))

cmdsg.Parameters.Add(New OleDbParameter("@city", txtCityStaff.Text))

cmdsg.Parameters.Add(New OleDbParameter("@parish", txtParishStaff.Text))

cmdsg.Parameters.Add(New OleDbParameter("@stafftype", cbStaffType.SelectedItem))

cmdsg.Parameters.Add(New OleDbParameter("@department", cbLevelStaff.SelectedItem))

cmdsg.Parameters.Add(New OleDbParameter("@ReceiveSms", staffsms))

cmdsg.Parameters.Add(New OleDbParameter("@age", txtAgeStaff.Text))

cmdsg.Parameters.Add(New OleDbParameter("@birthday", dtpDobStaff.Value.Date))

cmdsg.Parameters.Add(New OleDbParameter("@title", dbTitleStaff.SelectedItem))

Try

myconnection.Open()
If MessageBox.Show("Are you sure the information has been entered correctly?", "Save",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

If (cmd.ExecuteNonQuery() > 0) Then

cmdsg.ExecuteNonQuery()

myconnection.Close()

MsgBox("Staff registered successfully!")

Example1()

clearfieldsnew()

generate_student_id()

dailyGraphs()

update_linked_table()

' RefreshDGV()

filldb()

Update()

End If

End If

Catch ex As Exception

MsgBox(ex.Message)

myconnection.Close()

Finally

myconnection.Close()

End Try

End If

End Sub
'Private Sub BunifuButton46_Click(sender As Object, e As EventArgs) Handles BunifuButton46.Click

' BunifuPages1.SetPage("Add Staff")

'End Sub

Private Sub BunifuToggleSwitch3_CheckedChanged(sender As Object, e As


Bunifu.UI.WinForms.BunifuToggleSwitch.CheckedChangedEventArgs) Handles
BunifuToggleSwitch3.CheckedChanged

End Sub

Private Sub rbMaleStaff_CheckedChanged(sender As Object, e As EventArgs) Handles


rbMaleStaff.CheckedChanged

If rbMaleStaff.Checked = True Then

staffmale = "Male"

End If

End Sub

Function Find_Device_By_VID_PID(Device_VID_PID As String, endtxt As String) As Boolean

Try

' See if the desired device shows up in the device manager. '

Dim info As Management.ManagementObject

Dim search As System.Management.ManagementObjectSearcher

search = New System.Management.ManagementObjectSearcher("SELECT * From


Win32_PnPEntity")

For Each info In search.Get()

' Go through each device detected.'


Dim ID As String = CType(info("DeviceID"), String)

If InStr(info.Path.ToString, Device_VID_PID) Then

Dim final = info.Path.ToString.Substring(info.Path.ToString.Length - 14, 13)

If final = endtxt Then

Return True

End If

End If

Next

Catch ex As Exception

End Try

'We did not find the device we were looking for '

Return False

End Function

Private Sub rbFemaleStaff_CheckedChanged(sender As Object, e As EventArgs) Handles


rbFemaleStaff.CheckedChanged

If rbFemaleStaff.Checked = True Then

staffmale = "Female"

End If

End Sub

Private Sub BunifuLabel167_Click(sender As Object, e As EventArgs) Handles BunifuLabel167.Click

End Sub
Private Sub btnAddStaff2_Click(sender As Object, e As EventArgs) Handles btnAddStaff2.Click

BunifuPages1.SetPage("Add Staff")

End Sub

Private Sub btnRecordLookUp_Click(sender As Object, e As EventArgs) Handles btnRecordLookUp.Click

BunifuPages1.SetPage("records")

End Sub

Private Sub btnAddStudent2_Click(sender As Object, e As EventArgs) Handles btnAddStudent2.Click

BunifuPages1.SetPage("AddStudent")

End Sub

Private Sub cbStaffType_SelectedIndexChanged(sender As Object, e As EventArgs) Handles


cbStaffType.SelectedIndexChanged

End Sub

Private Sub dbRecordType_SelectedIndexChanged(sender As Object, e As EventArgs) Handles


dbRecordType.SelectedIndexChanged

If dbRecordType.SelectedItem = "Student" Then

dbStaffFilter.Enabled = False

dbStudentFilter.Enabled = True

dbStaffFilter.Text = ""

dbStaffFilter.SelectedIndex = -1
ElseIf dbRecordType.SelectedItem = "Staff" Then

dbStudentFilter.Enabled = False

dbStaffFilter.Enabled = True

dbStudentFilter.Text = ""

dbStudentFilter.SelectedIndex = -1

End If

End Sub

Private Sub btnClearStaff_Click(sender As Object, e As EventArgs) Handles btnClearStaff.Click

clearfieldsnew()

End Sub

Private Sub BunifuToggleSwitch3_CheckedChanged_1(sender As Object, e As


Bunifu.UI.WinForms.BunifuToggleSwitch.CheckedChangedEventArgs) Handles
BunifuToggleSwitch3.CheckedChanged

End Sub

Private Sub dbStudentFilter_SelectedIndexChanged(sender As Object, e As EventArgs) Handles


dbStudentFilter.SelectedIndexChanged

If dbStudentFilter.SelectedItem = "All" Then

txtsearch.Enabled = False

txtsearch.Clear()

Else
txtsearch.Enabled = True

End If

If dbStudentFilter.SelectedItem = "Student ID" Then

txtsearch.PlaceholderText = "Enter Student ID"

ElseIf dbStudentFilter.SelectedItem = "Student Name" Then

txtsearch.PlaceholderText = "Enter Student Name"

ElseIf dbStudentFilter.SelectedItem = "Guardian_1 #" Then

txtsearch.PlaceholderText = "Enter Guardian_1 #"

Else

txtsearch.PlaceholderText = "Enter text"

End If

End Sub

Private Sub dbStaffFilter_SelectedIndexChanged(sender As Object, e As EventArgs) Handles


dbStaffFilter.SelectedIndexChanged

If dbStaffFilter.SelectedItem = "All" Then

txtsearch.Enabled = False

txtsearch.Clear()

Else

txtsearch.Enabled = True

End If

If dbStaffFilter.SelectedItem = "Staff ID" Then


txtsearch.PlaceholderText = "Enter Staff ID"

ElseIf dbStaffFilter.SelectedItem = "Staff Name" Then

txtsearch.PlaceholderText = "Enter Staff Name"

ElseIf dbStaffFilter.SelectedItem = "Contact #" Then

txtsearch.PlaceholderText = "Enter Contact #"

Else

txtsearch.PlaceholderText = "Enter text"

End If

End Sub

Private Sub dtpDobStaff_ValueChanged(sender As Object, e As EventArgs) Handles


dtpDobStaff.ValueChanged

End Sub

Private Sub btnCloseStaff_Click(sender As Object, e As EventArgs) Handles btnCloseStaff.Click

If MessageBox.Show("Are you sure you want to exit?", "Exit", MessageBoxButtons.OKCancel,


MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

BunifuPages1.SetPage("records")

UpdateClearfieldsNew()

refreshRegGridStaff()

Else
End If

End Sub

Private Sub btnUpdateStaff_Click(sender As Object, e As EventArgs) Handles btnUpdateStaff.Click

If txtStaffID2.Text.Trim = "" Or txtFirstNameStaff2.Text.Trim = "" Or txtLastNameStaff2.Text.Trim = ""


Or txtAddressStaff2.Text.Trim = "" Or txtContactStaff2.Text.Trim = "" Or dbLevelStaff.Text.Trim = "" Or
txtAgeStaff2.Text = "" Then

MsgBox("Please fill in all required fields marked with ' * '")

Else

Dim sqlupdate As String

' sqlupdate = "UPDATE staff SET tag_id=@tag_id, firstname=@firstname, lastname=@lastname,


contactnumber=@contactnumber, gender=@gender, address=@address," &

'"birthday=@birthday, age=@age, department=@department, PicturePath=@PicturePath,


ReceiveSms=@ReceiveSms WHERE tag_id='" & BunifuTextBox50.Text & "'"

sqlupdate = "UPDATE staff SET staff_id=@staff_id, firstname=@firstname, lastname=@lastname,


contactnumber=@contactnumber, gender=@gender, address=@address," &

"birthday=@birthday, age=@age, department=@department, PicturePath=@PicturePath,


ReceiveSms=@ReceiveSms WHERE tag_id='" & txtTagIdStaff2.Text & "'"

Dim cmd As New OleDbCommand(sqlupdate, myconnection)

cmd.Parameters.Add(New OleDbParameter("@staff_id", txtStaffID2.Text))

cmd.Parameters.Add(New OleDbParameter("@firstname", txtFirstNameStaff2.Text))

cmd.Parameters.Add(New OleDbParameter("@lastname", txtLastNameStaff2.Text))


cmd.Parameters.Add(New OleDbParameter("@contactnumber", txtContactStaff2.Text))

cmd.Parameters.Add(New OleDbParameter("@gender", ganderstaff))

cmd.Parameters.Add(New OleDbParameter("@address", txtAddressStaff2.Text))

cmd.Parameters.Add(New OleDbParameter("@birthday", dtpDobStaff2.Value.Date))

cmd.Parameters.Add(New OleDbParameter("@age", txtAgeStaff2.Text))

cmd.Parameters.Add(New OleDbParameter("@department", dbLevelStaff.Text))

cmd.Parameters.Add(New OleDbParameter("@PicturePath", Replace$(imgboxreplace, "'", "''")))

' cmd.Parameters.Add(New OleDbParameter("@PicturePath", Replace$(BunifuTextBox54.Text,


"'", "''")))

cmd.Parameters.Add(New OleDbParameter("@ReceiveSms", staffsms2))

'viewImage(dr("tag_id"))

' genderstaff(dr("tag_id"))

Try

'cmd.ExecuteNonQuery()

'MsgBox("Record updated successfully!")

' BunifuPages1.SetPage("records")
myconnection.Open()

If MessageBox.Show("Are you sure you want to update this record?", "UPDATE",


MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

If (cmd.ExecuteNonQuery() > 0) Then

'DeleteNotification("Report successfully deleted!", "System Delete Notification")

MsgBox("Record updated successfully.")

myconnection.Close()

' BunifuPages1.SetPage("records")

End If

Else

myconnection.Close()

End If

Catch ex As Exception

MsgBox(ex.Message)

Finally

myconnection.Close()

End Try

' This are subs in Module1, to clear all the TextBoxes on the form

' and refresh the DataGridView on the MainFsorm to show our new records.

ClearTextBox(Me)

refreshRegGridStaff()

End If

End Sub

Private Sub btnBrowseStaff_Click(sender As Object, e As EventArgs) Handles btnBrowseStaff.Click

Dim img As String


Dim myStream As Stream = Nothing

Dim openFileDialog1 As New OpenFileDialog()

openFileDialog1.InitialDirectory = "c:\"

openFileDialog1.Filter = Nothing

openFileDialog1.FilterIndex = 2

openFileDialog1.RestoreDirectory = True

openFileDialog1.FileName = ""

If openFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then

Try

myStream = openFileDialog1.OpenFile()

If (myStream IsNot Nothing) Then

imgbox = ""

img = openFileDialog1.FileName

pbStaffPhoto.Image = System.Drawing.Bitmap.FromFile(img)

imgbox = openFileDialog1.FileName

End If

Catch Ex As Exception

MessageBox.Show("Cannot read file from disk. Original error: " & Ex.Message)
Finally

If (myStream IsNot Nothing) Then

myStream.Close()

End If

End Try

End If

End Sub

Private Sub btnBrowseStaff2_Click(sender As Object, e As EventArgs) Handles btnBrowseStaff2.Click

Dim img As String

Dim myStream As Stream = Nothing

Dim openFileDialog1 As New OpenFileDialog()

openFileDialog1.InitialDirectory = "c:\"

openFileDialog1.Filter = Nothing

openFileDialog1.FilterIndex = 2

openFileDialog1.RestoreDirectory = True

openFileDialog1.FileName = ""

If openFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then

Try

myStream = openFileDialog1.OpenFile()

If (myStream IsNot Nothing) Then


imgboxreplace = ""

img = openFileDialog1.FileName

pbStaffPhoto2.Image = System.Drawing.Bitmap.FromFile(img)

imgboxreplace = openFileDialog1.FileName

End If

Catch Ex As Exception

MessageBox.Show("Cannot read file from disk. Original error: " & Ex.Message)

Finally

If (myStream IsNot Nothing) Then

myStream.Close()

End If

End Try

End If

End Sub

Private Sub dtpDobStaff2_ValueChanged(sender As Object, e As EventArgs) Handles


dtpDobStaff2.ValueChanged

Dim iDagdag As Integer

iDagdag = CInt(DateDiff(DateInterval.Year, dtpDobStaff2.Value.Date, Now) / 4)

txtAgeStaff2.Text = Floor((DateDiff(DateInterval.Day, dtpDobStaff2.Value.Date, Now) - iDagdag) /


365)

End Sub
Private Sub dbRegistryType_SelectedIndexChanged(sender As Object, e As EventArgs) Handles
dbRegistryType.SelectedIndexChanged

If dbRegistryType.SelectedItem = "Global" Then

btnRemoveActive.Enabled = False

Else

btnRemoveActive.Enabled = True

End If

End Sub

Private Sub btnRemoveActive_Click(sender As Object, e As EventArgs) Handles btnRemoveActive.Click

If txtsearch.Text.Trim = "" Then

MsgBox("You must first search for a record.")

Else

Dim dialog As passwordPrompt = New passwordPrompt()

If dialog.ShowDialog() = DialogResult.OK Then

If dialog.BunifuTextBox1.Text = "" And dialog.BunifuTextBox2.Text = "" Then

MsgBox("Please enter Username and Password.")

Else

Dim userfound As Integer = LoginFunc(dialog.BunifuTextBox1.Text,


dialog.BunifuTextBox2.Text)

If userfound = 1 Then

Try
myconnection.Open()

If dbRecordType.SelectedItem = "Student" Then

Dim sqldelete As String

sqldelete = "DELETE * FROM students WHERE id='" & txtsearch.Text & "'"

Dim Dcommand As New OleDbCommand(sqldelete, myconnection)

If MessageBox.Show("Are you sure you want to delete this record?", "DELETE",


MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

If (Dcommand.ExecuteNonQuery() > 0) Then

ActivetoGlobalStatus(txtsearch.Text)

DeleteNotification("Record successfully deleted!", "System Delete Notification")

myconnection.Close()

cleartxt()

refreshRegGrid()

dailyGraphs()

End If

ElseIf MessageBoxButtons.OKCancel Then

End If

ElseIf dbRecordType.SelectedItem = "Staff" Then

Dim sqldelete As String

sqldelete = "DELETE * FROM staff WHERE staff_id='" & txtsearch.Text & "'"

Dim Dcommand As New OleDbCommand(sqldelete, myconnection)


If MessageBox.Show("Are you sure you want to delete this record?", "DELETE",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

If (Dcommand.ExecuteNonQuery() > 0) Then

ActivetoGlobalStatus(txtsearch.Text)

DeleteNotification("Record successfully deleted!", "System Delete Notification")

myconnection.Close()

cleartxt()

refreshRegGrid()

dailyGraphs()

End If

ElseIf MessageBoxButtons.OKCancel Then

End If

End If

Catch ex As Exception

MsgBox(ex.Message & "or There is nothing to Delete")

'myconnection.Close()

End Try

ElseIf userfound = 2 Then

MsgBox("Please enter the Local Admin user credentials.")

Else

MsgBox("The Username or Password is incorrenct.")

End If

End If

End If
dialog.Dispose()

myconnection.Close()

End If

End Sub

Private Sub BunifuButton44_Click(sender As Object, e As EventArgs)

Dim crystalReport As New CrystalReport2()

Dim dsCustomers As students = GetData()

crystalReport.SetDataSource(dsCustomers)

Me.CrystalReportViewer2.ReportSource = crystalReport

Me.CrystalReportViewer2.RefreshReport()

End Sub

Private Sub BunifuButton45_Click_1(sender As Object, e As EventArgs)

Dim crystalReport As New CrystalReport3()

Dim dsCustomers As global_students = GetStudentData("SELECT * from global_students")

crystalReport.SetDataSource(dsCustomers)

Me.CrystalReportViewer2.ReportSource = crystalReport

Me.CrystalReportViewer2.RefreshReport()

End Sub

Private Function GetData() As students

Dim constr As String = "provider = microsoft.ace.oledb.12.0; data


source=studentattendancesystem.accdb; Persist Security Info=False;"

Using con As New OleDbConnection(constr)

Using cmd As New OleDbCommand("SELECT * FROM students")

Using sda As New OleDbDataAdapter()


cmd.Connection = con

sda.SelectCommand = cmd

Using dsCustomers As New students()

sda.Fill(dsCustomers, "students")

Return dsCustomers

End Using

End Using

End Using

End Using

End Function

Private Function GetStudentData(ByVal sql As String) As global_students

Dim adapter As New OleDbDataAdapter(sql, myconnection)

Dim dt As New global_students()

adapter.Fill(dt, "global_students")

Return dt

End Function

Private Sub rdtoall2_CheckedChanged(sender As Object, e As EventArgs) Handles


rdtoall2.CheckedChanged

If rdtoall2.Checked = True Then

rdStaffId.Enabled = False

rbStaffLevel.Enabled = False

ddStaffSms.Enabled = False
'ddStaffSms2.Enabled = False

tbStaffSms.Enabled = False

rbStaffLevel.Checked = False

rdStaffId.Checked = False

Else

rdStaffId.Enabled = True

rbStaffLevel.Enabled = True

ddStaffSms.Enabled = True

'ddStaffSms2.Enabled = True

tbStaffSms.Enabled = True

End If

End Sub

Private Sub rdSendStaff_CheckedChanged(sender As Object, e As EventArgs) Handles


rdSendStaff.CheckedChanged

LabelStaff.Text = 0

Dim dtt As New DataTable("staffs")

eDA.SelectCommand = New OleDbCommand("SELECT staff_ID, Firstname, lastname,


contactnumber, Department as [Level] FROM staff", myconnection)

eDS.Clear()

eDA.Fill(dtt)

dgvStaff.DataSource = dtt

If rdSendStaff.Checked = True Then

dgvStaff.Show()
Else

dgvStaff.Hide()

End If

End Sub

Private Sub rdStaffId_CheckedChanged(sender As Object, e As EventArgs) Handles


rdStaffId.CheckedChanged

LabelStaff.Text = 0

Dim dtt As New DataTable("staffs")

eDA.SelectCommand = New OleDbCommand("SELECT staff_ID, Firstname, lastname,


contactnumber, Department as [Level] FROM staff", myconnection)

eDS.Clear()

eDA.Fill(dtt)

dgvStaff.DataSource = dtt

If rdStaffId.Checked = True Then

dgvStaff.Show()

tbStaffSms.Enabled = True

ddStaffSms.Enabled = False

'ddStaffSms2.Enabled = False

Else

dgvStaff.Hide()

tbStaffSms.Enabled = False

tbStaffSms.Text = ""
ddStaffSms.Enabled = True

'ddStaffSms2.Enabled = True

End If

End Sub

Private Sub rbStaffLevel_CheckedChanged(sender As Object, e As EventArgs) Handles


rbStaffLevel.CheckedChanged

LabelStaff.Text = 0

Dim dtt As New DataTable("staffs")

eDA.SelectCommand = New OleDbCommand("SELECT staff_ID, Firstname, lastname,


contactnumber, department as [Level] FROM staff", myconnection)

eDS.Clear()

eDA.Fill(dtt)

dgvStaff.DataSource = dtt

If rbStaffLevel.Checked = True Then

dgvStaff.Show()

ddStaffSms.Enabled = True

'ddStaffSms2.Enabled = False

tbStaffSms.Enabled = False

Else

dgvStaff.Hide()

ddStaffSms.Enabled = False

ddStaffSms.Text = ""
'ddStaffSms2.Enabled = True

tbStaffSms.Enabled = True

End If

End Sub

Private Sub tbStaffSms_TextChanged(sender As Object, e As EventArgs) Handles


tbStaffSms.TextChanged

provider = "provider = microsoft.ace.oledb.12.0; data source=studentattendancesystem.accdb;


Persist Security Info=False;"

myconnection.ConnectionString = provider

' SQL Statement so our User can search for either FirstName or LastName

Dim sqlsearch As String

sqlsearch = "SELECT staff_id, Firstname, lastname, Gender, contactnumber, Department FROM staff
WHERE staff_id LIKE '%" & tbStaffSms.Text & "%'" & ""

' Once again we execute the SQL statements against our DataBase

Dim adapter As New OleDbDataAdapter(sqlsearch, myconnection)

' Shows the records and updates the DataGridView

Dim dt As New DataTable("staff")

adapter.Fill(dt)

dgvStaff.DataSource = dt

End Sub

Private Sub ddStaffSms_SelectedIndexChanged(sender As Object, e As EventArgs) Handles


ddStaffSms.SelectedIndexChanged

LabelStaff.Text = 0
drpt2 = ddStaffSms.SelectedItem

If rbStaffLevel.Checked = True Then

Dim sql As String

' sql = "SELECT staff_ID, Firstname, lastname, contactnumber, department as [Level] FROM staff
WHERE department='" & drpt2 & "'"

sql = "SELECT staff_id, Firstname, lastname, Gender, contactnumber, Department FROM staff
WHERE department LIKE '%" & drpt2 & "'"

Dim adapter As New OleDbDataAdapter(sql, myconnection)

Dim dt As New DataTable("staffs")

adapter.Fill(dt)

dgvStaff.DataSource = dt

End If

End Sub

Private Sub btnStaffSend_Click(sender As Object, e As EventArgs) Handles btnStaffSend.Click

Dim num As Integer = 0

Dim gridCheck As Boolean = False

For Each oRow As DataGridViewRow In dgvStaff.Rows

If oRow.Cells(0).Value = True Then

num += 1

Else

End If

Next
If num >= 1 Then

gridCheck = True

Else

gridCheck = False

End If

If rdSendStaff.Checked = True And Not tbStaffMessages.Text.Trim = "" And gridCheck = True Then

If smsApi = True Then

If MessageBox.Show("Are you sure you want to send this message?", "Message",


MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

numbers.Clear()

btnStaffSend.Enabled = False

For Each oRow As DataGridViewRow In dgvStaff.Rows

If oRow.Cells(0).Value = True Then

numbers.Add(oRow.Cells("Contactnumber").Value)

'ss(oRow.Cells(0).ColumnIndex) = tbStaffMessages.Text

sValue = tbStaffMessages.Text

End If

Next

NumWorkers = NumWorkers + 1

ReDim Workers(NumWorkers)

Workers(NumWorkers) = New BackgroundWorker

Workers(NumWorkers).WorkerReportsProgress = True

Workers(NumWorkers).WorkerSupportsCancellation = True

AddHandler Workers(NumWorkers).DoWork, AddressOf WorkerDoWork


AddHandler Workers(NumWorkers).ProgressChanged, AddressOf WorkerProgressChanged

AddHandler Workers(NumWorkers).RunWorkerCompleted, AddressOf WorkerCompleted

Workers(NumWorkers).RunWorkerAsync()

MsgBox("The message was successfully sent to the selected records.")

Else

End If

ElseIf gsm = True Then

If MessageBox.Show("Are you sure you want to send this message?", "Message",


MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

btnStaffSend.Enabled = False

'Dosms(oRow.Cells("Guardiannumber1").Value, tbStaffMessages.Text)

MsgBox("The message was successfully sent to the selected records.")

Else

End If

Else

End If

btnStaffSend.Enabled = True

clearSmsCon()

ElseIf rdtoall2.Checked = True And Not tbStaffMessages.Text.Trim = "" Then

If smsApi = True Then

If MessageBox.Show("Are you sure you want to send this message?", "Message",


MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

numbers.Clear()
myconnection.Open()

eDA.SelectCommand = New OleDbCommand("SELECT Guardiannumber1 FROM staff ",


myconnection)

eDS.Clear()

eDA.Fill(eDS)

btnStaffSend.Enabled = False

For i As Integer = 0 To eDS.Tables(0).Rows.Count - 1

eDR = eDS.Tables(0).Rows(i)

numbers.Add(eDR("Guardiannumber1"))

sValue = tbStaffMessages.Text

Next

NumWorkers = NumWorkers + 1

ReDim Workers(NumWorkers)

Workers(NumWorkers) = New BackgroundWorker

Workers(NumWorkers).WorkerReportsProgress = True

Workers(NumWorkers).WorkerSupportsCancellation = True

AddHandler Workers(NumWorkers).DoWork, AddressOf WorkerDoWork

AddHandler Workers(NumWorkers).ProgressChanged, AddressOf WorkerProgressChanged

AddHandler Workers(NumWorkers).RunWorkerCompleted, AddressOf WorkerCompleted

Workers(NumWorkers).RunWorkerAsync()

btnStaffSend.Enabled = True

MsgBox("Your custom message was successfully sent to all recipients")

clearSmsCon()

Else
End If

ElseIf gsm = True Then

If MessageBox.Show("Are you sure you want to send this message?", "Message",


MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

myconnection.Open()

eDA.SelectCommand = New OleDbCommand("SELECT Guardiannumber1 FROM staff ",


myconnection)

eDS.Clear()

eDA.Fill(eDS)

btnStaffSend.Enabled = False

For i As Integer = 0 To eDS.Tables(0).Rows.Count - 1

eDR = eDS.Tables(0).Rows(i)

Dosms(eDR("Guardiannumber1"), TextBox37.Text)

Next

btnStaffSend.Enabled = True

MsgBox("Your custom message was successfully sent to all recipients")

clearSmsCon()

Else

RetrieveChkSms()

End If

End If

ElseIf tbStaffMessages.Text.Trim = "" Then

MsgBox("The SMS Body field cannot be empty.")

Else

MsgBox("Please enter all required information.")

End If
End Sub

Private Sub rbStaffEnableAll_CheckedChanged(sender As Object, e As EventArgs) Handles


rbStaffEnableAll.CheckedChanged

If rbStaffEnableAll.Checked = True Then

rbStaffDisableAuto.Checked = False

rbStaffEnableAuto.Checked = False

rbStaffSignin.Checked = True

rbStaffSignout.Checked = True

rbStaffAbsentSms.Checked = True

rbStaffSignin.Enabled = False

rbStaffSignout.Enabled = False

rbStaffAbsentSms.Enabled = False

' CODE INSERT

Dim sqlupdate As String

Dim opt As String = "enableALLStaffSMS"

Dim state As String = "True"

sqlupdate = "UPDATE controlsignout SET timeset=@timeset WHERE flag='" & opt & "'"

Dim cmd As New OleDbCommand(sqlupdate, myconnection)

cmd.Parameters.Add(New OleDbParameter("@timeset", state))


Try

myconnection.Open()

cmd.ExecuteNonQuery()

Catch ex As Exception

MsgBox(ex.Message)

Finally

myconnection.Close()

End Try

Else

' CODE INSERT

Dim sqlupdate As String

Dim opt As String = "enableALLStaffSMS"

Dim state As String = "False"

sqlupdate = "UPDATE controlsignout SET timeset=@timeset WHERE flag='" & opt & "'"

Dim cmd As New OleDbCommand(sqlupdate, myconnection)

cmd.Parameters.Add(New OleDbParameter("@timeset", state))

Try

myconnection.Open()

cmd.ExecuteNonQuery()

Catch ex As Exception

MsgBox(ex.Message)
Finally

myconnection.Close()

End Try

End If

End Sub

Private Sub rbStaffEnableAuto_CheckedChanged(sender As Object, e As EventArgs) Handles


rbStaffEnableAuto.CheckedChanged

If rbStaffEnableAuto.Checked = True Then

rbStaffDisableAuto.Checked = False

rbStaffEnableAll.Checked = False

rbStaffSignin.Checked = True

rbStaffSignout.Checked = False

rbStaffAbsentSms.Checked = False

rbStaffSignin.Enabled = True

rbStaffSignout.Enabled = True

rbStaffAbsentSms.Enabled = True

btnStaffSend2.Enabled = True

' CODE INSERT

Dim sqlupdate As String

Dim opt As String = "enableManualSMS"

Dim state As String = "True"


sqlupdate = "UPDATE controlsignout SET timeset=@timeset WHERE flag='" & opt & "'"

Dim cmd As New OleDbCommand(sqlupdate, myconnection)

cmd.Parameters.Add(New OleDbParameter("@timeset", state))

Try

myconnection.Open()

cmd.ExecuteNonQuery()

Catch ex As Exception

MsgBox(ex.Message)

Finally

myconnection.Close()

End Try

Else

' CODE INSERT

Dim sqlupdate As String

Dim opt As String = "enableManualSMS"

Dim state As String = "False"

sqlupdate = "UPDATE controlsignout SET timeset=@timeset WHERE flag='" & opt & "'"

Dim cmd As New OleDbCommand(sqlupdate, myconnection)

cmd.Parameters.Add(New OleDbParameter("@timeset", state))


Try

myconnection.Open()

cmd.ExecuteNonQuery()

Catch ex As Exception

MsgBox(ex.Message)

Finally

myconnection.Close()

End Try

End If

End Sub

Private Sub rbStaffDisableAuto_CheckedChanged(sender As Object, e As EventArgs) Handles


rbStaffDisableAuto.CheckedChanged

If rbStaffDisableAuto.Checked = True Then

rbStaffSignin.Checked = False

rbStaffSignout.Checked = False

rbStaffAbsentSms.Checked = False

rbStaffEnableAll.Checked = False

rbStaffEnableAuto.Checked = False

rbStaffSignin.Enabled = False

rbStaffSignout.Enabled = False

rbStaffAbsentSms.Enabled = False

btnStaffSend2.Enabled = False

' CODE INSERT


Dim sqlupdate As String

Dim opt As String = "disableAllSMS"

Dim state As String = "True"

sqlupdate = "UPDATE controlsignout SET timeset=@timeset WHERE flag='" & opt & "'"

Dim cmd As New OleDbCommand(sqlupdate, myconnection)

cmd.Parameters.Add(New OleDbParameter("@timeset", state))

Try

myconnection.Open()

cmd.ExecuteNonQuery()

Catch ex As Exception

MsgBox(ex.Message)

Finally

myconnection.Close()

End Try

Else

' CODE INSERT

Dim sqlupdate As String

Dim opt As String = "disableAllSMS"

Dim state As String = "False"

sqlupdate = "UPDATE controlsignout SET timeset=@timeset WHERE flag='" & opt & "'"
Dim cmd As New OleDbCommand(sqlupdate, myconnection)

cmd.Parameters.Add(New OleDbParameter("@timeset", state))

Try

myconnection.Open()

cmd.ExecuteNonQuery()

Catch ex As Exception

MsgBox(ex.Message)

Finally

myconnection.Close()

End Try

End If

End Sub

Private Sub rbStaffSignin_CheckedChanged(sender As Object, e As EventArgs) Handles


rbStaffSignin.CheckedChanged

If rbStaffSignin.Checked = True Then

' CODE INSERT

Dim sqlupdate As String

Dim opt As String = "staffSigninChk"

Dim state As String = "True"

sqlupdate = "UPDATE controlsignout SET timeset=@timeset WHERE flag='" & opt & "'"
Dim cmd As New OleDbCommand(sqlupdate, myconnection)

cmd.Parameters.Add(New OleDbParameter("@timeset", state))

Try

myconnection.Open()

cmd.ExecuteNonQuery()

Catch ex As Exception

MsgBox(ex.Message)

Finally

myconnection.Close()

End Try

Else

' CODE INSERT

Dim sqlupdate As String

Dim opt As String = "staffSigninChk"

Dim state As String = "False"

sqlupdate = "UPDATE controlsignout SET timeset=@timeset WHERE flag='" & opt & "'"

Dim cmd As New OleDbCommand(sqlupdate, myconnection)

cmd.Parameters.Add(New OleDbParameter("@timeset", state))


Try

myconnection.Open()

cmd.ExecuteNonQuery()

Catch ex As Exception

MsgBox(ex.Message)

Finally

myconnection.Close()

End Try

If Not chkSignin.Checked And Not CheckBox1.Checked And Not rbStaffSignout.Checked Then

'MsgBox("At least 1 checkbox must be checked")

rbStaffSignin.Checked = True

Exit Sub

End If

End If

End Sub

Private Sub rbStaffSignout_CheckedChanged(sender As Object, e As EventArgs) Handles


rbStaffSignout.CheckedChanged

If rbStaffSignout.Checked = True Then

' CODE INSERT

Dim sqlupdate As String

Dim opt As String = "staffSignoutChk"

Dim state As String = "True"


sqlupdate = "UPDATE controlsignout SET timeset=@timeset WHERE flag='" & opt & "'"

Dim cmd As New OleDbCommand(sqlupdate, myconnection)

cmd.Parameters.Add(New OleDbParameter("@timeset", state))

Try

myconnection.Open()

cmd.ExecuteNonQuery()

Catch ex As Exception

MsgBox(ex.Message)

Finally

myconnection.Close()

End Try

Else

' CODE INSERT

Dim sqlupdate As String

Dim opt As String = "staffSignoutChk"

Dim state As String = "False"

sqlupdate = "UPDATE controlsignout SET timeset=@timeset WHERE flag='" & opt & "'"

Dim cmd As New OleDbCommand(sqlupdate, myconnection)

cmd.Parameters.Add(New OleDbParameter("@timeset", state))


Try

myconnection.Open()

cmd.ExecuteNonQuery()

Catch ex As Exception

MsgBox(ex.Message)

Finally

myconnection.Close()

End Try

If Not rbStaffSignout.Checked And Not chkSignin.Checked And Not rbStaffAbsentSms.Checked


Then

'MsgBox("At least 1 checkbox must be checked")

rbStaffSignout.Checked = True

Exit Sub

End If

End If

End Sub

Private Sub rbStaffAbsentSms_CheckedChanged(sender As Object, e As EventArgs) Handles


rbStaffAbsentSms.CheckedChanged

If rbStaffAbsentSms.Checked = True Then

' CODE INSERT

Dim sqlupdate As String

Dim opt As String = "staffAbsentchk"

Dim state As String = "True"


sqlupdate = "UPDATE controlsignout SET timeset=@timeset WHERE flag='" & opt & "'"

Dim cmd As New OleDbCommand(sqlupdate, myconnection)

cmd.Parameters.Add(New OleDbParameter("@timeset", state))

Try

myconnection.Open()

cmd.ExecuteNonQuery()

Catch ex As Exception

MsgBox(ex.Message)

Finally

myconnection.Close()

End Try

btnStaffSend2.Enabled = False

Else

' CODE INSERT

Dim sqlupdate As String

Dim opt As String = "staffAbsentchk"

Dim state As String = "False"

sqlupdate = "UPDATE controlsignout SET timeset=@timeset WHERE flag='" & opt & "'"

Dim cmd As New OleDbCommand(sqlupdate, myconnection)


cmd.Parameters.Add(New OleDbParameter("@timeset", state))

Try

myconnection.Open()

cmd.ExecuteNonQuery()

Catch ex As Exception

MsgBox(ex.Message)

Finally

myconnection.Close()

End Try

btnStaffSend2.Enabled = True

If Not rbStaffAbsentSms.Checked And Not rbStaffSignin.Checked And Not rbStaffSignout.Checked


Then

'MsgBox("At least 1 checkbox must be checked")

rbStaffAbsentSms.Checked = True

Exit Sub

End If

End If

End Sub

Private Sub btnStaffSend2_Click(sender As Object, e As EventArgs) Handles btnStaffSend2.Click

If tbAbsentMessage.Text.Trim = "" Then

MsgBox("The SMS Body field cannot be empty.")

Else

sendStaffAbsentsms()
MsgBox("The absent message was successfully sent.")

myconnection.Close()

End If

End Sub

Private Sub btnAbsentUpdate_Click(sender As Object, e As EventArgs) Handles btnAbsentUpdate.Click

If tbAbsentMessage.Text.Trim = "" Then

MsgBox("The Absent message field cannot be empty.")

Else

' CODE INSERT

Dim sqlupdate As String

Dim time As String = "staff_absent"

sqlupdate = "UPDATE controlsignout SET timeset=@timeset WHERE flag='" & time & "'"

Dim cmd As New OleDbCommand(sqlupdate, myconnection)

cmd.Parameters.Add(New OleDbParameter("@timeset", tbAbsentMessage.Text))

Try

myconnection.Open()

If MessageBox.Show("Are you sure you want to update the Absent message?", "Change",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

If (cmd.ExecuteNonQuery() > 0) Then

MsgBox("The Absent message was updated successfully.")

myconnection.Close()
staffRetrieveMessages()

End If

End If

Catch ex As Exception

MsgBox(ex.Message)

Finally

myconnection.Close()

End Try

End If

End Sub

Private Sub btnStaffSignout_Click(sender As Object, e As EventArgs) Handles btnStaffSignout.Click

If tbStaffSignOut.Text.Trim = "" Then

MsgBox("The Sign-Out message field cannot be empty.")

Else

' CODE INSERT

Dim sqlupdate As String

Dim time As String = "staff_signout"

sqlupdate = "UPDATE controlsignout SET timeset=@timeset WHERE flag='" & time & "'"

Dim cmd As New OleDbCommand(sqlupdate, myconnection)

cmd.Parameters.Add(New OleDbParameter("@timeset", tbStaffSignOut.Text))


Try

myconnection.Open()

If MessageBox.Show("Are you sure you want to update the Sign-Out message?", "Change",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

If (cmd.ExecuteNonQuery() > 0) Then

MsgBox("The Sign-Out message was updated successfully.")

myconnection.Close()

staffRetrieveMessages()

End If

End If

Catch ex As Exception

MsgBox(ex.Message)

Finally

myconnection.Close()

End Try

End If

End Sub

Private Sub BunifuButton46_Click(sender As Object, e As EventArgs) Handles BunifuButton46.Click

Dim dialog As passwordPrompt = New passwordPrompt()

If dialog.ShowDialog() = DialogResult.OK Then

If dialog.BunifuTextBox1.Text = "" And dialog.BunifuTextBox2.Text = "" Then


MsgBox("please enter username and password")

Else

Dim userfound As Integer = LoginFunc(dialog.BunifuTextBox1.Text, dialog.BunifuTextBox2.Text)

If userfound = 1 Then

BunifuPages1.SetPage("StaffRelog")

TextBox1.Focus()

ElseIf userfound = 2 Then

MsgBox("Please enter the Local Admin user credentials.")

Else

MsgBox("The Username or Password is incorrenct.")

End If

End If

End If

dialog.Dispose()

myconnection.Close()

End Sub

Private Sub btnSigninStaff_Click(sender As Object, e As EventArgs) Handles btnSigninStaff.Click

If tbStaffSignin.Text.Trim = "" Then

MsgBox("The Sign-In message field cannot be empty.")

Else
' CODE INSERT

Dim sqlupdate As String

Dim time As String = "staff_signin"

sqlupdate = "UPDATE controlsignout SET timeset=@timeset WHERE flag='" & time & "'"

Dim cmd As New OleDbCommand(sqlupdate, myconnection)

cmd.Parameters.Add(New OleDbParameter("@timeset", tbStaffSignin.Text))

Try

myconnection.Open()

If MessageBox.Show("Are you sure you want to update the Sign-In message?", "Change",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

If (cmd.ExecuteNonQuery() > 0) Then

MsgBox("The Sign-In message was updated successfully.")

myconnection.Close()

staffRetrieveMessages()

End If

End If

Catch ex As Exception

MsgBox(ex.Message)

Finally

myconnection.Close()

End Try
End If

End Sub

#Region "Relog Scan Student"

Private Sub check_info_relog()

myconnection.Open()

eDA.SelectCommand = New OleDbCommand("SELECT firstname, lastname, count FROM students


WHERE tag_id='" & BunifuTextBox7.Text.ToString & "'", myconnection)

eDS.Clear()

eDS.Clear()

eDA.Fill(eDS)

If eDS.Tables(0).Rows.Count > 0 Then

eDR = eDS.Tables(0).Rows(0)

BunifuTextBox2.Text = eDR("firstname") + " " + eDR("lastname")

fname = eDR("firstname")

Sname = eDR("lastname")

a = eDR("count")

Dim userfound As Boolean = False

userfound = True

If userfound = True Then

insertimage_relog()

End If

dDA.SelectCommand = New OleDbCommand("SELECT * FROM studentsrecords WHERE tag_id='"


& BunifuTextBox7.Text & "' AND date_in=#" & DateTime.Now.ToString("MM/d/yyyy") & "# AND flag='" &
1 & "' AND time_out IS NULL", myconnection)

dDS.Clear()

dDA.Fill(dDS)

If dDS.Tables(0).Rows.Count > 0 Then

dDR = dDS.Tables(0).Rows(0)

Button222.Enabled = True

Button222.Text = "&Time Out"

BunifuTextBox5.Text = dDR("time_in") ' Format(dDR("time_in"), "HH:mm:ss tt")

'insertstd_relog() 'found

'insertstd_relog() 'found

Label20.Text = "Cannot relog student that is currently Signed-In"

Else

dDA.SelectCommand = New OleDbCommand("SELECT * FROM studentsrecords WHERE


tag_id='" & BunifuTextBox7.Text & "' AND date_in=#" & DateTime.Now.ToString("MM/d/yyyy") & "# AND
flag='" & 1 & "' AND time_in IS NOT NULL AND time_out IS NOT NULL", myconnection)

dDS.Clear()

dDA.Fill(dDS)

If dDS.Tables(0).Rows.Count > 0 Then

dDR = dDS.Tables(0).Rows(0)

fillAnotherStudDb()

Button222.Enabled = True

Button222.Text = "&Time In"

insertstd_relog()
Label20.Text = "Student Successfully Resinged-In"

'dDA.SelectCommand = New OleDbCommand("SELECT * FROM studentsrecords WHERE


tag_id='" & BunifuTextBox7.Text & "' AND date_in=#" & DateTime.Now.ToString("MM/d/yyyy") & "# AND
flag='" & 1 & "' AND time_out IS NULL", myconnection)

'dDS.Clear()

'dDA.Fill(dDS)

'If dDS.Tables(0).Rows.Count > 0 Then

' dDR = dDS.Tables(0).Rows(0)

' 'insertstd_relog()

' 'Label20.Text = "Student Successfully Resinged-Out"

'Else

' fillAnotherStudDb()

' Button222.Enabled = True

' Button222.Text = "&Time In"

' insertstd_relog()

' Label20.Text = "Student Successfully Resinged-In"

'End If

Else

Button222.Enabled = True

Button222.Text = "&Time In"

'insertstd_relog()

'makeThemAbsent()

Label20.Text = "please first sign in"


End If

End If

dDR = Nothing

dDS.Dispose()

dDA.Dispose()

cleartimer_relog()

Else

cleartimer_relog()

Button222.Enabled = False

End If

eDR = Nothing

eDS.Dispose()

eDA.Dispose()

myconnection.Close()

End Sub

Private Sub insertstd_relog()

' Time-in and Time-out button

Dim datey As String = DateTime.Now.ToString("MM/d/yyyy")

'fdate = datey.Substring(0, 10)


Dim flag As Integer = 1

Dim strSQL As String

If Button222.Text = "&Time In" Then

dDR = dDS.Tables(0).NewRow()

ftime = DateTime.Now.ToString("hh:mm:ss tt")

BunifuTextBox5.Text = ftime

insertd(BunifuTextBox7.Text, datey, fname, Sname, ftime)

strSQL = "UPDATE studentsrecords SET time_in=#" & BunifuTextBox5.Text & "#, flag='" & flag & "'
WHERE tag_id='" & BunifuTextBox7.Text & "' AND date_in=#" & datey & "# AND Flag IS Null"

Button222.Text = "&Time Out"

Dim SigninMsg As String = ""

Dim tag As String = "signin"

Try

Dim cmd As OleDbCommand = New OleDbCommand("SELECT timeset FROM controlsignout


WHERE flag='" & tag & "'", myconnection)

Dim dr As OleDbDataReader = cmd.ExecuteReader

Dim userfound As Boolean = False

While dr.Read

SigninMsg = dr("timeset")

End While

sValue = SigninMsg

Catch ex As Exception

MsgBox(ex.Message)
myconnection.Close()

End Try

If Panel25.Enabled = True Then

Try

Dim n As String = "1"

Dim cmd As OleDbCommand = New OleDbCommand("SELECT Guardiannumber1,


Guardiannumber2 FROM students WHERE Tag_ID='" & BunifuTextBox7.Text & "' And ReceiveSms='" & n
& "'", myconnection)

Dim dr As OleDbDataReader = cmd.ExecuteReader

Dim userfound As Boolean = False

While dr.Read

number = dr("Guardiannumber1")

'number2 = dr("Guardiannumber2")

End While

Catch ex As Exception

MsgBox(ex.Message)

End Try

If number = Nothing Then

Else

If ChkEnableAll.Checked = True Then


numbers.Clear()

numbers.Add(number)

'numbers.Add(number2)

NumWorkers = NumWorkers + 1

ReDim Workers(NumWorkers)

Workers(NumWorkers) = New BackgroundWorker

Workers(NumWorkers).WorkerReportsProgress = True

Workers(NumWorkers).WorkerSupportsCancellation = True

AddHandler Workers(NumWorkers).DoWork, AddressOf WorkerDoWork

AddHandler Workers(NumWorkers).ProgressChanged, AddressOf WorkerProgressChanged

AddHandler Workers(NumWorkers).RunWorkerCompleted, AddressOf WorkerCompleted

Workers(NumWorkers).RunWorkerAsync()

'sendSmS(SigninMsg)

'Label3.Text = "processing"

ElseIf chkSignin.Checked = True Then

numbers.Clear()

numbers.Add(number)

NumWorkers = NumWorkers + 1

ReDim Workers(NumWorkers)

Workers(NumWorkers) = New BackgroundWorker

Workers(NumWorkers).WorkerReportsProgress = True

Workers(NumWorkers).WorkerSupportsCancellation = True

AddHandler Workers(NumWorkers).DoWork, AddressOf WorkerDoWork

AddHandler Workers(NumWorkers).ProgressChanged, AddressOf WorkerProgressChanged


AddHandler Workers(NumWorkers).RunWorkerCompleted, AddressOf WorkerCompleted

Workers(NumWorkers).RunWorkerAsync()

'sendSmS(SigninMsg)

'Label3.Text = "processing"

ElseIf chkDisableAuto.Checked = True Then

End If

End If

number = 0

End If

Else

ftime = DateTime.Now.ToString("hh:mm:ss tt")

BunifuTextBox6.Text = ftime

'Label23.Text = "Signed Out"

strSQL = "UPDATE studentsrecords SET time_out=#" & BunifuTextBox6.Text & "# WHERE tag_id='"
& BunifuTextBox7.Text & "' AND date_in=#" & datey & "# and flag='1' and time_out IS NULL" 'time_in=#"
& BunifuTextBox5.Text & "#"

'Button222.Text = "&Time In"

Dim SigninMsg1 As String = ""

Dim tag As String = "signout"

Try

Dim cmd As OleDbCommand = New OleDbCommand("SELECT timeset FROM controlsignout


WHERE flag='" & tag & "'", myconnection)

Dim dr As OleDbDataReader = cmd.ExecuteReader

Dim userfound As Boolean = False


While dr.Read

SigninMsg1 = dr("timeset")

End While

sValue = SigninMsg1

Catch ex As Exception

MsgBox(ex.Message)

myconnection.Close()

End Try

If Panel25.Enabled = True Then

Try

Dim ny As String = "1"

Dim cmd As OleDbCommand = New OleDbCommand("SELECT Guardiannumber1,


Guardiannumber2 FROM students WHERE Tag_ID='" & BunifuTextBox7.Text & "' AND ReceiveSms='" &
ny & "'", myconnection)

Dim dr As OleDbDataReader = cmd.ExecuteReader

Dim userfound As Boolean = False

While dr.Read

number = dr("Guardiannumber1")

number2 = dr("Guardiannumber2")

End While

Catch ex As Exception

MsgBox(ex.Message)
End Try

If number = Nothing Then

Else

If ChkEnableAll.Checked = True Then

numbers.Clear()

numbers.Add(number)

NumWorkers = NumWorkers + 1

ReDim Workers(NumWorkers)

Workers(NumWorkers) = New BackgroundWorker

Workers(NumWorkers).WorkerReportsProgress = True

Workers(NumWorkers).WorkerSupportsCancellation = True

AddHandler Workers(NumWorkers).DoWork, AddressOf WorkerDoWork

AddHandler Workers(NumWorkers).ProgressChanged, AddressOf WorkerProgressChanged

AddHandler Workers(NumWorkers).RunWorkerCompleted, AddressOf WorkerCompleted

Workers(NumWorkers).RunWorkerAsync()

'sendSmS(SigninMsg1)

'Label3.Text = "processing"

ElseIf chkSignout.Checked = True Then

numbers.Clear()

numbers.Add(number)
NumWorkers = NumWorkers + 1

ReDim Workers(NumWorkers)

Workers(NumWorkers) = New BackgroundWorker

Workers(NumWorkers).WorkerReportsProgress = True

Workers(NumWorkers).WorkerSupportsCancellation = True

AddHandler Workers(NumWorkers).DoWork, AddressOf WorkerDoWork

AddHandler Workers(NumWorkers).ProgressChanged, AddressOf WorkerProgressChanged

AddHandler Workers(NumWorkers).RunWorkerCompleted, AddressOf WorkerCompleted

Workers(NumWorkers).RunWorkerAsync()

'sendSmS(SigninMsg1)

'Label3.Text = "processing"

ElseIf chkDisableAuto.Checked = True Then

End If

End If

number = 0

End If

End If

Dim dCmd As OleDbCommand = New OleDbCommand(strSQL, myconnection)

dCmd.ExecuteNonQuery()

dCmd.Dispose()

dDR = Nothing
dDS.Dispose()

dDA.Dispose()

myconnection.Close()

Button222.Enabled = False

End Sub

Private Sub insertimage_relog()

Dim cnn As New OleDb.OleDbConnection

cnn = New OleDb.OleDbConnection

cnn.ConnectionString = "provider = microsoft.ace.oledb.12.0; data


source=studentattendancesystem.accdb; Persist Security Info=False;"

If cnn.State = ConnectionState.Open Then

cnn.Open()

End If

Dim da As New OleDb.OleDbDataAdapter("SELECT * FROM students WHERE count = " & a, cnn)

Dim dt As New DataTable

da.Fill(dt)

Me.BunifuTextBox8.Text = dt.Rows(0).Item("PicturePath")

Try

BunifuPictureBox16.Image = System.Drawing.Bitmap.FromFile(BunifuTextBox8.Text)

cnn.Close()

Catch ex As Exception

cnn.Close()

End Try
End Sub

Private Sub fillAnotherStudDb()

Dim strSQL As String = ""

Dim strSQ As String = ""

strSQL = "INSERT INTO studentsrecords ([tag_id],[id],[firstname],[lastname],[department],[class],


[ReceiveSms],[userType],[status]) SELECT [tag_id],[id],[firstname],[lastname],[department],[class],
[ReceiveSms],[userType],[status] FROM students WHERE tag_id='" & BunifuTextBox7.Text & "'"

strSQ = "UPDATE studentsrecords SET date_in=#" & Format(Now, "MM/d/yyyy") & "# WHERE
tag_id='" & BunifuTextBox7.Text & "' and date_in IS NULL and time_in IS NULL and time_out IS NULL and
Flag IS Null and tag_id IS NOT NULL"

command = New OleDbCommand(strSQL, myconnection)

Dim comm As OleDbCommand = New OleDbCommand(strSQ, myconnection)

Try

command.ExecuteNonQuery()

comm.ExecuteNonQuery()

Catch ex As Exception

MsgBox(ex.Message)

myconnection.Close()

End Try

End Sub

Public Sub cleartimer_relog()

' Start the timer.

timeLeft = 5

' Label2.Text = "5 seconds"


Timer3.Start()

End Sub

Private Sub ddRegistryTypeFilter_SelectedIndexChanged(sender As Object, e As EventArgs) Handles


ddRegistryTypeFilter.SelectedIndexChanged

status = ddRegistryTypeFilter.SelectedIndex

End Sub

Private Sub BunifuPanel3_Click(sender As Object, e As EventArgs) Handles BunifuPanel3.Click

End Sub

Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged

check_staff_relog()

End Sub

Private Sub BunifuButton9_Click_1(sender As Object, e As EventArgs) Handles BunifuButton9.Click

BunifuPages1.SetPage("student")

End Sub

Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


Timer3.Tick

If timeLeft > 0 Then

timeLeft -= 1

'Label3.Text = timeLeft & " seconds"

Else
Timer3.[Stop]()

BunifuTextBox7.Clear()

BunifuTextBox7.ReadOnly = False

BunifuTextBox8.Clear()

'BunifuTextBox3.Clear()

'BunifuTextBox4.Clear()

'BunifuTextBox5.Clear()

BunifuTextBox2.Clear()

BunifuPictureBox16.ImageLocation = My.Application.Info.DirectoryPath & "\images\


emptyimage.png"

BunifuTextBox7.Focus()

'Label2.Text = ""

Label20.Text = "."

End If

End Sub

Private Sub txtsearch_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtsearch.KeyPress

Dim tmp As System.Windows.Forms.KeyPressEventArgs = e

If tmp.KeyChar = ChrW(Keys.Enter) Then

' MessageBox.Show("Enter key")

Call BunifuButton36_Click(sender, e)

Else

' MessageBox.Show(tmp.KeyChar)
End If

End Sub

Private Sub BunifuDataGridView3_CellMouseClick(sender As Object, e As


DataGridViewCellMouseEventArgs) Handles BunifuDataGridView3.CellMouseClick

Try

txtsearch.Text = BunifuDataGridView3.Rows(e.RowIndex).Cells(0).Value.ToString

If dbRecordType.SelectedItem = "student" Then

viewImage(BunifuDataGridView3.Rows(e.RowIndex).Cells(1).Value.ToString)

ElseIf dbRecordType.SelectedItem = "staff" Then

viewImageStaff(BunifuDataGridView3.Rows(e.RowIndex).Cells(1).Value.ToString)

Else

End If

'rdId.Checked = True

'BunifuRadioButton1.Checked = False

'rdName.Checked = False

'rdGaurdian.Checked = False
Catch ex As Exception

'MsgBox(ex.Message)

End Try

End Sub

Private Sub Panel68_Paint(sender As Object, e As PaintEventArgs) Handles Panel68.Paint

End Sub

Private Sub dgvStaff_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles


dgvStaff.CellContentClick

End Sub

Private Sub ComboBox2_Click(sender As Object, e As EventArgs) Handles ComboBox2.Click

refreshModerm()

End Sub

Private Sub DataGridView4_CellContentClick(sender As Object, e As DataGridViewCellEventArgs)


Handles DataGridView4.CellContentClick

End Sub

Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles PictureBox1.Click


End Sub

Private Sub BunifuLabel186_Click(sender As Object, e As EventArgs) Handles BunifuLabel186.Click

End Sub

Private Sub Panel27_Paint(sender As Object, e As PaintEventArgs) Handles Panel27.Paint

End Sub

Private Sub records_Click(sender As Object, e As EventArgs) Handles records.Click

If BunifuPages1.SelectedTab Is Editpage Then

If MessageBox.Show("Are you sure you want to leave this page now? Changes will not be saved if
not updated", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) =
Windows.Forms.DialogResult.OK Then

BunifuPages1.SetPage("studentsrecords")

End If

ElseIf BunifuPages1.SelectedTab Is Add Then

If MessageBox.Show("Are you sure you want to leave this page now?", "Warning",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

BunifuPages1.SetPage("studentsrecords")

End If

ElseIf BunifuPages1.SelectedTab Is Relog Then

If MessageBox.Show("Are you sure you want to leave this page now?", "Warning",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

BunifuPages1.SetPage("studentsrecords")

End If
ElseIf BunifuPages1.SelectedTab Is tpAddStuff Then

If MessageBox.Show("Are you sure you want to leave this page now?", "Warning",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then

BunifuPages1.SetPage("studentsrecords")

End If

Else

BunifuPages1.SetPage("studentsrecords")

End If

End Sub

Public Sub refreshModerm()

ComboBox2.Items.Clear()

myPort = IO.Ports.SerialPort.GetPortNames()

For i = 0 To UBound(myPort)

ComboBox2.Items.Add(myPort(i))

Next

Try

ComboBox2.Text = ComboBox2.Items.Item(0) 'COM no 1

Catch ex As Exception

End Try

End Sub

Private Sub BunifuDatePicker1_TextChanged(sender As Object, e As EventArgs) Handles


BunifuDatePicker1.TextChanged
Dim iDagdag As Integer

iDagdag = CInt(DateDiff(DateInterval.Year, BunifuDatePicker1.Value.Date, Now) / 4)

BunifuTextBox45.Text = Floor((DateDiff(DateInterval.Day, BunifuDatePicker1.Value.Date, Now) -


iDagdag) / 365)

End Sub

Private Sub BunifuToggleSwitch3_OnValuechange(sender As Object, e As EventArgs) Handles


BunifuToggleSwitch3.OnValuechange

If BunifuToggleSwitch3.Value = True Then

staffsms = "1"

Else

staffsms = "o"

End If

End Sub

Private Sub dtpDobStaff_TextChanged(sender As Object, e As EventArgs) Handles


dtpDobStaff.ValueChanged

Dim iDagdag As Integer

iDagdag = CInt(DateDiff(DateInterval.Year, dtpDobStaff.Value.Date, Now) / 4)

txtAgeStaff.Text = Floor((DateDiff(DateInterval.Day, dtpDobStaff.Value.Date, Now) - iDagdag) / 365)

End Sub

#End Region
#Region "Relog Staff Scan"

Private Sub check_staff_relog()

myconnection.Open()

eDA.SelectCommand = New OleDbCommand("SELECT firstname, lastname, count FROM staff


WHERE tag_id='" & TextBox1.Text.ToString & "'", myconnection)

eDS.Clear()

eDS.Clear()

eDA.Fill(eDS)

If eDS.Tables(0).Rows.Count > 0 Then

eDR = eDS.Tables(0).Rows(0)

BunifuTextBox14.Text = eDR("firstname") + " " + eDR("lastname")

fname = eDR("firstname")

Sname = eDR("lastname")

a = eDR("count")

Dim userfound As Boolean = False

userfound = True

If userfound = True Then

insertimage_staff_relog()

End If

dDA.SelectCommand = New OleDbCommand("SELECT * FROM studentsrecords WHERE tag_id='"


& TextBox1.Text & "' AND date_in=#" & DateTime.Now.ToString("MM/d/yyyy") & "# AND flag='" & 1 & "'
AND time_out IS NULL", myconnection)

dDS.Clear()

dDA.Fill(dDS)

If dDS.Tables(0).Rows.Count > 0 Then


dDR = dDS.Tables(0).Rows(0)

Button222.Enabled = True

Button222.Text = "&Time Out"

BunifuTextBox21.Text = dDR("time_in") ' Format(dDR("time_in"), "HH:mm:ss tt")

'insertstd_relog() 'found

'insertstd_relog() 'found

Label33.Text = "Cannot relog student that is currently Signed-In"

Else

dDA.SelectCommand = New OleDbCommand("SELECT * FROM studentsrecords WHERE


tag_id='" & TextBox1.Text & "' AND date_in=#" & DateTime.Now.ToString("MM/d/yyyy") & "# AND flag='"
& 1 & "' AND time_in IS NOT NULL AND time_out IS NOT NULL", myconnection)

dDS.Clear()

dDA.Fill(dDS)

If dDS.Tables(0).Rows.Count > 0 Then

dDR = dDS.Tables(0).Rows(0)

fillAnotherStaffDb()

Button222.Enabled = True

Button222.Text = "&Time In"

insertstaff_relog()

Label33.Text = "Student Successfully Resinged-In"

'dDA.SelectCommand = New OleDbCommand("SELECT * FROM studentsrecords WHERE


tag_id='" & BunifuTextBox7.Text & "' AND date_in=#" & DateTime.Now.ToString("MM/d/yyyy") & "# AND
flag='" & 1 & "' AND time_out IS NULL", myconnection)

'dDS.Clear()
'dDA.Fill(dDS)

'If dDS.Tables(0).Rows.Count > 0 Then

' dDR = dDS.Tables(0).Rows(0)

' 'insertstd_relog()

' 'Label20.Text = "Student Successfully Resinged-Out"

'Else

' fillAnotherStudDb()

' Button222.Enabled = True

' Button222.Text = "&Time In"

' insertstd_relog()

' Label20.Text = "Student Successfully Resinged-In"

'End If

Else

Button222.Enabled = True

Button222.Text = "&Time In"

'insertstd_relog()

'makeThemAbsent()

Label33.Text = "please first sign in"

End If

End If

dDR = Nothing

dDS.Dispose()
dDA.Dispose()

cleartimerStaff_relog()

Else

cleartimerStaff_relog()

Button222.Enabled = False

End If

eDR = Nothing

eDS.Dispose()

eDA.Dispose()

myconnection.Close()

End Sub

Private Sub insertstaff_relog()

' Time-in and Time-out button

Dim datey As String = DateTime.Now.ToString("MM/d/yyyy")

'fdate = datey.Substring(0, 10)

Dim flag As Integer = 1

Dim strSQL As String

If Button222.Text = "&Time In" Then

dDR = dDS.Tables(0).NewRow()
ftime = DateTime.Now.ToString("hh:mm:ss tt")

BunifuTextBox21.Text = ftime

insertd(TextBox1.Text, datey, fname, Sname, ftime)

strSQL = "UPDATE studentsrecords SET time_in=#" & BunifuTextBox21.Text & "#, flag='" & flag & "'
WHERE tag_id='" & TextBox1.Text & "' AND date_in=#" & datey & "# AND Flag IS Null"

Button222.Text = "&Time Out"

Dim SigninMsg As String = ""

Dim tag As String = "staff_signin"

Try

Dim cmd As OleDbCommand = New OleDbCommand("SELECT timeset FROM controlsignout


WHERE flag='" & tag & "'", myconnection)

Dim dr As OleDbDataReader = cmd.ExecuteReader

Dim userfound As Boolean = False

While dr.Read

SigninMsg = dr("timeset")

End While

sValue = SigninMsg

Catch ex As Exception

MsgBox(ex.Message)

myconnection.Close()

End Try

If Panel25.Enabled = True Then

Try

Dim n As String = "1"


Dim cmd As OleDbCommand = New OleDbCommand("SELECT contactnumber FROM staff
WHERE Tag_ID='" & TextBox1.Text & "' And ReceiveSms='" & n & "'", myconnection)

Dim dr As OleDbDataReader = cmd.ExecuteReader

Dim userfound As Boolean = False

While dr.Read

number = dr("contactnumber")

'number2 = dr("Guardiannumber2")

End While

Catch ex As Exception

MsgBox(ex.Message)

End Try

If number = Nothing Then

Else

If ChkEnableAll.Checked = True Then

numbers.Clear()

numbers.Add(number)

'numbers.Add(number2)

NumWorkers = NumWorkers + 1

ReDim Workers(NumWorkers)

Workers(NumWorkers) = New BackgroundWorker


Workers(NumWorkers).WorkerReportsProgress = True

Workers(NumWorkers).WorkerSupportsCancellation = True

AddHandler Workers(NumWorkers).DoWork, AddressOf WorkerDoWork

AddHandler Workers(NumWorkers).ProgressChanged, AddressOf WorkerProgressChanged

AddHandler Workers(NumWorkers).RunWorkerCompleted, AddressOf WorkerCompleted

Workers(NumWorkers).RunWorkerAsync()

'sendSmS(SigninMsg)

'Label3.Text = "processing"

ElseIf chkSignin.Checked = True Then

numbers.Clear()

numbers.Add(number)

NumWorkers = NumWorkers + 1

ReDim Workers(NumWorkers)

Workers(NumWorkers) = New BackgroundWorker

Workers(NumWorkers).WorkerReportsProgress = True

Workers(NumWorkers).WorkerSupportsCancellation = True

AddHandler Workers(NumWorkers).DoWork, AddressOf WorkerDoWork

AddHandler Workers(NumWorkers).ProgressChanged, AddressOf WorkerProgressChanged

AddHandler Workers(NumWorkers).RunWorkerCompleted, AddressOf WorkerCompleted

Workers(NumWorkers).RunWorkerAsync()

'sendSmS(SigninMsg)

'Label3.Text = "processing"

ElseIf chkDisableAuto.Checked = True Then


End If

End If

number = 0

End If

Else

ftime = DateTime.Now.ToString("hh:mm:ss tt")

BunifuTextBox22.Text = ftime

'Label23.Text = "Signed Out"

strSQL = "UPDATE studentsrecords SET time_out=#" & BunifuTextBox22.Text & "# WHERE
tag_id='" & TextBox1.Text & "' AND date_in=#" & datey & "# and flag='1' and time_out IS NULL"
'time_in=#" & BunifuTextBox5.Text & "#"

'Button222.Text = "&Time In"

Dim SigninMsg1 As String = ""

Dim tag As String = "staff_signout"

Try

Dim cmd As OleDbCommand = New OleDbCommand("SELECT timeset FROM controlsignout


WHERE flag='" & tag & "'", myconnection)

Dim dr As OleDbDataReader = cmd.ExecuteReader

Dim userfound As Boolean = False

While dr.Read

SigninMsg1 = dr("timeset")

End While

sValue = SigninMsg1

Catch ex As Exception
MsgBox(ex.Message)

myconnection.Close()

End Try

If Panel25.Enabled = True Then

Try

Dim ny As String = "1"

Dim cmd As OleDbCommand = New OleDbCommand("SELECT contactnumber FROM staff


WHERE Tag_ID='" & TextBox1.Text & "' AND ReceiveSms='" & ny & "'", myconnection)

Dim dr As OleDbDataReader = cmd.ExecuteReader

Dim userfound As Boolean = False

While dr.Read

number = dr("contactnumber")

'number2 = dr("Guardiannumber2")

End While

Catch ex As Exception

MsgBox(ex.Message)

End Try

If number = Nothing Then

Else

If ChkEnableAll.Checked = True Then

numbers.Clear()
numbers.Add(number)

NumWorkers = NumWorkers + 1

ReDim Workers(NumWorkers)

Workers(NumWorkers) = New BackgroundWorker

Workers(NumWorkers).WorkerReportsProgress = True

Workers(NumWorkers).WorkerSupportsCancellation = True

AddHandler Workers(NumWorkers).DoWork, AddressOf WorkerDoWork

AddHandler Workers(NumWorkers).ProgressChanged, AddressOf WorkerProgressChanged

AddHandler Workers(NumWorkers).RunWorkerCompleted, AddressOf WorkerCompleted

Workers(NumWorkers).RunWorkerAsync()

'sendSmS(SigninMsg1)

'Label3.Text = "processing"

ElseIf chkSignout.Checked = True Then

numbers.Clear()

numbers.Add(number)

NumWorkers = NumWorkers + 1

ReDim Workers(NumWorkers)

Workers(NumWorkers) = New BackgroundWorker

Workers(NumWorkers).WorkerReportsProgress = True

Workers(NumWorkers).WorkerSupportsCancellation = True

AddHandler Workers(NumWorkers).DoWork, AddressOf WorkerDoWork

AddHandler Workers(NumWorkers).ProgressChanged, AddressOf WorkerProgressChanged


AddHandler Workers(NumWorkers).RunWorkerCompleted, AddressOf WorkerCompleted

Workers(NumWorkers).RunWorkerAsync()

'sendSmS(SigninMsg1)

'Label3.Text = "processing"

ElseIf chkDisableAuto.Checked = True Then

End If

End If

number = 0

End If

End If

Dim dCmd As OleDbCommand = New OleDbCommand(strSQL, myconnection)

dCmd.ExecuteNonQuery()

dCmd.Dispose()

dDR = Nothing

dDS.Dispose()

dDA.Dispose()

myconnection.Close()

Button222.Enabled = False

End Sub

Private Sub insertimage_staff_relog()

Dim cnn As New OleDb.OleDbConnection


cnn = New OleDb.OleDbConnection

cnn.ConnectionString = "provider = microsoft.ace.oledb.12.0; data


source=studentattendancesystem.accdb; Persist Security Info=False;"

If cnn.State = ConnectionState.Open Then

cnn.Open()

End If

Dim da As New OleDb.OleDbDataAdapter("SELECT * FROM staff WHERE count = " & a, cnn)

Dim dt As New DataTable

da.Fill(dt)

Me.BunifuTextBox20.Text = dt.Rows(0).Item("PicturePath")

Try

BunifuPictureBox7.Image = System.Drawing.Bitmap.FromFile(BunifuTextBox20.Text)

cnn.Close()

Catch ex As Exception

cnn.Close()

End Try

End Sub

Private Sub fillAnotherStaffDb()

Dim strSQL As String = ""

Dim strSQ As String = ""

strSQL = "INSERT INTO studentsrecords ([tag_id],[id],[firstname],[lastname],[department],[class],


[ReceiveSms],[userType],[status]) SELECT [tag_id],[staff_id],[firstname],[lastname],[department],'None',
[ReceiveSms],[userType],[status] FROM staff WHERE tag_id='" & TextBox1.Text & "'"

strSQ = "UPDATE studentsrecords SET date_in=#" & Format(Now, "MM/d/yyyy") & "# WHERE
tag_id='" & TextBox1.Text & "' and date_in IS NULL and time_in IS NULL and time_out IS NULL and Flag IS
Null and tag_id IS NOT NULL"

command = New OleDbCommand(strSQL, myconnection)

Dim comm As OleDbCommand = New OleDbCommand(strSQ, myconnection)

Try

command.ExecuteNonQuery()

comm.ExecuteNonQuery()

Catch ex As Exception

MsgBox(ex.Message)

myconnection.Close()

End Try

End Sub

Public Sub cleartimerStaff_relog()

' Start the timer.

timeLeft = 5

' Label2.Text = "5 seconds"

Timer5.Start()

End Sub

Private Sub Timer5_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


Timer5.Tick

If timeLeft > 0 Then

timeLeft -= 1

'Label3.Text = timeLeft & " seconds"


Else

Timer5.[Stop]()

TextBox1.Clear()

TextBox1.ReadOnly = False

BunifuTextBox21.Clear()

'BunifuTextBox3.Clear()

BunifuTextBox22.Clear()

BunifuTextBox14.Clear()

BunifuTextBox20.Clear()

BunifuPictureBox7.ImageLocation = My.Application.Info.DirectoryPath & "\images\


emptyimage.png"

TextBox1.Focus()

'Label2.Text = ""

Label33.Text = "."

End If

End Sub

#End Region

#Region "header 1 for staff datagridview"

Private headerCheckBox2 As CheckBox = New CheckBox()

Private Sub BindGrid1()

Using con As OleDbConnection = New OleDbConnection(provider)


Using cmd As OleDbCommand = New OleDbCommand("SELECT staff_id, Firstname, lastname,
Gender, contactnumber, Department FROM staff", con)

cmd.CommandType = CommandType.Text

Using sda As OleDbDataAdapter = New OleDbDataAdapter(cmd)

Using dt As DataTable = New DataTable()

sda.Fill(dt)

dgvStaff.DataSource = dt

End Using

End Using

End Using

End Using

'Add a CheckBox Column to the DataGridView Header Cell.

'Find the Location of Header Cell.

'Dim headerCellLocation As Point = Me.dgvStaff.GetCellDisplayRectangle(0, -1, True).Location

'headerCheckBox2.Location = New Point(pt.X, pt.Y)

headerCheckBox2.BackColor = Color.White

'headerCheckBox2.Size = New Size(18, 18)

headerCheckBox2.Width = 15

'Assign Click event to the Header CheckBox.

AddHandler headerCheckBox2.Click, AddressOf headerCheckBox4_Clicked

dgvStaff.Controls.Add(headerCheckBox2)
'Add a CheckBox Column to the DataGridView at the first position.

Dim checkBoxColumn As DataGridViewCheckBoxColumn = New DataGridViewCheckBoxColumn()

checkBoxColumn.HeaderText = ""

checkBoxColumn.Width = 30

checkBoxColumn.Name = "checkBoxColumn"

dgvStaff.Columns.Insert(0, checkBoxColumn)

'Assign Click event to the DataGridView Cell.

AddHandler dgvStaff.CellContentClick, AddressOf DataGridView2_CellClick

End Sub

Private Sub headerCheckBox4_Clicked(ByVal sender As Object, ByVal e As EventArgs)

'Necessary to end the edit mode of the Cell.

dgvStaff.EndEdit()

'Loop and check and uncheck all row CheckBoxes based on Header Cell CheckBox.

For Each row As DataGridViewRow In dgvStaff.Rows

Dim checkBox As DataGridViewCheckBoxCell = (TryCast(row.Cells("checkBoxColumn"),


DataGridViewCheckBoxCell))

checkBox.Value = headerCheckBox2.Checked

Next

End Sub

Private Sub DataGridView2_CellClick(ByVal sender As Object, ByVal e As DataGridViewCellEventArgs)

'Check to ensure that the row CheckBox is clicked.

If e.RowIndex >= 0 AndAlso e.ColumnIndex = 0 Then


'Loop to verify whether all row CheckBoxes are checked or not.

Dim isChecked As Boolean = True

For Each row As DataGridViewRow In dgvStaff.Rows

If Convert.ToBoolean(row.Cells("checkBoxColumn").EditedFormattedValue) = False Then

isChecked = False

Exit For

End If

Next

headerCheckBox2.Checked = isChecked

End If

End Sub

Private Sub dgvStaff_CellValueChanged(sender As Object, e As DataGridViewCellEventArgs) Handles


dgvStaff.CellValueChanged

Console.WriteLine("we involked")

If dgvStaff.Columns(e.ColumnIndex).Name = "checkBoxColumn" Then

Dim count2 As Integer = 0

For Each row As DataGridViewRow In dgvStaff.Rows

Console.WriteLine("number yoo" & count2)

If row.Cells("checkBoxColumn").Value IsNot Nothing And row.Cells("checkBoxColumn").Value =


True Then

count2 += 1
Else

End If

Next

LabelStaff.Text = count2

End If

End Sub

#End Region

End Class

You might also like