コード例 #1
0
        private void btnBuscar_Click(object sender, EventArgs e)
        {
            try
            {
                if (mskCodigoprestamo.Text.Equals(""))
                {
                    MessageBox.Show("Ingrese el Codigo del Prestamo.", "Escuela Platanares", MessageBoxButtons.OK, MessageBoxIcon.Question);
                    return;
                }
                prestamo = Logica.SeleccionarPrestamoPorId(Convert.ToInt32(mskCodigoprestamo.Text.Trim()));

                if (prestamo == null)
                {
                    MessageBox.Show("Prestamo NO encontrado.", "Escuela Platanares", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                if (Validador_de_Solicitud(prestamo))
                {
                    return;
                }
                List <Libros> L_Prestados = new Capa.Logica.Prestamo_Libros_Logica().SeleccionarTodos(Convert.ToInt32(mskCodigoprestamo.Text.Trim()));
                lstLibrosPrestamo.DataSource = L_Prestados;
            }
            catch (Exception)
            {
                throw;
            }
            MostrarLogo();
            if (lstLibrosPrestamo.Items.Count > 0)
            {
                btnBuscarLibro.Enabled  = true;
                btnAgregarLibro.Enabled = true;
            }
        }
コード例 #2
0
        /// <summary>
        /// Metodo par aguardar un XML
        /// en una ruta determinada
        /// </summary>
        /// <param name="prestamo"></param>
        /// <param name="ruta"></param>
        public void GuardarXML(Prestamo prestamo, string ruta)
        {
            List <Libros> lista = new Prestamo_Libros_Logica().SeleccionarTodos(prestamo.id);

            XmlDocument doc = new XmlDocument();

            doc.LoadXml("<Prestamos></Prestamos>");

            XmlElement root = doc.DocumentElement;

            //--INICIO NODO PRESTAMO
            XmlElement NodoPrestamo = doc.CreateElement("Prestamo");
            //--
            XmlElement NodoCodigo = doc.CreateElement("Codigo");

            NodoCodigo.InnerText = prestamo.id.ToString();
            NodoPrestamo.AppendChild(NodoCodigo);
            //--
            //--
            XmlElement NodoFecha_Emision = doc.CreateElement("Fecha_Emision");

            NodoFecha_Emision.InnerText = prestamo.Fecha_Act.ToString();
            NodoPrestamo.AppendChild(NodoFecha_Emision);
            //--
            //--
            XmlElement NodoFecha_Devolucion = doc.CreateElement("Fecha_Devolucion");

            NodoFecha_Devolucion.InnerText = prestamo.Fecha_Dev.ToString();
            NodoPrestamo.AppendChild(NodoFecha_Devolucion);
            //--

            //--INICIO NODO USUARIO AUTORIZADO
            XmlElement NodoUsuario = doc.CreateElement("Usuario_Autorizado");

            NodoUsuario.InnerText = prestamo.Usuario.id.ToString();
            NodoPrestamo.AppendChild(NodoUsuario);
            //--
            //--
            XmlElement NodoRoll = doc.CreateElement("Roll_Usuario");

            NodoRoll.InnerText = prestamo.Usuario.Rol.descripcion.ToString();
            NodoPrestamo.AppendChild(NodoRoll);
            //--FIN NODO USUARIO AUTORIZADO


            //--INICIO NODO ESTUDIANTE
            XmlElement NodoEstudiante = doc.CreateElement("Estudiante");
            //--
            XmlElement NodoCedula = doc.CreateElement("Cedula");

            NodoCedula.InnerText = prestamo.estudiant.IdCedula.ToString();
            NodoEstudiante.AppendChild(NodoCedula);
            //--
            //--
            XmlElement NodoNombre = doc.CreateElement("Nombre");

            NodoNombre.InnerText = prestamo.estudiant.Nombre.ToString();
            NodoEstudiante.AppendChild(NodoNombre);
            //--
            //--
            XmlElement NodoSeccion = doc.CreateElement("Seccion");

            NodoSeccion.InnerText = prestamo.estudiant.Seccion.ToString();
            NodoEstudiante.AppendChild(NodoSeccion);
            //--
            //--
            XmlElement NodoTelefono = doc.CreateElement("Telefono");

            NodoTelefono.InnerText = prestamo.estudiant.Telefono.ToString();
            NodoEstudiante.AppendChild(NodoTelefono);
            //--
            //--
            XmlElement NodoEmail = doc.CreateElement("Email");

            NodoEmail.InnerText = prestamo.estudiant.Email.ToString();
            NodoEstudiante.AppendChild(NodoEmail);
            //--FIN NODO ESTUDIANTE

            XmlElement NodoLibros = doc.CreateElement("Libros");

            foreach (Libros Libro in lista)
            {
                //--INICIO NODO LIBRO
                XmlElement NodoLibro = doc.CreateElement("Libro");
                //--
                XmlElement NodoCodigo_L = doc.CreateElement("Codigo");
                NodoCodigo_L.InnerText = Libro.Id.ToString();
                NodoLibro.AppendChild(NodoCodigo_L);
                //--
                //--
                XmlElement NodoTitulo = doc.CreateElement("Titulo");
                NodoTitulo.InnerText = Libro.Titulo.ToString();
                NodoLibro.AppendChild(NodoTitulo);
                //--
                //--
                XmlElement NodoAnno = doc.CreateElement("Año");
                NodoAnno.InnerText = Libro.anno.ToString();
                NodoLibro.AppendChild(NodoAnno);
                //--
                //--
                XmlElement NodoEditoial = doc.CreateElement("Editorial");
                NodoEditoial.InnerText = Libro.Editorial.Nombre.ToString();
                NodoLibro.AppendChild(NodoEditoial);
                //--
                //--FIN NODO LIBRO

                NodoLibros.AppendChild(NodoLibro);
            }

            //--CAT
            XmlElement NodoTipo_solicitud = doc.CreateElement("Tipo_Solicitud");

            NodoTipo_solicitud.InnerText = prestamo.Categoria.Descripcion.ToString();
            NodoLibros.AppendChild(NodoTipo_solicitud);
            //--

            //--FIN NODO PRESTAMO
            root.AppendChild(NodoPrestamo);
            root.AppendChild(NodoEstudiante);
            root.AppendChild(NodoLibros);


            // Guardamos el Archivo XML
            doc.Save(ruta);
        }
コード例 #3
0
        /// <summary>
        /// Guardar en Prestamos en pdf
        /// para tener en comprobante del
        /// prestamo
        /// </summary>
        /// <param name="prestamo"></param>
        public void pdf(Prestamo prestamo)
        {
            List <Libros> lista = new Prestamo_Libros_Logica().SeleccionarTodos(prestamo.id);
            //var p = prestamo;
            // Creamos el documento con el tamaño de página tradicional
            Document doc = new Document(PageSize.LETTER);

            // Indicamos donde vamos a guardar el documento
            PdfWriter writer = PdfWriter.GetInstance(doc,
                                                     new FileStream(@"C:\Users\Pablo\Desktop\Comprobantes\Prestamo_" + prestamo.id + ".pdf", FileMode.Create));


            // Le colocamos el título y el autor
            // **Nota: Esto no será visible en el documento
            doc.AddTitle("Prestamos de Libros");
            doc.AddCreator("Escuela Platanares");

            // Abrimos el archivo
            doc.Open();

            // Escribimos el encabezamiento en el documento
            doc.Add(new Paragraph("Prestamos de Libros"));
            doc.Add(Chunk.NEWLINE);


            iTextSharp.text.Font _standardFont = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, iTextSharp.text.Font.NORMAL, BaseColor.BLACK);

            // Creamos una tabla que contendrá el nombre, apellido y país
            // de nuestros visitante.
            PdfPTable tblPrueba = new PdfPTable(1);

            tblPrueba.WidthPercentage = 25;

            //// Configuramos el título de las columnas de la tabla
            //--Inicio Prestamo
            PdfPCell clPrestamo = new PdfPCell(new Phrase("Informacion del Prestamo", _standardFont));

            clPrestamo.BorderWidth         = 2;
            clPrestamo.HorizontalAlignment = 1;
            clPrestamo.BorderWidthBottom   = 0.75f;
            tblPrueba.AddCell(clPrestamo);

            clPrestamo             = new PdfPCell(new Phrase("Codido: " + prestamo.id.ToString(), _standardFont));
            clPrestamo.BorderWidth = 0;
            tblPrueba.AddCell(clPrestamo);

            clPrestamo             = new PdfPCell(new Phrase("Fecha de Solicitud: " + prestamo.Fecha_Act.ToString("dd/mm/yyyy"), _standardFont));
            clPrestamo.BorderWidth = 0;
            tblPrueba.AddCell(clPrestamo);

            clPrestamo             = new PdfPCell(new Phrase("Fecha de Devolución: " + prestamo.Fecha_Dev.ToString("dd/mm/yyyy"), _standardFont));
            clPrestamo.BorderWidth = 0;
            tblPrueba.AddCell(clPrestamo);

            clPrestamo             = new PdfPCell(new Phrase("Días de Prestamo: " + prestamo.dias.ToString(), _standardFont));
            clPrestamo.BorderWidth = 0;
            tblPrueba.AddCell(clPrestamo);
            //--Fin Prestamo

            //--Inicio Usuario
            PdfPCell clUsuario = new PdfPCell(new Phrase("Usuario Autorizado", _standardFont));

            clUsuario.BorderWidth         = 2;
            clUsuario.HorizontalAlignment = 1;
            clUsuario.BorderWidthBottom   = 0.75f;

            tblPrueba.AddCell(clUsuario);

            clUsuario             = new PdfPCell(new Phrase("Usuario: " + prestamo.Usuario.id.ToString(), _standardFont));
            clUsuario.BorderWidth = 0;
            tblPrueba.AddCell(clUsuario);

            clUsuario             = new PdfPCell(new Phrase("Tipo: " + prestamo.Usuario.Rol.descripcion.ToString(), _standardFont));
            clUsuario.BorderWidth = 0;
            tblPrueba.AddCell(clUsuario);
            //--Fin Usuario

            //--Inicio Estudiante
            PdfPCell clEstudiante = new PdfPCell(new Phrase("Informacion del Estudiante", _standardFont));

            clEstudiante.BorderWidth         = 2;
            clEstudiante.HorizontalAlignment = 1;
            clEstudiante.BorderWidthBottom   = 0.75f;
            tblPrueba.AddCell(clEstudiante);

            clEstudiante             = new PdfPCell(new Phrase("Cédula: " + prestamo.estudiant.IdCedula.ToString(), _standardFont));
            clEstudiante.BorderWidth = 0;
            tblPrueba.AddCell(clEstudiante);

            clEstudiante             = new PdfPCell(new Phrase("Nombre: " + prestamo.estudiant.Nombre.ToString(), _standardFont));
            clEstudiante.BorderWidth = 0;
            tblPrueba.AddCell(clEstudiante);

            clEstudiante             = new PdfPCell(new Phrase("Sección: " + prestamo.estudiant.Seccion.ToString(), _standardFont));
            clEstudiante.BorderWidth = 0;
            tblPrueba.AddCell(clEstudiante);

            clEstudiante             = new PdfPCell(new Phrase("Teléfono: " + prestamo.estudiant.Telefono.ToString(), _standardFont));
            clEstudiante.BorderWidth = 0;
            tblPrueba.AddCell(clEstudiante);

            clEstudiante             = new PdfPCell(new Phrase("Email: " + prestamo.estudiant.Email.ToString(), _standardFont));
            clEstudiante.BorderWidth = 0;
            tblPrueba.AddCell(clEstudiante);
            //--Fin Estudiante

            foreach (Libros libro in lista)
            {
                //--Inicio Libro
                PdfPCell clLibro = new PdfPCell(new Phrase("Libro", _standardFont));
                clLibro.BorderWidth         = 2;
                clLibro.HorizontalAlignment = 1;
                clLibro.BorderWidthBottom   = 0.75f;
                tblPrueba.AddCell(clLibro);

                clLibro             = new PdfPCell(new Phrase("Código: " + libro.Id.ToString(), _standardFont));
                clLibro.BorderWidth = 0;
                tblPrueba.AddCell(clLibro);

                clLibro             = new PdfPCell(new Phrase("Título: " + libro.Titulo.ToString(), _standardFont));
                clLibro.BorderWidth = 0;
                tblPrueba.AddCell(clLibro);

                clLibro             = new PdfPCell(new Phrase("Año: " + libro.anno.ToString(), _standardFont));
                clLibro.BorderWidth = 0;
                tblPrueba.AddCell(clLibro);

                clLibro             = new PdfPCell(new Phrase("Editorial: " + libro.Editorial.Nombre.ToString(), _standardFont));
                clLibro.BorderWidth = 0;
                tblPrueba.AddCell(clLibro);
                //--Fin Libro
            }
            //--Inicio Tipo Solicitud
            PdfPCell clTipo = new PdfPCell(new Phrase("Tipo de Solicitud", _standardFont));

            clTipo.BorderWidth         = 2;
            clTipo.HorizontalAlignment = 1;
            clTipo.BorderWidthBottom   = 0.75f;
            tblPrueba.AddCell(clTipo);

            clTipo             = new PdfPCell(new Phrase("Clasificasión: " + prestamo.Categoria.Descripcion.ToString(), _standardFont));
            clTipo.BorderWidth = 0;
            tblPrueba.AddCell(clTipo);
            //--Fin Tipo Solicitud

            // Finalmente, añadimos la tabla al documento PDF y cerramos el documento
            doc.Add(tblPrueba);

            doc.Close();
            writer.Close();
        }