public static List <string> Load()
        {
            List <string> dataList = new List <string>();
            string        dataFile = ServerUtility.MapPath(@"~/App_Data/InventoryItemTypes.csv");

            using (TextFieldParser parser = new TextFieldParser(dataFile))
            {
                parser.TextFieldType = FieldType.Delimited;
                parser.SetDelimiters(",");

                while (!parser.EndOfData)
                {
                    string[] fields = parser.ReadFields();
                    dataList.Add(fields[0]);
                }
            }
            return(dataList);
        }
Exemplo n.º 2
0
        public static List <StationeryItemData> Load()
        {
            List <StationeryItemData> dataList = new List <StationeryItemData>();
            string dataFile = ServerUtility.MapPath(@"~/App_Data/StationeryItems.csv");

            using (TextFieldParser parser = new TextFieldParser(dataFile))
            {
                parser.TextFieldType = FieldType.Delimited;
                parser.SetDelimiters(",");

                while (!parser.EndOfData)
                {
                    string[]           fields  = parser.ReadFields();
                    StationeryItemData dataRow = new StationeryItemData()
                    {
                        Code = fields[0],
                        Name = fields[1]
                    };
                    dataList.Add(dataRow);
                }
            }
            return(dataList);
        }