public Impressao(LeituraX impri) { int qtdLinha = 20+ impri.itens.Count ; //this.printDocument1.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("comanda", 304, qtdLinha); //printDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.printDocument1_PrintPage); sizeLetra = 7; qtdLinha *= 10; qtdLinha += 70; this.printDocument1 = new System.Drawing.Printing.PrintDocument(); gerarLeituraX(impri); }
public void gerarLeituraX(LeituraX leitu) { int qtdLinha = 20 + leitu.itens.Count; linePorFolha = qtdLinha; qtdLinha *= 10; qtdLinha += 70; this.printDocument1.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("comanda", 304, qtdLinha); printDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.printDocument1_PrintPage); try { Reporter mr = new Reporter(); //quem vai colocar em italico e talz EpsonCodes mer = new EpsonCodes(); if (File.Exists(endereco)) File.Delete(endereco); mr.Output = endereco; mr.StartJob(); //-------------------------------------------------------------------------------- string pont = "|-----------------------------------|"; int line = 1; mr.PrintText(line++, 01, "|------------- LEITURA X -----------|"); mr.PrintText(line++, 02, leitu.empresa); //o \n serve como paper feed na impressora... mr.PrintText(line++, 01, pont); mr.PrintText(line, 01, "|Data:" + leitu.dataLeitura); mr.PrintText(line++, 37, "|"); mr.PrintText(line, 01, "|Hora:" + DateTime.Now.ToShortTimeString()); mr.PrintText(line++, 37, "|"); mr.PrintText(line++, 01, pont); //data e hora mr.PrintText(line++, 01, "|HORA -VENDA- PAGAM -VALOR -SITUAC|");//id casa 1 - cod casa 7 - desc - casa 12 - categ casa 32 mr.PrintText(line++, 01, pont); //itens { for (int i = 0; i < leitu.itens.Count; i++) { mr.PrintText(line, 01, "|"); mr.PrintText(line, 02, leitu.itens[i].hora); mr.PrintText(line, 08, "-"); mr.PrintText(line, 09, ""+leitu.itens[i].cod_venda); mr.PrintText(line, 15, "-"); mr.PrintText(line, 16, leitu.itens[i].formaPagamento.Substring(0,5)); mr.PrintText(line, 22, "-"); mr.PrintText(line, 23, new Tratamento().retornaValorEscrito( leitu.itens[i].valor)); mr.PrintText(line, 30,"-"+ leitu.itens[i].situac.Substring(0,6)); mr.PrintText(line++, 37, "|"); } } //itens mr.PrintText(line++, 01, pont); mr.PrintText(line, 01, "|"); mr.PrintText(line, 15, ("TOTAL R$ " + new Tratamento().retornaValorEscrito(leitu.valorTotal))); mr.PrintText(line++, 37, "|"); if (leitu.extorno > 0) { mr.PrintText(line, 01, "|"); mr.PrintText(line, 15, ("EXTORNO RS " + new Tratamento().retornaValorEscrito(leitu.extorno))); mr.PrintText(line++, 37, "|"); } if (leitu.totDinheiro > 0) { mr.PrintText(line, 01, "|"); mr.PrintText(line, 15, ("DINHEIRO RS " + new Tratamento().retornaValorEscrito(leitu.totDinheiro))); mr.PrintText(line++, 37, "|"); } if (leitu.totCredito > 0) { mr.PrintText(line, 01, "|"); mr.PrintText(line, 15, ("CREDITO RS " + new Tratamento().retornaValorEscrito(leitu.totCredito))); mr.PrintText(line++, 37, "|"); } if (leitu.totDebito > 0) { mr.PrintText(line, 01, "|"); mr.PrintText(line, 15, ("DEBITO RS " + new Tratamento().retornaValorEscrito(leitu.totDebito))); mr.PrintText(line++, 37, "|"); } if (leitu.totCheque > 0) { mr.PrintText(line, 01, "|"); mr.PrintText(line, 15, ("CHEQUE RS " + new Tratamento().retornaValorEscrito(leitu.totCheque))); mr.PrintText(line++, 37, "|"); } mr.PrintText(line++, 01, pont); //-------------------------------- mr.PrintText(line, 01, "|"); mr.PrintText(line++, 37, "|"); mr.PrintText(line, 01, "|Data Impresao :" + DateTime.Now.ToShortDateString()); mr.PrintText(line++, 37, "|"); mr.PrintText(line++, 01, "|___________________________________|"); mr.PrintJob(); mr.EndJob(); lerArquivo(0); } catch { } }
private void btLeituraX_Click(object sender, EventArgs e) { string data = cbDiaX.SelectedItem + "/" + (cbMesX.SelectedIndex+1) + "/" + cbAnoX.SelectedItem; DataTable tabela = new BancoRelatorio().consultaLeituraX(data); LeituraX lx = new LeituraX(); lx.dataLeitura = data; for (int i = 0; i < tabela.Rows.Count; i++ ) { lx.addItem( tabela.Rows[i].ItemArray.GetValue(0).ToString(), Convert.ToInt16( tabela.Rows[i].ItemArray.GetValue(1) ), Convert.ToInt16( tabela.Rows[i].ItemArray.GetValue(2) ), Convert.ToDouble( tabela.Rows[i].ItemArray.GetValue(3).ToString().Replace('.',',') ), tabela.Rows[i].ItemArray.GetValue(4).ToString()); } lx.imprimir(); }