0% found this document useful (0 votes)
16 views1 page

Timesheetadmin Formclosingeventargs Messagebox Messageboxbuttons

This document contains code for a TimeSheetAdmin class in a Windows Forms application written in Visual Basic. The class handles the FormClosing event, which occurs when the form is closing. It displays a confirmation message to the user asking if they want to exit the application. If they select "No", it cancels closing the form. If they select "Yes", it updates a status field in a database to 0 where the User ID matches the logged in user, before allowing the form to close.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views1 page

Timesheetadmin Formclosingeventargs Messagebox Messageboxbuttons

This document contains code for a TimeSheetAdmin class in a Windows Forms application written in Visual Basic. The class handles the FormClosing event, which occurs when the form is closing. It displays a confirmation message to the user asking if they want to exit the application. If they select "No", it cancels closing the form. If they select "Yes", it updates a status field in a database to 0 where the User ID matches the logged in user, before allowing the form to close.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Imports

Imports
Imports
Imports
Imports

System.Data.OleDb
iTextSharp.text.pdf
iTextSharp.text
System.IO
System.Globalization

Public Class TimeSheetAdmin


Private Sub TimeSheetAdmin_Closing(ByVal sender As Object, ByVal e As
System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Dim result As Integer = MessageBox.Show("Do you want to exit the application?", "Exit
Application", MessageBoxButtons.YesNo)
If result = DialogResult.No Then
e.Cancel = True
ElseIf result = DialogResult.Yes Then
Dim connectionstring As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" &
Application.StartupPath & "\STSlog.mdb;Jet OLEDB:Database Password=password;"
Dim conn As New OleDbConnection(connectionstring)
Dim command As New OleDbCommand
Dim commstring As String
Dim EmpNumString As String = Login.EmpNumTxtBox.Text
commstring = "UPDATE Access SET status = '0' WHERE UserID = '" & EmpNumString & "'"
command = New OleDbCommand(commstring, conn)
conn.Open()
Dim reader As OleDbDataReader = command.ExecuteReader()
reader.Read()
conn.Close()
e.Cancel = False
End If
End Sub

You might also like