示例#1
0
        public bool ClearData()
        {
            bool dataCleared = false;

            ListOfOffers.Clear();
            ListOfContractors.Clear();
            ListOfRoutes.Clear();
            // If the data in all the 3 lists is 0, it means that the lists are empty
            if (ListOfOffers.Count == 0 && ListOfContractors.Count == 0 && ListOfRoutes.Count == 0)
            {
                dataCleared = true;
            }

            return(dataCleared);
        }
示例#2
0
        private bool ImportContractor(string filepath)
        {
            bool isContractorData = false;

            //Get all the info from the CSV file
            string[] data = File.ReadAllLines(filepath, Encoding.GetEncoding("iso-8859-1"));

            //Check if these are columns for the Contractor
            if (data[0].Split(';').Length == 9)
            {
                isContractorData = true;
            }
            if (isContractorData)
            {
                //Go through every row on the CSV file data after the headers (i=1)
                for (int i = 1; i < data.Length; i++)
                {
                    string row = data[i];
                    //Get every column in that row
                    string[] collumns = row.Split(';');

                    string number      = collumns[0];
                    string name        = collumns[1];
                    string companyName = collumns[2];
                    string email       = collumns[3];
                    int    type2       = int.Parse(collumns[4]);
                    int    type3       = int.Parse(collumns[5]);
                    int    type5       = int.Parse(collumns[6]);
                    int    type6       = int.Parse(collumns[7]);
                    int    type7       = int.Parse(collumns[8]);


                    Contractor newContractor = new Contractor(number, companyName, name, email, type2, type3, type5, type6, type7);
                    ListOfContractors.Add(email, newContractor);
                }
            }

            if (ListOfContractors.Count <= 0)
            {
                isContractorData = false;
            }

            return(isContractorData);
        }