示例#1
0
        protected void voucherPDF(List <vendacliente> pVendaCliente)
        {
            var document      = new PdfDocument();
            var page          = document.AddPage();
            var graphics      = PdfSharp.Drawing.XGraphics.FromPdfPage(page);
            var textFormatter = new PdfSharp.Drawing.Layout.XTextFormatter(graphics);
            var font          = new PdfSharp.Drawing.XFont("Calibri", 12);
            var fontColuna    = new PdfSharp.Drawing.XFont("Calibri", 14);


            int y = 55;

            textFormatter.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Left;
            textFormatter.DrawString("Voucher ", font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(30, y, page.Width - 60, page.Height - 60));
            textFormatter.DrawString("Destino: " + ddlViagem.SelectedItem.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(200, y, page.Width - 60, page.Height - 60));

            y = y + 40;
            textFormatter.DrawString("Cliente", fontColuna, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(30, y, page.Width - 60, page.Height - 60));
            textFormatter.DrawString("Faixa Etaria", fontColuna, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(200, y, page.Width - 60, page.Height - 60));
            textFormatter.DrawString("Assento", fontColuna, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(300, y, page.Width - 60, page.Height - 60));
            textFormatter.DrawString("Valor Pago", fontColuna, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(370, y, page.Width - 60, page.Height - 60));
            y = y + 5;
            decimal ValorTotal = 0;

            foreach (var item in pVendaCliente)
            {
                ValorTotal += item.VendaValorPago;
                y           = y + 30;
                textFormatter.DrawString(SvcCliente.BuscarCliente(item.VendaIdCliente).Nome, font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(30, y, page.Width - 60, page.Height - 60));
                textFormatter.DrawString(item.FaixaEtaria, font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(200, y, page.Width - 60, page.Height - 60));
                textFormatter.DrawString(item.Assento.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(300, y, page.Width - 60, page.Height - 60));
                textFormatter.DrawString(item.VendaValorPago.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(370, y, page.Width - 60, page.Height - 60));
            }
            textFormatter.DrawString("Valor Total: " + ValorTotal.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(100, 50 + y, page.Width - 60, page.Height - 60));
            textFormatter.DrawString("Autorizado por: ____________________________________ ", font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(100, 100 + y, page.Width - 60, page.Height - 60));

            PdfSharp.Drawing.XRect  layoutRectangle = new PdfSharp.Drawing.XRect(0 /*X*/, page.Height - font.Height /*Y*/, page.Width /*Width*/, font.Height /*Height*/);
            PdfSharp.Drawing.XBrush brush           = PdfSharp.Drawing.XBrushes.Black;
            string noPages = document.Pages.Count.ToString();

            for (int i = 0; i < document.Pages.Count; ++i)
            {
                graphics.DrawString(
                    "Page " + (i + 1).ToString() + " of " + noPages,
                    font,
                    brush,
                    layoutRectangle,
                    PdfSharp.Drawing.XStringFormats.Center);

                graphics.DrawString(
                    "Data: " + DateTime.Now,
                    font,
                    brush,
                    layoutRectangle,
                    PdfSharp.Drawing.XStringFormats.TopLeft);
            }

            document.Save("Vendas.pdf");
            System.Diagnostics.Process.Start("chrome.exe", "Vendas.pdf");
        }
示例#2
0
 protected void grpListaDeVenda_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
         int     VendaIdCliente = Convert.ToInt32(e.Row.Cells[1].Text);
         cliente cliente        = new cliente();
         cliente             = SvcCliente.BuscarCliente(VendaIdCliente);
         e.Row.Cells[1].Text = cliente.Nome;
     }
 }
示例#3
0
        protected void MontarCadastro(int id)
        {
            _cliente = SvcCliente.BuscarCliente(id);
            if (_cliente == null)
            {
                return;//subtituir depois por menssagem
            }
            txtNome.Text           = _cliente.Nome;
            txtTelefone.Text       = Comun.FormatarTelefone(_cliente.Telefone);
            txtCpf.Text            = Comun.FormatarCpfCnpj(_cliente.Cpf);
            txtDataNascimento.Text = _cliente.DataNascimento.ToString("yyyy-MM-dd");
            txtEmail.Text          = _cliente.Email;
            limpar.Visible         = false;

            var enderecoPessoal = _cliente.endereco.Where(x => x.Origem == 0).FirstOrDefault();

            if (enderecoPessoal != null)
            {
                txtEstado.Value = enderecoPessoal.Estado;
                txtCidade.Text  = enderecoPessoal.Cidade;
                txtBairro.Text  = enderecoPessoal.Bairro;
                txtRua.Text     = enderecoPessoal.Rua;
                txtNumero.Text  = enderecoPessoal.Numero;
            }

            var enderecoComercial = _cliente.endereco.Where(x => x.Origem == 1).FirstOrDefault();

            if (enderecoComercial == null)
            {
                return;
            }
            txtEstadoC.Value = enderecoComercial.Estado;
            txtCidadeC.Text  = enderecoComercial.Cidade;
            txtBairroC.Text  = enderecoComercial.Bairro;
            txtRuaC.Text     = enderecoComercial.Rua;
            txtNumeroC.Text  = enderecoComercial.Numero;
        }
示例#4
0
        protected void GerarPDF_Click(object sender, EventArgs e)
        {
            vendacliente vendaCliente = new vendacliente();

            vendaCliente.VendaIdCliente = Convert.ToInt32(ddlNome.SelectedValue);
            vendaCliente.VendaIdViagem  = Convert.ToInt32(ddlViagem.SelectedValue);

            var vendaEncontrada = SvcVendaCliente.Pesquisa(vendaCliente);

            var document      = new PdfDocument();
            var page          = document.AddPage();
            var graphics      = XGraphics.FromPdfPage(page);
            var textFormatter = new PdfSharp.Drawing.Layout.XTextFormatter(graphics);
            var font          = new XFont("Calibri", 12);
            var fontColuna    = new XFont("Calibri", 14);

            int y = 55;

            textFormatter.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Left;
            textFormatter.DrawString("Destino: " + ddlViagem.SelectedItem.ToString(), font, XBrushes.Black, new XRect(30, y, page.Width - 60, page.Height - 60));
            textFormatter.DrawString("Cliente: " + ddlNome.SelectedItem.ToString(), font, XBrushes.Black, new XRect(200, y, page.Width - 60, page.Height - 60));
            y = y + 40;
            textFormatter.DrawString("Cliente", fontColuna, XBrushes.Black, new XRect(30, y, page.Width - 60, page.Height - 60));
            textFormatter.DrawString("Faixa Etaria", fontColuna, XBrushes.Black, new XRect(200, y, page.Width - 60, page.Height - 60));
            textFormatter.DrawString("Assento", fontColuna, XBrushes.Black, new XRect(300, y, page.Width - 60, page.Height - 60));
            textFormatter.DrawString("Valor Pago", fontColuna, XBrushes.Black, new XRect(370, y, page.Width - 60, page.Height - 60));
            y = y + 5;
            decimal ValorTotal      = 0;
            XRect   layoutRectangle = new XRect(0 /*X*/, page.Height - font.Height /*Y*/, page.Width /*Width*/, font.Height /*Height*/);
            XBrush  brush           = XBrushes.Black;
            string  noPages;
            int     i = 0;

            foreach (var item in vendaEncontrada)
            {
                if (y >= 760)
                {
                    page          = document.AddPage();
                    graphics      = XGraphics.FromPdfPage(page);
                    textFormatter = new PdfSharp.Drawing.Layout.XTextFormatter(graphics);
                    y             = 45;
                }
                ValorTotal += item.VendaValorPago;
                y           = y + 30;
                textFormatter.DrawString(SvcCliente.BuscarCliente(item.VendaIdCliente).Nome, font, XBrushes.Black, new XRect(30, y, page.Width - 60, page.Height - 60));
                textFormatter.DrawString(item.FaixaEtaria, font, XBrushes.Black, new XRect(200, y, page.Width - 60, page.Height - 60));
                textFormatter.DrawString(item.Assento.ToString(), font, XBrushes.Black, new XRect(300, y, page.Width - 60, page.Height - 60));
                textFormatter.DrawString(item.VendaValorPago.ToString(), font, XBrushes.Black, new XRect(370, y, page.Width - 60, page.Height - 60));
            }
            textFormatter.DrawString("Valor Total: " + ValorTotal.ToString(), font, XBrushes.Black, new XRect(100, 50 + y, page.Width - 60, page.Height - 60));
            document.Save("Vendas.pdf");

            PdfDocument pdfDocument = PdfReader.Open("Vendas.pdf", PdfDocumentOpenMode.Modify);

            noPages = pdfDocument.Pages.Count.ToString();
            for (i = 0; i < pdfDocument.Pages.Count; ++i)
            {
                PdfPage page1 = pdfDocument.Pages[i];
                using (XGraphics gfx = XGraphics.FromPdfPage(page1))
                {
                    gfx.DrawString(
                        "Page " + (i + 1).ToString() + " of " + noPages,
                        font,
                        brush,
                        layoutRectangle,
                        XStringFormats.Center);

                    gfx.DrawString(
                        "Data: " + DateTime.Now,
                        font,
                        brush,
                        layoutRectangle,
                        XStringFormats.TopLeft);
                }
            }
            pdfDocument.Save("Vendas.pdf");
            System.Diagnostics.Process.Start("chrome.exe", "Vendas.pdf");
        }