Imports Telerik.Web.UI

Public Class UvodniStrana_Slider_Seznam
	Inherits System.Web.UI.UserControl

	Public sAdresaUpravit As String = gadrUvodniStrana_Slider_Upravit
	Public sAdresaOdstranit As String = gadrUvodniStrana_Slider_Odstranit
	Public sAdresaSave As String = gadrUvodniStrana_Slider

	Public sTable As String = "[uvodni-strana].[slider]"

	Public bShowLocalization As Boolean = True

	''' <summary>
	''' Seznam zaznamu.
	''' Verze: 1.0
	''' Tabulka musi obsahovat pole - id, sort
	''' </summary>
	Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

		NacistZaznamy()

		Dim pSort As New PCSolution.SortItems
		pSort.InsertSorting(sTable)

		cmdNovy.Attributes.Add("onclick", "ShowPopInfo('" & gstrProbihaNacitaniStranky & "');")

	End Sub

#Region "  NACIST ZAZNAMY  "

	Sub NacistZaznamy()

		Dim s As String = ""

		Dim DS As DataTable = DB.ExecuteSelectCommand("SELECT * FROM " & sTable & " ORDER BY sort")

		If DS.Rows.Count < 2 Then phTip.Visible = False

		For Each cRow As DataRow In DS.Rows

			s &= "<tr id=""sort" & cRow("id") & """>"
			s &= "<td class=""item-edit first""><a href=""/id-" & cRow("id") & sAdresaUpravit & """>Upravit</a></td>"
			s &= "<td class=""item-edit""><a href=""#"" onclick=""ConfirmDelete('Odstranit snímek', 'Opravdu chcete odstranit snímek?','/id-" & cRow("id") & sAdresaOdstranit & "','','');return false;"">Odstranit</a></td>"

			s &= "<td class=""width-120 pointer""><img src=""" & _PathFotoRelative & "/Uvodni-strana/Slider/" & cRow("id") & "/v" & cRow("fotoverze") & "/Nahled2/" & cRow("fotonazev") & cRow("fotopripona") & """ /></td>"
            s &= "<td class=""pointer"">" & cRow("nadpis" & _Language) & "</td>"
            's &= "<td class=""pointer"">" & cRow("text" & _Language) & "</td>"
            's &= "<td class=""pointer"">" & cRow("odkaz" & _Language) & "</td>"
            s &= "</tr>"

		Next

		ph.Controls.Add(New LiteralControl(s)) : s = ""

		If DS.Rows.Count = 0 Then
			phTable.Visible = False
			phNoItem.Controls.Add(New LiteralControl("<div class=""noitem"">Není nalezený žádný snímek.</div>"))
		End If

	End Sub

	Private Sub cmdNovy_Click(sender As Object, e As EventArgs) Handles cmdNovy.Click

		Response.Redirect(sAdresaUpravit)

	End Sub

#End Region

End Class