private void btnProductIncomeCalculator_Click(object sender, RoutedEventArgs e) { try { string path = "..\\..\\..\\Json-Reports\\"; CupOfCoffeeContext context = new CupOfCoffeeContext(); var reports = ProductsReportsLoader.GetProductsSaleInfo(context); ProductsReportsLoader.GenerateJsonReports(reports, path); MySqlModel mySqlCOntext = new MySqlModel(); ProductsReportsLoader.AddReports(reports, mySqlCOntext); MessageBox.Show("The products reports were successfully generated!", "Generated successfully", MessageBoxButton.OK, MessageBoxImage.Information); Process.Start(path); } catch (Exception) { MessageBox.Show("Cannot generate the products reports!", "Generation failed", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void btnTotalProfitCalculator_Click(object sender, RoutedEventArgs e) { try { var path = "total-profit.xlsx"; var mySqlCOntext = new MySqlModel(); var products = ProductsReportsLoader.GetReportsFromMySql(mySqlCOntext); // TODO: Change it with entity framework var vendorsProduct = SqliteParser.GetVendorsProducts(); ExcelGenerator.Generate(products, vendorsProduct, path); MessageBox.Show("The total profit report was successfully generated!", "Generated successfully", MessageBoxButton.OK, MessageBoxImage.Information); Process.Start(path); } catch (Exception) { MessageBox.Show("Cannot generate the total profit report!", "Generation failed", MessageBoxButton.OK, MessageBoxImage.Error); } }