public bool save_XML(Majitele databaseM, Psi databaseP, string destinationFile)
        {
            try
            {
                //  string databasePath = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName, "projectData/database.xml");

                string databasePath = destinationFile;

                XmlDocument doc     = new XmlDocument();
                XmlNode     docNode = doc.CreateXmlDeclaration("1.0", "UTF-8", null);
                doc.AppendChild(docNode);

                XmlElement root = doc.CreateElement("DBS");
                doc.AppendChild(root);


                Majitel currentMajitel;

                int[] majitelId = databaseM.GetAllIds();

                XmlElement   parentNode;
                XmlElement[] childNodes = new XmlElement[10];


                XmlElement majitelNode = doc.CreateElement("Majitele");
                //  doc.DocumentElement.AppendChild(root);

                for (int i = 0; i < majitelId.Length; i++)
                {
                    currentMajitel = databaseM.GetMajitelById(majitelId[i]);

                    parentNode              = doc.CreateElement("Majitel");
                    childNodes[0]           = doc.CreateElement("Id");
                    childNodes[0].InnerText = Convert.ToString(currentMajitel.id);
                    childNodes[1]           = doc.CreateElement("FirstName");
                    childNodes[1].InnerText = currentMajitel.firstName;
                    childNodes[2]           = doc.CreateElement("LastName");
                    childNodes[2].InnerText = currentMajitel.lastName;
                    childNodes[3]           = doc.CreateElement("Clen");
                    childNodes[3].InnerText = currentMajitel.clen;
                    childNodes[4]           = doc.CreateElement("Penize");
                    childNodes[4].InnerText = Convert.ToString(currentMajitel.penize);
                    childNodes[5]           = doc.CreateElement("Potvrzeni");
                    childNodes[5].InnerText = currentMajitel.potvrzeni;
                    childNodes[6]           = doc.CreateElement("Telefon");
                    childNodes[6].InnerText = currentMajitel.telefon;
                    childNodes[7]           = doc.CreateElement("Email");
                    childNodes[7].InnerText = currentMajitel.email;
                    childNodes[8]           = doc.CreateElement("Narodnost");
                    childNodes[8].InnerText = currentMajitel.narodnost;
                    childNodes[9]           = doc.CreateElement("Pocet_psu");
                    childNodes[9].InnerText = Convert.ToString(currentMajitel.pocet_psu);

                    doc.DocumentElement.AppendChild(parentNode);

                    for (int j = 0; j < 10; j++)
                    {
                        doc.DocumentElement.LastChild.AppendChild(childNodes[j]);
                    }

                    doc.DocumentElement.AppendChild(majitelNode);
                    doc.DocumentElement.LastChild.AppendChild(parentNode);
                }

                Pes   currentPes;
                int[] pesId = databaseP.GetAllIds();

                XmlElement pesNode = doc.CreateElement("Psi");

                childNodes = new XmlElement[43];


                for (int i = 0; i < pesId.Length; i++)
                {
                    currentPes = databaseP.GetPesById(pesId[i]);

                    parentNode               = doc.CreateElement("Pes");
                    childNodes[0]            = doc.CreateElement("Id");
                    childNodes[0].InnerText  = Convert.ToString(currentPes.Id);
                    childNodes[1]            = doc.CreateElement("Jmeno");
                    childNodes[1].InnerText  = currentPes.Jmeno;
                    childNodes[2]            = doc.CreateElement("Plemeno");
                    childNodes[2].InnerText  = currentPes.Plemeno;
                    childNodes[3]            = doc.CreateElement("Pohlavi");
                    childNodes[3].InnerText  = currentPes.Pohlavi;
                    childNodes[4]            = doc.CreateElement("FCI");
                    childNodes[4].InnerText  = currentPes.Fci;
                    childNodes[5]            = doc.CreateElement("Datum");
                    childNodes[5].InnerText  = currentPes.Datum.ToString(Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern);
                    childNodes[6]            = doc.CreateElement("Licence");
                    childNodes[6].InnerText  = currentPes.Licence;
                    childNodes[7]            = doc.CreateElement("Majitel");
                    childNodes[7].InnerText  = Convert.ToString(currentPes.Majitel);
                    childNodes[8]            = doc.CreateElement("MajitelJmeno");
                    childNodes[8].InnerText  = Convert.ToString(currentPes.MajitelJmeno);
                    childNodes[9]            = doc.CreateElement("Skupina");
                    childNodes[9].InnerText  = Convert.ToString(currentPes.Skupina);
                    childNodes[10]           = doc.CreateElement("Start_beh1");
                    childNodes[10].InnerText = Convert.ToString(currentPes.StartBeh1);
                    childNodes[11]           = doc.CreateElement("Start_beh2");
                    childNodes[11].InnerText = Convert.ToString(currentPes.StartBeh2);

                    childNodes[12]           = doc.CreateElement("Zavod");
                    childNodes[12].InnerText = currentPes.ZavodLicence;
                    childNodes[13]           = doc.CreateElement("Platba");
                    childNodes[13].InnerText = Convert.ToString(currentPes.Platba);
                    childNodes[14]           = doc.CreateElement("Doplatit");
                    childNodes[14].InnerText = Convert.ToString(currentPes.Doplatit);
                    childNodes[15]           = doc.CreateElement("Pozn");
                    childNodes[15].InnerText = currentPes.Poznamka;

                    childNodes[16]           = doc.CreateElement("Diskvalifikace");
                    childNodes[16].InnerText = currentPes.Diskval;

                    //body první běh -->
                    childNodes[17]           = doc.CreateElement("Agility0");
                    childNodes[17].InnerText = Convert.ToString(currentPes.AgilityA0);
                    childNodes[18]           = doc.CreateElement("Speed0");
                    childNodes[18].InnerText = Convert.ToString(currentPes.SpeedA0);
                    childNodes[19]           = doc.CreateElement("Endurance0");
                    childNodes[19].InnerText = Convert.ToString(currentPes.EnduranceA0);
                    childNodes[20]           = doc.CreateElement("Enthusiasm0");
                    childNodes[20].InnerText = Convert.ToString(currentPes.EnthusiasmA0);
                    childNodes[21]           = doc.CreateElement("Intelligence0");
                    childNodes[21].InnerText = Convert.ToString(currentPes.IntelligenceA0);

                    childNodes[22]           = doc.CreateElement("Agility1");
                    childNodes[22].InnerText = Convert.ToString(currentPes.AgilityA1);
                    childNodes[23]           = doc.CreateElement("Speed1");
                    childNodes[23].InnerText = Convert.ToString(currentPes.SpeedA1);
                    childNodes[24]           = doc.CreateElement("Endurance1");
                    childNodes[24].InnerText = Convert.ToString(currentPes.EnduranceA1);
                    childNodes[25]           = doc.CreateElement("Enthusiasm1");
                    childNodes[25].InnerText = Convert.ToString(currentPes.EnthusiasmA1);
                    childNodes[26]           = doc.CreateElement("Intelligence1");
                    childNodes[26].InnerText = Convert.ToString(currentPes.IntelligenceA1);
                    childNodes[27]           = doc.CreateElement("Body1celekm");
                    childNodes[27].InnerText = Convert.ToString(currentPes.Body1); //<-- body1

                    //body druhý běh -->
                    childNodes[28]           = doc.CreateElement("Agility0_2kolo");
                    childNodes[28].InnerText = Convert.ToString(currentPes.AgilityB0);
                    childNodes[29]           = doc.CreateElement("Speed0_2kolo");
                    childNodes[29].InnerText = Convert.ToString(currentPes.SpeedB0);
                    childNodes[30]           = doc.CreateElement("Endurance0_2kolo");
                    childNodes[30].InnerText = Convert.ToString(currentPes.EnduranceB0);
                    childNodes[31]           = doc.CreateElement("Enthusiasm0_2kolo");
                    childNodes[31].InnerText = Convert.ToString(currentPes.EnthusiasmB0);
                    childNodes[32]           = doc.CreateElement("Intelligence0_2kolo");
                    childNodes[32].InnerText = Convert.ToString(currentPes.IntelligenceB0);

                    childNodes[33]           = doc.CreateElement("Agility1_2kolo");
                    childNodes[33].InnerText = Convert.ToString(currentPes.AgilityB1);
                    childNodes[34]           = doc.CreateElement("Speed1_2kolo");
                    childNodes[34].InnerText = Convert.ToString(currentPes.SpeedB1);
                    childNodes[35]           = doc.CreateElement("Endurance1_2kolo");
                    childNodes[35].InnerText = Convert.ToString(currentPes.EnduranceB1);
                    childNodes[36]           = doc.CreateElement("Enthusiasm1_2kolo");
                    childNodes[36].InnerText = Convert.ToString(currentPes.EnthusiasmB1);
                    childNodes[37]           = doc.CreateElement("Intelligence1_2kolo");
                    childNodes[37].InnerText = Convert.ToString(currentPes.IntelligenceB1);
                    childNodes[38]           = doc.CreateElement("Body2celekm");
                    childNodes[38].InnerText = Convert.ToString(currentPes.Body2); //<-- body2

                    childNodes[39]           = doc.CreateElement("Dvojice_kolo1");
                    childNodes[39].InnerText = Convert.ToString(currentPes.Dvojice0);
                    childNodes[40]           = doc.CreateElement("Dvojice_kolo2");
                    childNodes[40].InnerText = Convert.ToString(currentPes.Dvojice1);

                    childNodes[41]           = doc.CreateElement("Barva_kolo1");
                    childNodes[41].InnerText = Convert.ToString(currentPes.Barva0);
                    childNodes[42]           = doc.CreateElement("Barva_kolo2");
                    childNodes[42].InnerText = Convert.ToString(currentPes.Barva1);

                    doc.DocumentElement.AppendChild(parentNode);

                    for (int j = 0; j < 43; j++)
                    {
                        doc.DocumentElement.LastChild.AppendChild(childNodes[j]);
                    }

                    doc.DocumentElement.AppendChild(pesNode);
                    doc.DocumentElement.LastChild.AppendChild(parentNode);
                }
                doc.DocumentElement.AppendChild(pesNode);

                FileStream fileStrm = new FileStream(databasePath, FileMode.Create);
                doc.Save(fileStrm);
                fileStrm.Close();
            }
            catch (XmlException xmlEx)
            {
                Console.WriteLine("{0}", xmlEx.Message);
                return(false);
            }
            catch (FileNotFoundException ex)
            {
                Console.WriteLine("{0}", ex.Message);
                return(false);
            }
            catch (Exception ex)
            {
                Console.WriteLine("{0}", ex.Message);
                return(false);
            }

            return(true);
        }
        public void read_excel_table_temp(Majitele dataM, Psi dataP, string sourceFile, Int32 list)
        {
            Int32 tmp = 0;

            Excel.Application excelApp = new Excel.Application();
            Excel.Workbook    workbook;
            Excel.Worksheet   worksheet;
            Excel.Range       range;
            string            databasePath = sourceFile;

            workbook = excelApp.Workbooks.Open(databasePath);

            worksheet = (Excel.Worksheet)workbook.Sheets.get_Item(list);

            Majitel temp_majitel = new Majitel();
            Pes     temp_pes     = new Pes();

            Int32 row = 0;

            range = worksheet.UsedRange;
            DataTable dt = new DataTable();

            String temp = null;

            for (row = 2; row <= range.Rows.Count; row++)
            {
                DataRow dr = dt.NewRow();

                temp = (range.Cells[row, 1] as Excel.Range).Value2;
                if (temp != null) // excel sloupec clenstvi
                {
                    string tempStr = temp.ToString();
                    if (tempStr[0] == 'N')
                    {
                        temp_majitel.clen = "ne"; // neni clenem klubu
                    }
                    else
                    {
                        temp_majitel.clen = "ano"; // je clenem klubu
                    }
                }
                else
                {
                    temp_majitel.clen = "ano"; // policko by melo byt prazdne - mozna NULL ?!
                }

                //temp = (range.Cells[row, 2] as Excel.Range).Value2;
                temp_pes.ZavodLicence = SetTempFromExcel(range, row, 2);      // excel sloupec zavod-licence-trening

                temp_pes.Jmeno = SetTempFromExcel(range, row, 3);             // excel sloupec jmeno psa

                temp_pes.Plemeno = SetTempFromExcel(range, row, 4);           // excel sloupec plemeno

                temp_pes.Poznamka = SetTempFromExcel(range, row, 5);          // excel sloupec poznamka ZAVODNI SKUPINA !!!!

                temp_pes.Pohlavi = SetTempFromExcel(range, row, 6).ToLower(); // excel sloupec pohlavi

                temp_pes.Platba = SetTempIntFromExcel(range, row, 8);         // excel sloupec platba

                temp_pes.Licence = SetTempFromExcel(range, row, 11);          // excel sloupec licence

                temp = (range.Cells[row, 14] as Excel.Range).Value.ToShortDateString();
                if (temp != null) // excel sloupec datum narozeni
                {
                    temp_pes.Datum = DateTime.ParseExact(temp, Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern, Thread.CurrentThread.CurrentCulture);
                }
                else
                {
                    temp_pes.Datum = DateTime.ParseExact(DateTime.MinValue.ToShortDateString(), Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern, Thread.CurrentThread.CurrentCulture);
                }

                temp_majitel.firstName = SetTempFromExcel(range, row, 15); // excel sloupec jmeno

                temp_majitel.narodnost = SetTempFromExcel(range, row, 17); // excel sloupec národnost

                temp_majitel.telefon = SetTempFromExcel(range, row, 18);   // excel sloupec telefon

                temp_majitel.email = SetTempFromExcel(range, row, 19);     // excel sloupec email

                temp_pes.Doplatit = 0;

                temp_majitel.id        = dataM.GetNewId();                    // přiřzení ID majiteli
                temp_majitel.penize    = temp_pes.Platba + temp_pes.Doplatit; // součet zaplatil a má zaplatit
                temp_majitel.potvrzeni = "--";                                // implicitně nastaven jako nezaplaceno
                temp_majitel.pocet_psu = 1;

                temp_pes.Id             = dataP.GetNewId();
                temp_pes.Majitel        = temp_majitel.id;
                temp_pes.MajitelJmeno   = temp_majitel.firstName;
                temp_pes.Skupina        = 0;
                temp_pes.StartBeh1      = 0;
                temp_pes.StartBeh1      = 0;
                temp_pes.Diskval        = "---";
                temp_pes.AgilityA0      = 0;
                temp_pes.AgilityA1      = 0;
                temp_pes.SpeedA0        = 0;
                temp_pes.SpeedA1        = 0;
                temp_pes.EnduranceA0    = 0;
                temp_pes.EnduranceA1    = 0;
                temp_pes.EnthusiasmA0   = 0;
                temp_pes.EnthusiasmA1   = 0;
                temp_pes.IntelligenceA0 = 0;
                temp_pes.IntelligenceA1 = 0;
                temp_pes.AgilityB0      = 0;
                temp_pes.AgilityB1      = 0;
                temp_pes.SpeedB0        = 0;
                temp_pes.SpeedB1        = 0;
                temp_pes.EnduranceB0    = 0;
                temp_pes.EnduranceB1    = 0;
                temp_pes.EnthusiasmB0   = 0;
                temp_pes.EnthusiasmB1   = 0;
                temp_pes.IntelligenceB0 = 0;
                temp_pes.IntelligenceB1 = 0;
                temp_pes.Body1          = 0;
                temp_pes.Body2          = 0;
                temp_pes.Dvojice0       = 0;
                temp_pes.Dvojice1       = 0;
                temp_pes.Barva0         = "";
                temp_pes.Barva1         = "";

                tmp = dataM.FindSame(temp_majitel.firstName, temp_majitel.lastName, temp_majitel.email);
                if (tmp < 0)
                {
                    dataM.Add(new Majitel(temp_majitel));
                }
                else
                {
                    Majitel editmajitel = dataM.GetMajitelById(tmp);
                    editmajitel.penize += temp_majitel.penize; // přičtení majiteli platbu za dalšího psa
                    editmajitel.pocet_psu++;
                    dataM.Edit(tmp, editmajitel);
                    temp_pes.Majitel = tmp;
                }

                dataP.Add(new Pes(temp_pes));
            }
            workbook.Close(true, Missing.Value, Missing.Value);
            excelApp.Quit();
        }
        /// <summary>
        /// Nacte z XML souboru databazi majitelu i psu.
        /// </summary>
        /// <param name="databaseM"></param>
        /// <param name="databaseP"></param>
        /// <param name="sourceFile"></param>
        /// <returns></returns>
        public bool load_XML(Majitele databaseM, Psi databaseP, string sourceFile)
        {
            try
            {
                //  string databasePath = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName, "projectData/database.xml");
                string databasePath = sourceFile;

                String[]    majitelArrayData;
                String[]    pesArrayData;
                XmlDocument doc = new XmlDocument();

                FileStream fileStrm = new FileStream(databasePath, FileMode.Open);
                doc.Load(fileStrm);
                fileStrm.Close();

                XmlNode root = doc.DocumentElement;

                foreach (XmlNode node in root.ChildNodes)
                {
                    if (node.Name == "Majitele")
                    {
                        foreach (XmlNode nodeMajitel in node.ChildNodes)
                        {
                            majitelArrayData = new String[10];
                            Int32 i = 0;
                            foreach (XmlNode nodeMajitelElemnts in nodeMajitel)
                            {
                                majitelArrayData[i] = (String)nodeMajitelElemnts.InnerText;
                                i++;
                            }
                            databaseM.Add(new Majitel(majitelArrayData));
                        }
                    }
                    else if (node.Name == "Psi")
                    {
                        foreach (XmlNode nodePes in node.ChildNodes)
                        {
                            pesArrayData = new String[43];
                            Int32 i = 0;
                            foreach (XmlNode nodePesElements in nodePes)
                            {
                                pesArrayData[i] = (String)nodePesElements.InnerText;
                                i++;
                            }
                            databaseP.Add(new Pes(pesArrayData));
                        }
                    }
                }
            }
            catch (XmlException xmlEx)
            {
                Console.WriteLine("{0}", xmlEx.Message);
                return(false);
            }
            catch (FileNotFoundException ex)
            {
                Console.WriteLine("{0}", ex.Message);
                return(false);
            }
            catch (Exception ex)
            {
                Console.WriteLine("{0}", ex.Message);
                return(false);
            }

            return(true);
        }
        public void Write_to_excel(Psi dataP, string sourceFile, Int32 list, String type) // type "ROZPIS"/"ROZPIS_2"/...atd
        {
            Excel.Application excelApp = new Excel.Application();
            Excel.Workbook    workbook;
            Excel.Worksheet   worksheet;
            Excel.Range       range;
            workbook = excelApp.Workbooks.Open(sourceFile);
            Pes        temp;
            String     pomoc_cislo;
            List <int> dvojice = new List <int>();
            Int32      i       = 0;
            Int32      n       = 0;

            if (list <= workbook.Sheets.Count)
            {
                worksheet = (Excel.Worksheet)workbook.Sheets.get_Item(list);

                if (worksheet.Name != type)
                {
                    workbook.Sheets.Add(Type.Missing, workbook.Sheets[workbook.Sheets.Count], Type.Missing, Type.Missing);
                    worksheet      = (Excel.Worksheet)workbook.Sheets.get_Item(workbook.Sheets.Count);
                    worksheet.Name = type + Convert.ToString(list);
                }
                else
                {
                    worksheet.Cells.Clear();
                }
            }
            else
            {
                workbook.Sheets.Add(Type.Missing, workbook.Sheets[workbook.Sheets.Count], Type.Missing, Type.Missing);
                worksheet      = (Excel.Worksheet)workbook.Sheets.get_Item(workbook.Sheets.Count);
                worksheet.Name = type + Convert.ToString(list);
            }

            range = worksheet.UsedRange;

            switch (type)
            {
            case "ROZPIS":
                (range.Cells[1, 1] as Excel.Range).Value2 = "Č.běhu";
                (range.Cells[1, 2] as Excel.Range).Value2 = "Plemeno";
                (range.Cells[1, 3] as Excel.Range).Value2 = "Dečka";
                (range.Cells[1, 4] as Excel.Range).Value2 = "Číslo psa";
                (range.Cells[1, 5] as Excel.Range).Value2 = "Jméno psa";

                dvojice = dataP.GetAllDvojice();
                i       = 1;
                foreach (int x in dvojice)
                {
                    temp = dataP.GetPesByDvojice(x, "červená");
                    if (temp == null)
                    {
                        continue;
                    }
                    (range.Cells[i + 1, 1] as Excel.Range).Value2 = temp.Dvojice0;
                    (range.Cells[i + 1, 2] as Excel.Range).Value2 = temp.Plemeno;
                    (range.Cells[i + 1, 3] as Excel.Range).Value2 = temp.Barva0;
                    if (temp.ZavodLicence == "Licence")
                    {
                        pomoc_cislo = "L " + Convert.ToString(temp.StartBeh1);
                    }
                    else
                    {
                        pomoc_cislo = Convert.ToString(temp.StartBeh1);
                    }
                    (range.Cells[i + 1, 4] as Excel.Range).Value2 = pomoc_cislo;
                    (range.Cells[i + 1, 5] as Excel.Range).Value2 = temp.Jmeno;

                    ++i;

                    temp = dataP.GetPesByDvojice(x, "bílá");
                    if (temp == null)
                    {
                        continue;
                    }
                    (range.Cells[i + 1, 1] as Excel.Range).Value2 = temp.Dvojice0;
                    (range.Cells[i + 1, 2] as Excel.Range).Value2 = temp.Plemeno;
                    (range.Cells[i + 1, 3] as Excel.Range).Value2 = temp.Barva0;
                    if (temp.ZavodLicence == "Licence")
                    {
                        pomoc_cislo = "L " + Convert.ToString(temp.StartBeh1);
                    }
                    else
                    {
                        pomoc_cislo = Convert.ToString(temp.StartBeh1);
                    }
                    (range.Cells[i + 1, 4] as Excel.Range).Value2 = pomoc_cislo;
                    (range.Cells[i + 1, 5] as Excel.Range).Value2 = temp.Jmeno;

                    ++i;
                }
                for (int z = 1; z < i + 1; z++)
                {
                    for (int y = 1; y < 6; y++)
                    {
                        (range.Cells[z, y] as Excel.Range).BorderAround2();
                    }
                }

                worksheet.Columns.AutoFit();
                break;

            case "ROZPIS_2":
                (range.Cells[1, 1] as Excel.Range).Value2 = "Č.běhu";
                (range.Cells[1, 2] as Excel.Range).Value2 = "Plemeno";
                (range.Cells[1, 3] as Excel.Range).Value2 = "Dečka";
                (range.Cells[1, 4] as Excel.Range).Value2 = "Číslo psa";
                (range.Cells[1, 5] as Excel.Range).Value2 = "Jméno psa";

                dvojice = dataP.GetAllDvojice_1();
                i       = 1;
                foreach (int x in dvojice)
                {
                    temp = dataP.GetPesByDvojice_1(x, "červená");
                    if (temp == null)
                    {
                        continue;
                    }
                    (range.Cells[i + 1, 1] as Excel.Range).Value2 = temp.Dvojice1;
                    (range.Cells[i + 1, 2] as Excel.Range).Value2 = temp.Plemeno;
                    (range.Cells[i + 1, 3] as Excel.Range).Value2 = temp.Barva1;
                    if (temp.ZavodLicence == "Licence")
                    {
                        pomoc_cislo = "L " + Convert.ToString(temp.StartBeh1);
                    }
                    else
                    {
                        pomoc_cislo = Convert.ToString(temp.StartBeh1);
                    }
                    (range.Cells[i + 1, 4] as Excel.Range).Value2 = pomoc_cislo;
                    (range.Cells[i + 1, 5] as Excel.Range).Value2 = temp.Jmeno;
                    ++i;
                    temp = dataP.GetPesByDvojice_1(x, "bílá");
                    if (temp == null)
                    {
                        continue;
                    }
                    (range.Cells[i + 1, 1] as Excel.Range).Value2 = temp.Dvojice1;
                    (range.Cells[i + 1, 2] as Excel.Range).Value2 = temp.Plemeno;
                    (range.Cells[i + 1, 3] as Excel.Range).Value2 = temp.Barva1;
                    if (temp.ZavodLicence == "Licence")
                    {
                        pomoc_cislo = "L " + Convert.ToString(temp.StartBeh1);
                    }
                    else
                    {
                        pomoc_cislo = Convert.ToString(temp.StartBeh1);
                    }
                    (range.Cells[i + 1, 4] as Excel.Range).Value2 = pomoc_cislo;
                    (range.Cells[i + 1, 5] as Excel.Range).Value2 = temp.Jmeno;
                    ++i;
                    for (int z = 1; z < i + 1; z++)
                    {
                        for (int y = 1; y < 6; y++)
                        {
                            (range.Cells[z, y] as Excel.Range).BorderAround2();
                        }
                    }

                    worksheet.Columns.AutoFit();
                }
                break;

            case "TABULKY":
                n = 1;

                (range.Cells[1, 1] as Excel.Range).Value2  = "Č.běhu";
                (range.Cells[1, 2] as Excel.Range).Value2  = "Dečka";
                (range.Cells[1, 3] as Excel.Range).Value2  = "Plemeno";
                (range.Cells[1, 4] as Excel.Range).Value2  = "Číslo psa";
                (range.Cells[1, 5] as Excel.Range).Value2  = "Obratnost";
                (range.Cells[1, 6] as Excel.Range).Value2  = "Rychlost";
                (range.Cells[1, 7] as Excel.Range).Value2  = "Vytrvalost";
                (range.Cells[1, 8] as Excel.Range).Value2  = "Úsilí";
                (range.Cells[1, 9] as Excel.Range).Value2  = "Inteligence";
                (range.Cells[1, 10] as Excel.Range).Value2 = "Součet";

                for (int y = 1; y < 11; y++)
                {
                    (range.Cells[1, y] as Excel.Range).BorderAround2();
                }

                dvojice = dataP.GetAllDvojice();
                i       = 1;
                foreach (int x in dvojice)
                {
                    temp = dataP.GetPesByDvojice(x, "červená");
                    if (temp == null)
                    {
                        continue;
                    }

                    (range.Cells[i + n, 1] as Excel.Range).Value2 = temp.Dvojice0;
                    (range.Cells[i + n, 2] as Excel.Range).Value2 = temp.Barva0;
                    (range.Cells[i + n, 3] as Excel.Range).Value2 = temp.Plemeno;
                    if (temp.ZavodLicence == "Licence")
                    {
                        pomoc_cislo = "L " + Convert.ToString(temp.StartBeh1);
                    }
                    else
                    {
                        pomoc_cislo = Convert.ToString(temp.StartBeh1);
                    }
                    (range.Cells[i + n, 4] as Excel.Range).Value2 = pomoc_cislo;

                    for (int y = 1; y < 11; y++)
                    {
                        (range.Cells[i + n, y] as Excel.Range).BorderAround2();
                    }

                    ++i;

                    temp = dataP.GetPesByDvojice(x, "bílá");
                    if (temp == null)
                    {
                        ++n;
                        continue;
                    }

                    (range.Cells[i + n, 1] as Excel.Range).Value2 = temp.Dvojice0;
                    (range.Cells[i + n, 2] as Excel.Range).Value2 = temp.Barva0;
                    (range.Cells[i + n, 3] as Excel.Range).Value2 = temp.Plemeno;
                    if (temp.ZavodLicence == "Licence")
                    {
                        pomoc_cislo = "L " + Convert.ToString(temp.StartBeh1);
                    }
                    else
                    {
                        pomoc_cislo = Convert.ToString(temp.StartBeh1);
                    }
                    (range.Cells[i + n, 4] as Excel.Range).Value2 = pomoc_cislo;

                    for (int y = 1; y < 11; y++)
                    {
                        (range.Cells[i + n, y] as Excel.Range).BorderAround2();
                    }

                    ++i;
                    ++n;
                }
                break;

            case "TABULKY_2":
                n = 1;

                (range.Cells[1, 1] as Excel.Range).Value2  = "Č.běhu";
                (range.Cells[1, 2] as Excel.Range).Value2  = "Dečka";
                (range.Cells[1, 3] as Excel.Range).Value2  = "Plemeno";
                (range.Cells[1, 4] as Excel.Range).Value2  = "Číslo psa";
                (range.Cells[1, 5] as Excel.Range).Value2  = "Obratnost";
                (range.Cells[1, 6] as Excel.Range).Value2  = "Rychlost";
                (range.Cells[1, 7] as Excel.Range).Value2  = "Vytrvalost";
                (range.Cells[1, 8] as Excel.Range).Value2  = "Úsilí";
                (range.Cells[1, 9] as Excel.Range).Value2  = "Inteligence";
                (range.Cells[1, 10] as Excel.Range).Value2 = "Součet";

                for (int y = 1; y < 11; y++)
                {
                    (range.Cells[1, y] as Excel.Range).BorderAround2();
                }

                dvojice = dataP.GetAllDvojice_1();
                i       = 1;
                foreach (int x in dvojice)
                {
                    temp = dataP.GetPesByDvojice_1(x, "červená");
                    if (temp == null)
                    {
                        continue;
                    }

                    (range.Cells[i + n, 1] as Excel.Range).Value2 = temp.Dvojice1;
                    (range.Cells[i + n, 2] as Excel.Range).Value2 = temp.Barva1;
                    (range.Cells[i + n, 3] as Excel.Range).Value2 = temp.Plemeno;
                    if (temp.ZavodLicence == "Licence")
                    {
                        pomoc_cislo = "L " + Convert.ToString(temp.StartBeh1);
                    }
                    else
                    {
                        pomoc_cislo = Convert.ToString(temp.StartBeh1);
                    }
                    (range.Cells[i + n, 4] as Excel.Range).Value2 = pomoc_cislo;

                    for (int y = 1; y < 11; y++)
                    {
                        (range.Cells[i + n, y] as Excel.Range).BorderAround2();
                    }

                    ++i;

                    temp = dataP.GetPesByDvojice_1(x, "bílá");
                    if (temp == null)
                    {
                        ++n;
                        continue;
                    }

                    (range.Cells[i + n, 1] as Excel.Range).Value2 = temp.Dvojice1;
                    (range.Cells[i + n, 2] as Excel.Range).Value2 = temp.Barva1;
                    (range.Cells[i + n, 3] as Excel.Range).Value2 = temp.Plemeno;
                    if (temp.ZavodLicence == "Licence")
                    {
                        pomoc_cislo = "L " + Convert.ToString(temp.StartBeh1);
                    }
                    else
                    {
                        pomoc_cislo = Convert.ToString(temp.StartBeh1);
                    }
                    (range.Cells[i + n, 4] as Excel.Range).Value2 = pomoc_cislo;

                    for (int y = 1; y < 11; y++)
                    {
                        (range.Cells[i + n, y] as Excel.Range).BorderAround2();
                    }

                    ++i;
                    ++n;
                }
                break;

            case "VYSLEDKY":
                n = 1;

                (range.Cells[1, 1] as Excel.Range).Value2 = "Č.psa";
                (range.Cells[1, 2] as Excel.Range).Value2 = "Jméno psa";
                (range.Cells[1, 3] as Excel.Range).Value2 = "Plemeno";
                (range.Cells[1, 4] as Excel.Range).Value2 = "Pohlaví";

                // první rozhodčí

                (range.Cells[1, 5] as Excel.Range).Value2 = "Obratnost";
                (range.Cells[1, 6] as Excel.Range).Value2 = "Rychlost";
                (range.Cells[1, 7] as Excel.Range).Value2 = "Vytrvalost";
                (range.Cells[1, 8] as Excel.Range).Value2 = "Úsilí";
                (range.Cells[1, 9] as Excel.Range).Value2 = "Inteligence";

                // druhý rozhodčí

                (range.Cells[1, 10] as Excel.Range).Value2 = "Obratnost";
                (range.Cells[1, 11] as Excel.Range).Value2 = "Rychlost";
                (range.Cells[1, 12] as Excel.Range).Value2 = "Vytrvalost";
                (range.Cells[1, 13] as Excel.Range).Value2 = "Úsilí";
                (range.Cells[1, 14] as Excel.Range).Value2 = "Inteligence";
                (range.Cells[1, 15] as Excel.Range).Value2 = "Součet";

                for (int y = 1; y < 16; y++)
                {
                    (range.Cells[1, y] as Excel.Range).BorderAround2();
                }

                dvojice = dataP.GetAllStartList();
                i       = 1;
                foreach (int x in dvojice)
                {
                    temp = dataP.GetPesByStartNo(x);
                    if (temp == null)
                    {
                        continue;
                    }

                    if (temp.ZavodLicence == "Licence")
                    {
                        pomoc_cislo = "L " + Convert.ToString(temp.StartBeh1);
                    }
                    else
                    {
                        pomoc_cislo = Convert.ToString(temp.StartBeh1);
                    }
                    (range.Cells[i + n, 1] as Excel.Range).Value2 = pomoc_cislo;
                    (range.Cells[i + n, 2] as Excel.Range).Value2 = temp.Jmeno;
                    (range.Cells[i + n, 3] as Excel.Range).Value2 = temp.Plemeno;
                    (range.Cells[i + n, 4] as Excel.Range).Value2 = temp.Pohlavi;

                    (range.Cells[i + n, 5] as Excel.Range).Value2 = temp.AgilityA0;
                    (range.Cells[i + n, 6] as Excel.Range).Value2 = temp.SpeedA0;
                    (range.Cells[i + n, 7] as Excel.Range).Value2 = temp.EnduranceA0;
                    (range.Cells[i + n, 8] as Excel.Range).Value2 = temp.EnthusiasmA0;
                    (range.Cells[i + n, 9] as Excel.Range).Value2 = temp.IntelligenceA0;

                    (range.Cells[i + n, 10] as Excel.Range).Value2 = temp.AgilityA1;
                    (range.Cells[i + n, 11] as Excel.Range).Value2 = temp.SpeedA1;
                    (range.Cells[i + n, 12] as Excel.Range).Value2 = temp.EnduranceA1;
                    (range.Cells[i + n, 13] as Excel.Range).Value2 = temp.EnthusiasmA1;
                    (range.Cells[i + n, 14] as Excel.Range).Value2 = temp.IntelligenceA1;

                    (range.Cells[i + n, 15] as Excel.Range).Value2 = temp.Body1;

                    for (int y = 1; y < 16; y++)
                    {
                        (range.Cells[i + n, y] as Excel.Range).BorderAround2();
                    }

                    ++i;
                }
                break;

            case "VYSLEDKY_2":
                n = 1;

                (range.Cells[1, 1] as Excel.Range).Value2 = "Č.psa";
                (range.Cells[1, 2] as Excel.Range).Value2 = "Jméno psa";
                (range.Cells[1, 3] as Excel.Range).Value2 = "Plemeno";
                (range.Cells[1, 4] as Excel.Range).Value2 = "Pohlaví";

                // první rozhodčí

                (range.Cells[1, 5] as Excel.Range).Value2 = "Obratnost";
                (range.Cells[1, 6] as Excel.Range).Value2 = "Rychlost";
                (range.Cells[1, 7] as Excel.Range).Value2 = "Vytrvalost";
                (range.Cells[1, 8] as Excel.Range).Value2 = "Úsilí";
                (range.Cells[1, 9] as Excel.Range).Value2 = "Inteligence";

                // druhý rozhodčí

                (range.Cells[1, 10] as Excel.Range).Value2 = "Obratnost";
                (range.Cells[1, 11] as Excel.Range).Value2 = "Rychlost";
                (range.Cells[1, 12] as Excel.Range).Value2 = "Vytrvalost";
                (range.Cells[1, 13] as Excel.Range).Value2 = "Úsilí";
                (range.Cells[1, 14] as Excel.Range).Value2 = "Inteligence";
                (range.Cells[1, 15] as Excel.Range).Value2 = "Součet";
                (range.Cells[1, 16] as Excel.Range).Value2 = "Celkový součet";
                (range.Cells[1, 17] as Excel.Range).Value2 = "Umístění ve skupině";

                for (int y = 1; y < 18; y++)
                {
                    (range.Cells[1, y] as Excel.Range).BorderAround2();
                }

                dvojice = dataP.GetAllStartList();
                i       = 1;
                foreach (int x in dvojice)
                {
                    temp = dataP.GetPesByStartNo(x);
                    if (temp == null)
                    {
                        continue;
                    }

                    if (temp.ZavodLicence == "Licence")
                    {
                        pomoc_cislo = "L " + Convert.ToString(temp.StartBeh1);
                    }
                    else
                    {
                        pomoc_cislo = Convert.ToString(temp.StartBeh1);
                    }
                    (range.Cells[i + n, 1] as Excel.Range).Value2 = pomoc_cislo;
                    (range.Cells[i + n, 2] as Excel.Range).Value2 = temp.Jmeno;
                    (range.Cells[i + n, 3] as Excel.Range).Value2 = temp.Plemeno;
                    (range.Cells[i + n, 4] as Excel.Range).Value2 = temp.Pohlavi;

                    (range.Cells[i + n, 5] as Excel.Range).Value2 = temp.AgilityB0;
                    (range.Cells[i + n, 6] as Excel.Range).Value2 = temp.SpeedB0;
                    (range.Cells[i + n, 7] as Excel.Range).Value2 = temp.EnduranceB0;
                    (range.Cells[i + n, 8] as Excel.Range).Value2 = temp.EnthusiasmB0;
                    (range.Cells[i + n, 9] as Excel.Range).Value2 = temp.IntelligenceB0;

                    (range.Cells[i + n, 10] as Excel.Range).Value2 = temp.AgilityB1;
                    (range.Cells[i + n, 11] as Excel.Range).Value2 = temp.SpeedB1;
                    (range.Cells[i + n, 12] as Excel.Range).Value2 = temp.EnduranceB1;
                    (range.Cells[i + n, 13] as Excel.Range).Value2 = temp.EnthusiasmB1;
                    (range.Cells[i + n, 14] as Excel.Range).Value2 = temp.IntelligenceB1;

                    (range.Cells[i + n, 15] as Excel.Range).Value2 = temp.Body2;

                    (range.Cells[i + n, 16] as Excel.Range).Value2 = temp.Body1 + temp.Body2;

                    (range.Cells[i + n, 17] as Excel.Range).Value2 = temp.Skupina;

                    for (int y = 1; y < 18; y++)
                    {
                        (range.Cells[i + n, y] as Excel.Range).BorderAround2();
                    }

                    ++i;
                }
                break;

            default: break;
            }

            workbook.Close(true, Missing.Value, Missing.Value);
            excelApp.Quit();
        }