Imports Telerik.Web.UI

Public Class UvodniStrana_Zaznam
	Inherits System.Web.UI.UserControl

	Public sID As String = "100" 'ID zaznamu

	Public sAdresaSave As String = gadrUvodniStrana
	Public sAdresaStorno As String = gadrUvodniStrana

	Public sTable As String = "[uvodni-strana].[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)
            'txtMotto_nadpis.Text = cRow("motto_nadpis" & _Language)
            'txtMotto_text.Text = cRow("motto_text" & _Language)

            '# Lokalizace
            If _Language <> "cz" Then
                lblNadpis.Text = cRow("nadpiscz")
                lblText.Text = cRow("textcz")
                'lblMotto_nadpis.Text = cRow("motto_nadpiscz")
                'lblMotto_text.Text = cRow("motto_textcz")
            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) & "' " &
                           "WHERE id = " & sID)

        '"motto_nadpis" & _Language & " = '" & _PrevestTextNaBezpecny(txtMotto_nadpis.Text) & "', " &
        '"motto_text" & _Language & " = '" & _PrevestTextNaBezpecny(txtMotto_text.Text) & "' " &

        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