コード例 #1
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;
                }
            }
        }