示例#1
0
        public List <Facturacion_VentaDTO> ListarFacturaFiltroCliente(string TxtFiltro)
        {
            List <Facturacion_VentaDTO> ListaAuxDTO = new List <Facturacion_VentaDTO>();

            try
            {
                List <Facturacion_Venta> ListaF = R_Factura.ListarFacturaFiltroCliente(TxtFiltro);
                if (ListaF.Count != 0)
                {
                    foreach (Facturacion_Venta Aux in ListaF)
                    {
                        Cliente  AuxCli = R_Cli.BuscarID(Aux.Clienteid);
                        Empleado AuxEmp = R_Emp.BuscarID(Aux.Empleadoid);
                        Pedido   AuxP   = R_Ped.BuscarIDTotal(Aux.Pedidoid);

                        Facturacion_VentaDTO AuxFacDTO = new Facturacion_VentaDTO(Aux.Cod_factura, Aux.Fecha, Aux.Importetotal, AuxCli, AuxEmp, Aux.Metododepago, AuxP, Aux.Tipodefactura);
                        ListaAuxDTO.Add(AuxFacDTO);
                    }
                }
            }
            catch (Exception Ex)
            {
                throw new Exception(Ex.Message);
            }
            return(ListaAuxDTO);
        }
示例#2
0
        public List <Facturacion_VentaDTO> DevolverTodo()
        {
            List <Facturacion_VentaDTO> ListaDTO = new List <Facturacion_VentaDTO>();

            try
            {
                foreach (Facturacion_Venta Aux in R_Factura.DevolverTodo())
                {
                    Cliente  AuxCli = R_Cli.BuscarID(Aux.Clienteid);
                    Empleado AuxEmp = R_Emp.BuscarID(Aux.Empleadoid);
                    Pedido   AuxP   = R_Ped.BuscarIDTotal(Aux.Pedidoid);

                    Facturacion_VentaDTO AuxFacDTO = new Facturacion_VentaDTO(Aux.Cod_factura, Aux.Fecha, Aux.Importetotal, AuxCli, AuxEmp, Aux.Metododepago, AuxP, Aux.Tipodefactura);
                    ListaDTO.Add(AuxFacDTO);
                }
            }
            catch (Exception Ex)
            {
                throw new Exception(Ex.Message);
            }
            return(ListaDTO);
        }
示例#3
0
        public Facturacion_VentaDTO Buscar(int cod, char tipofactura)
        {
            Facturacion_Venta    Fact    = null;
            Facturacion_VentaDTO FactDTO = null;

            try
            {
                Fact = R_Factura.Buscar(cod, tipofactura);
                if (Fact != null)
                {
                    Cliente  AuxCli = R_Cli.BuscarID(Fact.Clienteid);
                    Empleado AuxEmp = R_Emp.BuscarID(Fact.Empleadoid);
                    Pedido   AuxP   = R_Ped.BuscarIDTotal(Fact.Pedidoid);

                    FactDTO = new Facturacion_VentaDTO(Fact.Cod_factura, Fact.Fecha, Fact.Importetotal, AuxCli, AuxEmp, Fact.Metododepago, AuxP, Fact.Tipodefactura);
                }
            }
            catch (Exception Ex)
            {
                throw new Exception(Ex.Message);
            }
            return(FactDTO);
        }
示例#4
0
        public void ExportarPDF(int nro, char tipof)
        {
            AuxFactDTO = ControlFacturacion.Buscar(nro, tipof);
            try
            {
                using (StringWriter sw = new StringWriter())
                {
                    using (HtmlTextWriter hw = new HtmlTextWriter(sw))
                    {
                        GrillaDetalle.AllowPaging = false;
                        GrillaDetalle.Width       = 660;
                        GrillaDetalle.CellSpacing = 3;
                        RefrescarDetalle(nro, tipof);
                        GrillaDetalle.RenderControl(hw);
                        StringReader sr     = new StringReader(sw.ToString());
                        Document     pdfDoc = new Document(PageSize.A4, 50f, 50f, 10f, 0f);
                        PdfWriter    writer = PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
                        pdfDoc.Open();
                        var  FontColour = new BaseColor(126, 151, 173);
                        Font LineBreak  = FontFactory.GetFont("Cambria", size: 10, color: BaseColor.BLACK);
                        Font LineBreak2 = FontFactory.GetFont("Cambria", size: 13, style: Font.BOLD, color: BaseColor.WHITE);
                        Font LineBreak3 = FontFactory.GetFont("Cambria", size: 15, color: FontColour);
                        Font LineBreak4 = FontFactory.GetFont("Cambria", size: 10, color: FontColour);
                        //logo local
                        var dataFilelogo               = Server.MapPath("~/App_Data/pedidotrasp.png");
                        iTextSharp.text.Image img      = iTextSharp.text.Image.GetInstance(dataFilelogo);
                        Paragraph             parrafo2 = new Paragraph(string.Format(""), LineBreak);
                        parrafo2.SpacingBefore = 200;
                        parrafo2.SpacingAfter  = 0;
                        parrafo2.Alignment     = 1;
                        pdfDoc.Add(parrafo2);
                        pdfDoc.Add(Chunk.NEWLINE);
                        img.SetAbsolutePosition(430, 720);
                        img.ScaleToFit(130f, 130F);
                        img.SpacingBefore = 10f;
                        pdfDoc.Add(img);
                        pdfDoc.Add(new Paragraph(string.Format("Dirección: San Martin 7500"), LineBreak));
                        pdfDoc.Add(new Paragraph(string.Format("Tel. 470-0000"), LineBreak));
                        pdfDoc.Add(new Paragraph(string.Format("Email: [email protected]"), LineBreak));
                        pdfDoc.Add(new Paragraph("\n\n", LineBreak));
                        float[]   columnWidths = { 5, 1, 5 };
                        PdfPTable table        = new PdfPTable(columnWidths);
                        PdfPCell  cell1        = new PdfPCell(new Phrase("Factura N.º: " + AuxFactDTO.Cod_factura.ToString("00000000"), LineBreak2));
                        PdfPCell  cell2        = new PdfPCell(new Phrase(AuxFactDTO.Tipodefactura.ToString(), LineBreak2));
                        PdfPCell  cell3        = new PdfPCell(new Phrase(AuxFactDTO.Fecha.ToString("dd/MM/yyyy"), LineBreak2));
                        cell1.BackgroundColor     = new iTextSharp.text.BaseColor(93, 123, 157);
                        cell2.BackgroundColor     = new iTextSharp.text.BaseColor(93, 123, 157);
                        cell3.BackgroundColor     = new iTextSharp.text.BaseColor(93, 123, 157);
                        cell3.HorizontalAlignment = Element.ALIGN_RIGHT;
                        cell2.HorizontalAlignment = Element.ALIGN_CENTER;
                        cell1.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell1.BorderWidth         = 0;
                        cell2.BorderWidth         = 1;
                        cell2.BorderColor         = BaseColor.DARK_GRAY;
                        cell3.BorderWidth         = 0;
                        table.WidthPercentage     = 100;
                        table.AddCell(cell1);
                        table.AddCell(cell2);
                        table.AddCell(cell3);
                        pdfDoc.Add(table);
                        pdfDoc.Add(new Paragraph("\n", LineBreak));
                        Paragraph ph          = new Paragraph(new Phrase("CLIENTE", LineBreak4));
                        PdfPCell  cellcliente = new PdfPCell(ph);
                        cellcliente.Border      = Rectangle.BOTTOM_BORDER;
                        cellcliente.BorderColor = new BaseColor(126, 151, 173);
                        cellcliente.BorderWidth = 0.5f;
                        PdfPTable tablecliente = new PdfPTable(1);
                        tablecliente.AddCell(cellcliente);
                        tablecliente.HorizontalAlignment = Element.ALIGN_LEFT;
                        tablecliente.WidthPercentage     = 100f;
                        pdfDoc.Add(tablecliente);
                        float[]   columnWidths2     = { 6, 5 };
                        PdfPTable tablaDatosCliente = new PdfPTable(columnWidths2);
                        tablaDatosCliente.WidthPercentage = 100f;
                        PdfPCell  cellDatosClienteLeft  = new PdfPCell();
                        PdfPCell  cellDatosClienteRight = new PdfPCell();
                        Paragraph nombrecompleto        = new Paragraph(string.Format("Apellido, Nombre: " + AuxFactDTO.Clienteid.Apellido + " " + AuxFactDTO.Clienteid.Nombre), LineBreak);
                        Paragraph telefono  = new Paragraph(string.Format("Telefono: " + AuxFactDTO.Clienteid.Telefono), LineBreak);
                        Paragraph direccion = new Paragraph(string.Format("Direccion: " + AuxFactDTO.Clienteid.Direccion), LineBreak);
                        Paragraph email     = new Paragraph(string.Format("Email: " + AuxFactDTO.Clienteid.Email), LineBreak);
                        Paragraph condicion = new Paragraph(string.Format(AuxFactDTO.Clienteid.Tipo), LineBreak);
                        Paragraph metodo    = new Paragraph(string.Format("Metodo de pago: " + AuxFactDTO.Metododepago), LineBreak);
                        Paragraph empleado  = new Paragraph(string.Format("Vendedor: " + AuxFactDTO.Empleadoid.Apellido + " " + AuxFactDTO.Empleadoid.Nombre), LineBreak);

                        cellDatosClienteLeft.HorizontalAlignment = Element.ALIGN_LEFT;
                        cellDatosClienteLeft.AddElement(nombrecompleto);
                        cellDatosClienteLeft.AddElement(telefono);
                        cellDatosClienteLeft.AddElement(direccion);
                        cellDatosClienteLeft.AddElement(email);
                        cellDatosClienteLeft.AddElement(condicion);
                        cellDatosClienteRight.HorizontalAlignment = Element.ALIGN_RIGHT;
                        cellDatosClienteRight.AddElement(metodo);
                        cellDatosClienteRight.AddElement(empleado);
                        cellDatosClienteRight.BorderWidth = 0;
                        cellDatosClienteLeft.BorderWidth  = 0;
                        tablaDatosCliente.AddCell(cellDatosClienteLeft);
                        tablaDatosCliente.AddCell(cellDatosClienteRight);
                        pdfDoc.Add(tablaDatosCliente);
                        pdfDoc.Add(Chunk.NEWLINE);
                        XMLWorkerHelper.GetInstance().ParseXHtml(writer, pdfDoc, sr);
                        pdfDoc.Close();
                        Response.ContentType = "application/pdf";
                        Response.AddHeader("content-disposition", "attachment;filename=pdfFactura.pdf");
                        Response.Cache.SetCacheability(HttpCacheability.NoCache);
                        Response.Write(pdfDoc);
                        Response.End();
                    }
                }
            }
            catch (DocumentException ex)
            {
                throw new DocumentException(ex.Message);
            }
            catch (IOException ex)
            {
                throw new IOException(ex.Message);
            }
        }