Exemplo n.º 1
0
        private void butGenerateConsolidatedReport_Click(object sender, RoutedEventArgs e)
        {
            string date = cboColsonidatedReportDate.SelectedValue.ToString();
            Dictionary <int, string> dict = DownloadData.GetWeeklyFarmData(date);

            processConsolidated p = new processConsolidated();

            if (File.Exists(Utilities.LOCAL_REPORT_URL))
            {
                try
                {
                    File.Delete(Utilities.LOCAL_REPORT_URL);
                }
                catch
                {
                    MessageBox.Show("The previous report is currently open in another application. Please close the application that is using this file.");
                }
            }
            DateTime dt = DateTime.Parse(date);

            try
            {
                Directory.CreateDirectory(Utilities.SAVE_FOLDER);
                p.createWorkBook(Utilities.LOCAL_REPORT_URL, date, dict);
            }
            catch
            {
                MessageBox.Show("Something went wrong when attempting to create your consolidated report.");
            }
            MessageBox.Show("Process Complete!");
        }