Attribute VB_Name = "ZadavaniHesel"
Option Explicit


'----------------------------------------------------------
'kontrola hesla pri startu
'----------------------------------------------------------

Public Sub KontrolaHesla(KeyCode As Integer)

    Select Case KeyCode
        Case 13: ZkusHeslo
        Case 27: Unload Form1
    End Select
    
    DoEvents

End Sub


'----------------------------------------------------------
'zjisteni spravnosti hesla
'----------------------------------------------------------

Public Sub ZkusHeslo()

    Dim i As Integer
    
    If (Form1.TxtHeslo.Text <> "") Then
          
            If (Form1.TxtHeslo.Text = Heslo(0)) Or (Form1.TxtHeslo.Text = Heslo(1)) Or (Form1.TxtHeslo.Text = Heslo(2)) Or (Form1.TxtHeslo.Text = Heslo(3)) Or (Form1.TxtHeslo.Text = Heslo(4)) Or (Form1.TxtHeslo.Text = Heslo(5)) Or (Form1.TxtHeslo.Text = Heslo(6)) Or (Form1.TxtHeslo.Text = Heslo(7)) Or (Form1.TxtHeslo.Text = Heslo(8)) Or (Form1.TxtHeslo.Text = Heslo(9)) Or (Form1.TxtHeslo.Text = HesloSpravce) Then
                ZkouskaPrav
                Form1.FraHeslo.Visible = False
                anno = True
            Else
                Form1.TxtHeslo.SetFocus
            End If
    
    Else
        
        Form1.FraHeslo.Visible = False
        Anonymous
    
    End If
    
    Form1.TxtHeslo.Text = ""

End Sub


'----------------------------------------------------------
'urceni prav podle uzivatelu
'----------------------------------------------------------

Public Sub ZkouskaPrav()

    Select Case Form1.TxtHeslo.Text
    
        Case HesloSpravce: AktJmeno = "Spravce"
        Case Heslo(0):  DOPrava 0
                        AktJmeno = Jmeno(0)
        Case Heslo(1):  DOPrava 1
                        AktJmeno = Jmeno(1)
        Case Heslo(2):  DOPrava 2
                        AktJmeno = Jmeno(2)
        Case Heslo(3):  DOPrava 3
                        AktJmeno = Jmeno(3)
        Case Heslo(4):  DOPrava 4
                        AktJmeno = Jmeno(4)
        Case Heslo(5):  DOPrava 5
                        AktJmeno = Jmeno(5)
        Case Heslo(6):  DOPrava 6
                        AktJmeno = Jmeno(6)
        Case Heslo(7):  DOPrava 7
                        AktJmeno = Jmeno(7)
        Case Heslo(8):  DOPrava 8
                        AktJmeno = Jmeno(8)
        Case Heslo(9):  DOPrava 9
                        AktJmeno = Jmeno(9)
                    
    End Select

End Sub


'----------------------------------------------------------
'prava pro anonymni pristup
'----------------------------------------------------------

Public Sub Anonymous()
    
    Form1.SSTabNabidka.TabEnabled(1) = False
    Form1.SSTabNabidka.TabEnabled(2) = False
    Form1.SSTabNabidka.TabEnabled(3) = False
    Form1.CmdStFlasOdeslat.Enabled = False
    anno = False

End Sub


'----------------------------------------------------------
'zmena hesla
'----------------------------------------------------------

Public Sub DOHeslo(ind As Integer)

    If (Form1.TxtUHeslo(ind).Text = Form1.TxtUHesloP(ind).Text) Then
        Heslo(ind) = Krypt(Form1.TxtUHeslo(ind).Text)
        Jmeno(ind) = Form1.TxtName(ind).Text
        Prava(ind) = "NNN"
        
        If (Form1.ChckFlash(ind).Value = 1) Then
            Mid(Prava(ind), 1) = "A"
        End If
        
        If (Form1.ChckText(ind).Value = 1) Then
            Mid(Prava(ind), 2) = "A"
        End If
        
        If (Form1.ChckPromo(ind).Value = 1) Then
            Mid(Prava(ind), 3) = "A"
        End If
        MsgBox "Změny úspěšně provedeny"
        
        ZapisHeslo
            
    Else:   MsgBox "Chyba v hesle"
            Form1.TxtUHeslo(ind).Text = ""
            Form1.TxtUHesloP(ind).Text = ""
    End If


End Sub


'----------------------------------------------------------
'smazani hesla
'----------------------------------------------------------

Public Sub SMAZHeslo(ind As Integer)

    Heslo(ind) = ""
    Form1.TxtUHeslo(ind).Text = ""
    Form1.TxtUHesloP(ind).Text = ""
    Jmeno(ind) = ""
    Form1.TxtName(ind).Text = ""
    Prava(ind) = "NNN"
    Form1.ChckFlash(ind).Value = 0
    Form1.ChckText(ind).Value = 0
    Form1.ChckPromo(ind).Value = 0
    
    ZapisHeslo
    
End Sub


'----------------------------------------------------------
'zmena prav
'----------------------------------------------------------

Public Sub DOPrava(ind As Integer)

    If (Mid(Prava(ind), 1, 1) <> "A") Then
        Form1.CmdStFlasOdeslat.Enabled = False
    End If
    
    If (Mid(Prava(ind), 2, 1) <> "A") Then
        Form1.SSTabNabidka.TabEnabled(1) = False
    End If
               
    If (Mid(Prava(ind), 3, 1) <> "A") Then
        Form1.SSTabNabidka.TabEnabled(2) = False
    End If
    
    Form1.SSTabNabidka.TabEnabled(3) = False

End Sub

