Exemple #1
0
        protected void OnGenerateFilesClick(object sender, EventArgs e)
        {
            m_folderBrowserDialog.SelectedPath = Configuration.Instance.MiscellaneousConfiguration.DefaultSaveFolder;
            m_folderBrowserDialog.Description  = "Save Generated Files To...";
            if (m_folderBrowserDialog.ShowDialog() == DialogResult.OK)
            {
                MonthlyTimesheets monthlyTimesheets = m_monthlyTimesheets;

                string outputFolder = m_folderBrowserDialog.SelectedPath;

                FileGenerateConfirmationDialog fileGenerateConfirmationDialog =
                    new FileGenerateConfirmationDialog(monthlyTimesheets, outputFolder);
                if (fileGenerateConfirmationDialog.ShowDialog(this) == DialogResult.Cancel)
                {
                    return;
                }
                else
                {
                    InvoiceNumberComfirmationDialog invoiceNumberComfirmationDialog =
                        new InvoiceNumberComfirmationDialog(monthlyTimesheets, false /* Handle the save below*/);
                    if (invoiceNumberComfirmationDialog.ShowDialog(this) == DialogResult.Cancel)
                    {
                        return;
                    }

                    this.Enabled = false;

                    // Save whatever changes were made first.
                    MonthlyTimesheetSaveProcessing();

                    // Generate any unsent Timesheets...
                    foreach (Timesheet timesheet in monthlyTimesheets.UnSentTimesheets)
                    {
                        TimesheetGenerator timesheetGenerator = new TimesheetGenerator(timesheet, outputFolder);
                        if (timesheetGenerator.Generate(false))
                        {
                        }
                        timesheetGenerator.Save();
                    }

                    // Generate our invoice...
                    InvoiceGenerator invoiceGenerator = new InvoiceGenerator(monthlyTimesheets, outputFolder);
                    if (invoiceGenerator.Generate(false))
                    {
                    }
                    invoiceGenerator.Save();

                    TimesheetGenerator.QuitExcel();

                    this.Enabled = true;
                }
            }
        }