Exemplo n.º 1
0
        public static EncabezadoDetalle Buscar(int?facturaId)
        {
            EncabezadoDetalle factura = null;

            using (var conexion = new DigitalServicesDB())
            {
                try
                {
                    factura = new EncabezadoDetalle()
                    {
                        Encabezado = conexion.Factura.Find(facturaId)
                    };
                    if (factura.Encabezado != null)
                    {
                        factura.Detalle =
                            BLL.FacturaDetalleBLL.Listar(factura.Encabezado.IdFactura);
                    }
                    else
                    {
                        factura = null;
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(factura);
        }
Exemplo n.º 2
0
 public static bool Guardar(FacturaDetalles detalle)
 {
     using (var conexion = new DigitalServicesDB())
     {
         try
         {
             conexion.FaturaDetalle.Add(detalle);
             if (conexion.SaveChanges() > 0)
             {
                 var item = BLL.ItemsBLL.Buscar(detalle.IdItem);
                 if (item.EsArticulo == 1)
                 {
                     item.Existencia = item.Existencia - detalle.Cantidad;
                     return(BLL.ItemsBLL.Modificar(item));
                 }
                 return(true);
             }
         }
         catch (Exception)
         {
             throw;
         }
     }
     return(false);
 }
Exemplo n.º 3
0
 public static bool Modificar(FacturaDetalles detalle)
 {
     using (var conexion = new DigitalServicesDB())
     {
         try
         {
             if (Buscar(detalle.Id) != null)
             {
                 conexion.Entry(detalle).State = EntityState.Modified;
                 if (conexion.SaveChanges() > 0)
                 {
                     return(true);
                 }
             }
             else
             {
                 return(Guardar(detalle));
             }
         }
         catch (Exception)
         {
             throw;
         }
     }
     return(false);
 }
Exemplo n.º 4
0
        public static bool Eliminar(FacturaDetalles detalle)
        {
            using (var conexion = new DigitalServicesDB())
            {
                try
                {
                    var item = BLL.ItemsBLL.Buscar(detalle.IdItem);
                    int cant = detalle.Cantidad;

                    conexion.Entry(detalle).State = EntityState.Deleted;
                    if (conexion.SaveChanges() > 0)
                    {
                        if (item.EsArticulo == 1)
                        {
                            item.Existencia = item.Existencia + cant;
                            return(BLL.ItemsBLL.Modificar(item));
                        }
                        return(true);
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(false);
        }
Exemplo n.º 5
0
 public static bool Eliminar(int?itemId)
 {
     using (var conexion = new DigitalServicesDB())
     {
         try
         {
             return(Eliminar(Buscar(itemId)));
         }
         catch (Exception)
         {
             throw;
         }
     }
     return(false);
 }
Exemplo n.º 6
0
        public static Facturas BuscarEncabezado(int?facturaId)
        {
            Facturas factura = null;

            using (var conexion = new DigitalServicesDB())
            {
                try
                {
                    factura = conexion.Factura.Find(facturaId);
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(factura);
        }
Exemplo n.º 7
0
        public static Usuarios Buscar(int?usuarioId)
        {
            Usuarios usuario = null;

            using (var conexion = new DigitalServicesDB())
            {
                try
                {
                    usuario = conexion.Usuarios.Find(usuarioId);
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(usuario);
        }
Exemplo n.º 8
0
        public static Items Buscar(int?itemId)
        {
            Items item = null;

            using (var conexion = new DigitalServicesDB())
            {
                try
                {
                    item = conexion.Items.Find(itemId);
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(item);
        }
Exemplo n.º 9
0
        public static List <Clientes> Listar()
        {
            List <Clientes> listado = null;

            using (var conexion = new DigitalServicesDB())
            {
                try
                {
                    listado = conexion.Cliente.OrderBy(c => c.Nombres).ToList();
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(listado);
        }
Exemplo n.º 10
0
        public static List <FacturaDetalles> Listar()
        {
            List <FacturaDetalles> listado = null;

            using (var conexion = new DigitalServicesDB())
            {
                try
                {
                    listado = conexion.FaturaDetalle.ToList();
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(listado);
        }
Exemplo n.º 11
0
        public static FacturaDetalles Buscar(int?detalleId)
        {
            FacturaDetalles detail = null;

            using (var conexion = new DigitalServicesDB())
            {
                try
                {
                    detail = conexion.FaturaDetalle.Find(detalleId);
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(detail);
        }
Exemplo n.º 12
0
        public static Clientes Buscar(int?clienteId)
        {
            Clientes cliente = null;

            using (var conexion = new DigitalServicesDB())
            {
                try
                {
                    cliente = conexion.Cliente.Find(clienteId);
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(cliente);
        }
Exemplo n.º 13
0
        public static List <Items> Listar()
        {
            List <Items> listado = null;

            using (var conexion = new DigitalServicesDB())
            {
                try
                {
                    listado = conexion.Items.OrderBy(i => i.Descripcion).ToList();
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(listado);
        }
Exemplo n.º 14
0
        public static List <Usuarios> Listar()
        {
            List <Usuarios> listado = null;

            using (var conexion = new DigitalServicesDB())
            {
                try
                {
                    listado = conexion.Usuarios.ToList();
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(listado);
        }
Exemplo n.º 15
0
        public static List <Facturas> Listar()
        {
            List <Facturas> listado = null;

            using (var conexion = new DigitalServicesDB())
            {
                try
                {
                    listado = conexion.Factura.OrderBy(f => f.Fecha).ToList();
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(listado);
        }
Exemplo n.º 16
0
        public static List <Facturas> Listar(Filtro filtro)
        {
            List <Facturas> listado = null;

            using (var conexion = new DigitalServicesDB())
            {
                try
                {
                    listado = conexion.Factura.Where(f => f.Fecha.CompareTo(filtro.Desde) >= 0 &&
                                                     f.Fecha.CompareTo(filtro.Hasta) <= 0).OrderBy(f => f.Fecha).ToList();
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(listado);
        }
Exemplo n.º 17
0
 public static bool Modificar(Items item)
 {
     using (var conexion = new DigitalServicesDB())
     {
         try
         {
             conexion.Entry(item).State = System.Data.Entity.EntityState.Modified;
             if (conexion.SaveChanges() > 0)
             {
                 return(true);
             }
         }
         catch (Exception)
         {
             throw;
         }
     }
     return(false);
 }
Exemplo n.º 18
0
 public static bool Guardar(Items item)
 {
     using (var conexion = new DigitalServicesDB())
     {
         try
         {
             conexion.Items.Add(item);
             if (conexion.SaveChanges() > 0)
             {
                 return(true);
             }
         }
         catch (Exception)
         {
             throw;
         }
     }
     return(false);
 }
Exemplo n.º 19
0
        public static List <FacturaDetalles> Listar(int?facturaId)
        {
            List <FacturaDetalles> listado = null;

            using (var conexion = new DigitalServicesDB())
            {
                try
                {
                    listado = conexion.FaturaDetalle.
                              Where(d => d.IdFactura == facturaId).
                              OrderBy(d => d.Id).ToList();
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(listado);
        }
Exemplo n.º 20
0
 public static bool Modificar(Usuarios usuario)
 {
     using (var conexion = new DigitalServicesDB())
     {
         try
         {
             conexion.Entry(usuario).State = EntityState.Modified;
             if (conexion.SaveChanges() > 0)
             {
                 return(true);
             }
         }
         catch (Exception)
         {
             throw;
         }
     }
     return(false);
 }
Exemplo n.º 21
0
 public static bool Guardar(Clientes cliente)
 {
     using (var conexion = new DigitalServicesDB())
     {
         try
         {
             conexion.Cliente.Add(cliente);
             if (conexion.SaveChanges() > 0)
             {
                 return(true);
             }
         }
         catch (Exception)
         {
             throw;
         }
     }
     return(false);
 }
Exemplo n.º 22
0
 public static bool Eliminar(Clientes cliente)
 {
     using (var conexion = new DigitalServicesDB())
     {
         try
         {
             conexion.Entry(cliente).State = EntityState.Deleted;
             if (conexion.SaveChanges() > 0)
             {
                 return(true);
             }
         }
         catch (Exception)
         {
             throw;
         }
     }
     return(false);
 }
Exemplo n.º 23
0
 public static bool ModificarEncabezado(int?facturaId)
 {
     using (var conexion = new DigitalServicesDB())
     {
         try
         {
             conexion.Entry(BuscarEncabezado(facturaId)).State = EntityState.Modified;
             if (conexion.SaveChanges() > 0)
             {
                 return(true);
             }
         }
         catch (Exception)
         {
             throw;
         }
     }
     return(false);
 }
Exemplo n.º 24
0
        public static bool Guardar(List <FacturaDetalles> detalles)
        {
            bool resultado = false;

            using (var conexion = new DigitalServicesDB())
            {
                try
                {
                    foreach (FacturaDetalles detail in detalles)
                    {
                        resultado = Guardar(detail);
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(resultado);
        }
Exemplo n.º 25
0
        public static bool Eliminar(EncabezadoDetalle factura)
        {
            bool resultado = false;

            using (var conexion = new DigitalServicesDB())
            {
                try
                {
                    if (BLL.FacturaDetalleBLL.Eliminar(factura.Detalle))
                    {
                        conexion.Entry(factura.Encabezado).State = EntityState.Deleted;
                        resultado = conexion.SaveChanges() > 0;
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(resultado);
        }
Exemplo n.º 26
0
        public static bool Guardar(EncabezadoDetalle factura)
        {
            bool resultado = false;

            using (var conexion = new DigitalServicesDB())
            {
                try
                {
                    conexion.Factura.Add(factura.Encabezado);
                    if (conexion.SaveChanges() > 0)
                    {
                        resultado = BLL.FacturaDetalleBLL.Guardar(factura.Detalle);
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(resultado);
        }
Exemplo n.º 27
0
        public static bool Modificar(EncabezadoDetalle factura)
        {
            bool resultado = false;

            using (var conexion = new DigitalServicesDB())
            {
                try
                {
                    conexion.Entry(factura.Encabezado).State = EntityState.Modified;
                    if (conexion.SaveChanges() > 0)
                    {
                        resultado = FacturaDetalleBLL.Modificar(factura.Detalle);
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(resultado);
        }