예제 #1
0
    private FacturaActualizada InformacionReporte()
    {
        /// List<Domicilio> FacturaC = new DAOFactura().facturaCompra(int.Parse(Session["id_usuario"].ToString()));
        DomicilioU domi      = new DAOFactura().obtenerDireccion(int.Parse(Session["idDomicilio"].ToString()));
        string     domicilio = domi.Direccion;
        // Pedido pedido = new DAOProducto().obtenerUltimoPedido(int.Parse(Session["id_usuario"].ToString()));
        // int idPedido = pedido.Id;

        DetallePedido nom = new DAOProducto().obtenerDatosFactura(int.Parse(Session["id_pedido"].ToString()), int.Parse(Session["id_usuario"].ToString()), domicilio);

        // FacturaCompra informe = new FacturaCompra();
        FacturaActualizada informe2   = new FacturaActualizada();
        DataTable          datosFinal = informe2.FacturaA;
        DataRow            fila;

        if (nom != null)
        {
            foreach (DetallePedido registro in JsonConvert.DeserializeObject <List <DetallePedido> >(nom.Detalle))
            {
                fila = datosFinal.NewRow();
                fila["nombreusuario"]  = nom.Nombre_usuario;
                fila["nombreproducto"] = registro.NombreProducto;
                fila["precio"]         = registro.Precio;
                fila["cantidad"]       = registro.Cantidad;
                fila["total"]          = registro.Total;
                fila["pago"]           = nom.Form;
                fila["direccion"]      = nom.Direccion;
                fila["factura"]        = nom.Id_pedido;
                fila["imagen"]         = obtenerImagen(registro.Imagen);
                fila["fecha"]          = nom.Fecha;
                datosFinal.Rows.Add(fila);
            }
        }
        return(informe2);
    }
예제 #2
0
    public void detallepedido()
    {
        string        total   = (new DAOProducto().obtenerProductosCarrito(int.Parse(Session["id_usuario"].ToString())).Sum(x => x.Total)).ToString();
        DetallePedido detalle = new DetallePedido();

        detalle.Id_usuario = int.Parse(Session["id_usuario"].ToString());
        detalle.Cantidad   = int.Parse(new DAOProducto().obtenerCantidadProductoxUser(((EPersona)Session["validar_sesion_usuario"]).Id).ToString());
        detalle.Fecha      = DateTime.Now;
        detalle.Total      = long.Parse(total);
        List <Pedido> P = new List <Pedido>();

        P = (new DAOFactura().ObtenerPedidoU(int.Parse(Session["id_usuario"].ToString())).ToList());
        int idFactura = P[0].Id;

        detalle.Id_pedido = idFactura;
        List <Carrito> listaP = new DAOProducto().obtenerProductosCarrito(int.Parse(Session["id_usuario"].ToString()));

        detalle.Detalle = JsonConvert.SerializeObject(listaP, Formatting.Indented, new JsonSerializerSettings
        {
            NullValueHandling = NullValueHandling.Ignore
        });
        detalle.Idpago       = int.Parse(tipo_pago.SelectedValue);
        Session["id_pedido"] = idFactura;
        new DAOFactura().InsertarDetallePedido(detalle);
        Response.Redirect("FacturaCompra.aspx");
    }
예제 #3
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
                {
                }
            }
        }
예제 #4
0
        public JsonResult BuscarNombre(string id)
        {
            try
            {
                List <ProductoE> lista = new List <ProductoE>();
                ProductoE        p     = new ProductoE();
                using (EntitiesProductos db = new EntitiesProductos())
                {
                    if (id == null)
                    {
                        lista = new DAOProducto().ListaProducto();
                    }
                    else
                    {
                        lista = new DAOProducto().BuscarNombre(id);
                    }

                    return(Json(new { r = "ok", listaB = lista }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                return(Json(ex.Message, JsonRequestBehavior.AllowGet));
            }
        }
예제 #5
0
        private void Editar_Load(object sender, EventArgs e)
        {
            Producto prod = new DAOProducto().getOne(idprod);

            txtNombre.Text      = prod.Nombre;
            txtPrecio.Text      = "" + prod.Precio;
            txtDescripcion.Text = prod.Descripcion;
            txtCategoria.Text   = prod.Categoria;
        }
예제 #6
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");
        }
    protected void btn_añadir_Click(object sender, EventArgs e)
    {
        ClientScriptManager cm = this.ClientScript;
        string seguridad       = (new DAOEmpleado().obtenerProductosCarritoE(int.Parse(Session["id_empleado"].ToString())).Sum(x => x.Total).ToString());
        long   verificar       = long.Parse(seguridad);

        if (verificar == 0)
        {
            return;
        }
        else
        {
            List <CarritoE> car = new DAOEmpleado().obtenerProductosCarritoE(int.Parse(Session["id_empleado"].ToString()));
            for (int i = 0; i <= car[i].Cantidad; i++)
            {
                Producto p   = new DAOProducto().VerificarProducto(car[i].Producto_id);
                string   nom = car[i].NombreProducto;
                if (car[i].Cantidad <= p.Cantidad)
                {
                    string  total  = string.Format(new DAOEmpleado().obtenerProductosCarritoE(int.Parse(Session["id_empleado"].ToString())).Sum(x => x.Total).ToString());
                    PedidoM pedido = new PedidoM();
                    pedido.Id_mesero = int.Parse(Session["id_empleado"].ToString());
                    pedido.Id_mesa   = int.Parse(tipo_mesa.SelectedValue);
                    pedido.Total     = long.Parse(total);
                    pedido.Fecha     = DateTime.Now;
                    List <CarritoE> lista = new DAOEmpleado().obtenerProductosCarritoE(int.Parse(Session["id_empleado"].ToString()));
                    pedido.Detalle = JsonConvert.SerializeObject(lista, Formatting.Indented, new JsonSerializerSettings
                    {
                        NullValueHandling = NullValueHandling.Ignore
                    });
                    pedido.Id_pago  = int.Parse(tipo_pago.SelectedValue);
                    pedido.Cantidad = int.Parse(new DAOEmpleado().obtenerCantidadProductoxEmpleado(int.Parse(Session["id_empleado"].ToString())).ToString());
                    ReporteGM reporte = new ReporteGM();
                    reporte.Id_mesero = int.Parse(Session["id_empleado"].ToString());
                    reporte.Total     = long.Parse(total);
                    reporte.Fecha     = DateTime.Now;
                    new DAOAdministrador().InsertarReporteMesero(reporte);
                    new DAOEmpleado().InsertarPedidoEmpleado(pedido);
                    new DAOEmpleado().ActulizarCantidad(int.Parse(Session["id_empleado"].ToString()));
                    new DAOEmpleado().borrarCarroEmpleado(int.Parse(Session["id_empleado"].ToString()));
                    Response.Redirect("CatalogoEmpleado.aspx");
                }
                else if (car[0].Cantidad > p.Cantidad)
                {
                    cm.RegisterClientScriptBlock(this.GetType(), "", "<script type='text/javascript'>alert('Cantidad No Disponible De:" + nom + ".Error:');</script>");
                    return;
                }
                else
                {
                    cm.RegisterClientScriptBlock(this.GetType(), "", "<script type='text/javascript'>alert('Error No Identificado  .Error:');</script>");
                    Session["id_empleado"] = null;
                    Response.Redirect("Ingresar.aspx");
                }
            }
        }
        // detallepedidoM();
    }
예제 #8
0
 public static void CrearProducto(DTOProducto productoDTO)
 {
     try
     {
         DAOProducto.CrearProducto(productoDTO);
     }
     catch (Exception ex)
     {
     }
 }
예제 #9
0
 public static List <DTOProducto> ObtenerProductos()
 {
     try
     {
         return(DAOProducto.ObtenerProductos());
     }
     catch (Exception ex)
     {
         throw;
     }
 }
예제 #10
0
 public ProductoNeg()
 {
     if (daoProducto == null)
     {
         daoProducto = new DAOProducto();
     }
     if (daoLocal == null)
     {
         daoLocal = new DAOLocal();
     }
 }
예제 #11
0
        public JsonResult ListaProducto()
        {
            try
            {
                List <ProductoE> lista = new DAOProducto().ListaProducto();

                return(Json(new { r = "ok", listaP = lista }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(ex.Message, JsonRequestBehavior.AllowGet));
            }
        }
예제 #12
0
        public JsonResult ObtenerProducto(int id)
        {
            try
            {
                ProductoE p = new DAOProducto().Obtener(id);

                return(Json(new { entProducto = p }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(ex.Message, JsonRequestBehavior.AllowGet));
            }
        }
예제 #13
0
    protected void btn_añadir_Click(object sender, EventArgs e)
    {
        ClientScriptManager cm = this.ClientScript;
        string seguridad       = (new DAOProducto().obtenerProductosCarrito(int.Parse(Session["id_usuario"].ToString())).Sum(x => x.Total)).ToString();
        long   verificar       = long.Parse(seguridad);

        if (verificar == 0)
        {
            return;
        }
        else
        {
            List <Carrito> car = new DAOProducto().obtenerProductosCarrito(int.Parse(Session["id_usuario"].ToString()));

            for (int i = 0; i <= car[i].Cantidad; i++)
            {
                Producto p   = new DAOProducto().VerificarProducto(car[i].Producto_id);
                string   nom = car[i].NombreProducto;
                if (car[i].Cantidad <= p.Cantidad)
                {
                    string total  = (new DAOProducto().obtenerProductosCarrito(int.Parse(Session["id_usuario"].ToString())).Sum(x => x.Total)).ToString();
                    Pedido pedido = new Pedido();
                    pedido.Id_usuario      = int.Parse(Session["id_usuario"].ToString());
                    pedido.Id_pago         = int.Parse(tipo_pago.SelectedValue);
                    pedido.Id_domicilio    = int.Parse(tipo_domicilio.SelectedValue);
                    pedido.Total           = long.Parse(total);
                    pedido.Fecha           = DateTime.Now;
                    Session["idDomicilio"] = int.Parse(pedido.Id_domicilio.ToString());
                    ReporteG reporte = new ReporteG();
                    reporte.Id_persona = int.Parse(Session["id_usuario"].ToString());
                    reporte.Total      = long.Parse(total);
                    reporte.Fecha      = DateTime.Now;
                    new DAOAdministrador().InsertarReporteUsuario(reporte);
                    new DAOFactura().InsertarPedido(pedido);
                    detallepedido();
                }
                else if (car[0].Cantidad > p.Cantidad)
                {
                    cm.RegisterClientScriptBlock(this.GetType(), "", "<script type='text/javascript'>alert('Cantidad No Disponible De:" + nom + ".Error:');</script>");
                    return;
                }
                else
                {
                    cm.RegisterClientScriptBlock(this.GetType(), "", "<script type='text/javascript'>alert('Error No Identificado  .Error:');</script>");
                    Session["id_usuario"] = null;
                    Response.Redirect("Ingresar.aspx");
                }
            }
        }
    }
예제 #14
0
        public bool EditarProducto(Entidad producto)
        {
            DAOProducto objDataBase = new DAOProducto();

            try
            {
                objDataBase.EditarProducto(producto);
            }
            catch (ExcepcionProducto e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw e;
            }
            return(true);
        }
예제 #15
0
        public bool EditarProductoGenerico(Entidad producto, String nombreViejo)
        {
            DAOProducto objDataBase = new DAOProducto();

            try
            {
                objDataBase.EditarProductoGenerico(producto, nombreViejo);
            }
            catch (ExcepcionProducto e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw e;
            }
            return(true);
        }
예제 #16
0
        //
        public List <String> ObtenerMarcas()
        {
            List <String> marcas      = new List <String>();
            DAOProducto   objDataBase = new DAOProducto();

            try
            {
                marcas = objDataBase.ConsultarMarcas();
            }
            catch (ExcepcionProducto e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw e;
            }
            return(marcas);
        }
예제 #17
0
        //
        public List <Entidad> ObtenerProductosDetallados(Entidad productoGenerico)
        {
            List <Entidad> productos   = new List <Entidad>();
            DAOProducto    objDataBase = new DAOProducto();

            try
            {
                productos = objDataBase.ConsultarProductosDetallados(productoGenerico);
            }
            catch (ExcepcionProducto e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw e;
            }
            return(productos);
        }
예제 #18
0
        //si
        public bool AgregarProducto(Entidad producto)
        {
            DAOProducto objDataBase = new DAOProducto();

            try
            {
                //1-Agregar el producto asociado a esa categoria
                objDataBase.AgregarProducto(producto);

                //2-Agregar el detalle_producto asociado al producto y a la marca
                objDataBase.AgregarDetalleProducto(producto);
            }
            catch (ExcepcionProducto e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw e;
            }
            return(true);
        }
    protected General_Producto InformacionReporte()
    {
        List <Producto>  ListaProductos = new DAOProducto().obtenerProductoReporte();
        General_Producto informe        = new General_Producto();
        DataTable        datosFinal     = informe.Producto;
        DataRow          fila;

        foreach (Producto registro in ListaProductos)
        {
            fila = datosFinal.NewRow();
            fila["ProductoId"]           = registro.Id;
            fila["ProductoNombre"]       = registro.Nombre;
            fila["ProductoCategoria"]    = registro.Categorrias;
            fila["ProductoSubcategoria"] = registro.Subcategorias;
            fila["ProductoPrecio"]       = registro.Precio;
            fila["ProductoImagen"]       = obtenerImagen(registro.Imagen);
            fila["ProductoDescripcion"]  = registro.Descripcion;
            fila["ProductoCantidad"]     = registro.Cantidad;
            datosFinal.Rows.Add(fila);
        }

        return(informe);
    }
예제 #20
0
    protected void DCatalogo_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        ClientScriptManager cm = this.ClientScript;

        if (int.Parse(((TextBox)e.Item.FindControl("txt_cantidad")).Text) <= 0)
        {
            ((Label)e.Item.FindControl("lb_mensaje")).ForeColor = Color.Red;
            ((Label)e.Item.FindControl("lb_mensaje")).Text      = "Ingrese numeros mayores a 0";
            return;
        }
        int cantidadSolicitada = int.Parse(((TextBox)e.Item.FindControl("txt_cantidad")).Text);
        int cantidadDisponible = new DAOProducto().obtenerCantidadxProducto(int.Parse(e.CommandArgument.ToString()));

        int    stock  = int.Parse(((Label)e.Item.FindControl("lb_cantidad")).Text);
        double precio = double.Parse(((Label)e.Item.FindControl("lb_precio")).Text.Replace("$", ""));

        if (e.Item.FindControl("txt_cantidad") != null || cantidadSolicitada > cantidadDisponible)
        {
            if (cantidadSolicitada > stock)
            {
                cm.RegisterClientScriptBlock(this.GetType(), "", "<script type='text/javascript'>alert('Cantidad No disponible. Disponible:');</script>");
                //this.RegisterStartupScript("mensaje", "<script type='text/javascript'>alert('Cantidad No disponible. Disponible: '" + cantidadDisponible.ToString() + "');</script>");
                return;
            }
            Carrito agregar = new Carrito();
            agregar.Producto_id = int.Parse(e.CommandArgument.ToString());
            agregar.Usuario_id  = ((EPersona)Session["validar_sesion_usuario"]).Id;
            agregar.Cantidad    = cantidadSolicitada;
            agregar.Fecha       = DateTime.Now;
            agregar.Precio      = precio;
            new DAOProducto().agregarCarrito(agregar);

            cm.RegisterClientScriptBlock(this.GetType(), "", "<script type='text/javascript'>alert('Producto Agregado');</script>");
            Response.Redirect("Catalogo.aspx");
        }
    }
예제 #21
0
 internal static eResultado Actualizar(TBL_EPI_PRODUCTO oProducto)
 {
     return(DAOProducto.Actualizar(oProducto));
 }
        public int Actualizar(Producto Producto)
        {
            DAOProducto daProducto = new DAOProducto();

            return(daProducto.Actualizar(Producto));
        }
        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();
        }
        public int Insertar(Producto Producto)
        {
            DAOProducto daProducto = new DAOProducto();

            return(daProducto.Insertar(Producto));
        }
예제 #25
0
 public AdminController()
 {
     productos   = new List <DTOProducto>();
     daoProducto = new DAOProducto();
 }
        public List <Producto> BuscarProducto(string campo, string valor)
        {
            DAOProducto daProducto = new DAOProducto();

            return(daProducto.BuscarProducto(campo, valor));
        }
예제 #27
0
 internal static eResultado Insertar(TBL_EPI_PRODUCTO oProducto)
 {
     return(DAOProducto.Insertar(oProducto));
 }
예제 #28
0
 internal static TBL_EPI_PRODUCTO obtieneProducto(int idProducto)
 {
     return(DAOProducto.obtieneProducto(idProducto));
 }
예제 #29
0
 internal static List <BEProducto> ListarProductos(int ID, string criterio)
 {
     return(DAOProducto.ListarProductos(ID, criterio));
 }
        public int Eliminar(int Id)
        {
            DAOProducto daProducto = new DAOProducto();

            return(daProducto.Eliminar(Id));
        }