Пример #1
0
 public List <PlaceB> GetPlaces(int recSkip, int recTake, string recFilter, GridSortExpressionCollection gridSortExxpressions)
 {
     using (var dbContext = new OTERTConnStr()) {
         try {
             dbContext.Configuration.ProxyCreationEnabled = false;
             IQueryable <PlaceB> datatmp = (from us in dbContext.Places
                                            select new PlaceB {
                 ID = us.ID,
                 CountryID = us.CountryID,
                 NameGR = us.NameGR,
                 NameEN = us.NameEN,
                 Country = new CountryDTO {
                     ID = us.Countries.ID, NameGR = us.Countries.NameGR, NameEN = us.Countries.NameEN
                 }
             });
             if (!string.IsNullOrEmpty(recFilter))
             {
                 datatmp = datatmp.Where(recFilter);
             }
             if (gridSortExxpressions.Count > 0)
             {
                 datatmp = datatmp.OrderBy(gridSortExxpressions[0].FieldName + " " + gridSortExxpressions[0].SortOrder);
             }
             else
             {
                 datatmp = datatmp.OrderByDescending(o => o.ID);
             }
             List <PlaceB> data = datatmp.Skip(recSkip).Take(recTake).ToList();
             return(data);
         }
         catch (Exception) { return(null); }
     }
 }
Пример #2
0
 public List <EventB> GetEvents(int recSkip, int recTake, string recFilter, GridSortExpressionCollection gridSortExxpressions)
 {
     using (var dbContext = new OTERTConnStr()) {
         try {
             dbContext.Configuration.ProxyCreationEnabled = false;
             List <EventB> data = (from us in dbContext.Events
                                   select new EventB {
                 ID = us.ID,
                 PlaceID = us.PlaceID,
                 NameGR = us.NameGR,
                 NameEN = us.NameEN,
                 Place = new PlaceDTO {
                     ID = us.Places.ID,
                     NameGR = us.Places.NameGR,
                     NameEN = us.Places.NameEN,
                     Country = new CountryDTO {
                         ID = us.Places.Countries.ID,
                         NameGR = us.Places.Countries.NameGR,
                         NameEN = us.Places.Countries.NameEN
                     },
                     CountryID = us.Places.CountryID
                 }
             }).OrderBy(o => o.ID).Skip(recSkip).Take(recTake).ToList();
             return(data);
         }
         catch (Exception) { return(null); }
     }
 }
Пример #3
0
        protected void gridMain_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            int    recSkip   = gridMain.CurrentPageIndex * gridMain.PageSize;
            int    recTake   = gridMain.PageSize;
            string recFilter = gridMain.MasterTableView.FilterExpression;
            GridSortExpressionCollection gridSortExxpressions = gridMain.MasterTableView.SortExpressions;

            try {
                DistancesController cont = new DistancesController();
                gridMain.VirtualItemCount = cont.CountDistances(recFilter);
                gridMain.DataSource       = cont.GetDistances(recSkip, recTake, recFilter, gridSortExxpressions);
            }
            catch (Exception) { }
        }
Пример #4
0
 protected void btnExportZip_Click(object sender, EventArgs e)
 {
     try {
         List <File4ListB>            files                = new List <File4ListB>();
         List <string>                errors               = new List <string>();
         string                       recFilter            = gridMain.MasterTableView.FilterExpression;
         GridSortExpressionCollection gridSortExxpressions = gridMain.MasterTableView.SortExpressions;
         FilesController              cont = new FilesController();
         int tasksCount = cont.CountFiles(recFilter);
         files = cont.GetFilesForList(0, tasksCount, recFilter, gridSortExxpressions);
         if (files.Count > 0)
         {
             MemoryStream memStream = new MemoryStream();
             using (ZipArchive archive = new ZipArchive(memStream, ZipArchiveMode.Create, true, null)) {
                 foreach (File4ListB file in files)
                 {
                     string physicalPath = System.Web.HttpContext.Current.Server.MapPath(file.FilePath);
                     string fileName     = Path.GetFileName(physicalPath);
                     if (File.Exists(physicalPath))
                     {
                         using (ZipArchiveEntry entry = archive.CreateEntry(fileName)) {
                             BinaryWriter writer = new BinaryWriter(entry.Open());
                             writer.Write(File.ReadAllBytes(physicalPath));
                             writer.Flush();
                         }
                     }
                     else
                     {
                         errors.Add(fileName + " (A/A:" + file.ID.ToString() + ")");
                     }
                 }
             }
             bool sendZip = false;
             if (files.Count > errors.Count)
             {
                 sendZip = true;
             }
             if (errors.Count > 0)
             {
                 ShowMissingFiles(errors, memStream, sendZip);
             }
             else
             {
                 SendZipToClient(memStream);
             }
         }
     }
     catch (Exception) { ShowErrorMessage(); }
 }
Пример #5
0
 public List <UserB> GetUsers(int recSkip, int recTake, string recFilter, GridSortExpressionCollection gridSortExxpressions)
 {
     using (var dbContext = new OTERTConnStr()) {
         try {
             dbContext.Configuration.ProxyCreationEnabled = false;
             IQueryable <UserB> datatmp = (from us in dbContext.Users
                                           select new UserB {
                 ID = us.ID,
                 UserGroupID = us.UserGroupID,
                 NameGR = us.NameGR,
                 NameEN = us.NameEN,
                 Telephone = us.Telephone,
                 FAX = us.FAX,
                 Email = us.Email,
                 UserName = us.UserName,
                 Password = us.Password,
                 UserGroup = new UserGroupDTO {
                     ID = us.UserGroups.ID, Name = us.UserGroups.Name
                 }
             });
             if (!string.IsNullOrEmpty(recFilter))
             {
                 datatmp = datatmp.Where(recFilter);
             }
             if (gridSortExxpressions.Count > 0)
             {
                 datatmp = datatmp.OrderBy(gridSortExxpressions[0].FieldName + " " + gridSortExxpressions[0].SortOrder);
             }
             else
             {
                 datatmp = datatmp.OrderByDescending(o => o.ID);
             }
             List <UserB> data = datatmp.Skip(recSkip).Take(recTake).ToList();
             return(data);
         }
         catch (Exception) { return(null); }
     }
 }
Пример #6
0
 public List <InvoiceB> GetInvoices(int recSkip, int recTake, string recFilter, GridSortExpressionCollection gridSortExxpressions)
 {
     using (var dbContext = new OTERTConnStr()) {
         try {
             dbContext.Configuration.ProxyCreationEnabled = false;
             IQueryable <InvoiceB> datatmp = (from us in dbContext.Invoices
                                              select new InvoiceB {
                 ID = us.ID,
                 CustomerID = us.CustomerID,
                 Customer = new CustomerDTO {
                     ID = us.Customers.ID,
                     CountryID = us.Customers.CountryID,
                     NameGR = us.Customers.NameGR,
                     NameEN = us.Customers.NameEN,
                     NamedInvoiceGR = us.Customers.NamedInvoiceGR,
                     NamedInvoiceEN = us.Customers.NamedInvoiceEN,
                     ZIPCode = us.Customers.ZIPCode,
                     CityGR = us.Customers.CityGR,
                     CityEN = us.Customers.CityEN,
                     ChargeTelephone = us.Customers.ChargeTelephone,
                     Telephone1 = us.Customers.Telephone1,
                     Telephone2 = us.Customers.Telephone2,
                     FAX1 = us.Customers.FAX1,
                     FAX2 = us.Customers.FAX2,
                     Address1GR = us.Customers.Address1GR,
                     Address1EN = us.Customers.Address1EN,
                     Address2GR = us.Customers.Address2GR,
                     Address2EN = us.Customers.Address2EN,
                     ContactPersonGR = us.Customers.ContactPersonGR,
                     ContactPersonEN = us.Customers.ContactPersonEN,
                     CustomerTypeID = us.Customers.CustomerTypeID,
                     LanguageID = us.Customers.LanguageID,
                     Email = us.Customers.Email,
                     URL = us.Customers.URL,
                     AFM = us.Customers.AFM,
                     DOY = us.Customers.DOY,
                     SAPCode = us.Customers.SAPCode,
                     UserID = us.Customers.UserID,
                     Comments = us.Customers.Comments,
                     IsProvider = us.Customers.IsProvider,
                     IsOTE = us.Customers.IsOTE
                 },
                 DateFrom = us.DateFrom,
                 DateTo = us.DateTo,
                 DateCreated = us.DateCreated,
                 RegNo = us.RegNo,
                 DatePaid = us.DatePaid,
                 TasksLineAmount = us.TasksLineAmount,
                 DiscountLineAmount = us.DiscountLineAmount,
                 IsLocked = us.IsLocked
             });
             if (!string.IsNullOrEmpty(recFilter))
             {
                 IQueryable    test              = dbContext.Invoices;
                 string[]      expressionsAND    = recFilter.Split(new string[] { "AND" }, StringSplitOptions.None);
                 List <string> columnExpressions = new List <string>();
                 for (int k = 0; k < expressionsAND.Length; k++)
                 {
                     if (!expressionsAND[k].Contains("OR"))
                     {
                         columnExpressions.Add(expressionsAND[k]);
                     }
                     else
                     {
                         string[] expressionsOR = expressionsAND[k].Split(new string[] { "OR" }, StringSplitOptions.None);
                         for (int i = 0; i < expressionsOR.Length; i++)
                         {
                             columnExpressions.Add(expressionsOR[i]);
                         }
                     }
                 }
                 List <string> DateFromExpressions = columnExpressions.Where(item => item.Contains("DateFrom")).ToList();
                 List <string> DateToExpressions   = columnExpressions.Where(item => item.Contains("DateTo")).ToList();
                 columnExpressions.RemoveAll(item => item.Contains("DateFrom") || item.Contains("DateTo"));
                 recFilter = string.Join("AND", columnExpressions.ToArray());
                 if (!string.IsNullOrEmpty(recFilter))
                 {
                     datatmp = datatmp.Where(recFilter.Replace("[", "").Replace("]", ""));
                 }
                 System.Globalization.DateTimeFormatInfo greek = new System.Globalization.CultureInfo("el-GR").DateTimeFormat;
                 if (DateFromExpressions.Count > 0)
                 {
                     List <DateTime> dateFromDates = new List <DateTime>();
                     foreach (string dtExpression in DateFromExpressions)
                     {
                         char testChar = '"';
                         if (dtExpression.Contains("'"))
                         {
                             testChar = '\'';
                         }
                         string[] dateExp = dtExpression.Split(new char[] { testChar });;
                         string   format  = "d/M/yyyy,h:mm:ss,tt";
                         DateTime newDate;
                         if (dateExp.Length > 1)
                         {
                             if (DateTime.TryParseExact(dateExp[1], format, greek, System.Globalization.DateTimeStyles.None, out newDate))
                             {
                                 dateFromDates.Add(newDate);
                             }
                         }
                     }
                     if (dateFromDates.Count == 2)
                     {
                         if (!string.IsNullOrEmpty(recFilter))
                         {
                             recFilter += " AND ";
                         }
                         if (DateFromExpressions[0].Contains(">="))
                         {
                             recFilter = "DateFrom >= @0 AND DateFrom <= @1";
                         }
                         else
                         {
                             recFilter = "DateFrom < @0 OR DateFrom > @1";
                         }
                         test = test.Where(recFilter, new DateTime(dateFromDates[0].Year, dateFromDates[0].Month, dateFromDates[0].Day, dateFromDates[0].Hour, dateFromDates[0].Minute, 0), new DateTime(dateFromDates[1].Year, dateFromDates[1].Month, dateFromDates[1].Day, dateFromDates[1].Hour, dateFromDates[1].Minute, 0));
                     }
                     else
                     {
                         test = test.Where(DateFromExpressions[0]);
                     }
                 }
                 if (DateToExpressions.Count > 0)
                 {
                     List <DateTime> dateToDates = new List <DateTime>();
                     foreach (string dtExpression in DateToExpressions)
                     {
                         char testChar = '"';
                         if (dtExpression.Contains("'"))
                         {
                             testChar = '\'';
                         }
                         string[] dateExp = dtExpression.Split(new char[] { testChar });
                         string   format  = "d/M/yyyy,h:mm:ss,tt";
                         DateTime newDate;
                         if (dateExp.Length > 1)
                         {
                             if (DateTime.TryParseExact(dateExp[1], format, greek, System.Globalization.DateTimeStyles.None, out newDate))
                             {
                                 dateToDates.Add(newDate);
                             }
                         }
                     }
                     if (dateToDates.Count == 2)
                     {
                         if (!string.IsNullOrEmpty(recFilter))
                         {
                             recFilter += " AND ";
                         }
                         if (DateToExpressions[0].Contains(">="))
                         {
                             recFilter = "DateTo >= @0 AND DateTo <= @1";
                         }
                         else
                         {
                             recFilter = "DateTo < @0 OR DateTo > @1";
                         }
                         test = test.Where(recFilter, new DateTime(dateToDates[0].Year, dateToDates[0].Month, dateToDates[0].Day, dateToDates[0].Hour, dateToDates[0].Minute, 0), new DateTime(dateToDates[1].Year, dateToDates[1].Month, dateToDates[1].Day, dateToDates[1].Hour, dateToDates[1].Minute, 0));
                     }
                     else
                     {
                         test = test.Where(DateToExpressions[0]);
                     }
                 }
             }
             if (gridSortExxpressions.Count > 0)
             {
                 string sortFieldName = "";
                 if (gridSortExxpressions[0].FieldName == "CustomerID")
                 {
                     sortFieldName = "Customer.NameGR";
                 }
                 else
                 {
                     sortFieldName = gridSortExxpressions[0].FieldName;
                 }
                 datatmp = datatmp.OrderBy(sortFieldName + " " + gridSortExxpressions[0].SortOrder);
             }
             else
             {
                 datatmp = datatmp.OrderByDescending(o => o.ID);
             }
             List <InvoiceB> data = datatmp.Skip(recSkip).Take(recTake).ToList();
             return(data);
         }
         catch (Exception ex) { return(null); }
     }
 }
Пример #7
0
        public List <File4ListB> GetFilesForList(int recSkip, int recTake, string recFilter, GridSortExpressionCollection gridSortExxpressions)
        {
            using (var dbContext = new OTERTConnStr()) {
                try {
                    dbContext.Configuration.ProxyCreationEnabled = false;
                    System.Globalization.DateTimeFormatInfo greek = new System.Globalization.CultureInfo("el-GR").DateTimeFormat;
                    IQueryable <File4ListB> datatmp = (from us in dbContext.Files
                                                       select new File4ListB {
                        ID = us.ID,
                        OrderID = us.OrderID,
                        TaskID = us.TaskID,
                        CustomerID = us.CustomerID != null ? us.CustomerID : (us.Tasks.CustomerID > 0 ? us.Tasks.CustomerID : (us.Orders.Customer1ID > 0 ? us.Orders.Customer1ID : -1)),
                        CustomerName = us.CustomerID != null ? us.Customers.NameGR : (us.Tasks.CustomerID > 0 ? us.Tasks.Customers.NameGR : (us.Orders.Customer1ID > 0 ? us.Orders.Customers1.NameGR : "")),
                        FilePath = us.FilePath,
                        FileName = us.FileName,
                        DateStamp = us.DateStamp
                    });
                    if (!string.IsNullOrEmpty(recFilter))
                    {
                        IQueryable test           = dbContext.Files;
                        string[]   expressionsAND = recFilter.Split(new string[] { "AND" }, StringSplitOptions.None);

                        List <string> columnExpressions = new List <string>();
                        for (int k = 0; k < expressionsAND.Length; k++)
                        {
                            if (!expressionsAND[k].Contains("OR"))
                            {
                                columnExpressions.Add(expressionsAND[k]);
                            }
                            else
                            {
                                string[] expressionsOR = expressionsAND[k].Split(new string[] { "OR" }, StringSplitOptions.None);
                                for (int i = 0; i < expressionsOR.Length; i++)
                                {
                                    columnExpressions.Add(expressionsOR[i]);
                                }
                            }
                        }
                        List <string> OrderDateExpressions = columnExpressions.Where(item => item.Contains("DateStamp")).ToList();
                        columnExpressions.RemoveAll(item => item.Contains("DateStamp"));
                        recFilter = string.Join("AND", columnExpressions.ToArray());
                        if (!string.IsNullOrEmpty(recFilter))
                        {
                            datatmp = datatmp.Where(recFilter);
                        }
                        if (OrderDateExpressions.Count > 0)
                        {
                            List <DateTime> orderDates = new List <DateTime>();
                            foreach (string dtExpression in OrderDateExpressions)
                            {
                                string[] dateExp = dtExpression.Split(new char[] { '"' });
                                string   format  = "d/M/yyyy,h:mm:ss,tt";
                                DateTime newDate;
                                if (dateExp.Length > 1)
                                {
                                    if (DateTime.TryParseExact(dateExp[1], format, greek, System.Globalization.DateTimeStyles.None, out newDate))
                                    {
                                        orderDates.Add(newDate);
                                    }
                                }
                            }
                            if (orderDates.Count == 2)
                            {
                                if (!string.IsNullOrEmpty(recFilter))
                                {
                                    recFilter += " AND ";
                                }
                                if (OrderDateExpressions[0].Contains(">="))
                                {
                                    recFilter = "DateStamp >= @0 AND DateStamp <= @1";
                                }
                                else
                                {
                                    recFilter = "DateStamp < @0 OR DateStamp > @1";
                                }
                                datatmp = datatmp.Where(recFilter, new DateTime(orderDates[0].Year, orderDates[0].Month, orderDates[0].Day, orderDates[0].Hour, orderDates[0].Minute, 0), new DateTime(orderDates[1].Year, orderDates[1].Month, orderDates[1].Day, orderDates[1].Hour, orderDates[1].Minute, 0));
                            }
                            else
                            {
                                datatmp = datatmp.Where(OrderDateExpressions[0]);
                            }
                        }
                    }
                    if (gridSortExxpressions.Count > 0)
                    {
                        datatmp = datatmp.OrderBy(gridSortExxpressions[0].FieldName + " " + gridSortExxpressions[0].SortOrder);
                    }
                    else
                    {
                        datatmp = datatmp.OrderByDescending(o => o.DateStamp);
                    }
                    List <File4ListB> data = datatmp.Skip(recSkip).Take(recTake).ToList();
                    return(data);
                }
                catch (Exception) { return(null); }
            }
        }
Пример #8
0
 public List <DistanceB> GetDistances(int recSkip, int recTake, string recFilter, GridSortExpressionCollection gridSortExxpressions)
 {
     using (var dbContext = new OTERTConnStr()) {
         try {
             dbContext.Configuration.ProxyCreationEnabled = false;
             IQueryable <DistanceB> datatmp = (from us in dbContext.Distances
                                               select new DistanceB {
                 ID = us.ID,
                 JobsMainID = us.JobsMainID,
                 JobsMain = new JobMainDTO {
                     ID = us.JobsMain.ID, PageID = us.JobsMain.PageID, Name = us.JobsMain.Name
                 },
                 Description = us.Position1 + " - " + us.Position2 + " (" + us.KM.ToString() + " km)",
                 Position1 = us.Position1,
                 Position2 = us.Position2,
                 KM = us.KM
             });
             if (!string.IsNullOrEmpty(recFilter))
             {
                 datatmp = datatmp.Where(recFilter);
             }
             if (gridSortExxpressions.Count > 0)
             {
                 datatmp = datatmp.OrderBy(gridSortExxpressions[0].FieldName + " " + gridSortExxpressions[0].SortOrder);
             }
             else
             {
                 datatmp = datatmp.OrderByDescending(o => o.ID);
             }
             List <DistanceB> data = datatmp.Skip(recSkip).Take(recTake).ToList();
             return(data);
         }
         catch (Exception) { return(null); }
     }
 }
Пример #9
0
        protected Workbook createWorkbook()
        {
            Workbook workbook = new Workbook();

            workbook.Sheets.Add(SheetType.Worksheet);
            Worksheet worksheet = workbook.ActiveWorksheet;

            worksheet.Name = "OTE RT";
            List <TaskB> tasks = new List <TaskB>();

            try {
                string recFilter = gridMain.MasterTableView.FilterExpression;
                GridSortExpressionCollection gridSortExxpressions = gridMain.MasterTableView.SortExpressions;
                TasksController cont       = new TasksController();
                int             tasksCount = cont.CountAllTasks(recFilter);
                tasks = cont.GetAllTasks(0, tasksCount, recFilter, gridSortExxpressions);
            }
            catch (Exception) { }
            prepareDocument(worksheet);
            int         currentRow = 1;
            CellBorder  border     = new CellBorder(CellBorderStyle.Thin, tcBlack);
            CellBorders borders    = new CellBorders(border, border, border, border, null, null, null, null);
            double      fontSize   = 12;

            foreach (TaskB curTask in tasks)
            {
                worksheet.Cells[currentRow, 0].SetValue(curTask.ID.ToString());
                worksheet.Cells[currentRow, 0].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 0].SetBorders(borders);
                worksheet.Cells[currentRow, 1].SetValue(curTask.RegNo);
                worksheet.Cells[currentRow, 1].SetFormat(new CellValueFormat("@"));
                worksheet.Cells[currentRow, 1].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 1].SetBorders(borders);
                worksheet.Cells[currentRow, 2].SetValue(curTask.OrderDate);
                worksheet.Cells[currentRow, 2].SetFormat(new CellValueFormat(dateFormat));
                worksheet.Cells[currentRow, 2].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 2].SetBorders(borders);
                worksheet.Cells[currentRow, 3].SetValue(curTask.Customer.NameGR);
                worksheet.Cells[currentRow, 3].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 3].SetBorders(borders);
                worksheet.Cells[currentRow, 4].SetValue(curTask.Job.Name);
                worksheet.Cells[currentRow, 4].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 4].SetBorders(borders);
                string distance = curTask.Distance.Position1 + " - " + curTask.Distance.Position2 + " (" + curTask.Distance.KM.ToString() + ")";
                worksheet.Cells[currentRow, 5].SetValue(distance);
                worksheet.Cells[currentRow, 5].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 5].SetBorders(borders);
                worksheet.Cells[currentRow, 6].SetValue(curTask.DateTimeStartOrder.GetValueOrDefault());
                worksheet.Cells[currentRow, 6].SetFormat(new CellValueFormat(dateFormat));
                worksheet.Cells[currentRow, 6].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 6].SetBorders(borders);
                worksheet.Cells[currentRow, 7].SetValue(curTask.DateTimeEndOrder.GetValueOrDefault());
                worksheet.Cells[currentRow, 7].SetFormat(new CellValueFormat(dateFormat));
                worksheet.Cells[currentRow, 7].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 7].SetBorders(borders);
                worksheet.Cells[currentRow, 8].SetValue(curTask.DateTimeDurationOrder);
                worksheet.Cells[currentRow, 8].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 8].SetBorders(borders);
                worksheet.Cells[currentRow, 9].SetValue(double.Parse(curTask.AddedCharges.GetValueOrDefault().ToString()));
                worksheet.Cells[currentRow, 9].SetFormat(new CellValueFormat(currencyFormat));
                worksheet.Cells[currentRow, 9].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 9].SetBorders(borders);
                worksheet.Cells[currentRow, 10].SetValue(double.Parse(curTask.CostCalculated.GetValueOrDefault().ToString()));
                worksheet.Cells[currentRow, 10].SetFormat(new CellValueFormat(currencyFormat));
                worksheet.Cells[currentRow, 10].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 10].SetBorders(borders);
                if (curTask.DateTimeStartActual.GetValueOrDefault().Year > 2000)
                {
                    worksheet.Cells[currentRow, 11].SetValue(curTask.DateTimeStartActual.GetValueOrDefault());
                }
                else
                {
                    worksheet.Cells[currentRow, 11].SetValue("");
                }
                worksheet.Cells[currentRow, 11].SetFormat(new CellValueFormat(dateFormat));
                worksheet.Cells[currentRow, 11].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 11].SetBorders(borders);
                if (curTask.DateTimeEndActual.GetValueOrDefault().Year > 2000)
                {
                    worksheet.Cells[currentRow, 12].SetValue(curTask.DateTimeEndActual.GetValueOrDefault());
                }
                else
                {
                    worksheet.Cells[currentRow, 12].SetValue("");
                }
                worksheet.Cells[currentRow, 12].SetFormat(new CellValueFormat(dateFormat));
                worksheet.Cells[currentRow, 12].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 12].SetBorders(borders);
                if (curTask.IsCanceled == true)
                {
                    worksheet.Cells[currentRow, 13].SetValue(0);
                }
                else
                {
                    worksheet.Cells[currentRow, 13].SetValue(curTask.DateTimeDurationActual.GetValueOrDefault());
                }
                worksheet.Cells[currentRow, 13].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 13].SetBorders(borders);
                if (curTask.PaymentDateOrder.GetValueOrDefault().Year > 2000)
                {
                    worksheet.Cells[currentRow, 14].SetValue(curTask.PaymentDateOrder.GetValueOrDefault());
                }
                else
                {
                    worksheet.Cells[currentRow, 14].SetValue("");
                }
                worksheet.Cells[currentRow, 14].SetFormat(new CellValueFormat(dateFormat));
                worksheet.Cells[currentRow, 14].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 14].SetBorders(borders);
                worksheet.Cells[currentRow, 15].SetValue(double.Parse(curTask.CostActual.GetValueOrDefault().ToString()));
                worksheet.Cells[currentRow, 15].SetFormat(new CellValueFormat(currencyFormat));
                worksheet.Cells[currentRow, 15].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 15].SetBorders(borders);
                if (curTask.PaymentDateCalculated.GetValueOrDefault().Year > 2000)
                {
                    worksheet.Cells[currentRow, 16].SetValue(curTask.PaymentDateCalculated.GetValueOrDefault());
                }
                else
                {
                    worksheet.Cells[currentRow, 16].SetValue("");
                }
                worksheet.Cells[currentRow, 16].SetFormat(new CellValueFormat(dateFormat));
                worksheet.Cells[currentRow, 16].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 16].SetBorders(borders);
                //if (curTask.PaymentDateActual.GetValueOrDefault().Year > 2000) {
                //    worksheet.Cells[currentRow, 17].SetValue(curTask.PaymentDateActual.GetValueOrDefault());
                //} else {
                //    worksheet.Cells[currentRow, 17].SetValue("");
                //}
                //worksheet.Cells[currentRow,17].SetFormat(new CellValueFormat(dateFormat));
                //worksheet.Cells[currentRow,17].SetFontSize(fontSize);
                //worksheet.Cells[currentRow,17].SetBorders(borders);
                string isCanc = "ΟΧΙ";
                if (curTask.IsCanceled == true)
                {
                    isCanc = "ΝΑΙ";
                }
                worksheet.Cells[currentRow, 17].SetValue(isCanc);
                worksheet.Cells[currentRow, 17].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 17].SetBorders(borders);
                worksheet.Cells[currentRow, 18].SetValue(curTask.Comments);
                worksheet.Cells[currentRow, 18].SetIsWrapped(true);
                worksheet.Cells[currentRow, 18].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 18].SetBorders(borders);
                worksheet.Cells[currentRow, 19].SetValue(curTask.InvoceComments);
                worksheet.Cells[currentRow, 19].SetIsWrapped(true);
                worksheet.Cells[currentRow, 19].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 19].SetBorders(borders);
                worksheet.Cells[currentRow, 20].SetValue(curTask.EnteredByUser);
                worksheet.Cells[currentRow, 20].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 20].SetBorders(borders);
                worksheet.Cells[currentRow, 21].SetValue(curTask.DateStamp);
                worksheet.Cells[currentRow, 21].SetFormat(new CellValueFormat(dateFormat));
                worksheet.Cells[currentRow, 21].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 21].SetBorders(borders);
                currentRow++;
            }
            for (int i = 0; i < worksheet.Columns.Count; i++)
            {
                worksheet.Columns[i].AutoFitWidth();
            }
            for (int i = 0; i < worksheet.Columns.Count; i++)
            {
                if (i == 18 || i == 19)
                {
                    worksheet.Columns[i].SetWidth(new ColumnWidth(300, true));
                }
                ColumnSelection columnSelection = worksheet.Columns[i];
                ColumnWidth     columnWidth     = columnSelection.GetWidth().Value;
                double          curColWidth     = columnWidth.Value + 10;
                if (curColWidth > 2000)
                {
                    curColWidth = 2000;
                }
                columnSelection.SetWidth(new ColumnWidth(curColWidth, columnWidth.IsCustom));
            }
            ColumnSelection columnSelection4 = worksheet.Columns[4];
            ColumnWidth     columnWidth4     = columnSelection4.GetWidth().Value;
            double          curColWidth4     = columnWidth4.Value + 10;

            if (curColWidth4 > 2000)
            {
                curColWidth4 = 2000;
            }
            columnSelection4.SetWidth(new ColumnWidth(curColWidth4, columnWidth4.IsCustom));
            return(workbook);
        }