Imports XCCLibrary Public Class Settings Public Shared filesFolder As String Public Shared HLCtFolder As String Public Shared folderPaths As New Dictionary(Of String, String) Private Shared appDataList As New List(Of String) Public Shared withoutSW As Boolean Public Shared KBUpdateTime As String Public Shared KBUpdateTimeHead As String = "Knowledge Base: Last Updated" Public Shared exportFolder As String Public Shared exportFolderHead As String = "Export Folder Path" Public Shared SRName, SRPhone, SRMail As String Public Shared SRNameHead As String = "Sales Representative: Name" Public Shared SRPhoneHead As String = "Sales Representative: Phone Number" Public Shared SRMailHead As String = "Sales Representative: Mail" Public Sub Init_Settings() PictureBox_FilePath.BackgroundImage = Global.Wardrobe.My.Resources.Resources.Icon_FilePath1_01 PictureBox_UpdateKB.BackgroundImage = Global.Wardrobe.My.Resources.Resources.Icon_UpdateKB1_01 PictureBox_Save.BackgroundImage = Global.Wardrobe.My.Resources.Resources.Icon_SaveSettings1_01 Dim appData As String() = System.IO.File.ReadAllLines(AppForm.appDataPath & "\SavedData.txt") appDataList.Clear() For i = 0 To appData.Length - 1 appDataList.Add(appData(i)) Next TextBox_Name.Text = SRName TextBox_Phone.Text = SRPhone TextBox_Mail.Text = SRMail Label_KB_Updated.Text = "Last Updated: " & KBUpdateTime Label_File_Path.Text = exportFolder End Sub Private Sub TextBox_Name_Leave(sender As Object, e As EventArgs) Handles TextBox_Name.Leave SRName = sender.Text Update_AppData(SRNameHead, SRName) End Sub Private Sub TextBox_Phone_Leave(sender As Object, e As EventArgs) Handles TextBox_Phone.Leave SRPhone = sender.Text Update_AppData(SRPhoneHead, SRPhone) End Sub Private Sub TextBox_Mail_Leave(sender As Object, e As EventArgs) Handles TextBox_Mail.Leave SRMail = sender.Text Update_AppData(SRMailHead, SRMail) End Sub Private Sub CheckBox_NoSW_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox_NoSW.CheckedChanged If CheckBox_NoSW.Checked = True Then withoutSW = True PictureBox_UpdateKB.Enabled = False Label_KB_Updated.Text = "" Else withoutSW = False PictureBox_UpdateKB.Enabled = True Label_KB_Updated.Text = "Last Updated: " & KBUpdateTime Label_KB_Updated.ForeColor = Color.Black End If End Sub ' ---------------------------------- Update File Path Button ---------------------------------- Private Sub Button_FilePath_Click(sender As Object, e As EventArgs) Handles PictureBox_FilePath.Click Dim ofd As FolderBrowserDialog = New FolderBrowserDialog If ofd.ShowDialog() <> DialogResult.Cancel Then Settings.exportFolder = ofd.SelectedPath Update_AppData(exportFolderHead, ofd.SelectedPath) Label_File_Path.Text = exportFolder End If End Sub Private Sub PictureBox_FilePath_MouseEnter(sender As Object, e As EventArgs) Handles PictureBox_FilePath.MouseEnter PictureBox_FilePath.BackgroundImage = Global.Wardrobe.My.Resources.Resources.Icon_FilePath2_01 PictureBox_FilePath.Cursor = Cursors.Hand End Sub Private Sub PictureBox_FilePath_MouseLeave(sender As Object, e As EventArgs) Handles PictureBox_FilePath.MouseLeave PictureBox_FilePath.BackgroundImage = Global.Wardrobe.My.Resources.Resources.Icon_FilePath1_01 PictureBox_FilePath.Cursor = Cursors.Default End Sub ' ---------------------------------- Update KB Button ---------------------------------- Private Sub Button_KB_Click(sender As Object, e As EventArgs) Handles PictureBox_UpdateKB.Click adminClass.updateDatabase() 'Update KB Dim timeNow As Date = Date.Now KBUpdateTime = timeNow.ToString() Label_KB_Updated.Text = "Last Updated: " & KBUpdateTime Update_AppData(KBUpdateTimeHead, KBUpdateTime) End Sub Private Sub PictureBox_UpdateKB_MouseEnter(sender As Object, e As EventArgs) Handles PictureBox_UpdateKB.MouseEnter PictureBox_UpdateKB.BackgroundImage = Global.Wardrobe.My.Resources.Resources.Icon_UpdateKB2_01 PictureBox_UpdateKB.Cursor = Cursors.Hand End Sub Private Sub PictureBox_UpdateKB_MouseLeave(sender As Object, e As EventArgs) Handles PictureBox_UpdateKB.MouseLeave PictureBox_UpdateKB.BackgroundImage = Global.Wardrobe.My.Resources.Resources.Icon_UpdateKB1_01 PictureBox_UpdateKB.Cursor = Cursors.Default End Sub ' ---------------------------------- Save Button ---------------------------------- Private Sub Button_Save_Click(sender As Object, e As EventArgs) Handles PictureBox_Save.Click System.IO.File.WriteAllLines(AppForm.appDataPath & "\SavedData.txt", appDataList.ToArray()) Check_Settings() AppForm.Panel_Start.Controls.Clear() Main_Menu.TopLevel = False AppForm.Panel_Start.Controls.Add(Main_Menu) AppForm.Width = 800 AppForm.Height = 500 Main_Menu.Show() End Sub Private Sub PictureBox_Save_MouseEnter(sender As Object, e As EventArgs) Handles PictureBox_Save.MouseEnter PictureBox_Save.BackgroundImage = Global.Wardrobe.My.Resources.Resources.Icon_SaveSettings2_01 PictureBox_Save.Cursor = Cursors.Hand End Sub Private Sub PictureBox_Save_MouseLeave(sender As Object, e As EventArgs) Handles PictureBox_Save.MouseLeave PictureBox_Save.BackgroundImage = Global.Wardrobe.My.Resources.Resources.Icon_SaveSettings1_01 PictureBox_Save.Cursor = Cursors.Default End Sub Public Sub Check_Settings() If SRName <> "" AndAlso SRPhone <> "" AndAlso SRMail <> "" AndAlso exportFolder <> "" Then Main_Menu.PictureBox_CreateOrder.Enabled = True Main_Menu.Label_SettingsError.Visible = False Else Main_Menu.PictureBox_CreateOrder.Enabled = False Main_Menu.Label_SettingsError.Visible = True End If If exportFolder = "" Then Label_File_Path.Text = "Needed" Label_File_Path.ForeColor = Color.Red Else Label_File_Path.ForeColor = Color.Black End If If withoutSW = False AndAlso KBUpdateTime = "" Then Label_KB_Updated.Text = "Update" Label_KB_Updated.ForeColor = Color.Red Else Label_KB_Updated.ForeColor = Color.Black End If If SRName <> "" Then Label_Name_Needed.Visible = False Else Label_Name_Needed.Visible = True End If If SRPhone <> "" Then Label_Phone_Needed.Visible = False Else Label_Phone_Needed.Visible = True End If If SRMail <> "" Then Label_Mail_Needed.Visible = False Else Label_Mail_Needed.Visible = True End If End Sub Private Shared Sub Update_AppData(dataName As String, data As String) Dim pathUpdated As Boolean = False For i = 0 To appDataList.Count - 1 If appDataList(i) = dataName Then appDataList(i + 1) = data pathUpdated = True Exit For End If Next If pathUpdated = False Then appDataList.Add("") appDataList.Add(dataName) appDataList.Add(data) End If End Sub End Class