예제 #1
0
        public bool guardarDB(int IdEmpresa, List <tbl_subcentro_Info> Lista)
        {
            try
            {
                int IdSCI = 1;
                Entities_mobileSCI Context   = new Entities_mobileSCI();
                EntitiesDBConta    Context_c = new EntitiesDBConta();

                foreach (var item in Lista)
                {
                    tbl_subcentro Entity = new tbl_subcentro
                    {
                        IdEmpresaSCI  = IdEmpresa,
                        IdSCI         = IdSCI++,
                        IdEmpresa     = IdEmpresa,
                        IdCentroCosto = item.IdCentroCosto,
                        IdCentroCosto_sub_centro_costo = item.IdCentroCosto_sub_centro_costo,
                    };
                    Context.tbl_subcentro.Add(Entity);

                    Context_c.ct_centro_costo_sub_centro_costo.Where(q => q.IdEmpresa == Entity.IdEmpresa && q.IdCentroCosto == item.IdCentroCosto && q.IdCentroCosto_sub_centro_costo == item.IdCentroCosto_sub_centro_costo).FirstOrDefault().mobile_cod_produccion = item.mobile_cod_produccion;
                }
                Context.SaveChanges();
                Context_c.SaveChanges();

                Context.Dispose();
                Context_c.Dispose();
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #2
0
        public bool guardarDB(int IdEmpresa, List <tbl_producto_Info> Lista)
        {
            try
            {
                int IdSCI = 1;
                Entities_mobileSCI Context   = new Entities_mobileSCI();
                EntitiesInventario Context_i = new EntitiesInventario();

                foreach (var item in Lista)
                {
                    tbl_producto Entity = new tbl_producto
                    {
                        IdEmpresaSCI = IdEmpresa,
                        IdSCI        = IdSCI++,
                        IdEmpresa    = IdEmpresa,
                        IdProducto   = item.IdProducto
                    };
                    Context.tbl_producto.Add(Entity);
                    Context_i.in_Producto.Where(q => q.IdEmpresa == Entity.IdEmpresa && q.IdProducto == Entity.IdProducto).FirstOrDefault().mobile_cod_produccion = item.mobile_cod_produccion;
                }
                Context.SaveChanges();
                Context_i.SaveChanges();

                Context_i.Dispose();
                Context.Dispose();

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #3
0
        public bool Aprobar(int IdEmpresa, List <tbl_movimientos_det_Info> Lista, string IdUsuario)
        {
            Entities_mobileSCI db_mobile = new Entities_mobileSCI();
            EntitiesInventario db_inv    = new EntitiesInventario();

            try
            {
                var Entity_p = db_inv.in_parametro.Where(q => q.IdEmpresa == IdEmpresa).FirstOrDefault();
                if (Entity_p == null || Entity_p.IdMovi_inven_tipo_mobile_ing == null || Entity_p.IdMovi_inven_tipo_mobile_egr == null)
                {
                    return(false);
                }

                var Entity_motivo_ing = db_inv.in_Motivo_Inven.Where(q => q.IdEmpresa == IdEmpresa && q.Tipo_Ing_Egr == "ING" && q.Genera_Movi_Inven == "S").FirstOrDefault();
                if (Entity_motivo_ing == null)
                {
                    return(false);
                }

                var Entity_motivo_egr = db_inv.in_Motivo_Inven.Where(q => q.IdEmpresa == IdEmpresa && q.Tipo_Ing_Egr == "EGR" && q.Genera_Movi_Inven == "S" && q.es_Inven_o_Consumo == "TIC_CONSU").FirstOrDefault();
                if (Entity_motivo_egr == null)
                {
                    return(false);
                }

                #region Ingresos
                var lst_mov_agrupada = (from q in Lista
                                        where q.cantidad > 0
                                        group new { q.IdEmpresa, q.IdSucursal, q.IdBodega, q.Fecha, q.IdSucursal_oc, q.IdOrdenCompra } by new { q.IdEmpresa, q.IdSucursal, q.IdBodega, q.Fecha, q.IdSucursal_oc, q.IdOrdenCompra } into g
                                        select new tbl_movimientos_det_Info
                {
                    IdEmpresa = g.Key.IdEmpresa,
                    IdSucursal = g.Key.IdSucursal,
                    IdBodega = g.Key.IdBodega,
                    Fecha = g.Key.Fecha,
                    IdSucursal_oc = g.Key.IdSucursal_oc,
                    IdOrdenCompra = g.Key.IdOrdenCompra,
                }).ToList();

                foreach (var item in lst_mov_agrupada)
                {
                    #region Cabecera
                    in_Ing_Egr_Inven Entity_cab = new in_Ing_Egr_Inven
                    {
                        IdEmpresa         = item.IdEmpresa,
                        IdSucursal        = item.IdSucursal,
                        IdMovi_inven_tipo = Convert.ToInt32(Entity_p.IdMovi_inven_tipo_mobile_ing),
                        IdNumMovi         = get_id(item.IdEmpresa, item.IdSucursal, Convert.ToInt32(Entity_p.IdMovi_inven_tipo_mobile_ing)),
                        IdBodega          = item.IdBodega,
                        signo             = "+",
                        CodMoviInven      = "MOBILE",
                        cm_observacion    = "Aprobación móvil " + DateTime.Now.ToString("dd/MM/yyyy"),
                        cm_fecha          = item.Fecha,
                        Estado            = "A",
                        IdMotivo_Inv      = Entity_motivo_ing.IdMotivo_Inv,
                        IdUsuario         = IdUsuario,
                        Fecha_Transac     = DateTime.Now
                    };
                    db_inv.in_Ing_Egr_Inven.Add(Entity_cab);
                    #endregion
                    #region Detalle
                    int sec = 1;
                    foreach (var mov in Lista.Where(q => q.IdEmpresa == item.IdEmpresa && q.IdSucursal == item.IdSucursal && q.IdBodega == item.IdBodega && q.Fecha == item.Fecha && q.IdSucursal_oc == item.IdSucursal_oc && q.IdOrdenCompra == item.IdOrdenCompra && q.cantidad > 0).ToList())
                    {
                        in_Ing_Egr_Inven_det Entity_det = new in_Ing_Egr_Inven_det
                        {
                            IdEmpresa         = Entity_cab.IdEmpresa,
                            IdSucursal        = Entity_cab.IdSucursal,
                            IdMovi_inven_tipo = Entity_cab.IdMovi_inven_tipo,
                            IdNumMovi         = Entity_cab.IdNumMovi,
                            Secuencia         = sec++,
                            IdBodega          = mov.IdBodega,
                            IdProducto        = mov.IdProducto,
                            dm_cantidad       = mov.cantidad,
                            dm_stock_actu     = 0,
                            dm_stock_ante     = 0,
                            dm_observacion    = "",
                            dm_precio         = 0,
                            mv_costo          = mov.do_precioFinal,
                            dm_peso           = 0,
                            IdCentroCosto     = null,
                            IdCentroCosto_sub_centro_costo = null,
                            IdEstadoAproba               = "PEND",
                            IdUnidadMedida               = mov.IdUnidadMedida,
                            IdEmpresa_oc                 = mov.IdEmpresa_oc,
                            IdSucursal_oc                = mov.IdSucursal_oc,
                            IdOrdenCompra                = mov.IdOrdenCompra,
                            Secuencia_oc                 = mov.secuencia_oc,
                            Motivo_Aprobacion            = "Aprobación movil",
                            dm_cantidad_sinConversion    = mov.cantidad,
                            IdUnidadMedida_sinConversion = mov.IdUnidadMedida,
                            mv_costo_sinConversion       = mov.do_precioFinal,
                            IdMotivo_Inv                 = null
                        };
                        db_inv.in_Ing_Egr_Inven_det.Add(Entity_det);

                        tbl_movimientos_det_apro Entity_apro = new tbl_movimientos_det_apro
                        {
                            IdSincronizacion  = mov.IdSincronizacion,
                            IdSecuencia       = mov.IdSecuencia,
                            IdEmpresa         = mov.IdEmpresa,
                            IdSucursal        = mov.IdSucursal,
                            IdMovi_inven_tipo = Entity_cab.IdMovi_inven_tipo,
                            IdNumMovi         = Entity_cab.IdNumMovi,
                            Secuencia         = Entity_det.Secuencia
                        };
                        db_mobile.tbl_movimientos_det_apro.Add(Entity_apro);

                        var Entity_sinc = db_mobile.tbl_movimientos_det.Where(q => q.IdSincronizacion == mov.IdSincronizacion && q.IdSecuencia == mov.IdSecuencia).FirstOrDefault().Aprobado = true;
                    }
                    #endregion
                    db_inv.SaveChanges();
                    db_mobile.SaveChanges();
                    db_inv.spINV_aprobacion_movimiento(Entity_cab.IdEmpresa, Entity_cab.IdSucursal, Entity_cab.IdMovi_inven_tipo, Entity_cab.IdBodega, Entity_cab.IdNumMovi);
                }
                #endregion

                #region Egresos
                lst_mov_agrupada = (from q in Lista
                                    where q.cantidad < 0
                                    group new { q.IdEmpresa, q.IdSucursal, q.IdBodega, q.Fecha } by new { q.IdEmpresa, q.IdSucursal, q.IdBodega, q.Fecha } into g
                                    select new tbl_movimientos_det_Info
                {
                    IdEmpresa = g.Key.IdEmpresa,
                    IdSucursal = g.Key.IdSucursal,
                    IdBodega = g.Key.IdBodega,
                    Fecha = g.Key.Fecha
                }).ToList();

                foreach (var item in lst_mov_agrupada)
                {
                    #region Cabecera
                    in_Ing_Egr_Inven Entity_cab = new in_Ing_Egr_Inven
                    {
                        IdEmpresa         = item.IdEmpresa,
                        IdSucursal        = item.IdSucursal,
                        IdMovi_inven_tipo = Convert.ToInt32(Entity_p.IdMovi_inven_tipo_mobile_egr),
                        IdNumMovi         = get_id(item.IdEmpresa, item.IdSucursal, Convert.ToInt32(Entity_p.IdMovi_inven_tipo_mobile_egr)),
                        IdBodega          = item.IdBodega,
                        signo             = "-",
                        CodMoviInven      = "MOBILE",
                        cm_observacion    = "Aprobación móvil " + DateTime.Now.ToString("dd/MM/yyyy"),
                        cm_fecha          = item.Fecha,
                        Estado            = "A",
                        IdMotivo_Inv      = Entity_motivo_egr.IdMotivo_Inv
                    };
                    db_inv.in_Ing_Egr_Inven.Add(Entity_cab);
                    #endregion
                    #region Detalle
                    int sec = 1;
                    foreach (var mov in Lista.Where(q => q.IdEmpresa == item.IdEmpresa && q.IdSucursal == item.IdSucursal && q.IdBodega == item.IdBodega && q.Fecha == item.Fecha && q.cantidad < 0).ToList())
                    {
                        in_Ing_Egr_Inven_det Entity_det = new in_Ing_Egr_Inven_det
                        {
                            IdEmpresa         = Entity_cab.IdEmpresa,
                            IdSucursal        = Entity_cab.IdSucursal,
                            IdMovi_inven_tipo = Entity_cab.IdMovi_inven_tipo,
                            IdNumMovi         = Entity_cab.IdNumMovi,
                            Secuencia         = sec++,
                            IdBodega          = mov.IdBodega,
                            IdProducto        = mov.IdProducto,
                            dm_cantidad       = mov.cantidad,
                            dm_stock_actu     = 0,
                            dm_stock_ante     = 0,
                            dm_observacion    = "",
                            dm_precio         = 0,
                            mv_costo          = mov.do_precioFinal,
                            dm_peso           = 0,
                            IdCentroCosto     = mov.IdCentroCosto,
                            IdCentroCosto_sub_centro_costo = mov.IdCentroCosto_sub_centro_costo,
                            IdEstadoAproba               = "PEND",
                            IdUnidadMedida               = mov.IdUnidadMedida,
                            IdEmpresa_oc                 = mov.IdEmpresa_oc,
                            IdSucursal_inv               = mov.IdSucursal_oc,
                            IdOrdenCompra                = mov.IdOrdenCompra,
                            Secuencia_oc                 = mov.secuencia_oc,
                            Motivo_Aprobacion            = "Aprobación movil",
                            dm_cantidad_sinConversion    = mov.cantidad,
                            IdUnidadMedida_sinConversion = mov.IdUnidadMedida,
                            mv_costo_sinConversion       = mov.do_precioFinal,
                            IdMotivo_Inv                 = null
                        };
                        db_inv.in_Ing_Egr_Inven_det.Add(Entity_det);

                        tbl_movimientos_det_apro Entity_apro = new tbl_movimientos_det_apro
                        {
                            IdSincronizacion  = mov.IdSincronizacion,
                            IdSecuencia       = mov.IdSecuencia,
                            IdEmpresa         = mov.IdEmpresa,
                            IdSucursal        = mov.IdSucursal,
                            IdMovi_inven_tipo = Entity_cab.IdMovi_inven_tipo,
                            IdNumMovi         = Entity_cab.IdNumMovi,
                            Secuencia         = Entity_det.Secuencia
                        };
                        db_mobile.tbl_movimientos_det_apro.Add(Entity_apro);

                        var Entity_sinc = db_mobile.tbl_movimientos_det.Where(q => q.IdSincronizacion == mov.IdSincronizacion && q.IdSecuencia == mov.IdSecuencia).FirstOrDefault().Aprobado = true;
                    }
                    #endregion
                    db_inv.SaveChanges();
                    db_mobile.SaveChanges();
                    db_inv.spINV_aprobacion_movimiento(Entity_cab.IdEmpresa, Entity_cab.IdSucursal, Entity_cab.IdMovi_inven_tipo, Entity_cab.IdBodega, Entity_cab.IdNumMovi);
                }
                #endregion

                return(true);
            }
            catch (Exception)
            {
                db_inv.Dispose();
                db_mobile.Dispose();
                throw;
            }
        }
예제 #4
0
        public List <tbl_subcentro_Info> get_list(int IdEmpresa, bool mostrar_no_asignados)
        {
            try
            {
                List <tbl_subcentro_Info> Lista;

                EntitiesDBConta Context_g = new EntitiesDBConta();
                List <ct_centro_costo_sub_centro_costo_Info> lst_subcentro = (from b in Context_g.ct_centro_costo_sub_centro_costo
                                                                              join s in Context_g.ct_centro_costo
                                                                              on new { b.IdEmpresa, b.IdCentroCosto } equals new { s.IdEmpresa, s.IdCentroCosto }
                                                                              where b.IdEmpresa == IdEmpresa
                                                                              select new ct_centro_costo_sub_centro_costo_Info
                {
                    IdEmpresa = b.IdEmpresa,
                    IdCentroCosto = b.IdCentroCosto,
                    IdCentroCosto_sub_centro_costo = b.IdCentroCosto_sub_centro_costo,
                    nom_Centro_costo = s.Centro_costo,
                    NomSubCentroCosto = b.Centro_costo,
                    mobile_cod_produccion = b.mobile_cod_produccion
                }).ToList();
                Context_g.Dispose();
                Entities_mobileSCI context_m = new Entities_mobileSCI();

                List <tbl_subcentro_Info> lst_filtro = (from q in context_m.tbl_subcentro
                                                        where q.IdEmpresaSCI == IdEmpresa
                                                        select new tbl_subcentro_Info
                {
                    IdEmpresa = q.IdEmpresa,
                    IdCentroCosto = q.IdCentroCosto,
                    IdCentroCosto_sub_centro_costo = q.IdCentroCosto_sub_centro_costo,
                }).ToList();



                if (mostrar_no_asignados)
                {
                    Lista = (from q in lst_subcentro
                             join b in lst_filtro
                             on new { q.IdEmpresa, q.IdCentroCosto, q.IdCentroCosto_sub_centro_costo } equals new { b.IdEmpresa, b.IdCentroCosto, b.IdCentroCosto_sub_centro_costo }
                             into gr
                             from p in gr.DefaultIfEmpty()
                             where q.IdEmpresa == IdEmpresa
                             select new tbl_subcentro_Info
                    {
                        IdEmpresa = q.IdEmpresa,
                        IdCentroCosto = q.IdCentroCosto,
                        IdCentroCosto_sub_centro_costo = q.IdCentroCosto_sub_centro_costo,
                        nom_centro = q.nom_Centro_costo,
                        nom_subcentro = q.NomSubCentroCosto,
                        seleccionado = p == null ? false : true,
                        mobile_cod_produccion = q.mobile_cod_produccion
                    }).ToList();
                }
                else
                {
                    Lista = (from q in lst_filtro
                             join b in lst_subcentro
                             on new { q.IdEmpresa, q.IdCentroCosto, q.IdCentroCosto_sub_centro_costo } equals new { b.IdEmpresa, b.IdCentroCosto, b.IdCentroCosto_sub_centro_costo }
                             into gr
                             from p in gr.DefaultIfEmpty()
                             where q.IdEmpresa == IdEmpresa
                             select new tbl_subcentro_Info
                    {
                        IdEmpresa = q.IdEmpresa,
                        IdCentroCosto = q.IdCentroCosto,
                        IdCentroCosto_sub_centro_costo = q.IdCentroCosto_sub_centro_costo,
                        nom_centro = p.nom_Centro_costo,
                        nom_subcentro = p.NomSubCentroCosto,
                        seleccionado = true,
                        mobile_cod_produccion = p.mobile_cod_produccion
                    }).ToList();
                }
                context_m.Dispose();
                return(Lista);
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #5
0
        public List <tbl_bodega_Info> get_list(int IdEmpresa, bool mostrar_no_asignados)
        {
            try
            {
                List <tbl_bodega_Info> Lista;

                EntitiesGeneral       Context_g  = new EntitiesGeneral();
                List <tb_Bodega_Info> lst_bodega = (from b in Context_g.tb_bodega
                                                    join s in Context_g.tb_sucursal
                                                    on new { b.IdEmpresa, b.IdSucursal } equals new { s.IdEmpresa, s.IdSucursal }
                                                    where b.IdEmpresa == IdEmpresa
                                                    select new tb_Bodega_Info
                {
                    IdEmpresa = b.IdEmpresa,
                    IdSucursal = b.IdSucursal,
                    IdBodega = b.IdBodega,
                    NomSucursal = s.Su_Descripcion,
                    bo_Descripcion = b.bo_Descripcion
                }).ToList();
                Context_g.Dispose();
                Entities_mobileSCI context_m = new Entities_mobileSCI();

                List <tbl_bodega_Info> lst_filtro = (from q in context_m.tbl_bodega
                                                     where q.IdEmpresaSCI == IdEmpresa
                                                     select new tbl_bodega_Info
                {
                    IdEmpresa = q.IdEmpresa,
                    IdSucursal = q.IdSucursal,
                    IdBodega = q.IdBodega,
                }).ToList();



                if (mostrar_no_asignados)
                {
                    Lista = (from q in lst_bodega
                             join b in lst_filtro
                             on new { q.IdEmpresa, q.IdSucursal, q.IdBodega } equals new { b.IdEmpresa, b.IdSucursal, b.IdBodega }
                             into gr
                             from p in gr.DefaultIfEmpty()
                             where q.IdEmpresa == IdEmpresa
                             select new tbl_bodega_Info
                    {
                        IdEmpresa = q.IdEmpresa,
                        IdSucursal = q.IdSucursal,
                        IdBodega = q.IdBodega,
                        nom_sucursal = q.NomSucursal,
                        nom_bodega = q.bo_Descripcion,
                        seleccionado = p == null ? false : true
                    }).ToList();
                }
                else
                {
                    Lista = (from q in lst_filtro
                             join b in lst_bodega
                             on new { q.IdEmpresa, q.IdSucursal, q.IdBodega } equals new { b.IdEmpresa, b.IdSucursal, b.IdBodega }
                             into gr
                             from p in gr.DefaultIfEmpty()
                             where q.IdEmpresa == IdEmpresa
                             select new tbl_bodega_Info
                    {
                        IdEmpresa = q.IdEmpresa,
                        IdSucursal = q.IdSucursal,
                        IdBodega = q.IdBodega,
                        nom_sucursal = p.NomSucursal,
                        nom_bodega = p.bo_Descripcion,
                        seleccionado = true
                    }).ToList();
                }
                context_m.Dispose();
                return(Lista);
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #6
0
        public List <tbl_producto_Info> get_list(int IdEmpresa, bool mostrar_no_asignados)
        {
            try
            {
                List <tbl_producto_Info> Lista;

                EntitiesInventario      Context_g    = new EntitiesInventario();
                List <in_Producto_Info> lst_producto = (from p in Context_g.in_Producto
                                                        join c in Context_g.in_categorias
                                                        on new { p.IdEmpresa, p.IdCategoria } equals new { c.IdEmpresa, c.IdCategoria }
                                                        join l in Context_g.in_linea
                                                        on new { p.IdEmpresa, p.IdCategoria, p.IdLinea } equals new { l.IdEmpresa, l.IdCategoria, l.IdLinea }
                                                        where p.IdEmpresa == IdEmpresa
                                                        select new in_Producto_Info
                {
                    IdEmpresa = p.IdEmpresa,
                    IdProducto = p.IdProducto,
                    pr_descripcion = p.pr_descripcion,
                    nom_Categoria = c.ca_Categoria,
                    nom_Linea = l.nom_linea,
                    mobile_cod_produccion = p.mobile_cod_produccion
                }).ToList();
                Context_g.Dispose();
                Entities_mobileSCI context_m = new Entities_mobileSCI();

                List <tbl_producto_Info> lst_filtro = (from q in context_m.tbl_producto
                                                       where q.IdEmpresaSCI == IdEmpresa
                                                       select new tbl_producto_Info
                {
                    IdEmpresa = q.IdEmpresa,
                    IdProducto = q.IdProducto,
                }).ToList();



                if (mostrar_no_asignados)
                {
                    Lista = (from q in lst_producto
                             join b in lst_filtro
                             on new { q.IdEmpresa, q.IdProducto } equals new { b.IdEmpresa, b.IdProducto }
                             into gr
                             from p in gr.DefaultIfEmpty()
                             where q.IdEmpresa == IdEmpresa
                             select new tbl_producto_Info
                    {
                        IdEmpresa = q.IdEmpresa,
                        IdProducto = q.IdProducto,
                        nom_producto = q.pr_descripcion,
                        seleccionado = p == null ? false : true,
                        nom_categoria = q.nom_Categoria,
                        nom_linea = q.nom_Linea,
                        mobile_cod_produccion = q.mobile_cod_produccion
                    }).ToList();
                }
                else
                {
                    Lista = (from q in lst_filtro
                             join b in lst_producto
                             on new { q.IdEmpresa, q.IdProducto } equals new { b.IdEmpresa, b.IdProducto }
                             into gr
                             from p in gr.DefaultIfEmpty()
                             where q.IdEmpresa == IdEmpresa
                             select new tbl_producto_Info
                    {
                        IdEmpresa = q.IdEmpresa,
                        IdProducto = q.IdProducto,
                        nom_producto = p.pr_descripcion,
                        seleccionado = true,
                        nom_categoria = p.nom_Categoria,
                        nom_linea = p.nom_Linea,
                        mobile_cod_produccion = p.mobile_cod_produccion
                    }).ToList();
                }

                context_m.Dispose();
                return(Lista);
            }
            catch (Exception)
            {
                throw;
            }
        }