Esempio n. 1
0
        public Boolean GrabaDB(List <in_producto_x_tb_bodega_Info> ls, int idempresa, ref string mensaje)
        {
            try
            {
                using (EntitiesInventario context = new EntitiesInventario())
                {
                    EntitiesInventario EDB = new EntitiesInventario();

                    foreach (var item in ls)
                    {
                        if (EDB.in_producto_x_tb_bodega.Count(v => v.IdEmpresa == item.IdEmpresa && v.IdSucursal == item.IdSucursal && v.IdBodega == item.IdBodega && v.IdProducto == item.IdProducto) == 0)
                        {
                            var address = new in_producto_x_tb_bodega();
                            address.IdEmpresa  = idempresa;
                            address.IdSucursal = item.IdSucursal;
                            address.IdBodega   = item.IdBodega;
                            address.IdProducto = item.IdProducto;

                            address.IdCtaCble_Vta = item.IdCtaCble_Vta;



                            address.IdCtaCble_Inven       = item.IdCtaCble_Inven;
                            address.IdCtaCble_Costo       = item.IdCtaCble_Costo;
                            address.IdCtaCble_Gasto_x_cxp = item.IdCtaCble_Gasto_x_cxp;



                            context.in_producto_x_tb_bodega.Add(address);
                            context.SaveChanges();
                        }
                    }
                    mensaje = "Grabacion ok..";
                    return(true);
                }
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now);
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                mensaje = ex.ToString() + " " + ex.Message;
                mensaje = "Error en : public Boolean GrabaDB(List<in_producto_x_tb_bodega_Info> ls, int idempresa, ref string mensaje) ...  " + ex.ToString() + " ";
                throw new Exception(mensaje);
            }
        }
        public bool modificar_Cta_Inven(in_producto_x_tb_bodega_Info info)
        {
            try
            {
                using (Entities_inventario Context = new Entities_inventario())
                {
                    in_producto_x_tb_bodega Entity = Context.in_producto_x_tb_bodega.Where(q => q.IdEmpresa == info.IdEmpresa && q.IdSucursal == info.IdSucursal && q.IdBodega == info.IdBodega && q.IdProducto == info.IdProducto).FirstOrDefault();
                    if (Entity == null)
                    {
                        return(false);
                    }

                    Entity.IdCtaCble_Inven = info.IdCtaCble_Inven;

                    Context.SaveChanges();
                }
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }