private void buttonConnectRepository_Click(object sender, EventArgs e)
        {
            try
            {

                SerRepository = new MS_SqlServerIPSerializer(@textBoxUser.Text, @textBoxPassword.Text, @textBoxIP.Text, @textBoxPort.Text, @textBoxDBName.Text);
                SerRepository.RegisterType(typeof(TaxonNames));
                SerRepository.Activate();
                ConnRepository = SerRepository.CreateConnection();
                buttonConnectRepository.Text = "Connected";
                buttonConnectRepository.BackColor = Color.Yellow;
                repositoryConnection = true;

            }
            catch (Exception f)
            {
                MessageBox.Show("An error according to Your Values has occured", "Check Values", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            startcheck();
        }
        private void buttonGetTaxa_Click(object sender, EventArgs e)
        {
            // Start Thread for ProgressInformation
            this.startProgressThread();
            this.setProgressValue(0);
            this.setActionInformation("Copy Mobile Database for Taxon- and PropertyNames to work directory");
            //if (activesync == true)
            //    //rapi.CopyFileFromDevice(taxPath, mobileTaxonPath, true);
            //else
            //{
                if (System.IO.File.Exists(mobileTaxonPath))
                    System.IO.File.Copy(mobileTaxonPath, taxPath, true);
                else
                {
                    FileDialog taxDialog = new OpenFileDialog();
                    taxDialog.Filter = "sdf files (*.sdf)|*.sdf"; //Im Moment wird nur das DB-Format von DiversityMobile unterstützt
                    if (taxDialog.ShowDialog() == DialogResult.OK)
                    {
                        mobileTaxonPath = taxDialog.FileName;
                        System.IO.File.Copy(mobileTaxonPath, taxPath, true);
                    }
                    else
                    {
                        this.endProgressThread(true);
                        return;
                    }
                }
            //}
            this.setProgressValue(100);
            this.setProgressInformation("Finished");

            // save current settings to XML
            try
            {
                this.writeSettingsToXML();
            }
            catch (Exception)
            {
                MessageBox.Show("XML-Write Error2!");
            }
            //Damit liegt die TaxonDatenBank im Arbeitsverzeichnis
            //Serializer erstellen
            Serializer taxonMobSerializer = new MS_SqlCeSerializer(taxPath);
            taxonMobSerializer.RegisterType(typeof(TaxonNames));
            taxonMobSerializer.RegisterType(typeof(PropertyNames));
            Serializer taxonRepSerializer = new MS_SqlServerIPSerializer(loginName, password, this.IPAddress, this.IPPort, this.TaxonNamesInitialCatalog,null);//AKtuell Datenbank mit den Definitionen
            taxonRepSerializer.RegisterType(typeof(TaxonNames));
            taxonRepSerializer.RegisterType(typeof(PropertyNames));
            DbConnection repConn = taxonRepSerializer.CreateConnection();
            SqlCeConnection mobConn = (SqlCeConnection)taxonMobSerializer.CreateConnection();
            int i;
            String[] sourceTablesFungi = { "TaxRef_LIAS_Erys_DE" };
            i = updateTaxa(sourceTablesFungi, "TaxonNamesFungi", repConn, mobConn);
            if (i > 0)
            {
                this.setProgressInformation("Fungi: " + i + " Taxa");
            }
            else
            {
                this.setProgressInformation("Fungi: no Taxa");
                System.Threading.Thread.Sleep(1000);
            }
            //MessageBox.Show("Fungi: " + i + " Taxa");
            String[] sourceTablesLichen = { "TaxRef_LIAS_Lichens_DE" };
            i = updateTaxa(sourceTablesLichen, "TaxonNamesLichen", repConn, mobConn);

            if (i > 0)
            {
                this.setProgressInformation("Lichen: " + i + " Taxa");
            }
            System.Threading.Thread.Sleep(1000);

            //MessageBox.Show("Lichen: " + i + " Taxa");
            String[] sourceTablePlants = { "TaxRef_BfN_VPlants" };
            i = updateTaxa(sourceTablePlants, "TaxonNamesPlants", repConn, mobConn);
            if (i > 0)
            {
                this.setProgressInformation("Plants: " + i + " Taxa");
            }
            System.Threading.Thread.Sleep(1000);
            String[] sourceTableInsects = { "TaxRef_UBT_Gallerreger" };
            i = updateTaxa(sourceTableInsects, "TaxonNamesInsects", repConn, mobConn);
            if (i > 0)
            {
                this.setProgressInformation("Insects: " + i + " Taxa");
            }
            System.Threading.Thread.Sleep(1000);
            //MessageBox.Show("Plants: " + i + " Taxa");

            //MessageBox.Show("Complete");
            //buttonGetTaxa.Text = "Download Complete";
            i = updateProperties("LebensraumTypen", "LebensraumTypenLfU", taxonRepSerializer, taxonMobSerializer);
            if (i > 0)
            {
                this.setProgressInformation("LebensraumTypen: " + i + " PropertyNames");
            }
            else
            System.Threading.Thread.Sleep(3000);

            i = updateProperties("Pflanzengesellschaften", "Pflanzengesellschaften", taxonRepSerializer, taxonMobSerializer);
            if (i > 0)
            {
                this.setProgressInformation("Pflanzengesellschaften: " + i + " PropertyNames");
            }
            System.Threading.Thread.Sleep(3000);

            mobConn.Close();

            this.setProgressValue(0);
            this.setActionInformation("Copy MobileTaxonNames Database from work directory");
            //Alte TaxonDatenbank überschreiben
            if (activesync == true)
                rapi.CopyFileToDevice(taxPath, mobileTaxonPath, true);
            else
                System.IO.File.Copy(taxPath, mobileTaxonPath, true);

            this.setProgressValue(100);
            this.setProgressInformation("Finished");

            this.endProgressThread(false);

            //buttonGetTaxa.Text = "Finished";
            buttonGetTaxa.Enabled = false;
        }