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.
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.
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