protected void UpdateFixture(object sender, GridViewUpdateEventArgs e) { FechaCampeonato fechaFixture = new FechaCampeonato(); Resultado resultadoPartido = new Resultado(); try { //Obtengo los valores de la fecha del fixture a modificar if (((DropDownList)grillaCampeonato.Rows[e.RowIndex].FindControl("ddlFechaGrilla_edit")).SelectedValue == "") { throw new SportingException("El campo Fecha Nro es requerido. Seleccione una fecha."); } fechaFixture.IdFecha = Convert.ToInt32(((DropDownList)grillaCampeonato.Rows[e.RowIndex].FindControl("ddlFechaGrilla_edit")).SelectedValue); if (((TextBox)grillaCampeonato.Rows[e.RowIndex].FindControl("txtFechaPartido")).Text == "") { throw new SportingException("El campo Fecha partido es requerido. Seleccione una fecha"); } try { resultadoPartido.FechaPartido = Convert.ToDateTime(((TextBox)grillaCampeonato.Rows[e.RowIndex].FindControl("txtFechaPartido")).Text); } catch (Exception ex) { throw new SportingException("Fecha incorrecta. Ingrese una fecha válida."); } if (((DropDownList)grillaCampeonato.Rows[e.RowIndex].FindControl("ddlLocalGrilla_edit")).SelectedValue == "") { throw new SportingException("El campo Local es requerido. Seleccione un equipo Local."); } resultadoPartido.EquipoLocal = new EquipoCampeonato(); resultadoPartido.EquipoLocal.IdEquipo = Convert.ToInt32(((DropDownList)grillaCampeonato.Rows[e.RowIndex].FindControl("ddlLocalGrilla_edit")).SelectedValue); if (((TextBox)grillaCampeonato.Rows[e.RowIndex].FindControl("txtPuntosLocal")).Text == "") { throw new SportingException("El campo Puntos Local es requerido. Si el partido no ha sido jugado ingrese cero (0)"); } try { resultadoPartido.EquipoLocalPuntos = Convert.ToInt32(((TextBox)grillaCampeonato.Rows[e.RowIndex].FindControl("txtPuntosLocal")).Text); } catch (Exception ex) { throw new SportingException("Puntos Local incorrecto. Ingrese solo números."); } if (((DropDownList)grillaCampeonato.Rows[e.RowIndex].FindControl("ddlVisitanteGrilla_edit")).SelectedValue == "") { throw new SportingException("El campo Visitante es requerido. Seleccione un equipo Visitante."); } resultadoPartido.EquipoVisitante = new EquipoCampeonato(); resultadoPartido.EquipoVisitante.IdEquipo = Convert.ToInt32(((DropDownList)grillaCampeonato.Rows[e.RowIndex].FindControl("ddlVisitanteGrilla_edit")).SelectedValue); if (((TextBox)grillaCampeonato.Rows[e.RowIndex].FindControl("txtPuntosVisitante")).Text == "") { throw new SportingException("El campo Puntos Visitante es requerido. Si el partido no ha sido jugado ingrese cero (0)"); } try { resultadoPartido.EquipoVisitantePuntos = Convert.ToInt32(((TextBox)grillaCampeonato.Rows[e.RowIndex].FindControl("txtPuntosVisitante")).Text); } catch (Exception ex) { throw new SportingException("Puntos Visitante incorrecto. Ingrese solo números."); } resultadoPartido.IdResultado = Convert.ToInt32(((Label)grillaCampeonato.Rows[e.RowIndex].FindControl("lblIdResultadoPartido")).Text); fechaFixture.Resultados = new List<Resultado>(); fechaFixture.Resultados.Add(resultadoPartido); //Modifico el partido del fixture existente GestorCampeonato.updatePartidoFixture(fechaFixture); setSuccessColorOutput(true); lblOutputFixture.Text = "Partido actualizado con éxito!"; //Recargo la grilla de fixture grillaCampeonato.EditIndex = -1; int idCamp = Convert.ToInt32(ddlCampeonato.SelectedValue); int idFecha = Convert.ToInt32(ddlFecha.SelectedValue); cargarFixture(idCamp, idFecha); } catch (SportingException spEx) { setSuccessColorOutput(false); lblOutputFixture.Text = spEx.Message; } catch (Exception ex) { setSuccessColorOutput(false); lblOutputFixture.Text = ex.Message; } }
protected void UpdateFecha(object sender, GridViewUpdateEventArgs e) { FechaCampeonato fechaCamp = new FechaCampeonato(); try { //Obtengo los valores de la fecha de campeoanto if (((DropDownList)grillaFechas.Rows[e.RowIndex].FindControl("ddlCampeonato_edit")).SelectedValue == "") { throw new SportingException("Campeonato requerido. Seleccione un campeonato."); } fechaCamp.IdCampeonato = Convert.ToInt32(((DropDownList)grillaFechas.Rows[e.RowIndex].FindControl("ddlCampeonato_edit")).SelectedValue); if (((TextBox)grillaFechas.Rows[e.RowIndex].FindControl("txtNumeroFecha")).Text == "") { throw new SportingException("Número de fecha requerido."); } try { fechaCamp.Numero = Convert.ToInt32(((TextBox)grillaFechas.Rows[e.RowIndex].FindControl("txtNumeroFecha")).Text); } catch (Exception ex) { throw new SportingException("Número de fecha incorrecto. Ingrese solo números."); } fechaCamp.Descripcion = ((TextBox)grillaFechas.Rows[e.RowIndex].FindControl("txtDesc")).Text; fechaCamp.IdFecha = Convert.ToInt32(((Label)grillaFechas.Rows[e.RowIndex].FindControl("lblIdFecha")).Text); //Modifico una fecha de campeonato existente GestorCampeonato.updateFechaCampeonato(fechaCamp); setSuccessColorOutput(true); lblOutputFecha.Text = "Fecha actualizada con éxito!"; //Recargo la grilla grillaFechas.EditIndex = -1; cargarFechas(); } catch (SportingException spEx) { setSuccessColorOutput(false); lblOutputFecha.Text = spEx.Message; } catch (Exception ex) { setSuccessColorOutput(false); lblOutputFecha.Text = ex.Message; } }
protected void AgregarPartido(object sender, EventArgs e) { FechaCampeonato fechaFixture = new FechaCampeonato(); Resultado resultadoPartido = new Resultado(); try { //Obtengo los valores de la nueva fecha del fixture if (((DropDownList)grillaCampeonato.FooterRow.FindControl("ddlFechaGrilla")).SelectedValue == "") { throw new SportingException("El campo Fecha Nro es requerido. Seleccione una fecha."); } fechaFixture.IdFecha = Convert.ToInt32(((DropDownList)grillaCampeonato.FooterRow.FindControl("ddlFechaGrilla")).SelectedValue); if (((TextBox)grillaCampeonato.FooterRow.FindControl("txtFechaPartidoFooter")).Text == "") { throw new SportingException("El campo Fecha partido es requerido. Seleccione una fecha"); } try { resultadoPartido.FechaPartido = Convert.ToDateTime(((TextBox)grillaCampeonato.FooterRow.FindControl("txtFechaPartidoFooter")).Text); } catch (Exception ex) { //trying to parse the date with other technique try { resultadoPartido.FechaPartido = DateTime.ParseExact(((TextBox)grillaCampeonato.FooterRow.FindControl("txtFechaPartidoFooter")).Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); } catch (Exception) { throw new SportingException("Fecha incorrecta. Ingrese una fecha válida."); } } if (((DropDownList)grillaCampeonato.FooterRow.FindControl("ddlLocalGrilla")).SelectedValue == "") { throw new SportingException("El campo Local es requerido. Seleccione un equipo Local."); } resultadoPartido.EquipoLocal = new EquipoCampeonato(); resultadoPartido.EquipoLocal.IdEquipo = Convert.ToInt32(((DropDownList)grillaCampeonato.FooterRow.FindControl("ddlLocalGrilla")).SelectedValue); if (((TextBox)grillaCampeonato.FooterRow.FindControl("txtPuntosLocal")).Text == "") { throw new SportingException("El campo Puntos Local es requerido. Si el partido no ha sido jugado ingrese cero (0)"); } try { resultadoPartido.EquipoLocalPuntos = Convert.ToInt32(((TextBox)grillaCampeonato.FooterRow.FindControl("txtPuntosLocal")).Text); } catch (Exception ex) { throw new SportingException("Puntos Local incorrecto. Ingrese solo números."); } if (((DropDownList)grillaCampeonato.FooterRow.FindControl("ddlVisitanteGrilla")).SelectedValue == "") { throw new SportingException("El campo Visitante es requerido. Seleccione un equipo Visitante."); } resultadoPartido.EquipoVisitante = new EquipoCampeonato(); resultadoPartido.EquipoVisitante.IdEquipo = Convert.ToInt32(((DropDownList)grillaCampeonato.FooterRow.FindControl("ddlVisitanteGrilla")).SelectedValue); if (((TextBox)grillaCampeonato.FooterRow.FindControl("txtPuntosVisitante")).Text == "") { throw new SportingException("El campo Puntos Visitante es requerido. Si el partido no ha sido jugado ingrese cero (0)"); } try { resultadoPartido.EquipoVisitantePuntos = Convert.ToInt32(((TextBox)grillaCampeonato.FooterRow.FindControl("txtPuntosVisitante")).Text); } catch (Exception ex) { throw new SportingException("Puntos Visitante incorrecto. Ingrese solo números."); } fechaFixture.Resultados = new List<Resultado>(); fechaFixture.Resultados.Add(resultadoPartido); //Guardo el nuevo partido del fixture GestorCampeonato.registrarPartidoFixture(fechaFixture); setSuccessColorOutput(true); lblOutputFixture.Text = "Partido registrado con éxito!"; //Recargo la grilla //Cargo el fixture int idCamp = Convert.ToInt32(ddlCampeonato.SelectedValue); int idFecha = Convert.ToInt32(ddlFecha.SelectedValue); cargarFixture(idCamp, idFecha); grillaCampeonato.SelectedIndex = -1; } catch (SportingException spEx) { setSuccessColorOutput(false); lblOutputFixture.Text = spEx.Message; } catch (Exception ex) { setSuccessColorOutput(false); lblOutputFixture.Text = ex.Message; } }
public static void updatePartidoFixture(FechaCampeonato partidoFixture) { try { if (partidoFixture != null && partidoFixture.Resultados[0] != null) { //Estoy actualizando un solo partido por eso tomo el primero Resultado partido = partidoFixture.Resultados[0]; if (partido.EquipoLocalPuntos != 0 || partido.EquipoVisitantePuntos != 0) { partidoFixture.Resultados[0].Jugado = true; } else { partidoFixture.Resultados[0].Jugado = false; } CampeonatoDAL.updatePartidoFixture(partidoFixture); } else { throw new SportingException("Error al modificar un partido del fixture."); } } catch (SportingException spEx) { throw spEx; } catch (Exception e) { throw new SportingException("Error al modificar un partido del fixture." + e.Message); } }
protected void AddFecha(object sender, EventArgs e) { FechaCampeonato fechaCamp = new FechaCampeonato(); try { //Obtengo los valores de la nueva fecha de campeoanto if (((DropDownList)grillaFechas.FooterRow.FindControl("ddlCampeonato")).SelectedValue == "") { throw new SportingException("Campeonato requerido. Seleccione un campeonato."); } fechaCamp.IdCampeonato = Convert.ToInt32(((DropDownList)grillaFechas.FooterRow.FindControl("ddlCampeonato")).SelectedValue); if (((TextBox)grillaFechas.FooterRow.FindControl("txtNumeroFecha")).Text == "") { throw new SportingException("Número de fecha requerido."); } try { fechaCamp.Numero = Convert.ToInt32(((TextBox)grillaFechas.FooterRow.FindControl("txtNumeroFecha")).Text); } catch (Exception ex) { throw new SportingException("Número de fecha incorrecto. Ingrese solo números."); } fechaCamp.Descripcion = ((TextBox)grillaFechas.FooterRow.FindControl("txtDesc")).Text; //Guardo la nueva fecha de campeonato GestorCampeonato.registrarFechaCampeonato(fechaCamp); setSuccessColorOutput(true); lblOutputFecha.Text = "Fecha registrada con éxito!"; //Recargo la grilla cargarFechas(); grillaFechas.SelectedIndex = -1; } catch (SportingException spEx) { setSuccessColorOutput(false); lblOutputFecha.Text = spEx.Message; } catch (Exception ex) { setSuccessColorOutput(false); lblOutputFecha.Text = ex.Message; } }
public static void registrarFechaCampeonato(FechaCampeonato fechaCamp) { try { CampeonatoDAL.insertarFecha(fechaCamp); } catch (SportingException spEx) { throw spEx; } catch (Exception e) { throw new SportingException("Error al registrar una fecha de campeonato." + e.Message); } }
public static void updateFechaCampeonato(FechaCampeonato fechaCamp) { try { CampeonatoDAL.updateFecha(fechaCamp); } catch (SportingException spEx) { throw spEx; } catch (Exception e) { throw new SportingException("Error al actualizar la fecha de campeonato." + e.Message); } }
public static void updateFecha(FechaCampeonato fechaCamp) { OdbcConnection conexion = null; OdbcCommand cmd = null; try { if (fechaCamp == null) { throw new SportingException("Error al actualizar la fecha de campeonato. Fecha sin información."); } conexion = ConexionBD.ObtenerConexion(); //Actualizo los datos de la fecha de campeonato String updateFecha = "UPDATE fecha_campeonato set numero=" + fechaCamp.Numero + ", descripcion = '" + fechaCamp.Descripcion + "', idCampeonato = "+ fechaCamp.IdCampeonato +" WHERE id = " + fechaCamp.IdFecha.ToString(); cmd = new OdbcCommand(updateFecha, conexion); cmd.ExecuteNonQuery(); conexion.Close(); } catch (Exception e) { throw e; } finally { cmd.Connection.Close(); } }
public static void updatePartidoFixture(FechaCampeonato partidoFixture) { OdbcConnection conexion = null; OdbcCommand cmd = null; try { if (partidoFixture == null) { throw new SportingException("Error al modificar partido en el fixture. Partido sin información."); } conexion = ConexionBD.ObtenerConexion(); //Actualizo los datos del partido String updatePartidoFixture = "UPDATE resultado_partido set idFecha = " + partidoFixture.IdFecha + ", "+ " idEquipoLocal = " + partidoFixture.Resultados[0].EquipoLocal.IdEquipo + ", "+ " localPuntos = " + partidoFixture.Resultados[0].EquipoLocalPuntos + ", "+ " idEquipoVisitante = " + partidoFixture.Resultados[0].EquipoVisitante.IdEquipo + ", "+ " visitantePuntos = " + partidoFixture.Resultados[0].EquipoVisitantePuntos + ", "+ " jugado = " + partidoFixture.Resultados[0].Jugado + ", "+ " fechaPartido = '" + partidoFixture.Resultados[0].FechaPartido.ToString("yyyy/MM/dd") + "' "+ "WHERE id = " +partidoFixture.Resultados[0].IdResultado.ToString(); cmd = new OdbcCommand(updatePartidoFixture, conexion); cmd.ExecuteNonQuery(); conexion.Close(); } catch (Exception e) { throw e; } finally { cmd.Connection.Close(); } }
public static void insertarPartidoFixture(FechaCampeonato partidoFixture) { OdbcConnection conexion = null; OdbcCommand cmd = null; try { if (partidoFixture == null) { throw new SportingException("Error al registrar nuevo partido en el fixture. Partido sin información."); } conexion = ConexionBD.ObtenerConexion(); //Guardo los datos del partido String insertarPartidoFixture = " INSERT INTO resultado_partido (idFecha, idEquipoLocal, localPuntos, " + " idEquipoVisitante, visitantePuntos, jugado, fechaPartido) " + " VALUES (" + partidoFixture.IdFecha + ", " + partidoFixture.Resultados[0].EquipoLocal.IdEquipo + ", " + partidoFixture.Resultados[0].EquipoLocalPuntos +", "+ partidoFixture.Resultados[0].EquipoVisitante.IdEquipo + ", " + partidoFixture.Resultados[0].EquipoVisitantePuntos +", "+ partidoFixture.Resultados[0].Jugado+ ", '" + partidoFixture.Resultados[0].FechaPartido.ToString("yyyy/MM/dd") + "')"; cmd = new OdbcCommand(insertarPartidoFixture, conexion); cmd.ExecuteNonQuery(); conexion.Close(); } catch (Exception e) { throw e; } finally { cmd.Connection.Close(); } }
public static void insertarFecha(FechaCampeonato fechaCamp) { OdbcConnection conexion = null; OdbcCommand cmd = null; try { if (fechaCamp == null) { throw new SportingException("Error al registrar nueva fecha de campeonato. Fecha sin información."); } conexion = ConexionBD.ObtenerConexion(); //Guardo los datos de la fecha String insertarFecha = " INSERT INTO fecha_campeonato (numero, descripcion, idCampeonato)" + " VALUES (" + fechaCamp.Numero + ", '" + fechaCamp.Descripcion + "' , " + fechaCamp.IdCampeonato + ")"; cmd = new OdbcCommand(insertarFecha, conexion); cmd.ExecuteNonQuery(); conexion.Close(); } catch (Exception e) { throw e; } finally { cmd.Connection.Close(); } }
/// <summary> /// Obtiene la lista de resultados de una fecha especifica. /// </summary> /// <param name="fecha"></param> /// <returns></returns> public static List<Resultado> getResultadosFecha(FechaCampeonato fecha, OdbcConnection con) { List<Resultado> resultados = new List<Resultado>(); String getResultadosFecha = "SELECT r.id, r.idEquipoLocal, r.localPuntos, r.idEquipoVisitante, r.visitantePuntos, r.jugado, r.fechaPartido "+ "FROM resultado_partido r " + "WHERE r.idFecha = " + fecha.IdFecha; OdbcDataReader dr = null; try { OdbcCommand cmd = new OdbcCommand(getResultadosFecha, con); cmd.CommandType = CommandType.Text; dr = cmd.ExecuteReader(); while (dr.Read()) { Resultado r = new Resultado(); r.IdResultado = dr.GetInt32(0); r.EquipoLocal = getEquipoById(dr.GetInt32(1), con); r.EquipoLocalPuntos = dr.GetInt32(2); r.EquipoVisitante = getEquipoById(dr.GetInt32(3), con); r.EquipoVisitantePuntos = dr.GetInt32(4); r.Jugado = dr.GetBoolean(5); r.FechaPartido = dr.GetDate(dr.GetOrdinal("fechaPartido")); resultados.Add(r); } } catch (Exception e) { throw new SportingException("Ocurrio un problema al intentar obtener los resultados de la fecha '" + fecha.Numero + "'. " + e.Message); } return resultados; }
public static List<FechaCampeonato> getFixtureCampeonato_porFecha(CampeonatoLiga camp, int fecha) { List<FechaCampeonato> fechasCamp = new List<FechaCampeonato>(); try { OdbcConnection con = ConexionBD.ObtenerConexion(); String getFixture = " SELECT f.id, f.numero, f.descripcion FROM fecha_campeonato f" + " WHERE f.idCampeonato = " + camp.IdCampeonato + " AND f.id = " + fecha; OdbcCommand cmd = new OdbcCommand(getFixture, con); OdbcDataAdapter da = new OdbcDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); FechaCampeonato f; foreach (DataRow row in dt.Rows) { f = new FechaCampeonato(); f.IdFecha = Convert.ToInt32(row["id"].ToString()); f.Numero = Convert.ToInt32(row["numero"].ToString()); f.Descripcion = row["descripcion"].ToString(); f.Resultados = getResultadosFecha(f, con); fechasCamp.Add(f); } } catch (SportingException sEx) { throw sEx; } catch (Exception e) { throw new SportingException("Ocurrio un problema al intentar obtener las fechas del campeonato. " + e.Message); } return fechasCamp; }
/// <summary> /// Obtiene la lista con las fechas de un campeonato especifico /// </summary> /// <param name="camp"></param> /// <returns></returns> public static List<FechaCampeonato> getFechasDeCampeonato(CampeonatoLiga camp, OdbcConnection con) { List<FechaCampeonato> fechas = new List<FechaCampeonato>(); String getFechas = "SELECT f.id, f.numero, f.descripcion FROM fecha_campeonato f" + " WHERE f.idCampeonato = " + camp.IdCampeonato + " ORDER BY f.numero"; OdbcDataReader dr = null; try { OdbcCommand cmd = new OdbcCommand(getFechas, con); cmd.CommandType = CommandType.Text; dr = cmd.ExecuteReader(); while (dr.Read()) { FechaCampeonato f = new FechaCampeonato(); f.IdFecha = dr.GetInt32(0); f.Numero = dr.GetInt32(1); f.Descripcion = dr.GetString(2); f.Resultados = getResultadosFecha(f, con); fechas.Add(f); } } catch (Exception e) { throw new SportingException("Ocurrio un problema al intentar obtener las fechas del campeonato '" + camp.Nombre + "'. " + e.Message); } return fechas; }