示例#1
0
        private void clearToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                string ClearingMovie = MovieList.SelectedItems[0].Text.ToString();
                MovieClass movie = new MovieClass(ClearingMovie);

                if (Directory.Exists("images\\" + movie.Index.ToString() + " Stars") == true)
                    Directory.Delete("images\\" + movie.Index.ToString() + " Stars", true);
                if (File.Exists("images\\" + movie.Index.ToString() + ".jpg") == true)
                    File.Delete("images\\" + movie.Index.ToString() + ".jpg");

                Movie = new MovieClass(ClearingMovie);
                MovieClass MovieAux = new MovieClass();
                MovieAux.Movie_Name = Movie.Movie_Name;
                MovieAux.Set_Date(Movie.Get_Date_Day().ToString(), Movie.Get_Date_Month().ToString(), Movie.Get_Date_Year().ToString());
                MovieAux.Set_IMDB_Adress(Movie.Get_IMDB_Adress());
                MovieAux.Set_Mark(Movie.Get_Mark());
                MovieAux.Set_Review(Movie.Get_Review());
                if (DataBaseManipulation.DefaultMovie().Movie_Name == MovieAux.Movie_Name)
                    MovieAux.Default = true;
                DataBaseManipulation.UpdateMovie(MovieAux);

                Update_Movie_Details(MovieAux);

                reloadToolStripMenuItem_Click(sender, e);

                MessageBox.Show("\"" + ClearingMovie + "\" was successfully cleaned!", "Successfully cleaned", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch
            {
                Error_Message();
            }
        }
        public static void UpdateMovie(MovieClass Movie,int LastIndex)
        {
            try
            {
                if (DBCon.ConnectionString == "")
                {
                    DBCon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Directory.GetCurrentDirectory() + "\\Movies.mdb;User Id=Admin;Password=;";
                    DBCon.Open();
                }

                string command = "UPDATE Movies SET ";
                command += "Name = '" + WorkerClass.StringWithoutApostrophe(Movie.Movie_Name) + "',";
                command += "[Year] = '" + WorkerClass.StringWithoutApostrophe(Movie.Get_Year()) + "',";
                command += "[Mark] = '" + WorkerClass.StringWithoutApostrophe(Movie.Get_Mark()) + "',";
                command += " IMDb_Adress = '" + WorkerClass.StringWithoutApostrophe(Movie.Get_IMDB_Adress()) + "',";
                command += " [Date] = '" + WorkerClass.StringWithoutApostrophe(Movie.Get_Date_Month().ToString()) + "/" + WorkerClass.StringWithoutApostrophe(Movie.Get_Date_Day().ToString()) + "/" + WorkerClass.StringWithoutApostrophe(Movie.Get_Date_Year().ToString()) + "',";
                command += " [Review] = '" + WorkerClass.StringWithoutApostrophe(Movie.Get_Review()) + "',";
                command += " RunTime = '" + Movie.Runtime + "',";
                command += " IMDb_Name = '" + WorkerClass.StringWithoutApostrophe(Movie.Get_IMDB_Name()) + "',";
                command += " IMDb_Mark = '" + Movie.Get_IMDB_Mark() + "',";
                command += " DirectorName = '" + WorkerClass.StringWithoutApostrophe(Movie.Director) + "',";
                command += " DirectorWebLink = '" + Movie.DirectorLink + "',";
                command += " [Country] = '" + WorkerClass.StringWithApostrophe(WorkerClass.ListToString(Movie.Get_Country())) + "',";
                command += " Stars = '" + WorkerClass.StringWithoutApostrophe(WorkerClass.ListToString(Movie.Get_Stars())) + "',";
                command += " StarsLink = '" + WorkerClass.StringWithoutApostrophe(WorkerClass.ListToString(Movie.Get_StarsLink())) + "',";
                command += " Genres = '" + WorkerClass.StringWithoutApostrophe(WorkerClass.ListToString(Movie.Get_Genre())) + "',";
                command += " [Language] = '" + WorkerClass.StringWithoutApostrophe(WorkerClass.ListToString(Movie.Get_Language())) + "',";
                command += " Tags = '" + WorkerClass.StringWithApostrophe(WorkerClass.ListToString(Movie.Get_Tags())) + "',";
                command += " StoryLine = '" + WorkerClass.StringWithoutApostrophe(Movie.Storyline) + "',";
                command += " TrailerMovie = '" + WorkerClass.StringWithoutApostrophe(Movie.MovieTrailer) + "',";
                command += " DefaultMovie = " + (Movie.Default ? 1 : 0).ToString() + ",";
                command += " MPAA = '" + WorkerClass.StringWithoutApostrophe(Movie.MPAA_Rating) + "',";
                command += " Prizes = '" + WorkerClass.StringWithoutApostrophe(Movie.Prize) + "'";
                command += " WHERE Index = " + LastIndex;

                OleDbCommand DBCom = new OleDbCommand(command, DBCon);
                DBCom.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }