Пример #1
0
        public static NivelEntidad Obtener(int idNivel)
        {
            List <NivelEntidad> lista = new List <NivelEntidad>();

            lista = NivelLN.ObtenerTodos();
            NivelEntidad user = new NivelEntidad();

            user = (lista.Find(elemento => elemento.idNivel == idNivel));
            return(user);
        }
Пример #2
0
        public static List <NivelEntidad> ObtenerTodos()
        {
            List <NivelEntidad> lista = new List <NivelEntidad>();
            DataSet             ds    = NivelDatos.SeleccionarTodos();

            foreach (DataRow fila in ds.Tables[0].Rows)
            {
                NivelEntidad registro = new NivelEntidad();
                registro.monto       = Convert.ToDouble(fila["monto"]);
                registro.descripcion = fila["descripcion"].ToString();
                registro.idNivel     = Convert.ToInt16(fila["idNivel"]);
                lista.Add(registro);
            }
            return(lista);
        }
Пример #3
0
        protected void btnPagar_Command(object sender, CommandEventArgs e)
        {
            if (Session["usuario"] == null)
            {
                Response.Redirect("inicioSesion.aspx");
            }
            else
            {
                //Usuario autentificado
                UsuarioEntidad user = (UsuarioEntidad)Session["usuario"];


                CompraEntidad compra = new CompraEntidad();
                compra.fecha     = DateTime.Now;
                compra.idUsuario = user.idUsuario;

                //Datos producto
                double descuento  = 0;
                double totalPagar = 0;
                foreach (var item in listaCarrito)
                {
                    compra.idProducto        = item.idProducto;
                    compra.cantidadProductos = item.cantidadProductos;
                    totalPagar = Convert.ToDouble(item.total);
                }



                //Consultar cupon por usuario
                List <CuponEntidad> cupones = new List <CuponEntidad>();
                cupones = CuponLN.ObtenerCuponporUsuario(user.idUsuario);
                foreach (var item in cupones)
                {
                    if (item.idNivel == user.nivelEntidad.idNivel && item.idProducto == compra.idProducto)
                    {
                        NivelEntidad nivel = NivelLN.Obtener(item.idNivel);
                        if (nivel.descripcion == "Bronce")
                        {
                            compra.total = Convert.ToDecimal(totalPagar - (totalPagar * 0.02));
                            descuento    = totalPagar * 0.02;
                        }
                        else
                        {
                            if (nivel.descripcion == "Plata")
                            {
                                compra.total = Convert.ToDecimal(totalPagar - (totalPagar * 0.05));
                                descuento    = totalPagar * 0.05;
                            }
                            else
                            {
                                if (nivel.descripcion == "Oro")
                                {
                                    compra.total = Convert.ToDecimal(totalPagar - (totalPagar * 0.07));
                                    descuento    = totalPagar * 0.07;
                                }
                                else
                                {
                                    if (nivel.descripcion == "Diamante")
                                    {
                                        compra.total = Convert.ToDecimal(totalPagar - (totalPagar * 0.10));
                                        descuento    = totalPagar * 0.10;
                                    }
                                    else
                                    {
                                        compra.total = Convert.ToDecimal(totalPagar);
                                    }
                                }
                            }
                        }
                    }
                }


                if (compra != null)
                {
                    if (compra.total == 0)
                    {
                        compra.total = Convert.ToDecimal(totalPagar);
                    }

                    CompraLN.Nuevo(compra);
                    CompraLN.limpiarLista();
                    descuentoGlobal = 0;
                    totalFinal      = 0;
                    Response.Redirect("carritoCompras.aspx");
                    this.lblMensaje.Text = "Compra realizada con exito";
                }
            }
        }
Пример #4
0
        protected void calculoDescuento()
        {
            if (Session["usuario"] == null)
            {
                mensajeDescuento = "Ingrese sesion para ver sus cupones y obtener descuentos!";
            }
            else
            {
                //Usuario autentificado
                UsuarioEntidad user = (UsuarioEntidad)Session["usuario"];


                CompraEntidad compra = new CompraEntidad();


                //Datos producto
                double descuento  = 0;
                double totalPagar = 0;
                foreach (var item in listaCarrito)
                {
                    compra.idProducto = item.idProducto;
                    totalPagar        = Convert.ToDouble(item.total);
                }



                //Consultar cupon por usuario
                List <CuponEntidad> cupones = new List <CuponEntidad>();
                cupones = CuponLN.ObtenerCuponporUsuario(user.idUsuario);
                foreach (var item in cupones)
                {
                    if (item.idNivel == user.nivelEntidad.idNivel && item.idProducto == compra.idProducto)
                    {
                        NivelEntidad nivel = NivelLN.Obtener(item.idNivel);
                        if (nivel.descripcion == "Bronce")
                        {
                            compra.total = Convert.ToDecimal(totalPagar - (totalPagar * 0.02));
                            descuento    = totalPagar * 0.02;
                        }
                        else
                        {
                            if (nivel.descripcion == "Plata")
                            {
                                compra.total = Convert.ToDecimal(totalPagar - (totalPagar * 0.05));
                                descuento    = totalPagar * 0.05;
                            }
                            else
                            {
                                if (nivel.descripcion == "Oro")
                                {
                                    compra.total = Convert.ToDecimal(totalPagar - (totalPagar * 0.07));
                                    descuento    = totalPagar * 0.07;
                                }
                                else
                                {
                                    compra.total = Convert.ToDecimal(totalPagar - (totalPagar * 0.10));
                                    descuento    = totalPagar * 0.10;
                                }
                            }
                        }
                    }
                }

                descuentoGlobal = Convert.ToDecimal(descuento);
                totalFinal      = Convert.ToDecimal(totalPagar - descuento);
            }
        }