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());
    }
Exemplo n.º 2
0
    protected void AddMovieButton_Click(object sender, EventArgs e)
    {
        string movieName = MovieNameTextBox.Text.Trim();
        string globalId  = GlobalIDTextBox.Text.Trim();

        if (movieName != "" && globalId != "")
        {
            int    series      = int.Parse(SeriesDropDownList.SelectedValue);
            int    rYear       = int.Parse(ReleaseYearTextBox.Text.Trim());
            bool   d3Available = D3AvailableCheckBox.Checked;
            double rating      = double.Parse(RatingTextBox.Text.Trim());
            int    totalTime   = int.Parse(TotalTimeTextBox.Text.Trim());

            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);
                }
            }

            string trailer = TrailerTextBox.Text.Trim();

            Movie m1 = new Movie(0, movieName, series, rYear, d3Available, rating, totalTime, pic, trailer, int.Parse(globalId));

            Movies.AddMovie(m1);

            int movieID = Movies.GetLastMovieID();

            for (int i = 0; i < GenresListBox.Items.Count; i++)
            {
                if (GenresListBox.Items[i].Selected)
                {
                    Genres.AddGenreAndMovie(int.Parse(GenresListBox.Items[i].Value), movieID);
                }
            }
            Response.Redirect("/Pages/OneMovie.aspx?mid=" + movieID);
        }
    }