Пример #1
0
        private void btnCrearGrup_Click(object sender, RoutedEventArgs e)
        {
            Torneig t = (Torneig)lvTornejos.SelectedItem;

            if (t != null)
            {
                Int32 caramboles, entrades;

                if (!(txtNomGrup.Text.Length >= 2 || txbTitol.Text.Length > 30))
                {
                    DisplayError("Error", "El nom del grup es incorrecte (2-30 caracters)");
                    return;
                }

                try
                {
                    entrades = Int32.Parse(txtLimitEntradesGrup.Text);
                }
                catch (Exception ex)
                {
                    DisplayError("Error", "Número d'entrades incorrecte");
                    return;
                }

                try
                {
                    caramboles = Int32.Parse(txtCarambolesGrup.Text);
                }
                catch (Exception ex)
                {
                    DisplayError("Error", "Número de caramboles incorrecte");
                    return;
                }

                Int32   contadorGrups = TorneigBD.selectTotalGrupsPerTorneig(t.Id);
                Torneig tor           = TorneigBD.selectTorneigPerId(t.Id);
                Grup    g             = new Grup(contadorGrups, txtNomGrup.Text, caramboles, entrades, tor);
                TorneigBD.insertGrupAUnTorneig(t.Id, g);
                lvGrupsDisponibles.ItemsSource = TorneigBD.selectGrupsDeUnTorneig(t.Id);
            }
        }