private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            /*I check if all TextBoxes have valid values in them, if not they won't be saved*/
            if (TitleTextBox.Text == "Title..." || InstructorTextBox.Text == "Instructor..." || YearTextBox.Text == "Year...")
            {
                MessageBox.Show("All values must be given!");
            }
            else
            {
                /*If the values are valid you have to confirm that you want to save it*/
                MessageBoxResult warning;
                warning = MessageBox.Show("Are you sure you want to add this?", "Warning!", MessageBoxButton.YesNo);
                if (warning == MessageBoxResult.No)
                {
                    this.Close();
                }
                else if (warning == MessageBoxResult.Yes)
                {
                    /*Here I update the values that exist already since this */
                    SqlManagement sqlManagement = new SqlManagement();

                    sqlManagement.RunNonQuery($"UPDATE movieList SET movieTitle = '{TitleTextBox.Text}', " +
                                              $"movieInstructor = '{InstructorTextBox.Text}', movieYear = {Convert.ToInt32(YearTextBox.Text)} WHERE " +
                                              $"movieTitle = '{((MainWindow)Application.Current.MainWindow).ItemList.SelectedItem}'");
                }
            }
        }
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            if (TitleTextBox.Text == "Title..." || InstructorTextBox.Text == "Instructor..." || YearTextBox.Text == "Year...")
            {
                MessageBox.Show("All values must be given!");
            }
            else
            {
                MessageBoxResult warning;
                warning = MessageBox.Show("Are you sure you want to add this?", "Warning!", MessageBoxButton.YesNo);
                if (warning == MessageBoxResult.No)
                {
                    this.Close();
                }
                else if (warning == MessageBoxResult.Yes)
                {
                    SqlManagement sqlManagement = new SqlManagement();

                    sqlManagement.RunNonQuery($"INSERT INTO movieList VALUES ('{TitleTextBox.Text}', '{InstructorTextBox.Text}', {Convert.ToInt32(YearTextBox.Text)})");
                }
            }
        }
Ejemplo n.º 3
0
        private void Delete_Click(object sender, RoutedEventArgs e)
        { /*I run a non query which deletes the selected movie*/
            SqlManagement sqlManagement = new SqlManagement();

            sqlManagement.RunNonQuery($"DELETE FROM movieList WHERE movieTitle = '{ItemList.SelectedItem.ToString()}'");
        }