Beispiel #1
0
        private static void LoadNeste(ExcelDoc excel)
        {
            int i = 4; //начальный индекс

            string currentCell = "A" + i;

            while (excel.getValue(currentCell) != null)
            {
                if (excel.getValue(currentCell).ToString() == "Grand Total")
                {
                    break;
                }

                currentCell = "B" + i;
                if (excel.getValue(currentCell) != null)
                {
                    i++;
                    currentCell = "A" + i;
                    continue;
                }

                currentCell = "A" + i;
                string   number   = excel.getValue(currentCell).ToString().Split(' ')[1]; //split example Карта: 7105066553656018
                FuelCard fuelCard = fuelCardList.getItem(number);
                if (fuelCard == null)
                {
                    i++;
                    erorrs.Add("Не найдена карта №" + number); //throw new NullReferenceException("Не найдена карта №" + number);
                    continue;
                }

                currentCell = "C" + i;
                DateTime datetime;
                DateTime.TryParse(excel.getValue(currentCell).ToString(),
                                  out datetime); //присутствует время, не забываем убирать

                currentCell = "D" + i;
                string     engineTypeName = excel.getValue(currentCell).ToString();
                EngineType engineType     = GetEngineType(engineTypeName);

                currentCell = "E" + i;
                double value;
                double.TryParse(excel.getValue(currentCell).ToString(), out value);

                Fuel fuel = new Fuel(fuelCard, datetime.Date, engineType);
                fuel.AddValue(value);
                fuel.Save();

                i++;
                currentCell = "A" + i;
            }
        }
Beispiel #2
0
        private static void LoadPetrol(ExcelDoc excel)
        {
            int i = 4; //начальный индекс

            string currentCell = "B" + i;

            while (excel.getValue(currentCell) != null)
            {
                currentCell = "D" + i;
                string   number   = excel.getValue(currentCell).ToString();
                FuelCard fuelCard = fuelCardList.getItem(number);
                if (fuelCard == null)
                {
                    i++;
                    currentCell = "B" + i;
                    erorrs.Add("Не найдена карта №" + number); //throw new NullReferenceException("Не найдена карта №" + number);
                    continue;
                }

                currentCell = "B" + i;
                string   dateString = excel.getValue1(currentCell).ToString();
                DateTime datetime;
                DateTime.TryParse(dateString, out datetime);//присутствует время, не забываем убирать

                currentCell = "G" + i;
                string     engineTypeName = excel.getValue(currentCell).ToString();
                EngineType engineType     = GetEngineType(engineTypeName);

                currentCell = "H" + i;
                double value;
                double.TryParse(excel.getValue(currentCell).ToString(), out value);

                Fuel fuel = new Fuel(fuelCard, datetime.Date, engineType);
                fuel.AddValue(value);
                fuel.Save();

                i++;
                currentCell = "B" + i;
            }
        }