Public Class Prihlasit
	Inherits System.Web.UI.Page

	Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

		Initialize()

		txtUserName.Focus()

		If _NotifyText <> "" Then
			Dim iTime As Int16 = 5
			ajax.ResponseScripts.Add("ShowNotify('" & _NotifyText & "', " & iTime & ", 0);")
			_NotifyText = ""
		End If

	End Sub

	Private Sub cmdPrihlasit_Click(sender As Object, e As EventArgs) Handles cmdPrihlasit.Click

		If txtName.IsValid = False Then Response.Redirect("http://www.google.com")
		If txtUserName.Text.Contains(" ") Then
			Response.Redirect("/Prihlasit.html")
		End If
		If txtPassword.Text.Contains(" ") Then
			Response.Redirect("/Prihlasit.html")
		End If

		If txtUserName.Text = "pcsolution" And txtPassword.Text = "pcsol615" Then 'Firemni prihlaseni
			_UserID = "999"
			_UserName = "PC Solution"
			_UserRealName = "PC Solution"
			Response.Redirect("/Default.aspx")
		End If

        Dim DS As DataTable = DB.ExecuteSelectCommand("SELECT * FROM [users].[list] WHERE username = '" & txtUserName.Text & "' AND password = '" & txtPassword.Text & "'")
		If DS.Rows.Count = 0 Then
			_NotifyText = "Uživatelské jméno nebo heslo není správně zadané."
			Response.Redirect("/Prihlasit.html")
		End If

		Dim cRow As DataRow = DS.Rows(0)
		_UserID = cRow("id")
		_UserName = cRow("username")
		_UserRealName = cRow("name")

		Response.Redirect("/Default.aspx")

	End Sub

End Class