示例#1
0
        private void mnuStripGenerate_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.dgvMovie.DataSource.Rows.Count > 0)
                {
                    if (saveScript.ShowDialog() == DialogResult.OK)
                    {
                        DataTable dt = new DataTable();
                        dt = Movie_SP.RequestMovieCopyGetList();
                        InsertManager im   = new InsertManager(false, false);
                        string        file = saveScript.FileName;
                        bool          a    = im.GenerateCopyRequestScript(dt, file);

                        if (a == true)
                        {
                            MessageBox.Show(Messages.ScriptGeneratedSuccessfuly, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show(Messages.ScriptGenerationFailed, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
                else
                {
                    throw new Exception(Messages.NoMovieToCopyScript);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
示例#2
0
        private void mnuStripLoad_Click(object sender, EventArgs e)
        {
            try
            {
                if (openScript.ShowDialog() == DialogResult.OK)
                {
                    if (File.Exists(openScript.FileName) == true)
                    {
                        long          failed   = 0;
                        long          notFound = 0;
                        string        file     = openScript.FileName;
                        DataTable     dt       = new DataTable();
                        InsertManager im       = new InsertManager(false, false);
                        dt = im.LoadCopyRequestScript(file, out failed, out notFound);

                        if (dt.Rows.Count > 0)
                        {
                            dgvMovie.DataSource = dt;
                            this.dataSource     = dt;
                        }
                        else if (dt.Rows.Count == 0 && notFound == 0)
                        {
                            throw new Exception(Messages.NoMovieToLoadScript);
                        }

                        if (notFound > 0)
                        {
                            MessageBox.Show(Messages.SomeMoviesNotLoadInScript.Replace("@NUM@", notFound.ToString()).Replace(@"\n", Environment.NewLine), Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                    else
                    {
                        throw new Exception(Messages.SelectFilePath);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
示例#3
0
        private void btnCopy_Click(object sender, EventArgs e)
        {
            try
            {
                string destination = txtCopy.Text;

                if (Directory.Exists(destination) == true)
                {
                    DataTable dtMovies = Movie_SP.RequestMovieCopyGetList();

                    if (dtMovies.Rows.Count > 0)
                    {
                        btnCopy.Enabled  = false;
                        btnClear.Enabled = false;

                        InsertManager im         = new InsertManager(false, false);
                        List <string> notFounded = new List <string>();

                        try
                        {
                            float size = im.CalculateSize(dtMovies, iMovieBase.MovieRootPath);

                            if (MessageBox.Show("Size to copy is about: " + SizeUtils.GetSizeString(size, SizeModeEnum.HumanReadable) + Environment.NewLine + "Start copying?", "iMovie", MessageBoxButtons.OKCancel) == DialogResult.OK)
                            {
                                notFounded = im.CopyMovies(destination, dtMovies, iMovieBase.MovieRootPath);
                            }
                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }
                        finally
                        {
                            this.dataSource     = Movie_SP.RequestMovieCopyGetList();
                            dgvMovie.DataSource = dataSource;
                        }

                        if (notFounded.Count > 0)
                        {
                            MessageBox.Show(Messages.RemainingMoviesNotFound, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }

                        btnCopy.Enabled  = true;
                        btnClear.Enabled = true;
                    }
                    else
                    {
                        throw new Exception(Messages.NoMovieToCopy);
                    }
                }
                else
                {
                    throw new Exception(Messages.SelectDestinationPath);
                }
            }
            catch (Exception ex)
            {
                btnCopy.Enabled  = true;
                btnClear.Enabled = true;

                MessageBox.Show(ex.Message, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
示例#4
0
        private void btnView_Click(object sender, EventArgs e)
        {
            try
            {
                enFilterType languageFilter = enFilterType.Any;

                if (radExactLanguage.Checked == true)
                {
                    languageFilter = enFilterType.Exact;
                }

                enFilterType genreFilter = enFilterType.Any;

                if (radExactGenre.Checked == true)
                {
                    genreFilter = enFilterType.Exact;
                }

                enFilterType directorFilter = enFilterType.Any;

                if (radExactDirector.Checked == true)
                {
                    directorFilter = enFilterType.Exact;
                }

                enFilterType actorFilter = enFilterType.Any;

                if (radExactActor.Checked == true)
                {
                    actorFilter = enFilterType.Exact;
                }

                int count = Convert.ToInt32(txtCount.Value);

                bool?isSeen = null;

                if (chkSeen.Checked == true && chkNotSeen.Checked == false)
                {
                    isSeen = true;
                }
                else if (chkSeen.Checked == false && chkNotSeen.Checked == true)
                {
                    isSeen = false;
                }

                bool?isFavorite = null;

                if (chkFavorite.Checked == true)
                {
                    isFavorite = true;
                }

                double imdbLow = Convert.ToDouble(dropRateLow.SelectedItem);
                double imdbUp  = Convert.ToDouble(dropRateUp.SelectedItem);

                int productLow = 1900;
                int productUp  = DateTime.Now.Year;

                if (Movie.IsProductYear(txtProductLow.Text) == true)
                {
                    productLow = Convert.ToInt32(txtProductLow.Text);
                }

                if (Movie.IsProductYear(txtProductUp.Text) == true)
                {
                    productUp = Convert.ToInt32(txtProductUp.Text);
                }

                string durationLow = "00:00:00";
                string durationUp  = "20:00:00";

                if (Movie.IsDuration(txtDurationLow.Text) == true)
                {
                    durationLow = txtDurationLow.Text;
                }

                if (Movie.IsDuration(txtDurationUp.Text) == true)
                {
                    durationUp = txtDurationUp.Text;
                }

                string movieName = txtMovieName.Text;

                string[] quality = chkQuality.SelectedID;

                if (quality.Length == 0 || chkQuality.SelectAll == true)
                {
                    quality = null;
                }

                string[] language = chkLanguage.SelectedID;

                if (language.Length == 0 || chkLanguage.SelectAll == true)
                {
                    language = null;
                }

                string[] genre = dgvGenre.SelectedID;

                if (genre.Length == 0 || dgvGenre.SelectAll == true)
                {
                    genre = null;
                }

                string[] director = dgvDirector.SelectedID;

                if (director.Length == 0 || dgvDirector.SelectAll == true)
                {
                    director = null;
                }

                string[] actor = dgvActor.SelectedID;

                if (actor.Length == 0 || dgvActor.SelectAll == true)
                {
                    actor = null;
                }

                InsertManager insertManager  = new InsertManager(false, false);
                List <Movie>  excludedMovies = new List <Movie>();

                foreach (PathSource pathSource in pathListBox.DataSource)
                {
                    excludedMovies.AddRange(insertManager.GetMovieListFromPath(pathSource.PathString));
                }

                List <Movie> duplicateMovies = new List <Movie>();

                duplicateMovies = Movie_SP.GetDuplicateMoviesInSource(excludedMovies);

                DataTable dtMovies = Movie_SP.SuggestRandom(count, movieName, productLow, productUp, imdbLow, imdbUp,
                                                            durationLow, durationUp, isSeen, isFavorite, director, directorFilter,
                                                            actor, actorFilter, genre, genreFilter, language, languageFilter, quality, duplicateMovies);

                Movie[] suggestedMovies = new Movie[0];

                suggestedMovies = Movie.FetchAllMovie(dtMovies);

                if (suggestedMovies.Length == 1)
                {
                    if (FormManager.IsFormOpen(enForms.frmMovie, suggestedMovies[0].MovieID) == false)
                    {
                        frmMovie movieTemp = new frmMovie(suggestedMovies[0].MovieID);

                        movieTemp.Show();
                    }
                }
                else if (suggestedMovies.Length > 1)
                {
                    if (FormManager.IsFormOpen(enForms.frmMovieSuggestList, suggestedMovies) == false)
                    {
                        frmMovieSuggestList suggestList = new frmMovieSuggestList(suggestedMovies);

                        suggestList.Show();
                    }
                }
                else
                {
                    MessageBox.Show(Messages.NoMovieFound, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
示例#5
0
        public SqlQuery ToQuery()
        {
            var manager = new InsertManager <TableType>();

            return(manager.ToQuery(instances));
        }