Imports Telerik.Web.UI

Public Class Nastaveni
	Inherits System.Web.UI.UserControl

	Public cTitle As Admin.Title
	Public sID As String = "900" 'ID zaznamu

	Public sAdresaSave As String = gadrNastaveni

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

	Public bShowLocalization As Boolean = True

	''' <summary>
	''' Seznam zaznamu - upravit zaznam
	''' 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('Probíhá ukládání nastavení...');")

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

	End Sub

#Region "  NACIST DATA  "

	Sub NacistData()

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

		Dim cRow As DataRow = DS.Rows(0)

		txtEmail.Text = cRow("email")
        txtPopis.Text = cRow("description" & _Language)
        txtTitulek.Text = cRow("titulek" & _Language)
        txtDodatek.Text = cRow("dodatek" & _Language)

        'txtFacebook.Text = cRow("facebook")

    End Sub

#End Region

#Region "  ULOZIT  "

	Sub UlozitZaznam()

        DB.ExecuteCommand("UPDATE " & sTable & " SET " &
                           "email = '" & _PrevestTextNaBezpecny(txtEmail.Text) & "', " &
                           "titulek" & _Language & " = '" & _PrevestTextNaBezpecny(txtTitulek.Text) & "', " &
                           "dodatek" & _Language & " = '" & _PrevestTextNaBezpecny(txtDodatek.Text) & "', " &
                           "description" & _Language & " = '" & _PrevestTextNaBezpecny(txtPopis.Text) & "' " &
                           "WHERE id = " & sID)
        '"facebook = '" & _PrevestTextNaBezpecny(txtFacebook.Text.Replace("http://", "").Replace("https://", "")) & "', " &

    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