Ejemplo n.º 1
0
        protected void SaveFilmBtn_Click(object sender, EventArgs e)
        {
            int id = GetFilmId();

            using (var context = new FilmsEntities())
            {
                var film = context.Films
                           .Where(b => b.ID == id)
                           .FirstOrDefault();

                film.Name        = ((TextBox)FilmDetailsView.Rows[0].Cells[0].FindControl("txtName")).Text.Trim();
                film.Description = ((TextBox)FilmDetailsView.Rows[0].Cells[0].FindControl("txtDescr")).Text.Trim();
                string year = ((TextBox)FilmDetailsView.Rows[0].Cells[0].FindControl("txtYear")).Text.Trim();
                film.Year     = short.Parse(year);
                film.Director = ((TextBox)FilmDetailsView.Rows[0].Cells[0].FindControl("txtDirector")).Text.Trim();

                FileUpload fileUpload = (FileUpload)FilmDetailsView.FindControl("PosterUpload");
                if (fileUpload != null)
                {
                    Stream       fs    = fileUpload.PostedFile.InputStream;
                    BinaryReader br    = new BinaryReader(fs);
                    Byte[]       bytes = br.ReadBytes((Int32)fs.Length);
                    film.Poster = bytes;
                }

                context.SaveChanges();
            }
            Response.Redirect("Default.aspx", false);
        }
Ejemplo n.º 2
0
 protected void SetEditMode(bool isEdit)
 {
     if (isEdit)
     {
         FilmDetailsView.ChangeMode(DetailsViewMode.Edit);
     }
     else
     {
         FilmDetailsView.ChangeMode(DetailsViewMode.ReadOnly);
     }
     ((TextBox)FilmDetailsView.Rows[0].Cells[0].FindControl("txtName")).ReadOnly     = !isEdit;
     ((TextBox)FilmDetailsView.Rows[0].Cells[0].FindControl("txtDescr")).ReadOnly    = !isEdit;
     ((TextBox)FilmDetailsView.Rows[0].Cells[0].FindControl("txtYear")).ReadOnly     = !isEdit;
     ((TextBox)FilmDetailsView.Rows[0].Cells[0].FindControl("txtDirector")).ReadOnly = !isEdit;
     SaveFilmBtn.Visible = isEdit;
 }