'
' Created by SharpDevelop.
' User: Jano
' Date: 23.7.2017
' Time: 16:21
' 
' To change this template use Tools | Options | Coding | Edit Standard Headers.
'
Imports System.IO
Public Partial Class FPrihlasSedenie
	Public Sub New()
		' The Me.InitializeComponent call is required for Windows Forms designer support.
		Me.InitializeComponent()
		
		'
		' TODO : Add constructor code after InitializeComponents
		'
	End Sub
	
	Sub FPrihlasSedenieFormClosed(sender As Object, e As FormClosedEventArgs)
		MainForm.okno=0
	End Sub
	
	Sub Button2Click(sender As Object, e As EventArgs) 'reset formulára
		textBox1.Text=""
		textBox2.Text=""
	End Sub
	
	Sub Button1Click(sender As Object, e As EventArgs) 'prihlas ma na sedenie
		Try
		Dim o As New Module1()
		If Not File.Exists(My.Computer.FileSystem.SpecialDirectories.MyDocuments.ToString & "/uziv" & textBox1.Text.Trim & ".txt") Then
				o.showMessage("Tento používateľ už neexistuje. Nasjkôr si ho musíte pridať, ak ho chcete použiť.")
				Return
		End If
		If o.vratMD5(textBox2.Text.Trim) = o.readUzivHeslo(textBox1.Text.Trim) Then
			'tu treba zapisat textbox1 do ktojeprihl:
			o.zapisPrihl(textBox1.Text.Trim)
			o.showMessage("Prebehol pokus o prihlásenie používateľa. Môžete skontrolovať, kto je prihlásený.")
			Me.Close
			Return
		Else
			o.showMessage("Zadali ste nesprávne meno alebo heslo používateľa.")
		End If
		Catch ex As Exception
		 	MsgBox(ex.Message)	
		End Try
	End Sub
End Class
