public void cargarAlquileres()
    {
        List <Alquiler> listAlquileres = Alquiler_BRL.GetAllAlquileres();

        GridAlquileres.DataSource = listAlquileres;
        GridAlquileres.DataBind();
    }
    protected void btnConfirmAlquiler_Click(object sender, EventArgs e)
    {
        int      diasxAlquilar = Convert.ToInt32(alq_txtDiasxAlquilar.Text.Trim(), CultureInfo.InvariantCulture);
        decimal  totalPago     = objSelected.PrecioAlquiler * diasxAlquilar;
        DateTime fechaAlqui    = DateTime.Now;
        DateTime fechaDevol    = fechaAlqui.AddDays(diasxAlquilar);
        string   tarjetaCredit = alq_txtNumTarjeta.Text.Trim();
        string   codigoTarjeta = alq_txtCodigoTarjeta.Text.Trim();

        if (tempAlquiler == null)
        {
            Alquiler obj = new Alquiler()
            {
                TotalPago      = totalPago,
                FechaAlqui     = fechaAlqui,
                FechaDevol     = fechaDevol,
                TarjetaCredito = tarjetaCredit,
                CodigoTarjeta  = codigoTarjeta,
                Estado         = true,
                UserId         = userLogeado.UserId,
                PeliculaId     = objSelected.PeliculaId
            };

            Alquiler_BRL.InsertAlquiler(obj);
        }
        else
        {
            tempAlquiler.TotalPago      = totalPago;
            tempAlquiler.FechaAlqui     = fechaAlqui;
            tempAlquiler.FechaDevol     = fechaDevol;
            tempAlquiler.TarjetaCredito = tarjetaCredit;
            tempAlquiler.CodigoTarjeta  = codigoTarjeta;
            tempAlquiler.Estado         = true;

            Alquiler_BRL.UpdateAlquiler(tempAlquiler);
        }

        tempAlquiler = null;
        Response.Redirect("DetallePelicula.aspx?Id=" + objSelected.PeliculaId);
    }
示例#3
0
    public static List <Transaction> GetAllTransactionByUserId(int UserId)
    {
        if (UserId <= 0)
        {
            throw new ArgumentException("El UserId debe ser mayor a 1");
        }
        List <Transaction> listTransaction = new List <Transaction>();
        //Obtieniendo Compras por UserID
        CompraTableAdapter adapterCompra = new CompraTableAdapter();

        Compra_DS.CompraDataTable tableCompra = adapterCompra.GetComprasByUserID(UserId);
        Transaction tempTransaction;
        UserCLI     tempUser;
        Pelicula    tempMovie;

        foreach (var row in tableCompra)
        {
            if (row.estado)
            {
                tempTransaction                  = new Transaction();
                tempTransaction.TotalPago        = row.totalPago;
                tempTransaction.FechaTransaction = row.fecha;
                tempTransaction.UserId           = row.UserId;
                tempUser = UserCLI_BRL.getUserById(row.UserId);
                tempTransaction.UserName       = tempUser.Nombre;
                tempTransaction.EmailUser      = tempUser.Email;
                tempTransaction.TarjetaCredito = row.tarjetaCredito;
                tempTransaction.CodigoTarjeta  = row.codigoTarjeta;
                tempTransaction.PeliculaId     = row.peliculaId;
                tempMovie = Pelicula_BRL.GetPeliculaByID(row.peliculaId);
                tempTransaction.NombrePelicula = tempMovie.Nombre;
                tempTransaction.Foto           = tempMovie.Foto;
                tempTransaction.Description    = tempMovie.Descripcion;
                tempTransaction.Director       = tempMovie.Director;
                tempTransaction.Elenco         = tempMovie.Elenco;
                tempTransaction.Label          = "<span class='label label-default pull-right'" +
                                                 "style='border-radius:3px; background-color:#5cb85c; color:#fff; padding: 6px 3px'" +
                                                 ">Venta</span>";


                listTransaction.Add(tempTransaction);
            }
        }

        AlquilerTableAdapter adapterAlquiler = new AlquilerTableAdapter();

        Alquiler_DS.AlquilerDataTable tableAlquiler = adapterAlquiler.GetAlquileresByUserID(UserId);

        foreach (var row in tableAlquiler)
        {
            if (row.estado)
            {
                TimeSpan ts        = DateTime.Now - row.fechaDevol;
                int      diference = ts.Days;
                if (diference > 0)
                {
                    Alquiler_BRL.DeleteAlquiler(row.AlquilerId);
                }
                else
                {
                    tempTransaction                  = new Transaction();
                    tempTransaction.TotalPago        = row.totalPago;
                    tempTransaction.FechaTransaction = row.fechaAlqui;
                    tempTransaction.UserId           = row.UserId;
                    tempUser = UserCLI_BRL.getUserById(row.UserId);
                    tempTransaction.UserName       = tempUser.Nombre;
                    tempTransaction.EmailUser      = tempUser.Email;
                    tempTransaction.TarjetaCredito = row.tarjetaCredito;
                    tempTransaction.CodigoTarjeta  = row.codigoTarjeta;
                    tempTransaction.PeliculaId     = row.peliculaId;
                    tempMovie = Pelicula_BRL.GetPeliculaByID(row.peliculaId);
                    tempTransaction.NombrePelicula = tempMovie.Nombre;
                    tempTransaction.Foto           = tempMovie.Foto;
                    tempTransaction.Description    = tempMovie.Descripcion;
                    tempTransaction.Director       = tempMovie.Director;
                    tempTransaction.Elenco         = tempMovie.Elenco;
                    tempTransaction.Label          = "<span class='label label-default pull-right'" +
                                                     "style='border-radius:3px; background-color:#777; color:#fff; padding: 6px 3px'" +
                                                     ">Alquiler</span>";


                    listTransaction.Add(tempTransaction);
                }
            }
        }

        return(listTransaction);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        userLogeado = (UserCLI)Session["User"];

        LikeIcon.Text    = "<i class='fa fa-thumbs-o-up'></i>";   //No selected
        DislikeIcon.Text = "<i class='fa fa-thumbs-o-down'></i>"; //No selected
        if (!IsPostBack)
        {
            objSelected  = null;
            tempCompra   = null;
            tempAlquiler = null;
            Response.Cache.SetCacheability(HttpCacheability.ServerAndNoCache);
            Response.Cache.SetAllowResponseInBrowserHistory(false);
            Response.Cache.SetNoStore();
        }


        string cadPeliculaId = Request.Params["Id"];

        if (String.IsNullOrEmpty(cadPeliculaId))
        {
            lbNombrePeli.InnerText = "Error 404 Not Found";
            return;
        }

        int idPelicula = Convert.ToInt32(cadPeliculaId);

        objSelected = Pelicula_BRL.GetPeliculaByID(idPelicula);
        cargarComentarios();

        lbCantLikes.Text    = Like_BRL.GetCantLikes(objSelected.PeliculaId) + " ";
        lbCantDislikes.Text = Like_BRL.GetCantDisLikes(objSelected.PeliculaId) + "";

        Youtube.Src                 = "https://www.youtube.com/embed/" + objSelected.TrailerCode;
        lbNombrePeli.InnerText      = objSelected.Nombre;
        txtDecripcion.InnerText     = objSelected.Descripcion;
        txtDirector.InnerText       = objSelected.Director;
        txtElenco.InnerText         = objSelected.Elenco;
        txtPrecioVenta.InnerText    = objSelected.PrecioVenta + " BS";
        txtPrecioAlquiler.InnerText = objSelected.PrecioAlquiler + " BS";
        if (userLogeado == null)
        {
            btnLike.Enabled        = false;
            btnDislike.Enabled     = false;
            btnAlquilarSel.Visible = false;
            btnComprarSel.Visible  = false;
            FormComent.Visible     = false;
            btnVerPelicula.Visible = false;
            return;
        }

        //CODE THE LIKE VALIDATION

        btnLike.Enabled    = true;
        btnDislike.Enabled = true;

        tempLike = Like_BRL.GetLikeByUserPeliculaID(userLogeado.UserId, objSelected.PeliculaId);

        if (tempLike == null)
        {
            LikeIcon.Text    = "<i class='fa fa-thumbs-o-up'></i>";   //No selected
            DislikeIcon.Text = "<i class='fa fa-thumbs-o-down'></i>"; //No selected
        }
        else
        {
            if (tempLike.IsLike)
            {
                LikeIcon.Text    = "<i class='fa fa-thumbs-up'></i>";     //SELECTED
                DislikeIcon.Text = "<i class='fa fa-thumbs-o-down'></i>"; //No selected
            }
            else
            {
                LikeIcon.Text    = "<i class='fa fa-thumbs-o-up'></i>"; //No selected
                DislikeIcon.Text = "<i class='fa fa-thumbs-down'></i>"; //SELECCIONADO
            }
        }

        FormComent.Visible = true;

        tempCompra = Compra_BRL.GetTransaction(userLogeado.UserId, objSelected.PeliculaId);
        if (tempCompra != null)
        {
            if (tempCompra.Estado)
            {
                btnAlquilarSel.Visible = false;
                btnComprarSel.Visible  = false;
                btnVerPelicula.Visible = true;
            }
        }

        tempAlquiler = Alquiler_BRL.GetTransactionAlq(userLogeado.UserId, objSelected.PeliculaId);
        if (tempAlquiler != null)
        {
            if (tempAlquiler.Estado)
            {
                btnAlquilarSel.Visible = false;
                btnComprarSel.Visible  = false;
                btnVerPelicula.Visible = true;
            }
        }

        txtNombrePropie.Text       = userLogeado.Nombre + " " + userLogeado.Apellido;
        alq_txtNomPropie.Text      = userLogeado.Nombre + " " + userLogeado.Apellido;
        alq_txtCostoAlquixDia.Text = objSelected.PrecioAlquiler + " BS";
    }