Imports Telerik.Web.UI

Public Class Kontakt_zaznam
    Inherits System.Web.UI.UserControl

    Public sID As String = "500" 'ID zaznamu

    Public sAdresaSave As String = gadrKontakt
    Public sAdresaStorno As String = gadrKontakt

    Public sTable As String = "[kontakt].[zaznam]"

    Public bShowLocalization As Boolean = True

    Public bPovolitVerzeFotografii As Boolean = True

    ''' <summary>
    ''' Zamecky hotel uvodni text
    ''' Verze: 1.0
    ''' </summary>
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        cmdSave.Attributes.Add("onclick", "ShowPopInfo('" & gstrProbihaUkladaniZaznamu & "');")

        If IsPostBack = False Then
            Me.NacistData()
        End If

        txtNadpis.Focus()

    End Sub

#Region "  NACIST DATA  "

    Sub NacistData()

        If sID = "" Then Exit Sub
        Dim cRow As DataRow

        Dim DS As DataTable = DB.ExecuteSelectCommand("SELECT * FROM " & sTable & " WHERE id = '" & sID & "'")
        If DS.Rows.Count > 0 Then

            cRow = DS.Rows(0)
            txtNadpis.Text = cRow("nadpis" & _Language)
            txtText.Text = cRow("text" & _Language)
            txtKancelar_brno.Text = cRow("kancelar_brno" & _Language)
            txtKancelar_nachod.Text = cRow("kancelar_nachod" & _Language)
            txtFakturacni_udaje.Text = cRow("fakturacni_udaje" & _Language)

            '# Lokalizace
            If _Language <> "cz" Then
                lblNadpis.Text = cRow("nadpiscz")
                lblText.Text = cRow("textcz")
                lblKancelar_brno.Text = cRow("kancelar_brnocz")
                lblKancelar_nachod.Text = cRow("kancelar_nachodcz")
                lblFakturacni_udaje.Text = cRow("fakturacni_udajecz")
            Else
                ajax.ResponseScripts.Add("$('.label-localize').css('display','none');")
            End If
            '@

        Else

            ajax.ResponseScripts.Add("$('.label-localize').css('display','none');")

        End If

        LoadLink(sID, 0, txtTitle.Text, txtLink.Text, txtHorniMenuText.Text, txtDescription.Text)

    End Sub

#End Region

#Region "  ULOZIT  "

    Sub UlozitZaznam()

        DB.ExecuteCommand("UPDATE " & sTable & " SET " &
                           "nadpis" & _Language & " = '" & _PrevestTextNaBezpecny(txtNadpis.Text) & "', " &
                           "text" & _Language & " = '" & _PrevestTextNaBezpecny(txtText.Text) & "', " &
                           "kancelar_brno" & _Language & " = '" & _PrevestTextNaBezpecny(txtKancelar_brno.Text) & "', " &
                           "kancelar_nachod" & _Language & " = '" & _PrevestTextNaBezpecny(txtKancelar_nachod.Text) & "', " &
                           "fakturacni_udaje" & _Language & " = '" & _PrevestTextNaBezpecny(txtFakturacni_udaje.Text) & "' " &
                           "WHERE id = " & sID)

        If txtTitle.Text = "" Then txtTitle.Text = txtNadpis.Text
        If txtLink.Text = "" Then txtLink.Text = txtNadpis.Text

        '# Ulozit informace o prohlizeci
        Dim sLink As String = SaveLink(sID, 0, txtTitle.Text, txtLink.Text, txtHorniMenuText.Text, txtDescription.Text)

    End Sub

    Private Sub cmdSave_Click(sender As Object, e As EventArgs) Handles cmdSave.Click

        Me.UlozitZaznam()
        _NotifyText = "Nastavení stránky je uložené."
        Response.Redirect(sAdresaSave)

    End Sub

#End Region

End Class