Exemple #1
0
        private void ReadFile(string filename)
        {
            try
            {
                using (ExcelDoc excelDoc = new ExcelDoc(filename))
                {
                    try
                    {
                        excelDoc.SetList("Расходы по а-м");

                        string grz = (excelDoc.getValue("B4") != null) ? excelDoc.getValue("B4").ToString() : string.Empty;

                        Car car = GetCar(grz);

                        if (car == null)
                        {
                            string driverFIO = (excelDoc.getValue("B5") != null) ? excelDoc.getValue("B5").ToString() : string.Empty;

                            DriverList driverList = DriverList.getInstance();
                            Driver     driver     = driverList.getItemByFIO(driverFIO);

                            if (driver != null)
                            {
                                DriverCarList driverCarList = DriverCarList.getInstance();
                                car = driverCarList.GetCar(driver);
                            }

                            if (car == null)
                            {
                                _mileageReportList.Add(new MileageReport(null, string.Concat("Не найден автомобиль: ", grz, " сотрудник: ", driverFIO, ". Файл: ", filename)));
                            }
                        }

                        if (car != null)
                        {
                            string value = (excelDoc.getValue("C8") != null) ? excelDoc.getValue("C8").ToString() : string.Empty;

                            SetMileage(car, value);
                        }
                    }

                    catch (IndexOutOfRangeException)
                    {
                        _mileageReportList.Add(new MileageReport(null, string.Concat("Ошибка при чтении файла: ", filename)));
                    }
                    catch (OverflowException)
                    {
                        _mileageReportList.Add(new MileageReport(null, string.Concat("Указан слишком большой пробег в файле: ", filename)));
                    }
                }
            }
            catch
            {
                _mileageReportList.Add(new MileageReport(null, string.Concat("Ошибка при чтении файла: ", filename)));
            }
        }
Exemple #2
0
        private void ReadFile(string filename)
        {
            try
            {
                using (ExcelDoc excelDoc = new ExcelDoc(filename))
                {
                    try
                    {
                        excelDoc.SetList("Расходы по а-м");

                        string grz = (excelDoc.getValue("B4") != null) ? excelDoc.getValue("B4").ToString() : string.Empty;

                        Car car = GetCar(grz);

                        if (car == null)
                        {
                            string driverFIO = (excelDoc.getValue("B5") != null) ? excelDoc.getValue("B5").ToString() : string.Empty;

                            DriverList driverList = DriverList.getInstance();
                            Driver driver = driverList.getItemByFIO(driverFIO);

                            if (driver != null)
                            {
                                DriverCarList driverCarList = DriverCarList.getInstance();
                                car = driverCarList.GetCar(driver);
                            }

                            if (car == null)
                                _mileageReportList.Add(new MileageReport(null, string.Concat("Не найден автомобиль: ", grz, " сотрудник: ", driverFIO, ". Файл: ", filename)));
                        }

                        if (car != null)
                        {
                            string value = (excelDoc.getValue("C8") != null) ? excelDoc.getValue("C8").ToString() : string.Empty;

                            SetMileage(car, value);
                        }
                    }

                    catch (IndexOutOfRangeException)
                    {
                        _mileageReportList.Add(new MileageReport(null, string.Concat("Ошибка при чтении файла: ", filename)));
                    }
                    catch (OverflowException)
                    {
                        _mileageReportList.Add(new MileageReport(null, string.Concat("Указан слишком большой пробег в файле: ", filename)));
                    }
                }
            }
            catch
            {
                _mileageReportList.Add(new MileageReport(null, string.Concat("Ошибка при чтении файла: ", filename)));
            }
        }
        public void Create()
        {
            ExcelDoc doc = new ExcelDoc();

            try
            {
                int i = 1;

                foreach (MileageReport item in _mileageReportList)
                {
                    if (item.IsFailed)
                    {
                        doc.setValue(i, 1, item.ToString());
                        i++;
                    }
                }

                doc.SetList(2);

                i = 1;

                foreach (MileageReport item in _mileageReportList)
                {
                    if (!(item.IsFailed))
                    {
                        doc.setValue(i, 1, item.ToString());
                        i++;
                    }
                }

                doc.Show();
            }

            catch
            {
                doc.Dispose();
            }
        }
        public void Create()
        {
            ExcelDoc doc = new ExcelDoc();

            try
            {
                int i = 1;

                foreach (MileageReport item in _mileageReportList)
                {
                    if (item.IsFailed)
                    {
                        doc.setValue(i, 1, item.ToString());
                        i++;
                    }
                }

                doc.SetList(2);

                i = 1;

                foreach (MileageReport item in _mileageReportList)
                {
                    if (!(item.IsFailed))
                    {
                        doc.setValue(i, 1, item.ToString());
                        i++;
                    }
                }

                doc.Show();
            }

            catch
            {
                doc.Dispose();
            }
        }