public Boolean VerificarExisteCodigo(string CodObra)
        {
            try
            {
                EntitiesCompras oen = new EntitiesCompras();

                var select = from q in oen.com_ListadoMateriales_Det
                             where q.CodObra == CodObra
                             select q;

                if (select.ToList().Count() >= 1)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now);
                mensaje = ex.ToString() + " " + ex.Message;
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                throw new Exception(ex.ToString());
            }
        }
        //public prd_CotizacionCompras_Info ObtenerListaCotizacion(int IdEmpresa, string CodObra)
        //{
        //    try
        //    {
        //        EntitiesProduccion_Cidersus OEEtapa = new EntitiesProduccion_Cidersus();
        //        var registros = from A in OEEtapa.prd_Obra
        //                        where A.IdEmpresa == IdEmpresa && A.CodObra == CodObra
        //                        select A;
        //        if (registros.ToList().Count > 0)
        //        {
        //            prd_Obra_Info info = new prd_Obra_Info();
        //            foreach (var item in registros)
        //            {
        //                info.CodObra = item.CodObra;
        //                info.IdEmpresa = item.IdEmpresa;
        //                info.IdCentroCosto = item.IdCentroCosto;
        //                info.Descripcion = item.Descripcion;
        //                info.Estado = item.Estado;
        //                info.Fecha = item.Fecha;
        //                info.DetalleObra = "[" + item.CodObra.Trim() + "] - " + item.Descripcion.Trim();
        //            }
        //            //return info;
        //        }
        //        else
        //            return new prd_CotizacionCompras_Info();
        //    }
        //    catch (Exception ex)
        //    {
        //        string arreglo = ToString();
        //        tb_sis_Log_Error_Vzen_Data oDataLog = new tb_sis_Log_Error_Vzen_Data();
        //        tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now);
        //        mensaje = ex.ToString() + " " + ex.Message;
        //        oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
        //        return new prd_CotizacionCompras_Info();
        //    }
        //}

        public decimal getId(int IdEmpresa)
        {
            decimal Id = 0;

            try
            {
                EntitiesCompras contex  = new EntitiesCompras();
                var             selecte = contex.com_cotizacion_compra.Count(q => q.IdEmpresa == IdEmpresa);

                if (selecte == 0)
                {
                    Id = 1;
                }
                else
                {
                    var select_em = (from q in contex.com_cotizacion_compra
                                     where q.IdEmpresa == IdEmpresa
                                     select q.IdCotizacion).Max();
                    Id = Convert.ToDecimal(select_em.ToString()) + 1;
                }

                return(Id);
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now);
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                mensaje = ex.ToString() + " " + ex.Message;
                return(0);
            }
        }
        public Boolean GuardarDB(prd_CotizacionCompras_Info info, ref string msg)
        {
            try
            {
                using (EntitiesCompras Context = new EntitiesCompras())
                {
                    var Address = new com_cotizacion_compra();

                    Address.IdEmpresa    = info.IdEmpresa;
                    Address.IdCotizacion = getId(info.IdEmpresa);
                    Address.IdSucursal   = info.IdSucursal;
                    Address.Observacion  = info.Observacion;

                    Context.com_cotizacion_compra.Add(Address);
                    Context.SaveChanges();


                    //grbar detalle
                }
                msg = "Grabación exitosa..";
                return(true);
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now);
                msg = ex.ToString() + " " + ex.Message;
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref msg);
                throw new Exception(ex.ToString());
            }
        }
 public Boolean EliminarDB(int IdEmpresa, int IdSucursal, int IdBodega, decimal IdCbteVta, ref string msg)
 {
     try
        {
        using (EntitiesCompras Entity = new EntitiesCompras())
        {
            int numeroElimindo = Entity.Database.ExecuteSqlCommand("delete fa_factura_x_formaPago where IdEmpresa = " + IdEmpresa
                + " and IdSucursal = " + IdSucursal
                + " and IdBodega = " + IdBodega
                + " and IdCbteVta = " + IdCbteVta
                );
        }
        msg = "Guardado con exito";
        return true;
        }
        catch (Exception ex)
        {
        string arreglo = ToString();
        tb_sis_Log_Error_Vzen_Data oDataLog = new tb_sis_Log_Error_Vzen_Data();
        tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "",
                            "", "", "", "", DateTime.Now);
        oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
        mensaje = ex.InnerException + " " + ex.Message;
        msg = "Error no se guardó " + ex.Message + " ";
        throw new Exception(ex.ToString());
        }
 }
Example #5
0
 public bool AprobarOrdenesCompras(List <prd_OrdenesComprasPendientes_Info> ListadosOCAprobar)
 {
     try
     {
         using (EntitiesCompras context = new EntitiesCompras())
         {
             foreach (var item in ListadosOCAprobar)
             {
                 var contact = context.com_ordencompra_local.FirstOrDefault(A => A.IdEmpresa == item.IdEmpresa && A.IdOrdenCompra == item.IdOrdenCompra);
                 if (contact != null)
                 {
                     contact.IdEstadoAprobacion_cat = item.IdEstadoAprobacion;
                     context.SaveChanges();
                 }
             }
         }
         return(true);
     }
     catch (Exception ex)
     {
         string arreglo = ToString();
         tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
         tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now);
         mensaje = ex.ToString() + " " + ex.Message;
         oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
         throw new Exception(ex.ToString());
     }
 }
Example #6
0
        public List <in_transferencia_det_Info> GetList(int IdEmpresa, int IdSucursal, decimal IdOrdenCompra)
        {
            try
            {
                List <in_transferencia_det_Info> Lista = new List <in_transferencia_det_Info>();

                using (EntitiesCompras db = new EntitiesCompras())
                {
                    var lst = db.vwcom_ordencompra_local_det.Where(q => q.IdEmpresa == IdEmpresa && q.IdSucursal == IdSucursal && q.IdOrdenCompra == IdOrdenCompra).ToList();

                    foreach (var item in lst)
                    {
                        Lista.Add(new in_transferencia_det_Info
                        {
                            IdProducto     = item.IdProducto,
                            pr_descripcion = item.pr_descripcion,
                            dt_cantidad    = item.do_Cantidad,
                            tr_Observacion = item.do_observacion,
                            IdUnidadMedida = item.IdUnidadMedida,
                            IdSucursal_oc  = item.IdSucursal,
                            IdOrdenCompra  = item.IdOrdenCompra,
                            Secuencia_oc   = item.Secuencia,
                        });
                    }
                }

                return(Lista);
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #7
0
        // aprobacion de Ordenes de Compras

        public Boolean ModificarDB(List <prd_GenerOCompra_Info> LstInfo)
        {
            try
            {
                int IdDetalleTransacion = 0;

                foreach (var item in LstInfo)
                {
                    IdDetalleTransacion = IdDetalleTransacion + 1;

                    using (EntitiesCompras Context = new EntitiesCompras())
                    {
                        var contact = Context.com_GenerOCompra_Det.FirstOrDefault(A => A.IdEmpresa == item.IdEmpresa && A.IdTransaccion == item.IdTransaccion && A.IdDetalle == item.IdDetalle && A.IdProducto == item.IdProducto && A.IdDetTrans == item.IdDetTrans);
                        if (contact != null)
                        {
                            contact.IdEstadoAprob = item.IdEstadoAprob;
                            Context.SaveChanges();
                        }
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now);
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                mensaje = ex.ToString() + " " + ex.Message;
                throw new Exception(ex.ToString());
            }
        }
Example #8
0
        public List <com_ListadoMateriales_Det_Info> ConsultaDetalleGODxDetListMateriales(int idempresa, decimal idlistadoMat, int iddetalle)
        {
            try
            {
                List <com_ListadoMateriales_Det_Info> Lst = new List <com_ListadoMateriales_Det_Info>();
                EntitiesCompras oEnti = new EntitiesCompras();

                var Query = from q in oEnti.vwcom_GenerOCompra_Det
                            where q.IdEmpresa == idempresa &&
                            q.IdListadoMateriales == idlistadoMat &&
                            q.IdDetalle == iddetalle
                            select q;
                foreach (var item in Query)
                {
                    com_ListadoMateriales_Det_Info Obj = new com_ListadoMateriales_Det_Info();
                    Obj.IdEmpresa           = item.IdEmpresa;
                    Obj.IdTransaccion       = item.IdTransaccion;
                    Obj.IdDetTrans          = item.IdDetTrans;
                    Obj.IdProveedor         = (item.IdProveedor == null) ? -1 : (decimal)item.IdProveedor;
                    Obj.CodObra             = item.CodObra;
                    Obj.obra                = item.ob_descripcion;
                    Obj.IdOrdenTaller       = item.IdOrdenTaller;
                    Obj.Motivo              = item.Motivo;
                    Obj.IdProducto          = item.IdProducto;
                    Obj.Unidades            = item.Cantidad;
                    Obj.Det_Kg              = item.Kg;
                    Obj.go_IdEstadoAprob    = item.IdEstadoAprob;
                    Obj.mr_codigo           = item.mr_codigo;
                    Obj.mr_descripcion      = item.mr_descripcion;
                    Obj.ea_codigo           = item.ea_codigo;
                    Obj.ea_descripcion      = item.ea_descripcion;
                    Obj.ot_codigo           = item.ot_codigo;
                    Obj.pr_descripcion      = item.pr_descripcion;
                    Obj.pr_codigo           = item.pr_codigo;
                    Obj.ob_descripcion      = item.ob_descripcion;
                    Obj.prov_descripcion    = item.prov_descripcion;
                    Obj.FechaRequer         = item.FechaRequer;
                    Obj.IdListadoMateriales = (decimal)item.IdListadoMateriales;
                    Obj.IdDetalle           = (int)item.IdDetalle;
                    Obj.IdOrdencompra       = item.oc_IdOrdenCompra;
                    Obj.oc_idempresa        = item.oc_IdEmpresa;
                    Obj.producto            = item.pr_descripcion + "[" + item.pr_codigo + "/" + item.IdProducto + "] ";
                    Obj.solicitante         = item.usuariosolicitante;
                    Obj.precio              = (double)item.precio;

                    Lst.Add(Obj);
                }
                return(Lst);
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now);
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                mensaje = ex.ToString() + " " + ex.Message;
                throw new Exception(ex.ToString());
            }
        }
Example #9
0
        public Boolean GuardarDB(List <prd_GenerOCompra_Info> LstInfo)
        {
            try
            {
                int IdDetalleTransacion = 0;

                foreach (var item in LstInfo)
                {
                    IdDetalleTransacion = IdDetalleTransacion + 1;

                    using (EntitiesCompras Context = new EntitiesCompras())
                    {
                        var Address = new com_GenerOCompra_Det();
                        Address.IdEmpresa           = item.IdEmpresa;
                        Address.IdTransaccion       = item.IdTransaccion;
                        Address.IdProveedor         = (item.IdProveedor == 0 || item.IdProveedor == null) ? null : item.IdProveedor;
                        Address.CodObra             = item.CodObra;
                        Address.IdOrdenTaller       = item.IdOrdenTaller;
                        Address.Motivo              = item.Motivo;
                        Address.IdProducto          = item.IdProducto;
                        Address.Cantidad            = item.Cantidad;
                        Address.Kg                  = item.Kg;
                        Address.precio              = item.precio;
                        Address.FechaRequer         = item.FechaRequer;
                        Address.IdEstadoAprob       = item.IdEstadoAprob;
                        Address.IdDetalle           = item.IdDetalle;
                        Address.IdListadoMateriales = item.IdListadoMateriales;
                        Address.oc_IdEmpresa        = item.oc_IdEmpresa;
                        Address.oc_IdOrdenCompra    = item.oc_IdOrdenCompra;
                        Address.usuariosolicitante  = item.usuariosolicitante;
                        Address.IdDetTrans          = IdDetalleTransacion;
                        Context.com_GenerOCompra_Det.Add(Address);
                        Context.SaveChanges();
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now);
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                mensaje = ex.ToString() + " " + ex.Message;
                throw new Exception(ex.ToString());
            }
        }
        public List <in_Guia_x_traspaso_bodega_Info> Get_List_OC_x_in_Guia(int IdEmpresa, int IdSucursal, decimal IdOrdenCompra)
        {
            try
            {
                List <in_Guia_x_traspaso_bodega_Info> Lista = new List <in_Guia_x_traspaso_bodega_Info>();

                using (EntitiesCompras Context = new EntitiesCompras())
                {
                    var lst = from q in Context.vwcom_ordencompra_local_x_in_guia_x_traspaso_bodega
                              where q.IdEmpresa_OC == IdEmpresa &&
                              q.IdSucursal_OC == IdSucursal &&
                              q.IdOrdenCompra_OC == IdOrdenCompra
                              select q;

                    foreach (var item in lst)
                    {
                        in_Guia_x_traspaso_bodega_Info info = new in_Guia_x_traspaso_bodega_Info();

                        info.IdEmpresa              = item.IdEmpresa;
                        info.IdGuia                 = item.IdGuia;
                        info.IdSucursal_Partida     = item.IdSucursal_Partida;
                        info.IdSucursal_Llegada     = item.IdSucursal_Llegada;
                        info.Su_Descripcion         = item.Su_Descripcion;
                        info.Su_Descripcion_Llegada = item.Su_Descripcion_Llegada;
                        info.Fecha = Convert.ToDateTime(item.Fecha);

                        Lista.Add(info);
                    }
                }

                return(Lista);
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now);
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                mensaje = ex.ToString() + " " + ex.Message;
                throw new Exception(ex.ToString());
            }
        }
Example #11
0
        public Boolean EliminarDB(int IdEmpresa, decimal IdActivoFijo)
        {
            try
            {
                EntitiesCompras Oent = new EntitiesCompras();

                var Consulta = Oent.Database.ExecuteSqlCommand("delete from Af_Activo_fijo_CtasCbles where IdEmpresa = " + IdEmpresa + " and IdActivoFijo =" + IdActivoFijo);

                return(true);
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now);
                mensaje = ex.ToString();
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                throw new Exception(ex.ToString());
            }
        }
Example #12
0
        public Boolean GrabarDB(com_GeneracionOCompra_Info info, ref string msg)
        {
            try
            {
                using (EntitiesCompras context = new EntitiesCompras())
                {
                    //var contact = com_GenerOCompra.Createcom_GenerOCompra(0, 0, 0, DateTime.Now, "", "");
                    var address = new com_GenerOCompra();
                    // decimal idEmp = getId(info.IdEmpresa);
                    //   id = idEmp;
                    address.IdEmpresa       = info.IdEmpresa;
                    address.IdSucursal      = info.IdSucursal;
                    address.IdTransaccion   = info.IdTransaccion;
                    address.IdEmpresa       = info.IdEmpresa;
                    address.FechaReg        = info.FechaReg;
                    address.Usuario         = info.Usuario;
                    address.g_ocObservacion = info.g_ocObservacion;
                    if (info.g_ocObservacion.Length > 1000)
                    {
                        address.g_ocObservacion = info.g_ocObservacion.Substring(0, 1000);
                    }
                    address.Estado = "A";


                    context.com_GenerOCompra.Add(address);
                    context.SaveChanges();
                    msg = "Se ha procedido a grabar el Listado de Materiales #: " + info.IdTransaccion + " exitosamente.";
                }
                return(true);
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "",
                                                                                          "", "", "", "", DateTime.Now);
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                mensaje = ex.ToString() + " " + ex.Message;
                throw new Exception(ex.ToString());
            }
        }
Example #13
0
 public bool Delete_Todos_Producto_x_bodega(int IdEmpresa, ref string MensajeError)
 {
     try
     {
         using (EntitiesCompras Entity = new EntitiesCompras())
         {
             int numeroElimindo = Entity.Database.ExecuteSqlCommand("delete from in_producto_x_tb_bodega where IdEmpresa=" + IdEmpresa);
         }
         MensajeError = "Guardado con exito";
         return(true);
     }
     catch (Exception ex)
     {
         string arreglo = ToString();
         tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
         tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now);
         oDataLog.Guardar_Log_Error(Log_Error_sis, ref MensajeError);
         MensajeError = ex.ToString() + " " + ex.Message;
         throw new Exception(ex.ToString());
     }
 }
Example #14
0
        public Boolean EliminarDB(string IdUsuario, ref string MensajeError)
        {
            try
            {
                using (EntitiesCompras Entity = new EntitiesCompras())
                {
                    int numeroElimindo = Entity.Database.ExecuteSqlCommand("delete from seg_usuario_x_tb_sis_reporte where IdUsuario='" + IdUsuario + "'");
                }

                return(true);
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now);
                MensajeError = ex.ToString();
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref MensajeError);
                throw new Exception(ex.ToString());
            }
        }
Example #15
0
        public int getId(int IdEmpresa)
        {
            try
            {
                int             Id;
                EntitiesCompras OEProd = new EntitiesCompras();
                var             select = from q in OEProd.com_GenerOCompra
                                         where q.IdEmpresa == IdEmpresa

                                         select q;

                if (select.ToList().Count == 0)
                {
                    Id = 1;
                }
                else
                {
                    var select_pv = (from q in OEProd.com_GenerOCompra
                                     where q.IdEmpresa == IdEmpresa

                                     select q.IdTransaccion).Max();
                    Id = Convert.ToInt32(select_pv.ToString()) + 1;
                }
                return(Id);
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "",
                                                                                          "", "", "", "", DateTime.Now);
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                mensaje = ex.ToString() + " " + ex.Message;
                throw new Exception(ex.ToString());
            }
        }
        public List <in_Ingreso_x_OrdenCompra_det_Info> Get_List_Ingreso_x_OrdenCompra_det_x_proveedor(int IdEmpresa, decimal IdProveedor)
        {
            try
            {
                decimal IdProveedorIni = 0;
                decimal IdProveedorFin = 0;

                IdProveedorIni = (IdProveedor == 0) ? 1 : IdProveedor;
                IdProveedorFin = (IdProveedor == 0) ? 9999999 : IdProveedor;


                List <in_Ingreso_x_OrdenCompra_det_Info> Lst = new List <in_Ingreso_x_OrdenCompra_det_Info>();
                EntitiesCompras oEnti = new EntitiesCompras();

                var Consulta = from q in oEnti.vwcom_ordencompra_local_det_con_saldo_x_ing_a_inven_con_saldo
                               where q.IdEmpresa == IdEmpresa &&
                               q.IdProveedor >= IdProveedorIni &&
                               q.IdProveedor <= IdProveedorFin &&
                               q.Estado == "A" &&
                               q.IdEstadoAprobacion_cat == "APRO" &&
                               q.IdEstado_cierre != "CERR" &&
                               q.Saldo_OC_x_Ing > 0
                               select q;


                foreach (var item in Consulta)
                {
                    in_Ingreso_x_OrdenCompra_det_Info Obj = new in_Ingreso_x_OrdenCompra_det_Info();
                    Obj.IdEmpresa            = Convert.ToInt32(item.IdEmpresa);
                    Obj.IdSucursal           = Convert.ToInt32(item.IdSucursal);
                    Obj.IdOrdenCompra        = Convert.ToDecimal(item.IdOrdenCompra);
                    Obj.secuencia_oc_det     = Convert.ToInt32(item.secuencia_oc_det);
                    Obj.nom_sucu             = item.nom_sucu;
                    Obj.IdProveedor          = Convert.ToDecimal(item.IdProveedor);
                    Obj.nom_proveedor        = item.nom_proveedor;
                    Obj.Tipo                 = item.Tipo;
                    Obj.oc_fecha             = Convert.ToDateTime(item.oc_fecha);
                    Obj.oc_observacion       = item.oc_observacion;
                    Obj.cod_producto         = item.cod_producto;
                    Obj.nom_producto         = item.nom_producto;
                    Obj.IdProducto           = Convert.ToDecimal(item.IdProducto);
                    Obj.cantidad_ing_a_Inven = 0;
                    Obj.Estado               = item.Estado;
                    Obj.IdEstadoAprobacion   = item.IdEstadoAprobacion_cat;
                    Obj.oc_NumDocumento      = item.oc_NumDocumento;
                    Obj.oc_precio            = Convert.ToDouble(item.oc_precio);

                    Obj.cantidad_pedida_OC             = Convert.ToDouble(item.cantidad_pedida_OC);
                    Obj.Saldo_x_Ing_OC                 = Convert.ToDouble(item.Saldo_OC_x_Ing);
                    Obj.Saldo_x_Ing_OC_AUX             = Convert.ToDouble(item.Saldo_OC_x_Ing);
                    Obj.pr_stock                       = Convert.ToDouble(item.pr_stock);
                    Obj.pr_peso                        = Convert.ToDouble(item.pr_peso);
                    Obj.CostoProducto                  = Convert.ToDouble(item.CostoProducto);
                    Obj.IdCentroCosto                  = item.IdCentroCosto;
                    Obj.IdCentroCosto_sub_centro_costo = item.IdCentroCosto_sub_centro_costo;

                    Obj.IdPunto_cargo_grupo = item.IdPunto_cargo_grupo;
                    Obj.IdPunto_cargo       = Convert.ToInt32(item.IdPunto_cargo);
                    Obj.IdUnidadMedida      = item.IdUnidadMedida;
                    Obj.IdMotivo_OC         = Convert.ToInt32(item.IdMotivo_oc);
                    Obj.Nom_Motivo          = item.Nom_Motivo;
                    Obj.cantidad_ingresada  = Convert.ToDouble(item.cantidad_ingresada);
                    Obj.IdEstado_cierre     = item.IdEstado_cierre;
                    Obj.nom_estado_cierre   = item.nom_estado_cierre;
                    Obj.Ref_OC       = "OC.# " + Convert.ToDecimal(item.IdOrdenCompra) + " Fecha:" + Convert.ToDateTime(item.oc_fecha) + " Proveedor:" + item.nom_proveedor.Trim();
                    Obj.do_descuento = Convert.ToDouble(item.do_descuento);
                    Obj.do_subtotal  = Convert.ToDouble(item.do_subtotal);
                    Obj.do_iva       = Convert.ToDouble(item.do_iva);
                    Obj.do_total     = Convert.ToDouble(item.do_total);

                    Obj.Descripcion            = item.Descripcion;
                    Obj.IdUnidadMedida_Consumo = item.IdUnidadMedida_Consumo;

                    if (item.IdCentroCosto_sub_centro_costo != null)
                    {
                        Obj.Nomsub_centro_costo = item.IdCentroCosto + "-" + item.IdCentroCosto_sub_centro_costo;
                    }
                    Obj.oc_NumDocumento = item.oc_NumDocumento;

                    Lst.Add(Obj);
                }

                return(Lst);
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "",
                                                                                          "", "", "", "", DateTime.Now);
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                mensaje = ex.ToString() + " " + ex.Message;
                throw new Exception(ex.ToString());
            }
        }