Пример #1
0
        private void addCinema__Button_Click(object sender, EventArgs e)
        {
            SQLData.command = new SqlCommand(
                "SELECT 1 FROM userCinemaList WHERE cinema_id=(SELECT cinema_id FROM cinemaList WHERE cinema_name = N'"
                + selectCinema__ComboBox.Items[selectCinema__ComboBox.SelectedIndex] + "')" +
                " AND user_id = " + UserData.Id,
                SQLData.connection);

            SQLData.reader = SQLData.command.ExecuteReader();  // выполнить запрос на считывание

            if (SQLData.reader.HasRows)
            {
                SQLData.reader.Close();
                MessageBox.Show("Добавлять один и тот же фильм запрещено.");
                return;
            }
            SQLData.reader.Close();

            SQLData.command = new SqlCommand(
                "INSERT INTO userCinemaList (user_id, cinema_id, status, user_description) VALUES (" +
                UserData.Id + "," +
                "(SELECT cinema_id FROM cinemaList WHERE cinema_name = N'" + selectCinema__ComboBox.Items[selectCinema__ComboBox.SelectedIndex] + "'), " +
                (selectCinemaStatus__ComboBox.SelectedIndex + 1) + "," +
                "N'" + inputCinemaDescription__TextBox.Text + "')",
                SQLData.connection);

            SQLData.command.ExecuteNonQuery(); // выполнить команду
            urf.InitializeCinemaList();
            this.Hide();
        }
Пример #2
0
        private void editCinema__Button_Click(object sender, EventArgs e)
        {
            SQLData.command = new SqlCommand(
                "UPDATE userCinemaList SET " +
                "cinema_id = (SELECT cinema_id FROM cinemaList WHERE cinema_name = N'" + selectCinema__ComboBox.Text + "'), " +
                "user_description = N'" + inputCinemaDescription__TextBox.Text + "', " +
                "status=" + (selectCinemaStatus__ComboBox.SelectedIndex + 1) +
                " WHERE user_id = " + UserData.Id +
                " AND cinema_id = (SELECT cinema_id FROM cinemaList WHERE cinema_name = N'" + Utils.selected_cinema_name + "')"
                , SQLData.connection);

            SQLData.command.ExecuteNonQuery();

            urf.InitializeCinemaList();
            this.Hide();
        }