public static List <Alquiler> GetAllAlquileres() { AlquilerTableAdapter adapter = new AlquilerTableAdapter(); Alquiler_DS.AlquilerDataTable table = adapter.GetAlquileres(); List <Alquiler> result = new List <Alquiler>(); Alquiler temp; foreach (var row in table) { temp = new Alquiler(); temp.AlquilerId = row.AlquilerId; temp.TotalPago = row.totalPago; temp.FechaAlqui = row.fechaAlqui; temp.FechaDevol = row.fechaDevol; temp.TarjetaCredito = row.tarjetaCredito; temp.CodigoTarjeta = row.codigoTarjeta; temp.Estado = row.estado; temp.UserId = row.UserId; UserCLI userTemp = UserCLI_BRL.getUserById(row.UserId); temp.Email = userTemp.Email; temp.PeliculaId = row.peliculaId; Pelicula moviesTemp = Pelicula_BRL.GetPeliculaByID(row.peliculaId); temp.NombrePelicula = moviesTemp.Nombre; result.Add(temp); } return(result); }
public static List <Compra> GetAllCompras() { CompraTableAdapter adapter = new CompraTableAdapter(); Compra_DS.CompraDataTable table = adapter.GetCompras(); List <Compra> result = new List <Compra>(); Compra temp; foreach (var row in table) { temp = new Compra(); temp.CompraId = row.CompraId; temp.Fecha = row.fecha; temp.TotalPago = row.totalPago; temp.TarjetaCredito = row.tarjetaCredito; temp.CodigoTarjeta = row.codigoTarjeta; temp.Estado = row.estado; temp.UserId = row.UserId; UserCLI userTemp = UserCLI_BRL.getUserById(row.UserId); temp.Email = userTemp.Email; temp.PeliculaId = row.peliculaId; Pelicula moviesTemp = Pelicula_BRL.GetPeliculaByID(row.peliculaId); temp.NombrePelicula = moviesTemp.Nombre; result.Add(temp); } return(result); }
public static List <Compra> GetComprasByUserID(int UserId) { if (UserId <= 0) { throw new ArgumentException("El UserId no debe ser menor igual a 0"); } CompraTableAdapter adapter = new CompraTableAdapter(); Compra_DS.CompraDataTable table = adapter.GetComprasByUserID(UserId); List <Compra> result = new List <Compra>(); Compra temp; foreach (var row in table) { temp = new Compra(); temp.CompraId = row.CompraId; temp.Fecha = row.fecha; temp.TotalPago = row.totalPago; temp.TarjetaCredito = row.tarjetaCredito; temp.CodigoTarjeta = row.codigoTarjeta; temp.Estado = row.estado; temp.UserId = row.UserId; UserCLI userTemp = UserCLI_BRL.getUserById(row.UserId); temp.Email = userTemp.Email; temp.PeliculaId = row.peliculaId; Pelicula moviesTemp = Pelicula_BRL.GetPeliculaByID(row.peliculaId); temp.NombrePelicula = moviesTemp.Nombre; result.Add(temp); } return(result); }
public void cargarPeliculas() { List <Pelicula> listPeliculas = Pelicula_BRL.GetPeliculas(); ListPeliculas.DataSource = listPeliculas; ListPeliculas.DataBind(); }
protected void GridPeliculas_RowCommand(object sender, GridViewCommandEventArgs e) { int peliculaId = 0; try { peliculaId = Convert.ToInt32(e.CommandArgument); } catch (Exception ex) { } if (peliculaId <= 0) { return; } if (e.CommandName == "Eliminar") { try { Pelicula_BRL.DeletePelicula(peliculaId); cargarPeliculas(); } catch (Exception ex) { Console.Write(ex.Message); throw new Exception("Error al eliminar"); } } if (e.CommandName == "Editar") { Response.Redirect("~/JoyanaADMI/Peliculas/FormPeliculas.aspx?Id=" + peliculaId.ToString()); return; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { objSelected = null; List <Genero> generos = Genero_BRL.GetGeneros(); GenerosList.DataSource = generos; GenerosList.DataBind(); Response.Cache.SetCacheability(HttpCacheability.ServerAndNoCache); Response.Cache.SetAllowResponseInBrowserHistory(false); Response.Cache.SetNoStore(); } string cadPeliculaId = Request.Params["Id"]; if (String.IsNullOrEmpty(cadPeliculaId)) { return; } int idPelicula = Convert.ToInt32(cadPeliculaId); objSelected = Pelicula_BRL.GetPeliculaByID(idPelicula); if (!IsPostBack) { imgPelicula.ImageUrl = objSelected.Foto; txtNombrePel.Text = objSelected.Nombre; txtPrecioVenta.Text = objSelected.PrecioVenta.ToString(CultureInfo.InvariantCulture); txtPrecioAlqui.Text = objSelected.PrecioAlquiler.ToString(CultureInfo.InvariantCulture); txtTrailerCode.Text = objSelected.TrailerCode; txtMovieCode.Text = objSelected.MovieCode; txtDirector.Text = objSelected.Director; txtElenco.Text = objSelected.Elenco; txtDescripción.Text = objSelected.Descripcion; for (int i = 0; i < GenerosList.Items.Count; i++) { PeliculaGenero pelGen = new PeliculaGenero() { PeliculaId = objSelected.PeliculaId, GeneroId = Convert.ToInt32(GenerosList.Items[i].Value) }; if (PeliculaGenero_BRL.tieneGenero(pelGen)) { GenerosList.Items[i].Selected = true; } } } lbVal.Text = ""; lbValFile.Text = ""; }
public static List <Pelicula> GetPeliculasByGenero(int generoId) { PeliculaGeneroTableAdapter adapter = new PeliculaGeneroTableAdapter(); PeliculaGenero_DS.PeliculaGeneroDataTable table = adapter.GetPeliculasByGenero(generoId); List <Pelicula> resultado = new List <Pelicula>(); Pelicula temp; foreach (var row in table) { temp = Pelicula_BRL.GetPeliculaByID(row.peliculaId); resultado.Add(temp); } return(resultado); }
protected void Page_Load(object sender, EventArgs e) { string nombre = Request.Params["Name"]; if (String.IsNullOrEmpty(nombre)) { return; } lbTitle.InnerText = "Busqueda: " + nombre; List <Pelicula> listPeliculas = Pelicula_BRL.GetBusqueda(nombre); ListPeliculas.DataSource = listPeliculas; ListPeliculas.DataBind(); if (!IsPostBack) { Response.Cache.SetCacheability(HttpCacheability.ServerAndNoCache); Response.Cache.SetAllowResponseInBrowserHistory(false); Response.Cache.SetNoStore(); } }
public static Compra GetCompraByID(int CompraId) { if (CompraId <= 0) { throw new ArgumentException("La CompraID debe ser mayor a 0"); } CompraTableAdapter adapter = new CompraTableAdapter(); Compra_DS.CompraDataTable table = adapter.GetCompraByID(CompraId); if (table.Rows.Count == 0) { return(null); } Compra_DS.CompraRow row = table[0]; Compra obj = new Compra(); obj.CompraId = row.CompraId; obj.Fecha = row.fecha; obj.TotalPago = row.totalPago; obj.TarjetaCredito = row.tarjetaCredito; obj.CodigoTarjeta = row.codigoTarjeta; obj.Estado = row.estado; obj.UserId = row.UserId; UserCLI userTemp = UserCLI_BRL.getUserById(row.UserId); obj.Email = userTemp.Email; obj.PeliculaId = row.peliculaId; Pelicula movieTemp = Pelicula_BRL.GetPeliculaByID(row.peliculaId); obj.NombrePelicula = movieTemp.Nombre; return(obj); }
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 btnRegistrar_Click(object sender, EventArgs e) { try { lbVal.Text = ""; lbValFile.Text = ""; string nombre = txtNombrePel.Text.Trim(); decimal precioVenta = Convert.ToDecimal(txtPrecioVenta.Text.Trim(), CultureInfo.InvariantCulture); decimal precioAlquiler = Convert.ToDecimal(txtPrecioAlqui.Text.Trim(), CultureInfo.InvariantCulture); string trailerCode = txtTrailerCode.Text.Trim(); string movieCode = txtMovieCode.Text.Trim(); string descripcion = txtDescripción.Text.Trim(); string director = txtDirector.Text.Trim(); string elenco = txtElenco.Text.Trim(); string urlFoto = imgPelicula.ImageUrl; bool estado = true; if (String.IsNullOrEmpty(nombre)) { lbVal.Text = "La casilla Nombre no debe de estar vacía"; return; } if (String.IsNullOrEmpty(trailerCode)) { lbVal.Text = "La casilla TrailerCODE no debe de estar vacía"; return; } if (String.IsNullOrEmpty(movieCode)) { lbVal.Text = "La casilla MovieCODE no debe de estar vacía"; return; } if (String.IsNullOrEmpty(director)) { lbVal.Text = "La casilla Director no debe de estar vacía"; return; } if (String.IsNullOrEmpty(elenco)) { lbVal.Text = "La casilla Elenco no debe de estar vacía"; return; } if (String.IsNullOrEmpty(descripcion)) { lbVal.Text = "La casilla Descripcion no debe de estar vacía"; return; } if (String.IsNullOrEmpty(urlFoto)) { lbVal.Text = "Debe cargar una foto de portada"; return; } //Insertando la Pelicula if (objSelected == null) { objSelected = new Pelicula(); } objSelected.Nombre = nombre; objSelected.PrecioVenta = precioVenta; objSelected.PrecioAlquiler = precioAlquiler; objSelected.TrailerCode = trailerCode; objSelected.MovieCode = movieCode; objSelected.Descripcion = descripcion; objSelected.Director = director; objSelected.Elenco = elenco; objSelected.Foto = urlFoto; objSelected.Estado = estado; int idPelicula = 0; if (objSelected.PeliculaId <= 0) //Insertando { idPelicula = Pelicula_BRL.InsertPelicula(objSelected); } else //Actualiza { idPelicula = objSelected.PeliculaId; Pelicula_BRL.UpdatePelicula(objSelected); } //Insertando Generos a la Pelicula for (int i = 0; i < GenerosList.Items.Count; i++) { PeliculaGenero pelGen = new PeliculaGenero() { PeliculaId = idPelicula, GeneroId = Convert.ToInt32(GenerosList.Items[i].Value) }; if (GenerosList.Items[i].Selected) { if (!PeliculaGenero_BRL.tieneGenero(pelGen)) { PeliculaGenero_BRL.InsertPeliculaGenero(pelGen); } } else { if (PeliculaGenero_BRL.tieneGenero(pelGen)) { PeliculaGenero_BRL.DeletePeliculaGenero(pelGen); } } } Response.Redirect("~/JoyanaADMI/Peliculas/ListPeliculas.aspx"); } catch (Exception ex) { lbVal.Text = ex.Message; } }
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"; }