public static List <HistoryOferta> GetAllOfertasByUsuarioByParametersLike(Usuario user, HistoryOfertaFilters filter)
        {
            var param = new List <SPParameter> {
                new SPParameter("idUsuario", user.ID),
                new SPParameter("Fecha_hoy", ConfigurationVariables.FechaSistema),
                new SPParameter("ID_Oferta", filter.Codigo ?? (object)DBNull.Value),
                new SPParameter("Monto", filter.Monto ?? (object)DBNull.Value),
                new SPParameter("Fecha", filter.Fecha ?? (object)DBNull.Value),
                new SPParameter("Descripcion", filter.Descripcion ?? (object)DBNull.Value),
                new SPParameter("Ganada", filter.Ganada ?? (object)DBNull.Value)
            };
            var sp = new StoreProcedure(DataBaseConst.Oferta.SPGetHistoryOfertasByUsuarioByParametersLike, param);

            return(sp.ExecuteReader <HistoryOferta>());
        }
Beispiel #2
0
        private void LblBuscar_Click(object sender, EventArgs e)
        {
            try
            {
                #region Validations

                var filtersSetted    = false;
                var exceptionMessage = string.Empty;

                if (!TypesHelper.IsEmpty(txtCodigo.Text))
                {
                    filtersSetted = true;
                    if (!TypesHelper.IsNumeric(txtCodigo.Text))
                    {
                        exceptionMessage += Environment.NewLine + "El código debe ser numérico.";
                    }
                }
                if (!TypesHelper.IsEmpty(txtDesc.Text))
                {
                    filtersSetted = true;
                }

                if (!TypesHelper.IsEmpty(txtMonto.Text))
                {
                    filtersSetted = true;
                    if (!TypesHelper.IsDecimal(txtMonto.Text))
                    {
                        exceptionMessage += Environment.NewLine + "El precio de la publicacion ser decimal (o numérico).";
                    }
                }

                if (!TypesHelper.IsEmpty(txtFecha.Text))
                {
                    filtersSetted = true;
                }

                if (!TypesHelper.IsEmpty(txtGanada.Text))
                {
                    filtersSetted = true;
                }


                if (!filtersSetted)
                {
                    exceptionMessage = "No se puede realizar la busqueda ya que no se informó ningún filtro";
                }

                if (!TypesHelper.IsEmpty(exceptionMessage))
                {
                    throw new Exception(exceptionMessage);
                }

                #endregion

                var filters = new HistoryOfertaFilters
                {
                    Codigo      = (!TypesHelper.IsEmpty(txtCodigo.Text)) ? Convert.ToInt32(txtCodigo.Text) : (int?)null,
                    Descripcion = (!TypesHelper.IsEmpty(txtDesc.Text)) ? txtDesc.Text : null,
                    Monto       = (!TypesHelper.IsEmpty(txtMonto.Text)) ? Convert.ToDouble(txtMonto.Text) : (double?)null,
                    Fecha       = (!TypesHelper.IsEmpty(txtFecha.Text)) ? txtFecha.Text : null,
                    Ganada      = (!TypesHelper.IsEmpty(txtGanada.Text)) ? txtGanada.Text : null
                };

                var historyCompras = (cBExact.Checked) ? OfertaPersistance.GetAllOfertasByUsuarioByParameters(SessionManager.CurrentUser, filters) : OfertaPersistance.GetAllOfertasByUsuarioByParametersLike(SessionManager.CurrentUser, filters);

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

                RefreshSources(historyCompras);
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Atención");
                ClearFiltersAndTable();
            }
        }