protected void btnActualizar_Click(object sender, EventArgs e) { try { EntCine ent = new EntCine(); ent.id = Convert.ToInt32(Request.QueryString["id"]); ent.nombre = txtNomb.Text.ToString(); ent.productor = txtProd.Text.ToString(); ent.sinopsis = txtSino.Text.ToString(); ent.estatus = chkEsta.Checked; ent.clasificacionId = Convert.ToInt32(ddlClas.SelectedValue); ent.generoId = Convert.ToInt32(ddlGenero.SelectedValue); ent.video = txtVideo.Text.ToString(); ent.fechaAlta = DateTime.Now; string ruta = Server.MapPath(@"content\img\"); if (FuFotoPort.HasFile && FuFotoPort.FileName != hfFotoPort.Value) { ent.fotoPort = "content/img/" + FuFotoPort.FileName; FuFotoPort.SaveAs(ruta + FuFotoPort.FileName); File.Delete(ruta + hfFotoPort.Value); } else { ent.fotoPort = hfFotoPort.Value; } if (fuFotoMini.HasFile && fuFotoMini.FileName != hfFotoMini.Value) { ent.fotoMini = "content/img/" + fuFotoMini.FileName; fuFotoMini.SaveAs(ruta + fuFotoMini.FileName); File.Delete(ruta + hfFotoMini.Value); } else { ent.fotoMini = hfFotoMini.Value; } new BusCine().Actualizar(ent); Response.Redirect("Cinepol.aspx"); } catch (Exception ex) { MostrarMensaje(ex.Message); } }
protected void btnAgregar_Click(object sender, EventArgs e) { try { EntCine ent = new EntCine(); if (fuFotoMini.HasFile && FuFotoPort.HasFile) { string ruta = MapPath(@"content\img\"); int fileSize = FuFotoPort.PostedFile.ContentLength; string extension = System.IO.Path.GetExtension(FuFotoPort.FileName); MemoryStream str = new MemoryStream(FuFotoPort.FileBytes); System.Drawing.Image bmp = System.Drawing.Image.FromStream(str); int ancho = bmp.Width; int alto = bmp.Height; if ((extension == ".jpg" || extension == ".jpeg") && (ancho <= 1200 || alto <= 800)) { FuFotoPort.SaveAs(ruta + FuFotoPort.FileName); fuFotoMini.SaveAs(ruta + fuFotoMini.FileName); ent.fotoPort = "content\\img\\" + FuFotoPort.FileName; ent.fotoMini = "content\\img\\" + fuFotoMini.FileName; ent.nombre = txtNomb.Text; ent.productor = txtProd.Text; ent.sinopsis = txtSino.Text; // ent.anio = Convert.ToInt32(ddlAnio.SelectedValue); ent.clasificacionId = Convert.ToInt32(ddlClas.SelectedValue); ent.generoId = Convert.ToInt32(ddlGenero.SelectedValue); ent.estatus = chkEsta.Checked; ent.video = txtVideo.Text; ent.fechaAlta = DateTime.Now; new BusCine().Insertar(ent); Response.Redirect("Cinepol.aspx"); } else { throw new ApplicationException("No se pudo Insertar la pelicula"); } } } catch (Exception ex) { MostrarMensaje(ex.Message); } }