Imports System.IO
Imports System.Text


Public NotInheritable Class SplashScreen

    'TODO: This form can easily be set as the splash screen for the application by going to the "Application" tab
    '  of the Project Designer ("Properties" under the "Project" menu).


    Private Sub SplashScreen_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'Set up the dialog text at runtime according to the application's assembly information.  

        'TODO: Customize the application's assembly information in the "Application" pane of the project 
        '  properties dialog (under the "Project" menu).

        'Application title
        If My.Application.Info.Title <> "" Then
            ApplicationTitle.Text = My.Application.Info.AssemblyName

        End If

        'Format the version information using the text set into the Version control at design time as the
        '  formatting string.  This allows for effective localization if desired.
        '  Build and revision information could be included by using the following code and changing the 
        '  Version control's designtime text to "Version {0}.{1:00}.{2}.{3}" or something similar.  See
        '  String.Format() in Help for more information.
        '
        '    Version.Text = System.String.Format(Version.Text, My.Application.Info.Version.Major, My.Application.Info.Version.Minor, My.Application.Info.Version.Build, My.Application.Info.Version.Revision)

        'Version.Text = System.String.Format(Version.Text, My.Application.Info.Version.Major, My.Application.Info.Version.Minor)

        'Copyright info
        Copyright.Text = My.Application.Info.Copyright

    End Sub

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


        'Verifica se Existe ou não o registro
        If Not File.Exists(My.Application.Info.DirectoryPath.Replace("\bin\Debug", "") & "\config.txt") Then
            'Mensagem de Boas Vindas
            Dim strString As New StringBuilder
            strString.Append("Olá, Bem vindo ao Programa" & vbCrLf)
            strString.Append("SSM - Setri Sales Management" & vbCrLf & vbCrLf)
            strString.Append("Informe os Dados da Empresa e  crie um usuário de acesso" & vbCrLf)
            strString.Append("Esclarecimentos email: fernando@setri.com.br" & vbCrLf)
            MessageBox.Show(strString.ToString)
            'Abre o formulário de Cliente
            frmCliente.Show()
        Else

            ' Chama Um StreamReade
            Dim fluxoTexto As IO.StreamReader
            ' Cria uma variavel String para receber o valor da linha
            Dim linhaTexto As String
            'Variavel de comparação
            Dim strString As String

            'Instancia o StreamReader
            fluxoTexto = New IO.StreamReader(My.Application.Info.DirectoryPath.Replace("\bin\Debug", "") & "\config.txt")
            'Recebe a Linha de texto
            linhaTexto = fluxoTexto.ReadLine
            'Começa o Loop precorrendo todo o arquivo
            While linhaTexto <> Nothing
                ' recebe o Nome do Campo
                strString = Mid(linhaTexto, 1, 16)

                ' Faz o Select Case para Completar as Variaveis
                Select Case strString
                    Case "[Cliente]      :"
                        strString = Mid(linhaTexto, 17, (Len(linhaTexto) - 16))
                        strEmpresaCliente = strString
                    Case "[Endereco]     :"
                        strString = Mid(linhaTexto, 17, (Len(linhaTexto) - 16))
                        strEnderecoCliente = strString
                    Case "[Numero]       :"
                        strString = Mid(linhaTexto, 17, (Len(linhaTexto) - 16))
                        strNumeroCliente = strString
                    Case "[Complemento]  :"
                        strString = Mid(linhaTexto, 17, (Len(linhaTexto) - 16))
                        strComplementoCliente = strString
                    Case "[Bairro]       :"
                        strString = Mid(linhaTexto, 17, (Len(linhaTexto) - 16))
                        strBairroCliente = strString
                    Case "[Cep]          :"
                        strString = Mid(linhaTexto, 17, (Len(linhaTexto) - 16))
                        strCEPCliente = strString
                    Case "[Cidade]       :"
                        strString = Mid(linhaTexto, 17, (Len(linhaTexto) - 16))
                        strCidadeCliente = strString
                    Case "[Estado]       :"
                        strString = Mid(linhaTexto, 17, (Len(linhaTexto) - 16))
                        StrEstadoCliente = strString
                    Case "[CNPJ]         :"
                        strString = Mid(linhaTexto, 17, (Len(linhaTexto) - 16))
                        strCNPJCliente = strString
                    Case "[IE]           :"
                        strString = Mid(linhaTexto, 17, (Len(linhaTexto) - 16))
                        strIECliente = strString
                    Case "[IM]           :"
                        strString = Mid(linhaTexto, 17, (Len(linhaTexto) - 16))
                        strIMCliente = strString
                    Case "[Contato]      :"
                        strString = Mid(linhaTexto, 17, (Len(linhaTexto) - 16))
                        strNomeUser = strString
                    Case "[Email]        :"
                        strString = Mid(linhaTexto, 17, (Len(linhaTexto) - 16))
                        strEmailCliente = strString
                    Case "[Telefone]     :"
                        strString = Mid(linhaTexto, 17, (Len(linhaTexto) - 16))
                        strTelefoneCliente = strString
                    Case "[Celular]      :"
                        strString = Mid(linhaTexto, 17, (Len(linhaTexto) - 16))
                        strCelularCliente = strString
                    Case "[Usuario]      :"
                        strString = Mid(linhaTexto, 17, (Len(linhaTexto) - 16))
                        strUserCliente = strString
                    Case "[Senha]        :"
                        strString = Mid(linhaTexto, 17, (Len(linhaTexto) - 16))
                        strSenhaCliente = strString
                    Case "[ConfirmaSenha]:"
                        strString = Mid(linhaTexto, 17, (Len(linhaTexto) - 16))
                        strConfirmaSenhaCliente = strString
                End Select
                'Le novamente outra linha
                linhaTexto = fluxoTexto.ReadLine
            End While
            'fecha o arquivo
            fluxoTexto.Close()

            'Abre o formulário de Login
            frmLogin.Show()
            frmLogin.txtUsuario.Text = strUserCliente

        End If
        'Timer fica False
        Me.Timer1.Enabled = False
        'Fecha o formulário
        Me.Hide()
    End Sub

End Class
