Ejemplo n.º 1
0
        //For use when updating display. E.G. when problem is changed, or when
        //the way that the arguments are displayed is changed. Use this to make a
        //whole new argument_display table from an argument_constructor table.
        public void FillArgumentDisplayTable(int num)
        {
            var numberOfQueries = this.GetArgumentListLength(num);
            var arguments       = new string[numberOfQueries];

            if (this.OpenConnection() == true)
            {
                for (var i = 0; i < numberOfQueries; i++)
                {
                    var query = "SELECT derivation FROM argument_constructor_" + num + " where number = " + i + ";";
                    var cmd   = new MySqlCommand(query, connection);
                    arguments[i] = Convert.ToString(cmd.ExecuteScalar());
                }
                this.CloseConnection();
            }
            var argumentsForDisplay = new string[numberOfQueries];
            var problemConstructor  = new ProblemConstructor();

            for (var i = 0; i < numberOfQueries; i++)
            {
                Console.WriteLine(arguments[i]);
                var tempArgument = problemConstructor.MakeCustomArgument(arguments[i]);
                argumentsForDisplay[i] = tempArgument.GetArgumentDisplay();
            }
            if (this.OpenConnection() == true)
            {
                for (var i = 0; i < numberOfQueries; i++)
                {
                    var query = "INSERT INTO argument_display_" + num + " VALUES(" + i + ", N'" + argumentsForDisplay[i] + "');";
                    var cmd   = new MySqlCommand(query, connection);
                    cmd.ExecuteNonQuery();
                }
                this.CloseConnection();
            }
        }
Ejemplo n.º 2
0
        //Testing
        public void InsertArgument(int table)
        {
Loop:
            Console.Write("Argument:");
            var input = Console.ReadLine();

            if (input == "exit")
            {
                goto End;
            }
            var problemConstructor = new ProblemConstructor();
            var newArgument        = problemConstructor.MakeCustomArgument(input);

            if (newArgument == null)
            {
                Console.WriteLine("Bad Syntax, try again.");
                goto Loop;
            }
            string query1 = "INSERT INTO argument_display_" + table + " VALUES(" + GetArgumentListLength(table) + ", N'" + newArgument.GetArgumentDisplay() + "');";
            string query2 = "INSERT INTO argument_constructor_" + table + " VALUES(" + GetArgumentListLength(table) + ", '" + input + "');";

            if (this.OpenConnection() == true)
            {
                var cmd1 = new MySqlCommand(query1, connection);
                var cmd2 = new MySqlCommand(query2, connection);
                cmd1.ExecuteNonQuery();
                cmd2.ExecuteNonQuery();
                this.CloseConnection();
            }

            End :;
        }