Example #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();
        }
Example #2
0
        public void Run()
        {
            while (true)
            {
                Console.WriteLine("Select 1 to create new row, 2 to update the table, 3 to read the table, 4 to delete a row, 9 to exit");
                int option = Int32.Parse(Console.ReadLine());
                switch (option)
                {
                case 1:
                    Game   game1     = CreateGameObject();
                    Insert sqlHelper = new Insert();
                    RunSQL(sqlHelper.InsertIntoGame(game1.Name, game1.Genre, game1.Type, game1.Review));
                    break;

                case 2:
                    Console.WriteLine("Enter the column to update: ");
                    string column = Console.ReadLine();
                    Console.WriteLine("Enter the value for the column: ");
                    string value = Console.ReadLine();
                    Console.WriteLine("Enter the name of the game to update");
                    string name       = Console.ReadLine();
                    Update sqlHelper2 = new Update();
                    RunSQL(sqlHelper2.UpdateRowByName(column, value, name));
                    break;

                case 3:
                    Select sqlHelper3 = new Select();
                    RunSQL(sqlHelper3.SelectAll());
                    break;

                case 4:
                    Delete sqlHelper4 = new Delete();
                    Console.WriteLine("Enter the name of the game to delete");
                    string name2 = Console.ReadLine();
                    RunSQL(sqlHelper4.DeleteFromGame(name2));
                    break;

                case 9:
                    return;

                default:
                    break;
                }
            }
        }