Пример #1
0
        public List <XINV_FJ_Rpt006_Info> Get_Kardes_Movimiento(int IdEmpresa, int IdSucursalIni, int IdSucursalFin, int IdBodegaIni, int IdBodegaFin, decimal IdProductoIni, decimal IdProductoFin, string IdCentroCosto, string IdSubCentroCosto, int IdMov_inven_tipoIni, int IdMov_inven_tipoFin, string TipoMov, DateTime FechaIni, DateTime FechaFin)
        {
            try
            {
                List <XINV_FJ_Rpt006_Info> lista = new List <XINV_FJ_Rpt006_Info>();
                using (EntitiesInventario_FJ_Rpt conexion = new EntitiesInventario_FJ_Rpt())
                {
                    //double Subtotal = 0;
                    var querry = from q in conexion.vwINV_FJ_Rpt006
                                 where q.IdEmpresa == IdEmpresa &&
                                 q.IdSucursal >= IdSucursalIni && q.IdSucursal <= IdSucursalFin &&
                                 q.IdBodega >= IdBodegaIni && q.IdBodega <= IdBodegaFin &&
                                 q.IdCentro_costo.Contains(IdCentroCosto) &&
                                 q.IdSubcentro_costo.Contains(IdSubCentroCosto) &&
                                 q.IdMovi_inven_tipo >= IdMov_inven_tipoIni && q.IdMovi_inven_tipo <= IdMov_inven_tipoFin &&
                                 q.IdProducto >= IdProductoIni && q.IdProducto <= IdProductoFin &&
                                 q.cm_tipo.Contains(TipoMov) &&
                                 q.cm_fecha >= FechaIni && q.cm_fecha <= FechaFin
                                 select q;


                    foreach (var item in querry)
                    {
                        XINV_FJ_Rpt006_Info itemInfo = new XINV_FJ_Rpt006_Info();

                        itemInfo.IdEmpresa           = item.IdEmpresa;
                        itemInfo.nom_empresa         = item.nom_empresa;
                        itemInfo.ruc_empresa         = item.ruc_empresa;
                        itemInfo.IdSucursal          = item.IdSucursal;
                        itemInfo.nom_sucursal        = item.nom_sucursal;
                        itemInfo.IdBodega            = item.IdBodega;
                        itemInfo.nom_bodega          = item.nom_bodega;
                        itemInfo.IdMovi_inven_tipo   = item.IdMovi_inven_tipo;
                        itemInfo.IdNumMovi           = item.IdNumMovi;
                        itemInfo.CodMoviInven        = item.CodMoviInven;
                        itemInfo.cm_tipo             = item.cm_tipo;
                        itemInfo.mv_costo            = item.mv_costo;
                        itemInfo.dm_cantidad         = item.dm_cantidad;
                        itemInfo.SubTotal            = item.dm_cantidad * item.mv_costo;
                        itemInfo.cm_fecha            = item.cm_fecha;
                        itemInfo.Secuencia           = item.Secuencia;
                        itemInfo.IdProducto          = item.IdProducto;
                        itemInfo.cod_producto        = item.cod_producto;
                        itemInfo.nom_producto        = item.nom_producto;
                        itemInfo.dm_observacion      = item.dm_observacion;
                        itemInfo.nom_tipo_inven      = item.nom_tipo_inven;
                        itemInfo.nom_centro_costo    = item.nom_centro_costo;
                        itemInfo.nom_subcentro_costo = item.nom_subcentro_costo;
                        itemInfo.IdCentro_costo      = item.IdCentro_costo;
                        itemInfo.IdSubcentro_costo   = item.IdSubcentro_costo;
                        lista.Add(itemInfo);
                    }
                }
                return(lista);
            }
            catch (Exception)
            {
                return(new List <XINV_FJ_Rpt006_Info>());
            }
        }
Пример #2
0
        public List <XINV_FJ_Rpt003_Info> get_Costos_x_Fecha(int IdEmpresa, int IdBodegaIni, int IdBodegaFin, int IdSucursalIni, int IdSucursalFin, decimal IdProductoIni, decimal IdProductoFin, string idCentro_costo, string idSubCentro_costo, DateTime FechaIni)
        {
            try
            {
                List <XINV_FJ_Rpt003_Info> lstInfo = new List <XINV_FJ_Rpt003_Info>();
                using (EntitiesInventario_FJ_Rpt listado = new EntitiesInventario_FJ_Rpt())
                {
                    var selectProce = from q in listado.spINV_FJ_Rpt003(IdEmpresa, IdSucursalIni, IdSucursalFin, IdBodegaIni, IdBodegaFin, IdProductoIni, IdProductoFin, FechaIni, idCentro_costo, idSubCentro_costo)
                                      select q;

                    foreach (var item in selectProce)
                    {
                        XINV_FJ_Rpt003_Info InfoPrueba = new XINV_FJ_Rpt003_Info();
                        InfoPrueba.IdBodega         = item.IdBodega;
                        InfoPrueba.IdSucursal       = item.IdSucursal;
                        InfoPrueba.IdProducto       = item.IdProducto;
                        InfoPrueba.CostoInicial     = Convert.ToDouble(item.Costo_Inicial);
                        InfoPrueba.Costo_x_Unidades = Convert.ToDouble(item.Costo_Inicial_Acum);
                        lstInfo.Add(InfoPrueba);
                    }
                }
                return(lstInfo);
            }
            catch (Exception ex)
            {
                string mensaje = "";
                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;
                throw new Exception(ex.ToString());
            }
        }
Пример #3
0
 public List <XINV_FJ_Rpt007_Info> consultar_data(int IdEmpresa, int IdSucursal, int IdBodega, int IdMovi_inven_tipo, decimal IdNumMovi, ref string mensaje)
 {
     try
     {
         List <XINV_FJ_Rpt007_Info> listadedatos = new List <XINV_FJ_Rpt007_Info>();
         using (EntitiesInventario_FJ_Rpt EgresosVarios = new EntitiesInventario_FJ_Rpt())
         {
             var select = from h in EgresosVarios.vwINV_FJ_Rpt007
                          where h.IdEmpresa == IdEmpresa &&
                          h.IdSucursal == IdSucursal &&
                          h.IdBodega == IdBodega &&
                          h.IdMovi_inven_tipo == IdMovi_inven_tipo &&
                          h.IdNumMovi == IdNumMovi
                          select h;
             infoEmp = dataEmp.Get_Info_Empresa(IdEmpresa);
             foreach (var item in select)
             {
                 XINV_FJ_Rpt007_Info itemInfo = new XINV_FJ_Rpt007_Info();
                 itemInfo.cantidad      = item.cantidad * -1;
                 itemInfo.cod_producto  = item.cod_producto;
                 itemInfo.CodMoviInven  = item.CodMoviInven;
                 itemInfo.Empresa       = item.Empresa;
                 itemInfo.fecha         = item.fecha;
                 itemInfo.IdBodega      = (item.IdBodega == null) ? 0 : Convert.ToInt32(item.IdBodega);
                 itemInfo.IdCentroCosto = item.IdCentroCosto;
                 itemInfo.IdCentroCosto_sub_centro_costo = item.IdCentroCosto_sub_centro_costo;
                 itemInfo.IdEmpresa                    = item.IdEmpresa;
                 itemInfo.IdMovi_inven_tipo            = item.IdMovi_inven_tipo;
                 itemInfo.IdNumMovi                    = item.IdNumMovi;
                 itemInfo.IdProducto                   = item.IdProducto;
                 itemInfo.IdSucursal                   = item.IdSucursal;
                 itemInfo.nom_bodega                   = item.nom_bodega;
                 itemInfo.nom_producto                 = item.nom_producto;
                 itemInfo.nom_sucursal                 = item.nom_sucursal;
                 itemInfo.observacion                  = item.observacion;
                 itemInfo.observacion_det              = item.observacion_det;
                 itemInfo.stock_act                    = item.stock_act;
                 itemInfo.stock_ant                    = item.stock_ant;
                 itemInfo.Tipo_Movimiento              = item.Tipo_Movimiento;
                 itemInfo.UnidadMedida                 = item.UnidadMedida;
                 itemInfo.em_logo_Image                = infoEmp.em_logo_Image;
                 itemInfo.IdEstadoDespacho_cat         = item.IdEstadoDespacho_cat;
                 itemInfo.Fecha_registro               = item.Fecha_registro;
                 itemInfo.Fecha_ingreso                = item.Fecha_ingreso;
                 itemInfo.Fecha_despacho               = item.Fecha_despacho;
                 itemInfo.Af_DescripcionCorta          = item.Af_DescripcionCorta;
                 itemInfo.dm_cantidad_sinConversion    = item.dm_cantidad_sinConversion * -1;
                 itemInfo.IdUnidadMedida_sinConversion = item.IdUnidadMedida_sinConversion;
                 itemInfo.UnidadMedida_sinConversion   = item.UnidadMedida_sinConversion;
                 itemInfo.mv_costo_sinConversion       = itemInfo.mv_costo_sinConversion;
                 listadedatos.Add(itemInfo);
             }
         }
         return(listadedatos);
     }
     catch (Exception ex)
     {
         return(new List <XINV_FJ_Rpt007_Info>());
     }
 }
Пример #4
0
 public List <XINV_FJ_Rpt001_Info> Get_OrdenSer_Info(int idEmpresa, int idSucursal, int idBodega, decimal idOrdenSer_x_Af)
 {
     try
     {
         List <XINV_FJ_Rpt001_Info> Lista = new List <XINV_FJ_Rpt001_Info>();
         using (EntitiesInventario_FJ_Rpt Conexion = new EntitiesInventario_FJ_Rpt())
         {
             Lista = (from q in Conexion.vwINV_FJ_Rpt001
                      where q.IdEmpresa == idEmpresa && q.IdSucursal == idSucursal &&
                      q.IdBodega == idBodega && q.IdOrdenSer_x_Af == idOrdenSer_x_Af
                      select new XINV_FJ_Rpt001_Info
             {
                 Secuencia = q.Secuencia,
                 Cantidad = q.Cantidad,
                 Costo = q.Costo,
                 SubTotal = q.SubTotal,
                 Iva = q.Iva,
                 Total = q.Total,
                 IdOrdenSer_x_Af = q.IdOrdenSer_x_Af,
                 //  Fecha = q.Fecha,
                 Num_Fact = q.Num_Fact,
                 Num_Documento = q.Num_Documento,
                 Observacion = q.Observacion,
                 Su_Descripcion = q.Su_Descripcion,
                 bo_Descripcion = q.bo_Descripcion,
                 pr_codigo = q.pr_codigo,
                 pr_descripcion = q.pr_descripcion,
                 IdSucursal = q.IdSucursal,
                 IdEmpresa = q.IdEmpresa,
                 IdBodega = q.IdBodega,
                 pr_nombre = q.pr_nombre,
                 Af_Nombre = q.Af_Nombre,
                 em_nombre = q.em_nombre
             }).ToList();
         }
         return(Lista);
     }
     catch (Exception)
     {
         return(new List <XINV_FJ_Rpt001_Info>());
     }
 }
Пример #5
0
        public List <XINV_Rpt010_Info> Get_List(DateTime Fecha_desde, DateTime Fecha_hasta, int IdEmpresa, int IdSucursal, List <int> lst_bodega, decimal IdProducto, string idUsuario, bool No_mostrar_valores_en_0, bool Mostrar_detallado)
        {
            try
            {
                Fecha_desde = Fecha_desde.Date;
                Fecha_hasta = Fecha_hasta.Date;

                int IdSucursal_ini = IdSucursal == 0 ? 1 : IdSucursal;
                int IdSucursal_fin = IdSucursal == 0 ? 9999 : IdSucursal;

                decimal IdProducto_ini = IdProducto == 0 ? 1 : IdProducto;
                decimal IdProducto_fin = IdProducto == 0 ? 99999 : IdProducto;

                List <XINV_Rpt010_Info> List = new List <XINV_Rpt010_Info>();

                using (EntitiesInventario_FJ_Rpt context = new EntitiesInventario_FJ_Rpt())
                {
                    context.SetCommandTimeOut(30000);
                    foreach (var item_bodega in lst_bodega)
                    {
                        List = (from q in context.spINV_FJ_Rpt009(IdEmpresa, IdSucursal_ini, IdSucursal_fin, item_bodega, item_bodega, IdProducto_ini, IdProducto_fin, Fecha_desde, Fecha_hasta, idUsuario, No_mostrar_valores_en_0, Mostrar_detallado)
                                select new XINV_Rpt010_Info
                        {
                            IdEmpresa = q.IdEmpresa,
                            IdSucursal = q.IdSucursal,
                            IdBodega = q.IdBodega,
                            IdMovi_inven_tipo = q.IdMovi_inven_tipo,
                            IdNumMovi = q.IdNumMovi,
                            Secuencia = q.Secuencia,
                            IdProducto = q.IdProducto,
                            Saldo_ini_cant = q.Saldo_ini_cant,
                            Cost_prom_ini = q.Cost_prom_ini,
                            Saldo_ini_cost = q.Saldo_ini_cost,
                            cant_ing = q.cant_ing,
                            cost_ing = q.cost_ing,
                            total_ing = q.total_ing,
                            cant_egr = q.cant_egr,
                            cost_egr = q.cost_egr,
                            total_egr = q.total_egr,
                            Saldo_cant = q.Saldo_cant,
                            Saldo_cost_prom = q.Saldo_cost_prom,
                            Saldo_cost = q.Saldo_cost,
                            Saldo_fin_cant = q.Saldo_fin_cant,
                            Cost_prom_fin = q.Cost_prom_fin,
                            Saldo_fin_cost = q.Saldo_fin_cost,
                            IdUsuario = q.IdUsuario,
                            dm_observacion = q.dm_observacion,
                            cm_fecha = q.cm_fecha,
                            tipo_movi = q.tipo_movi,
                            cod_bodega = q.cod_bodega,
                            nom_bodega = q.nom_bodega,
                            cod_sucursal = q.cod_sucursal,
                            nom_sucursal = q.nom_sucursal,
                            IdEmpresa_oc = q.IdEmpresa_oc,
                            IdSucursal_oc = q.IdSucursal_oc,
                            IdOrdenCompra = q.IdOrdenCompra,
                            num_factura = q.num_factura,
                            nom_proveedor = q.nom_proveedor,
                            pr_codigo = q.pr_codigo,
                            pr_descripcion = q.pr_descripcion,
                            IdUnidadMedida = q.IdUnidadMedida,
                            nom_unidad_consumo = q.nom_unidad_consumo,
                            cod_unidad_consumo = q.cod_unidad_consumo,
                            IdPunto_cargo = q.IdPunto_cargo,
                            nom_punto_cargo = q.nom_punto_cargo
                        }).ToList();
                    }
                    if (lst_bodega.Count == 0)
                    {
                        List = (from q in context.spINV_FJ_Rpt009(IdEmpresa, IdSucursal_ini, IdSucursal_fin, 1, 9999, IdProducto_ini, IdProducto_fin, Fecha_desde, Fecha_hasta, idUsuario, No_mostrar_valores_en_0, Mostrar_detallado)
                                select new XINV_Rpt010_Info
                        {
                            IdEmpresa = q.IdEmpresa,
                            IdSucursal = q.IdSucursal,
                            IdBodega = q.IdBodega,
                            IdMovi_inven_tipo = q.IdMovi_inven_tipo,
                            IdNumMovi = q.IdNumMovi,
                            Secuencia = q.Secuencia,
                            IdProducto = q.IdProducto,
                            Saldo_ini_cant = q.Saldo_ini_cant,
                            Cost_prom_ini = q.Cost_prom_ini,
                            Saldo_ini_cost = q.Saldo_ini_cost,
                            cant_ing = q.cant_ing,
                            cost_ing = q.cost_ing,
                            total_ing = q.total_ing,
                            cant_egr = q.cant_egr,
                            cost_egr = q.cost_egr,
                            total_egr = q.total_egr,
                            Saldo_cant = q.Saldo_cant,
                            Saldo_cost_prom = q.Saldo_cost_prom,
                            Saldo_cost = q.Saldo_cost,
                            Saldo_fin_cant = q.Saldo_fin_cant,
                            Cost_prom_fin = q.Cost_prom_fin,
                            Saldo_fin_cost = q.Saldo_fin_cost,
                            IdUsuario = q.IdUsuario,
                            dm_observacion = q.dm_observacion,
                            cm_fecha = q.cm_fecha,
                            tipo_movi = q.tipo_movi,
                            cod_bodega = q.cod_bodega,
                            nom_bodega = q.nom_bodega,
                            cod_sucursal = q.cod_sucursal,
                            nom_sucursal = q.nom_sucursal,
                            IdEmpresa_oc = q.IdEmpresa_oc,
                            IdSucursal_oc = q.IdSucursal_oc,
                            IdOrdenCompra = q.IdOrdenCompra,
                            num_factura = q.num_factura,
                            nom_proveedor = q.nom_proveedor,
                            pr_codigo = q.pr_codigo,
                            pr_descripcion = q.pr_descripcion,
                            IdUnidadMedida = q.IdUnidadMedida,
                            nom_unidad_consumo = q.nom_unidad_consumo,
                            cod_unidad_consumo = q.cod_unidad_consumo,
                            IdPunto_cargo = q.IdPunto_cargo,
                            nom_punto_cargo = q.nom_punto_cargo
                        }).ToList();
                    }
                }

                return(List);
            }
            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.InnerException + " " + ex.Message;
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref MensajeError);
                throw new Exception(ex.InnerException.ToString());
            }
        }
Пример #6
0
        public List <XINV_FJ_Rpt005_Info> get_Kardex_Resumido(int IdEmpresa, int IdBodegaIni, int IdBodegaFin, int IdSucursalIni,
                                                              int IdSucursalFin, decimal IdProductoIni, decimal IdProductoFin, string IdCentro_costo, string IdSubCentro_Costo, DateTime FechaIni, DateTime FechaFin)
        {
            try
            {
                List <XINV_FJ_Rpt005_Info> lista_datos      = new List <XINV_FJ_Rpt005_Info>();
                List <XINV_FJ_Rpt002_Info> lstCant_x_Fecha  = new List <XINV_FJ_Rpt002_Info>();
                List <XINV_FJ_Rpt003_Info> lstCosto_x_Fecha = new List <XINV_FJ_Rpt003_Info>();
                XINV_FJ_Rpt002_Data        dataCant         = new XINV_FJ_Rpt002_Data();
                XINV_FJ_Rpt003_Data        dataCosto        = new XINV_FJ_Rpt003_Data();

                lstCant_x_Fecha  = dataCant.get_Cantidades_x_Fecha(IdEmpresa, IdBodegaIni, IdBodegaFin, IdSucursalIni, IdSucursalFin, IdProductoIni, IdProductoFin, IdCentro_costo, IdSubCentro_Costo, FechaIni);
                lstCosto_x_Fecha = dataCosto.get_Costos_x_Fecha(IdEmpresa, IdBodegaIni, IdBodegaFin, IdSucursalIni, IdSucursalFin, IdProductoIni, IdProductoFin, IdCentro_costo, IdSubCentro_Costo, FechaIni);

                using (EntitiesInventario_FJ_Rpt kardexCostos = new EntitiesInventario_FJ_Rpt())
                {
                    double SaldoInicial   = 0;
                    double Saldo          = 0;
                    double CostoInicial   = 0;
                    double Costo          = 0;
                    double Costo_x_IngEgr = 0;

                    Costo = SaldoInicial * CostoInicial;

                    var select_Items = from h in kardexCostos.vwINV_FJ_Rpt005
                                       where h.IdEmpresa == IdEmpresa &&
                                       h.IdBodega >= IdBodegaIni && h.IdBodega <= IdBodegaFin &&
                                       h.IdSucursal >= IdSucursalIni && h.IdSucursal <= IdSucursalFin &&
                                       h.IdProducto >= IdProductoIni && h.IdProducto <= IdProductoFin &&
                                       h.Fecha >= FechaIni && h.Fecha <= FechaFin


                                       select h;

                    var select = from q in select_Items
                                 group q by new
                    {
                        q.IdEmpresa,
                        q.IdSucursal,
                        q.IdBodega,
                        q.IdProducto,
                        q.nom_sucursal,
                        q.nom_bodega,
                        q.nom_producto,
                        q.Cod_producto
                    } into
                    grouping
                        select new
                    {
                        grouping.Key,
                        CantiIngreso    = grouping.Sum(p => p.CantiIngreso),
                        CantiEgreso     = grouping.Sum(p => p.CantiEgreso),
                        CostoUniIngreso = grouping.Sum(p => p.CostoUniIngreso),
                        CostoUniEgreso  = grouping.Sum(p => p.CostoUniEgreso)
                    };

                    infoEmp = dataEmp.Get_Info_Empresa(IdEmpresa);

                    foreach (var item in select)
                    {
                        XINV_FJ_Rpt005_Info itemInfo = new XINV_FJ_Rpt005_Info();

                        ///Sacar las cantidades iniciales
                        foreach (var itemSaldo in lstCant_x_Fecha)
                        {
                            if (itemSaldo.IdBodega == item.Key.IdBodega && itemSaldo.IdSucursal == item.Key.IdSucursal && itemSaldo.IdProducto == item.Key.IdProducto)
                            {
                                SaldoInicial = Convert.ToDouble(itemSaldo.SaldoInicial);
                                itemSaldo.Saldo_x_Unidades = itemSaldo.Saldo_x_Unidades + item.CantiIngreso - ((item.CantiEgreso < 0) ? (item.CantiEgreso * -1) : item.CantiEgreso);
                                Saldo = Convert.ToDouble(itemSaldo.Saldo_x_Unidades);
                            }
                        }


                        if (lstCant_x_Fecha.Where(q => q.IdBodega == item.Key.IdBodega && q.IdSucursal == item.Key.IdSucursal && q.IdProducto == item.Key.IdProducto).Count() == 0)
                        {
                            XINV_FJ_Rpt002_Info InfoCant = new XINV_FJ_Rpt002_Info();
                            Saldo                     = 0;
                            InfoCant.IdBodega         = item.Key.IdBodega;
                            InfoCant.IdSucursal       = item.Key.IdSucursal;
                            InfoCant.IdProducto       = item.Key.IdProducto;
                            InfoCant.SaldoInicial     = 0;
                            InfoCant.Saldo_x_Unidades = Saldo + item.CantiIngreso - ((item.CantiEgreso < 0) ? (item.CantiEgreso * -1) : item.CantiEgreso);
                            Saldo                     = InfoCant.Saldo_x_Unidades;
                            lstCant_x_Fecha.Add(InfoCant);
                        }

                        //sacar los costos iniciales
                        foreach (var itemCosto in lstCosto_x_Fecha)
                        {
                            if (itemCosto.IdBodega == item.Key.IdBodega && itemCosto.IdSucursal == item.Key.IdSucursal && itemCosto.IdProducto == item.Key.IdProducto)
                            {
                                CostoInicial = Convert.ToDouble(itemCosto.CostoInicial);
                                itemCosto.Costo_x_Unidades = itemCosto.Costo_x_Unidades + (item.CantiIngreso * item.CostoUniIngreso) - (((item.CantiEgreso > 0) ? (item.CantiEgreso * -1) : item.CantiEgreso) * item.CostoUniEgreso);
                                Costo = Convert.ToDouble(itemCosto.Costo_x_Unidades);
                                itemCosto.Costo_x_IngEgr = itemCosto.Costo_x_IngEgr + (item.CostoUniIngreso - ((item.CostoUniEgreso < 0) ? (item.CostoUniEgreso * -1) : item.CostoUniEgreso));
                                Costo_x_IngEgr           = itemCosto.Costo_x_IngEgr;
                            }
                        }

                        if (lstCosto_x_Fecha.Where(q => q.IdBodega == item.Key.IdBodega && q.IdSucursal == item.Key.IdSucursal && q.IdProducto == item.Key.IdProducto).Count() == 0)
                        {
                            XINV_FJ_Rpt003_Info InfoCant = new XINV_FJ_Rpt003_Info();
                            Costo               = 0;
                            Costo_x_IngEgr      = 0;
                            InfoCant.IdBodega   = item.Key.IdBodega;
                            InfoCant.IdSucursal = item.Key.IdSucursal;
                            InfoCant.IdProducto = item.Key.IdProducto;

                            InfoCant.CostoInicial     = 0;
                            InfoCant.Costo_x_Unidades = Costo + (item.CantiIngreso * item.CostoUniIngreso) - (((item.CantiEgreso < 0) ? (item.CantiEgreso * -1) : item.CantiEgreso) * item.CostoUniEgreso);
                            InfoCant.Costo_x_IngEgr   = InfoCant.Costo_x_IngEgr + (item.CostoUniIngreso - ((item.CostoUniEgreso < 0) ? (item.CostoUniEgreso * -1) : item.CostoUniEgreso));
                            Costo          = InfoCant.Costo_x_Unidades;
                            Costo_x_IngEgr = InfoCant.Costo_x_IngEgr;
                            lstCosto_x_Fecha.Add(InfoCant);
                        }


                        itemInfo.CostoUniEgreso  = ((item.CostoUniEgreso < 0) ? (item.CostoUniEgreso * -1) : item.CostoUniEgreso);
                        itemInfo.CostoUniIngreso = item.CostoUniIngreso;

                        itemInfo.SaldoInicial     = SaldoInicial;
                        itemInfo.Saldo_x_Unidades = Saldo;
                        itemInfo.CantiIngreso     = item.CantiIngreso;
                        itemInfo.CantiEgreso      = ((item.CantiEgreso < 0) ? (item.CantiEgreso * -1) : item.CantiEgreso);

                        itemInfo.CostoInicial = CostoInicial;
                        itemInfo.CostoIngreso = item.CantiIngreso * item.CostoUniIngreso;
                        itemInfo.CostoEgreso  = ((item.CantiEgreso < 0) ? (item.CantiEgreso * -1) : item.CantiEgreso) * item.CostoUniEgreso;

                        itemInfo.Costo_x_Unidades = Costo;

                        itemInfo.Cod_producto = item.Key.Cod_producto;
                        itemInfo.IdBodega     = item.Key.IdBodega;
                        itemInfo.IdEmpresa    = item.Key.IdEmpresa;
                        itemInfo.IdProducto   = item.Key.IdProducto;
                        itemInfo.IdSucursal   = item.Key.IdSucursal;
                        itemInfo.nom_bodega   = item.Key.nom_bodega;
                        itemInfo.nom_producto = item.Key.nom_producto;
                        itemInfo.nom_sucursal = item.Key.nom_sucursal;

                        itemInfo.Logo    = infoEmp.em_logo_Image;
                        itemInfo.Empresa = infoEmp.em_nombre;


                        // itemInfo.IdCentroCosto =

                        lista_datos.Add(itemInfo);
                    }
                }
                return(lista_datos);
            }
            catch (Exception ex)
            {
                return(new List <XINV_FJ_Rpt005_Info>());
            }
        }
Пример #7
0
        public List <XINV_FJ_Rpt004_Info> get_Kardex_Detallado(int IdEmpresa, int IdBodegaIni, int IdBodegaFin, int IdSucursalIni, int IdSucursalFin, decimal IdProductoIni,
                                                               decimal IdProductoFin, string idCentro_costo, string idSubCentro_costo, DateTime FechaIni, DateTime FechaFin)
        {
            try
            {
                List <XINV_FJ_Rpt004_Info> lista_datos      = new List <XINV_FJ_Rpt004_Info>();
                List <XINV_FJ_Rpt002_Info> lstCant_x_Fecha  = new List <XINV_FJ_Rpt002_Info>();
                List <XINV_FJ_Rpt003_Info> lstCosto_x_Fecha = new List <XINV_FJ_Rpt003_Info>();
                XINV_FJ_Rpt002_Data        dataCant         = new XINV_FJ_Rpt002_Data();
                XINV_FJ_Rpt003_Data        dataCosto        = new XINV_FJ_Rpt003_Data();

                lstCant_x_Fecha  = dataCant.get_Cantidades_x_Fecha(IdEmpresa, IdBodegaIni, IdBodegaFin, IdSucursalIni, IdSucursalFin, IdProductoIni, IdProductoFin, idCentro_costo, idSubCentro_costo, FechaIni);
                lstCosto_x_Fecha = dataCosto.get_Costos_x_Fecha(IdEmpresa, IdBodegaIni, IdBodegaFin, IdSucursalIni, IdSucursalFin, IdProductoIni, IdProductoFin, idCentro_costo, idSubCentro_costo, FechaIni);

                using (EntitiesInventario_FJ_Rpt kardexCostos = new EntitiesInventario_FJ_Rpt())
                {
                    double SaldoInicial   = 0;
                    double Saldo          = 0;
                    double CostoInicial   = 0;
                    double Costo          = 0;
                    double Costo_x_IngEgr = 0;

                    Costo = SaldoInicial * CostoInicial;

                    var select = from h in kardexCostos.vwINV_FJ_Rpt004
                                 where h.IdEmpresa == IdEmpresa &&
                                 h.IdBodega >= IdBodegaIni && h.IdBodega <= IdBodegaFin &&
                                 h.IdSucursal >= IdSucursalIni && h.IdSucursal <= IdSucursalFin &&
                                 h.IdProducto >= IdProductoIni && h.IdProducto <= IdProductoFin &&
                                 h.Fecha >= FechaIni && h.Fecha <= FechaFin &&
                                 h.IdCentro_costo.Contains(idCentro_costo) &&
                                 h.Id_SubCentro_costo.Contains(idSubCentro_costo)
                                 select h;

                    infoEmp = dataEmp.Get_Info_Empresa(IdEmpresa);

                    foreach (var item in select)
                    {
                        XINV_FJ_Rpt004_Info itemInfo = new XINV_FJ_Rpt004_Info();

                        ///Sacar las cantidades iniciales
                        foreach (var itemSaldo in lstCant_x_Fecha)
                        {
                            if (itemSaldo.IdBodega == item.IdBodega && itemSaldo.IdSucursal == item.IdSucursal && itemSaldo.IdProducto == item.IdProducto)
                            {
                                SaldoInicial = Convert.ToDouble(itemSaldo.SaldoInicial);
                                itemSaldo.Saldo_x_Unidades = itemSaldo.Saldo_x_Unidades + item.CantiIngreso - ((item.CantiEgreso < 0) ? (item.CantiEgreso * -1) : item.CantiEgreso);
                                Saldo = Convert.ToDouble(itemSaldo.Saldo_x_Unidades);
                            }
                        }

                        if (lstCant_x_Fecha.Where(q => q.IdBodega == item.IdBodega && q.IdSucursal == item.IdSucursal && q.IdProducto == item.IdProducto).Count() == 0)
                        {
                            XINV_FJ_Rpt002_Info InfoCant = new XINV_FJ_Rpt002_Info();
                            Saldo                     = 0;
                            InfoCant.IdBodega         = item.IdBodega;
                            InfoCant.IdSucursal       = item.IdSucursal;
                            InfoCant.IdProducto       = item.IdProducto;
                            InfoCant.SaldoInicial     = 0;
                            InfoCant.Saldo_x_Unidades = Saldo + item.CantiIngreso - ((item.CantiEgreso < 0) ? (item.CantiEgreso * -1) : item.CantiEgreso);
                            Saldo                     = InfoCant.Saldo_x_Unidades;
                            lstCant_x_Fecha.Add(InfoCant);
                        }

                        //sacar los costos iniciales
                        foreach (var itemCosto in lstCosto_x_Fecha)
                        {
                            if (itemCosto.IdBodega == item.IdBodega && itemCosto.IdSucursal == item.IdSucursal && itemCosto.IdProducto == item.IdProducto)
                            {
                                CostoInicial = Convert.ToDouble(itemCosto.CostoInicial);
                                itemCosto.Costo_x_Unidades = itemCosto.Costo_x_Unidades + (item.CantiIngreso * item.Costo) - (((item.CantiEgreso < 0) ? (item.CantiEgreso * -1) : item.CantiEgreso) * item.Costo);
                                Costo = Convert.ToDouble(itemCosto.Costo_x_Unidades);
                                itemCosto.Costo_x_IngEgr = itemCosto.Costo_x_IngEgr + (item.CostoUniIngreso - ((item.CostoUniEgreso < 0)? (item.CostoUniEgreso * -1): item.CostoUniEgreso));
                                Costo_x_IngEgr           = itemCosto.Costo_x_IngEgr;
                            }
                        }

                        if (lstCosto_x_Fecha.Where(q => q.IdBodega == item.IdBodega && q.IdSucursal == item.IdSucursal && q.IdProducto == item.IdProducto).Count() == 0)
                        {
                            XINV_FJ_Rpt003_Info InfoCant = new XINV_FJ_Rpt003_Info();
                            Costo                     = 0;
                            Costo_x_IngEgr            = 0;
                            InfoCant.IdBodega         = item.IdBodega;
                            InfoCant.IdSucursal       = item.IdSucursal;
                            InfoCant.IdProducto       = item.IdProducto;
                            InfoCant.CostoInicial     = 0;
                            InfoCant.Costo_x_Unidades = Costo + (item.CantiIngreso * item.Costo) - (((item.CantiEgreso < 0) ? (item.CantiEgreso * -1) : item.CantiEgreso) * item.Costo);
                            InfoCant.Costo_x_IngEgr   = InfoCant.Costo_x_IngEgr + (item.CostoUniIngreso - ((item.CostoUniEgreso < 0) ? (item.CostoUniEgreso * -1) : item.CostoUniEgreso));
                            Costo                     = InfoCant.Costo_x_Unidades;
                            Costo_x_IngEgr            = InfoCant.Costo_x_IngEgr;
                            lstCosto_x_Fecha.Add(InfoCant);
                        }

                        itemInfo.Costo           = item.Costo;
                        itemInfo.CostoUniEgreso  = ((item.CostoUniEgreso < 0) ? (item.CostoUniEgreso * -1) : item.CostoUniEgreso);
                        itemInfo.CostoUniIngreso = item.CostoUniIngreso;

                        itemInfo.SaldoInicial     = SaldoInicial;
                        itemInfo.Saldo_x_Unidades = Saldo;
                        itemInfo.CantiIngreso     = item.CantiIngreso;
                        itemInfo.CantiEgreso      = ((item.CantiEgreso < 0) ? (item.CantiEgreso * -1) : item.CantiEgreso);

                        itemInfo.CostoInicial = CostoInicial;
                        itemInfo.CostoIngreso = item.CantiIngreso * item.Costo;
                        itemInfo.CostoEgreso  = ((item.CantiEgreso < 0) ? (item.CantiEgreso * -1) : item.CantiEgreso) * item.Costo;

                        itemInfo.Costo_x_Unidades = Costo;

                        itemInfo.cod_Movi_Inven_tipo = item.cod_Movi_Inven_tipo;
                        itemInfo.Cod_producto        = item.Cod_producto;
                        itemInfo.Fecha                   = item.Fecha;
                        itemInfo.IdBodega                = item.IdBodega;
                        itemInfo.IdEmpresa               = item.IdEmpresa;
                        itemInfo.IdMovi_inven_tipo       = item.IdMovi_inven_tipo;
                        itemInfo.IdNumMovi               = item.IdNumMovi;
                        itemInfo.CodMoviInven            = item.CodMoviInven;
                        itemInfo.IdProducto              = item.IdProducto;
                        itemInfo.IdSucursal              = item.IdSucursal;
                        itemInfo.mv_tipo_movi            = item.mv_tipo_movi;
                        itemInfo.nom_bodega              = item.nom_bodega;
                        itemInfo.nom_Movi_Inven_tipo     = item.nom_Movi_Inven_tipo;
                        itemInfo.nom_producto            = item.nom_producto;
                        itemInfo.nom_sucursal            = item.nom_sucursal;
                        itemInfo.NumDocumentoRelacionado = item.NumDocumentoRelacionado;
                        itemInfo.NumFactura              = item.NumFactura;
                        itemInfo.Observacion             = item.Observacion;
                        itemInfo.Logo           = infoEmp.em_logo_Image;
                        itemInfo.Empresa        = infoEmp.em_nombre;
                        itemInfo.IdMotivo_Inv   = item.IdMotivo_Inv;
                        itemInfo.Cod_Motivo_Inv = item.Cod_Motivo_Inv;
                        itemInfo.Desc_mov_inv   = item.Desc_mov_inv;

                        itemInfo.IdEmpresa_oc  = Convert.ToInt32(item.IdEmpresa_oc);
                        itemInfo.IdSucursal_oc = Convert.ToInt32(item.IdSucursal_oc);
                        itemInfo.IdOrdenCompra = Convert.ToDecimal(item.IdOrdenCompra);
                        itemInfo.IdProveedor   = Convert.ToDecimal(item.IdProveedor);
                        itemInfo.pr_nombre     = item.pr_nombre;

                        itemInfo.IdCentroCosto = item.IdCentro_costo;
                        itemInfo.IdCentroCosto_sub_centro_costo = item.Id_SubCentro_costo;
                        itemInfo.nom_Centro_costo    = item.nom_Centro_costo;
                        itemInfo.nom_SubCentro_costo = item.nom_SubCentro_costo;

                        lista_datos.Add(itemInfo);
                    }
                }
                return(lista_datos);
            }
            catch (Exception ex)
            {
                string mensaje = "";
                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;
                throw new Exception(ex.ToString());
            }
        }
Пример #8
0
        public List <XINV_FJ_Rpt003_Info> consultar_data(int IdEmpresa, int IdBodegaIni, int IdBodegaFin,
                                                         int IdSucursalIni, int IdSucursalFin, decimal IdProductoIni, decimal IdProductoFin,
                                                         string idCentro_costo, string idSubCentro_costo, DateTime FechaIni, DateTime FechaFin, ref String MensajeError)
        {
            try
            {
                List <XINV_FJ_Rpt003_Info> lista_datos      = new List <XINV_FJ_Rpt003_Info>();
                List <XINV_FJ_Rpt002_Info> lstCant_x_Fecha  = new List <XINV_FJ_Rpt002_Info>();
                List <XINV_FJ_Rpt003_Info> lstCosto_x_Fecha = new List <XINV_FJ_Rpt003_Info>();

                lstCant_x_Fecha  = dataCant.get_Cantidades_x_Fecha(IdEmpresa, IdBodegaIni, IdBodegaFin, IdSucursalIni, IdSucursalFin, IdProductoIni, IdProductoFin, idCentro_costo, idSubCentro_costo, FechaIni);
                lstCosto_x_Fecha = get_Costos_x_Fecha(IdEmpresa, IdBodegaIni, IdBodegaFin, IdSucursalIni, IdSucursalFin, IdProductoIni, IdProductoFin, idCentro_costo, idSubCentro_costo, FechaIni);

                using (EntitiesInventario_FJ_Rpt kardexCostos = new EntitiesInventario_FJ_Rpt())
                {
                    double SaldoInicial = 0;
                    double Saldo        = 0;
                    double CostoInicial = 0;
                    double Costo        = 0;

                    Costo = SaldoInicial * CostoInicial;

                    var select = from h in kardexCostos.vwINV_FJ_Rpt003
                                 where h.IdEmpresa == IdEmpresa &&
                                 h.IdBodega >= IdBodegaIni && h.IdBodega <= IdBodegaFin &&
                                 h.IdSucursal >= IdSucursalIni && h.IdSucursal <= IdSucursalFin &&
                                 h.IdProducto >= IdProductoIni && h.IdProducto <= IdProductoFin &&
                                 h.Fecha >= FechaIni && h.Fecha <= FechaFin &&
                                 h.idCentro_costo.Contains(idCentro_costo) &&
                                 h.idSubCentro_costo.Contains(idSubCentro_costo)
                                 select h;

                    //infoEmp = dataEmp.Get_Info_Empresa(IdEmpresa);

                    foreach (var item in select)
                    {
                        XINV_FJ_Rpt003_Info itemInfo = new XINV_FJ_Rpt003_Info();

                        ///Sacar las cantidades iniciales
                        foreach (var itemSaldo in lstCant_x_Fecha)
                        {
                            if (itemSaldo.IdBodega == item.IdBodega && itemSaldo.IdSucursal == item.IdSucursal && itemSaldo.IdProducto == item.IdProducto)
                            {
                                SaldoInicial = Convert.ToDouble(itemSaldo.SaldoInicial);
                                itemSaldo.Saldo_x_Unidades = itemSaldo.Saldo_x_Unidades + item.CantiIngreso - ((item.CantiEgreso < 0) ? (item.CantiEgreso * -1) : item.CantiEgreso);
                                Saldo = Convert.ToDouble(itemSaldo.Saldo_x_Unidades);
                            }
                        }

                        if (lstCant_x_Fecha.Where(q => q.IdBodega == item.IdBodega && q.IdSucursal == item.IdSucursal && q.IdProducto == item.IdProducto).Count() == 0)
                        {
                            XINV_FJ_Rpt002_Info InfoCant = new XINV_FJ_Rpt002_Info();
                            Saldo                     = 0;
                            InfoCant.IdBodega         = item.IdBodega;
                            InfoCant.IdSucursal       = item.IdSucursal;
                            InfoCant.IdProducto       = item.IdProducto;
                            InfoCant.SaldoInicial     = 0;
                            InfoCant.Saldo_x_Unidades = Saldo + item.CantiIngreso - ((item.CantiEgreso < 0) ? (item.CantiEgreso * -1) : item.CantiEgreso);
                            Saldo                     = InfoCant.Saldo_x_Unidades;
                            lstCant_x_Fecha.Add(InfoCant);
                        }

                        //sacar los costos iniciales
                        foreach (var itemCosto in lstCosto_x_Fecha)
                        {
                            if (itemCosto.IdBodega == item.IdBodega && itemCosto.IdSucursal == item.IdSucursal && itemCosto.IdProducto == item.IdProducto)
                            {
                                CostoInicial = Convert.ToDouble(itemCosto.CostoInicial);
                                itemCosto.Costo_x_Unidades = itemCosto.Costo_x_Unidades + (item.CantiIngreso * item.Costo) - (((item.CantiEgreso < 0) ? (item.CantiEgreso * -1) : item.CantiEgreso) * item.Costo);
                                Costo = Convert.ToDouble(itemCosto.Costo_x_Unidades);
                            }
                        }

                        if (lstCosto_x_Fecha.Where(q => q.IdBodega == item.IdBodega && q.IdSucursal == item.IdSucursal && q.IdProducto == item.IdProducto).Count() == 0)
                        {
                            XINV_FJ_Rpt003_Info InfoCant = new XINV_FJ_Rpt003_Info();
                            Costo                     = 0;
                            InfoCant.IdBodega         = item.IdBodega;
                            InfoCant.IdSucursal       = item.IdSucursal;
                            InfoCant.IdProducto       = item.IdProducto;
                            InfoCant.CostoInicial     = 0;
                            InfoCant.Costo_x_Unidades = Costo + (item.CantiIngreso * item.Costo) - (((item.CantiEgreso < 0) ? (item.CantiEgreso * -1) : item.CantiEgreso) * item.Costo);
                            Costo                     = InfoCant.Costo_x_Unidades;
                            lstCosto_x_Fecha.Add(InfoCant);
                        }

                        itemInfo.Costo = item.Costo;

                        itemInfo.SaldoInicial     = SaldoInicial;
                        itemInfo.Saldo_x_Unidades = Saldo;
                        itemInfo.CantiIngreso     = item.CantiIngreso;
                        itemInfo.CantiEgreso      = ((item.CantiEgreso < 0) ? (item.CantiEgreso * -1) : item.CantiEgreso);

                        itemInfo.CostoInicial = CostoInicial;
                        itemInfo.CostoIngreso = item.CantiIngreso * item.Costo;
                        itemInfo.CostoEgreso  = ((item.CantiEgreso < 0) ? (item.CantiEgreso * -1) : item.CantiEgreso) * item.Costo;
                        //Costo = Costo + itemInfo.CostoIngreso - itemInfo.CostoEgreso;
                        itemInfo.Costo_x_Unidades = Costo;

                        itemInfo.cod_Movi_Inven_tipo = item.cod_Movi_Inven_tipo;
                        itemInfo.Cod_producto        = item.Cod_producto;
                        itemInfo.Fecha                   = item.Fecha;
                        itemInfo.IdBodega                = item.IdBodega;
                        itemInfo.IdEmpresa               = item.IdEmpresa;
                        itemInfo.IdMovi_inven_tipo       = item.IdMovi_inven_tipo;
                        itemInfo.IdNumMovi               = item.IdNumMovi;
                        itemInfo.CodMoviInven            = item.CodMoviInven;
                        itemInfo.IdProducto              = item.IdProducto;
                        itemInfo.IdSucursal              = item.IdSucursal;
                        itemInfo.mv_tipo_movi            = item.mv_tipo_movi;
                        itemInfo.nom_bodega              = item.nom_bodega;
                        itemInfo.nom_Movi_Inven_tipo     = item.nom_Movi_Inven_tipo;
                        itemInfo.nom_producto            = item.nom_producto;
                        itemInfo.nom_sucursal            = item.nom_sucursal;
                        itemInfo.NumDocumentoRelacionado = item.NumDocumentoRelacionado;
                        itemInfo.NumFactura              = item.NumFactura;
                        itemInfo.Observacion             = item.Observacion;
                        //itemInfo.Logo = infoEmp.em_logo_Image;
                        //itemInfo.Empresa = infoEmp.em_nombre;
                        itemInfo.nom_Centro_costo    = item.nom_Centro_costo;
                        itemInfo.nom_subCentro_costo = item.nom_subCentro_costo;
                        itemInfo.idCentro_costo      = item.idCentro_costo;
                        itemInfo.idSubCentro_costo   = item.idSubCentro_costo;
                        lista_datos.Add(itemInfo);
                    }
                }
                return(lista_datos);
            }
            catch (Exception ex)
            {
                return(new List <XINV_FJ_Rpt003_Info>());
            }
        }
Пример #9
0
        public List <XINV_FJ_Rpt008_Info> Get_list(int IdEmpresa, int IdSucursal, List <int> lst_bodega, decimal IdProducto, string IdCentroCosto, List <string> lst_subcentro, DateTime Fecha_ini, DateTime Fecha_fin)
        {
            try
            {
                Fecha_ini = Fecha_ini.Date;
                Fecha_fin = Fecha_fin.Date;

                decimal IdProducto_ini = IdProducto;
                decimal IdProducto_fin = IdProducto == 0 ? 99999 : IdProducto;

                List <XINV_FJ_Rpt008_Info> Lista = new List <XINV_FJ_Rpt008_Info>();
                using (EntitiesInventario_FJ_Rpt Context = new EntitiesInventario_FJ_Rpt())
                {
                    IQueryable <vwINV_FJ_Rpt008> lst;
                    if (lst_bodega.Count > 0 && lst_subcentro.Count > 0)//Si escoge sucursal, bodegas, centro y subcentro
                    {
                        lst = from q in Context.vwINV_FJ_Rpt008
                              where q.IdEmpresa == IdEmpresa &&
                              q.IdSucursal == IdSucursal &&
                              lst_bodega.Contains(q.IdBodega) &&
                              q.IdCentroCosto == IdCentroCosto &&
                              lst_subcentro.Contains(q.IdCentroCosto_sub_centro_costo) &&
                              Fecha_ini <= q.cm_fecha && q.cm_fecha <= Fecha_fin &&
                              IdProducto_ini <= q.IdProducto && q.IdProducto <= IdProducto_fin
                              select q;
                    }
                    else
                    if ((IdCentroCosto == "" || IdCentroCosto == null) && (IdSucursal == 0))    // Si no escoge nada
                    {
                        lst = from q in Context.vwINV_FJ_Rpt008
                              where q.IdEmpresa == IdEmpresa &&
                              Fecha_ini <= q.cm_fecha && q.cm_fecha <= Fecha_fin &&
                              IdProducto_ini <= q.IdProducto && q.IdProducto <= IdProducto_fin
                              select q;
                    }
                    else
                    if (lst_bodega.Count > 0 && (IdCentroCosto == "" || IdCentroCosto == null))        //Si escoge sucursal y bodega pero no escoge centro
                    {
                        lst = from q in Context.vwINV_FJ_Rpt008
                              where q.IdEmpresa == IdEmpresa &&
                              q.IdSucursal == IdSucursal &&
                              lst_bodega.Contains(q.IdBodega) &&
                              Fecha_ini <= q.cm_fecha && q.cm_fecha <= Fecha_fin &&
                              IdProducto_ini <= q.IdProducto && q.IdProducto <= IdProducto_fin
                              select q;
                    }
                    else         //Si solo escoge centro y subcentro de costo pero no escoge sucursal ni bodega
                    {
                        lst = from q in Context.vwINV_FJ_Rpt008
                              where q.IdEmpresa == IdEmpresa &&
                              q.IdCentroCosto == IdCentroCosto &&
                              lst_subcentro.Contains(q.IdCentroCosto_sub_centro_costo) &&
                              Fecha_ini <= q.cm_fecha && q.cm_fecha <= Fecha_fin &&
                              IdProducto_ini <= q.IdProducto && q.IdProducto <= IdProducto_fin
                              select q;
                    }

                    foreach (var item in lst)
                    {
                        XINV_FJ_Rpt008_Info info = new XINV_FJ_Rpt008_Info();
                        info.IdEmpresa         = item.IdEmpresa;
                        info.IdSucursal        = item.IdSucursal;
                        info.IdBodega          = item.IdBodega;
                        info.IdMovi_inven_tipo = item.IdMovi_inven_tipo;
                        info.IdNumMovi         = item.IdNumMovi;
                        info.Secuencia         = item.Secuencia;
                        info.IdProducto        = item.IdProducto;
                        info.cod_producto      = item.cod_producto;
                        info.nom_producto      = item.nom_producto;
                        info.IdUnidadMedida    = item.IdUnidadMedida;
                        info.nom_unidad_medida = item.nom_unidad_medida;
                        info.cm_fecha          = item.cm_fecha;
                        info.cod_bodega        = item.cod_bodega;
                        info.nom_bodega        = item.nom_bodega;
                        info.cod_sucursal      = item.cod_sucursal;
                        info.nom_sucursal      = item.nom_sucursal;
                        info.IdCentroCosto     = item.IdCentroCosto;
                        info.nom_centro_costo  = item.nom_centro_costo;
                        info.IdCentroCosto_sub_centro_costo = item.IdCentroCosto_sub_centro_costo;
                        info.nom_subcentro_costo            = item.nom_subcentro_costo;
                        info.dm_cantidad           = item.dm_cantidad;
                        info.mv_costo              = item.mv_costo;
                        info.Total                 = item.Total;
                        info.mv_tipo_movi          = item.mv_tipo_movi;
                        info.IdPunto_cargo_grupo   = item.IdPunto_cargo_grupo;
                        info.cod_Punto_cargo_grupo = item.cod_Punto_cargo_grupo;
                        info.nom_punto_cargo_grupo = item.nom_punto_cargo_grupo;
                        info.IdPunto_cargo         = item.IdPunto_cargo;
                        info.codPunto_cargo        = item.codPunto_cargo;
                        info.nom_punto_cargo       = item.nom_punto_cargo;
                        Lista.Add(info);
                    }
                }
                return(Lista);
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #10
0
        public List <XINV_Rpt010_Info> Get_List(DateTime Fecha_desde, DateTime Fecha_hasta, int IdEmpresa, int IdSucursal, List <int> lst_bodega, decimal IdProducto, string idUsuario, bool No_mostrar_valores_en_0, bool Mostrar_detallado)
        {
            try
            {
                Fecha_desde = Fecha_desde.Date;
                Fecha_hasta = Fecha_hasta.Date;

                int IdSucursal_ini = IdSucursal == 0 ? 1 : IdSucursal;
                int IdSucursal_fin = IdSucursal == 0 ? 9999 : IdSucursal;

                decimal IdProducto_ini = IdProducto == 0 ? 1 : IdProducto;
                decimal IdProducto_fin = IdProducto == 0 ? 99999 : IdProducto;

                List <XINV_Rpt010_Info> List = new List <XINV_Rpt010_Info>();

                using (EntitiesInventario_FJ_Rpt context = new EntitiesInventario_FJ_Rpt())
                {
                    context.SetCommandTimeOut(30000);

                    foreach (var item_bodega in lst_bodega)
                    {
                        var lst = from q in context.spINV_FJ_Rpt009(IdEmpresa, IdSucursal_ini, IdSucursal_fin, item_bodega, item_bodega, IdProducto_ini, IdProducto_fin, Fecha_desde, Fecha_hasta, idUsuario, No_mostrar_valores_en_0, Mostrar_detallado)
                                  select q;
                        foreach (var item in lst)
                        {
                            XINV_Rpt010_Info info = new XINV_Rpt010_Info();
                            info.IdEmpresa          = item.IdEmpresa;
                            info.IdSucursal         = item.IdSucursal;
                            info.IdBodega           = item.IdBodega;
                            info.IdMovi_inven_tipo  = item.IdMovi_inven_tipo;
                            info.IdNumMovi          = item.IdNumMovi;
                            info.Secuencia          = item.Secuencia;
                            info.IdProducto         = item.IdProducto;
                            info.Saldo_ini_cant     = item.Saldo_ini_cant;
                            info.Cost_prom_ini      = item.Cost_prom_ini;
                            info.Saldo_ini_cost     = item.Saldo_ini_cost;
                            info.cant_ing           = item.cant_ing;
                            info.cost_ing           = item.cost_ing;
                            info.total_ing          = item.total_ing;
                            info.cant_egr           = item.cant_egr;
                            info.cost_egr           = item.cost_egr;
                            info.total_egr          = item.total_egr;
                            info.Saldo_cant         = item.Saldo_cant;
                            info.Saldo_cost_prom    = item.Saldo_cost_prom;
                            info.Saldo_cost         = item.Saldo_cost;
                            info.Saldo_fin_cant     = item.Saldo_fin_cant;
                            info.Cost_prom_fin      = item.Cost_prom_fin;
                            info.Saldo_fin_cost     = item.Saldo_fin_cost;
                            info.IdUsuario          = item.IdUsuario;
                            info.dm_observacion     = item.dm_observacion;
                            info.cm_fecha           = item.cm_fecha;
                            info.tipo_movi          = item.tipo_movi;
                            info.cod_bodega         = item.cod_bodega;
                            info.nom_bodega         = item.nom_bodega;
                            info.cod_sucursal       = item.cod_sucursal;
                            info.nom_sucursal       = item.nom_sucursal;
                            info.IdEmpresa_oc       = item.IdEmpresa_oc;
                            info.IdSucursal_oc      = item.IdSucursal_oc;
                            info.IdOrdenCompra      = item.IdOrdenCompra;
                            info.num_factura        = item.num_factura;
                            info.nom_proveedor      = item.nom_proveedor;
                            info.pr_codigo          = item.pr_codigo;
                            info.pr_descripcion     = item.pr_descripcion;
                            info.IdUnidadMedida     = item.IdUnidadMedida;
                            info.nom_unidad_consumo = item.nom_unidad_consumo;
                            info.cod_unidad_consumo = item.cod_unidad_consumo;
                            info.IdPunto_cargo      = item.IdPunto_cargo;
                            info.nom_punto_cargo    = item.nom_punto_cargo;
                            List.Add(info);
                        }
                    }
                }

                return(List);
            }
            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.InnerException + " " + ex.Message;
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref MensajeError);
                throw new Exception(ex.InnerException.ToString());
            }
        }
Пример #11
0
        //tb_Empresa_Data dataEmp = new tb_Empresa_Data();
        //tb_Empresa_Info infoEmp = new tb_Empresa_Info();

        public List <XINV_FJ_Rpt002_Info> consultar_data(int IdEmpresa, int IdBodegaIni,
                                                         int IdBodegaFin, int IdSucursalIni, int IdSucursalFin, decimal IdProductoIni,
                                                         decimal IdProductoFin, DateTime FechaIni, DateTime FechaFin,
                                                         string IdCentroCosto, string IdSubCentroCosto,
                                                         ref String MensajeError)
        {
            try
            {
                List <XINV_FJ_Rpt002_Info> listadedatos    = new List <XINV_FJ_Rpt002_Info>();
                List <XINV_FJ_Rpt002_Info> lstCant_x_Fecha = new List <XINV_FJ_Rpt002_Info>();

                lstCant_x_Fecha = get_Cantidades_x_Fecha(IdEmpresa, IdBodegaIni, IdBodegaFin, IdSucursalIni, IdSucursalFin, IdProductoIni, IdProductoFin, IdCentroCosto, IdSubCentroCosto, FechaIni);

                using (EntitiesInventario_FJ_Rpt DBEnti_Inven = new EntitiesInventario_FJ_Rpt())
                {
                    double SaldoInicial = 0;
                    double Saldo        = 0;

                    var select = from h in DBEnti_Inven.vwINV_FJ_Rpt002
                                 where h.IdEmpresa == IdEmpresa &&
                                 h.IdBodega >= IdBodegaIni && h.IdBodega <= IdBodegaFin &&
                                 h.IdSucursal >= IdSucursalIni && h.IdSucursal <= IdSucursalFin &&
                                 h.IdProducto >= IdProductoIni && h.IdProducto <= IdProductoFin &&
                                 h.Fecha >= FechaIni && h.Fecha <= FechaFin &&
                                 h.IdCentroCosto.Contains(IdCentroCosto) &&
                                 h.IdSubCentro_costo.Contains(IdSubCentroCosto)
                                 select h;



                    foreach (var item in select)
                    {
                        XINV_FJ_Rpt002_Info itemInfo = new XINV_FJ_Rpt002_Info();

                        foreach (var itemSaldo in lstCant_x_Fecha)
                        {
                            if (itemSaldo.IdBodega == item.IdBodega && itemSaldo.IdSucursal == item.IdSucursal && itemSaldo.IdProducto == item.IdProducto)
                            {
                                SaldoInicial = Convert.ToDouble(itemSaldo.SaldoInicial);
                                itemSaldo.Saldo_x_Unidades = itemSaldo.Saldo_x_Unidades + item.CantiIngreso - ((item.CantiEgreso < 0) ? (item.CantiEgreso * -1) : item.CantiEgreso);
                                Saldo = Convert.ToDouble(itemSaldo.Saldo_x_Unidades);
                            }
                        }

                        if (lstCant_x_Fecha.Where(q => q.IdBodega == item.IdBodega && q.IdSucursal == item.IdSucursal && q.IdProducto == item.IdProducto).Count() == 0)
                        {
                            XINV_FJ_Rpt002_Info InfoCant = new XINV_FJ_Rpt002_Info();
                            Saldo                     = 0;
                            InfoCant.IdBodega         = item.IdBodega;
                            InfoCant.IdSucursal       = item.IdSucursal;
                            InfoCant.IdProducto       = item.IdProducto;
                            InfoCant.SaldoInicial     = 0;
                            InfoCant.Saldo_x_Unidades = Saldo + item.CantiIngreso - ((item.CantiEgreso < 0)? (item.CantiEgreso * -1): item.CantiEgreso);
                            Saldo                     = InfoCant.Saldo_x_Unidades;
                            lstCant_x_Fecha.Add(InfoCant);
                        }

                        itemInfo.SaldoInicial        = SaldoInicial;
                        itemInfo.Saldo_x_Unidades    = Saldo;
                        itemInfo.ingresos            = item.CantiIngreso;
                        itemInfo.egresos             = ((item.CantiEgreso < 0) ? (item.CantiEgreso * -1) : item.CantiEgreso);
                        itemInfo.cod_Movi_Inven_tipo = item.cod_Movi_Inven_tipo;
                        itemInfo.Cod_producto        = item.Cod_producto;
                        itemInfo.Fecha                   = item.Fecha;
                        itemInfo.IdBodega                = item.IdBodega;
                        itemInfo.IdEmpresa               = item.IdEmpresa;
                        itemInfo.IdMovi_inven_tipo       = item.IdMovi_inven_tipo;
                        itemInfo.IdNumMovi               = item.IdNumMovi;
                        itemInfo.CodMoviInven            = item.CodMoviInven;
                        itemInfo.IdProducto              = item.IdProducto;
                        itemInfo.IdSucursal              = item.IdSucursal;
                        itemInfo.mv_tipo_movi            = item.mv_tipo_movi;
                        itemInfo.nom_bodega              = item.nom_bodega;
                        itemInfo.nom_Movi_Inven_tipo     = item.nom_Movi_Inven_tipo;
                        itemInfo.nom_producto            = item.nom_producto;
                        itemInfo.nom_sucursal            = item.nom_sucursal;
                        itemInfo.NumDocumentoRelacionado = item.NumDocumentoRelacionado;
                        itemInfo.NumFactura              = item.NumFactura;
                        itemInfo.Observacion             = item.Observacion;

                        itemInfo.IdCentroCosto       = item.IdCentroCosto;
                        itemInfo.nom_Centro_costo    = item.nom_Centro_costo;
                        itemInfo.IdSubCentro_costo   = item.IdSubCentro_costo;
                        itemInfo.nom_SubCentro_costo = item.nom_SubCentro_costo;

                        listadedatos.Add(itemInfo);
                    }
                }
                return(listadedatos);
            }
            catch (Exception ex)
            {
                string mensaje = "";
                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;
                throw new Exception(ex.ToString());
            }
        }