Imports System.ComponentModel

Public Class frmManagement


    Private Sub frmManagement_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        InitializeDatabaseConnection()
        txtConnection.Text = My.Settings.SQL_CONNECTION_STRINGS
        If InitializeDatabaseConnection() = True Then
            GroupBox1.Visible = False
            txtConnection.Visible = False
            btnSave.Visible = False
            btnClose.Visible = False
            btnAdministration.Visible = True
            btnAttendance.Visible = True
        Else
            GroupBox1.Visible = True
            txtConnection.Visible = True
            btnSave.Visible = True
            btnClose.Visible = True
            btnAdministration.Visible = False
            btnAttendance.Visible = False
        End If
    End Sub

    Private Sub btnAdministration_Click(sender As Object, e As EventArgs) Handles btnAdministration.Click
        frmLogIn.Show()
        Me.Close()
    End Sub

    Private Sub btnAttendance_Click(sender As Object, e As EventArgs) Handles btnAttendance.Click
        frmDailyAttendance.ShowDialog()
    End Sub



    Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
        If txtConnection.Text = "" Then
            MsgBox("Please specify the database connection string.", MsgBoxStyle.Critical, "Error")
        Else
            My.Settings.SQL_CONNECTION_STRINGS = txtConnection.Text
            My.Settings.Save()
            MsgBox("Connection string has been saved successfully.", MsgBoxStyle.Information, "Information")
        End If
    End Sub
End Class