public void Dispose() { if (im != null) { im.Dispose(); im = null; } }
public bool Emitir_Boleto(int iCodigoNF, int iNumero_Parcela) { bool bRetorno = true; try { Funcoes func; string sPorta = func.Busca_Propriedade("Porta_Padrao_Matricial"); if (!string.IsNullOrEmpty(sPorta)) { bRetorno = im.Inicio(sPorta); } else { bRetorno = false; CompSoft.compFrameWork.MsgBox.Show("Porta para impressão matricial não foi definida." , "Erro" , System.Windows.Forms.MessageBoxButtons.OK , System.Windows.Forms.MessageBoxIcon.Stop); } } catch { bRetorno = false; CompSoft.compFrameWork.MsgBox.Show("Não foi possivel abrir a porta LPT1 para impressão" , "Erro" , System.Windows.Forms.MessageBoxButtons.OK , System.Windows.Forms.MessageBoxIcon.Stop); } if (bRetorno) { im.Imp(im.Comprimido); //-- Busca dados da nota fiscal. DataRow row_Capa = this.Dados_CapaNF(iCodigoNF); DataTable dt_Vencimento = this.Dados_VencimentosNF(iCodigoNF); DataRow row_Venc = null; foreach (DataRow row in dt_Vencimento.Select("Numero_Parcela = " + iNumero_Parcela.ToString())) { row_Venc = row; //-- Imprimi a boleto em formulário continuo. this.Gerar_Dados_Boletos(ref row_Capa, ref row_Venc); } //-- Fecha conexão com a porta LPT1 da impressara im.Fim(); im.Dispose(); im = null; } return(bRetorno); }
public bool Imprimir_NF(int iCodigoNF, bool bImprimirNota, bool bMarcarImpresso = false) { bool bRetorno = true; try { Funcoes func; string sPorta = func.Busca_Propriedade("Porta_Padrao_Matricial"); if (!string.IsNullOrEmpty(sPorta)) { bRetorno = im.Inicio(sPorta); } else { bRetorno = false; CompSoft.compFrameWork.MsgBox.Show("Porta para impressão matricial não foi definida." , "Erro" , System.Windows.Forms.MessageBoxButtons.OK , System.Windows.Forms.MessageBoxIcon.Stop); } } catch { bRetorno = false; CompSoft.compFrameWork.MsgBox.Show("Não foi possivel abrir a porta LPT1 para impressão" , "Erro" , System.Windows.Forms.MessageBoxButtons.OK , System.Windows.Forms.MessageBoxIcon.Stop); } //-- Instancia e seta valores para impressão if (bRetorno) { im.Imp(im.Comprimido); //-- Busca dados da nota fiscal. DataRow row_Capa = this.Dados_CapaNF(iCodigoNF); DataTable dt_Vencimento = this.Dados_VencimentosNF(iCodigoNF); DataTable dt_Itens = this.Dados_ItensNF(iCodigoNF); //-- Imprimi nota fiscal. if (bImprimirNota) { //-- Gera header da nota fiscal. this.Gerar_Header(ref row_Capa); //-- Gera os vencimentos da nota fiscal. this.Gerar_Vencimentos(ref row_Capa, ref dt_Vencimento); //-- Gera itens da nota fiscal. this.Gerar_Itens(ref dt_Itens, ref row_Capa); //-- Gera fooder da nota fiscal. this.Gerar_Fooder(ref row_Capa); } else //-- Imprime cupom. { this.Gerar_Header_Cupom(ref row_Capa); this.Gerar_Vencimentos_Cupom(ref dt_Vencimento); this.Gerar_Itens_Cupom(ref dt_Itens); this.Gerar_Fooder_Cupom(ref row_Capa); } //-- Ejeta o papel e prepara para uma nova impressão caso exista. im.Eject(); //-- Fecha conexão com a porta LPT1 da impressara im.Fim(); if (bMarcarImpresso) { //-- Marca registro como impresso. this.Marcar_NF_Impressa(iCodigoNF); } im.Dispose(); im = null; } //-- Retorno. return(bRetorno); }