Example #1
0
 public IEnumerable <GastoListViewModel> GetGastos(GastoQuery query)
 {
     using (var context = new CCEntities()) {
         var gastosDA = new GastoDataAccess(context);
         return(gastosDA.GetGastos(query));
     }
 }
Example #2
0
        public IEnumerable <GastoListViewModel> GetGastos(GastoQuery query)
        {
            var desde       = new SqlParameter("@fechaDesde", query.FechaDesde ?? SqlDateTime.Null);
            var hasta       = new SqlParameter("@fechaHasta", query.FechaHasta ?? SqlDateTime.Null);
            var idCategoria = new SqlParameter("@idCategoria", query.IdCategoria ?? SqlInt32.Null);
            var idMedio     = new SqlParameter("@idMedio", query.IdMedio ?? SqlInt32.Null);

            var result = context.Database.SqlQuery <GastoListViewModel>("exec dbo.[GetGastos] @fechaDesde, @fechaHasta, @idCategoria, @idMedio", desde, hasta, idCategoria, idMedio);

            return(result.ToList());
        }
Example #3
0
        private void Buscar()
        {
            var query = new GastoQuery();

            if (checkBoxDesde.Checked)
            {
                query.FechaDesde = dtDesde.Value;
            }
            else
            {
                query.FechaDesde = null;
            }

            if (checkBoxHasta.Checked)
            {
                query.FechaHasta = dtHasta.Value;
            }
            else
            {
                query.FechaHasta = null;
            }

            if (checkBoxCategoria.Checked)
            {
                query.IdCategoria = (int)cbCategoria.SelectedValue;
            }
            else
            {
                query.IdCategoria = null;
            }

            if (checkBoxMedio.Checked)
            {
                query.IdMedio = (int)cbMedio.SelectedValue;
            }
            else
            {
                query.IdMedio = null;
            }

            dgGastos.DataSource = gastoBusiness.GetGastos(query);
        }