コード例 #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 ImportRoute(string filepath)
        {
            bool isRouteData = false;

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


            //Check if these are 5 columns for the Route
            if (data[0].Split(';').Length == 5)
            {
                isRouteData = true;
            }

            if (isRouteData)
            {
                //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 collumn in that row
                    string[] collumns = row.Split(';');

                    int routeNr = int.Parse(collumns[0]);

                    int vehType       = int.Parse(collumns[1]);
                    int hoursWeekdays = int.Parse(collumns[2]);
                    int hoursWeekends = int.Parse(collumns[3]);
                    int hoursHolidays = int.Parse(collumns[4]);

                    Route newRoute = new Route(routeNr, vehType, hoursWeekdays, hoursWeekends, hoursHolidays);
                    ListOfRoutes.Add(routeNr, newRoute);
                }
            }

            if (ListOfRoutes.Count <= 0)
            {
                isRouteData = false;
            }

            return(isRouteData);
        }