Attribute VB_Name = "Setup"
Option Explicit


'----------------------------------------------------------
'zadani noveho hesla
'----------------------------------------------------------´

Public Sub NoveHeslo(ind As Integer)

    Dim Stav As Integer

    If (Frm1.TxtSetNHeslo(ind).Text <> "") Then
    
        If (Frm1.TxtSetNHeslo(ind).Text = Frm1.TxtSetNHeslo2(ind).Text) Then
            
            HesloSpravce = Frm1.TxtSetNHeslo(ind).Text
    
            If (Dir(CestaSoubory & "/RDSEdit.Ini") <> "") Then
                Stav = WritePrivateProfileString _
            ("Spravce", "Heslo", Krypt(HesloSpravce), (CestaSoubory & "\RDSEdit.ini"))
            Else:
                Frm1.FraERRORAdr.Visible = True
            End If
            
            HesloSpravce = Frm1.TxtSetNHeslo(ind).Text
            
            Frm1.TxtSetNHeslo(ind).Text = ""
            Frm1.TxtSetNHeslo2(ind).Text = ""
            MsgBox "Heslo úspěšně změněno"
       
        Else
        
                MsgBox "Chyba v hesle"
                Frm1.TxtSetNHeslo(ind).Text = ""
                Frm1.TxtSetNHeslo2(ind).Text = ""
                
        End If
   
   Else
   
           MsgBox "Chyba v hesle"
           Frm1.TxtSetNHeslo(ind).Text = ""
           Frm1.TxtSetNHeslo2(ind).Text = ""
   
   End If

End Sub


'----------------------------------------------------------
'zmena priority jednotlivych vysilacich prvku (textu, prom, flash)
'----------------------------------------------------------

Public Sub ZmenPrioritu()
    
    Dim i As Integer

    For i = 0 To 2

        If (Frm1.OptSetup1(i).Value = True) Then
            Priorita(i) = "1"
        ElseIf (Frm1.OptSetup2(i).Value = True) Then
            Priorita(i) = "2"
         ElseIf (Frm1.OptSetup3(i).Value = True) Then
            Priorita(i) = "3"
        End If
    
    Next i

    ZapisIni
    DataDoPole Date
    DoEvents

End Sub


'----------------------------------------------------------
'vytvoreni adresarove struktury
'----------------------------------------------------------

Public Sub DoStruktura()
    
    Dim i As Integer
    
    If (Dir(CestaSoubory & "/RDS-Promo", vbDirectory) = "") Then
        MkDir (CestaSoubory & "/RDS-Promo")
    End If

    If (Dir(CestaSoubory & "/RDS-Promo/RDS-Promo1", vbDirectory) = "") Then
        MkDir (CestaSoubory & "/RDS-Promo/RDS-Promo1")
    End If
    
    If (Dir(CestaSoubory & "/RDS-Promo/RDS-Promo2", vbDirectory) = "") Then
        MkDir (CestaSoubory & "/RDS-Promo/RDS-Promo2")
    End If
    
    If (Dir(CestaSoubory & "/RDS-Promo/RDS-Promo3", vbDirectory) = "") Then
        MkDir (CestaSoubory & "/RDS-Promo/RDS-Promo3")
    End If
    
    If (Dir(CestaSoubory & "/RDS-Promo/RDS-Promo4", vbDirectory) = "") Then
        MkDir (CestaSoubory & "/RDS-Promo/RDS-Promo4")
    End If
    
    If (Dir(CestaSoubory & "/RDS-Promo/RDS-Promo5", vbDirectory) = "") Then
        MkDir (CestaSoubory & "/RDS-Promo/RDS-Promo5")
    End If
    
    If (Dir(CestaSoubory & "/RDS-Logy", vbDirectory) = "") Then
        MkDir (CestaSoubory & "/RDS-Logy")
    End If
    
    If (Dir(CestaSoubory & "/RDS-Texty", vbDirectory) = "") Then
        MkDir (CestaSoubory & "/RDS-Texty")
    End If
    
    If (Dir(CestaSoubory & "/RDS-Logy/SystemLog/", vbDirectory) = "") Then
        MkDir (CestaSoubory & "/RDS-Logy/SystemLog/")
    End If
    
    If (Dir(CestaSoubory & "/RDS-Logy/Odvysilano", vbDirectory) = "") Then
        MkDir (CestaSoubory & "/RDS-Logy/Odvysilano")
    End If
    
    If (Dir(CestaSoubory & "/RDS-Logy/Odvysilano/Texty", vbDirectory) = "") Then
        MkDir (CestaSoubory & "/RDS-Logy/Odvysilano/Texty")
    End If
    
    If (Dir(CestaSoubory & "/RDS-Logy/Odvysilano/Promo", vbDirectory) = "") Then
        MkDir (CestaSoubory & "/RDS-Logy/Odvysilano/Promo")
    End If
    
    If (Dir(CestaSoubory & "/RDS-Logy/Odvysilano/TA", vbDirectory) = "") Then
        MkDir (CestaSoubory & "/RDS-Logy/Odvysilano/TA")
    End If
    
    If (Dir(CestaSoubory & "/RDS-Logy/Upravovano", vbDirectory) = "") Then
        MkDir (CestaSoubory & "/RDS-Logy/Upravovano")
    End If
    
    If (Dir(CestaSoubory & "/RDS-Logy/Upravovano/Texty", vbDirectory) = "") Then
        MkDir (CestaSoubory & "/RDS-Logy/Upravovano/Texty")
    End If
    
    If (Dir(CestaSoubory & "/RDS-Logy/Upravovano/Promo", vbDirectory) = "") Then
        MkDir (CestaSoubory & "/RDS-Logy/Upravovano/Promo")
    End If
    
    If (Dir(CestaSoubory & "/RDS-Texty/" & "NahradniText.rds") = "") Then
        FileCopy Cesta & "/NahradniText.rds", CestaSoubory & "/RDS-Texty/NahradniText.rds"
    End If
    
    If (Dir(CestaSoubory & "RDSEdit.ini") = "") Then
        Open CestaSoubory & "/RDSEdit.ini" For Output As #30
        
            Print #30, "[Config]"
            Print #30, "Maska=%yyy-%m-%d"
            Print #30, "[Spravce]"
            Print #30, "Heslo = rwmims"
            
            For i = 1 To 10
                Print #30, "[User" & i & "]"
                Print #30, "Prava = NNN"
                Print #30, "Jmeno="
                Print #30, "Heslo="
            Next i
            
            For i = 1 To 5
                Print #30, "[Promo" & i & "]"
                Print #30, "Ovladani = NNNNNNNAA"
            Next i
               
        End If
    
    Close #30
    
    DoEvents
    
    ZapisIni
    CteniIni
    ZmenaCesty = False
    
    ZapisSystemLog "Adresarova struktura", "Adresarova struktura Vytovrena"
        
    Pokracovani

End Sub
    
    
'----------------------------------------------------------
'vytvoreni emailoveho uzivatele
'----------------------------------------------------------

Public Sub VytvorEmailUziv()
    
    Dim i As Integer
        
    For i = 0 To 9
    
        If (Frm1.TxtSetupUsr(i) <> "") Then
            
            EmailUsr(i, 0) = Frm1.TxtSetupUsr(i).Text
            EmailUsr(i, 1) = Frm1.ChckSetupER(i).Value
            EmailUsr(i, 2) = Frm1.ChckSetupDL(i).Value
            EmailUsr(i, 3) = Frm1.ChckSetupPL(i).Value
            EmailUsr(i, 4) = Frm1.ChckSetupSL(i).Value

        End If
    
    Next i
        
End Sub


'----------------------------------------------------------
'zapsani emailoveho uzivatele
'----------------------------------------------------------

Public Sub ZapisEmailUziv()

    Dim i As Integer

    For i = 0 To 9
        
        Frm1.TxtSetupUsr(i) = EmailUsr(i, 0)
        If EmailUsr(i, 1) <> "" Then Frm1.ChckSetupER(i).Value = EmailUsr(i, 1)
        If EmailUsr(i, 2) <> "" Then Frm1.ChckSetupDL(i).Value = EmailUsr(i, 2)
        If EmailUsr(i, 3) <> "" Then Frm1.ChckSetupPL(i).Value = EmailUsr(i, 3)
        If EmailUsr(i, 4) <> "" Then Frm1.ChckSetupSL(i).Value = EmailUsr(i, 4)
    
    Next i

End Sub
