private void imprimir_Click(object sender, EventArgs e) { var dataSet = new carrinho(); foreach (DataGridViewRow linha in dgvCarrinho.Rows) { if (!linha.IsNewRow) { var novaLinhaDataSet = dataSet._carrinho.NewcarrinhoRow(); novaLinhaDataSet.quantidade = linha.Cells[1].Value.ToString(); novaLinhaDataSet.descricao = linha.Cells[0].Value.ToString(); decimal vTotal = Convert.ToDecimal(linha.Cells[1].Value.ToString().Replace("R$", "")) * Convert.ToDecimal(linha.Cells[2].Value); novaLinhaDataSet.valorTotal = vTotal; dataSet._carrinho.AddcarrinhoRow(novaLinhaDataSet); } } string end = ""; if (entrega.Text == "ENTREGA") { end = endereco.Text + ", " + numero.Text + "-" + bairro.Text; } impressaoLocal impressaoPedido = new impressaoLocal(txnumeroPedido.Text, nome.Text, end, txtObs.Text, subTotal.Text, taxaEntrega.Text, total.Text, troco.Text, valorTroco.Text, formaPagamento.Text, entrega.Text, dataSet); impressaoPedido.ShowDialog(); }
public impressaoLocal(string numeroPedido, string nome, string endereco, string obs, string subTotal, string taxa, string total, string trocoPara, string trocoCliente, string formaPagamento, string formaEntrega, DataSet dataSet) { InitializeComponent(); carrinho carrinho = new carrinho(); TextInfo myTI = new CultureInfo("pt-BR", false).TextInfo; DateTime dateTime = DateTime.Now; this.reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter("hora", myTI.ToUpper(dateTime.ToString("g")))); this.reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter("numeroPedido", myTI.ToUpper(numeroPedido))); this.reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter("nome", myTI.ToUpper(nome.RemoveDiacritics()))); this.reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter("subTotal", myTI.ToUpper(subTotal))); if (formaEntrega == "ENTREGA:") { this.reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter("endereco", myTI.ToUpper(endereco.RemoveDiacritics()))); this.reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter("taxa", myTI.ToUpper(taxa))); } this.reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter("endereco", myTI.ToUpper(endereco.RemoveDiacritics()))); this.reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter("obs", myTI.ToUpper(obs.RemoveDiacritics()))); this.reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter("taxa", myTI.ToUpper(taxa))); this.reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter("total", myTI.ToUpper(total))); this.reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter("formaPagamento", myTI.ToUpper(formaPagamento))); if (myTI.ToUpper(formaPagamento) != "CARTAO") { this.reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter("trocoPara", myTI.ToUpper(trocoPara))); this.reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter("trocoCliente", myTI.ToUpper(trocoCliente))); } this.reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter("formEntrega", myTI.ToUpper(formaEntrega))); ReportDataSource rdsCarrinho = new ReportDataSource("Carrinho", dataSet.Tables[0]); reportViewer1.LocalReport.DataSources.Add(rdsCarrinho); reportViewer1.LocalReport.Refresh(); reportViewer1.SetDisplayMode(DisplayMode.PrintLayout); var setup = reportViewer1.GetPageSettings(); setup.PaperSize.Height = 500; setup.PaperSize.Width = 370; setup.Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0); reportViewer1.SetPageSettings(setup); this.reportViewer1.RefreshReport(); }