mirror of
https://github.com/stokebob/BealeEngineering.git
synced 2026-03-21 15:47:15 +00:00
Added file picker dialog to import
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user