예제 #1
0
        public IEnumerable <TODisponible> GetDisponibles(int esp_cont, int pro_cont, int year, int month, int day)
        {
            var      ocupados = daoAgenda.GetOcupados(emp_codi, esp_cont, year, month, day);
            DateTime fechaMin = new DateTime();
            DateTime fechaMax = new DateTime();
            DateTime ahora    = DateTime.Now;

            daoAgenda.GetFechaMinMax(emp_codi, year, month, day, esp_cont, out fechaMin, out fechaMax);
            var producto = daoProducto.GetProducto(emp_codi, pro_cont);

            if (fechaMin == DateTime.MinValue)
            {
                fechaMin = new DateTime(year, month, day);
                //fechaMax = new DateTime(year, month, day, 23, 59, 59);
                fechaMax = new DateTime(year, month, day);
            }

            List <TODisponible> listItems = new List <TODisponible>();

            for (DateTime i = fechaMin; i < fechaMax && producto != null && producto.Pro_dmin > 0; i = i.AddMinutes(producto.Pro_dmin))
            {
                TODisponible item = new TODisponible();
                item.FechaInicio = i;
                item.FechaFin    = i.AddMinutes(producto.Pro_dmin);

                if (item.FechaInicio > ahora)
                {
                    listItems.Add(item);
                }
            }

            //cruzar lista horario del espacio con las reservas de este
            //return (start1 < end2 && start2 < end1) ||
            //(start1 == start2 && (start1 == end1 || start2 == end2));
            foreach (var itemHorario in listItems)
            {
                foreach (var itemOcupado in ocupados)
                {
                    if ((itemHorario.FechaInicio < itemOcupado.Res_fina && itemOcupado.Res_fini <= itemHorario.FechaFin) ||
                        (itemHorario.FechaInicio == itemOcupado.Res_fini && itemHorario.FechaFin == itemOcupado.Res_fina))
                    {
                        itemHorario.Estado = 1;
                        break;
                    }
                    else
                    {
                        itemHorario.Estado = 0;
                    }
                }
            }
            var ret = listItems.Where(x => x.Estado == 0);

            return(ret);
        }
예제 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                try
                {
                    string query = null;


                    if (Request.QueryString.AllKeys.Contains("id"))
                    {
                        query = Request.QueryString["id"].ToUpper();
                    }
                    DAOProducto daoprod = new DAOProducto();
                    Producto    prod    = daoprod.GetProducto(query);

                    List <Producto> listado = new List <Producto>();
                    listado.Add(prod);

                    repetidorProducto.DataSource = listado;
                    repetidorProducto.DataBind();
                }
                catch
                {
                }
            }
        }
예제 #3
0
        protected void repetidorProducto_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            int cantidad = Convert.ToInt32(Request.Form["cantidadProducto"].ToString());

            string id = e.CommandArgument.ToString();

            if (Session["carro"] == null)
            {
                List <DetallePedido> carrito = new List <DetallePedido>();
                DAOProducto          prod    = new DAOProducto();

                Producto      producto = prod.GetProducto(id);
                DetallePedido detalle  = new DetallePedido();

                detalle.Cantidad    = cantidad;
                detalle.Precio      = producto.Precio;
                detalle.Nombre      = producto.Nombre;
                detalle.PROMO       = producto.PROMO;
                detalle.Id_Producto = producto.Id;
                detalle.Imagen      = producto.Imagen;


                carrito.Add(detalle);
                Session["carro"] = carrito;
            }

            else
            {
                List <DetallePedido> carrito = (List <DetallePedido>)HttpContext.Current.Session["carro"];
                if (carrito.Exists(x => x.Id_Producto == Convert.ToInt32(id)))
                {
                    foreach (var detallep in carrito.Where(w => w.Id_Producto == Convert.ToInt32(id)))
                    {
                        detallep.Cantidad = detallep.Cantidad + cantidad;
                    }
                }

                else
                {
                    DAOProducto   pro  = new DAOProducto();
                    Producto      prod = pro.GetProducto(id);
                    DetallePedido ped  = new DetallePedido();

                    ped.Cantidad = cantidad;
                    ped.Precio   = prod.Precio;
                    ped.Nombre   = prod.Nombre;
                    ped.PROMO    = prod.PROMO;

                    ped.Id_Producto = prod.Id;
                    ped.Imagen      = prod.Imagen;

                    carrito.Add(ped);
                    Session["carro"] = carrito;
                }
            }
            Response.Redirect("Default.aspx");
        }
        private void PintarOrden()
        {
            Cliente cliente = null;

            if (Session["cliente"] != null)
            {
                cliente = (Cliente)Session["cliente"];
            }


            DAOPedido daoPedido = new DAOPedido();
            Pedido    ped       = daoPedido.GetPedidoActual(cliente.Id);

            //Pedido ped = cliente.Pedidos.OrderByDescending(x => x.Id).FirstOrDefault();
            if (ped.Status == 0 || ped.Status == 1)
            {
                if (ped.Status == 1) //Aceptado
                {
                    Buttonprueba.Visible = false;
                }


                DAOProducto prod = new DAOProducto();

                List <DetallePedido> detalles = ped.Detalles;

                for (var i = 0; i < detalles.Count; i++)
                {
                    Producto item = prod.GetProducto(detalles[i].Id_Producto.ToString());
                    detalles[i].Imagen = item.Imagen;
                }

                repetidorDetalles.DataSource = detalles;
                repetidorDetalles.DataBind();

                Decimal total = detalles.Select(x => x.Costo).Sum();
                LiteralSubTotal.Text = total.ToString();
                LiteralTotal.Text    = total.ToString();

                literalFechaCreacion.Text = ped.Fecha_Pedido.ToString(CultureInfo.GetCultureInfo("es-MX")); //"dddd, dd MMMM yyyy, hh:mm tt",
                int entregado = DateTime.Compare(ped.Fecha_Estimada, DateTime.MinValue);

                switch (entregado)
                {
                case 0:
                    literalFechaEntrega.Text = "Fecha por confirmar.";
                    break;

                case -1:
                    literalFechaEntrega.Text = ped.Fecha_Estimada.ToString(CultureInfo.GetCultureInfo("es-MX"));
                    break;
                }


                //Fecha_Creacion = ped.Fecha_Pedido.ToString("dddd, dd MMMM yyyy, hh:mm tt");
                //Fecha_Entrega = ped.Fecha_Entrega.ToString("dddd, dd MMMM yyyy, hh:mm tt");
                switch (ped.Status)
                {
                case 0:
                    literalStatusOrden.Text = "Pedido pendiente de confirmación.";
                    //Status = "Pedido pendiente de confirmación.";
                    break;

                case 1:
                    literalStatusOrden.Text = "Pedido aceptado.";
                    //Status = "Pedido aceptado.";
                    break;
                }

                literalNumeroOrden.Text = Convert.ToString(ped.Id);
                //Orden = Convert.ToString(ped.Id);
                this.latitud  = Convert.ToDecimal(ped.Latitud);
                this.longitud = Convert.ToDecimal(ped.Longitud);
            }

            else
            {
                Response.Redirect("Cuenta.aspx#NoOpOrder");
            }


            //repetidorDetalles.DataSource = detalles;
            //repetidorDetalles.DataBind();

            //Decimal total = detalles.Select(x => x.Costo).Sum();

            //LiteralSubTotal.Text = total.ToString();
            //LiteralTotal.Text = total.ToString();
        }
예제 #5
0
        protected void RepetidorFavoritos_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            string id = e.CommandArgument.ToString();

            //Si el carro está vacio
            if (Session["carro"] == null)
            {
                List <DetallePedido> carrito = new List <DetallePedido>();


                DAOProducto   pro  = new DAOProducto();
                Producto      prod = pro.GetProducto(id);
                DetallePedido ped  = new DetallePedido();

                ped.Cantidad = 1;
                ped.Precio   = prod.Precio;
                ped.Nombre   = prod.Nombre;
                ped.PROMO    = prod.PROMO;
                ped.Costo    = prod.Precio;

                ped.Id_Producto = prod.Id;
                ped.Imagen      = prod.Imagen;


                carrito.Add(ped);
                Session["carro"] = carrito;
                //List<DetallePedido> carrito = (List<DetallePedido>)HttpContext.Current.Session["carro"];

                //Producto prod = pro.GetProducto(i);
                //DetallePedido ped = new DetallePedido();
                //ped.Cantidad = 1;
                //ped.Precio = prod.Precio;
                //ped.Nombre = prod.Nombre;
                //ped.PROMO = prod.PROMO;

                //ped.Id_Producto = prod.Id;
                //ped.Imagen = prod.Imagen;

                //ped.Costo = ped.Precio * ped.Cantidad;


                //carrito.Add(ped);

                //HttpContext.Current.Session["carro"] = carrito;
            }


            else  //si tengo carrito
            {
                List <DetallePedido> carrito = (List <DetallePedido>)HttpContext.Current.Session["carro"];

                if (carrito.Exists(x => x.Id_Producto == Convert.ToInt32(id)))
                {
                    foreach (var detallep in carrito.Where(w => w.Id_Producto == Convert.ToInt32(id)))
                    {
                        detallep.Cantidad = detallep.Cantidad + 1;
                    }
                }
                else
                {
                    DAOProducto pro  = new DAOProducto();
                    Producto    prod = pro.GetProducto(id);

                    DetallePedido ped = new DetallePedido();

                    ped.Cantidad = 1;
                    ped.Precio   = prod.Precio;
                    ped.Nombre   = prod.Nombre;
                    ped.PROMO    = prod.PROMO;
                    ped.Costo    = prod.Precio;

                    ped.Id_Producto = prod.Id;
                    ped.Imagen      = prod.Imagen;

                    carrito.Add(ped);
                    Session["carro"] = carrito;
                }
            }
            Response.Redirect(Request.RawUrl);
        }