Example #1
0
        protected void Avanzar(object sender, EventArgs e)
        {
            if ((txtpatente.Value != "") && (txtdni.Value != "") && (StockError.Visible == false))
            {
                Buscadores bus       = new Buscadores();
                cliente    ocliente  = bus.oclientedni(txtdni.Value);
                vehiculo   ovehiculo = bus.buscarvehiculo(txtpatente.Value);
                cliente    oclientes = bus.ocliente(ovehiculo);

                if ((ovehiculo != null) && (ovehiculo.id_cliente != null) && (ocliente != null) && (ovehiculo.id_cliente == ocliente.id))
                {
                    Server.Transfer("DetalleTaller.aspx");
                }
                else
                {
                }
            }
        }
Example #2
0
        private void GuardarCambiodecliente()
        {
            Buscadores bus       = new Buscadores();
            vehiculo   ovehiculo = bus.buscarvehiculo(txtpatente.Value);
            cliente    ocliente  = bus.ocliente(ovehiculo);
            cliente    oclientes = bus.oclientedni(txtdni.Value);

            btnGuardar.Visible = false;
            if ((ocliente != null) && (oclientes != null))
            {
                ocliente = bus.oclientedni(txtdni.Value);
                using (aplicadaBDEntities2 DBF = new aplicadaBDEntities2())
                {
                    vehiculo oVehiculo = (from q in DBF.vehiculo where q.id_vehiculo == ovehiculo.id_vehiculo select q).First();
                    oVehiculo.id_cliente = ocliente.id;
                    DBF.SaveChanges();
                }
            }
            else
            {
                using (aplicadaBDEntities2 DBF = new aplicadaBDEntities2())
                {
                    cliente ncliente = new cliente
                    {
                        dni      = txtdni.Value,
                        nombre   = txtapellido.Value + " " + txtnombre.Value,
                        telefono = txttelefono.Value,
                        email    = txtemail.Value,
                    };

                    DBF.cliente.Add(ncliente);
                    DBF.SaveChanges();
                }
                ocliente = bus.oclientedni(txtdni.Value);
                using (aplicadaBDEntities2 DBF = new aplicadaBDEntities2())
                {
                    vehiculo oVehiculo = (from q in DBF.vehiculo where q.id_vehiculo == ovehiculo.id_vehiculo select q).First();
                    oVehiculo.id_cliente = ocliente.id;
                    DBF.SaveChanges();
                }
            }
        }
Example #3
0
        protected void BtnBuscar(object sender, EventArgs e)
        {
            Buscadores bus = new Buscadores();

            if (txtidorden.Value != "")
            {
                orden       oOrden       = bus.buscarorden(int.Parse(txtidorden.Value));
                ordenestado Oordenestado = new ordenestado();

                if (oOrden != null)
                {
                    Oordenestado = bus.buscarvestadoorden(oOrden.id_orden);
                }

                if (oOrden != null)
                {
                    if ((Oordenestado == null) || (Oordenestado.estado == null) || (Oordenestado.estado == 0) || (Oordenestado.estado == 5))
                    {
                        //Validar orden estado 2 o superior aca? si?
                        NoAuto.Visible = false;
                        vehiculo Ovehiculo = bus.buscarvehiculoid(int.Parse(oOrden.id_vehiculo.ToString()));
                        cliente  oCliente  = bus.ocliente(Ovehiculo);
                        modelo   omodelo   = bus.buscarmodelo(Ovehiculo);
                        Ovehiculo.modelo = omodelo;
                        marca omarca = bus.buscarmarca(Ovehiculo.modelo);
                        Ovehiculo.modelo.marca = omarca;
                        Ovehiculo.cliente      = oCliente;
                        oOrden.vehiculo        = Ovehiculo;

                        txtpatente.Value = oOrden.vehiculo.patente;
                        txtmodelo.Value  = oOrden.vehiculo.modelo.nombre;
                        txtmarca.Value   = oOrden.vehiculo.modelo.marca.nombre;

                        txtaño.Value = oOrden.vehiculo.annio;
                        string[] separadas;
                        if (Ovehiculo.cliente.dni != null)
                        {
                            separadas         = Ovehiculo.cliente.nombre.Split(' ');
                            txtdni.Value      = Ovehiculo.cliente.dni;
                            txtapellido.Value = separadas[0];
                            txtnombre.Value   = separadas[1];
                            txttelefono.Value = Ovehiculo.cliente.telefono;
                            txtemail.Value    = Ovehiculo.cliente.email;
                        }
                        OrdenActual = oOrden;
                        CargarGrid(oOrden);
                        PDFESTADOCERO();
                    }
                    else
                    {
                        Label3.Text    = "EL VEHICULO YA POSEE UNA ORDEN ACTIVA";
                        NoAuto.Visible = true;
                    }
                }
                else
                {
                    Label3.Text    = "ORDEN NO EXISTENTE";
                    NoAuto.Visible = true;
                }
            }
        }
Example #4
0
        public void PDFESTADOCERO()
        {
            Buscadores bus    = new Buscadores();
            var        doc    = new iTextSharp.text.Document(PageSize.A4.Rotate());
            string     path   = Server.MapPath("~");
            PdfWriter  writer = PdfWriter.GetInstance(doc, new FileStream(path + "/Presupuesto.pdf", FileMode.Create));

            doc.Open();

            doc.AddTitle("Presupuesto");

            Paragraph p = new Paragraph("Presupuesto");

            p.Alignment = 1;
            p.Font.Size = 24;
            doc.Add(p);
            PdfContentByte cb = writer.DirectContent;

            cb.MoveTo(100, 0);
            cb.LineTo(0, 0);
            cb.Stroke();
            doc.Add(Chunk.NEWLINE);
            Paragraph d = new Paragraph("Orden N°: " + OrdenActual.id_orden);

            d.Alignment = 2;
            d.Font.Size = 12;
            doc.Add(d);

            //////////////////////////////////////////desde aca yo me mando las cagadas////////////////////////////////////////////////

            Paragraph fe = new Paragraph(DateTime.Now.ToString("dd-MM-yyyy"));

            fe.Alignment = 2;
            fe.Font.Size = 12;
            doc.Add(fe);

            Paragraph op = new Paragraph("Operario: " + LogEmpleado.nombreyapellido);

            op.Alignment = 2;
            op.Font.Size = 12;
            doc.Add(op);
            doc.Add(Chunk.NEWLINE);

            /////////////////////////////////////////hasta aca llego mi cagada/////////////////////////////////////////////////////////

            vehiculo ovehiculo = bus.buscarvehiculo(txtpatente.Value);
            cliente  ocliente  = bus.ocliente(ovehiculo);
            modelo   omarca    = bus.buscarmodelo(ovehiculo);
            marca    omodelo   = bus.buscarmarca(omarca);

            Paragraph Cliente = new Paragraph("Apellido y Nombre: " + ocliente.nombre + "                 DNI: " + ocliente.dni + "            Telefono: " + ocliente.telefono + "        Correo Electronico: " + ocliente.email);

            doc.Add(Cliente);
            doc.Add(Chunk.NEWLINE);
            Paragraph Vehiculo = new Paragraph("Patente: " + ovehiculo.patente + "          Modelo: " + omodelo.nombre + "       Marca: " + omarca.nombre);

            doc.Add(Vehiculo);
            doc.Add(Chunk.NEWLINE);



            PdfPTable pdfTable = new PdfPTable(GridView2.HeaderRow.Cells.Count);

            foreach (TableCell headerCell in GridView2.HeaderRow.Cells)
            {
                PdfPCell pdfCell = new PdfPCell(new Phrase(headerCell.Text));
                pdfTable.AddCell(pdfCell);
            }

            foreach (GridViewRow gridViewRow in GridView2.Rows)
            {
                foreach (TableCell tableCell in gridViewRow.Cells)
                {
                    PdfPCell pdfCell = new PdfPCell(new Phrase(tableCell.Text));
                    pdfTable.AddCell(pdfCell);
                }
            }
            doc.Add(pdfTable);
            Paragraph tt = new Paragraph("Total: $" + lblprecio.Text);

            tt.Alignment = 2;
            tt.Font.Size = 12;
            doc.Add(tt);
            doc.Add(Chunk.NEWLINE);

            doc.Close();
            Page.ClientScript.RegisterStartupScript(this.GetType(), "OpenWindow", "window.open('Presupuesto.pdf','_newtab');", true);
            //Response.Redirect("Presupuesto.pdf");
        }
Example #5
0
        protected void PDFPP(object sender, EventArgs e)
        {
            if ((txtdni.Value != "") && (txtfechafin.Value != "") && (txtfechainicio.Value != ""))
            {
                Buscadores bus         = new Buscadores();
                DateTime   oDateinicio = Convert.ToDateTime(txtfechainicio.Value);
                DateTime   oDatefin    = Convert.ToDateTime(txtfechafin.Value);
                cliente    ocliente    = bus.oclientedni(txtdni.Value);

                if (ocliente.dni != null)
                {
                    List <vehiculo> Lvehiculo = bus.buscarclientevehiculo(ocliente.id);
                    Lvehiculo.Count();
                    if (Lvehiculo.Count != 0)
                    {
                        var       doc    = new iTextSharp.text.Document(PageSize.A4);
                        string    path   = Server.MapPath("~");
                        PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(path + "/Taller.pdf", FileMode.Create));
                        doc.Open();
                        //Cabecera
                        BaseFont             bfntHead   = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
                        iTextSharp.text.Font fntHead    = new iTextSharp.text.Font(bfntHead, 16, 1, iTextSharp.text.BaseColor.GREEN.Darker());
                        Paragraph            prgHeading = new Paragraph();
                        prgHeading.Alignment = 1;
                        prgHeading.Add(new Chunk("Taller de Reparaciones".ToUpper(), fntHead));
                        doc.Add(prgHeading);
                        doc.Add(Chunk.NEWLINE);
                        //Generado By
                        Paragraph            prgGeneratedBY = new Paragraph();
                        BaseFont             btnAuthor      = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
                        iTextSharp.text.Font fntAuthor      = new iTextSharp.text.Font(btnAuthor, 12, 2, iTextSharp.text.BaseColor.BLACK);
                        prgGeneratedBY.Alignment = Element.ALIGN_RIGHT;
                        prgGeneratedBY.Add(new Chunk("Generado por: " + LogEmpleado.nombreyapellido, fntAuthor));      //Agregar LOG Empleado
                        prgGeneratedBY.Add(new Chunk("\nFecha : " + DateTime.Now.ToShortDateString(), fntAuthor));
                        doc.Add(prgGeneratedBY);
                        Paragraph p = new Paragraph(new Chunk(new iTextSharp.text.pdf.draw.LineSeparator(0.0F, 100.0F, iTextSharp.text.BaseColor.BLACK, Element.ALIGN_LEFT, 1)));
                        doc.Add(p);
                        //Espacio
                        doc.Add(new Chunk("\n", fntHead));
                        //Datos
                        Paragraph            Datos     = new Paragraph();
                        BaseFont             bfntDatos = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
                        iTextSharp.text.Font fntDatos  = new iTextSharp.text.Font(bfntDatos, 12, 0, iTextSharp.text.BaseColor.BLACK);
                        Datos.Alignment = Element.ALIGN_CENTER;
                        Datos.Add(new Chunk("\nApellido y Nombre: " + ocliente.nombre + "   DNI:" + ocliente.dni + "  Telefono:  " + ocliente.telefono + " \nEmail:  " + ocliente.email, fntDatos));
                        doc.Add(Datos);
                        //Espacio
                        doc.Add(new Chunk("\n", fntHead));
                        int controlprecio;
                        foreach (vehiculo o in Lvehiculo)
                        {
                            controlprecio = 0;

                            o.modelo       = bus.buscarmodelo(o);
                            o.modelo.marca = bus.buscarmarca(o.modelo);


                            //Creo una tabla
                            DataTable dt = new DataTable();
                            dt.Columns.AddRange(new DataColumn[3] {
                                new DataColumn("N°Orden"), new DataColumn("Fecha"), new DataColumn("PrecioTotal")
                            });                                                                                                                             //nombre de las columnas
                            List <orden> Lorden = bus.buscarListaordenporvehiculo(o.id_vehiculo);
                            foreach (orden OrdenActual in Lorden)
                            {
                                int         preciototal = 0;
                                ordenestado oestado     = bus.buscarvestadoorden(OrdenActual.id_orden);
                                if ((oestado.fecha_entregado >= oDateinicio) && (oestado.fecha_entregado <= oDatefin))
                                {
                                    List <ordenservicio> Lidservidcios = new List <ordenservicio>();
                                    Lidservidcios = bus.buscarlistaid(OrdenActual.id_orden);
                                    List <servicio> Lservicio = bus.ObtenerServicios(Lidservidcios);
                                    foreach (ordenservicio ordenservi in Lidservidcios)
                                    {
                                        servicio oservicio = Lservicio.Find(x => x.id_servicios == ordenservi.id_servicio);
                                        int      cantidad  = ordenservi.cantidad ?? default(int);
                                        string   total     = (double.Parse(oservicio.precio) * Convert.ToDouble(cantidad)).ToString();
                                        preciototal = preciototal + int.Parse(total);
                                    }
                                    string   fecha = oestado.fecha_entregado.ToString();
                                    string[] fechasinhora;
                                    fechasinhora = fecha.Split(' ');


                                    dt.Rows.Add(OrdenActual.id_orden, fechasinhora[0], preciototal);

                                    controlprecio = preciototal;
                                }
                            }
                            //aqui
                            if (dt.Rows.Count != 0)
                            {
                                doc.Add(p);
                                Paragraph Dato = new Paragraph();
                                Dato.Alignment = Element.ALIGN_LEFT;
                                Dato.Add(new Chunk("\npatente: " + o.patente + "   Modelo: " + o.modelo.nombre + "  Marca:  " + o.modelo.marca.nombre, fntDatos));
                                doc.Add(Dato);
                                //Espacio
                                doc.Add(new Chunk("\n", fntHead));
                                //Tabla
                                PdfPTable table = new PdfPTable(dt.Columns.Count);

                                for (int i = 0; i < dt.Columns.Count; i++)
                                {
                                    string   cellText = Server.HtmlDecode(dt.Columns[i].ColumnName);
                                    PdfPCell cell     = new PdfPCell();
                                    cell.Phrase              = new Phrase(cellText, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 10, 1, new BaseColor(System.Drawing.ColorTranslator.FromHtml("#000000"))));
                                    cell.BackgroundColor     = new BaseColor(System.Drawing.ColorTranslator.FromHtml("#C8C8C8"));
                                    cell.HorizontalAlignment = Element.ALIGN_CENTER;
                                    cell.PaddingBottom       = 5;

                                    table.AddCell(cell);
                                }
                                for (int i = 0; i < dt.Rows.Count; i++)
                                {
                                    for (int j = 0; j < dt.Columns.Count; j++)
                                    {
                                        table.AddCell(dt.Rows[i][j].ToString());
                                    }
                                }
                                table.HorizontalAlignment = Element.ALIGN_CENTER;

                                doc.Add(table);


                                //Espacio
                                doc.Add(new Chunk("\n", fntHead));
                            }
                        }



                        doc.Close();
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "OpenWindow", "window.open('Taller.pdf','_newtab');", true);
                    }
                }
            }
        }
Example #6
0
        public void PDFESTADOCERO()
        {
            Buscadores bus       = new Buscadores();
            vehiculo   ovehiculo = bus.buscarvehiculo(txtpatente.Value);
            cliente    ocliente  = bus.ocliente(ovehiculo);
            modelo     omarca    = bus.buscarmodelo(ovehiculo);
            marca      omodelo   = bus.buscarmarca(omarca);

            iTextSharp.text.Rectangle rec = new iTextSharp.text.Rectangle(PageSize.A4);
            var doc = new iTextSharp.text.Document(rec);

            rec.BackgroundColor = new BaseColor(System.Drawing.Color.Olive);
            doc.SetPageSize(iTextSharp.text.PageSize.A4);
            string path = Server.MapPath("~");

            PdfWriter.GetInstance(doc, new FileStream(path + "/Presupuesto.pdf", FileMode.Create));
            doc.Open();
            //Cabecera
            BaseFont bfntHead = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);

            iTextSharp.text.Font fntHead    = new iTextSharp.text.Font(bfntHead, 16, 1, iTextSharp.text.BaseColor.GREEN.Darker());
            Paragraph            prgHeading = new Paragraph();

            prgHeading.Alignment = Element.ALIGN_LEFT;
            prgHeading.Add(new Chunk("Taller de Reparaciones - Presupuesto".ToUpper(), fntHead));
            doc.Add(prgHeading);
            //Generado By
            Paragraph prgGeneratedBY = new Paragraph();
            BaseFont  btnAuthor      = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);

            iTextSharp.text.Font fntAuthor = new iTextSharp.text.Font(btnAuthor, 8, 2, iTextSharp.text.BaseColor.BLACK);
            prgGeneratedBY.Alignment = Element.ALIGN_RIGHT;
            prgGeneratedBY.Add(new Chunk("Generado por: " + LogEmpleado.nombreyapellido, fntAuthor));  //Agregar LOG Empleado
            prgGeneratedBY.Add(new Chunk("\nFecha Generado valido por 5 dias : " + DateTime.Now.ToShortDateString(), fntAuthor));
            prgGeneratedBY.Add(new Chunk("\nN° de Orden : " + OrdenActual.id_orden, fntAuthor));
            doc.Add(prgGeneratedBY);
            //La f Linea
            Paragraph p = new Paragraph(new Chunk(new iTextSharp.text.pdf.draw.LineSeparator(0.0F, 100.0F, iTextSharp.text.BaseColor.BLACK, Element.ALIGN_LEFT, 1)));

            doc.Add(p);
            //Espacio
            doc.Add(new Chunk("\n", fntHead));
            //Datos
            Paragraph Datos     = new Paragraph();
            BaseFont  bfntDatos = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);

            iTextSharp.text.Font fntDatos = new iTextSharp.text.Font(bfntDatos, 12, 0, iTextSharp.text.BaseColor.BLACK);
            Datos.Alignment = Element.ALIGN_CENTER;
            Datos.Add(new Chunk("Apellido y Nombre: " + ocliente.nombre + "   DNI: " + ocliente.dni + "   Telefono: " + ocliente.telefono + "\nCorreo Electronico: " + ocliente.email, fntDatos));

            Datos.Add(new Chunk("\nPatente: " + ovehiculo.patente + "   Modelo:" + omodelo.nombre + "  Marca:  " + omarca.nombre, fntDatos));
            doc.Add(Datos);
            //Espacio
            doc.Add(new Chunk("\n", fntHead));
            //Tabla
            PdfPTable table = new PdfPTable(dtable.Columns.Count);

            for (int i = 0; i < dtable.Columns.Count; i++)
            {
                string   cellText = Server.HtmlDecode(dtable.Columns[i].ColumnName);
                PdfPCell cell     = new PdfPCell();
                cell.Phrase              = new Phrase(cellText, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 10, 1, new BaseColor(System.Drawing.ColorTranslator.FromHtml("#000000"))));
                cell.BackgroundColor     = new BaseColor(System.Drawing.ColorTranslator.FromHtml("#C8C8C8"));
                cell.HorizontalAlignment = Element.ALIGN_CENTER;
                cell.PaddingBottom       = 5;
                table.AddCell(cell);
            }
            //Agregando Campos a la tabla
            for (int i = 0; i < dtable.Rows.Count; i++)
            {
                for (int j = 0; j < dtable.Columns.Count; j++)
                {
                    table.AddCell(dtable.Rows[i][j].ToString());
                }
            }
            doc.Add(table);
            //Espacio
            doc.Add(new Chunk("\n", fntHead));
            //Datos2.0
            Paragraph Datos2 = new Paragraph();

            Datos2.Alignment = Element.ALIGN_RIGHT;
            Datos2.Add(new Chunk("\nPrecio Total=  $" + lblprecio.Text, fntDatos));
            doc.Add(Datos2);
            Paragraph Datos3 = new Paragraph();

            Datos3.Alignment = Element.ALIGN_CENTER;
            iTextSharp.text.Font fntDatos3 = new iTextSharp.text.Font(bfntDatos, 12, 1, iTextSharp.text.BaseColor.BLACK);
            Datos3.Add(new Chunk("\nPresupuesto NO VALIDO como Factura", fntDatos3));
            doc.Add(Datos3);

            doc.Close();
            Page.ClientScript.RegisterStartupScript(this.GetType(), "OpenWindow", "window.open('Presupuesto.pdf','_newtab');", true);
        }
Example #7
0
        //public void PDFESTADOCERO() {

        //    iTextSharp.text.Rectangle rec = new iTextSharp.text.Rectangle(PageSize.A4);
        //    var doc = new iTextSharp.text.Document(rec);
        //    string url = "@//";

        //    rec.BackgroundColor = new BaseColor(System.Drawing.Color.Olive);
        //    doc.SetPageSize(iTextSharp.text.PageSize.A4);
        //    string path = Server.MapPath("~");
        //    PdfWriter.GetInstance(doc, new FileStream(path + "/Factura.pdf", FileMode.Create));
        //    doc.Open();
        //    iTextSharp.text.Image Factura = iTextSharp.text.Image.GetInstance("C:/Users/niko_/documents/visual studio 2013/Projects/AplicandoAplicada/AplicandoAplicada/Resources/Factura.jpg");
        //    Factura.BorderWidth = 0;
        //    Factura.Alignment = Element.ALIGN_RIGHT;
        //    float percentage = 0.0f;
        //    percentage = 150 / Factura.Width;
        //    Factura.ScalePercent(percentage * 100);
        //    doc.Add(Factura);

        //    // Cerramos el documento
        //    doc.Close();

        //    Page.ClientScript.RegisterStartupScript(this.GetType(), "OpenWindow", "window.open('Factura.pdf','_newtab');", true);

        //}

        public void PDFESTADOCERO()
        {
            Buscadores bus    = new Buscadores();
            var        doc    = new iTextSharp.text.Document(PageSize.A4);
            string     path   = Server.MapPath("~");
            PdfWriter  writer = PdfWriter.GetInstance(doc, new FileStream(path + "/Factura.pdf", FileMode.Create));


            vehiculo ovehiculo = bus.buscarvehiculoid(Ordenn.id_vehiculo ?? default(int));
            cliente  ocliente  = bus.ocliente(ovehiculo);
            modelo   omodelo   = bus.buscarmodelo(ovehiculo);
            marca    omarca    = bus.buscarmarca(omodelo);

            doc.Open();

            //Cabecera
            BaseFont bfntHead = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);

            iTextSharp.text.Font fntHead    = new iTextSharp.text.Font(bfntHead, 16, 1, iTextSharp.text.BaseColor.GREEN.Darker());
            Paragraph            prgHeading = new Paragraph();

            prgHeading.Alignment = 1;
            prgHeading.Add(new Chunk("Factura".ToUpper(), fntHead));
            doc.Add(prgHeading);
            doc.Add(Chunk.NEWLINE);

            //Generado By
            Paragraph prgGeneratedBY = new Paragraph();
            BaseFont  btnAuthor      = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);

            iTextSharp.text.Font fntAuthor = new iTextSharp.text.Font(btnAuthor, 12, 2, iTextSharp.text.BaseColor.BLACK);
            prgGeneratedBY.Alignment = Element.ALIGN_RIGHT;
            prgGeneratedBY.Add(new Chunk("Generado por: " + LogEmpleado.nombreyapellido, fntAuthor));  //Agregar LOG Empleado
            prgGeneratedBY.Add(new Chunk("\nFecha : " + DateTime.Now.ToShortDateString(), fntAuthor));
            prgGeneratedBY.Add(new Chunk("\nN° de Orden : " + Ordenn.id_orden, fntAuthor));
            doc.Add(prgGeneratedBY);
            doc.Add(Chunk.NEWLINE);

            doc.Add(Chunk.NEWLINE);

            //tablados
            PdfPTable tabla2 = new PdfPTable(2);

            tabla2.WidthPercentage = 100;
            tabla2.SpacingAfter    = 20;

            PdfPCell vehiculoTitulo = new PdfPCell(new Phrase("Vehiculo"));

            vehiculoTitulo.BorderWidth         = 0;
            vehiculoTitulo.BorderWidthRight    = 0.75f;
            vehiculoTitulo.BorderWidthTop      = 0.75f;
            vehiculoTitulo.BorderWidthLeft     = 0.75f;
            vehiculoTitulo.HorizontalAlignment = Element.ALIGN_CENTER;
            vehiculoTitulo.BackgroundColor     = new BaseColor(System.Drawing.ColorTranslator.FromHtml("#C8C8C8"));

            PdfPCell clienteTitulo = new PdfPCell(new Phrase("Cliente"));

            clienteTitulo.BorderWidth         = 0;
            clienteTitulo.BorderWidthTop      = 0.75f;
            clienteTitulo.BorderWidthRight    = 0.75f;
            clienteTitulo.HorizontalAlignment = Element.ALIGN_CENTER;
            clienteTitulo.BackgroundColor     = new BaseColor(System.Drawing.ColorTranslator.FromHtml("#C8C8C8"));



            PdfPCell patente = new PdfPCell(new Phrase("Patente: " + ovehiculo.patente));

            patente.BorderWidth       = 0;
            patente.BorderWidthRight  = 0.75f;
            patente.BorderWidthBottom = 0.75f;
            patente.BorderWidthLeft   = 0.75f;
            patente.BackgroundColor   = new BaseColor(System.Drawing.ColorTranslator.FromHtml("#C8C8C8"));

            PdfPCell marca = new PdfPCell(new Phrase("Marca: " + omarca.nombre));

            marca.BorderWidth      = 0;
            marca.BorderWidthRight = 0.75f;
            marca.BorderWidthLeft  = 0.75f;
            marca.BackgroundColor  = new BaseColor(System.Drawing.ColorTranslator.FromHtml("#C8C8C8"));

            PdfPCell modelo = new PdfPCell(new Phrase("Modelo: " + omodelo.nombre));

            modelo.BorderWidth      = 0;
            modelo.BorderWidthRight = 0.75f;
            modelo.BorderWidthLeft  = 0.75f;
            modelo.BackgroundColor  = new BaseColor(System.Drawing.ColorTranslator.FromHtml("#C8C8C8"));

            PdfPCell nombre = new PdfPCell(new Phrase("Apellido y Nombre: " + ocliente.nombre));

            nombre.BorderWidth       = 0;
            nombre.BorderWidthLeft   = 0.75f;
            nombre.BorderWidthBottom = 0.75f;
            nombre.BorderWidthRight  = 0.75f;
            nombre.BackgroundColor   = new BaseColor(System.Drawing.ColorTranslator.FromHtml("#C8C8C8"));

            PdfPCell dni = new PdfPCell(new Phrase("DNI: " + ocliente.dni));

            dni.BorderWidth       = 0;
            dni.BorderWidthBottom = 0.75f;
            dni.BorderWidthRight  = 0.75f;
            dni.BackgroundColor   = new BaseColor(System.Drawing.ColorTranslator.FromHtml("#C8C8C8"));

            tabla2.AddCell(vehiculoTitulo);
            tabla2.AddCell(clienteTitulo);

            tabla2.AddCell(marca);
            tabla2.AddCell(modelo);
            tabla2.AddCell(nombre);
            tabla2.AddCell(patente);
            tabla2.AddCell(dni);

            doc.Add(tabla2);
            dt.Rows.Add("", "", "Total", lblprecio.Text);
            PdfPTable table = new PdfPTable(dt.Columns.Count);

            for (int i = 0; i < dt.Columns.Count; i++)
            {
                string   cellText = Server.HtmlDecode(dt.Columns[i].ColumnName);
                PdfPCell cell     = new PdfPCell();
                cell.Phrase              = new Phrase(cellText, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 10, 1, new BaseColor(System.Drawing.ColorTranslator.FromHtml("#000000"))));
                cell.BackgroundColor     = new BaseColor(System.Drawing.ColorTranslator.FromHtml("#C8C8C8"));
                cell.HorizontalAlignment = Element.ALIGN_CENTER;
                cell.VerticalAlignment   = Element.ALIGN_CENTER;
                cell.PaddingBottom       = 5;

                table.AddCell(cell);
            }
            //Agregando Campos a la tabla
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                for (int j = 0; j < dt.Columns.Count; j++)
                {
                    PdfPCell cell = new PdfPCell();
                    cell.Phrase = new Phrase(dt.Rows[i][j].ToString(), new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 10, 0, new BaseColor(System.Drawing.ColorTranslator.FromHtml("#000000"))));

                    if (j == 1)
                    {
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                    }
                    else
                    {
                        cell.HorizontalAlignment = Element.ALIGN_CENTER;
                    }
                    if (dt.Rows[i][j].ToString() == "Total")
                    {
                        cell.Phrase = new Phrase(dt.Rows[i][j].ToString(), new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 10, 1, new BaseColor(System.Drawing.ColorTranslator.FromHtml("#000000"))));
                    }
                    table.AddCell(cell);
                }
            }
            table.SetWidths(new float[] { 2, 8, 1, 1 });
            doc.Add(table);
            //Espacio


            doc.Close();
            Page.ClientScript.RegisterStartupScript(this.GetType(), "OpenWindow", "window.open('Factura.pdf','_newtab');", true);
            //Response.Redirect("Presupuesto.pdf");
        }
Example #8
0
        public void PDFESTADOCERO()
        {
            Buscadores bus    = new Buscadores();
            var        doc    = new iTextSharp.text.Document(PageSize.A4);
            string     path   = Server.MapPath("~");
            PdfWriter  writer = PdfWriter.GetInstance(doc, new FileStream(path + "/Conformidad.pdf", FileMode.Create));


            vehiculo ovehiculo = bus.buscarvehiculo(lblPatente.Text);
            cliente  ocliente  = bus.ocliente(ovehiculo);
            modelo   omarca    = bus.buscarmodelo(ovehiculo);
            marca    omodelo   = bus.buscarmarca(omarca);

            doc.Open();

            //Cabecera
            BaseFont bfntHead = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);

            iTextSharp.text.Font fntHead    = new iTextSharp.text.Font(bfntHead, 16, 1, iTextSharp.text.BaseColor.GREEN.Darker());
            Paragraph            prgHeading = new Paragraph();

            prgHeading.Alignment = 1;
            prgHeading.Add(new Chunk("Contrato de Conformidad".ToUpper(), fntHead));
            doc.Add(prgHeading);
            doc.Add(Chunk.NEWLINE);

            //Generado By
            Paragraph prgGeneratedBY = new Paragraph();
            BaseFont  btnAuthor      = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);

            iTextSharp.text.Font fntAuthor = new iTextSharp.text.Font(btnAuthor, 12, 2, iTextSharp.text.BaseColor.BLACK);
            prgGeneratedBY.Alignment = Element.ALIGN_RIGHT;
            prgGeneratedBY.Add(new Chunk("Generado por: " + LogEmpleado.nombreyapellido, fntAuthor));  //Agregar LOG Empleado
            prgGeneratedBY.Add(new Chunk("\nFecha : " + DateTime.Now.ToShortDateString(), fntAuthor));
            prgGeneratedBY.Add(new Chunk("\nN° de Orden : " + Ordenn.id_orden, fntAuthor));
            doc.Add(prgGeneratedBY);


            Paragraph l = new Paragraph(new Chunk(new iTextSharp.text.pdf.draw.LineSeparator(0.0F, 100.0F, iTextSharp.text.BaseColor.BLACK, Element.ALIGN_LEFT, 1)));

            doc.Add(l);
            doc.Add(Chunk.NEWLINE);

            Paragraph Cliente1 = new Paragraph("Apellido y Nombre: " + ocliente.nombre);

            doc.Add(Cliente1);

            Paragraph Cliente2 = new Paragraph("DNI: " + ocliente.dni);

            doc.Add(Cliente2);

            Paragraph Cliente3 = new Paragraph("Telefono: " + ocliente.telefono);

            doc.Add(Cliente3);

            Paragraph Cliente4 = new Paragraph("Correo Electronico: " + ocliente.email);

            doc.Add(Cliente4);
            doc.Add(Chunk.NEWLINE);



            Paragraph Vehiculo1 = new Paragraph("Patente: " + ovehiculo.patente);

            doc.Add(Vehiculo1);

            Paragraph Vehiculo2 = new Paragraph("Marca: " + omodelo.nombre);

            doc.Add(Vehiculo2);

            Paragraph Vehiculo3 = new Paragraph("Modelo: " + omarca.nombre);

            doc.Add(Vehiculo3);
            doc.Add(Chunk.NEWLINE);
            doc.Add(Chunk.NEWLINE);

            Paragraph e = new Paragraph("Estimado cliente:");

            e.Font.Size = 18;
            doc.Add(e);
            doc.Add(Chunk.NEWLINE);

            Paragraph cu = new Paragraph("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer vitae venenatis sem. Integer non tellus et elit fermentum scelerisque mollis a tellus. Nam pellentesque viverra dui id tincidunt. Mauris ipsum purus, dignissim vel blandit vel, ornare at purus. In pharetra non tellus non faucibus. Nulla ut purus et quam condimentum eleifend. Maecenas faucibus odio sit amet interdum viverra. Donec congue metus eu nunc ultrices, a ornare ex pulvinar. Morbi sit amet odio molestie, volutpat enim quis, varius ipsum. Morbi mattis ante sit amet justo dictum consectetur. Maecenas convallis dui in erat interdum congue. Phasellus semper eu libero eu ullamcorper.Curabitur dapibus ex sit amet arcu sodales lobortis.Duis lacinia faucibus erat quis condimentum.Nam facilisis eu mauris et congue.Fusce iaculis erat quis neque ornare condimentum.Ut id mi ut tellus luctus consectetur ac a odio.Mauris imperdiet vulputate urna vel elementum.Mauris vulputate purus et metus lobortis tincidunt.Donec sem purus, egestas at ultrices vel, ultrices facilisis enim.Vivamus eget maximus mauris.Donec tincidunt turpis a felis venenatis aliquam.");

            cu.Alignment = Element.ALIGN_JUSTIFIED;
            doc.Add(cu);
            doc.Add(Chunk.NEWLINE);
            doc.Add(Chunk.NEWLINE);
            doc.Add(Chunk.NEWLINE);


            Paragraph ff = new Paragraph("________");

            ff.Alignment = 1;
            doc.Add(ff);

            Paragraph fff = new Paragraph("(FIRMA)");

            fff.Alignment = 1;
            doc.Add(fff);
            doc.Add(Chunk.NEWLINE);


            doc.Close();
            Page.ClientScript.RegisterStartupScript(this.GetType(), "OpenWindow", "window.open('Conformidad.pdf','_newtab');", true);
            //Response.Redirect("Presupuesto.pdf");
        }