Example #1
0
 private void Detalleboleta(int idpedidoProd, int modopago, int idempleado, decimal totalpago)
 {
     using (var db = new restaurantEntities())
     {
         detalleboleta detalle = new detalleboleta();
         if (idempleado != 0)
         {
             detalle.idpedido   = idpedidoProd;
             detalle.idempleado = idempleado;
             detalle.fecha      = DateTime.Now;
             detalle.montifinal = totalpago;
             if (modopago == 7)
             {
                 detalle.observacion = "Pago que se efectuo por tarjeta de credito o paypal";
                 detalle.idmodopago  = 7;
             }
             else
             {
                 detalle.observacion = "Pago realizado al momento de la entrega del repartidor";
                 detalle.idmodopago  = 8;
             }
         }
         else
         {
             //aca poner la observacion generada desde la computadora
         }
         db.detalleboleta.Add(detalle);
         db.SaveChanges();
     }
 }
Example #2
0
        public void AgregarNuevos(List <Carrito> pedidos, int modopago)
        {
            int     idpedido = 0;
            decimal total    = 0;
            string  detalles = "Los productos que se pidieron son ";

            //concatenamos los nombres de los productos
            for (int i = 0; i < pedidos.Count; i++)
            {
                detalles += " " + pedidos[i].nombre + " ,";
            }
            using (var db = new restaurantEntities())
            {
                pedido newpedido = new pedido();
                newpedido.idcliente = 1;
                // (idcliente!=0 ? "PEDIDO HECHO POR UN EMPLEADO : "PEDIDO HECHO POR UN CLIENTE"")
                newpedido.detalle = detalles;
                db.pedido.Add(newpedido);
                db.SaveChanges();
                idpedido = newpedido.id;
                productopedido prodpedido = new productopedido();
                foreach (var item in pedidos)
                {
                    total += (item.cantidad * item.precio);
                    prodpedido.idpedido   = idpedido;
                    prodpedido.idproducto = item.idproducto;
                    prodpedido.cantidad   = item.cantidad;
                    prodpedido.tipopedido = item.tipoPedido;
                    db.productopedido.Add(prodpedido);
                    db.SaveChanges();
                }
            }
            Detalleboleta(idpedido, modopago, 1, total);
        }
Example #3
0
 public bool EliminarPP(int id)
 {
     using (var agr = new restaurantEntities())
     {
         //eliminae los registros que dependan de esta
         var s = (from tp in agr.tipoproducto
                  where tp.product.Value == id
                  select tp).FirstOrDefault <tipoproducto>();
         if (s == null)
         {
             return(false);
         }
         else
         {
             agr.tipoproducto.Remove(s);
             var idped = (from ta in agr.productopedido
                          where ta.idproducto.Value == id
                          select ta).ToList();
             foreach (var item in idped)
             {
                 agr.productopedido.Remove(item);
             }
             agr.producto.Remove(agr.producto.Find(id));
             agr.SaveChanges();
             return(true);
         }
     }
 }
Example #4
0
        public bool EliminarPedido(int id)
        {
            try
            {
                using (var db = new restaurantEntities())
                {
                    productopedido prodped  = new productopedido();
                    var            prodped1 = (from ta in db.productopedido
                                               where ta.idpedido == id
                                               select ta).ToList();
                    foreach (var item in prodped1)
                    {
                        db.productopedido.Remove(item);
                    }
                    db.SaveChanges();
                    var detalleb = (from dt in db.detalleboleta
                                    where dt.idpedido == id
                                    select dt).FirstOrDefault();
                    db.detalleboleta.Remove(detalleb);
                    db.SaveChanges();
                    db.pedido.Remove(db.pedido.Find(id));
                    db.SaveChanges();
                }
                return(true);
            }
            catch (Exception ex)
            {
                return(false);

                throw;
            }
        }
 public List <promocion> ReturnRegistros()
 {
     using (var db = new restaurantEntities())
     {
         var lst = (from d in db.promocion
                    select d).ToList();
         return(lst);
     }
 }
Example #6
0
        public List <Returnproducto_Result> Retornar()
        {
            List <Returnproducto_Result> lis = new List <Returnproducto_Result> ();

            using (var prod = new restaurantEntities())
            {
                lis = prod.Returnproducto().ToList();
                return(lis);
            }
        }
Example #7
0
        public List <ventas_Result> Retornoventas()
        {
            List <ventas_Result> venta = new List <ventas_Result>();

            using (var db = new restaurantEntities())
            {
                venta = db.ventas().ToList();
            }
            return(venta);
        }
        public List <empleado> EmpleaReturn()
        {
            List <empleado> emple = new List <empleado>();

            using (var db = new restaurantEntities())
            {
                emple = (from tt in db.empleado
                         select tt).ToList();
            }
            return(emple);
        }
Example #9
0
        public List <detalleboleta> Detallesbol()
        {
            List <detalleboleta> detalle = new List <detalleboleta>();

            using (var db = new restaurantEntities())
            {
                detalle = (from tt in db.detalleboleta
                           select tt).ToList();
            }
            return(detalle);
        }
 public void EliminarU(int id)
 {
     using (var db = new restaurantEntities())
     {
         var borrar = db.empleado.Find(id);
         if (borrar != null)
         {
             db.empleado.Remove(borrar);
         }
         db.SaveChanges();
     }
 }
 public void EliminarPromocion(int id)
 {
     try
     {
         using (var db = new restaurantEntities())
         {
             var s = (from e in db.promocion
                      where e.id == id
                      select e).FirstOrDefault <promocion>();
             db.promocion.Remove(s);
             db.SaveChanges();
         }
     }
     catch (Exception w)
     {
     }
 }
 public void Editar(string nombre, string contra, int telefono, int rol, int id)
 {
     try
     {
         using (var db = new restaurantEntities())
         {
             var nuevo = db.empleado.Find(id);
             nuevo.contrasenia    = contra;
             nuevo.Nombrecompleto = nombre;
             nuevo.telefooo       = telefono;
             nuevo.rolEmp         = rol;
             db.SaveChanges();
         }
     }
     catch (Exception e)
     {
         throw;
     }
 }
 public void AgregarPromo(int idPP, string tituloo, int cantidadd, decimal precioneww, string imageSrcc, string descripcion)
 {
     try
     {
         using (var agr = new restaurantEntities())
         {
             promocion prom = new promocion();
             prom.cantidad     = cantidadd;
             prom.idproducto   = idPP;
             prom.titulo       = tituloo;
             prom.nuevoprecio  = precioneww;
             prom.img          = imageSrcc;
             prom.descripPromo = descripcion;
             agr.promocion.Add(prom);
             agr.SaveChanges();
         }
     }
     catch (Exception ee)
     {
         throw;
     }
 }
Example #14
0
 public bool EditarP(int id, string nombre, decimal precio, int stock, byte[] imagen, int tipoP, string descripcionP, int visible)
 {
     using (var agr = new restaurantEntities())
     {
         var s = (from tp in agr.tipoproducto
                  where tp.product.Value == id
                  select tp).FirstOrDefault <tipoproducto>();
         if (s != null)
         {
             s.tipo        = tipoP;
             s.descripcion = descripcionP;
             var producer = agr.producto.Find(id);
             producer.nombre = nombre;
             producer.precio = precio;
             producer.stock  = stock;
             producer.imagen = imagen;
             agr.SaveChanges();
             return(true);
         }
         return(false);
     }
 }
Example #15
0
        //
        public void Agregar(string nombre, decimal precio, int stock, byte[] imagen, int tipoP, string descripcionP)
        {
            using (var agr = new restaurantEntities())
            {
                producto prd = new producto();
                prd.nombre = nombre;
                prd.precio = precio;
                prd.stock  = stock;
                prd.imagen = imagen;
                agr.producto.Add(prd);
                int          prs = prd.id;
                tipoproducto tip = new tipoproducto();
                tip.tipo        = tipoP;
                tip.descripcion = descripcionP;
                tip.product     = prs;
                agr.tipoproducto.Add(tip);
                agr.SaveChanges();

                /*
                 */
            }
        }
        public bool Agregar(string nombre, string contra, int telefono, int rol)
        {
            try
            {
                using (var db = new restaurantEntities())
                {
                    empleado nuevo = new empleado();
                    nuevo.contrasenia    = contra;
                    nuevo.Nombrecompleto = nombre;
                    nuevo.telefooo       = telefono;
                    nuevo.rolEmp         = rol;
                    db.empleado.Add(nuevo);
                    db.SaveChanges();
                }
                return(true);
            }
            catch (Exception e)
            {
                return(false);

                throw;
            }
        }