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); }
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); }
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); }
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); }
public static bool Eliminar(int?itemId) { using (var conexion = new DigitalServicesDB()) { try { return(Eliminar(Buscar(itemId))); } catch (Exception) { throw; } } return(false); }
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); }
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); }
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); }
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); }
public static List <FacturaDetalles> Listar() { List <FacturaDetalles> listado = null; using (var conexion = new DigitalServicesDB()) { try { listado = conexion.FaturaDetalle.ToList(); } catch (Exception) { throw; } } return(listado); }
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); }
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); }
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); }
public static List <Usuarios> Listar() { List <Usuarios> listado = null; using (var conexion = new DigitalServicesDB()) { try { listado = conexion.Usuarios.ToList(); } catch (Exception) { throw; } } return(listado); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }