Exemplo n.º 1
0
        private static void FindData(DataBase database)
        {
            Console.Write("Input name of table for search: ");
            MyString     nameOfTable = new MyString(Console.ReadLine().ToCharArray());
            MyList <Row> rows        = database.GetRows(nameOfTable);
            int          action      = -1;

            while (action < 1 || action > rows.Size)
            {
                for (int i = 1; i <= rows.Size; i++)
                {
                    Console.WriteLine($"{i}. Find with field {rows[i - 1].Data[0].GetString()}");
                }
                Console.Write("Action: ");
                action = Convert.ToInt32(Console.ReadLine());
                if (action < 1 || action > rows.Size)
                {
                    Console.WriteLine("ERROR! Wrong action!");
                }
            }
            Console.Write("Input data: ");
            MyString data = new MyString(Console.ReadLine().ToCharArray());

            MyList <Row> result = database.SearchWithField(nameOfTable, action - 1, data);

            ConsolePrint.PrintTable(result);
        }
Exemplo n.º 2
0
        public void Show()
        {
            Console.Write("| ");
            for (int i = 0; i < Rows.Size; i++)
            {
                Console.Write(" {0,12} | ", Rows[i].Data[0].GetString());
            }

            ConsolePrint.PrintLine(Rows.Size);
            Console.Write("| ");

            int j = 0;

            for (int i = 0; i < Rows[0].Data.Size - 1; i++)
            {
                Console.Write(" {0,12} | ", Rows[j].Data[i + 1].GetString());
                if (j + 1 < Rows.Size)
                {
                    j++;
                    i--;
                }
                else
                {
                    j = 0;
                    ConsolePrint.PrintLine(Rows.Size);
                    Console.Write("| ");
                }
            }
            Console.WriteLine();
        }