Example #1
0
 public void Insertar(DETALLE_VENTA P)
 {
     try
     {
         new DatDetalle_Venta().Insertar(P);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Example #2
0
 public void Actualizar(DETALLE_VENTA P)
 {
     try
     {
         new DatDetalle_Venta().Actualizar(P);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Example #3
0
 public void Insertar(DETALLE_VENTA P)
 {
     try
     {
         ContextoDB ct = new ContextoDB();
         ct.DETALLE_VENTA.Add(P);
         ct.SaveChanges();
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Example #4
0
        public bool Delete()
        {
            try
            {
                DETALLE_VENTA dv = CommonBC.DBConexion.DETALLE_VENTA.First(d => d.ID == this.Id);
                CommonBC.DBConexion.DETALLE_VENTA.Remove(dv);
                CommonBC.DBConexion.SaveChanges();

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Example #5
0
 public bool Read()
 {
     try
     {
         DETALLE_VENTA dv = CommonBC.DBConexion.DETALLE_VENTA.First(d => d.ID == this.Id);
         this.Cantidad   = (int)dv.CANTIDAD;
         this.VentaId    = (int)dv.VENTA_ID;
         this.ProductoId = (int)dv.PRODUCTO_ID;
         this.Precio     = (int)dv.PRECIO;
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Example #6
0
        public DETALLE_VENTA GetById(int CAsiento, int CVenta)
        {
            try
            {
                ContextoDB    ct            = new ContextoDB();
                DETALLE_VENTA DETALLE_VENTA = (from x in ct.DETALLE_VENTA
                                               where x.CASiento == CAsiento && x.CVenta == CVenta
                                               select x).FirstOrDefault();

                return(DETALLE_VENTA);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Example #7
0
 public void Eliminar(int CAsiento, int CVenta)
 {
     try
     {
         ContextoDB    ct            = new ContextoDB();
         DETALLE_VENTA DETALLE_VENTA = (from x in ct.DETALLE_VENTA
                                        where x.CASiento == CAsiento && x.CVenta == CVenta
                                        select x).FirstOrDefault();
         if (DETALLE_VENTA != null)
         {
             ct.DETALLE_VENTA.Remove(DETALLE_VENTA);
             ct.SaveChanges();
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Example #8
0
        public bool Update()
        {
            try
            {
                DETALLE_VENTA dv = CommonBC.DBConexion.DETALLE_VENTA.First(d => d.ID == this.Id);
                dv.CANTIDAD    = this.Cantidad;
                dv.VENTA_ID    = this.VentaId;
                dv.PRODUCTO_ID = this.ProductoId;
                dv.PRECIO      = this.Precio;

                CommonBC.DBConexion.Entry(dv).State = System.Data.EntityState.Modified;
                CommonBC.DBConexion.SaveChanges();

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Example #9
0
        public bool CrearDetalleVenta()
        {
            try
            {
                DETALLE_VENTA dv = new DETALLE_VENTA();
                dv.CANTIDAD    = this.Cantidad;
                dv.VENTA_ID    = this.VentaId;
                dv.PRODUCTO_ID = this.ProductoId;
                dv.PRECIO      = this.Precio;

                CommonBC.DBConexion.DETALLE_VENTA.Add(dv);
                CommonBC.DBConexion.SaveChanges();

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Example #10
0
        public void Actualizar(DETALLE_VENTA P)
        {
            try
            {
                ContextoDB    ct            = new ContextoDB();
                DETALLE_VENTA DETALLE_VENTA = (from x in ct.DETALLE_VENTA
                                               where x.CASiento == P.CASiento && x.CVenta == P.CVenta
                                               select x).FirstOrDefault();

                if (DETALLE_VENTA != null)
                {
                    ct.Entry(DETALLE_VENTA).CurrentValues.SetValues(P);
                    ct.SaveChanges();
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Example #11
0
        public respuesta Agregar(long _idProducto, int _cantidad, int _subtotal, long _idVenta)
        {
            respuesta r;

            try
            {
                using (POS.DBModel.negocioEntities db = new POS.DBModel.negocioEntities())
                {
                    try
                    {
                        DETALLE_VENTA obj = new DETALLE_VENTA();
                        obj.fk_producto = _idProducto;
                        obj.cantidad    = _cantidad;
                        obj.subtotal    = _subtotal;
                        obj.fk_venta    = _idVenta;

                        db.DETALLE_VENTA.Add(obj);
                        int           afected       = db.SaveChanges();
                        DETALLE_VENTA detalle_venta = (DETALLE_VENTA)obj;
                        if (afected == 1)
                        {
                            r = new respuesta(true, "VENTA GUARDADA CORRECTAMENTE", obj);
                        }
                        else
                        {
                            r = new respuesta(false, "NO SE PUDO GUARDAR LA VENTA");
                        }
                    }
                    catch (Exception ex)
                    {
                        r = new respuesta(false, "ERROR AL CREAR VENTA", ex.Message.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                r = new respuesta(false, "CONEXION CON LA DB RECHAZADA", ex.Message.ToString());
            }
            return(r);
        }