'
' Created by SharpDevelop.
' User: Jano
' Date: 7.8.2017
' Time: 15:11
' 
' To change this template use Tools | Options | Coding | Edit Standard Headers.
'
Public Partial Class FSZKurz
	Public Shared okno = 0
	Public shared vybkurzik = ""
	Public Sub New()
		Try
		' The Me.InitializeComponent call is required for Windows Forms designer support.
		Me.InitializeComponent()
		
		'
		' TODO : Add constructor code after InitializeComponents
		'
		'nacitam kurzy zvoleneho pouzivatela do listboxu
		Dim modul As New Module1
		Dim kurzy As String = modul.citajKurzy(modul.readKtojeprihl())
		If kurzy.Trim()="" Then
			MsgBox("Nemáte vytvorené žiadne kurzy. Najskôr prosím nejaký vytvorte!")
		End If
		Dim kurzyp As String() = kurzy.Trim().Split(New Char() {" "c})
		'MsgBox(kurzyp.Length)
		For Each kurz As String In kurzyp
            listBox1.Items.Add(kurz)
		Next
		listBox1.SelectedIndex=0
		Catch ex As Exception
			MsgBox(ex.Message)
		End Try
	End Sub
	
	Sub FSZKurzFormClosed(sender As Object, e As FormClosedEventArgs)
		FSZKurz.okno=0	
		MainForm.okno=0
	End Sub
	
	Sub Button1Click(sender As Object, e As EventArgs)
		'klikol na spusti vybraný kurz
		'spravim to pomocou fomrulára vyuka
		If listBox1.SelectedItem.Trim()="" Then
			MsgBox("There are no courses to run. First you must create some courses.")
		End If
		If listBox1.SelectedItem.Trim()<>"" Then
		Me.vybkurzik = listBox1.SelectedItem
		Dim fn As New FVyuka("vybranykurz")
		If FSZKurz.okno = 0 Then
			fn.Show	
			FSZKurz.okno = 1
		End If
		End If
	End Sub
	
	Sub ListBox1SelectedIndexChanged(sender As Object, e As EventArgs)
		FVyuka.por = 0
	End Sub
	
	Sub Button2Click(sender As Object, e As EventArgs)
		'klikol zmaz vybraný kurz
		Try
			If listBox1.SelectedItem.Trim()="" Then
				MsgBox("There are no courses to delete. First you must create som courses.")
			Else
				'inak tu idem mazať vybraý kurz
				Dim modul As New Module1
				modul.zmazVybranyKurz(listBox1.SelectedItem.ToString().Trim())
				MsgBox("We tried to delete selected course. Please see courses list.")
				listBox1.Items.Clear()
				
				Dim kurzy As String = modul.citajKurzy(modul.readKtojeprihl())
				If kurzy.Trim()="" Then
					MsgBox("You do not have created courses. First create some course!")
				End If
				Dim kurzyp As String() = kurzy.Trim().Split(New Char() {" "c})
				'MsgBox(kurzyp.Length)
				For Each kurz As String In kurzyp
		            listBox1.Items.Add(kurz)
				Next
				listBox1.SelectedIndex=0
				End If
		Catch ex As Exception
			MsgBox(ex.Message)
		End Try
	End Sub
	
	Sub ListBox1MouseDoubleClick(sender As Object, e As MouseEventArgs)
		'klikol na spusti vybraný kurz
		'spravim to pomocou fomrulára vyuka
		If listBox1.SelectedItem.Trim()="" Then
			MsgBox("There are no courses to run. First you must create some courses.")
		End If
		If listBox1.SelectedItem.Trim()<>"" Then
		Me.vybkurzik = listBox1.SelectedItem
		Dim fn As New FVyuka("vybranykurz")
		If FSZKurz.okno = 0 Then
			fn.Show	
			FSZKurz.okno = 1
		End If
		End If
	End Sub
End Class
