Exemplo n.º 1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            SQL_STATEMENT option     = (SQL_STATEMENT)Enum.ToObject(typeof(SQL_STATEMENT), SqlOption.SelectedIndex);
            Game          gameObject = new Game(nameField.Text, genreField.Text, typeField.Text, reviewField.Text);
            List <string> result;

            switch (option)
            {
            case SQL_STATEMENT.INSERT:
                application.RunSQL(insert.InsertIntoGame(gameObject));
                break;

            case SQL_STATEMENT.UPDATE:
                application.RunSQL(update.UpdateRowByName(genreField.Text, typeField.Text, nameField.Text));
                break;

            case SQL_STATEMENT.SELECT:
                application.RunSQL(select.SelectAll(), out result);
                if (result != null)
                {
                    PrintToListBox(result);
                }
                break;

            case SQL_STATEMENT.DELETE:
                application.RunSQL(delete.DeleteFromGame(nameField.Text));
                break;

            default:
                break;
            }
            ClearTextBoxes();
        }
Exemplo n.º 2
0
        private void SqlOption_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBox      cb     = sender as ComboBox;
            SQL_STATEMENT option = (SQL_STATEMENT)Enum.ToObject(typeof(SQL_STATEMENT), cb.SelectedIndex);

            switch (option)
            {
            case SQL_STATEMENT.INSERT:
                EnableTextBoxes();
                break;

            case SQL_STATEMENT.UPDATE:
                EnableTextBoxes();
                nameField.Text  = "Game name";
                genreField.Text = "Column to update";
                typeField.Text  = "Value";
                reviewField.Clear();
                reviewField.IsEnabled = false;
                break;

            case SQL_STATEMENT.SELECT:
                DisableTextBoxes();
                break;

            case SQL_STATEMENT.DELETE:
                EnableTextBoxes();
                break;

            default:
                break;
            }
        }