Beispiel #1
0
 static void Main()
 {
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     csvf = new FormCSV();
     dbf  = new FormDB();
     Application.Run(csvf);
 }
Beispiel #2
0
        public static void RunWorkerCompleted <T>(
            RunWorkerCompletedEventArgs e,
            string names,
            ref List <T> records,
            FormCSV form,
            Label label,
            ProgressBar progressBar,
            EnableDisableDelegate EnableDisable,
            int numFiles)
        {
            if (records != null)
            {
                if (e.Error != null)
                {
                    // Failed
                    string msg = string.Format("Failed to parse {0} CSV File(s).", names);
                    MessageBox.Show(msg, form.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    records = null;
                }
                else if ((bool)e.Result)
                {
                    // Cancelled
                    string msg = string.Format("Parsing {0} CSV File(s) cancelled by user.", names);
                    MessageBox.Show(msg, form.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    form.Cursor = Cursors.Default;
                    records     = null;
                }
                else
                {
                    // Parsed

                    string msg;

                    if (records.Count == 0)
                    {
                        msg = string.Format("There is no records in the selected {0} CSV File(s).", names);
                        MessageBox.Show(msg, form.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        records = null;
                    }
                    else
                    {
                        msg = string.Format("{0} {1} CSV File(s) parsed successfully.", numFiles, names);
                        MessageBox.Show(msg, form.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }

            label.Text        = string.Empty;
            progressBar.Value = 0;
            EnableDisable(false);

            ParsedData.OnParseComplete();
        }