//MUESTRA PREVISUALIZACION CONTRATO
        private void btnShowContract_Click(object sender, MouseButtonEventArgs e)
        {
            bool crearcarp = new Clases.Pdf().CrearCarpetaXml("contratos");
            if (crearcarp)
            {
                Boolean flag = true;
                try
                {
                    Console.WriteLine("init");
                    ThreadPool.QueueUserWorkItem(o =>
                    {
                        while (flag)
                        {
                            Dispatcher.BeginInvoke(new Action(() =>
                            {
                                this.label.Content = "CARGANDO";
                            }));
                            Thread.Sleep(100);
                        }
                    });
                    listCargo = new Cargo().findAll(this.cTypeContract.SelectedIndex + 1);
                    listTipoContrato = new TipoContrato().findAll();
                    listJornada = new tipo_jornada().findforCargo(this.cCargo.Text);
                    Clases.Contratos contrato = new Clases.Contratos(this.tRut.Text, this.tDateInit.Text, this.tName.Text + " " + this.tSurname.Text, this.Tdireccion.Text,
                                                            listCargo[this.cCargo.SelectedIndex].cargo, this.cDepto.Text.Trim(),
                                                            listTipoContrato[this.cTypeContract.SelectedIndex].tipo,
                                                            new Contratos().get_sueldo(listCargo[this.cCargo.SelectedIndex].id.ToString(), listJornada[this.cJornada.SelectedIndex].id_tipo_jornada.ToString()),
                                                            this.tDateEnd.Text,
                                                            this.cAfp.Text.Trim(), this.cSalud.Text.Trim()
                        );

                    new Clases.Pdf().CrearArchivoXml("contratos/contract.xml",
                    contrato.rut, contrato.fInicio, contrato.nombre_completo, contrato.direccion, contrato.Cargo, contrato.depto, contrato.tContrato,
                    contrato.SueldoBase, contrato.fTermino, contrato.afp, contrato.salud);
                    Document document = new Document();

                    List<String> resul = new Clases.Pdf().Leer("administrativo");

                    PdfWriter.GetInstance(document, new FileStream("contrato.pdf", FileMode.OpenOrCreate));
                    document.Open();
                    Chunk chunk = new Chunk(resul[0], FontFactory.GetFont("ARIAL", 12, iTextSharp.text.Font.UNDERLINE));

                    document.Add(new iTextSharp.text.Paragraph(chunk));
                    for (int i = 1; i < resul.Count; i++)
                    {
                        document.Add(new iTextSharp.text.Paragraph(resul[i]));
                    }
                    document.Close();

                    new Dialog("Contrato generado con exito.", main).ShowDialog();
                    flag = false;
                    System.Diagnostics.Process.Start("contrato.pdf");
                    this.label.Content = "";
                }
                catch (Exception ex)
                {
                    flag = false;
                    new Dialog("Ocurrio un error al generar el contrato.", main).ShowDialog();
                    this.label.Content = "";
                    Console.WriteLine("MainWindow.btnShowContract_Click() " + ex.Message.ToString());
                }
            }
        }
        //MUESTRA PREVISUALIZACION CONTRATO
        private void btnShowContract_Click(object sender, MouseButtonEventArgs e)
        {
            bool crearcarp = new Clases.Pdf().CrearCarpetaXml("contratos");

            if (crearcarp)
            {
                Boolean flag = true;
                try
                {
                    Console.WriteLine("init");
                    ThreadPool.QueueUserWorkItem(o =>
                    {
                        while (flag)
                        {
                            Dispatcher.BeginInvoke(new Action(() =>
                            {
                                this.label.Content = "CARGANDO";
                            }));
                            Thread.Sleep(100);
                        }
                    });
                    listCargo        = new Cargo().findAll(this.cTypeContract.SelectedIndex + 1);
                    listTipoContrato = new TipoContrato().findAll();
                    listJornada      = new tipo_jornada().findforCargo(this.cCargo.Text);
                    Clases.Contratos contrato = new Clases.Contratos(this.tRut.Text, this.tDateInit.Text, this.tName.Text + " " + this.tSurname.Text, this.Tdireccion.Text,
                                                                     listCargo[this.cCargo.SelectedIndex].cargo, this.cDepto.Text.Trim(),
                                                                     listTipoContrato[this.cTypeContract.SelectedIndex].tipo,
                                                                     new Contratos().get_sueldo(listCargo[this.cCargo.SelectedIndex].id.ToString(), listJornada[this.cJornada.SelectedIndex].id_tipo_jornada.ToString()),
                                                                     this.tDateEnd.Text,
                                                                     this.cAfp.Text.Trim(), this.cSalud.Text.Trim()
                                                                     );

                    new Clases.Pdf().CrearArchivoXml("contratos/contract.xml",
                                                     contrato.rut, contrato.fInicio, contrato.nombre_completo, contrato.direccion, contrato.Cargo, contrato.depto, contrato.tContrato,
                                                     contrato.SueldoBase, contrato.fTermino, contrato.afp, contrato.salud);
                    Document document = new Document();

                    List <String> resul = new Clases.Pdf().Leer("administrativo");

                    PdfWriter.GetInstance(document, new FileStream("contrato.pdf", FileMode.OpenOrCreate));
                    document.Open();
                    Chunk chunk = new Chunk(resul[0], FontFactory.GetFont("ARIAL", 12, iTextSharp.text.Font.UNDERLINE));

                    document.Add(new iTextSharp.text.Paragraph(chunk));
                    for (int i = 1; i < resul.Count; i++)
                    {
                        document.Add(new iTextSharp.text.Paragraph(resul[i]));
                    }
                    document.Close();

                    new Dialog("Contrato generado con exito.", main).ShowDialog();
                    flag = false;
                    System.Diagnostics.Process.Start("contrato.pdf");
                    this.label.Content = "";
                }
                catch (Exception ex)
                {
                    flag = false;
                    new Dialog("Ocurrio un error al generar el contrato.", main).ShowDialog();
                    this.label.Content = "";
                    Console.WriteLine("MainWindow.btnShowContract_Click() " + ex.Message.ToString());
                }
            }
        }