diff --git a/BealeEngineering/BealeEngineering.Accounts/frmMain.cs b/BealeEngineering/BealeEngineering.Accounts/frmMain.cs index 486626f..7ab40bd 100644 --- a/BealeEngineering/BealeEngineering.Accounts/frmMain.cs +++ b/BealeEngineering/BealeEngineering.Accounts/frmMain.cs @@ -174,19 +174,40 @@ namespace BealeEngineering.Accounts private void xeroInvoiceToolStripMenuItem_Click(object sender, EventArgs e) { - string fileInputPath = - Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) - + @"\Dropbox\Beale Engineering Services Ltd\BE Accounts\Xero-Export-Invoices.csv"; + string fileInputPath = null; - string dialogText = "Importing file from location: " + Environment.NewLine + Environment.NewLine + fileInputPath; + using (OpenFileDialog openFileDialog = new OpenFileDialog()) + { + openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\Downloads"; + openFileDialog.Filter = ".csv files (*.csv)|*.csv|All files (*.*)|*.*"; + openFileDialog.FilterIndex = 1; + openFileDialog.RestoreDirectory = true; - DialogResult dialogResult = MessageBox.Show(dialogText, "Import Xero Invoice flat-file", MessageBoxButtons.OKCancel); - if (dialogResult == DialogResult.OK) + if (openFileDialog.ShowDialog() == DialogResult.OK) + { + //Get the path of specified file + fileInputPath = openFileDialog.FileName; + } + else + { + return; + } + } + + if (fileInputPath != null) { var importXeroInvoice = new BealeEngineering.Core.Logic.Import.XeroInvoiceFlatFile(sqlConnectionString); - importXeroInvoice.ByFilePath(fileInputPath); + try + { + Cursor.Current = Cursors.WaitCursor; + importXeroInvoice.ByFilePath(fileInputPath); + } + finally + { + Cursor.Current = Cursors.Default; + } - dialogText = "Import complete." + Environment.NewLine + Environment.NewLine + string dialogText = "Import complete." + Environment.NewLine + Environment.NewLine + importXeroInvoice.InvoicesProcessed + " invoice(s) found" + Environment.NewLine + importXeroInvoice.InvoicesCreated + " invoice(s) created" + Environment.NewLine + importXeroInvoice.InvoicesUpdated + " invoice(s) updated" + Environment.NewLine