Exemplo n.º 1
0
 private void buttonSubmit_Click(object sender, EventArgs e)
 {
     //проверка правильности ввода
     if (CheckDataFilm())
     {
         //проверка названия на дубликат
         if (SqlManipul.GetInstance().ValidMovieTitle(tbTitle.Text))
         {
             //фиксация
             rated = (String.IsNullOrWhiteSpace(tbRated.Text) ? "UNRATED" : tbRated.Text);
             //исполнение
             if (InsertFilm())
             {
                 MessageBox.Show("Фильм - " + tbTitle.Text + " успешно добавлен.", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             else
             {
                 MessageBox.Show("Не удалось добавить фильм - " + tbTitle.Text, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         else
         {
             MessageBox.Show("Фильм с названием - " + tbTitle.Text + " уже существует в базе.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         MessageBox.Show("Заполните все необходимые поля.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 2
0
        private void buttonDeleteFeedBack_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Вы уверены, что хотите удалить отзыв пользователя: " +
                                                  movieDBDataSet.UserFeedBack.Select(cmd)[0]["UserName"] + " ?", "Внимание", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (result == DialogResult.Yes)
            {
                try
                {
                    using (SqlConnection connection = new SqlConnection(SqlManipul.GetInstance().ConnectionString))
                    {
                        connection.Open();
                        userFeedBackTableAdapter.Adapter.DeleteCommand.Connection  = connection;
                        userFeedBackTableAdapter.Adapter.DeleteCommand.CommandText = "delete from UserFeedBack where FeedBackId=@id";
                        userFeedBackTableAdapter.Adapter.DeleteCommand.Parameters.Clear();
                        userFeedBackTableAdapter.Adapter.DeleteCommand.Parameters.Add(new SqlParameter("@id", SqlDbType.Int)
                        {
                            Value = comboBoxFeedBack.SelectedValue
                        });
                        userFeedBackTableAdapter.Adapter.DeleteCommand.ExecuteNonQuery();
                        MessageBox.Show("Отзыв удален из базы данных", "Успех");
                    }
                    this.userFeedBackTableAdapter.Fill(this.movieDBDataSet.UserFeedBack);
                    comboBoxFeedBack.DataSource = movieDBDataSet.UserFeedBack.Select("Allowed=0");
                }
                catch (Exception error)
                {
                    MessageBox.Show(error.Message);
                }
            }
        }
Exemplo n.º 3
0
 public SignUpForm()
 {
     InitializeComponent();
     pictureBoxIcon.Image = new Bitmap(Application.StartupPath + @"\Resources\Icons\logo1.png");
     using (SqlConnection connection = new SqlConnection(SqlManipul.GetInstance().ConnectionString))
     {
         connection.Open();
         try
         {
             SqlCommand    selectRole = new SqlCommand("Select * from UserRole", connection);
             SqlDataReader reader     = selectRole.ExecuteReader();
             if (reader.HasRows)
             {
                 while (reader.Read())
                 {
                     Roles.Add((string)reader.GetValue(1));
                 }
             }
         }
         catch (Exception error)
         {
             MessageBox.Show(error.Message, "Ошибка при определении ролей", MessageBoxButtons.OK, MessageBoxIcon.Error);
             Roles.Add("Администратор");
         }
     }
     comboRole.DataSource = Roles;
 }
Exemplo n.º 4
0
        public SelectedFilmForm()
        {
            InitializeComponent();
            dataGridView1.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
            SqlManipul.GetInstance().DataSetMovies = movieDBDataSet;
            pictureBoxIcon.Image = new Bitmap(Application.StartupPath + @"\Resources\Icons\logo1.png");
            switch (UserDAO.GetInstance().Role)
            {
            case "Администратор":
            {
                buttonFilmAdd.Visible           = true;
                buttonFilmAdd.Enabled           = true;
                buttonModeratorFeedBack.Visible = true;
                buttonModeratorFeedBack.Enabled = true;
            }
            break;

            case "Модератор":
            {
                buttonModeratorFeedBack.Visible = true;
                buttonModeratorFeedBack.Enabled = true;
            }
            break;

            default:
                break;
            }
        }
Exemplo n.º 5
0
 private void dataGridView1_Sorted(object sender, EventArgs e)
 {
     SqlManipul.GetInstance().CurrentFilmId = (int)dataGridView1.Rows[0].Cells[1].Value;
     for (int i = 0; i < dataGridView1.Rows.Count; i++)
     {
         dataGridView1.Rows[i].Cells["PosterImage"].Value = new Bitmap(Application.StartupPath + @"\Resources\Images\" + (string)dataGridView1.Rows[i].Cells["posterData"].Value);
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// Метод производящий регистрацию на сервере
        /// </summary>
        /// <param name="login"></param>
        /// <param name="password"></param>
        /// <param name="role"></param>
        /// <returns></returns>
        public bool RegistrationUser(string login, string password, string role)
        {
            bool result = false;

            using (SqlConnection connection = new SqlConnection(SqlManipul.GetInstance().ConnectionString))
            {
                connection.Open();
                SqlTransaction transaction = connection.BeginTransaction();
                try
                {
                    SqlCommand registrationCommand = new SqlCommand("RegistrationUser", connection);
                    registrationCommand.CommandType = CommandType.StoredProcedure;
                    registrationCommand.Transaction = transaction;
                    SqlParameter pLog = new SqlParameter("@Login", SqlDbType.NVarChar, 20);
                    pLog.Value = login;
                    SqlParameter pPas = new SqlParameter("@Password", SqlDbType.NVarChar, 20);
                    pPas.Value = password;
                    SqlParameter pRole = new SqlParameter("@Role", SqlDbType.NVarChar, 20);
                    pRole.Value = role;
                    SqlParameter pResult = new SqlParameter("@result", SqlDbType.Bit);
                    pResult.Direction = ParameterDirection.Output;

                    registrationCommand.Parameters.Add(pLog);
                    registrationCommand.Parameters.Add(pPas);
                    registrationCommand.Parameters.Add(pRole);
                    registrationCommand.Parameters.Add(pResult);

                    registrationCommand.ExecuteNonQuery();
                    result = (bool)registrationCommand.Parameters["@result"].Value;
                    if (result)
                    {
                        transaction.Commit();
                    }
                    else
                    {
                        transaction.Rollback();
                    }
                }
                catch (Exception error)
                {
                    MessageBox.Show(error.Message, "Ошибка при попытке регистрации", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    transaction.Rollback();
                }
            }
            if (result)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 7
0
 private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (dataGridView1.DataSource != null)
         {
             SqlManipul.GetInstance().CurrentFilmId = (int)dataGridView1.CurrentRow.Cells[1].Value;
         }
     }
     catch (Exception error)
     {
         MessageBox.Show(error.Message);
     }
 }
Exemplo n.º 8
0
 public PrintOrSavePosterForm()
 {
     InitializeComponent();
     using (SqlConnection connection = new SqlConnection(SqlManipul.GetInstance().ConnectionString))
     {
         connection.Open();
         pictureBoxIcon.Image = new Bitmap(Application.StartupPath + @"\Resources\Icons\logo1.png");
         SqlCommand command = new SqlCommand("select Poster from Movie where MovieId=@filmid", connection);
         command.Parameters.Add(new SqlParameter("@filmid", SqlDbType.Int)
         {
             Value = SqlManipul.GetInstance().CurrentFilmId
         });
         path = Application.StartupPath + @"\Resources\Images\" + command.ExecuteScalar().ToString();
     }
 }
Exemplo n.º 9
0
 private void buttonShowSelectedFilm_Click(object sender, EventArgs e)
 {
     if (SqlManipul.GetInstance().CurrentFilmId != -1)
     {
         DialogResult result = ShowNextForm(new ShowFilmForm(), true);
         if (result == DialogResult.Abort)
         {
             DialogResult = DialogResult.Abort;
         }
         dataGridView1.Sort(dataGridView1.Columns["рейтинг10DataGridViewTextBoxColumn"], ListSortDirection.Descending);
     }
     else
     {
         MessageBox.Show("Для просмотра подробной информации о фильме, его следует выбрать.", "Фильм не выбран", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemplo n.º 10
0
 private void buttonSubmit_Click(object sender, EventArgs e)
 {
     //проверка выбранных пунктов фильтров
     //жанр
     SqlManipul.GetInstance().GenreFilterId = (checkEnableGenre.Checked) ? (int)comboGenre.SelectedValue : -1;
     //страна
     SqlManipul.GetInstance().CountryFilterId = (checkEnableCountry.Checked) ? (int)comboCountry.SelectedValue : -1;
     //режиссёр
     SqlManipul.GetInstance().DirectorFilterId = (checkEnableDirector.Checked) ? (int)comboDirector.SelectedValue : -1;
     //язык
     SqlManipul.GetInstance().LanguageFilterId = (checkEnableLanguage.Checked) ? (int)comboLanguage.SelectedValue : -1;
     //возрастной рейтинг
     SqlManipul.GetInstance().RatedFilterId = (checkEnableRated.Checked) ? (int)comboRated.SelectedValue : -1;
     //год выхода
     SqlManipul.GetInstance().YearFilterVal = (checkEnableYear.Checked) ? (int)numericYear.Value : -1;
     this.DialogResult = DialogResult.Yes;
 }
Exemplo n.º 11
0
        /// <summary>
        /// Метод производящий авторизацию пользователя
        /// </summary>
        /// <param name="login"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public bool SignIn(string login, string password)
        {
            Role = "";
            using (SqlConnection connection = new SqlConnection(SqlManipul.GetInstance().ConnectionString))
            {
                connection.Open();
                try
                {
                    SqlCommand signInCommand = new SqlCommand("SignInUser", connection);
                    signInCommand.CommandType = System.Data.CommandType.StoredProcedure;
                    SqlParameter parLogin = new SqlParameter("@Login", SqlDbType.NVarChar, 20);
                    parLogin.Value = login;
                    SqlParameter parPassword = new SqlParameter("Password", SqlDbType.NVarChar, 20);
                    parPassword.Value = password;
                    //возвращаемые значения
                    SqlParameter parRole = new SqlParameter("@Role", SqlDbType.NVarChar, 20);
                    parRole.Direction = ParameterDirection.Output;
                    SqlParameter parResult = new SqlParameter("@result", SqlDbType.Bit);
                    parResult.Direction = ParameterDirection.Output;
                    signInCommand.Parameters.Add(parLogin);
                    signInCommand.Parameters.Add(parPassword);
                    signInCommand.Parameters.Add(parRole);
                    signInCommand.Parameters.Add(parResult);

                    signInCommand.ExecuteNonQuery();
                    if ((bool)signInCommand.Parameters["@result"].Value)
                    {
                        this.Role = (string)signInCommand.Parameters["@Role"].Value;
                    }
                }
                catch (Exception error)
                {
                    MessageBox.Show(error.Message, "Ошибка при попытке авторизации", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            if (!String.IsNullOrEmpty(Role))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 12
0
        private void buttonSelectFilther_Click(object sender, EventArgs e)
        {
            DialogResult result = ShowNextForm(new MovieFilterForm(), true);

            switch (result)
            {
            case DialogResult.Abort:
                DialogResult = DialogResult.Abort;
                break;

            case DialogResult.Yes:
            {
                string filter = SqlManipul.GetInstance().GetFilterIdFilms();
                if (!String.IsNullOrEmpty(filter))
                {
                    dataGridView1.DataSource = movieDBDataSet.vMovies.Select("ID in (" + filter + ")").CopyToDataTable();
                }
                else
                {
                    dataGridView1.DataSource = null;
                }
            }
            break;

            case DialogResult.No:
            {
                dataGridView1.DataSource = movieDBDataSet.vMovies;
            }
            break;

            default:
                break;
            }
            dataGridView1.Sort(dataGridView1.Columns["рейтинг10DataGridViewTextBoxColumn"], ListSortDirection.Descending);
            if (result != DialogResult.Abort)
            {
                for (int i = 0; i < dataGridView1.Rows.Count; i++)
                {
                    dataGridView1.Rows[i].Cells["PosterImage"].Value = new Bitmap(Application.StartupPath + @"\Resources\Images\" + (string)dataGridView1.Rows[i].Cells["posterData"].Value);
                }
            }
        }
Exemplo n.º 13
0
 private void buttonSubmit_Click(object sender, EventArgs e)
 {
     if (!String.IsNullOrEmpty(tbName.Text) && !String.IsNullOrEmpty(tbComment.Text))
     {
         using (SqlConnection connection = new SqlConnection(SqlManipul.GetInstance().ConnectionString))
         {
             try
             {
                 connection.Open();
                 SqlCommand command = new SqlCommand("insert into UserFeedBack (UserName,Comment,MovieId) values (@name,@comment,@movieid)", connection);
                 command.Parameters.Add(new SqlParameter("@name", SqlDbType.NVarChar, 50)
                 {
                     Value = tbName.Text
                 });
                 command.Parameters.Add(new SqlParameter("@comment", SqlDbType.NVarChar, 2000)
                 {
                     Value = tbComment.Text
                 });
                 command.Parameters.Add(new SqlParameter("@movieid", SqlDbType.Int)
                 {
                     Value = SqlManipul.GetInstance().CurrentFilmId
                 });
                 command.ExecuteNonQuery();
                 MessageBox.Show("Ваш отзыв успешно отправлен на модерацию.", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             catch (Exception err)
             {
                 MessageBox.Show(err.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
     else
     {
         MessageBox.Show("Нельзя оставлять поля пустыми", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 14
0
        public MovieFilterForm()
        {
            InitializeComponent();
            pictureBoxIcon.Image = new Bitmap(Application.StartupPath + @"\Resources\Icons\logo1.png");
            //заполнение comboBox данными по фильтрам из БД
            using (SqlConnection connection = new SqlConnection(SqlManipul.GetInstance().ConnectionString))
            {
                connection.Open();
                List <DataTable> filterTables = new List <DataTable>();

                filterTables.Add(new DataTable("Genre"));
                filterTables.Add(new DataTable("Country"));
                filterTables.Add(new DataTable("Director"));
                filterTables.Add(new DataTable("Language"));
                filterTables.Add(new DataTable("Rated"));


                //устанока select на жанры и заполнение таблицы
                SqlDataAdapter adapter = new SqlDataAdapter("select * from Genre order by GenreName", connection);
                adapter.Fill(filterTables[0]);
                //заполнение списком стран
                adapter.SelectCommand.CommandText = "select * from Country order by CountryName";
                adapter.Fill(filterTables[1]);
                //заполнение списком режиссёров
                adapter.SelectCommand.CommandText = "select distinct PersonId,Name from vDirectorsInMovieTable order by Name";
                adapter.Fill(filterTables[2]);
                //заполнение списком языков
                adapter.SelectCommand.CommandText = "select * from Language order by LanguageName";
                adapter.Fill(filterTables[3]);
                //заполнение списком возрастного рейтинга
                adapter.SelectCommand.CommandText = "select * from Rated order by RatedName";
                adapter.Fill(filterTables[4]);

                foreach (DataTable table in filterTables)
                {
                    dataFilters.Tables.Add(table);
                }
            }
            //настройка данных для comboBox
            //жанр
            comboGenre.DataSource    = dataFilters.Tables[0];
            comboGenre.DisplayMember = "GenreName";
            comboGenre.ValueMember   = "GenreId";
            //страна
            comboCountry.DataSource    = dataFilters.Tables[1];
            comboCountry.DisplayMember = "CountryName";
            comboCountry.ValueMember   = "CountryId";
            //режиссёр
            comboDirector.DataSource    = dataFilters.Tables[2];
            comboDirector.DisplayMember = "Name";
            comboDirector.ValueMember   = "PersonId";
            //язык
            comboLanguage.DataSource    = dataFilters.Tables[3];
            comboLanguage.DisplayMember = "LanguageName";
            comboLanguage.ValueMember   = "LanguageId";
            //возрастной рейтинг
            comboRated.DataSource    = dataFilters.Tables[4];
            comboRated.DisplayMember = "RatedName";
            comboRated.ValueMember   = "RatedId";

            //восстановление фильтра по его текущему состоянию
            if (SqlManipul.GetInstance().GenreFilterId != -1)
            {
                checkEnableGenre.Checked = true;
                comboGenre.SelectedValue = SqlManipul.GetInstance().GenreFilterId;
            }
            if (SqlManipul.GetInstance().CountryFilterId != -1)
            {
                checkEnableCountry.Checked = true;
                comboCountry.SelectedValue = SqlManipul.GetInstance().CountryFilterId;
            }
            if (SqlManipul.GetInstance().DirectorFilterId != -1)
            {
                checkEnableDirector.Checked = true;
                comboDirector.SelectedValue = SqlManipul.GetInstance().DirectorFilterId;
            }
            if (SqlManipul.GetInstance().LanguageFilterId != -1)
            {
                checkEnableLanguage.Checked = true;
                comboLanguage.SelectedValue = SqlManipul.GetInstance().LanguageFilterId;
            }
            if (SqlManipul.GetInstance().RatedFilterId != -1)
            {
                checkEnableRated.Checked = true;
                comboRated.SelectedValue = SqlManipul.GetInstance().RatedFilterId;
            }
            if (SqlManipul.GetInstance().YearFilterVal != -1)
            {
                checkEnableYear.Checked = true;
                numericYear.Value       = SqlManipul.GetInstance().YearFilterVal;
            }
        }
Exemplo n.º 15
0
        private bool InsertFilm()
        {
            bool result = false;

            using (SqlConnection connection = new SqlConnection(SqlManipul.GetInstance().ConnectionString))
            {
                connection.Open();
                SqlTransaction transaction = connection.BeginTransaction();
                try
                {
                    //Добавление фильма с получением его primary key
                    int        FilmId;
                    SqlCommand insertCommand = connection.CreateCommand();
                    insertCommand.CommandType = CommandType.StoredProcedure;
                    insertCommand.Transaction = transaction;
                    insertCommand.CommandText = "InsertMovie";

                    //добаление обязательных параметров

                    //возвращаемое значение
                    insertCommand.Parameters.Add(new SqlParameter("@result", SqlDbType.Int)
                    {
                        Direction = ParameterDirection.Output
                    });
                    //заголовок
                    insertCommand.Parameters.Add(new SqlParameter("@Title", SqlDbType.NVarChar, 50)
                    {
                        Value = tbTitle.Text
                    });
                    //имя рейтинга
                    insertCommand.Parameters.Add(new SqlParameter("@Rated", SqlDbType.NVarChar, 30)
                    {
                        Value = rated
                    });
                    //дата релиза
                    insertCommand.Parameters.Add(new SqlParameter("@Released", SqlDbType.DateTime)
                    {
                        Value = releasedDate
                    });
                    //длительность
                    insertCommand.Parameters.Add(new SqlParameter("@RunTime", SqlDbType.Int)
                    {
                        Value = (int)numericRuntime.Value
                    });
                    //описание
                    insertCommand.Parameters.Add(new SqlParameter("@Plot", SqlDbType.NVarChar, 500)
                    {
                        Value = tbPlot.Text
                    });
                    //постер
                    insertCommand.Parameters.Add(new SqlParameter("@Poster", SqlDbType.NVarChar, 50)
                    {
                        Value = poster
                    });
                    //рейтинг
                    insertCommand.Parameters.Add(new SqlParameter("@Rating", SqlDbType.Float)
                    {
                        Value = 5.0f
                    });

                    //опциональные параметры
                    //проверка на установленный флаг
                    if (cBAdditionalParam.Checked)
                    {
                        //награды
                        if (!String.IsNullOrWhiteSpace(tBAwards.Text))
                        {
                            insertCommand.Parameters.Add(new SqlParameter("@Awards", SqlDbType.NVarChar, 100)
                            {
                                Value = tBAwards.Text
                            });
                        }
                        //рейтинг imdb
                        if (numericImdbRated.Value != 0)
                        {
                            insertCommand.Parameters.Add(new SqlParameter("@ImdbRating", SqlDbType.Float)
                            {
                                Value = (float)Math.Round(numericImdbRated.Value, 2)
                            });
                        }
                        //метасумма
                        if (numericMetaScore.Value != 0)
                        {
                            insertCommand.Parameters.Add(new SqlParameter("@MetaScore", SqlDbType.Int)
                            {
                                Value = (int)numericMetaScore.Value
                            });
                        }
                        //голоса
                        if (numericImdbVotes.Value != 0)
                        {
                            insertCommand.Parameters.Add(new SqlParameter("@Votes", SqlDbType.Int)
                            {
                                Value = (int)numericImdbVotes.Value
                            });
                        }
                        //dvd
                        if (dvd != default(DateTime))
                        {
                            insertCommand.Parameters.Add(new SqlParameter("@DVD", SqlDbType.DateTime)
                            {
                                Value = dvd
                            });
                        }
                        //сборы
                        if (numericBoxOffice.Value != 0)
                        {
                            insertCommand.Parameters.Add(new SqlParameter("@BoxOffice", SqlDbType.Int)
                            {
                                Value = (int)numericBoxOffice.Value
                            });
                        }
                        //сайт
                        if (!String.IsNullOrWhiteSpace(tbSite.Text))
                        {
                            insertCommand.Parameters.Add(new SqlParameter("@SiteURL", SqlDbType.NVarChar, 100)
                            {
                                Value = tbSite.Text
                            });
                        }
                    }
                    insertCommand.ExecuteNonQuery();
                    FilmId = (int)insertCommand.Parameters["@result"].Value;

                    //добавление записей в обязательные таблицы
                    //параметр id фильма
                    SqlParameter paramFilmId = new SqlParameter("@FilmId", SqlDbType.Int)
                    {
                        Value = FilmId
                    };


                    //жанр
                    insertCommand.Parameters.Clear();
                    insertCommand.CommandText = "InsertMovieOnGenre";
                    //аргумент названия
                    insertCommand.Parameters.Add(new SqlParameter("@GenreValue", SqlDbType.NVarChar, 30));
                    insertCommand.Parameters.Add(paramFilmId);
                    for (int index = 0; index < tableGenre.Rows.Count; index++)
                    {
                        insertCommand.Parameters["@GenreValue"].Value = (string)tableGenre.Rows[index][0];
                        insertCommand.ExecuteNonQuery();
                    }

                    //язык
                    insertCommand.Parameters.Clear();
                    insertCommand.CommandText = "InsertMovieOnLanguage";
                    insertCommand.Parameters.Add(new SqlParameter("@LanguageValue", SqlDbType.NVarChar, 30));
                    insertCommand.Parameters.Add(paramFilmId);
                    for (int index = 0; index < tableLanguage.Rows.Count; index++)
                    {
                        insertCommand.Parameters["@LanguageValue"].Value = (string)tableLanguage.Rows[index][0];
                        insertCommand.ExecuteNonQuery();
                    }

                    //страна
                    insertCommand.Parameters.Clear();
                    insertCommand.CommandText = "InsertMovieOnCountry";
                    insertCommand.Parameters.Add(new SqlParameter("@CountryValue", SqlDbType.NVarChar, 30));
                    insertCommand.Parameters.Add(paramFilmId);
                    for (int index = 0; index < tableCountry.Rows.Count; index++)
                    {
                        insertCommand.Parameters["@CountryValue"].Value = (string)tableCountry.Rows[index][0];
                        insertCommand.ExecuteNonQuery();
                    }

                    //режиссёр
                    insertCommand.Parameters.Clear();
                    insertCommand.CommandText = "InsertPersonInMovie";
                    insertCommand.Parameters.Add(new SqlParameter("@PersonName", SqlDbType.NVarChar, 60));
                    insertCommand.Parameters.Add(new SqlParameter("@RoleName", SqlDbType.NVarChar, 30)
                    {
                        Value = "Director"
                    });
                    insertCommand.Parameters.Add(paramFilmId);
                    for (int index = 0; index < tableDirector.Rows.Count; index++)
                    {
                        insertCommand.Parameters["@PersonName"].Value = (string)tableDirector.Rows[index][0];
                        insertCommand.ExecuteNonQuery();
                    }


                    //опциональные записи
                    //проверка установки галочки на доп параметры
                    if (cBAdditionalParam.Checked)
                    {
                        //актёры
                        if (tableActors.Rows.Count > 0)
                        {
                            insertCommand.Parameters.Clear();
                            insertCommand.CommandText = "InsertPersonInMovie";
                            insertCommand.Parameters.Add(new SqlParameter("@PersonName", SqlDbType.NVarChar, 60));
                            insertCommand.Parameters.Add(new SqlParameter("@RoleName", SqlDbType.NVarChar, 30)
                            {
                                Value = "Actors"
                            });
                            insertCommand.Parameters.Add(paramFilmId);
                            for (int index = 0; index < tableActors.Rows.Count; index++)
                            {
                                insertCommand.Parameters["@PersonName"].Value = (string)tableActors.Rows[index][0];
                                insertCommand.ExecuteNonQuery();
                            }
                        }

                        //писатели
                        if (tableWriters.Rows.Count > 0)
                        {
                            insertCommand.Parameters.Clear();
                            insertCommand.CommandText = "InsertPersonInMovie";
                            insertCommand.Parameters.Add(new SqlParameter("@PersonName", SqlDbType.NVarChar, 60));
                            insertCommand.Parameters.Add(new SqlParameter("@RoleName", SqlDbType.NVarChar, 30));
                            insertCommand.Parameters.Add(paramFilmId);
                            for (int index = 0; index < tableWriters.Rows.Count; index++)
                            {
                                insertCommand.Parameters["@PersonName"].Value = (string)tableWriters.Rows[index][0];
                                insertCommand.Parameters["@RoleName"].Value   = (String.IsNullOrWhiteSpace(tableWriters.Rows[index][1].ToString()) ? "Writer" : (string)tableWriters.Rows[index][1]);
                                insertCommand.ExecuteNonQuery();
                            }
                        }

                        //студия производитель
                        if (tableProduction.Rows.Count > 0)
                        {
                            insertCommand.Parameters.Clear();
                            insertCommand.CommandText = "InsertMovieOnProduction";
                            insertCommand.Parameters.Add(new SqlParameter("@ProductionValue", SqlDbType.NVarChar, 30));
                            insertCommand.Parameters.Add(paramFilmId);
                            for (int index = 0; index < tableProduction.Rows.Count; index++)
                            {
                                insertCommand.Parameters["@ProductionValue"].Value = (string)tableProduction.Rows[index][0];
                                insertCommand.ExecuteNonQuery();
                            }
                        }
                    }

                    transaction.Commit();
                    result = true;
                }
                catch (Exception error)
                {
                    transaction.Rollback();
                    MessageBox.Show(error.Message, "Ошибка при попытке добавить фильм", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    result = false;
                }
            }
            return(result);
        }
Exemplo n.º 16
0
 private void ShowFeedBackFirmForm_Load(object sender, EventArgs e)
 {
     // TODO: данная строка кода позволяет загрузить данные в таблицу "movieDBDataSet.UserFeedBack". При необходимости она может быть перемещена или удалена.
     this.userFeedBackTableAdapter.Fill(this.movieDBDataSet.UserFeedBack);
     comboBoxFeedBack.DataSource = movieDBDataSet.UserFeedBack.Select("MovieId=" + SqlManipul.GetInstance().CurrentFilmId + " and Allowed=1");
 }
Exemplo n.º 17
0
 private void buttonReset_Click(object sender, EventArgs e)
 {
     SqlManipul.GetInstance().FilterReset();
     this.DialogResult = DialogResult.No;
 }