private void onSubmit_Click(object sender, EventArgs e)
        {
            //Initialize variables
            TrackingEntry newEntry = new TrackingEntry();
            TrackingProcessing newProcess = new TrackingProcessing(connection);

            //Parse and validate input
            if (!ParseInput(ref newEntry))
            {
                //Show error message
                MessageBox.Show("Could not add entry to the repository!\nPlease check all fields for errors.", "Error Message:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                //Add entry to repository
                newProcess.addTrackingEntry(newEntry);

                //Show success message
                MessageBox.Show("Entry successfully added to the repository!", "Entry Added", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        //Export the database into a file by location, with a user assigned name
        public static void ExportOnLocation(string fileName, string city, string state, string country, MySqlConnection connection)
        {
            //Initialize variables
            StreamWriter fileStream = new StreamWriter(fileName);
            List<string> outputStrings = new List<string>();
            TrackingProcessing exportProcess = new TrackingProcessing(connection);

            //Get the list of entries assocoiated with that tag number
            outputStrings = exportProcess.exportByLocation(fileStream, city, state, country);

            //Show error box if the location returns no entries
            if (outputStrings == null || outputStrings.Count == 0)
            {
                //Show error message
                MessageBox.Show("No entries found for that location!", "Error Message:", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                //Log a failure and close the file
                Log.Write("Failed exporting by location: " + city + " " + state + " " + country);
                fileStream.Close();
            }

            //Print the output to the file if entries are returned
            else
            {
                for (int i = 0; i < outputStrings.Count; i++)
                {
                    fileStream.WriteLine(outputStrings[i]);
                }//for

                //Show success message
                MessageBox.Show("Successfully exported by location: " + city + " " + state + " " + country, "Export Succeeded", MessageBoxButtons.OK, MessageBoxIcon.Information);

                //Log a success and close the file
                Log.Write("Successfully exported by location: " + city + " " + state + " " + country);
                fileStream.Close();
            }
        }
        //Export the database into a file by tag, with a user assigned name
        public static void ExportOnTag(string fileName, int tagNumber, MySqlConnection connection)
        {
            //Initialize variables
            StreamWriter fileStream = new StreamWriter(fileName);       //Writer for writing output
            List<string> outputStrings = new List<string>();            //List of output entries to write
            TrackingProcessing exportProcess = new TrackingProcessing(connection);      //Processing class for database queries

            //Get the list of entries assocoiated with that tag number
            outputStrings = exportProcess.exportByTag(fileStream, tagNumber);

            //Show error box if the tag number returns no entries
            if(outputStrings.Count == 0)
            {
                //Show error message
                MessageBox.Show("No entries found for that tag number!", "Error Message:", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                //Log a failure and close the file
                Log.Write("Failed exporting by tag number: " + tagNumber);
                fileStream.Close();
            }

            //Print the output to the file if entries are returned
            else
            {
                for (int i = 0; i < outputStrings.Count; i++)
                {
                    fileStream.WriteLine(outputStrings[i]);
                }//for

                //Show success message
                MessageBox.Show("Successfully exported by tag number: " + tagNumber, "Export Succeeded", MessageBoxButtons.OK, MessageBoxIcon.Information);

                //Log a success and close the file
                Log.Write("Successfully exported by tag number: " + tagNumber);
                fileStream.Close();
            }
        }
        //Class methods
        //Import from selected file into database
        public static void Import(string fileName, MySqlConnection connection)
        {
            //Initialize variables
            int importCount = 0;                //Number of entries attempted for import
            string entryString = "";            //Next entry string to be imported
            string importedEntries = "";        //Line number of each imported entry
            string failedEntries = "";          //Line number of each failed entry
            List<int> entriesImported = new List<int>();                //List of imported entry numbers
            List<int> entriesFailed = new List<int>();                  //List of failed entry numbers
            StreamReader fileStream = new StreamReader(fileName);       //Reader for getting input
            TrackingEntry newEntry = new TrackingEntry(connection);     //Entry to be added to the database
            TrackingProcessing newProcess = new TrackingProcessing(connection);     //Processing class for database queries

            //Validate the file sequence number, header & trailer, and the number of entries in the file
            if(ValidateFile(fileStream))
            {
                //Move to the first entry string after validating file
                GetHeader(entryString, fileStream);

                //Get the next line of the file
                entryString = fileStream.ReadLine();

                //Iterate through entries until the trailer is reached
                while (!entryString.StartsWith("TR "))
                {
                    //Parse the new entry, and validate data
                    if(newEntry.Parse(entryString) != false)
                    {
                        Console.WriteLine(newEntry.tagNumber);
                        //Add entry to repository
                        newProcess.addTrackingEntry(newEntry);

                        importCount++;
                        entryString = fileStream.ReadLine();

                        //Store successfully imported entries
                        entriesImported.Add(importCount);

                    }

                    //Error return if one or more fields are invalid
                    else
                    {
                        importCount++;
                        entryString = fileStream.ReadLine();

                        //Store unsuccessfully imported entries
                        entriesFailed.Add(importCount);
                    }
                }//while

                //Build the imported and failed string of entries
                for(int i = 0; i < entriesImported.Count; i++)
                {
                    importedEntries += Convert.ToString(entriesImported[i]) + ", ";
                }//for

                for(int i = 0; i < entriesFailed.Count; i++)
                {
                    failedEntries += Convert.ToString(entriesFailed[i]) + ", ";
                }//for

                //Show success message
                MessageBox.Show("Successfully imported file: " + fileName + "\nThe next file in sequence is " + String.Format("{0:0000}", (seqNum + 1))
                                + ".\nImported entries #: " + importedEntries + "\nFailed entries #: " + failedEntries,"Import Succeeded",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);

                //Log a success and close the file
                Log.Write("Successfully imported file: " + fileName);
                fileStream.Close();
            }

            //Show error box if file cannot be validated
            else
            {
                //Show error message
                MessageBox.Show("Could not import file!\nThis is due to an invalid header or trailer line.", "Error Message:", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                //Log a failure and close the file
                Log.Write("Failed to import file: " + fileName);
                fileStream.Close();
            }
        }
 public TrackingProcessingUnitTest(MySqlConnection connection)
 {
     this.connection = connection;
     process = new TrackingProcessing(connection);
 }
        public static void trackingProcessingTests(MySqlConnection connection, bool testEntry,
            bool testButterfly, bool testLocation, bool testDate)
        {
            TrackingProcessingUnitTest test = new TrackingProcessingUnitTest(connection);
            TrackingEntry entry = new TrackingEntry();
            TrackingProcessing process = new TrackingProcessing(connection);

            if (testEntry)
            {
                entry = process.createTrackingEntry(1, -1, 'T', "Sean Gallagher", "2015-12-13 12:56:45", 1,
                    "Monarch", "Dearborn", "MI", "USA", "", "", "", "", "", "");
                test.unitTestAddEntry(entry);
                Console.WriteLine("Done");
            }

            if (testButterfly)
            {
                entry = process.createTrackingEntry(1, -1, 'T', "Sean Gallagher", "2015-12-13 01:40:00", 1,
                    "Monarch", "Dearborn", "MI", "USA", "", "", "", "", "", "");
                test.unitTestAddEntry(entry);
                Console.WriteLine("Done");

                entry = process.createTrackingEntry(1, -1, 'T', "Sean Gallagher", "2015-12-13 01:40:00", 16,
                    "Tiger Swallowtail", "Dearborn", "MI", "USA", "", "", "", "", "", "");
                test.unitTestAddEntry(entry);
                Console.WriteLine("Done");
            }

            if (testLocation)
            {
                entry = process.createTrackingEntry(1, -1, 'T', "Sean Gallagher", "2015-12-13 01:40:00", 16,
                    "Tiger Swallowtail", "", "", "USA", "", "", "", "", "", "");
                test.unitTestAddEntry(entry);
                Console.WriteLine("Done");
            }

            if (testDate)
            {
                entry = process.createTrackingEntry(1, -1, 'T', "Sean Gallagher", "2015-12-13 12:48:10", 16,
                    "Tiger Swallowtail", "", "", "USA", "", "", "", "", "", "");
                test.unitTestAddEntry(entry);
                Console.WriteLine("Done");
            }
        }