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)
|
private void xeroInvoiceToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
string fileInputPath =
|
string fileInputPath = null;
|
||||||
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)
|
|
||||||
+ @"\Dropbox\Beale Engineering Services Ltd\BE Accounts\Xero-Export-Invoices.csv";
|
|
||||||
|
|
||||||
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 (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
if (dialogResult == 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);
|
var importXeroInvoice = new BealeEngineering.Core.Logic.Import.XeroInvoiceFlatFile(sqlConnectionString);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Cursor.Current = Cursors.WaitCursor;
|
||||||
importXeroInvoice.ByFilePath(fileInputPath);
|
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.InvoicesProcessed + " invoice(s) found" + Environment.NewLine
|
||||||
+ importXeroInvoice.InvoicesCreated + " invoice(s) created" + Environment.NewLine
|
+ importXeroInvoice.InvoicesCreated + " invoice(s) created" + Environment.NewLine
|
||||||
+ importXeroInvoice.InvoicesUpdated + " invoice(s) updated" + Environment.NewLine
|
+ importXeroInvoice.InvoicesUpdated + " invoice(s) updated" + Environment.NewLine
|
||||||
|
|||||||
Reference in New Issue
Block a user