/// <summary> /// Buscamos la líneas de detalle de una factura /// </summary> /// <param name="id">Id de la Factura</param> /// <returns></returns> //public JsonResult GetDetails(int id) //{ // //db.Configuration.ProxyCreationEnabled = false; // //var _detalle = db.Detalles.Where(x => x.FacturaId == id).ToList(); // var _factura = db.Facturas.FirstOrDefault(x => x.FacturaId == id); // if (_factura == null) // return Json(new { Error = true, Msg = "Factura no encontrada." }); // var result = new // { // detalle = (from deta in _factura.Detalles // select new // { // _D_DetalleId = deta.DetalleId, // _D_Articulo = deta.Articulo, // _D_ArticuloAlternativo = deta.ArticuloAlternativo, // _D_Orden = deta.Orden, // _D_Cantidad = deta.Cantidad, // _D_PrecioUnitario = deta.PrecioUnitario, // _D_PorcentajeIva = deta.PorcentajeIva, // _D_Importe = deta.Importe, // _D_TextoIva = deta.TextoIva, // _D_TotalIva = deta.TotalIVA, // } // ), // factura = new // { // _F_NumeroFactura = _factura.NumeroFactura, // _F_Orden = _factura.Orden, // _F_FechaFactura = _factura.FechaFactura.ToShortDateString(), // _F_Tipo = _factura.Tipo, // _F_idSobreFactura = _factura.IdSobreFactura, // _F_SobreFactura = _factura.SobreFactura, // _F_RotuloGerencia = _factura.RotuloGerencia, // _F_PorcentajeBonificacion = _factura.PorcentajeBonificacion.ToString(), // _F_PorcentajeRetencion = _factura.PorcentajeRetencion.ToString(), // _F_Subtotal = _factura.Subtotal.ToString(), // _F_Bonificacion = _factura.Bonificacion.ToString(), // _F_BaseImponible = _factura.BaseImponible.ToString(), // _F_Retencion = _factura.Retencion.ToString(), // _F_TotalAOrigen = _factura.TotalAOrigen.ToString(), // _F_CertificacionesAnteriores = _factura.CertificacionesAnteriores.ToString(), // _F_Facturardo = _factura.Facturado.ToString(), // _F_TipoFacturacion = _factura.TipoFacturacion, // _F_Cerrada = _factura.Cerrada.ToString(), // _F_FacturaEspecial = _factura.FacturaEspecial.ToString(), // _F_FacturaUnica = _factura.FacturaUnica.ToString(), // _F_Contabilizado = _factura.Contabilizado.ToString(), // _F_TieneTotalPropio = _factura.TieneTotalPropio.ToString(), // _F_TextoFactura = _factura.TextoFactura, // _F_Total = _factura.Total // } // }; // return Json(result, JsonRequestBehavior.AllowGet); //} public JsonResult GetDetails(int id, jqGridViewModel jqgrid) { IEnumerable <Detalle> _detalle = db.Detalles.Where(x => x.FacturaId == id).ToList(); if (_detalle == null) { return(Json(new { Error = true, Msg = "Detalle no encontrado." })); } if (jqgrid._search) { _detalle = _detalle.AsQueryable <Detalle>().Where <Detalle>(jqgrid.searchField, jqgrid.searchString, ( WhereOperation )StringEnum.Parse(typeof(WhereOperation), jqgrid.searchOper)).ToList(); } try { var count = _detalle.Count(); int pageIndex = jqgrid.page; int pageSize = jqgrid.rows; int startRow = (pageIndex * pageSize) + 1; int totalRecords = count; int totalPages = ( int )Math.Ceiling(( float )totalRecords / ( float )pageSize); _detalle = _detalle.AsQueryable().OrderBy(jqgrid.sidx, jqgrid.sord).ToList(); var data = _detalle.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToArray(); var result = new { total = totalPages, page = pageIndex, records = count, rows = ( from detalle in data select new { id = detalle.DetalleId.ToString(), cell = new string[] { detalle.DetalleId.ToString(), detalle.Orden.ToString(), detalle.Articulo, detalle.Cantidad.ToString().Replace(',', '.'), detalle.PrecioUnitario.ToString().Replace(',', '.'), detalle.Importe.ToString().Replace(',', '.'), detalle.ArticuloAlternativo, detalle.PorcentajeIva.ToString().Replace(',', '.'), detalle.TextoIva, detalle.TotalIVA.ToString().Replace(',', '.'), } }).ToArray() }; return(Json(result, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { Error = true, Msg = ex.Message })); } }
public JsonResult GetAll(jqGridViewModel jqgrid) { //IQueryable<Cliente> _cliente = db.Clientes.Include("Provincia");//.AsQueryable(); IEnumerable <Delegacion> _delegaciones = db.Delegaciones.ToList(); //return Json(new { Error = 1, Msg = "Esto es un error" }, JsonRequestBehavior.AllowGet); //return Json(new Exception("Esto es un error como un pino")); // Si estamos usando filtros //filtring if (jqgrid._search) { _delegaciones = _delegaciones.AsQueryable <Delegacion>().Where <Delegacion>(jqgrid.searchField, jqgrid.searchString, ( WhereOperation )StringEnum.Parse(typeof(WhereOperation), jqgrid.searchOper)).ToList(); } try { var count = _delegaciones.Count(); int pageIndex = jqgrid.page; int pageSize = jqgrid.rows; int startRow = (pageIndex * pageSize) + 1; int totalRecords = count; int totalPages = ( int )Math.Ceiling(( float )totalRecords / ( float )pageSize); _delegaciones = _delegaciones.AsQueryable().OrderBy(jqgrid.sidx, jqgrid.sord).ToList(); var data = _delegaciones.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToArray(); var result = new { total = totalPages, page = jqgrid.page, records = count, rows = ( //from ivaSort in ivasSort from fp in data select new { id = fp.DelegacionId.ToString(), cell = new string[] { fp.DelegacionId.ToString(), fp.NombreDelegacion, fp.Abreviatura, fp.Mostrar.ToString(), fp.FechaAlta.ToString(), } }).ToArray() }; return(Json(result, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { Error = true, Msg = ex.Message })); } }
public JsonResult GetAll(jqGridViewModel jqgrid) { IEnumerable <Banco> _bancos = db.Bancos.ToList(); if (jqgrid._search) { _bancos = _bancos.AsQueryable <Banco>().Where <Banco>(jqgrid.searchField, jqgrid.searchString, ( WhereOperation )StringEnum.Parse(typeof(WhereOperation), jqgrid.searchOper)).ToList(); } try { var count = _bancos.Count(); int pageIndex = jqgrid.page; int pageSize = jqgrid.rows; int startRow = (pageIndex * pageSize) + 1; int totalRecords = count; int totalPages = ( int )Math.Ceiling(( float )totalRecords / ( float )pageSize); _bancos = _bancos.AsQueryable().OrderBy(jqgrid.sidx, jqgrid.sord).ToList(); var data = _bancos.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToArray(); var result = new { total = totalPages, page = jqgrid.page, records = count, rows = ( from banco in data select new { id = banco.BancoId.ToString(), cell = new string[] { banco.BancoId.ToString(), banco.Codigo, banco.Nombre, banco.Direccion, banco.Mostrar.ToString(), banco.FechaAlta.ToString() } }).ToArray() }; return(Json(result, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { Error = true, Msg = ex.Message })); } }
public JsonResult GetAll(jqGridViewModel jqgrid) { //var actividades = db.Actividades.ToList(); IEnumerable <Actividad> _actividades = db.Actividades.ToList(); if (jqgrid._search) { _actividades = _actividades.AsQueryable <Actividad>().Where <Actividad>(jqgrid.searchField, jqgrid.searchString, ( WhereOperation )StringEnum.Parse(typeof(WhereOperation), jqgrid.searchOper)).ToList(); } try { var count = _actividades.Count(); int pageIndex = jqgrid.page; int pageSize = jqgrid.rows; int startRow = (pageIndex * pageSize) + 1; int totalRecords = count; int totalPages = ( int )Math.Ceiling(( float )totalRecords / ( float )pageSize); _actividades = _actividades.AsQueryable().OrderBy(jqgrid.sidx, jqgrid.sord).ToList(); var data = _actividades.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToArray(); var result = new { total = totalPages, page = pageIndex, records = count, rows = ( from actividad in data select new { id = actividad.ActividadID.ToString(), cell = new string[] { actividad.ActividadID.ToString(), actividad.Nombre, actividad.Abreviatura, actividad.Mostrar.ToString() } }).ToArray() }; return(Json(result, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { Error = true, Msg = ex.Message })); } }
public JsonResult GetByCliente(int id, jqGridViewModel jqgrid) { IEnumerable <Obra> _obras = db.Obras.Where(x => x.ClienteId == id).ToList(); if (jqgrid._search) { _obras = _obras.AsQueryable <Obra>().Where <Obra>(jqgrid.searchField, jqgrid.searchString, (WhereOperation)StringEnum.Parse(typeof(WhereOperation), jqgrid.searchOper)).ToList(); } try { var count = _obras.Count(); int pageIndex = jqgrid.page; int pageSize = jqgrid.rows; int startRow = (pageIndex * pageSize) + 1; int totalRecords = count; int totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize); _obras = _obras.AsQueryable().OrderBy(jqgrid.sidx, jqgrid.sord).ToList(); var data = _obras.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToArray(); var result = new { total = totalPages, page = pageIndex, records = count, rows = ( from obra in data select new { id = obra.ObraId.ToString(), cell = new string[] { obra.ObraId.ToString(), obra.Nombre, obra.Acabada.ToString() } }).ToArray() }; return(Json(result, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { Error = true, Msg = ex.Message })); } }
/// <summary> /// Coge las facturas de una obra /// </summary> /// <param name="id">id de la obra</param> /// <param name="jqgrid">parámetros del grid</param> /// <returns></returns> public JsonResult GetFacturasDeObra(int id, jqGridViewModel jqgrid) { IEnumerable <Factura> _facturas = db.Facturas.Where(x => x.ObraId == id).ToList(); if (jqgrid._search) { _facturas = _facturas.AsQueryable <Factura>().Where <Factura>(jqgrid.searchField, jqgrid.searchString, ( WhereOperation )StringEnum.Parse(typeof(WhereOperation), jqgrid.searchOper)).ToList(); } try { var count = _facturas.Count(); int pageIndex = jqgrid.page; int pageSize = jqgrid.rows; int startRow = (pageIndex * pageSize) + 1; int totalRecords = count; int totalPages = ( int )Math.Ceiling(( float )totalRecords / ( float )pageSize); _facturas = _facturas.AsQueryable().OrderBy(jqgrid.sidx, jqgrid.sord).ToList(); var data = _facturas.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToArray(); var result = new { total = totalPages, page = pageIndex, records = count, rows = ( from factura in data select new { id = factura.FacturaId.ToString(), cell = new string[] { factura.FacturaId.ToString(), factura.Orden.ToString(), factura.NumeroFactura.ToString(), factura.FechaFactura.ToShortDateString(), factura.BaseImponible.ToString().Replace(',', '.'), factura.Tipo, factura.ObraId.ToString(), factura.RotuloGerencia, factura.PorcentajeBonificacion.ToString().Replace(',', '.'), factura.PorcentajeRetencion.ToString().Replace(',', '.'), factura.Subtotal.ToString().Replace(',', '.'), factura.Bonificacion.ToString().Replace(',', '.'), factura.Retencion.ToString().Replace(',', '.'), factura.Total.ToString().Replace(',', '.'), factura.TotalAOrigen.ToString().Replace(',', '.'), factura.CertificacionesAnteriores.ToString().Replace(',', '.'), factura.Cerrada.ToString(), factura.FacturaEspecial.ToString(), factura.Contabilizado.ToString(), factura.TieneTotalPropio.ToString(), factura.Detalles.Sum(x => x.TotalIVA).ToString().Replace(',', '.') } }).ToArray() }; return(Json(result, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { Error = true, Msg = ex.Message })); } }
public JsonResult GetAll(jqGridViewModel jqgrid) { IEnumerable <Obra> _obras = db.Obras.ToList(); // Si no quiero ver las obras terminadas //if (verObra.VerObrasTerminadas == false) // _obras = _obras.Where(x => x.Acabada == false); if (jqgrid._search) { _obras = _obras.AsQueryable <Obra>().Where <Obra>(jqgrid.searchField, jqgrid.searchString, (WhereOperation)StringEnum.Parse(typeof(WhereOperation), jqgrid.searchOper)).ToList(); } try { var count = _obras.Count(); int pageIndex = jqgrid.page; int pageSize = jqgrid.rows; int startRow = (pageIndex * pageSize) + 1; int totalRecords = count; int totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize); _obras = _obras.AsQueryable().OrderBy(jqgrid.sidx, jqgrid.sord).ToList(); var data = _obras.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToArray(); var result = new { total = totalPages, page = pageIndex, records = count, rows = ( from obra in data select new { id = obra.ObraId.ToString(), cell = new string[] { obra.ObraId.ToString(), obra.Nombre, obra.NombreAmpliado, obra.Direccion, obra.Localidad, obra.CP, obra.Provincia, obra.Telefono, obra.Movil, obra.Fax, obra.Tecnico, obra.Observaciones, obra.Mostrar.ToString(), obra.CertificacionesAnteriores.ToString(), obra.ContarAbonos.ToString(), obra.Acabada.ToString(), obra.ACodigoObra.ToString(), obra.Actividad.Nombre, //obra.ActividadId.ToString(), obra.SubActividad.Subactividad, obra.Delegacion.NombreDelegacion, obra.Cliente.NombreCliente, obra.FechaAlta.ToShortDateString(), } }).ToArray() }; return(Json(result, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { Error = true, Msg = ex.Message })); } }
public JsonResult GetAll(jqGridViewModel jqgrid) { IQueryable <FormaPago> _formapago = db.FormasPago; //.AsQueryable(); //return Json(new { Error = 1, Msg = "Esto es un error" }, JsonRequestBehavior.AllowGet); //return Json(new Exception("Esto es un error como un pino")); // Si estamos usando filtros //filtring if (jqgrid._search) { //And if (jqgrid.filters.groupOP == "AND") { foreach (var rule in jqgrid.filters.rules) { _formapago = _formapago.Where <FormaPago>(rule.field, rule.data, ( WhereOperation )StringEnum.Parse(typeof(WhereOperation), rule.op)); } } else { //Or var temp = (new List <FormaPago>()).AsQueryable(); foreach (var rule in jqgrid.filters.rules) { var t = _formapago.Where <FormaPago>(rule.field, rule.data, ( WhereOperation )StringEnum.Parse(typeof(WhereOperation), rule.op)); temp = temp.Concat <FormaPago>(t); } //remove repeating records _formapago = temp.Distinct <FormaPago>(); } } try { var count = _formapago.Count(); int pageIndex = jqgrid.page; int pageSize = jqgrid.rows; int startRow = (pageIndex * pageSize) + 1; int totalRecords = count; int totalPages = ( int )Math.Ceiling(( float )totalRecords / ( float )pageSize); //IEnumerable<Iva> ivasSort = null; _formapago = _formapago.OrderBy <FormaPago>(jqgrid.sidx, jqgrid.sord); //if (!string.IsNullOrWhiteSpace(jqgrid.sidx)) // ivasSort = jqgrid.sord == "asc" ? ivas.OrderBy(x => x.GetType().GetProperty(jqgrid.sidx).GetValue(x)) : ivas.OrderByDescending(x => x.GetType().GetProperty(jqgrid.sidx).GetValue(x)); //else // ivasSort = ivas.OrderBy(x => x.IvaId); //ivasSort = ivasSort.Skip((pageIndex - 1) * pageSize).Take(pageSize); var data = _formapago.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToArray(); var result = new { total = totalPages, page = jqgrid.page, records = count, rows = ( //from ivaSort in ivasSort from fp in data select new { id = fp.FormaPagoId.ToString(), cell = new string[] { fp.FormaPagoId.ToString(), fp.Descripcion, fp.TextoLargo, fp.Vcto1.ToString(), fp.Vcto2.ToString(), fp.Vcto3.ToString(), fp.Vcto4.ToString(), fp.Vcto5.ToString(), fp.Vcto6.ToString(), fp.Mostrar.ToString(), fp.FechaAlta.ToString() } }).ToArray() }; return(Json(result, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { throw ex; } }
public JsonResult GetAll(jqGridViewModel jqgrid) { //IQueryable<Cliente> _cliente = db.Clientes.Include("Provincia");//.AsQueryable(); IEnumerable <DireccionEntrega> _direccionies = db.DireccionesEntrega.ToList(); //return Json(new { Error = 1, Msg = "Esto es un error" }, JsonRequestBehavior.AllowGet); //return Json(new Exception("Esto es un error como un pino")); // Si estamos usando filtros //filtring if (jqgrid._search) { _direccionies = _direccionies.AsQueryable <DireccionEntrega>().Where <DireccionEntrega>(jqgrid.searchField, jqgrid.searchString, ( WhereOperation )StringEnum.Parse(typeof(WhereOperation), jqgrid.searchOper)).ToList(); //if (jqgrid.filters.groupOP == "AND") //{ // foreach (var rule in jqgrid.filters.rules) // //_cliente = _cliente.AsQueryable().Where<Cliente>(rule.field, rule.data, ( WhereOperation )StringEnum.Parse(typeof(WhereOperation), rule.op)); // _cliente = _cliente.AsQueryable<Cliente>().Where<Cliente>(rule.field, rule.data, ( WhereOperation )StringEnum.Parse(typeof(WhereOperation), rule.op)).ToList(); //} //else //{ // //Or // var temp = (new List<Cliente>()).AsQueryable(); // //IEnumerable<Cliente> temp = null; // foreach (var rule in jqgrid.filters.rules) // { // var t = _cliente.AsQueryable<Cliente>().Where<Cliente>(rule.field, rule.data, ( WhereOperation )StringEnum.Parse(typeof(WhereOperation), rule.op)).ToList(); // temp = temp.Concat<Cliente>(t); // } // //remove repeating records // _cliente = temp.Distinct<Cliente>(); //} } try { var count = _direccionies.Count(); int pageIndex = jqgrid.page; int pageSize = jqgrid.rows; int startRow = (pageIndex * pageSize) + 1; int totalRecords = count; int totalPages = ( int )Math.Ceiling(( float )totalRecords / ( float )pageSize); //IEnumerable<Iva> ivasSort = null; //_cliente = _cliente.OrderBy<Cliente>(jqgrid.sidx, jqgrid.sord); _direccionies = _direccionies.AsQueryable().OrderBy(jqgrid.sidx, jqgrid.sord).ToList(); //if (!string.IsNullOrWhiteSpace(jqgrid.sidx)) // _cliente = jqgrid.sord == "asc" ? _cliente.OrderBy(x => x.GetType().GetProperty(jqgrid.sidx).GetValue(x)) : _cliente.OrderByDescending(x => x.GetType().GetProperty(jqgrid.sidx).GetValue(x)); //else // _cliente = _cliente.OrderBy(x => x.ClienteId); //ivasSort = ivasSort.Skip((pageIndex - 1) * pageSize).Take(pageSize); var data = _direccionies.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToArray(); var result = new { total = totalPages, page = jqgrid.page, records = count, rows = ( //from ivaSort in ivasSort from fp in data select new { id = fp.DireccionEntregaId.ToString(), cell = new string[] { fp.DireccionEntregaId.ToString(), fp.Direccion, fp.Localidad, fp.CP, fp.ProvinciaId.ToString(), fp.CIF, fp.PersonaContacto, fp.Cliente == null ? string.Empty : fp.Cliente.NombreCliente, fp.Mostrar.ToString(), fp.FechaAlta.ToString() } }).ToArray() }; return(Json(result, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { throw ex; } }
public JsonResult GetAll(jqGridViewModel jqgrid) { IQueryable <Articulo> articulos = db.Articulos.Include("Iva"); //.AsQueryable(); //return Json(new { Error = 1, Msg = "Esto es un error" }, JsonRequestBehavior.AllowGet); //return Json(new Exception("Esto es un error como un pino")); // Si estamos usando filtros //filtring if (jqgrid._search) { //StringBuilder sb = new StringBuilder(); //string rtRule = string.Empty; //string rtWhere = string.Empty; //JavaScriptSerializer serializer = new JavaScriptSerializer(); ////Filters filters = serializer.Deserialize<Filters>(jqgrid.filter); //Filters filters = serializer.Deserialize<Filters>(Request.QueryString["filters"]); //foreach (Rules regla in filters.rules) //{ // rtRule = LinqDynamicConditionHelper.GetCondition<Iva>(regla); // if (rtRule.Length > 0) // { // sb.Append(rtRule); // sb.Append(filters.groupOP.ToLower() == "and" ? " && " : " || "); // } //} //ivas.Where<T>(sb.ToString(), 1); //And if (jqgrid.filters.groupOP == "AND") { foreach (var rule in jqgrid.filters.rules) { articulos = articulos.Where <Articulo>(rule.field, rule.data, ( WhereOperation )StringEnum.Parse(typeof(WhereOperation), rule.op)); } } else { //Or var temp = (new List <Articulo>()).AsQueryable(); foreach (var rule in jqgrid.filters.rules) { var t = articulos.Where <Articulo>(rule.field, rule.data, ( WhereOperation )StringEnum.Parse(typeof(WhereOperation), rule.op)); temp = temp.Concat <Articulo>(t); } //remove repeating records articulos = temp.Distinct <Articulo>(); } } try { var count = articulos.Count(); int pageIndex = jqgrid.page; int pageSize = jqgrid.rows; int startRow = (pageIndex * pageSize) + 1; int totalRecords = count; int totalPages = ( int )Math.Ceiling(( float )totalRecords / ( float )pageSize); //IEnumerable<Iva> ivasSort = null; articulos = articulos.OrderBy <Articulo>(jqgrid.sidx, jqgrid.sord); //if (!string.IsNullOrWhiteSpace(jqgrid.sidx)) // ivasSort = jqgrid.sord == "asc" ? ivas.OrderBy(x => x.GetType().GetProperty(jqgrid.sidx).GetValue(x)) : ivas.OrderByDescending(x => x.GetType().GetProperty(jqgrid.sidx).GetValue(x)); //else // ivasSort = ivas.OrderBy(x => x.IvaId); //ivasSort = ivasSort.Skip((pageIndex - 1) * pageSize).Take(pageSize); var data = articulos.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToArray(); var result = new { total = totalPages, page = jqgrid.page, records = count, rows = ( //from ivaSort in ivasSort from articulo in data select new { id = articulo.ArticuloId.ToString(), cell = new string[] { articulo.ArticuloId.ToString(), articulo.Descripcion, articulo.Precio.ToString(), articulo.PrecioCompra.ToString(), articulo.PrecioVenta.ToString(), articulo.Iva.Texto, //articulo.Iva.IvaId.ToString(), articulo.CodigoContable, articulo.Ver.ToString() } }).ToArray() }; return(Json(result, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { throw ex; } }
public JsonResult GetAll(jqGridViewModel jqgrid) { IEnumerable <Iva> _ivas = db.Ivas.ToList(); //.AsQueryable(); if (jqgrid._search) { _ivas = _ivas.AsQueryable <Iva>().Where <Iva>(jqgrid.searchField, jqgrid.searchString, ( WhereOperation )StringEnum.Parse(typeof(WhereOperation), jqgrid.searchOper)).ToList(); //And //if (jqgrid.filters.groupOP == "AND") // foreach (var rule in jqgrid.filters.rules) // ivas = ivas.Where<Iva>(rule.field, rule.data, ( WhereOperation )StringEnum.Parse(typeof(WhereOperation), rule.op)); //else //{ // //Or // var temp = (new List<Iva>()).AsQueryable(); // foreach (var rule in jqgrid.filters.rules) // { // var t = ivas.Where<Iva>(rule.field, rule.data, ( WhereOperation )StringEnum.Parse(typeof(WhereOperation), rule.op)); // temp = temp.Concat<Iva>(t); // } // //remove repeating records // ivas = temp.Distinct<Iva>(); //} } try { var count = _ivas.Count(); int pageIndex = jqgrid.page; int pageSize = jqgrid.rows; int startRow = (pageIndex * pageSize) + 1; int totalRecords = count; int totalPages = ( int )Math.Ceiling(( float )totalRecords / ( float )pageSize); _ivas = _ivas.AsQueryable().OrderBy(jqgrid.sidx, jqgrid.sord).ToList(); var data = _ivas.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToArray(); var result = new { total = totalPages, page = jqgrid.page, records = count, rows = ( //from ivaSort in ivasSort from iva in data select new { id = iva.IvaId.ToString(), cell = new string[] { iva.IvaId.ToString(), iva.Texto, iva.Porcentaje.ToString(), iva.CuentaContable, iva.Defecto.ToString(), iva.Mostrar.ToString() } }).ToArray() }; return(Json(result, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { Error = true, Msg = ex.Message })); } }