コード例 #1
0
        public ResultEntity Update(TorneoEntity torneo)
        {
            var result = new ResultEntity();

            var tn = new Torneo
            {
                Id             = torneo.Id,
                Nombre         = torneo.Nombre,
                IdPrimeraRonda = torneo.IdPrimeraRonda,
                IdSegundaRonda = torneo.IdSegundaRonda,
                IdTerceraRonda = torneo.IdTerceraRonda,
                TiempoDeJuego  = torneo.TiempoDeJuego,
                FechaCreacion  = torneo.FechaCreacion,
                Borrado        = torneo.Borrado
            };

            var repResult = _repository.Update(tn);

            result.ResultOk         = repResult.ActionResult;
            result.Message          = repResult.ActionResult ? "Torneo añadido con exito." : "Error al añadir un nuevo Torneo.";
            result.ErrorCode        = repResult.ActionResult ? 200 : 500;
            result.ErrorDescription = repResult.Error?.Message;

            return(result);
        }
コード例 #2
0
        private void BtnPrintResult_Click(object sender, RoutedEventArgs e)
        {
            TorneoEntity tournament     = SqlDal_Tournaments.GetTorneoById(_idTorneo);
            String       nomeDisciplina = SqlDal_Tournaments.GetDisciplinaById(_idDisciplina);

            pdf.FineTorneo(goldMedal, silverMedal, bronzeMedal, woodMedal, tournament.Name, nomeDisciplina);
        }
コード例 #3
0
        private static void ShowReport(object sender)
        {
            TorneoEntity torunament = ((FrameworkElement)sender).DataContext as TorneoEntity;

            TournamentResultReport report = new TournamentResultReport(torunament.Id, torunament.Name);

            report.Show();
        }
コード例 #4
0
        public static Int32 InserNewTorneo(TorneoEntity t)
        {
            String startDate = "@startDate";
            String endDate   = "@endDate";

            String commandText = "INSERT INTO Torneo VALUES ('" + t.Name + "','" + t.Place + "'," + startDate + "," + endDate + ", -1, '')" +
                                 "SELECT SCOPE_IDENTITY();";

            List <SqlParameter> parameters = new List <SqlParameter>
            {
                new SqlParameter(startDate, SqlDbType.DateTime)
                {
                    Value = t.StartDate
                },
                new SqlParameter(endDate, SqlDbType.DateTime)
                {
                    Value = t.EndDate
                }
            };

            SqlConnection c = null;

            try
            {
                c = new SqlConnection(Helper.GetConnectionString());

                c.Open();

                SqlCommand command = new SqlCommand(commandText, c);
                command.Parameters.AddRange(parameters.ToArray());
                SqlDataReader reader = command.ExecuteReader();

                Int32 idInserted = 0;
                reader.Read();

                idInserted = Convert.ToInt32(reader[0]);

                if (idInserted > 0)
                {
                    return(idInserted);
                }
                else
                {
                    return(0);
                }
            }
            catch (Exception ex)
            {
                return(0);
            }
            finally
            {
                c.Close();
            }
        }
コード例 #5
0
ファイル: TorneoController.cs プロジェクト: nkarg/CoreProject
        public IActionResult Edit(TorneoViewModel torneo)
        {
            if (ModelState.IsValid)
            {
                var tn = new TorneoEntity
                {
                    Id             = torneo.Id,
                    Nombre         = torneo.Nombre,
                    IdPrimeraRonda = torneo.IdPrimeraRonda,
                    IdSegundaRonda = torneo.IdSegundaRonda,
                    IdTerceraRonda = torneo.IdTerceraRonda,
                    TiempoDeJuego  = torneo.TiempoDeJuego,
                    FechaCreacion  = torneo.FechaCreacion,
                    Borrado        = torneo.Borrado,
                };

                ViewBag.ResultEntity = _torneoManager.Update(tn);
            }
            return(View());
        }
コード例 #6
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            if (textBoxNomeTorneo.Text != "")
            {
                DateTime datainizioTorneo = dateTimePickerDataInizioTorneo.Value;
                DateTime dataFineTorneo   = dateTimePickerDataFineTorneo.Value;
                String   nomeTorneo       = textBoxNomeTorneo.Text;
                String   luogoTorneo      = textBoxLuogo.Text;

                bool swordAndDagger  = checkBoxSpagaPugnale.Checked;
                bool swordAndBuckler = checkBoxSpadaBrocchiero.Checked;
                bool swordAndShield  = checkBoxSpadaRotella.Checked;
                bool twoHandSword    = checkBoxSpadaDueMani.Checked;
                bool singleSword     = checkBoxSpadaSola.Checked;

                TorneoEntity t = new TorneoEntity()
                {
                    Name      = nomeTorneo,
                    Place     = luogoTorneo,
                    StartDate = datainizioTorneo,
                    EndDate   = dataFineTorneo
                                //mancano i commenti
                };

                Int32 newTournamentId = SqlDal_Tournaments.InserNewTorneo(t);

                if (newTournamentId > 0)
                {
                    String categoria = radioButtonMale.Checked ? "M" : radioButtonMale.Checked ? "F" : "O";
                    SqlDal_Tournaments.AddDisciplineToTorneo(newTournamentId, singleSword, swordAndDagger, swordAndBuckler, swordAndShield, twoHandSword, categoria);
                }
                else
                {
                    MessageBox.Show("Errore durante il salvataggio del nuovo torneo", "ERRORE", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Inserire un nome per il nuovo Torneo", "Attenzione", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
コード例 #7
0
        public TorneoEntity GetById(int id)
        {
            TorneoEntity torneo = null;
            var          obj    = _repository.GetByKey(id);

            if (obj != null)
            {
                torneo = new TorneoEntity
                {
                    Id             = torneo.Id,
                    Nombre         = torneo.Nombre,
                    IdPrimeraRonda = torneo.IdPrimeraRonda,
                    IdSegundaRonda = torneo.IdSegundaRonda,
                    IdTerceraRonda = torneo.IdTerceraRonda,
                    TiempoDeJuego  = torneo.TiempoDeJuego,
                    FechaCreacion  = torneo.FechaCreacion,
                    Borrado        = torneo.Borrado
                };
            }

            return(torneo);
        }
コード例 #8
0
        public static TorneoEntity GetTorneoById(int idTorneo)
        {
            SqlConnection c = null;

            try
            {
                String sqlText = "SELECT * FROM TORNEO WHERE Id = " + idTorneo;
                c = new SqlConnection(Helper.GetConnectionString());

                c.Open();
                TorneoEntity torneo = new TorneoEntity();

                SqlCommand    command = new SqlCommand(sqlText, c);
                SqlDataReader reader  = command.ExecuteReader();

                while (reader.Read())
                {
                    torneo = new TorneoEntity()
                    {
                        Name      = reader["NomeTorneo"].ToString(),
                        Id        = Int32.Parse(reader["Id"].ToString()),
                        StartDate = Convert.ToDateTime(reader["DataInizio"].ToString()).Date,
                        EndDate   = Convert.ToDateTime(reader["DataFine"].ToString()).Date
                    };
                }

                return(torneo);
            }
            catch (Exception e)
            {
                return(null);
            }
            finally
            {
                c.Close();
            }
        }