public object ObenerArticuloServicio(string Codigo) { DataTable dt = null; CONSULTAS sql = new CONSULTAS(); CONEXION C = new CONEXION(); string sentencia = sql.OBTENER_ARTICULO_SERVICIO_POR_CODIGO(Codigo); dt = C.EjecutarConsulta(sentencia); var list = dt.AsEnumerable() .Select(x => new { CODIGO = x.Field <string>("CODIGO"), DESCRIPCION = x.Field <string>("DESCRIPCION"), PRECIO_SIN_IVA = x.Field <decimal>("PRECIO_SIN_IVA"), UNIDAD = x.Field <string>("UNIDAD"), P_IVA = (x.Field <bool>("GENERA_IVA") ? IVA : 0), P_ISH = (x.Field <bool>("GENERA_ISH") ? ISH : 0), P_IEPS = x.Field <double>("P_IEPS") }).ToList(); if (list.Count > 0) { return(list[0]); } else { return(null); } }
public IList ObenerArticuloServicio(string Codigo, string Descripcion, int Elementos) { DataTable dt = null; CONSULTAS sql = new CONSULTAS(); CONEXION C = new CONEXION(); string sentencia = string.Empty; if (string.IsNullOrEmpty(Codigo)) { sentencia = sql.OBTENER_ARTICULO_SERVICIO_POR_DESCRIPCION(Descripcion, 5); } else { sentencia = sql.OBTENER_ARTICULO_SERVICIO_POR_CODIGO(Codigo); } dt = C.EjecutarConsulta(sentencia); return(dt.AsEnumerable() .Select(x => new { CODIGO = x.Field <string>("CODIGO"), DESCRIPCION = x.Field <string>("DESCRIPCION"), PRECIO_SIN_IVA = x.Field <decimal>("PRECIO_SIN_IVA"), UNIDAD = x.Field <string>("UNIDAD") }).ToList()); }