Imports Telerik.Web.UI

Namespace PCSolution

	Public Class PageUzivatel

		Public sUzivatelID As String

#Region "  SEZNAM UZIVATELU  "

		Sub SeznamUzivatelu(ph As PlaceHolder)

			Dim s As String = ""

			'# Kontejner okna - zahlavi
			s &= "<div class=""container form"">"
			s &= "<div class=""row"">"
			s &= "<div class=""col-xs-12 form-title"">"
			s &= "Uživatelé"
			s &= "</div>"
			s &= "</div>"
			ph.Controls.Add(New LiteralControl(s)) : s = ""
			'@

			'# DATA
			s &= "<div class=""row"">"
			s &= "<div class=""col-xs-12"">"
			s &= "<table class=""table"">"
			Dim DS As DataTable = DB.ExecuteSelectCommand("SELECT * FROM [users].[list] ORDER BY username")

			For Each cRow As DataRow In DS.Rows

				s &= "<tr>"
				If _UserName = "admin" Then
					s &= "<td class=""item-edit first""><a href=""/id-" & cRow("id") & gadrUzivatelNastaveni & """>Editovat</a></td>"
					If cRow("username") <> "admin" Then
						s &= "<td class=""item-edit""><a href=""#"" onclick=""ConfirmDelete('Odstranit uživatele', 'Opravdu chcete odstranit uživatele " & cRow("username") & "?','/id-" & cRow("id") & gadrUzivatelOdstranit & "','','');return false;"">Odstranit</a></td>"
					Else
						s &= "<td class=""item-edit first""></td>"
					End If
				Else
					s &= "<td class=""item-edit first"" colspan=""2""><a href=""/id-" & cRow("id") & gadrUzivatelNastaveni & """>Editovat</a></td>"
				End If

				s &= "<td>" & cRow("username") & "</td>"
				s &= "<td>" & cRow("name") & "</td>"

				ph.Controls.Add(New LiteralControl(s)) : s = ""
				ph.Controls.Add(New LiteralControl("</td></tr>"))

			Next



			s &= "</table>"
			s &= "</div></div>" 'end col, row
			'@

			'# Kontejner okna - zapati
			s &= "<div class=""row"">"
			s &= "<div class=""col-xs-12 form-footer"">"
			s &= "</div>"
			s &= "</div>"
			s &= "</div>"
			ph.Controls.Add(New LiteralControl(s)) : s = ""
			'@

		End Sub

#End Region

#Region "  NASTAVENI UZIVATELE  "

		'Nastaveni uzivatele je v souboru /Globals/Pages/UzivatelNastaveni.ascx

#End Region

#Region "  ODSTRANIT UZIVATELE  "

		Sub OdstranitUzivatele(sID As String, ph As PlaceHolder)

			If sID = "" Then HttpContext.Current.Response.Redirect(gadrUzivatelSeznam)

			DB.ExecuteCommand("DELETE FROM [users].[list] WHERE id = '" & sID & "'")


			_NotifyText = "Uživatel je odstraněn."
			HttpContext.Current.Response.Redirect(gadrUzivatelSeznam)

		End Sub

#End Region

	End Class

End Namespace
