Beispiel #1
0
 public static void DeleteMovie(string id)
 {
     Genres.DeleteMovieGenres(id);
     Actors.DeleteMovieActors(id);
     Directors.DeleteMovieDirectors(id);
     Writers.DeleteMovieWriters(id);
     Awards.DeleteMovieAwards(id);
     DBConn.RunNonQuerySQL("delete from Movies where MovieID=" + id);
 }
    protected void UpdateMovieButton_Click(object sender, EventArgs e)
    {
        int    id       = int.Parse(Request["mid"]);
        string name     = MovieNameTextBox.Text;
        int    serie    = int.Parse(SeriesDropDownList.SelectedValue);
        int    ry       = int.Parse(ReleaseYearTextBox.Text);
        bool   d3       = D3AvailableCheckBox.Checked;
        double rating   = double.Parse(RatingTextBox.Text);
        int    tt       = int.Parse(TotalTimeTextBox.Text);
        int    globalId = int.Parse(GlobalIDTextBox.Text);

        string pic = "";

        if (PhotoFileUpload.PostedFile != null)
        {
            if (PhotoFileUpload.PostedFile.FileName.Trim().Length > 0 && PhotoFileUpload.PostedFile.ContentLength > 0)
            {
                pic = Path.GetFileName(PhotoFileUpload.PostedFile.FileName.Trim());

                string dir  = Server.MapPath("~/Pictures/Movies/");
                string file = Path.GetFileName(PhotoFileUpload.PostedFile.FileName.Trim());

                PhotoFileUpload.PostedFile.SaveAs(dir + file);
            }
            else
            {
                pic = Movies.GetMovieByID(id.ToString()).GetMoviePhoto();
            }
        }


        string trailer = TrailerTextBox.Text;

        Movie m1 = new Movie(id, name, serie, ry, d3, rating, tt, pic, trailer, globalId);

        Movies.UpdateMovie(m1);

        Genres.DeleteMovieGenres(m1.GetID().ToString());

        for (int i = 0; i < GenresListBox.Items.Count; i++)
        {
            if (GenresListBox.Items[i].Selected)
            {
                Genres.AddGenreAndMovie(int.Parse(GenresListBox.Items[i].Value), m1.GetID());
            }
        }

        Response.Redirect("/Pages/OneMovie.aspx?mid=" + m1.GetID());
    }