Ejemplo n.º 1
0
        private void cargarGrid(int estado)
        {
            IEnumerable <Cupon> lista = (IEnumerable <Cupon>)CuponLN.ListaCupones(estado);

            grvListado.DataSource = lista.ToList();
            grvListado.DataBind();
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string id;
                if (!String.IsNullOrEmpty(Request.QueryString["id"]))
                {
                    id = Convert.ToString(Request.QueryString["id"]);

                    cliente = ClienteLN.ObtenerPorIdentificacion(id);
                    cN      = ClienteNivelLN.Obtener(cliente.identificacion);

                    Session["clienteCanje"] = ClienteLN.ObtenerPorIdentificacion(id);

                    lblNombreCliente.Text = cliente.nombreCompleto;
                    lblNivelCliente.Text  = cN.nivel.nombre;
                    imagenNivel.ImageUrl += cN.nivel.Imagen;

                    ddlCupon.DataSource     = CuponLN.ObtenerTodos();
                    ddlCupon.DataTextField  = "Nombre";
                    ddlCupon.DataValueField = "ID";
                    ddlCupon.DataBind();

                    listaCupon();
                    ddlCupon_SelectedIndexChanged(null, null);
                }
            }
        }
Ejemplo n.º 3
0
        // El nombre de parámetro del id. debe coincidir con el valor DataKeyNames establecido en el control



        protected void grvCuponSin_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if ((e.Row.RowType == DataControlRowType.DataRow))
            {
                // DataRow Vale las row que tienen datos, de esta manera se saltea el header,el footer y el pager
                DropDownList ddl;
                int          id = Convert.ToInt32(grvCuponSin.DataKeys[e.Row.RowIndex].Value);
                // Celda 1 es donde esta el DropdownList
                GridViewRow gvrow = ((GridViewRow)(e.Row.Cells[3].NamingContainer));
                ddl = ((DropDownList)(gvrow.FindControl("ddlCliente")));

                Cupon          cupon = CuponLN.Obtener(id);
                List <Cliente> lista = new List <Cliente>();
                foreach (var item in ClienteLN.ObtenerTodos())
                {
                    if (item.rango.idRango == cupon.rango.idRango)
                    {
                        lista.Add(item);
                    }
                }

                ddl.DataSource    = lista;
                ddl.SelectedIndex = -1;
                ddl.DataBind();
                ListItem lst = new ListItem("Seleccione un Cliente", "0");
                ddl.Items.Insert(0, lst);
            }
        }
Ejemplo n.º 4
0
        protected void ddlCliente_SelectedIndexChanged(object sender, EventArgs e)
        {
            DropDownList ddl;
            GridViewRow  currentRow = (GridViewRow)((DropDownList)sender).Parent.Parent;

            // Celda 1 es donde esta el DropdownList

            ddl = ((DropDownList)(currentRow.FindControl("ddlCliente")));

            int idCupon = Convert.ToInt32(grvCuponSin.DataKeys[currentRow.RowIndex].Values[0]);

            if (idCupon > 0)
            {
                Cliente cliente = ClienteLN.Obtener(Convert.ToInt32(ddl.SelectedValue));


                Cupon cupon = new Cupon()
                {
                    idCupon = idCupon,
                    cliente = cliente,
                    estado  = true
                };
                CuponLN.InsertarCliente(cupon);
                CuponLN.ActualizarEstadoCupon(false, idCupon);

                grvCuponSin.DataBind();
            }
        }
Ejemplo n.º 5
0
        public void cargarGrid()
        {
            IEnumerable <Cupon> lista = (IEnumerable <Cupon>)CuponLN.listaCuponesMantenimiento();

            grvListado.DataSource = lista.ToList();
            grvListado.DataBind();
        }
Ejemplo n.º 6
0
        protected void btnRegistrar_Click(object sender, EventArgs e)
        {
            //Datos cupon
            CuponEntidad cupon = new CuponEntidad();

            cupon.nombre      = txtNombre.Text;
            cupon.descripcion = txtDescripcion.Text;
            cupon.tipoCupon   = Convert.ToString(ddlTipoCupon.SelectedValue);
            cupon.idNivel     = Convert.ToInt32(ddlNivel.SelectedValue);
            cupon.idUsuario   = Convert.ToInt32(ddlUsuario.SelectedValue);
            cupon.idProducto  = Convert.ToInt32(ddlProducto.SelectedValue);

            if (cupon != null)
            {
                CuponLN.Nuevo(cupon);
                this.lblMensaje.Text = "Cupon agregado con exito";

                //Limpiar campos
                this.txtNombre.Text      = "";
                this.txtDescripcion.Text = "";
                this.ddlTipoCupon.ClearSelection();
                this.ddlNivel.ClearSelection();
                this.ddlUsuario.ClearSelection();
                this.ddlProducto.ClearSelection();
            }
        }
Ejemplo n.º 7
0
        protected void ddlCupon_SelectedIndexChanged(object sender, EventArgs e)
        {
            Cupon cupon = CuponLN.Obtener(Convert.ToInt16(ddlCupon.SelectedValue));

            imgCupon.Visible  = true;
            imgCupon.ImageUrl = cupon.Imagen;
            lblMensaje.Text   = "";
        }
Ejemplo n.º 8
0
 protected void ddlCupon_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listaClienteCupones != null)
     {
         Cupon cupon = CuponLN.Obtener(Convert.ToInt16(ddlCupon.SelectedValue));
         imgCupon.Visible  = true;
         imgCupon.ImageUrl = cupon.Imagen;
     }
 }
Ejemplo n.º 9
0
        protected void ddlRango_SelectedIndexChanged(object sender, EventArgs e)
        {
            int id = Convert.ToInt32(ddlRango.SelectedValue);

            if (ddlRango.SelectedIndex != -1)
            {
                grvListadoCupon.DataSource = CuponLN.ObtenerXRango(id);
                grvListadoCupon.DataBind();
            }
        }
Ejemplo n.º 10
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         ddlRango.DataSource = RangoLN.ObtenerTodos().Where(x => x.idRango != 5);
         ddlRango.DataBind();
         grvListadoCupon.DataSource = CuponLN.ObtenerTodos();
         grvListadoCupon.DataBind();
     }
 }
Ejemplo n.º 11
0
        protected void chkEstado_CheckedChanged(object sender, EventArgs e)
        {
            GridViewRow currentRow = (GridViewRow)((CheckBox)sender).Parent.Parent;
            CheckBox    estado     = (CheckBox)currentRow.FindControl("ChkEstado");
            bool        activo     = estado.Checked;
            int         idCupon    = Convert.ToInt32(grvCupon.DataKeys[currentRow.RowIndex].Values[0]);

            CuponLN.ActualizarEstadoCuponCliente(activo, idCupon);
            ClientScript.RegisterStartupScript(this.GetType(), "Carrito",
                                               "mensajeConfirm('Actualizado correctamente')", true);
        }
Ejemplo n.º 12
0
        public void aceptarCupon(int idCupon)
        {
            Cupon cupon = CuponLN.obtenerCupon(idCupon);

            Session["Cupon"] = cupon;
            //hfCupon.Value = cupon.ID.ToString();
            //lblDescripcion.Text = cupon.Descripcion;
            //lblEcoMonedasNesarias.Text = cupon.EcoMonedasNecesarias.ToString();
            //lblNombre.InnerText = cupon.Nombre;
            //lblNombreC.Text = cupon.Nombre;
            //lblValorComercial.Text = cupon.PrecioCanje.ToString();
        }
Ejemplo n.º 13
0
        protected void grvListado_SelectedIndexChanged(object sender, EventArgs e)
        {
            int   id    = Convert.ToInt32(grvListado.DataKeys[grvListado.SelectedIndex].Values[0]);
            Cupon cupon = CuponLN.obtenerCupon(id);

            //Aqui se le indican los valores en las distintos controles del form
            txtNombre.Text               = cupon.Nombre;
            txtDescripcion.Text          = cupon.Descripcion;
            txtPrecioCanje.Text          = cupon.PrecioCanje.ToString();
            txtEcoMonedasNecesarias.Text = cupon.EcoMonedasNecesarias.ToString();
            chkEstado.Checked            = cupon.Estado;
            hfCuponID.Value              = cupon.ID.ToString();
            btnRegistrar.Text            = "Actualizar";
        }
Ejemplo n.º 14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string cuponID = Request.QueryString["idCupon"];

            cupID = Convert.ToInt32(cuponID);

            if (!IsPostBack)
            {
                ReportViewer1.LocalReport.DataSources.Clear();
                ReportDataSource rdc = new ReportDataSource("dsCupon", CuponLN.obtenerCuponPorID(Convert.ToInt32(cuponID)));
                ReportViewer1.LocalReport.DataSources.Add(rdc);
                ReportViewer1.LocalReport.Refresh();
            }
        }
Ejemplo n.º 15
0
        protected void btnRegistrar_Click(object sender, EventArgs e)
        {
            CuponLN cupones      = new CuponLN();
            bool    confirmacion = cupones.GuardarCupon(txtNombre.Text, txtDescripcion.Text, chkEstado.Checked, txtPrecioCanje.Text, txtEcoMonedasNecesarias.Text, hfCuponID.Value);

            if (confirmacion)
            {
                this.Response.Redirect("MantenimientoCupones.aspx?accion=guardado");
            }
            else
            {
                lblMensaje.Visible = true;
                lblMensaje.Text    = "No se puede guardar el cupon";
            }
        }
Ejemplo n.º 16
0
        protected void btnRegistrar_Click(object sender, EventArgs e)
        {
            if (Page.IsValid && (rbtnDescuento.Checked || rbtnRegalia.Checked))
            {
                Cupon cupon = new Cupon()
                {
                    idCupon     = Random(),
                    nombre      = txtNombre.Text,
                    descripcion = txtDescripcion.Text,
                    cantidad    = Convert.ToInt32(txtCantidad.Text),
                    estado      = true
                };
                if (ddlProducto.SelectedIndex == 0 || ddlRango.SelectedIndex == 0)
                {
                    ClientScript.RegisterStartupScript(
                        this.GetType(),
                        "Cupón",
                        "mensaje('Cupón','Registro no exitoso!','warning')",
                        true
                        );
                }
                else
                {
                    cupon.producto.idProducto = Convert.ToInt32(ddlProducto.SelectedValue);

                    cupon.rango.idRango = Convert.ToInt32(ddlRango.SelectedValue);
                }

                if (txtDescuento.Text == "")
                {
                    cupon.descuento = ProductoLN.Obtener(Convert.ToInt32(ddlProducto.SelectedValue)).precio;
                }
                else
                {
                    cupon.descuento = Convert.ToDecimal(txtDescuento.Text);
                }
                CuponLN.Nuevo(cupon);


                ClientScript.RegisterStartupScript(this.GetType(), "Carrito",
                                                   "mensajeConfirm('Agregado correctamente')", true);
                Response.Redirect("CuponCliente.aspx");

                txtCantidad.Text    = "";
                txtDescripcion.Text = "";
                txtNombre.Text      = "";
            }
        }
Ejemplo n.º 17
0
        protected void btnLimpiar_Click(object sender, EventArgs e)
        {
            int id = Convert.ToInt32(grvListado.DataKeys[grvListado.SelectedIndex].Values[0]);

            Cupon mat =
                CuponLN.listaCupones().
                Where(p => p.Id_Cupon == id).FirstOrDefault <Cupon>();

            txtNombre.Text      = mat.nombre;
            txtDescripcion.Text = mat.descripcion;
            txtPrecio.Text      = mat.Precio_Canje.ToString();
            hiddenID.Value      = mat.Id_Cupon.ToString();
            imgLibro.ImageUrl   = "~/images/cupones/" + mat.imagen;
            btnGuardar.Text     = "Actualizar";
            rfImagen.Enabled    = false;
        }
Ejemplo n.º 18
0
        protected void ChkMiCupon_CheckedChanged(object sender, EventArgs e)
        {
            if (Session["Cliente"] != null && ChkMiCupon.Checked)
            {
                int     id      = ((Cliente)Session["Cliente"]).idCliente;
                Cliente usuario = ClienteLN.Obtener(id);


                grvListadoCupon.DataSource = CuponLN.ObtenerClientes(usuario.idCliente).Where(x => x.estado == true);
                grvListadoCupon.DataBind();
            }
            else
            {
                grvListadoCupon.DataSource = CuponLN.ObtenerTodos();
                grvListadoCupon.DataBind();
            }
        }
Ejemplo n.º 19
0
        protected void btnAsignar_Click(object sender, EventArgs e)
        {
            Cupon        cupon = CuponLN.Obtener(Convert.ToInt16(ddlCupon.SelectedValue));
            Cliente      cl    = (Cliente)Session["clienteCanje"];
            ClienteNivel cn    = ClienteNivelLN.Obtener(cl.identificacion);

            if (ClienteCuponLN.ExisteCupon(cupon, cl.identificacion))
            {
                lblMensaje.Text    = "";
                lblMensaje.Visible = true;
                lblMensaje.Text    = "Cupón ya ha sido asígnado";
            }
            else
            {
                if (cn.nivel.id < cupon.nivel.id)
                {
                    lblMensaje.Text    = "";
                    lblMensaje.Visible = true;
                    lblMensaje.Text    = "Cupón no puede ser asígnado";
                }
                else
                {
                    ClienteCupon cc = new ClienteCupon
                    {
                        cliente  = cl,
                        codigoQR = qr(),
                        cupon    = cupon,
                        estado   = 1,
                        estadoS  = "Sin usar",
                    };
                    ClienteCuponLN.Insertar(cc);
                    lblMensaje.Text    = "";
                    lblMensaje.Visible = true;
                    lblMensaje.Text    = "Cupón se ha asígnado";
                    listaCupon();
                }
            }
        }
Ejemplo n.º 20
0
        protected void btnSignin_Click(object sender, EventArgs e)
        {
            try
            {
                Usuario usu = new Usuario
                {
                    tipoUsuario = "Cliente",
                    contrasenna = Convert.ToString(txtContrasenna.Text),
                    email       = Convert.ToString(txtEmail.Text),
                    estado      = 1,
                };

                Usuario usua = UsuarioLN.ObtenerPorEmail(usu.email);
                if (usua != null)
                {
                    lblMensaje.Visible = true;
                    lblMensaje.Text    = "el email ingresado ya existe, intente con otro";
                }
                else
                {
                    UsuarioLN.Insertar(usu);
                    TipoIdentificacion tipo    = TipoIdentificacionLN.Obtener(Convert.ToInt16(ddlTipoIdentificacion.SelectedValue));
                    Cliente            cliente = new Cliente
                    {
                        fechaNacimiento    = Convert.ToDateTime(txtFecha.Text),
                        identificacion     = Convert.ToString(txtIdentificacion.Text),
                        nombreCompleto     = Convert.ToString(txtNombre.Text),
                        tarjetaCredito     = Convert.ToString(txtTarjetaCredito.Text),
                        tipoIdentificacion = tipo,
                        usuario            = UsuarioLN.ObtenerPorContrasenna(usu.contrasenna)
                    };

                    Cliente clien = ClienteLN.ObtenerPorIdentificacion(cliente.identificacion);
                    if (clien != null)
                    {
                        lblMensaje.Visible = true;
                        lblMensaje.Text    = "Ya existe un cliente con este número de céudla";
                    }
                    else
                    {
                        ClienteLN.Insertar(cliente);

                        Provincia provincia = ProvinciaLN.Obtener(Convert.ToInt16(ddlProvincia.SelectedValue));
                        Direccion direccion = new Direccion
                        {
                            provincia     = provincia,
                            codigo_postal = Convert.ToString(txtCodigo.Text),
                            otrassennas   = Convert.ToString(txtOtras.Text),
                            cliente       = cliente
                        };
                        DireccionLN.Insertar(direccion);


                        ClienteNivel cN = new ClienteNivel
                        {
                            cliente     = ClienteLN.ObtenerPorIdentificacion(cliente.identificacion),
                            montoActual = 0,
                            nivel       = NivelLN.Obtener(1)
                        };
                        ClienteNivelLN.Insertar(cN);

                        ClienteCupon cC = new ClienteCupon
                        {
                            cliente  = ClienteLN.ObtenerPorIdentificacion(cliente.identificacion),
                            codigoQR = qr(),
                            cupon    = CuponLN.Obtener(1),
                            estado   = 1
                        };

                        ClienteCuponLN.Insertar(cC);

                        lblMensaje.Visible = true;
                        lblMensaje.Text    = "Registro exitoso, ya puede ingresar a la tienda";
                        limpiarCampos();
                    }
                }
            }
            catch (Exception e1)
            {
                lblMensaje.Visible = true;
                lblMensaje.Text    = "Ha ocurrido un problema  " + e1.Message;
            }
        }
Ejemplo n.º 21
0
 public List <Cupon> grvCuponSin_GetData()
 {
     return(CuponLN.ObtenerTodos());
 }
Ejemplo n.º 22
0
 public IEnumerable <Cupon> listadoCupon()
 {
     return(CuponLN.listaCupones());
 }
Ejemplo n.º 23
0
        protected void linkAgregar_Click(object sender, EventArgs e)
        {
            Usuario usuario2 = (Usuario)Session["usuario"];


            //Otra forma de obtener el id del producto
            ListViewDataItem fila = (ListViewDataItem)(sender as Control).Parent;
            HiddenField      hi   = (HiddenField)fila.FindControl("hiddenID");
            int idCupon           = Convert.ToInt32(hi.Value);

            if (idCupon != 0)
            {
                Cupon     cupon     = CuponLN.obtenerCupon(idCupon);
                Billetera billetera = BilleteraLN.obtenerBilletera(usuario2.Billetera.Id_Billetera);

                if (billetera.Total_Disponible >= cupon.Precio_Canje)
                {
                    // Cambiamos la billetera

                    BilleteraLN.ObtenerCupon(billetera.Id_Billetera, cupon.Precio_Canje);
                    lblTotalEcomonedas.Text = billetera.Total_Disponible.ToString();


                    //Agregamos el cupon a la bd
                    Cupon_UsuarioLN.registrarCupon_Usuario(usuario2.Id_Usuario, cupon.Id_Cupon, cupon.activo.Value);



                    //Creamos un qr

                    var             txtQRCode   = cupon.nombre + numeroAleatorio();
                    QRCodeGenerator qrGenerator = new QRCodeGenerator();
                    QRCodeData      qrCodeData  = qrGenerator.CreateQrCode(txtQRCode, QRCodeGenerator.ECCLevel.Q);
                    QRCode          qrCode      = new QRCode(qrCodeData);
                    Bitmap          qrCodeImage = qrCode.GetGraphic(20);

                    //guardamos la imagen
                    var folder = "images/Qrs/";
                    var path   = System.Web.HttpContext.Current.Server.MapPath(folder);
                    qrCodeImage.Save(path + cupon.nombre + "qr.Jpeg", ImageFormat.Jpeg);


                    //Asignamos la ruta de las imagenes
                    System.Drawing.Image imagen = System.Drawing.Image.FromFile(Server.MapPath("~/images/cupones/" + cupon.imagen));


                    //Hacemos las imagenes en byte
                    CanjeCupon Canje = new CanjeCupon();
                    Canje.cliente     = usuario2.NombreCompleto;
                    Canje.id          = cupon.Id_Cupon;
                    Canje.imagenQR    = CanjeCuponLN.ImagenByte(qrCodeImage);
                    Canje.imagenCupon = CanjeCuponLN.ImagenByte(imagen);
                    Canje.nombreCupon = cupon.nombre;



                    //llamamos al reporte
                    LocalReport report = new LocalReport();
                    report.DataSources.Clear();

                    ReportDataSource rdc = new ReportDataSource("DataSet1", CanjeCuponLN.canjeCupon(Canje));
                    report.DataSources.Add(rdc);
                    report.ReportPath           = Server.MapPath("~/Reportes/CuponObtenido.rdlc");
                    report.EnableExternalImages = true;


                    string    FileName = "Cupon-" + cupon.nombre.Trim() + ".pdf";
                    string    extension;
                    string    encoding;
                    string    mimeType;
                    string[]  streams;
                    Warning[] warnings;



                    Byte[] mybytes = report.Render("PDF", null,
                                                   out extension, out encoding,
                                                   out mimeType, out streams, out warnings); //for exporting to PDF
                    using (FileStream fs = File.Create(Server.MapPath("~/images/DescargasCupones/") + FileName))
                    {
                        fs.Write(mybytes, 0, mybytes.Length);
                    }



                    Response.Buffer = true;

                    Response.ContentType = "application/pdf";

                    Response.AddHeader("content-disposition", "inline;filename=" + FileName + ".pdf");
                    Response.WriteFile(Server.MapPath(Path.Combine("~/images/DescargasCupones/" + FileName)));
                    Response.End();
                }
                else
                {
                    lblMensaje.Visible   = true;
                    lblMensaje.Text      = "Lo sentimos, no le alcanza para este cupón";
                    lblMensaje.ForeColor = Color.Red;
                }
            }
        }
Ejemplo n.º 24
0
        public List <CuponEntidad> gvCupones_GetData()
        {
            UsuarioEntidad user = (UsuarioEntidad)Session["usuario"];

            return(CuponLN.ObtenerCuponporUsuario(user.idUsuario));
        }
Ejemplo n.º 25
0
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            bool estado = true;

            if (RadioButton1.Checked)
            {
                estado = true;
            }
            else
            {
                if (RadioButton2.Checked)
                {
                    estado = false;
                }
            }
            Boolean archivoOK = false;
            String  path      = Server.MapPath("~/images/");

            if (archivoImagen.HasFile)
            {
                String   fileExtension     = System.IO.Path.GetExtension(archivoImagen.FileName).ToLower();
                String[] allowedExtensions = { ".gif", ".png", ".jpeg", ".jpg" };
                for (int i = 0; i < allowedExtensions.Length; i++)
                {
                    if (fileExtension == allowedExtensions[i])
                    {
                        archivoOK = true;
                    }
                }


                if (archivoOK)
                {
                    try
                    {
                        // Guardar imagen en la carpeta materiales
                        archivoImagen.PostedFile.SaveAs(path + "cupones/" + archivoImagen.FileName);
                    }
                    catch (Exception ex)
                    {
                        lblMensaje.Visible = true;
                        lblMensaje.Text    = ex.Message;
                    }
                }
                else
                {
                    lblMensaje.Visible = true;
                    lblMensaje.Text    = "No se puede aceptar el tipo de archivo.";
                    return;
                }
            }

            // Agregar producto a la BD

            bool confirmar = CuponLN.agregarCupones(txtNombre.Text, txtDescripcion.Text, txtPrecio.Text, archivoImagen.FileName, estado, hiddenID.Value);

            if (confirmar)
            {
                // Recargar la pagina
                string accion = (hiddenID.Value == "" || hiddenID.Value == "0") ? "nuevo" : "actu";
                Response.Redirect("MantCupones.aspx?accion=" + accion);
            }
            else
            {
                lblMensaje.Visible = true;
                lblMensaje.Text    = "No se puedo agregar un nuevo cupón, por favor intentar de nuevo";
            }
        }
Ejemplo n.º 26
0
 //public void CargarCuponCliente()
 //{
 //    grvCupon.DataSource = CuponLN.ObtenerTodosCliente().Where(x => x.canjeado == true);
 //    grvCupon.DataBind();
 //}
 public List <Cupon> grvCuponCon_GetData()
 {
     return(CuponLN.ObtenerTodosCliente());
 }
Ejemplo n.º 27
0
        protected void btnConfirmar_Click(object sender, EventArgs e)
        {
            //verificar si hay cliente
            Cliente cliente = (Cliente)Session["cliente"];

            if (cliente != null)
            {
                // si hay cliente hace lo siguiente

                Cupon cupon = new Cupon();;
                //si el ddlCupon es diferente de null obtiene la información del cupón
                if (listaClienteCupones != null)
                {
                    cupon = CuponLN.Obtener(Convert.ToInt16(ddlCupon.SelectedValue));
                }
                //se busca el nivel del cliente
                ClienteNivel clienteNivel = ClienteNivelLN.ObtenerClienteNivel(cliente.identificacion);

                //se inserta el cambio en el canje, se pregunta primero si agarró algún cupon
                if (cupon.id != 0)
                {
                    //se va a ser el canje sólo si escogió un producto



                    if (producto != null)
                    {
                        Canje canje = new Canje
                        {
                            cliente  = cliente,
                            cupon    = cupon,
                            producto = producto //el que cliente escogío
                        };
                        CanjeLN.Insertar(canje);
                    }

                    //actualiza el estado después de realizar el canje
                    ClienteCuponLN.ActualizarEstado(cliente.identificacion, 2);
                }
                else
                {
                    //mensaje
                    lblMensajeCupon.Text    = "No se aplicará descuento";
                    lblMensajeCupon.Visible = true;
                }


                //ACERCA DE LOS NIVELES
                if (clienteNivel.nivel.nombre == "Bronce")
                {
                    // esta suma es acerca del monto que se compró + el monto meta LO QUE SE BUSCA ES ACTUALIZAR EL MONTO ACTUAL DEL CLIENTE NIVEL
                    int suma = clienteNivel.montoActual + Subtotal();
                    ClienteNivelLN.Actualizar(cliente.identificacion, suma);

                    ClienteNivel clienteNivel2 = ClienteNivelLN.Obtener(cliente.identificacion);

                    //subir de nivel y asignar cupon
                    if (clienteNivel.nivel.montoMeta < clienteNivel2.montoActual)
                    {
                        Nivel nivel = NivelLN.Obtener(2);
                        ClienteNivelLN.ActualizarNivel(cliente.identificacion, nivel.id);
                    }
                }
                else
                {
                    if (clienteNivel.nivel.nombre == "Plata")
                    {
                        // esta suma es acerca del monto que se compró + el monto meta LO QUE SE BUSCA ES ACTUALIZAR EL MONTO ACTUAL DEL CLIENTE NIVEL
                        int          suma          = clienteNivel.montoActual + Subtotal();
                        ClienteNivel clienteNivel2 = ClienteNivelLN.Obtener(cliente.identificacion);

                        //subir de nivel y asignar cupon
                        if (clienteNivel.nivel.montoMeta < clienteNivel2.montoActual)
                        {
                            Nivel nivel = NivelLN.Obtener(3);
                            ClienteNivelLN.ActualizarNivel(cliente.identificacion, nivel.id);
                        }
                    }
                    else
                    {
                        if (clienteNivel.nivel.nombre == "Oro")
                        {
                            // esta suma es acerca del monto que se compró + el monto meta LO QUE SE BUSCA ES ACTUALIZAR EL MONTO ACTUAL DEL CLIENTE NIVEL
                            int          suma          = clienteNivel.montoActual + Subtotal();
                            ClienteNivel clienteNivel2 = ClienteNivelLN.Obtener(cliente.identificacion);

                            //subir de nivel y asignar cupon
                            if (clienteNivel.nivel.montoMeta < clienteNivel2.montoActual)
                            {
                                Nivel nivel = NivelLN.Obtener(4);
                                ClienteNivelLN.ActualizarNivel(cliente.identificacion, nivel.id);
                            }
                        }
                    }
                }


                int total = 0;
                //sacar total
                if (cupon != null)
                {
                    int descuento = 0;
                    descuento = cupon.descuento / 100;


                    total = Subtotal2() + (producto.precio - descuento);
                }
                else
                {
                    total = Subtotal();
                }


                //lista de compras
                List <DetPedido> lista = (List <DetPedido>)Session["lista"];

                //se insertan los det
                foreach (DetPedido det in lista)
                {
                    DetPedidoLN.Insertar(det);
                }

                //ahora los det de que ya existen en el enca
                foreach (DetPedido det in lista)
                {
                    DetPedido  detP       = DetPedidoLN.Obtener(det.id);
                    EncaPedido encaPedido = new EncaPedido
                    {
                        cliente   = cliente,
                        detPedido = detP,
                        total     = total
                    };
                    EncaPedidoLN.Insertar(encaPedido);
                }

                lblMensajeC.Text    = "¡Compra exitosa, gracias por preferirnos!";
                lblMensajeC.Visible = true;
                //limpiar la lista
                limpiarLista();
            }
            else
            {
                lblMensaje.Text = "Debe ingresar para continuar con la finalización de la compra";
            }
        }
Ejemplo n.º 28
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                listadoDetPedido();

                Cliente cliente = (Cliente)Session["cliente"];
                if (cliente != null)
                {
                    List <ClienteCupon> cupones = ClienteCuponLN.ClientePorCupon(cliente.identificacion);
                    listaClienteCupones = new List <ClienteCupon>();
                    listaCupones        = new List <Cupon>();
                    foreach (ClienteCupon cc in cupones)
                    {
                        ClienteCupon c = cc;

                        if (c.estado == 1)
                        {//busca los ClienteCupon que tenga el cliente
                            listaClienteCupones.Add(c);
                        }
                    }


                    if (listaClienteCupones != null)
                    {
                        //luego Busca los cupones por id paraobtener el nombre
                        foreach (ClienteCupon cc in listaClienteCupones)
                        {
                            Cupon c = CuponLN.Obtener(cc.cupon.id);

                            listaCupones.Add(c);
                        }

                        ddlCupon.DataSource     = listaCupones;
                        ddlCupon.DataTextField  = "Nombre";
                        ddlCupon.DataValueField = "ID";
                        ddlCupon.DataBind();

                        ddlCupon_SelectedIndexChanged(null, null);
                    }
                    else
                    {
                        ddlCupon.Visible        = false;
                        lblMensajeCupon.Visible = true;
                    }


                    txtNombre.Text = cliente.nombreCompleto;

                    Direccion direc = DireccionLN.DireccionPorCliente(cliente.identificacion);

                    txtProvinica.Text    = direc.provincia.dscProvincia;
                    txtCodigoPostal.Text = direc.codigo_postal;
                    txtOtrasSennas.Text  = direc.otrassennas;
                    txtTarjeta.Text      = cliente.tarjetaCredito;

                    txtSubTotal.Text   = Convert.ToString(Subtotal());
                    txtTotal.Text      = Convert.ToString(Subtotal());
                    lblMensaje.Visible = false;
                }
                else
                {
                    ddlCupon.Visible = false;
                    imgCupon.Visible = false;
                }
            }
        }
Ejemplo n.º 29
0
 // El tipo devuelto puede ser modificado a IEnumerable, sin embargo, para ser compatible con la paginación y ordenación de
 //, se deben agregar los siguientes parametros:
 //     int maximumRows
 //     int startRowIndex
 //     out int totalRowCount
 //     string sortByExpression
 public List <Cupon> grvCupon_GetData()
 {
     return(CuponLN.ObtenerTodosCliente().Where(x => x.canjeado == true).ToList());
 }
Ejemplo n.º 30
0
        public IEnumerable <Cupon> listadoCupones()
        {
            List <Cupon> lista = CuponLN.obtenerListaCupones(1).ToList();

            return(lista);
        }