コード例 #1
0
        public List <EntCine> ObtenerPelicula()
        {
            DataTable      dt    = new DatCine().ObtenerPelicula();
            List <EntCine> lista = new List <EntCine>();

            foreach (DataRow dr in dt.Rows)
            {
                EntCine ent = new EntCine();
                ent.id              = Convert.ToInt32(dr["PELI_ID"]);
                ent.nombre          = dr["PELI_NOMB"].ToString();
                ent.sinopsis        = dr["PELI_SINO"].ToString();
                ent.generoId        = Convert.ToInt32(dr["PELI_GENE_ID"]);
                ent.clasificacionId = Convert.ToInt32(dr["PELI_CLAS_ID"]);
                ent.fotoMini        = dr["PELI_FOTO_MINI"].ToString();
                ent.fotoPort        = dr["PELI_FOTO_PORT"].ToString();
                ent.anio            = Convert.ToInt32(dr["PELI_ANIO"]);
                ent.fechaAlta       = Convert.ToDateTime(dr["PELI_FECH_ALTA"]);
                ent.estatus         = Convert.ToBoolean(dr["PELI_ESTA"]);
                ent.video           = dr["PELI_VIDE"].ToString();
                ent.productor       = dr["PELI_PROD"].ToString();
                //ent.Clas = new EntClasificacion();
                ent.Clas.nombre = dr["CLAS_NOMB"].ToString();
                //ent.Genero = new EntGenero();
                ent.Genero.nombre = dr["GENE_NOMB"].ToString();

                lista.Add(ent);
            }
            return(lista);
        }
コード例 #2
0
 protected void btnBorrar_Click(object sender, EventArgs e)
 {
     try
     {
         EntCine ent = new EntCine();
         ent.id = Convert.ToInt32(Request.QueryString["id"]);
         new BusCine().Borrar(ent);
         Response.Redirect(Request.CurrentExecutionFilePath);
     }
     catch (Exception ex)
     {
         MostrarMensaje(ex.Message);
     }
 }
コード例 #3
0
 protected void gvPeliculas_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     try
     {
         EntCine ent = new EntCine();
         ent.id = Convert.ToInt32(gvPeliculas.DataKeys[e.RowIndex].Values["id"]);
         new BusCine().Borrar(ent);
         Response.Redirect("Cinepol.aspx");
     }
     catch (Exception ex)
     {
         MostrarMensaje(ex.Message);
     }
 }
コード例 #4
0
    protected void gvPeliculas_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        try
        {
            EntCine ent  = new EntCine();
            string  ruta = Server.MapPath(@"content\img\");
            ent.id              = Convert.ToInt32(gvPeliculas.DataKeys[e.RowIndex].Values["id"]);
            ent.nombre          = ((TextBox)gvPeliculas.Rows[e.RowIndex].FindControl("EITtxtNombre")).Text;
            ent.sinopsis        = ((TextBox)gvPeliculas.Rows[e.RowIndex].FindControl("EITtxtSinopsis")).Text;
            ent.generoId        = Convert.ToInt32(((DropDownList)gvPeliculas.Rows[e.RowIndex].FindControl("EITddlGenero")).SelectedValue);
            ent.clasificacionId = Convert.ToInt32(((DropDownList)gvPeliculas.Rows[e.RowIndex].FindControl("EITddlClasificacion")).SelectedValue);

            FileUpload fuFotoMini = (FileUpload)gvPeliculas.Rows[e.RowIndex].FindControl("EITfuFotoMini");
            if (fuFotoMini.HasFile && fuFotoMini.FileName != gvPeliculas.DataKeys[e.RowIndex].Values["fotomini"].ToString())
            {
                ent.fotoMini = @"content\img\" + fuFotoMini.FileName;
                fuFotoMini.SaveAs(ruta + fuFotoMini.FileName);
            }
            else
            {
                ent.fotoMini = gvPeliculas.DataKeys[e.RowIndex].Values["fotomini"].ToString();
            }


            FileUpload fuFotoPort = (FileUpload)gvPeliculas.Rows[e.RowIndex].FindControl("EITfuFotoPort");
            if (fuFotoPort.HasFile && fuFotoPort.FileName != gvPeliculas.DataKeys[e.RowIndex].Values["fotoport"].ToString())
            {
                ent.fotoPort = @"content\img\" + fuFotoPort.FileName;
                fuFotoPort.SaveAs(ruta + fuFotoPort.FileName);
            }
            else
            {
                ent.fotoPort = gvPeliculas.DataKeys[e.RowIndex].Values["fotoport"].ToString();
            }


            ent.anio      = Convert.ToInt32(((DropDownList)gvPeliculas.Rows[e.RowIndex].FindControl("EITddlAnio")).SelectedValue);
            ent.fechaAlta = Convert.ToDateTime(((TextBox)gvPeliculas.Rows[e.RowIndex].FindControl("EITtxtAlta")).Text);
            ent.estatus   = ((CheckBox)gvPeliculas.Rows[e.RowIndex].FindControl("EITchkEstatus")).Checked;
            ent.video     = ((TextBox)gvPeliculas.Rows[e.RowIndex].FindControl("EITtxtVideo")).Text;
            ent.productor = ((TextBox)gvPeliculas.Rows[e.RowIndex].FindControl("EITtxtProductor")).Text;
            new BusCine().Actualizar(ent);
            Response.Redirect("Cinepol.aspx");
        }
        catch (Exception ex)
        {
            MostrarMensaje(ex.Message);
        }
    }
コード例 #5
0
    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);
        }
    }
コード例 #6
0
    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);
        }
    }
コード例 #7
0
        public EntCine obtener(int id)
        {
            DataRow dr  = new DatCine().Obtener(id);
            EntCine ent = new EntCine();

            ent.id              = Convert.ToInt32(dr["PELI_ID"]);
            ent.nombre          = dr["PELI_NOMB"].ToString();
            ent.sinopsis        = dr["PELI_SINO"].ToString();
            ent.generoId        = Convert.ToInt32(dr["PELI_GENE_ID"]);
            ent.clasificacionId = Convert.ToInt32(dr["PELI_CLAS_ID"]);
            ent.fotoMini        = dr["PELI_FOTO_MINI"].ToString();
            ent.fotoPort        = dr["PELI_FOTO_PORT"].ToString();
            ent.anio            = Convert.ToInt32(dr["PELI_ANIO"]);
            ent.fechaAlta       = Convert.ToDateTime(dr["PELI_FECH_ALTA"]);
            ent.estatus         = Convert.ToBoolean(dr["PELI_ESTA"]);
            ent.video           = dr["PELI_VIDE"].ToString();
            ent.productor       = dr["PELI_PROD"].ToString();

            return(ent);
        }
コード例 #8
0
    protected void lnkAgregar_Click(object sender, EventArgs e)
    {
        try
        {
            EntCine ent  = new EntCine();
            string  ruta = Server.MapPath(@"content\img\");
            //TextBox txtNombre = new TextBox();
            //txtNombre = (TextBox)gvPeliculas.FooterRow.FindControl("FTtxtNombre");
            //ent.nombre = txtNombre.Text;
            // Estas 3 lineas hacen la misma accion que la siguiente linea
            ent.nombre          = ((TextBox)gvPeliculas.FooterRow.FindControl("FTtxtNombre")).Text;
            ent.sinopsis        = ((TextBox)gvPeliculas.FooterRow.FindControl("FTtxtSinopsis")).Text;
            ent.generoId        = Convert.ToInt32(((DropDownList)gvPeliculas.FooterRow.FindControl("FTddlGenero")).SelectedValue);
            ent.clasificacionId = Convert.ToInt32(((DropDownList)gvPeliculas.FooterRow.FindControl("FTddlClasificacion")).SelectedValue);

            FileUpload fuFotoMini = (FileUpload)gvPeliculas.FooterRow.FindControl("FTfuFotoMini");
            ent.fotoMini = @"content\img\" + fuFotoMini.FileName;
            fuFotoMini.SaveAs(ruta + fuFotoMini.FileName);

            FileUpload fuFotoPort = (FileUpload)gvPeliculas.FooterRow.FindControl("FTfuFotoPort");
            ent.fotoPort = @"content\img\" + fuFotoPort.FileName;
            fuFotoPort.SaveAs(ruta + fuFotoPort.FileName);


            ent.anio      = Convert.ToInt32(((DropDownList)gvPeliculas.FooterRow.FindControl("FTddlAnio")).SelectedValue);
            ent.fechaAlta = Convert.ToDateTime(((TextBox)gvPeliculas.FooterRow.FindControl("FTtxtFecha")).Text);
            ent.estatus   = ((CheckBox)gvPeliculas.FooterRow.FindControl("FTchkEstatus")).Checked;
            ent.video     = ((TextBox)gvPeliculas.FooterRow.FindControl("FTtxtVideo")).Text;
            ent.productor = ((TextBox)gvPeliculas.FooterRow.FindControl("FTtxtProductor")).Text;
            new BusCine().Insertar(ent);
            Response.Redirect("Cinepol.aspx");
        }
        catch (Exception ex)
        {
            MostrarMensaje(ex.Message);
        }
    }