public void Actualizar() { ControladorDeporte controladorDeporte = new ControladorDeporte(); List <ModelDeporte> lista; deporteBindingSource.Clear(); if (txtNombreDeporte.Text.ToString().Equals("") && txtDescripcionDeporte.Text.ToString().Equals("")) { lista = controladorDeporte.ListarTodosDeportes(); } else { lista = controladorDeporte.ListarTodosDeportesPorFiltros(txtNombreDeporte.Text.ToString(), txtDescripcionDeporte.Text.ToString()); } if (lista.Count == 0) { ModificarMensaje("NO EXISTE NINGÚN DEPORTE CON LOS FILTROS SELECCIONADOS"); return; } else if (lblInfoDeporte.Text.Equals("NO EXISTE NINGÚN DEPORTE CON LOS FILTROS SELECCIONADOS")) { ModificarMensaje(""); } dataGridViewDeporte.DataSource = lista; dataGridViewDeporte.Visible = true; }
public void Test3CategoriaControladorBD() { // Una vez ejecutada el testing de Deporte debieron haber sido creado 2 deportes nuevos ControladorDeporte controladorDeporte = new ControladorDeporte(); ControladorCategoria controladorCategoria = new ControladorCategoria(); DateTime Inicio = DateTime.ParseExact("01/08/2018", "dd/MM/yyyy", CultureInfo.InvariantCulture); DateTime Fin = DateTime.ParseExact("30/11/2018", "dd/MM/yyyy", CultureInfo.InvariantCulture); //Aceptado Assert.IsTrue(controladorCategoria.CrearCategoria("FutbolPrueba 2do cuastrimestre 2018", 600, Inicio, Fin, controladorDeporte.BuscarDeportePorClavesUnicas("FutbolPrueba")) > 0); Assert.IsTrue(controladorCategoria.CrearCategoria("NatacionPrueba 2do cuastimestre 2018", 500, Inicio, Fin, controladorDeporte.BuscarDeportePorClavesUnicas("NatacionPrueba")) > 0); Categoria Categoria_buscado = controladorCategoria.BuscarCategoriaPorClavesUnicas("FutbolPrueba 2do cuastrimestre 2018"); Assert.IsNotNull(Categoria_buscado); Assert.IsTrue(controladorCategoria.ListarTodosCategorias().Count > 0); Assert.IsTrue(controladorCategoria.ListarTodosCategoriasFiltro("cuastr", controladorDeporte.BuscarDeportePorClavesUnicas("FutbolPrueba")).Count > 0); Assert.IsTrue(controladorCategoria.ModificarCategoria(Categoria_buscado.IdCategoria, "FutbolPrueba 2do cuastrimestre 2018", 1200, Inicio, Fin, controladorDeporte.BuscarDeportePorClavesUnicas("FutbolPrueba"), EnumEstadoCategoria.Pendiente) > 0); //Error Assert.AreEqual(controladorCategoria.CrearCategoria("FutbolPrueba 2do cuastrimestre 2018", 600, Inicio, Fin, controladorDeporte.BuscarDeportePorClavesUnicas("FutbolPrueba")), -2); Assert.IsFalse(controladorCategoria.ListarTodosCategoriasFiltro("z", controladorDeporte.BuscarDeportePorClavesUnicas("FutbolPrueba")).Count > 0); Assert.IsFalse(controladorCategoria.ListarTodosCategoriasFiltro("FutbolPrueba", controladorDeporte.BuscarDeportePorClavesUnicas("NatacionPrueba")).Count > 0); //Eliminación Assert.IsTrue(controladorCategoria.EliminarCategoria(Categoria_buscado) > 0); Categoria_buscado = controladorCategoria.BuscarCategoriaPorClavesUnicas("NatacionPrueba 2do cuastimestre 2018"); Assert.IsTrue(controladorCategoria.EliminarCategoria(Categoria_buscado) > 0); //Como que se eliminaron todo, todavia debe existir en la bd pero en estado BAJA //Recuperación Assert.IsTrue(controladorCategoria.CrearCategoria("FutbolPrueba 2do cuastrimestre 2018", 9950, Inicio, Fin, controladorDeporte.BuscarDeportePorClavesUnicas("FutbolPrueba")) == -1); Assert.IsTrue(controladorCategoria.CrearCategoria("NatacionPrueba 2do cuastimestre 2018", 6540, Inicio, Fin, controladorDeporte.BuscarDeportePorClavesUnicas("NatacionPrueba")) == -1); categorias.Add(controladorCategoria.BuscarCategoriaPorClavesUnicas("FutbolPrueba 2do cuastrimestre 2018")); categorias.Add(controladorCategoria.BuscarCategoriaPorClavesUnicas("NatacionPrueba 2do cuastimestre 2018")); }
public void Test2DeporteControladorBD() { ControladorDeporte controladorDeporte = new ControladorDeporte(); //Aceptado Assert.IsTrue(controladorDeporte.CrearDeporte("FutbolPrueba", "pepeeejd") > 0); Assert.IsTrue(controladorDeporte.CrearDeporte("NatacionPrueba", "") > 0); Deporte deporte_buscado = controladorDeporte.BuscarDeportePorClavesUnicas("FutbolPrueba"); Assert.IsNotNull(deporte_buscado); Assert.IsTrue(controladorDeporte.ListarTodosDeportes().Count > 0); Assert.IsTrue(controladorDeporte.ListarTodosDeportesPorFiltros("ut", "").Count > 0); Assert.IsTrue(controladorDeporte.ModificarDeporte(deporte_buscado.IdDeporte, "FutbolPrueba", "Futbol en Testing") > 0); Assert.IsTrue(controladorDeporte.ListarTodosDeportesPorFiltros("", "Futbol en Test").Count > 0); //Error Assert.AreEqual(controladorDeporte.CrearDeporte("FutbolPrueba", ""), -2); Assert.IsFalse(controladorDeporte.ListarTodosDeportesPorFiltros("z", "").Count > 0); Assert.IsFalse(controladorDeporte.ListarTodosDeportesPorFiltros("", "z").Count > 0); //Eliminación Assert.IsTrue(controladorDeporte.EliminarDeporte(deporte_buscado) > 0); deporte_buscado = controladorDeporte.BuscarDeportePorClavesUnicas("NatacionPrueba"); Assert.IsTrue(controladorDeporte.EliminarDeporte(deporte_buscado) > 0); //Recuperación Assert.IsTrue(controladorDeporte.CrearDeporte("FutbolPrueba", "Recuperando Futbol") == -1); Assert.IsTrue(controladorDeporte.CrearDeporte("NatacionPrueba", "Recuperando Natacion") == -1); deportes.Add(controladorDeporte.BuscarDeportePorClavesUnicas("FutbolPrueba")); deportes.Add(controladorDeporte.BuscarDeportePorClavesUnicas("NatacionPrueba")); }
public InterfazInscribirSocioCategoria(InterfazListaSocio ventana, ModelSocioPersona socio) { Padre = ventana; MiSocio = socio; InitializeComponent(); dtvListarCategorias.AllowUserToAddRows = false; dtvListarCategorias.Visible = false; lblInfoCategoria.Text = ""; ControladorDeporte Cdeporte = new ControladorDeporte(); List <ModelDeporte> lista = new List <ModelDeporte>(); lista = Cdeporte.ListarTodosDeportes(); lista.Insert(0, new ModelDeporte() { IdDeporte = 0, Nombre = "Seleccione un deporte" }); cbxDeporteCategoria.DataSource = lista; cbxDeporteCategoria.ValueMember = "IdDeporte"; cbxDeporteCategoria.DisplayMember = "Nombre"; this.CategoriaBindingSource.DataSource = typeof(ProjectGimnasiaYEsgrima.Modelo.ModelCategoria); CargarCamposFocus(); CargarInterfazBuena(); }
private void button1_Click(object sender, EventArgs e) { ControladorDeporte CDeporte = new ControladorDeporte(); List <ModelDeporte> lista = null; lista = CDeporte.ListarTodos() .AsEnumerable() .OrderBy(b => b.Nombre) .ToList(); ReportDataSource dt = new ReportDataSource("DataSet1", lista); string dir = "ProjectGimnasiaYEsgrima.Utils.ReporteTodosDeporte.rdlc"; new InterfazGenerarReporte(dt, dir).ShowDialog(); }
public InterfazAltaCategoria(InterfazListaCategoria interfazListaCategoria) { this.Padre = interfazListaCategoria; InitializeComponent(); ControladorDeporte Cdeporte = new ControladorDeporte(); List <ModelDeporte> lista = new List <ModelDeporte>(); lista = Cdeporte.ListarTodosDeportes(); cbxDeporte.DataSource = lista; cbxDeporte.ValueMember = "IdDeporte"; cbxDeporte.DisplayMember = "Nombre"; CargarCamposFocus(); CargarInterfazBuena(); }
private void BotonGuardarDeporte_Click(object sender, EventArgs e) { string nombre = txtNombreDeporte.Text; string descripcion = txtDescripcionDeporte.Text; ControladorDeporte un_controlador_deporte = new ControladorDeporte(); var resultado = un_controlador_deporte.ModificarDeporte(deporte.IdDeporte, nombre, descripcion); if (resultado > 0) { Padre.ModificarMensaje("El DEPORTE ha sido modificado con ÉXITO"); Padre.Actualizar(); Dispose(); } else if (resultado == -2) { MyMessageBox.Show(this, "Ya existe el nombre del DEPORTE", "Deporte"); } }
private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (dataGridViewDeporte.Columns[e.ColumnIndex].Name.Equals("Modificar")) { AbrirOtraVentana <InterfazModificarDeporte>(new InterfazModificarDeporte(this, ((ModelDeporte)dataGridViewDeporte.CurrentRow.DataBoundItem).MiDeporte)); Button1_Click(sender, e); } else if (dataGridViewDeporte.Columns[e.ColumnIndex].Name.Equals("Eliminar")) { if (MyMessageBox.Show("¿Está seguro que desea eliminar este Deporte?", "Mensaje", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.OK) { var resultado = new ControladorDeporte().EliminarDeporte(((ModelDeporte)dataGridViewDeporte.CurrentRow.DataBoundItem).MiDeporte); if (resultado > 0) { ModificarMensaje("El DEPORTE ha sido eliminado con ÉXITO"); dataGridViewDeporte.DataSource = new ControladorDeporte().ListarTodosDeportesPorFiltros(txtNombreDeporte.Text.ToString(), txtDescripcionDeporte.Text.ToString()); } } } }
private void BotonGuardarDeporte_Click(object sender, EventArgs e) { var hayError = false; if (txtNombreDeporte.Text.Length < 3) { hayError = true; errorProvider1.SetError(txtNombreDeporte, "El nombre del deporte debe contener entre 3 y 50 caracteres"); } else { errorProvider1.SetError(txtNombreDeporte, ""); } if (hayError) { return; } ControladorDeporte un_controlador_deporte = new ControladorDeporte(); var resultado = un_controlador_deporte.CrearDeporte(txtNombreDeporte.Text, txtDescripcionDeporte.Text); if (resultado > 0) { Padre.ModificarMensaje("El DEPORTE ha sido creado con ÉXITO"); Padre.Actualizar(); Dispose(); } else if (resultado == -1) { Padre.ModificarMensaje("El DEPORTE ha sido recuperado con ÉXITO"); Padre.Actualizar(); Dispose(); } else if (resultado == -2) { MyMessageBox.Show(this, "Ya existe el nombre del DEPORTE", "Deporte"); } }
public InterfazModificarCategoria(InterfazListaCategoria padre, ModelCategoria categoria) { Padre = padre; Categoria = categoria; InitializeComponent(); txtNombreCategoria.Text = Categoria.Nombre; dtpInicioCategoria.Value = Categoria.FechaInicio; dtpFinCategoria.Value = Categoria.FechaFin; txtImporteMensualCategoria.Text = Categoria.MiCategoria.Costo + ""; ControladorDeporte Cdeporte = new ControladorDeporte(); List <ModelDeporte> lista = new List <ModelDeporte>(); lista = Cdeporte.ListarTodosDeportes(); txtDeporteCategoria.Text = Categoria.Deporte.Nombre; txtDeporteCategoria.ReadOnly = true; txtNombreCategoria.ReadOnly = true; CargarCamposFocus(); CargarInterfazBuena(); }
public InterfazCategoriaReporte(InterfazFiltroReporte ventana) { MiVentana = ventana; InitializeComponent(); cbxCancelado.Checked = true; cbxIniciado.Checked = true; cbxPendiente.Checked = true; cbxTerminado.Checked = true; ControladorDeporte CDeporte = new ControladorDeporte(); List <ModelDeporte> lista = new List <ModelDeporte>(); lista = CDeporte.ListarTodosDeportes(); cbxDeporte.DataSource = lista; lista.Insert(0, new ModelDeporte() { IdDeporte = 0, Nombre = "Seleccione un deporte" }); cbxDeporte.ValueMember = "IdDeporte"; cbxDeporte.DisplayMember = "Nombre"; CargarInterfazBuena(); }
private void button2_Click(object sender, EventArgs e) { ControladorDeporte CDeporte = new ControladorDeporte(); List <ModelDeporte> lista = null; if (cbxAlta.Checked && cbxBaja.Checked) { lista = CDeporte.ListarTodos(); } else { lista = CDeporte.ListarTodos() .AsEnumerable() .Where(b => (cbxAlta.Checked ? true : b.EstadoDeporte != EnumEstadoDeporte.Activo)) .Where(b => (cbxBaja.Checked ? true : b.EstadoDeporte != EnumEstadoDeporte.Baja)) .ToList() ; } ReportDataSource dt = new ReportDataSource("DataSet1", lista); string dir = "ProjectGimnasiaYEsgrima.Utils.ReporteTodosDeporte.rdlc"; new InterfazGenerarReporte(dt, dir).ShowDialog(); }