private static Grup selectGrupDeUnTorneigIUnGrup(int idT, int numG) { Grup g = null; //--------------------------------- using (MySqlConnection connexio = MySQL.GetConnexio()) { connexio.Open(); using (MySqlCommand consulta = connexio.CreateCommand()) { consulta.CommandText = @"select * from grup where torneig_id = @idTorneig and num = @numGrup"; UtilsDB.AddParameter(consulta, "idTorneig", idT, MySqlDbType.Int32); UtilsDB.AddParameter(consulta, "numGrup", numG, MySqlDbType.Int32); MySqlDataReader reader = consulta.ExecuteReader(); while (reader.Read()) { Int32 num = reader.GetInt32(reader.GetOrdinal("num")); string description = reader.GetString(reader.GetOrdinal("description")); Int32 carambolesVictoria = reader.GetInt32(reader.GetOrdinal("caramboles_victoria")); Int32 limitEntrades = reader.GetInt32(reader.GetOrdinal("limit_entrades")); Torneig t = TorneigBD.selectTorneigPerId(idT); g = new Grup(num, description, carambolesVictoria, limitEntrades, t); } } } return(g); }
public static Torneig selectTorneigPerId(int idTorneig) { Torneig t = null; using (MySqlConnection connexio = MySQL.GetConnexio()) { connexio.Open(); using (MySqlCommand consulta = connexio.CreateCommand()) { consulta.CommandText = @"select * from torneig where id = @idTorneig"; UtilsDB.AddParameter(consulta, "idTorneig", idTorneig, MySqlDbType.Int32); MySqlDataReader reader = consulta.ExecuteReader(); while (reader.Read()) { Int32 id = reader.GetInt32(reader.GetOrdinal("id")); string nom = reader.GetString(reader.GetOrdinal("nom")); DateTime dataAlta = reader.GetDateTime(reader.GetOrdinal("data_inici")); DateTime dataFinalitzacio = new DateTime(); try { dataFinalitzacio = reader.GetDateTime(reader.GetOrdinal("data_finalitzacio")); } catch (Exception e) { } Int32 preinscripcioOberta = reader.GetInt32(reader.GetOrdinal("preinscripcio_oberta")); Modalitat mod = TorneigBD.selectModalitatPerId(reader.GetInt32(reader.GetOrdinal("modalitat_id"))); t = new Torneig(id, nom, dataAlta, dataFinalitzacio, preinscripcioOberta, mod); } } } return(t); }
public static ObservableCollection <Grup> selectGrupsDeUnTorneig(Int32 idTorneig) { ObservableCollection <Grup> grups = new ObservableCollection <Grup>(); //--------------------------------- using (MySqlConnection connexio = MySQL.GetConnexio()) { connexio.Open(); using (MySqlCommand consulta = connexio.CreateCommand()) { consulta.CommandText = @"select * from grup where torneig_id = @idTorneig"; UtilsDB.AddParameter(consulta, "idTorneig", idTorneig, MySqlDbType.Int32); MySqlDataReader reader = consulta.ExecuteReader(); while (reader.Read()) { Int32 num = reader.GetInt32(reader.GetOrdinal("num")); string description = reader.GetString(reader.GetOrdinal("description")); Int32 carambolesVictoria = reader.GetInt32(reader.GetOrdinal("caramboles_victoria")); Int32 limitEntrades = reader.GetInt32(reader.GetOrdinal("limit_entrades")); Torneig t = TorneigBD.selectTorneigPerId(idTorneig); Grup g = new Grup(num, description, carambolesVictoria, limitEntrades, t); grups.Add(g); } } } return(grups); }
public static ObservableCollection <Inscrit> selectInscritsDeUnTorneigIGrup(Int32 idTorneig, Grup g) { DateTime data; ObservableCollection <Inscrit> inscrits = new ObservableCollection <Inscrit>(); //--------------------------------- using (MySqlConnection connexio = MySQL.GetConnexio()) { connexio.Open(); using (MySqlCommand consulta = connexio.CreateCommand()) { consulta.CommandText = @"select inscrit.* from inscrit where inscrit.torneig_id = @idTorneig and inscrit.grup_num = @numGrup"; UtilsDB.AddParameter(consulta, "idTorneig", idTorneig, MySqlDbType.Int32); UtilsDB.AddParameter(consulta, "numGrup", g.Num, MySqlDbType.Int32); MySqlDataReader reader = consulta.ExecuteReader(); while (reader.Read()) { Inscrit i; Int32 idS = reader.GetInt32(reader.GetOrdinal("soci_id")); Int32 idT = reader.GetInt32(reader.GetOrdinal("torneig_id")); Int32 numG = -1; try { numG = reader.GetInt32(reader.GetOrdinal("grup_num")); } catch (Exception e) { } data = reader.GetDateTime(reader.GetOrdinal("data")); Soci s = TorneigBD.selectSociPerId(idS); Torneig t = TorneigBD.selectTorneigPerId(idT); if (numG != -1) { Grup gr = TorneigBD.selectGrupDeUnTorneigIUnGrup(idT, numG); i = new Inscrit(s, t, gr, data); inscrits.Add(i); } else { i = new Inscrit(s, t, null, data); inscrits.Add(i); } } } } return(inscrits); }
public static ObservableCollection <Inscrit> selectInscritsDeUnTorneig(Int32 idTorneig) { DateTime data; ObservableCollection <Inscrit> inscrits = new ObservableCollection <Inscrit>(); //--------------------------------- using (MySqlConnection connexio = MySQL.GetConnexio()) { connexio.Open(); using (MySqlCommand consulta = connexio.CreateCommand()) { consulta.CommandText = @"select inscrit.* from inscrit inner join soci on inscrit.soci_id = soci.id left join estadistica_modalitat on estadistica_modalitat.soci_id = soci.id where inscrit.torneig_id = @idTorneig and inscrit.grup_num is NULL and estadistica_modalitat.modalitat_id = 1 order by estadistica_modalitat.coeficient_base desc"; UtilsDB.AddParameter(consulta, "idTorneig", idTorneig, MySqlDbType.Int32); MySqlDataReader reader = consulta.ExecuteReader(); while (reader.Read()) { Inscrit i; Int32 idS = reader.GetInt32(reader.GetOrdinal("soci_id")); Int32 idT = reader.GetInt32(reader.GetOrdinal("torneig_id")); Int32 numG = -1; try { numG = reader.GetInt32(reader.GetOrdinal("grup_num")); } catch (Exception e) { } data = reader.GetDateTime(reader.GetOrdinal("data")); Soci s = TorneigBD.selectSociPerId(idS); Torneig t = TorneigBD.selectTorneigPerId(idT); if (numG != -1) { Grup g = TorneigBD.selectGrupDeUnTorneigIUnGrup(idT, numG); i = new Inscrit(s, t, g, data); inscrits.Add(i); } else { i = new Inscrit(s, t, null, data); inscrits.Add(i); } } } } return(inscrits); }
internal static object selectTornejosFiltrados(bool data, bool estat) { String dataString = data == true ? "asc" : "desc"; Int32 estatInt = estat == true ? 1 : 0; ObservableCollection <Torneig> tornejos = new ObservableCollection <Torneig>(); //--------------------------------- using (MySqlConnection connexio = MySQL.GetConnexio()) { connexio.Open(); using (MySqlCommand consulta = connexio.CreateCommand()) { consulta.CommandText = data == true ? @"select * from torneig where preinscripcio_oberta = @estat order by data_inici asc" : @"select * from torneig where preinscripcio_oberta = @estat order by data_inici desc"; UtilsDB.AddParameter(consulta, "estat", estatInt, MySqlDbType.Int32); MySqlDataReader reader = consulta.ExecuteReader(); while (reader.Read()) { Int32 id = reader.GetInt32(reader.GetOrdinal("id")); string nom = reader.GetString(reader.GetOrdinal("nom")); DateTime dataAlta = reader.GetDateTime(reader.GetOrdinal("data_inici")); DateTime dataFinalitzacio = new DateTime(); try { dataFinalitzacio = reader.GetDateTime(reader.GetOrdinal("data_finalitzacio")); } catch (Exception e) { } Int32 preinscripcioOberta = reader.GetInt32(reader.GetOrdinal("preinscripcio_oberta")); Modalitat mod = TorneigBD.selectModalitatPerId(reader.GetInt32(reader.GetOrdinal("modalitat_id"))); Torneig t = new Torneig(id, nom, dataAlta, dataFinalitzacio, preinscripcioOberta, mod); tornejos.Add(t); } } } return(tornejos); }
public static ObservableCollection <Torneig> selectTornejos() { ObservableCollection <Torneig> tornejos = new ObservableCollection <Torneig>(); //--------------------------------- using (MySqlConnection connexio = MySQL.GetConnexio()) { connexio.Open(); using (MySqlCommand consulta = connexio.CreateCommand()) { consulta.CommandText = @"select * from torneig"; MySqlDataReader reader = consulta.ExecuteReader(); while (reader.Read()) { Int32 id = reader.GetInt32(reader.GetOrdinal("id")); string nom = reader.GetString(reader.GetOrdinal("nom")); DateTime dataAlta = new DateTime(); dataAlta = reader.GetDateTime(reader.GetOrdinal("data_inici")); DateTime dataFinalitzacio = new DateTime(); try { dataFinalitzacio = reader.GetDateTime(reader.GetOrdinal("data_finalitzacio")); } catch (Exception e) { } Int32 preinscripcioOberta = reader.GetInt32(reader.GetOrdinal("preinscripcio_oberta")); Modalitat mod = TorneigBD.selectModalitatPerId(reader.GetInt32(reader.GetOrdinal("modalitat_id"))); Torneig t = new Torneig(id, nom, dataAlta, dataFinalitzacio, preinscripcioOberta, mod); tornejos.Add(t); } } } return(tornejos); }