Imports Telerik.Web.UI

Public Class Projekty_kategorie_seznam
    Inherits System.Web.UI.UserControl

    Public sAdresaUpravit As String = gadrProjekty_kategorie_upravit
    Public sAdresaOdstranit As String = gadrProjekty_kategorie_odstranit
    Public sAdresaSave As String = gadrProjekty_kategorie_seznam

    Public sTable As String = "[projekty].[kategorie]"

    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()

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

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

    End Sub

#Region "  NACIST ZAZNAMY  "

    Sub NacistZaznamy()

        Dim s As String = ""

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

        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 kategorii', " &
                 "'Opravdu chcete odstranit kategorii? Budou odstraněné všechny reference v této kategorii.','/id-" & cRow("id") & sAdresaOdstranit & "','','');return false;"">Odstranit</a></td>"

            s &= "<td class=""pointer"">"
            If cRow("zobrazit" & _Language) = "False" Then s &= "<span class=""label label-red""> </span>&nbsp;"
            s &= cRow("nadpis" & _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á kategorie.</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