private void buttonStartConversion_Click_1(object sender, EventArgs e)
        {
            if (Utilities.IsNumber(textBoxMaxLines.Text) == false)
            {
                MessageBox.Show("Split factor must be a number, 0 means no splitting.", "OCDataImporter");
                return;
            }
            BuildRepeatingEventString();
            BuildRepeatingGroupString();

            // delete DataImport*.xml
            string[] txtList = Directory.GetFiles(conversionSettings.workdir, "DataImport_*.xml");
            if (txtList.Length > 0)
            {
                if (MessageBox.Show("DataImport_* files will be overwritten. Do you want to delete the old files?", "Confirm delete old DataImport*.xml files", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                {
                    foreach (string f in txtList) File.Delete(f);
                }
            }

            conversionSettings.checkForDuplicateSubjects = checkBoxDup.Checked;
            conversionSettings.useTodaysDateIfNoEventDate = radioButtonUseTD.Checked;
            conversionSettings.dateFormat = cbDateFormat.SelectedItem.ToString();
            conversionSettings.defaultLocation = tbLocationEvent.Text;
            conversionSettings.defaultSubjectSex = cbSex.SelectedItem.ToString();
            conversionSettings.outFMaxLines = System.Convert.ToInt32(textBoxMaxLines.Text);
            conversionSettings.selectedStudyEvent = comboBoxSE.SelectedItem.ToString();

            conversionSettings.uploadOnNotStarted = cbUploadWhen_NotStarted.Checked;
            conversionSettings.uploadOnDataEntryStarted = cbUploadWhen_DataEntryStarted.Checked;
            conversionSettings.uploadOnDataEntryComplete = cbUploadWhen_DataEntryComplete.Checked;

            fillConversionSettings();

            dumpTheGrid();
            Converter converter = new Converter(conversionSettings, studyMetaDataValidator, warningLog, this, labelOCoidExists, LabelOID);
            try
            {
                converter.DoWork(dataGrid);
            }
            catch (OCDataImporterException ocdie) {
                    MessageBox.Show(ocdie.ToString(), "OCDataImporter", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    exit_error(ocdie.ToString());
            }
            String pathWarningLog = conversionSettings.workdir + "\\OCDataImporter_warnings.txt";
            warningLog.dumpToFile(pathWarningLog);
            initializeUserInterfaceElements();
            resetUserInterfaceElements(converter);
        }
        /// <summary>
        /// Resets the user interface elements after the conversion and update the fields with the information
        /// of the run which just finished.
        /// </summary>
        private void resetUserInterfaceElements(Converter converter)
        {
            buttonBackToBegin.BackColor = System.Drawing.Color.LightGreen;
            buttonBackToBegin.Enabled = true;
            buttonStartConversion.Enabled = false;
            buttonStartConversion.BackColor = SystemColors.Control;
            button_start.Enabled = false;
            buttonExit.Enabled = true;
            buttonExit.BackColor = System.Drawing.Color.LightGreen;
            buttonBrowse.Enabled = false;
            buttonCancel.Enabled = false;
            buttonCancel.BackColor = SystemColors.Control;
            textBoxInput.Focus();
            this.Cursor = Cursors.Arrow;
            progressBar1.Value = PROGBARSIZE;
            int numberOfWarnings = warningLog.getWarningCount();

            textBoxOutput.Text += warningLog.ToString();

            labelWarningCounter.Text = "WARNINGS: " + numberOfWarnings.ToString();
            if (numberOfWarnings == 0)
            {
                warningLog.appendMessage(DateTime.Now + " Finished successfully.");
                MessageBox.Show("Process finished successfully", "OCDataImporter", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Process ended with errors or warnings: See OCDataImporter_log.txt and/or OCDataImporter_warning.txt for details", "OCDataImporter", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                textBoxOutput.Text += "*** There are errors or warnings: See OCDataImporter_log.txt and/or OCDataImporter_warning.txt for details ***";
            }
            if (converter.numberOfOutputFiles > 1)
            {
                textBoxOutput.Text += " Total: " + converter.numberOfOutputFiles.ToString() + " ODM files.";
            }
            textBoxOutput.SelectionStart = textBoxOutput.Text.Length;
            textBoxOutput.ScrollToCaret();
            conversionSettings.statusAfterUpload = StatusAfterUpload.DATA_ENTRY_STARTED;
        }