protected void CarregaListaTransicao() { vendacliente vendaCliente = new vendacliente(); vendaCliente.VendaIdCliente = Convert.ToInt32(ddlNome.SelectedValue); vendaCliente.VendaIdViagem = Convert.ToInt32(ddlViagem.SelectedValue); grpListaDeVenda.DataSource = SvcVendaCliente.Pesquisa(vendaCliente); grpListaDeVenda.DataBind(); CarregarValorTotal(); uppGridView.Update(); }
protected void btnBuscarVenda_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); lblNUmeroRegistro(vendaEncontrada); grpListaDeVenda.DataSource = vendaEncontrada; grpListaDeVenda.DataBind(); CarregarValorTotal(); uppGridView.Update(); }
protected void CarregarValorTotal() { vendacliente vendaCliente = new vendacliente(); vendaCliente.VendaIdCliente = Convert.ToInt32(ddlNome.SelectedValue); vendaCliente.VendaIdViagem = Convert.ToInt32(ddlViagem.SelectedValue); var vendaEncontrada = SvcVendaCliente.Pesquisa(vendaCliente); decimal ValorTotal = 0; foreach (var item in vendaEncontrada) { ValorTotal += item.VendaValorPago; } valorTotal.Text = ValorTotal.ToString(); }
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"); }