Esempio n. 1
0
        private void LblBuscar_Click(object sender, EventArgs e)
        {
            try
            {
                #region Validaciones

                var filtrosSeteados = false;
                var mensajeDeExcepcion = string.Empty;

                if (!ValidadorDeTipos.IsEmpty(TxtMatricula.Text))
                    filtrosSeteados = true;

                if (!ValidadorDeTipos.IsEmpty(TxtFabricante.Text))
                    filtrosSeteados = true;

                if (!ValidadorDeTipos.IsEmpty(TxtModelo.Text))
                    filtrosSeteados = true;

                if (!ValidadorDeTipos.IsEmpty(CboServicio.Text))
                    filtrosSeteados = true;

                if (chkFecha.Checked && !ValidadorDeTipos.IsEmpty(dtpAlta.Text))
                    filtrosSeteados = true;

                if (!filtrosSeteados)
                    mensajeDeExcepcion = "No se puede realizar la búsqueda. Verifique que haya ingresado algún filtro y que los mismos sean válidos.";

                if (!ValidadorDeTipos.IsEmpty(mensajeDeExcepcion))
                    throw new Exception(mensajeDeExcepcion);

                #endregion

                 #region Cargar filtros
                var filtros = new AeronaveFiltros
                {
                    Matricula = (!ValidadorDeTipos.IsEmpty(TxtMatricula.Text)) ? TxtMatricula.Text : null,
                    Fabricante = (!ValidadorDeTipos.IsEmpty(TxtFabricante.Text)) ? TxtFabricante.Text : null,
                    Modelo = (!ValidadorDeTipos.IsEmpty(TxtModelo.Text)) ? TxtModelo.Text : null,
                    Servicio = (!ValidadorDeTipos.IsEmpty(CboServicio.Text)) ? CboServicio.Text : null,
                    Fecha_Alta = (chkFecha.Checked==true) ? dtpAlta.Value.Date : DateTime.MinValue
                };

                 #endregion

                var aeronaves = (ChkBusquedaExacta.Checked) ? AeronavePersistencia.ObtenerTodasPorParametros(filtros) : AeronavePersistencia.ObtenerTodasPorParametrosComo(filtros);

                if (aeronaves == null || aeronaves.Count == 0)
                {
                    ActualizarPantalla(null);
                    LimpiarFiltros();
                    throw new Exception("No se encontraron aeronaves según los filtros informados.");
                }

                //Refrescar la grilla, cargando las aeronaves que se obtuvieron como resultado de los filtros
                CboServicio.Text = string.Empty;
                ActualizarPantalla(aeronaves);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Atención");
            }
        }
Esempio n. 2
0
        public static List<Aeronave> ObtenerTodasPorParametrosComo(AeronaveFiltros filtros)
        {
            var param = new List<SPParameter> { new SPParameter("Matricula", filtros.Matricula ?? (object)DBNull.Value),
                                                new SPParameter("Fabricante", filtros.Fabricante ?? (object)DBNull.Value),
                                                new SPParameter("Modelo", filtros.Modelo ?? (object)DBNull.Value),
                                                new SPParameter("Nombre_Servicio", filtros.Servicio ?? (object)DBNull.Value),
                                                new SPParameter("Fecha_Alta", (filtros.Fecha_Alta == DateTime.MinValue) ?  DateTime.Parse("01/01/1990") : filtros.Fecha_Alta)
                                              };

            var sp = new StoreProcedure(DBQueries.Aeronave.SPGetAeronavesPorParametrosComo, param);

            return sp.ExecuteReader<Aeronave>();
        }