Example #1
0
        /// <summary>
        /// Reads the file from the path "myPath" using "mySeparator" as a separator.
        /// Displays the table and saves it at the same path with the same separator.
        /// </summary>
        /// <param name="myInfo"></param>
        public static void GetTable(System.IO.FileInfo myPath, char mySeparator = ';', bool dialog = true, System.Windows.Forms.Form myForm = null)
        {
            if (((int)mySeparator != (int)MyStringOperations.AsciiSet1.Comma) &&
                ((int)mySeparator != (int)MyStringOperations.AsciiSet3.Semicolon))
            {
                throw new ArgumentException("GeneralLibrary|GridInputTable|GetTable the separator should be a comma or a semicolon");
            }

            if (myPath.Exists == false)
            {
                throw new ArgumentException("The input file does not exist");
            }


            MyTable InputTable = new MyTable(MyTable.TypeOfTable.Standard);
            string  MyInput    = MyFileOperations.ReadFile(myPath.FullName);
            // MyStringOperations.Dou
            MyTable        TableToPut = new MyTable(MyInput, MyStringOperations.EndOfLine, mySeparator.ToString(), true);
            GridInputTable MinuTable  = new GridInputTable();
            Tuple <MyTable, DialogResult> LocalTable = MinuTable.GetTableWithHeader(TableToPut, dialog);

            if (LocalTable.Item2 == DialogResult.OK)
            {
                LocalTable.Item1.BackupTable();
                LocalTable.Item1.SaveToSeparated(myPath.FullName, Char.ToString(mySeparator));
            }
        }
Example #2
0
        /// <summary>
        /// Fills the list "listToFill" basing on the header of the file "CSVPath" - the list is firstly cleared. Through the variable "tableId" the ID of the table is passed.  Throws an exception if the file "cSVPath" is wrong.
        /// </summary>
        public static void FillList(ref List <TablesFields> listToFill, string cSVPath, int tableId)
        {
            try
            {
                MyFileOperations.CheckFile(cSVPath);
            }
            catch
            {
                throw new ArgumentException("The file cSVPath does not exist.");
            }

            listToFill.Clear();

            MyTable CSVTable = new MyTable(cSVPath);

            for (int Iterator = 1; Iterator <= CSVTable.ColumnsInFirstRow(); Iterator++)
            {
                string       NameOfField = CSVTable.Content[1 - 1][Iterator - 1];
                TablesFields FieldToAdd  = new TablesFields();
                const string StringType  = "3";
                const string Description = @" id of table=";
                ///  new List<string>() { "ID", "NameOfField", "IDType", "DefaultValue", "IfMandatory", "IfHidden", "IDTable", "IfDependent", "IDMasterField", "IfUnique", "IDConstraint", "Description" };
                FieldToAdd.SetValues(Iterator.ToString(), NameOfField, StringType, "", "false", "false", tableId.ToString(), "false", "", "false", "", NameOfField + Description + tableId.ToString());
                listToFill.Add(FieldToAdd);
            }
        }
Example #3
0
        /// <summary>
        /// Reads the table from the location "myInfo" assuming that there is a CSV file at this location with "mySeparator" as a separator.
        /// </summary>
        /// <param name="tableToSelect"></param>
        public MyGridEditor(System.IO.FileInfo myInfo, char mySeparator)
        {
            if (myInfo.Exists == false)
            {
                throw new ArgumentException("There is no file at the path " + myInfo.FullName);
            }

            FileNameBox.Text = myInfo.FullName;


            //    MyPath = new FileInfo(myInfo.FullName);
            InitializeComponent();
            throw new NotImplementedException();


            string MyInput = MyFileOperations.ReadFile(myInfo.FullName);

            // MyStringOperations.Dou
            MyTable TableToPut = new MyTable(MyInput, MyStringOperations.EndOfLine, mySeparator.ToString(), true);

            // MyTable tableToPut=new MyTable(myInfo.FullName)
            int           MaxCount = TableToPut.Content.Select(Element => Element.Count()).ToList().Max();///The length of the longest row
            List <string> myHeader = TableToPut.Content[0];

            if (MaxCount > myHeader.Count())
            {
                throw new ArgumentException("Wrong arguments passed to the function DisplayGrid");
            }
            for (int Iterator = 1; Iterator <= myHeader.Count(); Iterator++)
            {
                MyGridView2.Columns.Add(myHeader[Iterator - 1], myHeader[Iterator - 1]);
            }

            int GridRow  = 1;
            int TableRow = 1;

            MyGridView2.RowCount = TableToPut.RowCount();
            while
            (TableRow <= (TableToPut.Count()))
            {
                for (int ColumnIterator = 1; ColumnIterator <= TableToPut[TableRow - 1].Count(); ColumnIterator++)
                {
                    MyGridView2[ColumnIterator - 1, GridRow - 1].Value = TableToPut.Content[TableRow - 1][ColumnIterator - 1];
                }
                GridRow  += 1;
                TableRow += 1;
            }
        }