Esempio n. 1
0
 public bool CreateExcelReport()
 {
     bool result;
     try
     {
         var mySQLManager = new MySQLManager();
         var reports = mySQLManager.GetAllReports();
         var sqliteManager = new SQLiteManager();
         var discountInformations = sqliteManager.GetDiscountPercentagesPerCompany();
         var reportsWithDiscounts = from r in reports
                                    join di in discountInformations on r.CompanyID equals di.CompanyID
                                    select new DiscountedReport
                                    {
                                        CompanyName = r.CompanyName,
                                        ProductName = r.ProductName,
                                        Price = r.Price * (decimal)(1 - (di.DiscountPercent / 100.00)),
                                        Quantity = r.Quantity,
                                        TotalRevenue = r.TotalRevenue * (decimal)(1 - (di.DiscountPercent / 100.00)),
                                        TotalDiscount = r.TotalRevenue * (decimal)(di.DiscountPercent / 100.00)
                                    };
         var file = CreateDirAndFile();
         WriteReportDataToFile(file, reportsWithDiscounts);
         result = true;
     }
     catch (Exception)
     {
         result = false;
     }
     return result;
 }