Imports System.ComponentModel
Imports System.IO
Imports MySql.Data.MySqlClient

Public Class frm_ranking
    Private Sub frm_ranking_Closing(sender As Object, e As CancelEventArgs) Handles Me.Closing

        frm_event_control.Show()

    End Sub

    Private Sub frm_ranking_Load(sender As Object, e As EventArgs) Handles Me.Load

        cbo_display_type.SelectedIndex = 0

    End Sub

    Private Sub cbo_display_type_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cbo_display_type.SelectedIndexChanged

    End Sub

    Private Sub list_weight_classes(eventID As Integer)

        Dim QRY As String = ("

            select 
	            distinct
	            person.gender, person.category, person.weight_class
            from 
	            person
            left join
	            event_matches on (person.id = coalesce(event_matches.blue_fighter, 0) or person.id = coalesce(event_matches.red_fighter, 0))
            where 
	            event_matches.eid = " & eventID & "
            order by 
                category, 
                gender, 
                weight_class 
                asc
        ")

        Dim CON As New MySqlConnection(CON_STRING)
        Dim COM As New MySqlCommand(QRY, CON)
        Dim RDR As MySqlDataReader
        Dim LST As New List(Of dataset)

        Try
            CON.Open()
            RDR = COM.ExecuteReader
            If RDR.HasRows = True Then
                While RDR.Read
                    LST.Add(New dataset(RDR("weight_class"), RDR("category")))
                End While
            End If
            CON.Close()
        Catch ex As MySqlException
            MessageBox.Show(ex.Message)
        Finally
            CON.Dispose()
        End Try

        lst_type.DataSource = LST
        lst_type.ValueMember = "ID"
        lst_type.DisplayMember = "name"

    End Sub

End Class