/// <summary>
        /// Lista de Medio Pago
        /// </summary>
        /// <returns>Colección de Medio Pago</returns>
        public CmpObservableCollection <ESGR_MedioPago> GetCollectionMedioPago()
        {
            try
            {
                var objCmpSql           = new CmpSql(SGRVariables.ConectionString);
                var CollectionMedioPago = new CmpObservableCollection <ESGR_MedioPago>();

                objCmpSql.CommandProcedure("spSGR_GET_BusquedaGeneral");
                objCmpSql.AddParameter("@Opcion", SqlDbType.VarChar, "GetMedioPago");
                objCmpSql.AddParameter("@Filtro", SqlDbType.VarChar, "");
                objCmpSql.AddParameter("@ParameterId", SqlDbType.Int, SGRVariables.ESGR_Usuario.ESGR_Empresa.IdEmpresa);
                DataTable dt = objCmpSql.ExecuteDataTable();

                for (int x = 0; x < dt.Rows.Count; x++)
                {
                    CollectionMedioPago.Add(new ESGR_MedioPago
                    {
                        IdMedioPago    = (dt.Rows[x]["IdMedioPago"] != DBNull.Value) ? Convert.ToInt16(dt.Rows[x]["IdMedioPago"]) : Convert.ToInt16(0),
                        MedioPago      = (dt.Rows[x]["MedioPago"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["MedioPago"]) : string.Empty,
                        DiasCredito    = (dt.Rows[x]["DiasCredito"] != DBNull.Value) ? Convert.ToInt16(dt.Rows[x]["DiasCredito"]) : Convert.ToInt16(0),
                        ESGR_FormaPago = new ESGR_FormaPago()
                        {
                            IdFormaPago = (dt.Rows[x]["IdFormaPago"] != DBNull.Value) ? Convert.ToInt16(dt.Rows[x]["IdFormaPago"]) : Convert.ToInt16(0),
                            FormaPago   = (dt.Rows[x]["FormaPago"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["FormaPago"]) : string.Empty,
                        },
                    });
                }

                return(CollectionMedioPago);
            }

            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Lista de Venta
        /// </summary>
        /// <returns>Colección de las Ventas Cuentas</returns>
        public CmpObservableCollection <ESGR_VentaCuenta> GetCollectionESGR_VentaCuenta(int ParameterId, string Filtro = "%")
        {
            try
            {
                var objCmpSql             = new CmpSql(SGRVariables.ConectionString);
                var CollectionVentaCuenta = new CmpObservableCollection <ESGR_VentaCuenta>();

                objCmpSql.CommandProcedure("spSGR_GET_BusquedaGeneral");
                objCmpSql.AddParameter("@Opcion", SqlDbType.VarChar, "GetVentaCuenta");
                objCmpSql.AddParameter("@Filtro", SqlDbType.VarChar, (Filtro != null || Filtro.Trim().Length != 0) ? Filtro : "%");
                objCmpSql.AddParameter("@ParameterId", SqlDbType.Int, ParameterId);
                DataTable dt = objCmpSql.ExecuteDataTable();

                for (int x = 0; x < dt.Rows.Count; x++)
                {
                    CollectionVentaCuenta.Add(new ESGR_VentaCuenta
                    {
                        IdCuenta   = (dt.Rows[x]["IdCuenta"] != DBNull.Value) ? Convert.ToInt16(dt.Rows[x]["IdCuenta"]) : Convert.ToInt16(0),
                        ESGR_Venta = new ESGR_Venta()
                        {
                            IdVenta   = (dt.Rows[x]["IdVenta"] != DBNull.Value) ? Convert.ToInt16(dt.Rows[x]["IdVenta"]) : Convert.ToInt16(0),
                            ESGR_Caja = new ESGR_Caja()
                            {
                                IdCaja = (dt.Rows[x]["IdCaja"] != DBNull.Value) ? Convert.ToInt16(dt.Rows[x]["IdCaja"]) : Convert.ToInt16(0),
                            }
                        },
                        ESGR_Cliente = new ESGR_Cliente()
                        {
                            IdCliente       = (dt.Rows[x]["IdCliente"] != DBNull.Value) ? Convert.ToInt16(dt.Rows[x]["IdCliente"]) : Convert.ToInt16(0),
                            Cliente         = (dt.Rows[x]["Cliente"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Cliente"]) : string.Empty,
                            NroDocIdentidad = (dt.Rows[x]["NroDocIdentidad"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["NroDocIdentidad"]) : string.Empty,
                        },
                        ESGR_MedioPago = new ESGR_MedioPago()
                        {
                            IdMedioPago = (dt.Rows[x]["IdMedioPago"] != DBNull.Value) ? Convert.ToInt16(dt.Rows[x]["IdMedioPago"]) : Convert.ToInt16(0),
                        },
                        ESGR_Documento = new ESGR_Documento()
                        {
                            CodDocumento = (dt.Rows[x]["CodDocumento"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["CodDocumento"]) : string.Empty,
                            Descripcion  = (dt.Rows[x]["Descripcion"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Descripcion"]) : string.Empty,
                        },
                        ESGR_Moneda = new ESGR_Moneda()
                        {
                            CodMoneda   = (dt.Rows[x]["CodMoneda"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["CodMoneda"]) : string.Empty,
                            Descripcion = (dt.Rows[x]["Descripcion"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Descripcion"]) : string.Empty,
                            Defecto     = (dt.Rows[x]["Defecto"] != DBNull.Value) ? Convert.ToBoolean(dt.Rows[x]["Defecto"]) : false,
                        },
                        Serie        = (dt.Rows[x]["Serie"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Serie"]) : string.Empty,
                        Numero       = (dt.Rows[x]["Numero"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Numero"]) : string.Empty,
                        Fecha        = (dt.Rows[x]["Fecha"] != DBNull.Value) ? Convert.ToDateTime(dt.Rows[x]["Fecha"]) : DateTime.Now,
                        TipoCambio   = (dt.Rows[x]["TipoCambio"] != DBNull.Value) ? Convert.ToDecimal(dt.Rows[x]["TipoCambio"]) : 0,
                        Gravada      = (dt.Rows[x]["Gravada"] != DBNull.Value) ? Convert.ToDecimal(dt.Rows[x]["Gravada"]) : 0,
                        IGV          = (dt.Rows[x]["IGV"] != DBNull.Value) ? Convert.ToDecimal(dt.Rows[x]["IGV"]) : 0,
                        ImporteIGV   = (dt.Rows[x]["ImporteIGV"] != DBNull.Value) ? Convert.ToDecimal(dt.Rows[x]["ImporteIGV"]) : 0,
                        Adicional    = (dt.Rows[x]["Adicional"] != DBNull.Value) ? Convert.ToDecimal(dt.Rows[x]["Adicional"]) : 0,
                        Descuento    = (dt.Rows[x]["Descuento"] != DBNull.Value) ? Convert.ToDecimal(dt.Rows[x]["Descuento"]) : 0,
                        ImporteDscto = (dt.Rows[x]["ImporteDscto"] != DBNull.Value) ? Convert.ToDecimal(dt.Rows[x]["ImporteDscto"]) : 0,
                    });
                }

                return(CollectionVentaCuenta);
            }

            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 3
0
 public ObservableCollection <ECMP_NotaCreditoDebito> GETNotaCreditoDebito(string Opcion, ECMP_NotaCreditoDebito ObjECMP_NotaCreditoDebito)
 {
     try
     {
         ListECMP_NotaCreditoDebito = new ObservableCollection <ECMP_NotaCreditoDebito>();
         ObjCmpSql = new CmpSql(SGCVariables.ConectionString);
         ObjCmpSql.CommandProcedure("spCMP_GET_NotaCreditoDebito");
         ObjCmpSql.AddParameter("@Opcion", SqlDbType.VarChar, Opcion);
         ObjCmpSql.AddParameter("@FechaIni", SqlDbType.SmallDateTime, ObjECMP_NotaCreditoDebito.FechaInicio.ToShortDateString());
         ObjCmpSql.AddParameter("@FechaFin", SqlDbType.SmallDateTime, ObjECMP_NotaCreditoDebito.FechaHasta.ToShortDateString());
         ObjCmpSql.AddParameter("@Filtro", SqlDbType.VarChar, ObjECMP_NotaCreditoDebito.Filtro.Replace("'", string.Empty));
         DataTable dt = ObjCmpSql.ExecuteDataTable();
         for (int x = 0; x < dt.Rows.Count; x++)
         {
             ListECMP_NotaCreditoDebito.Add(new ECMP_NotaCreditoDebito
             {
                 IdNotaCreDeb = (dt.Rows[x]["IdNotaCreDeb"] != DBNull.Value) ? Convert.ToInt32(dt.Rows[x]["IdNotaCreDeb"]) : 0,
                 ObjEMNF_MotivoNotaCreditoDebito = new EMNF_MotivoNotaCreditoDebito()
                 {
                     IdMotCreDeb = (dt.Rows[x]["IdMotCreDeb"] != DBNull.Value) ? Convert.ToInt32(dt.Rows[x]["IdMotCreDeb"]) :0,
                     Motivo      = (dt.Rows[x]["Motivo"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Motivo"]) : string.Empty,
                     CodMotivo   = (dt.Rows[x]["CodMotivo"] != DBNull.Value)?Convert.ToString(dt.Rows[x]["CodMotivo"]):string.Empty
                 },
                 ObjESGC_Moneda = new SGC.Empresarial.Entity.ESGC_Moneda()
                 {
                     CodMoneda   = (dt.Rows[x]["CodMoneda"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["CodMoneda"]) : string.Empty,
                     Descripcion = (dt.Rows[x]["Descripcion"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Descripcion"]) : string.Empty,
                     Simbolo     = (dt.Rows[x]["Simbolo"] != DBNull.Value)?Convert.ToString(dt.Rows[x]["Simbolo"]):string.Empty
                 },
                 ObjESGC_Estado = new ESGC_Estado()
                 {
                     CodEstado = (dt.Rows[x]["CodEstado"] != DBNull.Value)?Convert.ToString(dt.Rows[x]["CodEstado"]):string.Empty,
                     Estado    = (dt.Rows[x]["Estado"] != DBNull.Value)?Convert.ToString(dt.Rows[x]["Estado"]):string.Empty
                 },
                 CodDocumento            = (dt.Rows[x]["CodDocumento"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["CodDocumento"]) : string.Empty,
                 Serie                   = (dt.Rows[x]["Serie"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Serie"]) : string.Empty,
                 Numero                  = (dt.Rows[x]["Numero"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Numero"]) : string.Empty,
                 CodDocumentoSerieNumero = (dt.Rows[x]["CodDocumentoSerieNumero"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["CodDocumentoSerieNumero"]) : string.Empty,
                 Fecha                   = (dt.Rows[x]["Fecha"] != DBNull.Value) ? Convert.ToDateTime(dt.Rows[x]["Fecha"]) : DateTime.Now,
                 Periodo                 = (dt.Rows[x]["Periodo"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Periodo"]) : string.Empty,
                 TipoCambio              = (dt.Rows[x]["TipoCambio"] != DBNull.Value) ? Convert.ToDecimal(dt.Rows[x]["TipoCambio"]) : 0,
                 Exonerada               = (dt.Rows[x]["Exonerada"] != DBNull.Value) ? Convert.ToDecimal(dt.Rows[x]["Exonerada"]) : 0,
                 Gravada                 = (dt.Rows[x]["Gravada"] != DBNull.Value) ? Convert.ToDecimal(dt.Rows[x]["Gravada"]) : 0,
                 IGV        = (dt.Rows[x]["IGV"] != DBNull.Value) ? Convert.ToDecimal(dt.Rows[x]["IGV"]) : 0,
                 ImporteIGV = (dt.Rows[x]["ImporteIGV"] != DBNull.Value) ? Convert.ToDecimal(dt.Rows[x]["ImporteIGV"]) : 0,
                 Glosa      = (dt.Rows[x]["Glosa"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Glosa"]) : string.Empty,
                 ObjEMNF_ClienteProveedor = new EMNF_ClienteProveedor()
                 {
                     IdCliProveedor  = (dt.Rows[x]["IdCliProveedor"] != DBNull.Value) ? Convert.ToInt32(dt.Rows[x]["IdCliProveedor"]) : 0,
                     RazonSocial     = (dt.Rows[x]["RazonSocial"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["RazonSocial"]) : string.Empty,
                     NroDocIdentidad = (dt.Rows[x]["NroDocIdentidad"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["NroDocIdentidad"]) : string.Empty,
                     Direccion       = (dt.Rows[x]["Direccion"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Direccion"]) : string.Empty
                 },
                 AfectaAlmacen = (dt.Rows[x]["AfectaAlmacen"] != DBNull.Value) ? Convert.ToBoolean(dt.Rows[x]["AfectaAlmacen"]) : false,
             });
         }
         return(ListECMP_NotaCreditoDebito);
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Listado de Orden de Servicio
        /// </summary>
        /// <param name="Opcion">Opcion de Filtro de Orden de Servicio  : (T) => Muestra Todos los registros ; (F) => Filtra por Rango de Fecha</param>
        /// <param name="FechaDesde">Fecha de Inicio de Busqueda</param>
        /// <param name="FechaHasta">Fecha de Fin de Busqueda</param>
        /// <returns>Lista ECMP_OrdenServicio</returns>
        public List <ECMP_OrdenServicio> ListFiltrarOrdenServicio(ECMP_OrdenServicio ObjECMP_OrdenServicio, string Filtro)
        {
            try
            {
                ObjCmpSql = new CmpSql(SGCVariables.ConectionString);
                ListECMP_OrdenServicio = new List <ECMP_OrdenServicio>();

                ObjCmpSql.CommandProcedure("spCMP_GET_OrdenServicio");
                ObjCmpSql.AddParameter("@Opcion", SqlDbType.Char, ObjECMP_OrdenServicio.Opcion);
                ObjCmpSql.AddParameter("@Filtro", SqlDbType.Char, (Filtro.Length == 0) ? "%" : Filtro);
                ObjCmpSql.AddParameter("@FechaDesde", SqlDbType.SmallDateTime, ObjECMP_OrdenServicio.FechaInicio);
                ObjCmpSql.AddParameter("@FechaHasta", SqlDbType.SmallDateTime, ObjECMP_OrdenServicio.FechaFin);
                ObjCmpSql.AddParameter("@CodEstado", SqlDbType.VarChar, ObjECMP_OrdenServicio.ObjESGC_Estado.CodEstado);
                ObjCmpSql.AddParameter("@IdCliProveedor", SqlDbType.VarChar, ObjECMP_OrdenServicio.ObjEMNF_ClienteProveedor.IdCliProveedor);
                ObjCmpSql.AddParameter("@CodMoneda", SqlDbType.VarChar, ObjECMP_OrdenServicio.ObjESGC_Moneda.CodMoneda);
                ObjCmpSql.AddParameter("@ParameterId", SqlDbType.Char, SGCVariables.ObjESGC_Usuario.IdUsuario);

                DataTable dt = ObjCmpSql.ExecuteDataTable();

                for (int x = 0; x < dt.Rows.Count; x++)
                {
                    ListECMP_OrdenServicio.Add(new ECMP_OrdenServicio
                    {
                        IdOrdenServicio         = (dt.Rows[x]["IdOrdenServicio"] != DBNull.Value) ? Convert.ToInt32(dt.Rows[x]["IdOrdenServicio"]) : 0,
                        ObjESGC_EmpresaSucursal = new ESGC_EmpresaSucursal
                        {
                            IdEmpSucursal = (dt.Rows[x]["IdEmpSucursal"] != DBNull.Value) ? Convert.ToInt32(dt.Rows[x]["IdEmpSucursal"]) : 0,
                            Sucursal      = (dt.Rows[x]["Sucursal"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Sucursal"]) : string.Empty
                        },
                        ObjESGC_Area = new ESGC_Area
                        {
                            IdArea = (dt.Rows[x]["IdArea"] != DBNull.Value) ? Convert.ToInt32(dt.Rows[x]["IdArea"]) : 0,
                            Area   = (dt.Rows[x]["Area"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Area"]) : string.Empty,
                        },
                        ObjEMNF_ClienteProveedor = new EMNF_ClienteProveedor
                        {
                            IdCliProveedor  = (dt.Rows[x]["IdCliProveedor"] != DBNull.Value) ? Convert.ToInt32(dt.Rows[x]["IdCliProveedor"]) : 0,
                            RazonSocial     = (dt.Rows[x]["RazonSocial"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["RazonSocial"]) : string.Empty,
                            NroDocIdentidad = (dt.Rows[x]["NroDocIdentidad"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["NroDocIdentidad"]) : string.Empty,
                            Direccion       = (dt.Rows[x]["Direccion"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Direccion"]) : string.Empty,
                        },
                        //ObjEALM_Almacen = new EALM_Almacen
                        //{
                        //    IdAlmacen = (dt.Rows[x][9] != DBNull.Value) ? Convert.ToInt32(dt.Rows[x][9]) : 0,
                        //    Almacen = (dt.Rows[x][10] != DBNull.Value) ? Convert.ToString(dt.Rows[x][10]) : string.Empty,
                        //},
                        ObjESGC_Moneda = new ESGC_Moneda
                        {
                            CodMoneda   = (dt.Rows[x]["CodMoneda"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["CodMoneda"]) : string.Empty,
                            Descripcion = (dt.Rows[x]["Descripcion"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Descripcion"]) : string.Empty,
                            Simbolo     = (dt.Rows[x]["Simbolo"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Simbolo"]) : string.Empty
                        },
                        ObjESGC_Estado = new ESGC_Estado
                        {
                            CodEstado = (dt.Rows[x]["CodEstado"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["CodEstado"]) : string.Empty,
                            Estado    = (dt.Rows[x]["Estado"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Estado"]) : string.Empty
                        },
                        ObjESGC_Documento = new ESGC_Documento
                        {
                            CodDocumento = (dt.Rows[x]["CodDocumento"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["CodDocumento"]) : string.Empty
                        },
                        Serie             = (dt.Rows[x]["Serie"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Serie"]) : string.Empty,
                        Numero            = (dt.Rows[x]["Numero"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Numero"]) : string.Empty,
                        ObjESGC_FormaPago = new ESGC_FormaPago
                        {
                            IdFormaPago = (dt.Rows[x]["IdFormaPago"] != DBNull.Value) ? Convert.ToInt32(dt.Rows[x]["IdFormaPago"]) : 0,
                            FormaPago   = (dt.Rows[x]["FormaPago"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["FormaPago"]) : string.Empty
                        },
                        ObjEMNF_TipoDestino = new EMNF_TipoDestino()
                        {
                            CodTipoDestino = (dt.Rows[x]["CodTipoDestino"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["CodTipoDestino"]) : string.Empty,
                        },
                        Periodo      = (dt.Rows[x]["Periodo"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Periodo"]) : string.Empty,
                        Fecha        = (dt.Rows[x]["Fecha"] != DBNull.Value) ? Convert.ToDateTime(dt.Rows[x]["Fecha"]) : DateTime.Now,
                        FechaInicio  = (dt.Rows[x]["FechaInicio"] != DBNull.Value) ? Convert.ToDateTime(dt.Rows[x]["FechaInicio"]) : DateTime.Now,
                        FechaFin     = (dt.Rows[x]["FechaFin"] != DBNull.Value) ? Convert.ToDateTime(dt.Rows[x]["FechaFin"]) : DateTime.Now,
                        Contacto     = (dt.Rows[x]["Contacto"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Contacto"]) : string.Empty,
                        TipoCambio   = (dt.Rows[x]["TipoCambio"] != DBNull.Value) ? Convert.ToDecimal(dt.Rows[x]["TipoCambio"]) : 0,
                        Gravada      = (dt.Rows[x]["Gravada"] != DBNull.Value) ? Convert.ToDecimal(dt.Rows[x]["Gravada"]) : 0,
                        IGV          = (dt.Rows[x]["IGV"] != DBNull.Value) ? Convert.ToDecimal(dt.Rows[x]["IGV"]) : 0,
                        ImporteIGV   = (dt.Rows[x]["ImporteIGV"] != DBNull.Value) ? Convert.ToDecimal(dt.Rows[x]["ImporteIGV"]) : 0,
                        Exonerado    = (dt.Rows[x]["Exonerado"] != DBNull.Value) ? Convert.ToInt32(dt.Rows[x]["Exonerado"]) : 11,
                        Retencion    = (dt.Rows[x]["Retencion"] != DBNull.Value) ? Convert.ToBoolean(dt.Rows[x]["Retencion"]) : false,
                        DocumenSerie = (dt.Rows[x]["DocumenSerie"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["DocumenSerie"]) : string.Empty,
                        Creacion     = (dt.Rows[x]["Creado"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Creado"]) : string.Empty,
                        Aprobacion   = (dt.Rows[x]["Aprobado"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Aprobado"]) : string.Empty
                    });
                }
                return(ListECMP_OrdenServicio);
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Listado de Orden de Compra
        /// </summary>
        /// <param name="Opcion">Opcion de Filtro de Orden de Compra  : (T) => Muestra Todos los registros ; (F) => Filtra por Rango de Fecha</param>
        /// <returns>Lista de ECMP_OrdenCompra</returns>
        public List <ECMP_OrdenCompra> ListOrdenCompra(ECMP_OrdenCompra ObjECMP_OrdenCompra, string Filtro)
        {
            try
            {
                objCmpSql            = new CmpSql(SGCVariables.ConectionString);
                ListECMP_OrdenCompra = new List <ECMP_OrdenCompra>();

                objCmpSql.CommandProcedure("spCMP_GET_OrdenCompra");
                objCmpSql.AddParameter("@Opcion", SqlDbType.Char, (ObjECMP_OrdenCompra.Opcion == null) ? "F" : ObjECMP_OrdenCompra.Opcion);
                objCmpSql.AddParameter("@Filtro", SqlDbType.Char, (Filtro.Length == 0) ? "%" : Filtro);
                objCmpSql.AddParameter("@FechaDesde", SqlDbType.SmallDateTime, ObjECMP_OrdenCompra.Fecha.ToShortDateString());
                objCmpSql.AddParameter("@FechaHasta", SqlDbType.SmallDateTime, ObjECMP_OrdenCompra.FechaEntrega.ToShortDateString());
                objCmpSql.AddParameter("@CodEstado", SqlDbType.VarChar, ObjECMP_OrdenCompra.ObjESGC_Estado.CodEstado);
                //objCmpSql.AddParameter("@IdFormaPago", SqlDbType.VarChar, ObjECMP_OrdenCompra.ObjESGC_FormaPago.IdFormaPago);
                objCmpSql.AddParameter("@CodMoneda", SqlDbType.VarChar, ObjECMP_OrdenCompra.ObjESGC_Moneda.CodMoneda);
                objCmpSql.AddParameter("@IdCliProveedor", SqlDbType.Char, ObjECMP_OrdenCompra.ObjEMNF_ClienteProveedor.IdCliProveedor);
                objCmpSql.AddParameter("@ParameterId", SqlDbType.Char, SGCVariables.ObjESGC_Usuario.IdUsuario);
                DataTable dt = objCmpSql.ExecuteDataTable();

                for (int x = 0; x < dt.Rows.Count; x++)
                {
                    ListECMP_OrdenCompra.Add(new ECMP_OrdenCompra
                    {
                        IdOrdenCompra           = (dt.Rows[x]["IdOrdenCompra"] != DBNull.Value) ? Convert.ToInt32(dt.Rows[x]["IdOrdenCompra"]) : 0,
                        ObjESGC_EmpresaSucursal = new ESGC_EmpresaSucursal
                        {
                            IdEmpSucursal = (dt.Rows[x]["IdEmpSucursal"] != DBNull.Value) ? Convert.ToInt32(dt.Rows[x]["IdEmpSucursal"]) : 0,
                            Sucursal      = (dt.Rows[x]["Sucursal"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Sucursal"]) : string.Empty
                        },
                        ObjEMNF_ClienteProveedor = new EMNF_ClienteProveedor
                        {
                            IdCliProveedor  = (dt.Rows[x]["IdCliProveedor"] != DBNull.Value) ? Convert.ToInt32(dt.Rows[x]["IdCliProveedor"]) : 0,
                            RazonSocial     = (dt.Rows[x]["RazonSocial"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["RazonSocial"]) : string.Empty,
                            NroDocIdentidad = (dt.Rows[x]["NroDocIdentidad"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["NroDocIdentidad"]) : string.Empty,
                            Direccion       = (dt.Rows[x]["Direccion"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Direccion"]) : string.Empty
                        },
                        ObjEALM_Almacen = new EALM_Almacen
                        {
                            IdAlmacen = (dt.Rows[x]["IdAlmacen"] != DBNull.Value) ? Convert.ToInt32(dt.Rows[x]["IdAlmacen"]) : 0,
                            Almacen   = (dt.Rows[x]["Almacen"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Almacen"]) : string.Empty,
                        },
                        LugarEntrega   = (dt.Rows[x]["LugarEntrega"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["LugarEntrega"]) : string.Empty,
                        Fecha          = (dt.Rows[x]["Fecha"] != DBNull.Value) ? Convert.ToDateTime(dt.Rows[x]["Fecha"]) : DateTime.Now,
                        ObjESGC_Moneda = new ESGC_Moneda
                        {
                            CodMoneda   = (dt.Rows[x]["CodMoneda"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["CodMoneda"]) : string.Empty,
                            Descripcion = (dt.Rows[x]["MonedaDescripcion"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["MonedaDescripcion"]) : string.Empty,
                            Simbolo     = (dt.Rows[x]["Simbolo"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Simbolo"]) : string.Empty,
                        },
                        ObjESGC_Estado = new ESGC_Estado
                        {
                            CodEstado = (dt.Rows[x]["CodEstado"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["CodEstado"]) : string.Empty,
                            Estado    = (dt.Rows[x]["Estado"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Estado"]) : string.Empty
                        },
                        ObjESGC_Documento = new ESGC_Documento
                        {
                            CodDocumento = (dt.Rows[x]["CodDocumento"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["CodDocumento"]) : string.Empty,
                            Descripcion  = (dt.Rows[x]["DocumentoDescripcion"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["DocumentoDescripcion"]) : string.Empty
                        },
                        Serie  = (dt.Rows[x]["Serie"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Serie"]) : string.Empty,
                        Numero = (dt.Rows[x]["Numero"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Numero"]) : string.Empty,

                        ObjESGC_FormaPago = new ESGC_FormaPago
                        {
                            IdFormaPago = (dt.Rows[x]["IdFormaPago"] != DBNull.Value) ? Convert.ToInt32(dt.Rows[x]["IdFormaPago"]) : 0,
                            FormaPago   = (dt.Rows[x]["FormaPago"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["FormaPago"]) : string.Empty
                        },
                        FechaEntrega     = (dt.Rows[x]["FechaEntrega"] != DBNull.Value) ? Convert.ToDateTime(dt.Rows[x]["FechaEntrega"]) : DateTime.Now,
                        TipoCambio       = (dt.Rows[x]["TipoCambio"] != DBNull.Value) ? Convert.ToDecimal(dt.Rows[x]["TipoCambio"]) : 0,
                        Gravada          = (dt.Rows[x]["Gravada"] != DBNull.Value) ? Convert.ToDecimal(dt.Rows[x]["Gravada"]) : 0,
                        Exonerada        = (dt.Rows[x]["Exonerada"] != DBNull.Value) ? Convert.ToDecimal(dt.Rows[x]["Exonerada"]) : 0,
                        IGV              = (dt.Rows[x]["IGV"] != DBNull.Value) ? Convert.ToDecimal(dt.Rows[x]["IGV"]) : 0,
                        ImporteIGV       = (dt.Rows[x]["ImporteIGV"] != DBNull.Value) ? Convert.ToDecimal(dt.Rows[x]["ImporteIGV"]) : 0,
                        IncluyeIGV       = (dt.Rows[x]["IncluyeIGV"] != DBNull.Value) ? Convert.ToBoolean(dt.Rows[x]["IncluyeIGV"]) : false,
                        Creacion         = (dt.Rows[x]["Creado"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Creado"]) : string.Empty,
                        Aprobacion       = (dt.Rows[x]["Aprobado"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Aprobado"]) : string.Empty,
                        DocumenSerie     = (dt.Rows[x]["DocumenSerie"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["DocumenSerie"]) : string.Empty,
                        Periodo          = (dt.Rows[x]["Periodo"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Periodo"]) : string.Empty,
                        Provisionado     = (dt.Rows[x]["Provisionado"] != DBNull.Value) ? Convert.ToUInt16(dt.Rows[x]["Provisionado"]) : uint.Parse("0"),
                        ProvicionadoText = ((dt.Rows[x]["Provisionado"] != DBNull.Value) ? Convert.ToUInt16(dt.Rows[x]["Provisionado"]) : uint.Parse("0")) == 0 ? "NO PROVISIONADO" : "PROVISIONADO",
                    });
                }

                return(ListECMP_OrdenCompra);
            }

            catch (Exception)
            {
                throw;
            }
        }
        /// <summary>
        /// Listado de Compra
        /// </summary>
        /// <param name="Opcion">Opcion de Filtro de Orden de Compra  : (T) => Muestra Todos los registros ; (F) => Filtra por Rango de Fecha</param>
        /// <param name="FechaDesde">Fecha de Inicio de Busqueda</param>
        /// <param name="FechaHasta">Fecha de Fin de Busqueda</param>
        /// <returns>Lista de ECMP_OrdenCompra</returns>
        public List <ECMP_Compra> ListCompra(string Opcion, DateTime FechaDesde, DateTime FechaHasta, string CodEstado, string Filtro)
        {
            try
            {
                objCmpSql       = new CmpSql(SGCVariables.ConectionString);
                ListECMP_Compra = new List <ECMP_Compra>();

                objCmpSql.CommandProcedure("spCMP_GET_Compra");
                objCmpSql.AddParameter("@Opcion", SqlDbType.Char, Opcion);
                objCmpSql.AddParameter("@Filtro", SqlDbType.Char, (Filtro.Length == 0) ? "%" : Filtro);
                objCmpSql.AddParameter("@FechaDesde", SqlDbType.SmallDateTime, FechaDesde.ToShortDateString());
                objCmpSql.AddParameter("@FechaHasta", SqlDbType.SmallDateTime, FechaHasta.ToShortDateString());
                objCmpSql.AddParameter("@CodEstado", SqlDbType.Char, CodEstado);
                objCmpSql.AddParameter("@ParameterId", SqlDbType.Char, SGCVariables.ObjESGC_Usuario.IdUsuario);
                DataTable dt = objCmpSql.ExecuteDataTable();

                for (int x = 0; x < dt.Rows.Count; x++)
                {
                    ListECMP_Compra.Add(new ECMP_Compra
                    {
                        IdCompra = (dt.Rows[x]["IdCompra"] != DBNull.Value) ? Convert.ToInt32(dt.Rows[x]["IdCompra"]) : 0,
                        ObjEMNF_ClienteProveedor = new EMNF_ClienteProveedor
                        {
                            IdCliProveedor  = (dt.Rows[x]["IdCliProveedor"] != DBNull.Value) ? Convert.ToInt32(dt.Rows[x]["IdCliProveedor"]) : 0,
                            RazonSocial     = (dt.Rows[x]["RazonSocial"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["RazonSocial"]) : string.Empty,
                            NroDocIdentidad = (dt.Rows[x]["NroDocIdentidad"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["NroDocIdentidad"]) : string.Empty,
                            Direccion       = (dt.Rows[x]["Direccion"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Direccion"]) : string.Empty
                        },
                        Fecha          = (dt.Rows[x]["Fecha"] != DBNull.Value) ? Convert.ToDateTime(dt.Rows[x]["Fecha"]) : DateTime.Now,
                        FechaContable  = (dt.Rows[x]["FechaContable"] != DBNull.Value) ? Convert.ToDateTime(dt.Rows[x]["FechaContable"]) : DateTime.Now,
                        ObjESGC_Moneda = new ESGC_Moneda
                        {
                            CodMoneda   = (dt.Rows[x]["CodMoneda"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["CodMoneda"]) : string.Empty,
                            Descripcion = (dt.Rows[x]["MonedaDescripcion"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["MonedaDescripcion"]) : string.Empty,
                        },
                        ObjESGC_Estado = new ESGC_Estado
                        {
                            CodEstado = (dt.Rows[x]["CodEstado"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["CodEstado"]) : string.Empty,
                            Estado    = (dt.Rows[x]["Estado"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Estado"]) : string.Empty
                        },
                        CodDocumento = (dt.Rows[x]["CodDocumento"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["CodDocumento"]) : string.Empty,
                        Serie        = (dt.Rows[x]["Serie"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Serie"]) : string.Empty,
                        Numero       = (dt.Rows[x]["Numero"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Numero"]) : string.Empty,

                        ObjESGC_FormaPago = new ESGC_FormaPago
                        {
                            IdFormaPago = (dt.Rows[x]["IdFormaPago"] != DBNull.Value) ? Convert.ToInt32(dt.Rows[x]["IdFormaPago"]) : 0,
                            FormaPago   = (dt.Rows[x]["FormaPago"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["FormaPago"]) : string.Empty
                        },
                        FechaVencimiento = (dt.Rows[x]["FechaVencimiento"] != DBNull.Value) ? Convert.ToDateTime(dt.Rows[x]["FechaVencimiento"]) : DateTime.Now,
                        TipoCambio       = (dt.Rows[x]["TipoCambio"] != DBNull.Value) ? Convert.ToDecimal(dt.Rows[x]["TipoCambio"]) : 0,
                        Gravada          = (dt.Rows[x]["Gravada"] != DBNull.Value) ? Convert.ToDecimal(dt.Rows[x]["Gravada"]) : 0,
                        Exonerada        = (dt.Rows[x]["Exonerada"] != DBNull.Value) ? Convert.ToDecimal(dt.Rows[x]["Exonerada"]) : 0,
                        IGV                         = (dt.Rows[x]["IGV"] != DBNull.Value) ? Convert.ToDecimal(dt.Rows[x]["IGV"]) : 0,
                        ImporteIGV                  = (dt.Rows[x]["ImporteIGV"] != DBNull.Value) ? Convert.ToDecimal(dt.Rows[x]["ImporteIGV"]) : 0,
                        IncluyeIGV                  = (dt.Rows[x]["IncluyeIGV"] != DBNull.Value) ? Convert.ToBoolean(dt.Rows[x]["IncluyeIGV"]) : false,
                        Planilla                    = (dt.Rows[x]["Planilla"] != DBNull.Value) ? Convert.ToBoolean(dt.Rows[x]["Planilla"]) : false,
                        AfectoDetraccion            = (dt.Rows[x]["AfectoDetraccion"] != DBNull.Value) ? Convert.ToBoolean(dt.Rows[x]["AfectoDetraccion"]) : false,
                        AfectoPercepcion            = (dt.Rows[x]["AfectoPercepcion"] != DBNull.Value) ? Convert.ToBoolean(dt.Rows[x]["AfectoPercepcion"]) : false,
                        ObjEMNF_OperacionMovimiento = new EMNF_OperacionMovimiento()
                        {
                            CodOpeMovimiento = (dt.Rows[x]["CodOpeMovimiento"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["CodOpeMovimiento"]) : string.Empty,
                        },
                        ObjEMNF_MotivoMovimiento = new EMNF_MotivoMovimiento()
                        {
                            CodMotMovimiento = (dt.Rows[x]["CodMotMovimiento"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["CodMotMovimiento"]) : string.Empty,
                            MotMovimiento    = (dt.Rows[x]["MotMovimiento"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["MotMovimiento"]) : string.Empty,
                        },
                        ObjEMNF_MedioPago = new EMNF_MedioPago()
                        {
                            CodMediosPago = (dt.Rows[x]["CodMediosPago"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["CodMediosPago"]) : string.Empty,
                        },
                        ObjEMNF_SubDiario = new EMNF_SubDiario()
                        {
                            IdSubDiario = (dt.Rows[x]["IdSubDiario"] != DBNull.Value) ? Convert.ToInt32(dt.Rows[x]["IdSubDiario"]) : 0,
                        },
                        ObjEMNF_TipoDestino = new EMNF_TipoDestino()
                        {
                            CodTipoDestino = (dt.Rows[x]["CodTipoDestino"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["CodTipoDestino"]) : string.Empty,
                        },
                        CodDocumentoRef = (dt.Rows[x]["CodDocumentoRef"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["CodDocumentoRef"]) : string.Empty,
                        Detraccion      = (dt.Rows[x]["Detraccion"] != DBNull.Value) ? Convert.ToDecimal(dt.Rows[x]["Detraccion"]) * 100 : 0,
                        GuiaRemision    = (dt.Rows[x]["GuiaRemision"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["GuiaRemision"]) : string.Empty,
                        AfectaAlmacen   = (dt.Rows[x]["AfectaAlmacen"] != DBNull.Value) ? Convert.ToBoolean(dt.Rows[x]["AfectaAlmacen"]) : false,
                        Distribucion    = (dt.Rows[x]["Distribucion"] != DBNull.Value) ? Convert.ToBoolean(dt.Rows[x]["Distribucion"]) : false,
                        CajaBanco       = (dt.Rows[x]["CajaBanco"] != DBNull.Value) ? Convert.ToBoolean(dt.Rows[x]["CajaBanco"]) : false,
                        Anticipo        = (dt.Rows[x]["Anticipo"] != DBNull.Value) ? Convert.ToBoolean(dt.Rows[x]["Anticipo"]) : false,
                        Percepcion      = (dt.Rows[x]["Percepcion"] != DBNull.Value) ? Convert.ToDecimal(dt.Rows[x]["Percepcion"]) : 0,
                        Retencion       = (dt.Rows[x]["Retencion"] != DBNull.Value) ? Convert.ToBoolean(dt.Rows[x]["Retencion"]) : false,
                        Periodo         = (dt.Rows[x]["Periodo"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Periodo"]) : string.Empty,
                        Glosa           = (dt.Rows[x]["Glosa"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Glosa"]) : string.Empty
                    });
                }

                return(ListECMP_Compra);
            }

            catch (Exception)
            {
                throw;
            }
        }
        public List <ECMP_Compra> ListCompraBusqDocumentoAnticipo(ECMP_Compra ObjECMP_Compra, string FiltrarDocumento)
        {
            try
            {
                objCmpSql       = new CmpSql(SGCVariables.ConectionString);
                ListECMP_Compra = new List <ECMP_Compra>();

                objCmpSql.CommandProcedure("spCMP_GET_DocumentoAnticipo");
                objCmpSql.AddParameter("@IdCliProveedor", SqlDbType.VarChar, ObjECMP_Compra.ObjEMNF_ClienteProveedor.IdCliProveedor);
                objCmpSql.AddParameter("@CodMoneda", SqlDbType.VarChar, (ObjECMP_Compra.ObjESGC_Moneda.CodMoneda == null) ? "%" : ObjECMP_Compra.ObjESGC_Moneda.CodMoneda);
                objCmpSql.AddParameter("@FiltrarDocumento", SqlDbType.VarChar, (FiltrarDocumento == "" || FiltrarDocumento == null) ? "%" : FiltrarDocumento);
                DataTable dt = objCmpSql.ExecuteDataTable();
                for (int x = 0; x < dt.Rows.Count; x++)
                {
                    ListECMP_Compra.Add(new ECMP_Compra
                    {
                        IdCompra = (dt.Rows[x]["IdCompra"] != DBNull.Value) ? Convert.ToInt32(dt.Rows[x]["IdCompra"]) : 0,
                        ObjEMNF_ClienteProveedor = new EMNF_ClienteProveedor
                        {
                            IdCliProveedor = (dt.Rows[x]["IdCliProveedor"] != DBNull.Value) ? Convert.ToInt32(dt.Rows[x]["IdCliProveedor"]) : 0,
                            RazonSocial    = (dt.Rows[x]["RazonSocial"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["RazonSocial"]) : string.Empty,
                        },
                        ObjESGC_Moneda = new ESGC_Moneda
                        {
                            CodMoneda   = (dt.Rows[x]["CodMoneda"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["CodMoneda"]) : string.Empty,
                            Descripcion = (dt.Rows[x]["Descripcion"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Descripcion"]) : string.Empty,
                            Defecto     = (dt.Rows[x]["Defecto"] != DBNull.Value) ? Convert.ToBoolean(Convert.ToInt32(dt.Rows[x]["Defecto"])) : false,
                            Simbolo     = (dt.Rows[x]["Simbolo"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Simbolo"]) : string.Empty,
                        },
                        ObjESGC_Estado = new ESGC_Estado()
                        {
                            Estado = (dt.Rows[x]["Estado"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Estado"]) : string.Empty,
                        },
                        TipoCambio       = (dt.Rows[x]["TipoCambio"] != DBNull.Value) ? Convert.ToDecimal(dt.Rows[x]["TipoCambio"]) : 0,
                        CodDocumento     = (dt.Rows[x]["CodDocumento"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["CodDocumento"]) : string.Empty,
                        DescDocumento    = (dt.Rows[x]["DescDocumento"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["DescDocumento"]) : string.Empty,
                        Descripcion      = (dt.Rows[x]["DescDocumento"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["DescDocumento"]) : string.Empty,
                        Serie            = (dt.Rows[x]["Serie"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Serie"]) : string.Empty,
                        Numero           = (dt.Rows[x]["Numero"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Numero"]) : string.Empty,
                        Fecha            = (dt.Rows[x]["Fecha"] != DBNull.Value) ? Convert.ToDateTime(dt.Rows[x]["Fecha"]) : DateTime.Now,
                        IGV              = (dt.Rows[x]["IGV"] != DBNull.Value) ? Convert.ToDecimal(dt.Rows[x]["IGV"]) : 0,
                        IncluyeIGV       = (dt.Rows[x]["IncluyeIGV"] != DBNull.Value) ? Convert.ToBoolean(dt.Rows[x]["IncluyeIGV"]) : false,
                        Anticipo         = (dt.Rows[x]["Anticipo"] != DBNull.Value) ? Convert.ToBoolean(dt.Rows[x]["Anticipo"]) : false,
                        Gravada          = (dt.Rows[x]["Gravada"] != DBNull.Value) ? Convert.ToDecimal(dt.Rows[x]["Gravada"]) : 0,
                        Exonerada        = (dt.Rows[x]["Exonerada"] != DBNull.Value) ? Convert.ToDecimal(dt.Rows[x]["Exonerada"]) : 0,
                        ImporteIGV       = (dt.Rows[x]["ImporteIGV"] != DBNull.Value) ? Convert.ToDecimal(dt.Rows[x]["ImporteIGV"]) : 0,
                        CodEstado        = (dt.Rows[x]["CodEstado"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["CodEstado"]) : string.Empty,
                        Total            = (dt.Rows[x]["Total"] != DBNull.Value) ? Convert.ToDecimal(dt.Rows[x]["Total"]) : 0,
                        SaldoCompra      = (dt.Rows[x]["Saldo"] != DBNull.Value) ? Convert.ToDecimal(dt.Rows[x]["Saldo"]) : 0,
                        DetraccionCompra = (dt.Rows[x]["Detraccion"] != DBNull.Value) ? Convert.ToDecimal(dt.Rows[x]["Detraccion"]) : 0,
                        PagoDetraccion   = (dt.Rows[x]["PagoDetraccion"] != DBNull.Value) ? Convert.ToBoolean(dt.Rows[x]["PagoDetraccion"]) : false,
                    });
                }

                return(ListECMP_Compra);
            }

            catch (Exception)
            {
                throw;
            }
        }