Exemplo n.º 1
0
        /// <summary>
        /// Looks for the column named "commentColumn" and applies to all columns from the list "addTags"
        /// the function AddColumnBetween. Displays the table obtained in such a way.
        /// An exception is thrown if any string from addTags and commentColumn is missing inside the first row.
        /// </summary>
        /// <param name="addTags"></param>
        public void DisplayAddTable(List <string> addTags, string commentColumn)
        {
            DateTime TimeOne     = DateTime.Now;
            MyTable  LocalTable  = TableInfo();///Put into the variable LocalTable the current content from the form.
            int      FoundColumn = LocalTable.FindInFirstRow(commentColumn);

            if (FoundColumn <= 0)
            {
                throw new ArgumentException("Wrong argument commentColumn passed to DisplayAddTable");
            }

            List <string> CommentColumn = LocalTable.GiveColumn(FoundColumn);

            for (int MyIterator = 1; MyIterator <= addTags.Count(); MyIterator++)
            {
                if (LocalTable.FindInFirstRow(addTags[MyIterator - 1]) <= 0)
                {
                    throw new ArgumentException("Wrong column name passed inside the argument addTags, the name is " + addTags[MyIterator - 1]);
                }
                LocalTable.AddColumnBetween(commentColumn, addTags[MyIterator - 1]);
            }
            DateTime     TimeTwo   = DateTime.Now;
            TimeSpan     MySpan    = (TimeTwo - TimeOne);
            const string AddedInfo = "GridInputTable|DisplayAddTable";

            MyStringOperations.LogInfo(MySpan, AddedInfo);
            DisplayTable(LocalTable);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Collects the info from the control MyGridView2
        /// </summary>
        /// <returns></returns>
        public MyTable TableInfo()
        {
            DateTime DateOne = DateTime.Now;
            List <List <string> > MyContent  = new List <List <string> >();
            List <string>         HeaderList = new List <string>();

            //   MyGridView2.Columns.Count
            for (int Iterator = 1; Iterator <= MyGridView2.Columns.Count; Iterator++)
            {
                string MyHeader = MyGridView2.Columns[Iterator - 1].HeaderText;
                HeaderList.Add(MyHeader);
            }
            MyContent.Add(HeaderList);
            for (int Iterator = 1; Iterator <= MyGridView2.RowCount; Iterator++)
            {
                List <string> MyRowItem = new List <string>();
                for (int ColumnIterator = 1; ColumnIterator <= MyGridView2.ColumnCount; ColumnIterator++)
                {
                    string CollectedValue = (MyGridView2[ColumnIterator - 1, Iterator - 1].Value is null) ?
                                            "" : MyGridView2[ColumnIterator - 1, Iterator - 1].Value.ToString();
                    MyRowItem.Add(CollectedValue);
                }
                MyContent.Add(MyRowItem);
            }
            DateTime DateTwo       = DateTime.Now;
            TimeSpan MySpan        = DateTwo - DateOne;
            MyTable  TableToReturn = new MyTable(MyContent);

            LogList.Add(MyStringOperations.LogInfo(MySpan));
            return(TableToReturn);
        }