예제 #1
0
        //launches open dialog for a csv file
        private void importDataToolStripMenuItem_Click(object sender, EventArgs e)
        {
            const string   FILTER = "Text documents (.csv,*.csv)|*.csv;";
            OpenFileDialog dlg    = new OpenFileDialog();

            dlg.FileName   = "Document";
            dlg.DefaultExt = ".csv";
            dlg.Filter     = FILTER;
            DialogResult result = dlg.ShowDialog();

            if (result == DialogResult.OK)
            {
                string       filePath     = dlg.FileName;
                InputTracker inputTracker = FileReader.ReadCsvFile(filePath);
                productRepo.AddAll(inputTracker);
                if (inputTracker.error != string.Empty)
                {
                    MessageBox.Show(inputTracker.error,
                                    "Error Notification",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }