public static List <Estadistica> GetSellersWithBetterQualifications(EstadisticaFilters filters) { var param = new List <SPParameter> { new SPParameter("Fecha_Desde", filters.FechaDesde), new SPParameter("Fecha_Hasta", filters.FechaHasta) }; var sp = new StoreProcedure(DataBaseConst.Estadistica.SPGetSellersWithBetterQualifications, param); var statistics = sp.ExecuteReader <Estadistica>(); if (statistics == null || statistics.Count == 0) { return(null); } return(statistics); }
public static List <Estadistica> GetSellersWithMoreProductsNotSold(EstadisticaFilters filters) { var param = new List <SPParameter> { new SPParameter("Fecha_Desde", filters.FechaDesde), new SPParameter("Fecha_Hasta", filters.FechaHasta), new SPParameter("Visibilidad", filters.Visibilidad ?? (object)DBNull.Value) }; var sp = new StoreProcedure(DataBaseConst.Estadistica.SPGetSellersWithMoreProductsNotSold, param); var statistics = sp.ExecuteReader <Estadistica>(); if (statistics == null || statistics.Count == 0) { return(null); } return(statistics); }
private void LblFiltrar_Click(object sender, EventArgs e) { try { #region Validaciones var filtersSetted = false; var exceptionMessage = string.Empty; if (!TypesHelper.IsEmpty(CboAño.Text)) { filtersSetted = true; } if (!TypesHelper.IsEmpty(CboTrimestre.Text)) { filtersSetted = true; } if (!TypesHelper.IsEmpty(CboListado.Text)) { filtersSetted = true; } if ((int)CboListado.SelectedValue == 1 && !TypesHelper.IsEmpty(CboVisibilidad.Text)) { filtersSetted = true; } if (!filtersSetted) { exceptionMessage = "No se puede obtener el listado estadístico. Verifique que haya ingresado los filtros correctamente."; } if (!TypesHelper.IsEmpty(exceptionMessage)) { throw new Exception(exceptionMessage); } #endregion var monthDesde = ""; var dayHasta = ""; var monthHasta = ""; //Si es la primera estadística, puede que esté filtrada por mes, si está en 00, filtro por trimestre if ((string)cboMes.SelectedValue == "00" || (int)CboListado.SelectedValue != 1) { switch ((int)CboTrimestre.SelectedValue) { case 1: monthDesde = "01"; monthHasta = "03"; break; case 2: monthDesde = "04"; monthHasta = "06"; break; case 3: monthDesde = "07"; monthHasta = "09"; break; case 4: monthDesde = "10"; monthHasta = "12"; break; } } else { monthDesde = monthHasta = (string)cboMes.SelectedValue; } switch (monthHasta) { case "01": case "03": case "05": case "07": case "08": case "10": case "12": dayHasta = "31"; break; case "04": case "06": case "09": case "11": dayHasta = "30"; break; case "02": dayHasta = "28"; break; } var fechaDesde = DateTime.Parse("01/" + monthDesde + "/" + CboAño.SelectedValue.ToString()); var fechaHasta = DateTime.Parse(dayHasta + "/" + monthHasta + "/" + CboAño.SelectedValue.ToString()); //Creo los filtros con los que se ejecuta la consulta. var filters = new EstadisticaFilters { FechaDesde = fechaDesde, FechaHasta = fechaHasta, Visibilidad = (!TypesHelper.IsEmpty(CboVisibilidad.Text) && (int)CboVisibilidad.SelectedValue != 0) ? (int)CboVisibilidad.SelectedValue : (int?)null }; var listado = new List <Estadistica>(); switch ((int)CboListado.SelectedValue) { case 1: listado = EstadisticaPersistance.GetSellersWithMoreProductsNotSold(filters); break; case 2: listado = EstadisticaPersistance.GetSellersWithMoreBilling(filters); break; case 3: listado = EstadisticaPersistance.GetSellersWithBetterQualifications(filters); break; case 4: listado = EstadisticaPersistance.GetClientsWithMoreNotQualifiedPublications(filters); break; } if (listado == null || listado.Count == 0) { throw new Exception("No se encontraron estadísticas según los filtros informados."); } LoadGrid(listado); } catch (Exception ex) { MessageBox.Show(ex.Message, "Atención"); ClearDataGridView(); } }