'
' 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("This user already exists. First you must add user to use him.")
				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("We tried to log in user. You can check who is logged in.")
			Me.Close
			Return
		Else
			o.showMessage("You entered wrong name or password of the user.")
		End If
		Catch ex As Exception
		 	MsgBox(ex.Message)	
		End Try
	End Sub
End Class
