ViraFrangos Posted June 10, 2013 at 04:27 PM Report #511874 Posted June 10, 2013 at 04:27 PM boa tarde, tive aqui a ver 1's topicos sobre o mesmo assunto, topicos do bio, que ajudaram bastante, só que o meu é um pouco diferente, vou tentar explicar, eu faço a venda de um produto, tenho la tudo dados quem compra, etc, desse genero tudo dentro de texts box, vou criar 1 botao de imprimir, agora é, segundo o topico do bio, ele ia buscar os dados a uma data grid , do tipo "Empresa = DataGridView1.CurrentRow.Cells(1).Value" , agora eu preciso é que ele praticamente assuma o que esta dentro das text, será só Cliente = ClienteTextBox.Text? Cumprimentos.
legd1991 Posted June 10, 2013 at 10:46 PM Report #511923 Posted June 10, 2013 at 10:46 PM Sim basicamente é isso
ViraFrangos Posted June 11, 2013 at 05:53 PM Author Report #512105 Posted June 11, 2013 at 05:53 PM boa tarde, tive a tentar fazer diante das minhas necessidades, entretanto ele nao me faz nada, e devia, vou deixar aqui o cod qe tenho para confirmem o qe estou a fazer de errado. cumprimentos. http://img835.imageshack.us/img835/8237/59832698.png
legd1991 Posted June 11, 2013 at 06:05 PM Report #512106 Posted June 11, 2013 at 06:05 PM Usa as tag para colocares o teu código
ViraFrangos Posted June 11, 2013 at 06:13 PM Author Report #512109 Posted June 11, 2013 at 06:13 PM boa tarde legd, obrigado pelo post, mas podes especificar um pouco mais sff?
legd1991 Posted June 11, 2013 at 06:19 PM Report #512111 Posted June 11, 2013 at 06:19 PM Aqui no forum quando se quer colocar código põe-se entre as tags (code)(/code), trocas os () por []
ViraFrangos Posted June 11, 2013 at 06:27 PM Author Report #512114 Posted June 11, 2013 at 06:27 PM ok, acho que nao conseguiste ver a imagem, vou por o codigo Imports System.Data.OleDb Imports System.Data Imports System.Data.Odbc Imports System.Data.DataTable Imports System.Drawing.Printing Public Class VendaProduto Dim CN As New OleDbConnection() Dim DA As New OleDbDataAdapter() Dim DS As New DataSet() Dim tables As DataTableCollection = DS.Tables Public dr As OleDbDataReader Private Cliente, Contribuinte, Telefone, Produto, Preco, Quantidade, PrecoTotal, TipoPagamento As String Public Sub Factura() Dim imprimir As New PrintDocument Dim visualizar As New PrintPreviewDialog visualizar.Document = imprimir Cliente = ClienteTextBox.Text Contribuinte = ContribuinteTextBox.Text Telefone = TelefoneTextBox.Text Produto = ComboBox1.Text Preco = ComboBox2.Text Quantidade = QuantidadeTextBox.Text PrecoTotal = PrecoTotalTextBox.Text TipoPagamento = ComboBox3.Text AddHandler imprimir.PrintPage, AddressOf imprimir_printpage Clipboard.SetImage(My.Resources.TECHO_SMARTS) End Sub Private Sub imprimir_printpage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) ' Cola o logótipo e.Graphics.DrawImage(Clipboard.GetImage, 150, -100, 550, 500) ' Desenha um rectângulo à volta do documento Dim rect As New Rectangle(0, 300, 900, 800) e.Graphics.DrawRectangle(Pens.Gray, rect) ' 300 = coordenadasX :: 250 = coordenadasY e.Graphics.DrawString("Venda de Produtos", New Font("Comic Sans MS", 20, FontStyle.Bold), Brushes.Black, 300, 250) ' Informações e.Graphics.DrawString("Cliente: ", New Font("Arial", 16, FontStyle.Bold), Brushes.Black, 40, 350) e.Graphics.DrawString(Cliente, New Font("Arial", 15, FontStyle.Regular), Brushes.Black, 175, 351) e.Graphics.DrawString("Contribuinte: ", New Font("Arial", 16, FontStyle.Bold), Brushes.Black, 40, 400) e.Graphics.DrawString(Contribuinte, New Font("Arial", 15, FontStyle.Regular), Brushes.Black, 217, 402) e.Graphics.DrawString("Telefone: ", New Font("Arial", 16, FontStyle.Bold), Brushes.Black, 40, 400) e.Graphics.DrawString(Telefone, New Font("Arial", 15, FontStyle.Regular), Brushes.Black, 217, 402) e.Graphics.DrawString("Produto: ", New Font("Arial", 16, FontStyle.Bold), Brushes.Black, 40, 450) e.Graphics.DrawString(Produto, New Font("Arial", 15, FontStyle.Regular), Brushes.Black, 162, 451) e.Graphics.DrawString("Preco: ", New Font("Arial", 16, FontStyle.Bold), Brushes.Black, 40, 400) e.Graphics.DrawString(Preco, New Font("Arial", 15, FontStyle.Regular), Brushes.Black, 217, 402) e.Graphics.DrawString("Quantidade: ", New Font("Arial", 16, FontStyle.Bold), Brushes.Black, 40, 400) e.Graphics.DrawString(Quantidade, New Font("Arial", 15, FontStyle.Regular), Brushes.Black, 217, 402) e.Graphics.DrawString("PrecoTotal: ", New Font("Arial", 16, FontStyle.Bold), Brushes.Black, 40, 400) e.Graphics.DrawString(PrecoTotal, New Font("Arial", 15, FontStyle.Regular), Brushes.Black, 217, 402) e.Graphics.DrawString("TipoPagamento: ", New Font("Arial", 16, FontStyle.Bold), Brushes.Black, 40, 400) e.Graphics.DrawString(TipoPagamento, New Font("Arial", 15, FontStyle.Regular), Brushes.Black, 217, 402) ' Desenha uma linha na horizontal e.Graphics.DrawLine(Pens.Gray, 40, 525, 500, 525) e.Graphics.DrawLine(Pens.Gray, 40, 525, 500, 525) e.Graphics.DrawString("Techno Smarts", New Font("Comic Sans MS", 20, FontStyle.Bold), Brushes.Black, 300, 250) e.Graphics.DrawLine(Pens.Gray, 40, 525, 500, 525) e.Graphics.DrawLine(Pens.Gray, 40, 525, 500, 525) ' Data do documento e.Graphics.DrawString(Date.Now, New Font("Arial", 16, FontStyle.Bold), Brushes.Black, 525, 1120) End Sub o que está de errado?
legd1991 Posted June 12, 2013 at 08:27 AM Report #512200 Posted June 12, 2013 at 08:27 AM (edited) Tenta assim: public void Print(object _stream) { imprimir = new PrintDocument(); imprimir.PrintPage += new PrintPageEventHandler(imprimir_PrintPage); imprimir.Print(); } Está em C# mas penso que é fácil de perceber Edited June 12, 2013 at 08:30 AM by legd1991
bioshock Posted June 12, 2013 at 08:53 AM Report #512209 Posted June 12, 2013 at 08:53 AM (edited) Nada. Pelo menos não aparenta nada estar errado. Que erro te dá? Edit: Não faças a última linha de código que o user @legd1991 te disse. Utiliza antes: visualizar.ShowDialog() Edit 2: E vê este tópico: http://www.portugal-a-programar.pt/topic/60864-duvida-sobre-impressao-utilizando-o-systemdrawingprinting/#entry512054 Edited June 12, 2013 at 08:56 AM by bioshock
ViraFrangos Posted June 12, 2013 at 09:05 AM Author Report #512215 Posted June 12, 2013 at 09:05 AM bom dia bio, ele nao me da erro, simplesmente quando carrego n0 botao de imprimir ele nao faz nada.
bioshock Posted June 12, 2013 at 09:06 AM Report #512216 Posted June 12, 2013 at 09:06 AM É normal que não faça nada..não estás a dizer, no teu código, para ele te abrir o "processo". Já te dei a solução no meu último post. Coloca o código depois desta tua linha: Clipboard.SetImage(My.Resources.TECHO_SMARTS)
ViraFrangos Posted June 12, 2013 at 09:18 AM Author Report #512223 Posted June 12, 2013 at 09:18 AM Excelente bio, agora sim, ja me faz a preview do documento. e imprime, faltava aquela linha de codigo,muito obrigado . podem fechar. 🙂
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now