using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using MySql.Data.MySqlClient;
using fatd_faturamento.ENTIDADE;
using fatd_faturamento.DAL.Conexao;

namespace fatd_faturamento.DAL.Persistencia
{
    public class dalTempFaturaNF3EB
    {

        string vFILTER = null;
        string vINNERJOIN = null;
        string vAND = null;
        string vORDERBY = null;

        #region Métodos

        public void Insert(entidadeTempFaturaNF3EB objTempFaturaNF3EB)
        {
            MySqlCommand cmd = null;

            IGerenciadorTransacao objGerenciadorTransacao = null;
            ConexaoBD objconexaoBD = null;

            try
            {
                objconexaoBD = new ConexaoBD();

                objconexaoBD.SetarConexaoBanco(TipoBDConexao.fat_BD);

                using (objGerenciadorTransacao = FabricaGerenciadorTransacao.GetGerenciador(TipoBDGerenciador.MySql))
                {

                    vFILTER = vFILTER + "SEGVIA                                                     = ?SEGVIA                 , ";
                    vFILTER = vFILTER + "NOMEMAQUINA                                                = ?NOMEMAQUINA            , ";
                    //DADOS DA FATURA                                                               
                    vFILTER = vFILTER + "NUMNF                                                       = ?NUMNF                  , ";
                    vFILTER = vFILTER + "CFOP                                                        = ?CFOP                   , ";
                    vFILTER = vFILTER + "ZONA                                                        = ?ZONA                   , ";
                    vFILTER = vFILTER + "LIVRO                                                       = ?LIVRO                  , ";
                    vFILTER = vFILTER + "CONTA                                                       = ?CONTA                  , ";
                    vFILTER = vFILTER + "CONS_ID                                                     = ?CONS_ID                , ";
                    vFILTER = vFILTER + "UNID_ID                                                     = ?UNID_ID                , ";
                    vFILTER = vFILTER + "ROTA                                                        = ?ROTA                   , ";
                    vFILTER = vFILTER + "VALORTOT                                                    = ?VALORTOT               , ";
                    vFILTER = vFILTER + "VALORLIQ                                                    = ?VALORLIQ               , ";
                    vFILTER = vFILTER + "CODCLAS                                                     = ?CODCLAS                , ";
                    vFILTER = vFILTER + "DATAVENC                                                    = ?DATAVENC               , ";
                    vFILTER = vFILTER + "BANIDENT                                                    = ?BANIDENT               , ";
                    vFILTER = vFILTER + "BANCO_FATUR                                                 = ?BANCO_FATUR            , ";
                    vFILTER = vFILTER + "MESANO                                                      = ?MESANO                 , ";
                    vFILTER = vFILTER + "ANOMES_FAT                                                  = ?ANOMES_FAT             , ";
                    vFILTER = vFILTER + "MESANOREF                                                   = ?MESANOREF              , ";
                    vFILTER = vFILTER + "DATAAPR                                                     = ?DATAAPR                , ";
                    vFILTER = vFILTER + "DATAEMISSAO                                                 = ?DATAEMISSAO            , ";
                    vFILTER = vFILTER + "DATAPROXLEIT                                                = ?DATAPROXLEIT           , ";
                    vFILTER = vFILTER + "DATALEIT                                                    = ?DATALEIT               , ";
                    vFILTER = vFILTER + "DATALEITANT                                                 = ?DATALEITANT            , ";
                    vFILTER = vFILTER + "FASE                                                        = ?FASE                   , ";
                    vFILTER = vFILTER + "TA                                                          = ?TA                     , ";
                    vFILTER = vFILTER + "TENSAO                                                      = ?TENSAO                 , ";
                    vFILTER = vFILTER + "CODHASH                                                     = ?CODHASH                , ";
                    vFILTER = vFILTER + "CODBARRA                                                    = ?CODBARRA               , ";
                    vFILTER = vFILTER + "DVCODBARRA                                                  = ?DVCODBARRA             , ";
                    vFILTER = vFILTER + "DESCCLASSE                                                  = ?DESCCLASSE             , ";
                    vFILTER = vFILTER + "NUM_MED                                                     = ?NUM_MED                , ";
                    vFILTER = vFILTER + "CONST_MED                                                   = ?CONST_MED              , ";
                    //DADOS DA UNIDADE                                                              
                    vFILTER = vFILTER + "CPF_CNPJ                                                    = ?CPF_CNPJ               , ";
                    vFILTER = vFILTER + "RG_IE                                                       = ?RG_IE                  , ";
                    vFILTER = vFILTER + "CGC                                                         = ?CGC                    , ";
                    vFILTER = vFILTER + "INSC                                                        = ?INSC                   , ";
                    vFILTER = vFILTER + "AGENC                                                       = ?AGENC                  , ";
                    vFILTER = vFILTER + "CC                                                          = ?CC                     , ";
                    vFILTER = vFILTER + "NOMECONS                                                    = ?NOMECONS               , ";
                    vFILTER = vFILTER + "REFCONS                                                     = ?REFCONS                , ";
                    vFILTER = vFILTER + "NOME_CONJUGE                                                = ?NOME_CONJUGE           , ";
                    vFILTER = vFILTER + "CIDADE                                                      = ?CIDADE                 , ";
                    vFILTER = vFILTER + "DISTRITO                                                    = ?DISTRITO               , ";
                    vFILTER = vFILTER + "BAIRRO                                                      = ?BAIRRO                 , ";
                    vFILTER = vFILTER + "RUA                                                         = ?RUA                    , ";
                    vFILTER = vFILTER + "NUMERO                                                      = ?NUMERO                 , ";
                    vFILTER = vFILTER + "COMPLEMENT                                                  = ?COMPLEMENT             , ";
                    vFILTER = vFILTER + "CEP                                                         = ?CEP                    , ";
                    vFILTER = vFILTER + "UF                                                          = ?UF                     , ";
                    vFILTER = vFILTER + "QUADRA                                                      = ?QUADRA                 , ";
                    vFILTER = vFILTER + "LOTE                                                        = ?LOTE                   , ";
                    vFILTER = vFILTER + "ENTREGA                                                     = ?ENTREGA                , ";
                    vFILTER = vFILTER + "CID_ENTREGA                                                 = ?CID_ENTREGA            , ";
                    vFILTER = vFILTER + "DIS_ENTREGA                                                 = ?DIS_ENTREGA            , ";
                    vFILTER = vFILTER + "BAI_ENTREGA                                                 = ?BAI_ENTREGA            , ";
                    vFILTER = vFILTER + "END_ENTREGA                                                 = ?END_ENTREGA            , ";
                    vFILTER = vFILTER + "NUM_ENTREGA                                                 = ?NUM_ENTREGA            , ";
                    vFILTER = vFILTER + "COMPL_ENTREGA                                               = ?COMPL_ENTREGA          , ";
                    vFILTER = vFILTER + "CEP_ENTREGA                                                 = ?CEP_ENTREGA            , ";
                    vFILTER = vFILTER + "UF_ENTREGA                                                  = ?UF_ENTREGA             , ";
                    vFILTER = vFILTER + "QUA_ENTREGA                                                 = ?QUA_ENTREGA            , ";
                    vFILTER = vFILTER + "LOT_ENTREGA                                                 = ?LOT_ENTREGA            , ";
                    vFILTER = vFILTER + "GRUPO                                                       = ?GRUPO                  , ";
                    //LEITURAS E CONSUMOS                                                           
                    vFILTER = vFILTER + "LEIT                                                        = ?LEIT                   , ";
                    vFILTER = vFILTER + "LEITURAANT                                                  = ?LEITURAANT             , ";
                    vFILTER = vFILTER + "CONSFATURADO                                                = ?CONSFATURADO           , ";
                    vFILTER = vFILTER + "CONSLIDO                                                    = ?CONSLIDO               , ";
                    vFILTER = vFILTER + "CONSRESIDUO                                                 = ?CONSRESIDUO            , ";
                    vFILTER = vFILTER + "VALORCONSUMO                                                = ?VALORCONSUMO           , ";
                    vFILTER = vFILTER + "DIASCONSUMO                                                 = ?DIASCONSUMO            , ";
                    vFILTER = vFILTER + "VLRDIARIO                                                   = ?VLRDIARIO              , ";
                    vFILTER = vFILTER + "MEDIACONSUMODIARIO                                          = ?MEDIACONSUMODIARIO     , ";
                    vFILTER = vFILTER + "MAIORCONSUMO                                                = ?MAIORCONSUMO           , ";
                    vFILTER = vFILTER + "MESMAIORCONSUMO                                             = ?MESMAIORCONSUMO        , ";
                    vFILTER = vFILTER + "MENORCONSUMO                                                = ?MENORCONSUMO           , ";
                    vFILTER = vFILTER + "MESMENORCONSUMO                                             = ?MESMENORCONSUMO        , ";
                    vFILTER = vFILTER + "MEDIACONSUMO3MESES                                          = ?MEDIACONSUMO3MESES     , ";

                    // REVERSO                                                                               
                    vFILTER = vFILTER + "LEIT_REVERSO_ATUAL                                          = ?LEIT_REVERSO_ATUAL     , ";
                    vFILTER = vFILTER + "LEIT_REVERSO_ANTER                                          = ?LEIT_REVERSO_ANTER     , ";
                    vFILTER = vFILTER + "KWH_REVERSO_FAT                                             = ?KWH_REVERSO_FAT        , ";
                    vFILTER = vFILTER + "KWH_REVERSO_RES                                             = ?KWH_REVERSO_RES        , ";
                    vFILTER = vFILTER + "KWH_REVERSO_LID                                             = ?KWH_REVERSO_LID        , ";
                    vFILTER = vFILTER + "MICRO_GERACAO                                               = ?MICRO_GERACAO          , ";

                    // IRRIGACAO                                                                   
                    vFILTER = vFILTER + "LEIT_IRRIGANTE_ATUAL                                        = ?LEIT_IRRIGANTE_ATUAL   , ";
                    vFILTER = vFILTER + "LEIT_IRRIGANTE_ANTERIOR                                     = ?LEIT_IRRIGANTE_ANTERIOR, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_FATURADO                                      = ?KWH_IRRIGANTE_FATURADO , ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_LIDO                                          = ?KWH_IRRIGANTE_LIDO     , ";
                    vFILTER = vFILTER + "IRRIGACAO_AQUICULTURA                                       = ?IRRIGACAO_AQUICULTURA  , ";

                    // TARIFA BRANCA                                                                
                    vFILTER = vFILTER + "TARIFA_BRANCA                                               = ?TARIFA_BRANCA, ";
                    vFILTER = vFILTER + "LEITURA_ANTER_PONTA                                         = ?LEITURA_ANTER_PONTA, ";
                    vFILTER = vFILTER + "LEITURA_ATUAL_PONTA                                         = ?LEITURA_ATUAL_PONTA, ";
                    vFILTER = vFILTER + "LEITURA_ANTER_INTER                                         = ?LEITURA_ANTER_INTER, ";
                    vFILTER = vFILTER + "LEITURA_ATUAL_INTER                                         = ?LEITURA_ATUAL_INTER, ";
                    vFILTER = vFILTER + "LEITURA_ANTER_FORAP                                         = ?LEITURA_ANTER_FORAP, ";
                    vFILTER = vFILTER + "LEITURA_ATUAL_FORAP                                         = ?LEITURA_ATUAL_FORAP, ";
                    vFILTER = vFILTER + "RESIDUO_PONTA                                               = ?RESIDUO_PONTA, ";
                    vFILTER = vFILTER + "RESIDUO_INTER                                               = ?RESIDUO_INTER, ";
                    vFILTER = vFILTER + "RESIDUO_FORAP                                               = ?RESIDUO_FORAP, ";
                    vFILTER = vFILTER + "CONSUMO_PONTA                                               = ?CONSUMO_PONTA, ";
                    vFILTER = vFILTER + "CONSUMO_INTER                                               = ?CONSUMO_INTER, ";
                    vFILTER = vFILTER + "CONSUMO_FORAP                                               = ?CONSUMO_FORAP, ";

                    // TRIBUTOS                                                                      
                    // ICMS                                                                          
                    vFILTER = vFILTER + "BASEICMS                                                    = ?BASEICMS               , ";
                    vFILTER = vFILTER + "ALIQICMS                                                    = ?ALIQICMS               , ";
                    vFILTER = vFILTER + "VLRICMS                                                     = ?VLRICMS                , ";
                    vFILTER = vFILTER + "BASEICMS1                                                   = ?BASEICMS1              , ";
                    vFILTER = vFILTER + "ALIQICMS1                                                   = ?ALIQICMS1              , ";
                    vFILTER = vFILTER + "VLRICMS1                                                    = ?VLRICMS1               , ";
                    //PIS                                                                         
                    vFILTER = vFILTER + "BASEPIS                                                     = ?BASEPIS                , ";
                    vFILTER = vFILTER + "ALIQPIS                                                     = ?ALIQPIS                , ";
                    vFILTER = vFILTER + "VLRPIS                                                      = ?VLRPIS                 , ";
                    //COFINS                                                                        
                    vFILTER = vFILTER + "BASECOFINS                                                  = ?BASECOFINS             , ";
                    vFILTER = vFILTER + "ALIQCOFINS                                                  = ?ALIQCOFINS             , ";
                    vFILTER = vFILTER + "VLRCOFINS                                                   = ?VLRCOFINS              , ";
                    //OUTROS                                                                        
                    vFILTER = vFILTER + "VLRCONSUTRIB                                                = ?VLRCONSUTRIB           , ";
                    vFILTER = vFILTER + "BASEICMSTOTAL                                               = ?BASEICMSTOTAL          , ";
                    vFILTER = vFILTER + "VLRICMSTOTAL                                                = ?VLRICMSTOTAL           , ";
                    //INDICADOR DE CONTINUIDADE                                                      
                    vFILTER = vFILTER + "DEC_META                                                    = ?DEC_META               , ";
                    vFILTER = vFILTER + "FEC_META                                                    = ?FEC_META               , ";
                    vFILTER = vFILTER + "DIC_META                                                    = ?DIC_META               , ";
                    vFILTER = vFILTER + "FIC_META                                                    = ?FIC_META               , ";
                    vFILTER = vFILTER + "DMIC                                                        = ?DMIC                   , ";
                    vFILTER = vFILTER + "DEC_REA                                                     = ?DEC_REA                , ";
                    vFILTER = vFILTER + "FEC_REA                                                     = ?FEC_REA                , ";
                    vFILTER = vFILTER + "DIC_REA                                                     = ?DIC_REA                , ";
                    vFILTER = vFILTER + "FIC_REA                                                     = ?FIC_REA                , ";
                    vFILTER = vFILTER + "DMIC_REA                                                    = ?DMIC_REA               , ";
                    vFILTER = vFILTER + "REFINDICADOR                                                = ?REFINDICADOR           , ";
                    //RETENÇÃO TRIBUTÁRIA                                                            
                    vFILTER = vFILTER + "RET_IRPJ                                                    = ?RET_IRPJ               , ";
                    vFILTER = vFILTER + "RET_PIS                                                     = ?RET_PIS                , ";
                    vFILTER = vFILTER + "RET_CSLL                                                    = ?RET_CSLL               , ";
                    vFILTER = vFILTER + "RET_COFINS                                                  = ?RET_COFINS             , ";
                    //COMPOSIÇÃO DA FATURA                                                         
                    vFILTER = vFILTER + "COMP_ENERGIA                                                = ?COMP_ENERGIA           , ";
                    vFILTER = vFILTER + "COMP_TRANSMISSAO                                            = ?COMP_TRANSMISSAO       , ";
                    vFILTER = vFILTER + "COMP_DISTRIBUICAO                                           = ?COMP_DISTRIBUICAO      , ";
                    vFILTER = vFILTER + "COMP_ENCARGOS_SETORIAIS                                     = ?COMP_ENCARGOS_SETORIAIS, ";

                    //REAVISO                                                                         
                    //if (objTempFaturaNF3EB.REAVISO_VECTO != Convert.ToDateTime("01/01/0001"))
                    //{
                      //  vFILTER = vFILTER + "REAVISO_VECTO                                               = ?REAVISO_VECTO          , ";
                    //}

                    //if (objTempFaturaNF3EB.REAVISO_NUMNF != 0)
                    // {
                    ///    vFILTER = vFILTER + "REAVISO_NUMNF                                               = ?REAVISO_NUMNF          , ";
                    //}

                    //if (objTempFaturaNF3EB.REAVISO_VALOR != 0)
                    //{
                    //    vFILTER = vFILTER + "REAVISO_VALOR                                               = ?REAVISO_VALOR          , ";
                    //}

                    //if (objTempFaturaNF3EB.REAVISO_MESANO != string.Empty)
                    //{
                    //    vFILTER = vFILTER + "REAVISO_MESANO                                              = ?REAVISO_MESANO         , ";
                    //}

                    //if (objTempFaturaNF3EB.REAVISO_IDENTIFICADOR != string.Empty)
                    //{
                    //    vFILTER = vFILTER + "REAVISO_IDENTIFICADOR                                       = ?REAVISO_IDENTIFICADOR  , ";
                    //}

                    //if (objTempFaturaNF3EB.REAVISO_MENSAGEM != string.Empty)
                    //{
                    //    vFILTER = vFILTER + "REAVISO_MENSAGEM                                            = ?REAVISO_MENSAGEM       , ";
                    //}

                    //OUTROS                                                                         
                    vFILTER = vFILTER + "MENSAGEM                                                    = ?MENSAGEM               , ";
                    vFILTER = vFILTER + "ITENSIMP                                                    = ?ITENSIMP               , ";
                    vFILTER = vFILTER + "MENSAGEM_BANDEIRA                                           = ?MENSAGEM_BANDEIRA      , ";
                    vFILTER = vFILTER + "BANDEIRA                                                    = ?BANDEIRA               , ";
                    vFILTER = vFILTER + "FRENTEVERSO                                                 = ?FRENTEVERSO            , ";
                    vFILTER = vFILTER + "OCORRENCIA                                                  = ?OCORRENCIA             , ";
                    vFILTER = vFILTER + "SALDOACUMULADO                                              = ?SALDOACUMULADO               ";

                    cmd = new MySqlCommand(this.QueryInsert);


                    cmd.Parameters.AddWithValue("?SEGVIA", objTempFaturaNF3EB.SEGVIA);
                    cmd.Parameters.AddWithValue("?NOMEMAQUINA", objTempFaturaNF3EB.NOMEMAQUINA.ToString().ToUpper());
                    //DADOS DA FATURA                                                               
                    cmd.Parameters.AddWithValue("?NUMNF", objTempFaturaNF3EB.NUMNF);
                    cmd.Parameters.AddWithValue("?CFOP", objTempFaturaNF3EB.CFOP);
                    cmd.Parameters.AddWithValue("?ZONA", objTempFaturaNF3EB.ZONA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?LIVRO", objTempFaturaNF3EB.LIVRO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CONTA", objTempFaturaNF3EB.CONTA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CONS_ID", objTempFaturaNF3EB.CONS_ID);
                    cmd.Parameters.AddWithValue("?UNID_ID", objTempFaturaNF3EB.UNID_ID);
                    cmd.Parameters.AddWithValue("?ROTA", objTempFaturaNF3EB.ROTA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?VALORTOT", objTempFaturaNF3EB.VALORTOT);
                    cmd.Parameters.AddWithValue("?VALORLIQ", objTempFaturaNF3EB.VALORLIQ);
                    cmd.Parameters.AddWithValue("?CODCLAS", objTempFaturaNF3EB.CODCLAS.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?DATAVENC", objTempFaturaNF3EB.DATAVENC);
                    cmd.Parameters.AddWithValue("?BANIDENT", objTempFaturaNF3EB.BANIDENT.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?BANCO_FATUR", objTempFaturaNF3EB.BANCO_FATUR.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?MESANO", objTempFaturaNF3EB.MESANO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?ANOMES_FAT", objTempFaturaNF3EB.ANOMES_FAT.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?MESANOREF", objTempFaturaNF3EB.MESANOREF);
                    cmd.Parameters.AddWithValue("?DATAAPR", objTempFaturaNF3EB.DATAAPR);
                    cmd.Parameters.AddWithValue("?DATAEMISSAO", objTempFaturaNF3EB.DATAEMISSAO);
                    cmd.Parameters.AddWithValue("?DATAPROXLEIT", objTempFaturaNF3EB.DATAPROXLEIT);
                    cmd.Parameters.AddWithValue("?DATALEIT", objTempFaturaNF3EB.DATALEIT);
                    cmd.Parameters.AddWithValue("?DATALEITANT", objTempFaturaNF3EB.DATALEITANT);
                    cmd.Parameters.AddWithValue("?FASE", objTempFaturaNF3EB.FASE.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?TA", objTempFaturaNF3EB.TA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?TENSAO", objTempFaturaNF3EB.TENSAO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CODHASH", objTempFaturaNF3EB.CODHASH.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CODBARRA", objTempFaturaNF3EB.CODBARRA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?DVCODBARRA", objTempFaturaNF3EB.DVCODBARRA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?DESCCLASSE", objTempFaturaNF3EB.DESCCLASSE.ToString().ToUpper().Replace("-","").Trim());
                    cmd.Parameters.AddWithValue("?NUM_MED", objTempFaturaNF3EB.NUM_MED.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CONST_MED", objTempFaturaNF3EB.CONST_MED);
                    //DADOS DA UNIDADE                                                              
                    cmd.Parameters.AddWithValue("?CPF_CNPJ", objTempFaturaNF3EB.CPF_CNPJ.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?RG_IE", objTempFaturaNF3EB.RG_IE.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CGC", objTempFaturaNF3EB.CGC.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?INSC", objTempFaturaNF3EB.INSC.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?AGENC", objTempFaturaNF3EB.AGENC.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CC", objTempFaturaNF3EB.CC.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?NOMECONS", objTempFaturaNF3EB.NOMECONS.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?REFCONS", objTempFaturaNF3EB.REFCONS.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?NOME_CONJUGE", objTempFaturaNF3EB.NOME_CONJUGE.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CIDADE", objTempFaturaNF3EB.CIDADE.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?DISTRITO", objTempFaturaNF3EB.DISTRITO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?BAIRRO", objTempFaturaNF3EB.BAIRRO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?RUA", objTempFaturaNF3EB.RUA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?NUMERO", objTempFaturaNF3EB.NUMERO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?COMPLEMENT", objTempFaturaNF3EB.COMPLEMENT.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CEP", objTempFaturaNF3EB.CEP.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?UF", objTempFaturaNF3EB.UF.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?QUADRA", objTempFaturaNF3EB.QUADRA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?LOTE", objTempFaturaNF3EB.LOTE.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?ENTREGA", objTempFaturaNF3EB.ENTREGA);
                    cmd.Parameters.AddWithValue("?CID_ENTREGA", objTempFaturaNF3EB.CID_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?DIS_ENTREGA", objTempFaturaNF3EB.DIS_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?BAI_ENTREGA", objTempFaturaNF3EB.BAI_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?END_ENTREGA", objTempFaturaNF3EB.END_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?NUM_ENTREGA", objTempFaturaNF3EB.NUM_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?COMPL_ENTREGA", objTempFaturaNF3EB.COMPL_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CEP_ENTREGA", objTempFaturaNF3EB.CEP_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?UF_ENTREGA", objTempFaturaNF3EB.UF_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?QUA_ENTREGA", objTempFaturaNF3EB.QUA_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?LOT_ENTREGA", objTempFaturaNF3EB.LOT_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?GRUPO", objTempFaturaNF3EB.GRUPO.ToString().ToUpper());
                    //LEITURAS E CONSUMOS                                                           
                    cmd.Parameters.AddWithValue("?LEIT", objTempFaturaNF3EB.LEIT);
                    cmd.Parameters.AddWithValue("?LEITURAANT", objTempFaturaNF3EB.LEITURAANT);
                    cmd.Parameters.AddWithValue("?CONSFATURADO", objTempFaturaNF3EB.CONSFATURADO);
                    cmd.Parameters.AddWithValue("?CONSLIDO", objTempFaturaNF3EB.CONSLIDO);
                    cmd.Parameters.AddWithValue("?CONSRESIDUO", objTempFaturaNF3EB.CONSRESIDUO);
                    cmd.Parameters.AddWithValue("?VALORCONSUMO", objTempFaturaNF3EB.VALORCONSUMO);
                    cmd.Parameters.AddWithValue("?DIASCONSUMO", objTempFaturaNF3EB.DIASCONSUMO);
                    cmd.Parameters.AddWithValue("?VLRDIARIO", objTempFaturaNF3EB.VLRDIARIO);
                    cmd.Parameters.AddWithValue("?MEDIACONSUMODIARIO", objTempFaturaNF3EB.MEDIACONSUMODIARIO);
                    cmd.Parameters.AddWithValue("?MAIORCONSUMO", objTempFaturaNF3EB.MAIORCONSUMO);
                    cmd.Parameters.AddWithValue("?MESMAIORCONSUMO", objTempFaturaNF3EB.MESMAIORCONSUMO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?MENORCONSUMO", objTempFaturaNF3EB.MENORCONSUMO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?MESMENORCONSUMO", objTempFaturaNF3EB.MESMENORCONSUMO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?MEDIACONSUMO3MESES", objTempFaturaNF3EB.MEDIACONSUMO3MESES);

                    // REVERSO                                                                               
                    cmd.Parameters.AddWithValue("?LEIT_REVERSO_ATUAL", objTempFaturaNF3EB.LEIT_REVERSO_ATUAL);
                    cmd.Parameters.AddWithValue("?LEIT_REVERSO_ANTER", objTempFaturaNF3EB.LEIT_REVERSO_ANTER);
                    cmd.Parameters.AddWithValue("?KWH_REVERSO_FAT", objTempFaturaNF3EB.KWH_REVERSO_FAT);
                    cmd.Parameters.AddWithValue("?KWH_REVERSO_RES", objTempFaturaNF3EB.KWH_REVERSO_RES);
                    cmd.Parameters.AddWithValue("?KWH_REVERSO_LID", objTempFaturaNF3EB.KWH_REVERSO_LID);
                    cmd.Parameters.AddWithValue("?MICRO_GERACAO", objTempFaturaNF3EB.MICRO_GERACAO);

                    // IRRIGACAO                                                                   
                    cmd.Parameters.AddWithValue("?LEIT_IRRIGANTE_ATUAL", objTempFaturaNF3EB.LEIT_IRRIGANTE_ATUAL);
                    cmd.Parameters.AddWithValue("?LEIT_IRRIGANTE_ANTERIOR", objTempFaturaNF3EB.LEIT_IRRIGANTE_ANTERIOR);

                    cmd.Parameters.AddWithValue("?KWH_IRRIGANTE_FATURADO", objTempFaturaNF3EB.KWH_IRRIGANTE_FATURADO);

                    cmd.Parameters.AddWithValue("?KWH_IRRIGANTE_LIDO", objTempFaturaNF3EB.KWH_IRRIGANTE_LIDO);
                    cmd.Parameters.AddWithValue("?IRRIGACAO_AQUICULTURA", objTempFaturaNF3EB.IRRIGACAO_AQUICULTURA);

                    // TARIFA BRANCA                                                                
                    cmd.Parameters.AddWithValue("?TARIFA_BRANCA", objTempFaturaNF3EB.TARIFA_BRANCA);

                    cmd.Parameters.AddWithValue("?LEITURA_ANTER_PONTA", objTempFaturaNF3EB.LEITURA_ANTER_PONTA);

                    cmd.Parameters.AddWithValue("?LEITURA_ATUAL_PONTA", objTempFaturaNF3EB.LEITURA_ATUAL_PONTA);

                    cmd.Parameters.AddWithValue("?LEITURA_ANTER_INTER", objTempFaturaNF3EB.LEITURA_ANTER_INTER);

                    cmd.Parameters.AddWithValue("?LEITURA_ATUAL_INTER", objTempFaturaNF3EB.LEITURA_ATUAL_INTER);

                    cmd.Parameters.AddWithValue("?LEITURA_ANTER_FORAP", objTempFaturaNF3EB.LEITURA_ANTER_FORAP);

                    cmd.Parameters.AddWithValue("?LEITURA_ATUAL_FORAP", objTempFaturaNF3EB.LEITURA_ATUAL_FORAP);

                    cmd.Parameters.AddWithValue("?RESIDUO_PONTA", objTempFaturaNF3EB.RESIDUO_PONTA);

                    cmd.Parameters.AddWithValue("?RESIDUO_INTER", objTempFaturaNF3EB.RESIDUO_INTER);

                    cmd.Parameters.AddWithValue("?RESIDUO_FORAP", objTempFaturaNF3EB.RESIDUO_FORAP);

                    cmd.Parameters.AddWithValue("?CONSUMO_PONTA", objTempFaturaNF3EB.CONSUMO_PONTA);

                    cmd.Parameters.AddWithValue("?CONSUMO_INTER", objTempFaturaNF3EB.CONSUMO_INTER);

                    cmd.Parameters.AddWithValue("?CONSUMO_FORAP", objTempFaturaNF3EB.CONSUMO_FORAP);

                    // TRIBUTOS                                                                      
                    // ICMS                                                                          
                    cmd.Parameters.AddWithValue("?BASEICMS", objTempFaturaNF3EB.BASEICMS);
                    cmd.Parameters.AddWithValue("?ALIQICMS", objTempFaturaNF3EB.ALIQICMS);
                    cmd.Parameters.AddWithValue("?VLRICMS", objTempFaturaNF3EB.VLRICMS);
                    cmd.Parameters.AddWithValue("?BASEICMS1", objTempFaturaNF3EB.BASEICMS1);
                    cmd.Parameters.AddWithValue("?ALIQICMS1", objTempFaturaNF3EB.ALIQICMS1);
                    cmd.Parameters.AddWithValue("?VLRICMS1", objTempFaturaNF3EB.VLRICMS1);
                    //PIS                                                                         
                    cmd.Parameters.AddWithValue("?BASEPIS", objTempFaturaNF3EB.BASEPIS);
                    cmd.Parameters.AddWithValue("?ALIQPIS", objTempFaturaNF3EB.ALIQPIS);
                    cmd.Parameters.AddWithValue("?VLRPIS", objTempFaturaNF3EB.VLRPIS);
                    //COFINS                                                                        
                    cmd.Parameters.AddWithValue("?BASECOFINS", objTempFaturaNF3EB.BASECOFINS);
                    cmd.Parameters.AddWithValue("?ALIQCOFINS", objTempFaturaNF3EB.ALIQCOFINS);
                    cmd.Parameters.AddWithValue("?VLRCOFINS", objTempFaturaNF3EB.VLRCOFINS);
                    //OUTROS                                                                        
                    cmd.Parameters.AddWithValue("?VLRCONSUTRIB", objTempFaturaNF3EB.VLRCONSUTRIB);
                    cmd.Parameters.AddWithValue("?BASEICMSTOTAL", objTempFaturaNF3EB.BASEICMSTOTAL);
                    cmd.Parameters.AddWithValue("?VLRICMSTOTAL", objTempFaturaNF3EB.VLRICMSTOTAL);
                    //INDICADOR DE CONTINUIDADE                                                      
                    cmd.Parameters.AddWithValue("?DEC_META", objTempFaturaNF3EB.DEC_META);
                    cmd.Parameters.AddWithValue("?FEC_META", objTempFaturaNF3EB.FEC_META);
                    cmd.Parameters.AddWithValue("?DIC_META", objTempFaturaNF3EB.DIC_META);
                    cmd.Parameters.AddWithValue("?FIC_META", objTempFaturaNF3EB.FIC_META);
                    cmd.Parameters.AddWithValue("?DMIC", objTempFaturaNF3EB.DMIC);
                    cmd.Parameters.AddWithValue("?DEC_REA", objTempFaturaNF3EB.DEC_REA);
                    cmd.Parameters.AddWithValue("?FEC_REA", objTempFaturaNF3EB.FEC_REA);
                    cmd.Parameters.AddWithValue("?DIC_REA", objTempFaturaNF3EB.DIC_REA);
                    cmd.Parameters.AddWithValue("?FIC_REA", objTempFaturaNF3EB.FIC_REA);
                    cmd.Parameters.AddWithValue("?DMIC_REA", objTempFaturaNF3EB.DMIC_REA);
                    cmd.Parameters.AddWithValue("?REFINDICADOR", objTempFaturaNF3EB.REFINDICADOR.ToString().ToUpper());
                    //RETENÇÃO TRIBUTÁRIA                                                            
                    cmd.Parameters.AddWithValue("?RET_IRPJ", objTempFaturaNF3EB.RET_IRPJ);
                    cmd.Parameters.AddWithValue("?RET_PIS", objTempFaturaNF3EB.RET_PIS);
                    cmd.Parameters.AddWithValue("?RET_CSLL", objTempFaturaNF3EB.RET_CSLL);
                    cmd.Parameters.AddWithValue("?RET_COFINS", objTempFaturaNF3EB.RET_COFINS);
                    //COMPOSIÇÃO DA FATURA                                                         
                    cmd.Parameters.AddWithValue("?COMP_ENERGIA", objTempFaturaNF3EB.COMP_ENERGIA);
                    cmd.Parameters.AddWithValue("?COMP_TRANSMISSAO", objTempFaturaNF3EB.COMP_TRANSMISSAO);
                    cmd.Parameters.AddWithValue("?COMP_DISTRIBUICAO", objTempFaturaNF3EB.COMP_DISTRIBUICAO);
                    cmd.Parameters.AddWithValue("?COMP_ENCARGOS_SETORIAIS", objTempFaturaNF3EB.COMP_ENCARGOS_SETORIAIS);

                    //REAVISO                                                                         
                    //if (objTempFaturaNF3EB.REAVISO_VECTO != Convert.ToDateTime("01/01/0001"))
                    //{
                    //    cmd.Parameters.AddWithValue("?REAVISO_VECTO", objTempFaturaNF3EB.REAVISO_VECTO);
                    //}

                    //if (objTempFaturaNF3EB.REAVISO_NUMNF != 0)
                    //{
                    //    cmd.Parameters.AddWithValue("?REAVISO_NUMNF", objTempFaturaNF3EB.REAVISO_NUMNF);
                   // }

                    //if (objTempFaturaNF3EB.REAVISO_VALOR != 0)
                    //{
                    //    cmd.Parameters.AddWithValue("?REAVISO_VALOR", objTempFaturaNF3EB.REAVISO_VALOR);
                    //}

                    //if (objTempFaturaNF3EB.REAVISO_MESANO != string.Empty)
                    //{
                    //    cmd.Parameters.AddWithValue("?REAVISO_MESANO", objTempFaturaNF3EB.REAVISO_MESANO.ToString().ToUpper());
                    //}

                    //if (objTempFaturaNF3EB.REAVISO_IDENTIFICADOR != string.Empty)
                    //{
                    //    cmd.Parameters.AddWithValue("?REAVISO_IDENTIFICADOR", objTempFaturaNF3EB.REAVISO_IDENTIFICADOR.ToString().ToUpper());
                    //}

                    //if (objTempFaturaNF3EB.REAVISO_MENSAGEM != string.Empty)
                    //{
                    //    cmd.Parameters.AddWithValue("?REAVISO_MENSAGEM", objTempFaturaNF3EB.REAVISO_MENSAGEM.ToString().ToUpper());
                   // }

                    //OUTROS                                                                         
                    cmd.Parameters.AddWithValue("?MENSAGEM", objTempFaturaNF3EB.MENSAGEM.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?ITENSIMP", objTempFaturaNF3EB.ITENSIMP.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?MENSAGEM_BANDEIRA", objTempFaturaNF3EB.MENSAGEM_BANDEIRA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?BANDEIRA", objTempFaturaNF3EB.BANDEIRA);
                    cmd.Parameters.AddWithValue("?FRENTEVERSO", objTempFaturaNF3EB.FRENTEVERSO);
                    cmd.Parameters.AddWithValue("?OCORRENCIA", objTempFaturaNF3EB.OCORRENCIA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?SALDOACUMULADO", objTempFaturaNF3EB.SALDOACUMULADO);

                    objGerenciadorTransacao.Execute(cmd);


                }
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                if (cmd != null)
                    cmd.Dispose();
            }
        }

        public void InsertFatwin(entidadeTempFaturaNF3EB objTempFaturaNF3EB)
        {
            MySqlCommand cmd = null;

            IGerenciadorTransacao objGerenciadorTransacao = null;
            ConexaoBD objconexaoBD = null;

            try
            {
                objconexaoBD = new ConexaoBD();

                objconexaoBD.SetarConexaoBanco(TipoBDConexao.fatwin_BD);

                using (objGerenciadorTransacao = FabricaGerenciadorTransacao.GetGerenciador(TipoBDGerenciador.MySql))
                {

                    vFILTER = vFILTER + "SEGVIA                                                     = ?SEGVIA                 , ";
                    vFILTER = vFILTER + "NOMEMAQUINA                                                = ?NOMEMAQUINA            , ";
                    //DADOS DA FATURA                                                               
                    vFILTER = vFILTER + "NUMNF                                                       = ?NUMNF                  , ";
                    vFILTER = vFILTER + "CFOP                                                        = ?CFOP                   , ";
                    vFILTER = vFILTER + "ZONA                                                        = ?ZONA                   , ";
                    vFILTER = vFILTER + "LIVRO                                                       = ?LIVRO                  , ";
                    vFILTER = vFILTER + "CONTA                                                       = ?CONTA                  , ";
                    vFILTER = vFILTER + "CONS_ID                                                     = ?CONS_ID                , ";
                    vFILTER = vFILTER + "UNID_ID                                                     = ?UNID_ID                , ";
                    vFILTER = vFILTER + "ROTA                                                        = ?ROTA                   , ";
                    vFILTER = vFILTER + "VALORTOT                                                    = ?VALORTOT               , ";
                    vFILTER = vFILTER + "VALORLIQ                                                    = ?VALORLIQ               , ";
                    vFILTER = vFILTER + "CODCLAS                                                     = ?CODCLAS                , ";
                    vFILTER = vFILTER + "DATAVENC                                                    = ?DATAVENC               , ";
                    vFILTER = vFILTER + "BANIDENT                                                    = ?BANIDENT               , ";
                    vFILTER = vFILTER + "BANCO_FATUR                                                 = ?BANCO_FATUR            , ";
                    vFILTER = vFILTER + "MESANO                                                      = ?MESANO                 , ";
                    vFILTER = vFILTER + "ANOMES_FAT                                                  = ?ANOMES_FAT             , ";
                    vFILTER = vFILTER + "MESANOREF                                                   = ?MESANOREF              , ";
                    vFILTER = vFILTER + "DATAAPR                                                     = ?DATAAPR                , ";
                    vFILTER = vFILTER + "DATAEMISSAO                                                 = ?DATAEMISSAO            , ";
                    vFILTER = vFILTER + "DATAPROXLEIT                                                = ?DATAPROXLEIT           , ";
                    vFILTER = vFILTER + "DATALEIT                                                    = ?DATALEIT               , ";
                    vFILTER = vFILTER + "DATALEITANT                                                 = ?DATALEITANT            , ";
                    vFILTER = vFILTER + "FASE                                                        = ?FASE                   , ";
                    vFILTER = vFILTER + "TA                                                          = ?TA                     , ";
                    vFILTER = vFILTER + "TENSAO                                                      = ?TENSAO                 , ";
                    vFILTER = vFILTER + "CODHASH                                                     = ?CODHASH                , ";
                    vFILTER = vFILTER + "CODBARRA                                                    = ?CODBARRA               , ";
                    vFILTER = vFILTER + "DVCODBARRA                                                  = ?DVCODBARRA             , ";
                    vFILTER = vFILTER + "DESCCLASSE                                                  = ?DESCCLASSE             , ";
                    vFILTER = vFILTER + "NUM_MED                                                     = ?NUM_MED                , ";
                    vFILTER = vFILTER + "CONST_MED                                                   = ?CONST_MED              , ";
                    //DADOS DA UNIDADE                                                              
                    vFILTER = vFILTER + "CPF_CNPJ                                                    = ?CPF_CNPJ               , ";
                    vFILTER = vFILTER + "RG_IE                                                       = ?RG_IE                  , ";
                    vFILTER = vFILTER + "CGC                                                         = ?CGC                    , ";
                    vFILTER = vFILTER + "INSC                                                        = ?INSC                   , ";
                    vFILTER = vFILTER + "AGENC                                                       = ?AGENC                  , ";
                    vFILTER = vFILTER + "CC                                                          = ?CC                     , ";
                    vFILTER = vFILTER + "NOMECONS                                                    = ?NOMECONS               , ";
                    vFILTER = vFILTER + "REFCONS                                                     = ?REFCONS                , ";
                    vFILTER = vFILTER + "NOME_CONJUGE                                                = ?NOME_CONJUGE           , ";
                    vFILTER = vFILTER + "CIDADE                                                      = ?CIDADE                 , ";
                    vFILTER = vFILTER + "DISTRITO                                                    = ?DISTRITO               , ";
                    vFILTER = vFILTER + "BAIRRO                                                      = ?BAIRRO                 , ";
                    vFILTER = vFILTER + "RUA                                                         = ?RUA                    , ";
                    vFILTER = vFILTER + "NUMERO                                                      = ?NUMERO                 , ";
                    vFILTER = vFILTER + "COMPLEMENT                                                  = ?COMPLEMENT             , ";
                    vFILTER = vFILTER + "CEP                                                         = ?CEP                    , ";
                    vFILTER = vFILTER + "UF                                                          = ?UF                     , ";
                    vFILTER = vFILTER + "QUADRA                                                      = ?QUADRA                 , ";
                    vFILTER = vFILTER + "LOTE                                                        = ?LOTE                   , ";
                    vFILTER = vFILTER + "ENTREGA                                                     = ?ENTREGA                , ";
                    vFILTER = vFILTER + "CID_ENTREGA                                                 = ?CID_ENTREGA            , ";
                    vFILTER = vFILTER + "DIS_ENTREGA                                                 = ?DIS_ENTREGA            , ";
                    vFILTER = vFILTER + "BAI_ENTREGA                                                 = ?BAI_ENTREGA            , ";
                    vFILTER = vFILTER + "END_ENTREGA                                                 = ?END_ENTREGA            , ";
                    vFILTER = vFILTER + "NUM_ENTREGA                                                 = ?NUM_ENTREGA            , ";
                    vFILTER = vFILTER + "COMPL_ENTREGA                                               = ?COMPL_ENTREGA          , ";
                    vFILTER = vFILTER + "CEP_ENTREGA                                                 = ?CEP_ENTREGA            , ";
                    vFILTER = vFILTER + "UF_ENTREGA                                                  = ?UF_ENTREGA             , ";
                    vFILTER = vFILTER + "QUA_ENTREGA                                                 = ?QUA_ENTREGA            , ";
                    vFILTER = vFILTER + "LOT_ENTREGA                                                 = ?LOT_ENTREGA            , ";
                    vFILTER = vFILTER + "GRUPO                                                       = ?GRUPO                  , ";
                    //LEITURAS E CONSUMOS                                                           
                    vFILTER = vFILTER + "LEIT                                                        = ?LEIT                   , ";
                    vFILTER = vFILTER + "LEITURAANT                                                  = ?LEITURAANT             , ";
                    vFILTER = vFILTER + "CONSFATURADO                                                = ?CONSFATURADO           , ";
                    vFILTER = vFILTER + "CONSLIDO                                                    = ?CONSLIDO               , ";
                    vFILTER = vFILTER + "CONSRESIDUO                                                 = ?CONSRESIDUO            , ";
                    vFILTER = vFILTER + "VALORCONSUMO                                                = ?VALORCONSUMO           , ";
                    vFILTER = vFILTER + "DIASCONSUMO                                                 = ?DIASCONSUMO            , ";
                    vFILTER = vFILTER + "VLRDIARIO                                                   = ?VLRDIARIO              , ";
                    vFILTER = vFILTER + "MEDIACONSUMODIARIO                                          = ?MEDIACONSUMODIARIO     , ";
                    vFILTER = vFILTER + "MAIORCONSUMO                                                = ?MAIORCONSUMO           , ";
                    vFILTER = vFILTER + "MESMAIORCONSUMO                                             = ?MESMAIORCONSUMO        , ";
                    vFILTER = vFILTER + "MENORCONSUMO                                                = ?MENORCONSUMO           , ";
                    vFILTER = vFILTER + "MESMENORCONSUMO                                             = ?MESMENORCONSUMO        , ";
                    vFILTER = vFILTER + "MEDIACONSUMO3MESES                                          = ?MEDIACONSUMO3MESES     , ";

                    // REVERSO                                                                               
                    vFILTER = vFILTER + "LEIT_REVERSO_ATUAL                                          = ?LEIT_REVERSO_ATUAL     , ";
                    vFILTER = vFILTER + "LEIT_REVERSO_ANTER                                          = ?LEIT_REVERSO_ANTER     , ";
                    vFILTER = vFILTER + "KWH_REVERSO_FAT                                             = ?KWH_REVERSO_FAT        , ";
                    vFILTER = vFILTER + "KWH_REVERSO_RES                                             = ?KWH_REVERSO_RES        , ";
                    vFILTER = vFILTER + "KWH_REVERSO_LID                                             = ?KWH_REVERSO_LID        , ";
                    vFILTER = vFILTER + "MICRO_GERACAO                                               = ?MICRO_GERACAO          , ";

                    // IRRIGACAO                                                                   
                    vFILTER = vFILTER + "LEIT_IRRIGANTE_ATUAL                                        = ?LEIT_IRRIGANTE_ATUAL   , ";
                    vFILTER = vFILTER + "LEIT_IRRIGANTE_ANTERIOR                                     = ?LEIT_IRRIGANTE_ANTERIOR, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_FATURADO                                      = ?KWH_IRRIGANTE_FATURADO , ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_LIDO                                          = ?KWH_IRRIGANTE_LIDO     , ";
                    vFILTER = vFILTER + "IRRIGACAO_AQUICULTURA                                       = ?IRRIGACAO_AQUICULTURA  , ";

                    // TARIFA BRANCA                                                                
                    vFILTER = vFILTER + "TARIFA_BRANCA                                               = ?TARIFA_BRANCA, ";
                    vFILTER = vFILTER + "LEITURA_ANTER_PONTA                                         = ?LEITURA_ANTER_PONTA, ";
                    vFILTER = vFILTER + "LEITURA_ATUAL_PONTA                                         = ?LEITURA_ATUAL_PONTA, ";
                    vFILTER = vFILTER + "LEITURA_ANTER_INTER                                         = ?LEITURA_ANTER_INTER, ";
                    vFILTER = vFILTER + "LEITURA_ATUAL_INTER                                         = ?LEITURA_ATUAL_INTER, ";
                    vFILTER = vFILTER + "LEITURA_ANTER_FORAP                                         = ?LEITURA_ANTER_FORAP, ";
                    vFILTER = vFILTER + "LEITURA_ATUAL_FORAP                                         = ?LEITURA_ATUAL_FORAP, ";
                    vFILTER = vFILTER + "RESIDUO_PONTA                                               = ?RESIDUO_PONTA, ";
                    vFILTER = vFILTER + "RESIDUO_INTER                                               = ?RESIDUO_INTER, ";
                    vFILTER = vFILTER + "RESIDUO_FORAP                                               = ?RESIDUO_FORAP, ";
                    vFILTER = vFILTER + "CONSUMO_PONTA                                               = ?CONSUMO_PONTA, ";
                    vFILTER = vFILTER + "CONSUMO_INTER                                               = ?CONSUMO_INTER, ";
                    vFILTER = vFILTER + "CONSUMO_FORAP                                               = ?CONSUMO_FORAP, ";

                    // TRIBUTOS                                                                      
                    // ICMS                                                                          
                    vFILTER = vFILTER + "BASEICMS                                                    = ?BASEICMS               , ";
                    vFILTER = vFILTER + "ALIQICMS                                                    = ?ALIQICMS               , ";
                    vFILTER = vFILTER + "VLRICMS                                                     = ?VLRICMS                , ";
                    vFILTER = vFILTER + "BASEICMS1                                                   = ?BASEICMS1              , ";
                    vFILTER = vFILTER + "ALIQICMS1                                                   = ?ALIQICMS1              , ";
                    vFILTER = vFILTER + "VLRICMS1                                                    = ?VLRICMS1               , ";
                    //PIS                                                                         
                    vFILTER = vFILTER + "BASEPIS                                                     = ?BASEPIS                , ";
                    vFILTER = vFILTER + "ALIQPIS                                                     = ?ALIQPIS                , ";
                    vFILTER = vFILTER + "VLRPIS                                                      = ?VLRPIS                 , ";
                    //COFINS                                                                        
                    vFILTER = vFILTER + "BASECOFINS                                                  = ?BASECOFINS             , ";
                    vFILTER = vFILTER + "ALIQCOFINS                                                  = ?ALIQCOFINS             , ";
                    vFILTER = vFILTER + "VLRCOFINS                                                   = ?VLRCOFINS              , ";
                    //OUTROS                                                                        
                    vFILTER = vFILTER + "VLRCONSUTRIB                                                = ?VLRCONSUTRIB           , ";
                    vFILTER = vFILTER + "BASEICMSTOTAL                                               = ?BASEICMSTOTAL          , ";
                    vFILTER = vFILTER + "VLRICMSTOTAL                                                = ?VLRICMSTOTAL           , ";
                    //INDICADOR DE CONTINUIDADE                                                      
                    vFILTER = vFILTER + "DEC_META                                                    = ?DEC_META               , ";
                    vFILTER = vFILTER + "FEC_META                                                    = ?FEC_META               , ";
                    vFILTER = vFILTER + "DIC_META                                                    = ?DIC_META               , ";
                    vFILTER = vFILTER + "FIC_META                                                    = ?FIC_META               , ";
                    vFILTER = vFILTER + "DMIC                                                        = ?DMIC                   , ";
                    vFILTER = vFILTER + "DEC_REA                                                     = ?DEC_REA                , ";
                    vFILTER = vFILTER + "FEC_REA                                                     = ?FEC_REA                , ";
                    vFILTER = vFILTER + "DIC_REA                                                     = ?DIC_REA                , ";
                    vFILTER = vFILTER + "FIC_REA                                                     = ?FIC_REA                , ";
                    vFILTER = vFILTER + "DMIC_REA                                                    = ?DMIC_REA               , ";
                    vFILTER = vFILTER + "REFINDICADOR                                                = ?REFINDICADOR           , ";
                    //RETENÇÃO TRIBUTÁRIA                                                            
                    vFILTER = vFILTER + "RET_IRPJ                                                    = ?RET_IRPJ               , ";
                    vFILTER = vFILTER + "RET_PIS                                                     = ?RET_PIS                , ";
                    vFILTER = vFILTER + "RET_CSLL                                                    = ?RET_CSLL               , ";
                    vFILTER = vFILTER + "RET_COFINS                                                  = ?RET_COFINS             , ";
                    //COMPOSIÇÃO DA FATURA                                                         
                    vFILTER = vFILTER + "COMP_ENERGIA                                                = ?COMP_ENERGIA           , ";
                    vFILTER = vFILTER + "COMP_TRANSMISSAO                                            = ?COMP_TRANSMISSAO       , ";
                    vFILTER = vFILTER + "COMP_DISTRIBUICAO                                           = ?COMP_DISTRIBUICAO      , ";
                    vFILTER = vFILTER + "COMP_ENCARGOS_SETORIAIS                                     = ?COMP_ENCARGOS_SETORIAIS, ";

                    //OUTROS                                                                         
                    vFILTER = vFILTER + "MENSAGEM                                                    = ?MENSAGEM               , ";
                    vFILTER = vFILTER + "ITENSIMP                                                    = ?ITENSIMP               , ";
                    vFILTER = vFILTER + "MENSAGEM_BANDEIRA                                           = ?MENSAGEM_BANDEIRA      , ";
                    vFILTER = vFILTER + "BANDEIRA                                                    = ?BANDEIRA               , ";
                    vFILTER = vFILTER + "FRENTEVERSO                                                 = ?FRENTEVERSO            , ";
                    vFILTER = vFILTER + "OCORRENCIA                                                  = ?OCORRENCIA             , ";
                    vFILTER = vFILTER + "SALDOACUMULADO                                              = ?SALDOACUMULADO               ";

                    cmd = new MySqlCommand(this.QueryInsert);

                    cmd.Parameters.AddWithValue("?SEGVIA", objTempFaturaNF3EB.SEGVIA);
                    cmd.Parameters.AddWithValue("?NOMEMAQUINA", objTempFaturaNF3EB.NOMEMAQUINA.ToString().ToUpper());
                    //DADOS DA FATURA                                                               
                    cmd.Parameters.AddWithValue("?NUMNF", objTempFaturaNF3EB.NUMNF);
                    cmd.Parameters.AddWithValue("?CFOP", objTempFaturaNF3EB.CFOP);
                    cmd.Parameters.AddWithValue("?ZONA", objTempFaturaNF3EB.ZONA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?LIVRO", objTempFaturaNF3EB.LIVRO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CONTA", objTempFaturaNF3EB.CONTA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CONS_ID", objTempFaturaNF3EB.CONS_ID);
                    cmd.Parameters.AddWithValue("?UNID_ID", objTempFaturaNF3EB.UNID_ID);
                    cmd.Parameters.AddWithValue("?ROTA", objTempFaturaNF3EB.ROTA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?VALORTOT", objTempFaturaNF3EB.VALORTOT);
                    cmd.Parameters.AddWithValue("?VALORLIQ", objTempFaturaNF3EB.VALORLIQ);
                    cmd.Parameters.AddWithValue("?CODCLAS", objTempFaturaNF3EB.CODCLAS.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?DATAVENC", objTempFaturaNF3EB.DATAVENC);
                    cmd.Parameters.AddWithValue("?BANIDENT", objTempFaturaNF3EB.BANIDENT.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?BANCO_FATUR", objTempFaturaNF3EB.BANCO_FATUR.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?MESANO", objTempFaturaNF3EB.MESANO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?ANOMES_FAT", objTempFaturaNF3EB.ANOMES_FAT.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?MESANOREF", objTempFaturaNF3EB.MESANOREF);
                    cmd.Parameters.AddWithValue("?DATAAPR", objTempFaturaNF3EB.DATAAPR);
                    cmd.Parameters.AddWithValue("?DATAEMISSAO", objTempFaturaNF3EB.DATAEMISSAO);
                    cmd.Parameters.AddWithValue("?DATAPROXLEIT", objTempFaturaNF3EB.DATAPROXLEIT);
                    cmd.Parameters.AddWithValue("?DATALEIT", objTempFaturaNF3EB.DATALEIT);
                    cmd.Parameters.AddWithValue("?DATALEITANT", objTempFaturaNF3EB.DATALEITANT);
                    cmd.Parameters.AddWithValue("?FASE", objTempFaturaNF3EB.FASE.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?TA", objTempFaturaNF3EB.TA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?TENSAO", objTempFaturaNF3EB.TENSAO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CODHASH", objTempFaturaNF3EB.CODHASH.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CODBARRA", objTempFaturaNF3EB.CODBARRA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?DVCODBARRA", objTempFaturaNF3EB.DVCODBARRA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?DESCCLASSE", objTempFaturaNF3EB.DESCCLASSE.ToString().ToUpper().Replace("-", "").Trim());
                    cmd.Parameters.AddWithValue("?NUM_MED", objTempFaturaNF3EB.NUM_MED.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CONST_MED", objTempFaturaNF3EB.CONST_MED);
                    //DADOS DA UNIDADE                                                              
                    cmd.Parameters.AddWithValue("?CPF_CNPJ", objTempFaturaNF3EB.CPF_CNPJ.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?RG_IE", objTempFaturaNF3EB.RG_IE.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CGC", objTempFaturaNF3EB.CGC.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?INSC", objTempFaturaNF3EB.INSC.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?AGENC", objTempFaturaNF3EB.AGENC.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CC", objTempFaturaNF3EB.CC.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?NOMECONS", objTempFaturaNF3EB.NOMECONS.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?REFCONS", objTempFaturaNF3EB.REFCONS.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?NOME_CONJUGE", objTempFaturaNF3EB.NOME_CONJUGE.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CIDADE", objTempFaturaNF3EB.CIDADE.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?DISTRITO", objTempFaturaNF3EB.DISTRITO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?BAIRRO", objTempFaturaNF3EB.BAIRRO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?RUA", objTempFaturaNF3EB.RUA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?NUMERO", objTempFaturaNF3EB.NUMERO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?COMPLEMENT", objTempFaturaNF3EB.COMPLEMENT.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CEP", objTempFaturaNF3EB.CEP.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?UF", objTempFaturaNF3EB.UF.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?QUADRA", objTempFaturaNF3EB.QUADRA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?LOTE", objTempFaturaNF3EB.LOTE.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?ENTREGA", objTempFaturaNF3EB.ENTREGA);
                    cmd.Parameters.AddWithValue("?CID_ENTREGA", objTempFaturaNF3EB.CID_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?DIS_ENTREGA", objTempFaturaNF3EB.DIS_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?BAI_ENTREGA", objTempFaturaNF3EB.BAI_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?END_ENTREGA", objTempFaturaNF3EB.END_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?NUM_ENTREGA", objTempFaturaNF3EB.NUM_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?COMPL_ENTREGA", objTempFaturaNF3EB.COMPL_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CEP_ENTREGA", objTempFaturaNF3EB.CEP_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?UF_ENTREGA", objTempFaturaNF3EB.UF_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?QUA_ENTREGA", objTempFaturaNF3EB.QUA_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?LOT_ENTREGA", objTempFaturaNF3EB.LOT_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?GRUPO", objTempFaturaNF3EB.GRUPO.ToString().ToUpper());
                    //LEITURAS E CONSUMOS                                                           
                    cmd.Parameters.AddWithValue("?LEIT", objTempFaturaNF3EB.LEIT);
                    cmd.Parameters.AddWithValue("?LEITURAANT", objTempFaturaNF3EB.LEITURAANT);
                    cmd.Parameters.AddWithValue("?CONSFATURADO", objTempFaturaNF3EB.CONSFATURADO);
                    cmd.Parameters.AddWithValue("?CONSLIDO", objTempFaturaNF3EB.CONSLIDO);
                    cmd.Parameters.AddWithValue("?CONSRESIDUO", objTempFaturaNF3EB.CONSRESIDUO);
                    cmd.Parameters.AddWithValue("?VALORCONSUMO", objTempFaturaNF3EB.VALORCONSUMO);
                    cmd.Parameters.AddWithValue("?DIASCONSUMO", objTempFaturaNF3EB.DIASCONSUMO);
                    cmd.Parameters.AddWithValue("?VLRDIARIO", objTempFaturaNF3EB.VLRDIARIO);
                    cmd.Parameters.AddWithValue("?MEDIACONSUMODIARIO", objTempFaturaNF3EB.MEDIACONSUMODIARIO);
                    cmd.Parameters.AddWithValue("?MAIORCONSUMO", objTempFaturaNF3EB.MAIORCONSUMO);
                    cmd.Parameters.AddWithValue("?MESMAIORCONSUMO", objTempFaturaNF3EB.MESMAIORCONSUMO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?MENORCONSUMO", objTempFaturaNF3EB.MENORCONSUMO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?MESMENORCONSUMO", objTempFaturaNF3EB.MESMENORCONSUMO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?MEDIACONSUMO3MESES", objTempFaturaNF3EB.MEDIACONSUMO3MESES);

                    // REVERSO                                                                               
                    cmd.Parameters.AddWithValue("?LEIT_REVERSO_ATUAL", objTempFaturaNF3EB.LEIT_REVERSO_ATUAL);
                    cmd.Parameters.AddWithValue("?LEIT_REVERSO_ANTER", objTempFaturaNF3EB.LEIT_REVERSO_ANTER);
                    cmd.Parameters.AddWithValue("?KWH_REVERSO_FAT", objTempFaturaNF3EB.KWH_REVERSO_FAT);
                    cmd.Parameters.AddWithValue("?KWH_REVERSO_RES", objTempFaturaNF3EB.KWH_REVERSO_RES);
                    cmd.Parameters.AddWithValue("?KWH_REVERSO_LID", objTempFaturaNF3EB.KWH_REVERSO_LID);
                    cmd.Parameters.AddWithValue("?MICRO_GERACAO", objTempFaturaNF3EB.MICRO_GERACAO);

                    // IRRIGACAO                                                                   
                    cmd.Parameters.AddWithValue("?LEIT_IRRIGANTE_ATUAL", objTempFaturaNF3EB.LEIT_IRRIGANTE_ATUAL);
                    cmd.Parameters.AddWithValue("?LEIT_IRRIGANTE_ANTERIOR", objTempFaturaNF3EB.LEIT_IRRIGANTE_ANTERIOR);

                    cmd.Parameters.AddWithValue("?KWH_IRRIGANTE_FATURADO", objTempFaturaNF3EB.KWH_IRRIGANTE_FATURADO);

                    cmd.Parameters.AddWithValue("?KWH_IRRIGANTE_LIDO", objTempFaturaNF3EB.KWH_IRRIGANTE_LIDO);
                    cmd.Parameters.AddWithValue("?IRRIGACAO_AQUICULTURA", objTempFaturaNF3EB.IRRIGACAO_AQUICULTURA);

                    // TARIFA BRANCA                                                                
                    cmd.Parameters.AddWithValue("?TARIFA_BRANCA", objTempFaturaNF3EB.TARIFA_BRANCA);

                    cmd.Parameters.AddWithValue("?LEITURA_ANTER_PONTA", objTempFaturaNF3EB.LEITURA_ANTER_PONTA);

                    cmd.Parameters.AddWithValue("?LEITURA_ATUAL_PONTA", objTempFaturaNF3EB.LEITURA_ATUAL_PONTA);

                    cmd.Parameters.AddWithValue("?LEITURA_ANTER_INTER", objTempFaturaNF3EB.LEITURA_ANTER_INTER);

                    cmd.Parameters.AddWithValue("?LEITURA_ATUAL_INTER", objTempFaturaNF3EB.LEITURA_ATUAL_INTER);

                    cmd.Parameters.AddWithValue("?LEITURA_ANTER_FORAP", objTempFaturaNF3EB.LEITURA_ANTER_FORAP);

                    cmd.Parameters.AddWithValue("?LEITURA_ATUAL_FORAP", objTempFaturaNF3EB.LEITURA_ATUAL_FORAP);

                    cmd.Parameters.AddWithValue("?RESIDUO_PONTA", objTempFaturaNF3EB.RESIDUO_PONTA);

                    cmd.Parameters.AddWithValue("?RESIDUO_INTER", objTempFaturaNF3EB.RESIDUO_INTER);

                    cmd.Parameters.AddWithValue("?RESIDUO_FORAP", objTempFaturaNF3EB.RESIDUO_FORAP);

                    cmd.Parameters.AddWithValue("?CONSUMO_PONTA", objTempFaturaNF3EB.CONSUMO_PONTA);

                    cmd.Parameters.AddWithValue("?CONSUMO_INTER", objTempFaturaNF3EB.CONSUMO_INTER);

                    cmd.Parameters.AddWithValue("?CONSUMO_FORAP", objTempFaturaNF3EB.CONSUMO_FORAP);

                    // TRIBUTOS                                                                      
                    // ICMS                                                                          
                    cmd.Parameters.AddWithValue("?BASEICMS", objTempFaturaNF3EB.BASEICMS);
                    cmd.Parameters.AddWithValue("?ALIQICMS", objTempFaturaNF3EB.ALIQICMS);
                    cmd.Parameters.AddWithValue("?VLRICMS", objTempFaturaNF3EB.VLRICMS);
                    cmd.Parameters.AddWithValue("?BASEICMS1", objTempFaturaNF3EB.BASEICMS1);
                    cmd.Parameters.AddWithValue("?ALIQICMS1", objTempFaturaNF3EB.ALIQICMS1);
                    cmd.Parameters.AddWithValue("?VLRICMS1", objTempFaturaNF3EB.VLRICMS1);
                    //PIS                                                                         
                    cmd.Parameters.AddWithValue("?BASEPIS", objTempFaturaNF3EB.BASEPIS);
                    cmd.Parameters.AddWithValue("?ALIQPIS", objTempFaturaNF3EB.ALIQPIS);
                    cmd.Parameters.AddWithValue("?VLRPIS", objTempFaturaNF3EB.VLRPIS);
                    //COFINS                                                                        
                    cmd.Parameters.AddWithValue("?BASECOFINS", objTempFaturaNF3EB.BASECOFINS);
                    cmd.Parameters.AddWithValue("?ALIQCOFINS", objTempFaturaNF3EB.ALIQCOFINS);
                    cmd.Parameters.AddWithValue("?VLRCOFINS", objTempFaturaNF3EB.VLRCOFINS);
                    //OUTROS                                                                        
                    cmd.Parameters.AddWithValue("?VLRCONSUTRIB", objTempFaturaNF3EB.VLRCONSUTRIB);
                    cmd.Parameters.AddWithValue("?BASEICMSTOTAL", objTempFaturaNF3EB.BASEICMSTOTAL);
                    cmd.Parameters.AddWithValue("?VLRICMSTOTAL", objTempFaturaNF3EB.VLRICMSTOTAL);
                    //INDICADOR DE CONTINUIDADE                                                      
                    cmd.Parameters.AddWithValue("?DEC_META", objTempFaturaNF3EB.DEC_META);
                    cmd.Parameters.AddWithValue("?FEC_META", objTempFaturaNF3EB.FEC_META);
                    cmd.Parameters.AddWithValue("?DIC_META", objTempFaturaNF3EB.DIC_META);
                    cmd.Parameters.AddWithValue("?FIC_META", objTempFaturaNF3EB.FIC_META);
                    cmd.Parameters.AddWithValue("?DMIC", objTempFaturaNF3EB.DMIC);
                    cmd.Parameters.AddWithValue("?DEC_REA", objTempFaturaNF3EB.DEC_REA);
                    cmd.Parameters.AddWithValue("?FEC_REA", objTempFaturaNF3EB.FEC_REA);
                    cmd.Parameters.AddWithValue("?DIC_REA", objTempFaturaNF3EB.DIC_REA);
                    cmd.Parameters.AddWithValue("?FIC_REA", objTempFaturaNF3EB.FIC_REA);
                    cmd.Parameters.AddWithValue("?DMIC_REA", objTempFaturaNF3EB.DMIC_REA);
                    cmd.Parameters.AddWithValue("?REFINDICADOR", objTempFaturaNF3EB.REFINDICADOR.ToString().ToUpper());
                    //RETENÇÃO TRIBUTÁRIA                                                            
                    cmd.Parameters.AddWithValue("?RET_IRPJ", objTempFaturaNF3EB.RET_IRPJ);
                    cmd.Parameters.AddWithValue("?RET_PIS", objTempFaturaNF3EB.RET_PIS);
                    cmd.Parameters.AddWithValue("?RET_CSLL", objTempFaturaNF3EB.RET_CSLL);
                    cmd.Parameters.AddWithValue("?RET_COFINS", objTempFaturaNF3EB.RET_COFINS);
                    //COMPOSIÇÃO DA FATURA                                                         
                    cmd.Parameters.AddWithValue("?COMP_ENERGIA", objTempFaturaNF3EB.COMP_ENERGIA);
                    cmd.Parameters.AddWithValue("?COMP_TRANSMISSAO", objTempFaturaNF3EB.COMP_TRANSMISSAO);
                    cmd.Parameters.AddWithValue("?COMP_DISTRIBUICAO", objTempFaturaNF3EB.COMP_DISTRIBUICAO);
                    cmd.Parameters.AddWithValue("?COMP_ENCARGOS_SETORIAIS", objTempFaturaNF3EB.COMP_ENCARGOS_SETORIAIS);

                    //OUTROS                                                                         
                    cmd.Parameters.AddWithValue("?MENSAGEM", objTempFaturaNF3EB.MENSAGEM.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?ITENSIMP", objTempFaturaNF3EB.ITENSIMP.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?MENSAGEM_BANDEIRA", objTempFaturaNF3EB.MENSAGEM_BANDEIRA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?BANDEIRA", objTempFaturaNF3EB.BANDEIRA);
                    cmd.Parameters.AddWithValue("?FRENTEVERSO", objTempFaturaNF3EB.FRENTEVERSO);
                    cmd.Parameters.AddWithValue("?OCORRENCIA", objTempFaturaNF3EB.OCORRENCIA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?SALDOACUMULADO", objTempFaturaNF3EB.SALDOACUMULADO);

                    objGerenciadorTransacao.Execute(cmd);

                }
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                if (cmd != null)
                    cmd.Dispose();
            }
        }

        public void Update(entidadeTempFaturaNF3EB objTempFaturaNF3EB)
        {
            MySqlCommand cmd = null;

            IGerenciadorTransacao objGerenciadorTransacao = null;
            ConexaoBD objconexaoBD = null;

            try
            {
                objconexaoBD = new ConexaoBD();

                objconexaoBD.SetarConexaoBanco(TipoBDConexao.fat_BD);

                using (objGerenciadorTransacao = FabricaGerenciadorTransacao.GetGerenciador(TipoBDGerenciador.MySql))
                {


                    vFILTER = vFILTER + " UPDATE temp_fatura_nf3e_b, CONSUMOS SET ";
                    vFILTER = vFILTER + " temp_fatura_nf3e_b.VALORPEND = temp_fatura_nf3e_b.VALORPEND + CONSUMOS.VALOR" + objTempFaturaNF3EB.AUXIMP + ", ";
                    vFILTER = vFILTER + " temp_fatura_nf3e_b.TOTALPEND = temp_fatura_nf3e_b.TOTALPEND + 1 ";
                    vFILTER = vFILTER + "  WHERE 1 = 1 ";
                    vFILTER = vFILTER + "  AND (CONSUMOS.DATAPAG" + objTempFaturaNF3EB.AUXIMP + " IS NULL OR CONSUMOS.DATAPAG" + objTempFaturaNF3EB.AUXIMP + " = '0000-00-00') ";
                    vFILTER = vFILTER + "  AND CONSUMOS.MESANO" + objTempFaturaNF3EB.AUXIMP + " IS NOT NULL ";
                    vFILTER = vFILTER + "  AND temp_fatura_nf3e_b.ZONA = CONSUMOS.ZONA ";
                    vFILTER = vFILTER + "  AND temp_fatura_nf3e_b.LIVRO = CONSUMOS.LIVRO ";
                    vFILTER = vFILTER + "  AND temp_fatura_nf3e_b.CONTA = CONSUMOS.CONTA ";
                    vFILTER = vFILTER + "  AND temp_fatura_nf3e_b.MESANO <> CONSUMOS.MESANO" + objTempFaturaNF3EB.AUXIMP + " ";

                    if (!String.IsNullOrEmpty(objTempFaturaNF3EB.LISTENVIADONF3E))
                    {
                        vAND = vAND + "AND temp_fatura_nf3e_b.NUMNF NOT IN (" + objTempFaturaNF3EB.LISTENVIADONF3E.ToString().ToUpper() + ") ";
                    }
                    else { vAND = vAND + " "; }


                    vAND = vFILTER;

                    cmd = new MySqlCommand(this.QueryExecute);

                    objGerenciadorTransacao.Execute(cmd);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (cmd != null)
                    cmd.Dispose();
            }
        }

        public void UpdateFatwin(entidadeTempFaturaNF3EB objTempFaturaNF3EB)
        {
            MySqlCommand cmd = null;

            IGerenciadorTransacao objGerenciadorTransacao = null;
            ConexaoBD objconexaoBD = null;

            try
            {
                objconexaoBD = new ConexaoBD();

                objconexaoBD.SetarConexaoBanco(TipoBDConexao.fatwin_BD);

                using (objGerenciadorTransacao = FabricaGerenciadorTransacao.GetGerenciador(TipoBDGerenciador.MySql))
                {

                    vFILTER = vFILTER + " UPDATE temp_fatura_nf3e_b, CONSUMOS SET ";
                    vFILTER = vFILTER + " temp_fatura_nf3e_b.VALORPEND = temp_fatura_nf3e_b.VALORPEND + CONSUMOS.VALOR" + objTempFaturaNF3EB.AUXIMP + ", ";
                    vFILTER = vFILTER + " temp_fatura_nf3e_b.TOTALPEND = temp_fatura_nf3e_b.TOTALPEND + 1 ";
                    vFILTER = vFILTER + "  WHERE 1 = 1 ";
                    vFILTER = vFILTER + "  AND (CONSUMOS.DATAPAG" + objTempFaturaNF3EB.AUXIMP + " IS NULL OR CONSUMOS.DATAPAG" + objTempFaturaNF3EB.AUXIMP + " = '0000-00-00') ";
                    vFILTER = vFILTER + "  AND CONSUMOS.MESANO" + objTempFaturaNF3EB.AUXIMP + " IS NOT NULL ";
                    vFILTER = vFILTER + "  AND temp_fatura_nf3e_b.ZONA = CONSUMOS.ZONA ";
                    vFILTER = vFILTER + "  AND temp_fatura_nf3e_b.LIVRO = CONSUMOS.LIVRO ";
                    vFILTER = vFILTER + "  AND temp_fatura_nf3e_b.CONTA = CONSUMOS.CONTA ";
                    vFILTER = vFILTER + "  AND temp_fatura_nf3e_b.MESANO <> CONSUMOS.MESANO" + objTempFaturaNF3EB.AUXIMP + " ";

                    if (!String.IsNullOrEmpty(objTempFaturaNF3EB.LISTENVIADONF3E))
                    {
                        vAND = vAND + "AND temp_fatura_nf3e_b.NUMNF NOT IN (" + objTempFaturaNF3EB.LISTENVIADONF3E.ToString().ToUpper() + ") ";
                    }
                    else { vAND = vAND + " "; }

                    vAND = vFILTER;

                    cmd = new MySqlCommand(this.QueryExecute);

                    objGerenciadorTransacao.Execute(cmd);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (cmd != null)
                    cmd.Dispose();
            }
        }

        public void Update_1(entidadeTempFaturaNF3EB objTempFaturaNF3EB)
        {
            MySqlCommand cmd = null;

            IGerenciadorTransacao objGerenciadorTransacao = null;
            ConexaoBD objconexaoBD = null;

            try
            {
                objconexaoBD = new ConexaoBD();

                objconexaoBD.SetarConexaoBanco(TipoBDConexao.fat_BD);

                using (objGerenciadorTransacao = FabricaGerenciadorTransacao.GetGerenciador(TipoBDGerenciador.MySql))
                {

                    vFILTER = vFILTER + " UPDATE temp_fatura_nf3e_b, LEITMENSAL SET ";
                    vFILTER = vFILTER + " temp_fatura_nf3e_b.LEITURAANT             = LEITMENSAL.LEIT_ANT + 0 , ";
                    vFILTER = vFILTER + " temp_fatura_nf3e_b.LEIT                   = LEITMENSAL.LEIT_ATUAL + 0 , ";
                    vFILTER = vFILTER + " temp_fatura_nf3e_b.LEITURA_KVARH_ANTERIOR = LEITMENSAL.KVARH, ";
                    vFILTER = vFILTER + " temp_fatura_nf3e_b.LEITURA_KVARH_ATUAL    = LEITMENSAL.KVARHATUAL, ";
                    vFILTER = vFILTER + " temp_fatura_nf3e_b.CONSUMO_KVARH          = LEITMENSAL.CONSUMOKVARH, ";
                    vFILTER = vFILTER + " temp_fatura_nf3e_b.FP                     = LEITMENSAL.FP ";
                    vFILTER = vFILTER + " WHERE 1 = 1 ";
                    vFILTER = vFILTER + " AND CONCAT(MID(LEITMENSAL.DT_FATURAMENTO, 6, 2), '/', YEAR(LEITMENSAL.DT_FATURAMENTO)) = temp_fatura_nf3e_b.MESANO ";
                    vFILTER = vFILTER + " AND temp_fatura_nf3e_b.ZONA = LEITMENSAL.ZONA ";
                    vFILTER = vFILTER + " AND temp_fatura_nf3e_b.LIVRO = LEITMENSAL.LIVRO ";
                    vFILTER = vFILTER + " AND temp_fatura_nf3e_b.CONTA = LEITMENSAL.CONTA ";
                    vFILTER = vFILTER + " AND temp_fatura_nf3e_b.NOMEMAQUINA = ?NOMEMAQUINA ";

                    if (!String.IsNullOrEmpty(objTempFaturaNF3EB.LISTENVIADONF3E))
                    {
                        vAND = vAND + "AND temp_fatura_nf3e_b.NUMNF NOT IN (" + objTempFaturaNF3EB.LISTENVIADONF3E.ToString().ToUpper() + ") ";
                    }
                    else { vAND = vAND + " "; }


                    vAND = vFILTER;

                    cmd = new MySqlCommand(this.QueryExecute);

                    cmd.Parameters.AddWithValue("?NOMEMAQUINA", objTempFaturaNF3EB.NOMEMAQUINA.ToString().ToUpper());

                    objGerenciadorTransacao.Execute(cmd);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (cmd != null)
                    cmd.Dispose();
            }
        }

        public void UpdateFatwin_1(entidadeTempFaturaNF3EB objTempFaturaNF3EB)
        {
            MySqlCommand cmd = null;

            IGerenciadorTransacao objGerenciadorTransacao = null;
            ConexaoBD objconexaoBD = null;

            try
            {
                objconexaoBD = new ConexaoBD();

                objconexaoBD.SetarConexaoBanco(TipoBDConexao.fatwin_BD);

                using (objGerenciadorTransacao = FabricaGerenciadorTransacao.GetGerenciador(TipoBDGerenciador.MySql))
                {

                    vFILTER = vFILTER + " UPDATE temp_fatura_nf3e_b, LEITMENSAL SET ";
                    vFILTER = vFILTER + " temp_fatura_nf3e_b.LEITURAANT             = LEITMENSAL.LEIT_ANT + 0 , ";
                    vFILTER = vFILTER + " temp_fatura_nf3e_b.LEIT                   = LEITMENSAL.LEIT_ATUAL + 0 , ";
                    vFILTER = vFILTER + " temp_fatura_nf3e_b.LEITURA_KVARH_ANTERIOR = LEITMENSAL.KVARH, ";
                    vFILTER = vFILTER + " temp_fatura_nf3e_b.LEITURA_KVARH_ATUAL    = LEITMENSAL.KVARHATUAL, ";
                    vFILTER = vFILTER + " temp_fatura_nf3e_b.CONSUMO_KVARH          = LEITMENSAL.CONSUMOKVARH, ";
                    vFILTER = vFILTER + " temp_fatura_nf3e_b.FP                     = LEITMENSAL.FP ";
                    vFILTER = vFILTER + " WHERE 1 = 1 ";
                    vFILTER = vFILTER + " AND CONCAT(MID(LEITMENSAL.DT_FATURAMENTO, 6, 2), '/', YEAR(LEITMENSAL.DT_FATURAMENTO)) = temp_fatura_nf3e_b.MESANO ";
                    vFILTER = vFILTER + " AND temp_fatura_nf3e_b.ZONA = LEITMENSAL.ZONA ";
                    vFILTER = vFILTER + " AND temp_fatura_nf3e_b.LIVRO = LEITMENSAL.LIVRO ";
                    vFILTER = vFILTER + " AND temp_fatura_nf3e_b.CONTA = LEITMENSAL.CONTA ";
                    vFILTER = vFILTER + " AND temp_fatura_nf3e_b.NOMEMAQUINA = ?NOMEMAQUINA ";

                    if (!String.IsNullOrEmpty(objTempFaturaNF3EB.LISTENVIADONF3E))
                    {
                        vAND = vAND + "AND temp_fatura_nf3e_b.NUMNF NOT IN (" + objTempFaturaNF3EB.LISTENVIADONF3E.ToString().ToUpper() + ") ";
                    }
                    else { vAND = vAND + " "; }

                    vAND = vFILTER;

                    cmd = new MySqlCommand(this.QueryExecute);

                    cmd.Parameters.AddWithValue("?NOMEMAQUINA", objTempFaturaNF3EB.NOMEMAQUINA.ToString().ToUpper());

                    objGerenciadorTransacao.Execute(cmd);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (cmd != null)
                    cmd.Dispose();
            }
        }
        public void Update_2(entidadeTempFaturaNF3EB objTempFaturaNF3EB)
        {
            MySqlCommand cmd = null;

            IGerenciadorTransacao objGerenciadorTransacao = null;
            ConexaoBD objconexaoBD = null;

            try
            {
                objconexaoBD = new ConexaoBD();

                objconexaoBD.SetarConexaoBanco(TipoBDConexao.fatwin_BD);

                using (objGerenciadorTransacao = FabricaGerenciadorTransacao.GetGerenciador(TipoBDGerenciador.MySql))
                {

                    vFILTER = vFILTER + " ENVIADONF3E  = ?ENVIADONF3E , ";
                    vFILTER = vFILTER + " JSONDADOSSEFAZ  = ?JSONDADOSSEFAZ, ";
                    vFILTER = vFILTER + " JSONDADOSSEFAZ_ORI  = ?JSONDADOSSEFAZ_ORI ";
                    vAND = vAND + " AND NUMNF = ?NUMNF ";

                    cmd = new MySqlCommand(this.QueryUpdate);

                    cmd.Parameters.AddWithValue("?ENVIADONF3E", objTempFaturaNF3EB.ENVIADONF3E);
                    cmd.Parameters.AddWithValue("?JSONDADOSSEFAZ", objTempFaturaNF3EB.JSONDADOSSEFAZ);
                    if (string.IsNullOrEmpty(objTempFaturaNF3EB.JSONDADOSSEFAZ_ORI))
                    {
                        cmd.Parameters.AddWithValue("?JSONDADOSSEFAZ_ORI", objTempFaturaNF3EB.JSONDADOSSEFAZ);
                    }
                    else
                    {
                        cmd.Parameters.AddWithValue("?JSONDADOSSEFAZ_ORI", objTempFaturaNF3EB.JSONDADOSSEFAZ_ORI);
                    }
                    cmd.Parameters.AddWithValue("?NUMNF", objTempFaturaNF3EB.NUMNF);

                    objGerenciadorTransacao.Execute(cmd);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (cmd != null)
                    cmd.Dispose();
            }
        }

        public void Update_Fatwin(entidadeTempFaturaNF3EB objTempFaturaNF3EB)
        {
            MySqlCommand cmd = null;

            IGerenciadorTransacao objGerenciadorTransacao = null;
            ConexaoBD objconexaoBD = null;

            try
            {
                objconexaoBD = new ConexaoBD();

                objconexaoBD.SetarConexaoBanco(TipoBDConexao.fatwin_BD);

                using (objGerenciadorTransacao = FabricaGerenciadorTransacao.GetGerenciador(TipoBDGerenciador.MySql))
                {

                    vFILTER = vFILTER + " ENVIADONF3E  = ?ENVIADONF3E , ";
                    vFILTER = vFILTER + " JSONDADOSSEFAZ  = ?JSONDADOSSEFAZ, ";
                    vFILTER = vFILTER + " JSONDADOSSEFAZ_ORI  = ?JSONDADOSSEFAZ_ORI ";
                    vAND = vAND + " AND NUMNF = ?NUMNF ";

                    cmd = new MySqlCommand(this.QueryUpdate);

                    cmd.Parameters.AddWithValue("?ENVIADONF3E", objTempFaturaNF3EB.ENVIADONF3E);
                    cmd.Parameters.AddWithValue("?JSONDADOSSEFAZ", objTempFaturaNF3EB.JSONDADOSSEFAZ);
                    if (string.IsNullOrEmpty(objTempFaturaNF3EB.JSONDADOSSEFAZ_ORI))
                    {
                        cmd.Parameters.AddWithValue("?JSONDADOSSEFAZ_ORI", objTempFaturaNF3EB.JSONDADOSSEFAZ);
                    }
                    else
                    {
                        cmd.Parameters.AddWithValue("?JSONDADOSSEFAZ_ORI", objTempFaturaNF3EB.JSONDADOSSEFAZ_ORI);
                    }
                    cmd.Parameters.AddWithValue("?NUMNF", objTempFaturaNF3EB.NUMNF);

                    objGerenciadorTransacao.Execute(cmd);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (cmd != null)
                    cmd.Dispose();
            }
        }

        public void Update_Fatwin2(entidadeTempFaturaNF3EB objTempFaturaNF3EB)
        {
            MySqlCommand cmd = null;

            IGerenciadorTransacao objGerenciadorTransacao = null;
            ConexaoBD objconexaoBD = null;

            try
            {
                objconexaoBD = new ConexaoBD();

                objconexaoBD.SetarConexaoBanco(TipoBDConexao.fatwin_BD);

                using (objGerenciadorTransacao = FabricaGerenciadorTransacao.GetGerenciador(TipoBDGerenciador.MySql))
                {

                    vFILTER = vFILTER + " ENVIADONF3E  = ?ENVIADONF3E , ";
                    vFILTER = vFILTER + " JSONDADOSSEFAZ  = ?JSONDADOSSEFAZ, ";
                    vFILTER = vFILTER + " JSONDADOSSEFAZ_ORI  = ?JSONDADOSSEFAZ_ORI, ";
                    vFILTER = vFILTER + " DATA_AUT_SEFAZ  = ?DATAAUTSEFAZ ";
                    vAND = vAND + " AND NUMNF = ?NUMNF ";

                    cmd = new MySqlCommand(this.QueryUpdate);

                    cmd.Parameters.AddWithValue("?ENVIADONF3E", objTempFaturaNF3EB.ENVIADONF3E);
                    cmd.Parameters.AddWithValue("?JSONDADOSSEFAZ", objTempFaturaNF3EB.JSONDADOSSEFAZ);
                    if (string.IsNullOrEmpty(objTempFaturaNF3EB.JSONDADOSSEFAZ_ORI))
                    {
                        cmd.Parameters.AddWithValue("?JSONDADOSSEFAZ_ORI", objTempFaturaNF3EB.JSONDADOSSEFAZ);
                    }
                    else
                    {
                        cmd.Parameters.AddWithValue("?JSONDADOSSEFAZ_ORI", objTempFaturaNF3EB.JSONDADOSSEFAZ_ORI);
                    }
                    cmd.Parameters.AddWithValue("?DATAAUTSEFAZ", objTempFaturaNF3EB.DATAAUTSEFAZ);
                    cmd.Parameters.AddWithValue("?NUMNF", objTempFaturaNF3EB.NUMNF);

                    objGerenciadorTransacao.Execute(cmd);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (cmd != null)
                    cmd.Dispose();
            }
        }
        public void Delete(entidadeTempFaturaNF3EB objTempFaturaNF3EB)
        {

            MySqlCommand cmd = null;
            IGerenciadorTransacao objGerenciadorTransacao = null;
            ConexaoBD objconexaoBD = null;

            try
            {
                objconexaoBD = new ConexaoBD();

                objconexaoBD.SetarConexaoBanco(TipoBDConexao.fat_BD);

                using (objGerenciadorTransacao = FabricaGerenciadorTransacao.GetGerenciador(TipoBDGerenciador.MySql))
                {
                    vORDERBY = " ";


                    vAND = vAND + "AND ENVIADONF3E = ?ENVIADONF3E ";
                    vAND = vAND + "AND MESANOREF = ?MESANOREF ";

                    cmd = new MySqlCommand(this.QueryDelete);

                    cmd.Parameters.AddWithValue("?ENVIADONF3E", objTempFaturaNF3EB.ENVIADONF3E);
                    cmd.Parameters.AddWithValue("?MESANOREF", objTempFaturaNF3EB.MESANOREF);

                    objGerenciadorTransacao.Execute(cmd);
                }


            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (cmd != null)
                    cmd.Dispose();
            }
        }

        public void DeleteFatwin(entidadeTempFaturaNF3EB objTempFaturaNF3EB)
        {

            MySqlCommand cmd = null;
            IGerenciadorTransacao objGerenciadorTransacao = null;
            ConexaoBD objconexaoBD = null;

            try
            {
                objconexaoBD = new ConexaoBD();

                objconexaoBD.SetarConexaoBanco(TipoBDConexao.fatwin_BD);

                using (objGerenciadorTransacao = FabricaGerenciadorTransacao.GetGerenciador(TipoBDGerenciador.MySql))
                {
                    vORDERBY = " ";

                    vAND = vAND + "AND ENVIADONF3E = ?ENVIADONF3E ";
                    vAND = vAND + "AND MESANOREF = ?MESANOREF ";

                    cmd = new MySqlCommand(this.QueryDelete);

                    cmd.Parameters.AddWithValue("?ENVIADONF3E", objTempFaturaNF3EB.ENVIADONF3E);
                    cmd.Parameters.AddWithValue("?MESANOREF", objTempFaturaNF3EB.MESANOREF);

                    objGerenciadorTransacao.Execute(cmd);
                }

            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (cmd != null)
                    cmd.Dispose();
            }
        }

        public DataTable Select(entidadeTempFaturaNF3EB objTempFaturaNF3EB)
        {
            DataTable dt = null;
            MySqlCommand cmd = null;
            IGerenciadorTransacao objGerenciadorTransacao = null;
            ConexaoBD objconexaoBD = null;

            try
            {
                objconexaoBD = new ConexaoBD();

                objconexaoBD.SetarConexaoBanco(TipoBDConexao.fat_BD);

                using (objGerenciadorTransacao = FabricaGerenciadorTransacao.GetGerenciador(TipoBDGerenciador.MySql))
                {
                    vFILTER = vFILTER + "NUMNF, ";
                    vFILTER = vFILTER + "CFOP, ";
                    vFILTER = vFILTER + "ZONA, ";
                    vFILTER = vFILTER + "LIVRO, ";
                    vFILTER = vFILTER + "CONTA, ";
                    vFILTER = vFILTER + "CONS_ID, ";
                    vFILTER = vFILTER + "UNID_ID, ";
                    vFILTER = vFILTER + "ROTA, ";
                    vFILTER = vFILTER + "AGENC, ";
                    vFILTER = vFILTER + "CC, ";
                    vFILTER = vFILTER + "VALORTOT, ";
                    vFILTER = vFILTER + "VLRCONSUTRIB, ";
                    vFILTER = vFILTER + "CODCLAS, ";
                    vFILTER = vFILTER + "DATAVENC, ";
                    vFILTER = vFILTER + "BANCO_FATUR, ";
                    vFILTER = vFILTER + "MESANO, ";
                    vFILTER = vFILTER + "NOMECONS, ";
                    vFILTER = vFILTER + "REFCONS, ";
                    vFILTER = vFILTER + "CGC, ";
                    vFILTER = vFILTER + "INSC, ";
                    vFILTER = vFILTER + "DATAAPR, ";
                    vFILTER = vFILTER + "DATAEMISSAO, ";
                    vFILTER = vFILTER + "DATAPROXLEIT, ";
                    vFILTER = vFILTER + "DATALEIT, ";
                    vFILTER = vFILTER + "DATALEITANT, ";
                    vFILTER = vFILTER + "NUM_MED, ";
                    vFILTER = vFILTER + "CONST_MED, ";
                    vFILTER = vFILTER + "FASE, ";
                    vFILTER = vFILTER + "CODHASH, ";
                    vFILTER = vFILTER + "LEIT, ";
                    vFILTER = vFILTER + "DESCCLASSE, ";
                    vFILTER = vFILTER + "CONSFATURADO, ";
                    vFILTER = vFILTER + "CONSLIDO, ";
                    vFILTER = vFILTER + "CONSRESIDUO, ";
                    vFILTER = vFILTER + "LEITURAANT, ";
                    vFILTER = vFILTER + "FP, ";
                    vFILTER = vFILTER + "BASEICMS, ";
                    vFILTER = vFILTER + "ALIQICMS, ";
                    vFILTER = vFILTER + "VLRICMS, ";
                    vFILTER = vFILTER + "BASEICMS1, ";
                    vFILTER = vFILTER + "ALIQICMS1, ";
                    vFILTER = vFILTER + "VLRICMS1, ";
                    vFILTER = vFILTER + "BASEICMSTOTAL, ";
                    vFILTER = vFILTER + "VLRICMSTOTAL, ";
                    vFILTER = vFILTER + "BASEPIS, ";
                    vFILTER = vFILTER + "ALIQPIS, ";
                    vFILTER = vFILTER + "VLRPIS, ";
                    vFILTER = vFILTER + "BASECOFINS, ";
                    vFILTER = vFILTER + "ALIQCOFINS, ";
                    vFILTER = vFILTER + "VLRCOFINS, ";
                    vFILTER = vFILTER + "DIASCONSUMO, ";
                    vFILTER = vFILTER + "VLRDIARIO, ";
                    vFILTER = vFILTER + "MEDIACONSUMODIARIO, ";
                    vFILTER = vFILTER + "MAIORCONSUMO, ";
                    vFILTER = vFILTER + "MEDIACONSUMO3MESES, ";
                    vFILTER = vFILTER + "OCORRENCIA, ";
                    vFILTER = vFILTER + "CODBARRA, ";
                    vFILTER = vFILTER + "DVCODBARRA, ";
                    vFILTER = vFILTER + "MENSAGEM, ";
                    vFILTER = vFILTER + "VALORPEND, ";
                    vFILTER = vFILTER + "TOTALPEND, ";
                    vFILTER = vFILTER + "DEC_META, ";
                    vFILTER = vFILTER + "DEC_REA, ";
                    vFILTER = vFILTER + "FEC_META, ";
                    vFILTER = vFILTER + "FEC_REA, ";
                    vFILTER = vFILTER + "DIC_META, ";
                    vFILTER = vFILTER + "DIC_REA, ";
                    vFILTER = vFILTER + "FIC_META, ";
                    vFILTER = vFILTER + "FIC_REA, ";
                    vFILTER = vFILTER + "DMIC, ";
                    vFILTER = vFILTER + "DMICM, ";
                    vFILTER = vFILTER + "DMIC_REA, ";
                    vFILTER = vFILTER + "REFINDICADOR, ";
                    vFILTER = vFILTER + "CIDADE, ";
                    vFILTER = vFILTER + "DISTRITO, ";
                    vFILTER = vFILTER + "BAIRRO, ";
                    vFILTER = vFILTER + "RUA, ";
                    vFILTER = vFILTER + "NUMERO, ";
                    vFILTER = vFILTER + "COMPLEMENT, ";
                    vFILTER = vFILTER + "CEP, ";
                    vFILTER = vFILTER + "UF, ";
                    vFILTER = vFILTER + "QUADRA, ";
                    vFILTER = vFILTER + "LOTE, ";
                    vFILTER = vFILTER + "ENTREGA, ";
                    vFILTER = vFILTER + "CID_ENTREGA, ";
                    vFILTER = vFILTER + "DIS_ENTREGA, ";
                    vFILTER = vFILTER + "BAI_ENTREGA, ";
                    vFILTER = vFILTER + "END_ENTREGA, ";
                    vFILTER = vFILTER + "NUM_ENTREGA, ";
                    vFILTER = vFILTER + "COMPL_ENTREGA, ";
                    vFILTER = vFILTER + "CEP_ENTREGA, ";
                    vFILTER = vFILTER + "UF_ENTREGA, ";
                    vFILTER = vFILTER + "QUA_ENTREGA, ";
                    vFILTER = vFILTER + "LOT_ENTREGA, ";
                    vFILTER = vFILTER + "CPF_CNPJ, ";
                    vFILTER = vFILTER + "RG_IE, ";
                    vFILTER = vFILTER + "TENSAO, ";
                    vFILTER = vFILTER + "GRUPO, ";
                    vFILTER = vFILTER + "TA, ";
                    vFILTER = vFILTER + "MESMAIORCONSUMO, ";
                    vFILTER = vFILTER + "MENORCONSUMO, ";
                    vFILTER = vFILTER + "MESMENORCONSUMO, ";
                    vFILTER = vFILTER + "ORDIMP, ";
                    vFILTER = vFILTER + "AUXIMP, ";
                    vFILTER = vFILTER + "LEITURA_KVARH_ANTERIOR, ";
                    vFILTER = vFILTER + "LEITURA_KVARH_ATUAL, ";
                    vFILTER = vFILTER + "CONSUMO_KVARH, ";
                    vFILTER = vFILTER + "CONJUNTO, ";
                    vFILTER = vFILTER + "BANIDENT, ";
                    vFILTER = vFILTER + "RET_IRPJ, ";
                    vFILTER = vFILTER + "RET_PIS, ";
                    vFILTER = vFILTER + "RET_CSLL, ";
                    vFILTER = vFILTER + "RET_COFINS, ";
                    vFILTER = vFILTER + "VALORLIQ, ";
                    vFILTER = vFILTER + "SEGVIA, ";
                    vFILTER = vFILTER + "NOMEMAQUINA, ";
                    vFILTER = vFILTER + "COMP_ENERGIA, ";
                    vFILTER = vFILTER + "COMP_TRANSMISSAO, ";
                    vFILTER = vFILTER + "COMP_DISTRIBUICAO, ";
                    vFILTER = vFILTER + "COMP_ENCARGOS_SETORIAIS, ";
                    vFILTER = vFILTER + "COMP_PERDAS, ";
                    vFILTER = vFILTER + "COMP_TRIBUTOS, ";
                    vFILTER = vFILTER + "COMP_OUTROS, ";
                    vFILTER = vFILTER + "VALORCONSUMO, ";
                    vFILTER = vFILTER + "ITENSIMP, ";
                    vFILTER = vFILTER + "MESANOREF, ";
                    vFILTER = vFILTER + "BANDEIRA, ";
                    vFILTER = vFILTER + "LEIT_IRRIGANTE_ATUAL, ";
                    vFILTER = vFILTER + "LEIT_REVERSO_ATUAL, ";
                    vFILTER = vFILTER + "LEIT_REVERSO_ANTER, ";
                    vFILTER = vFILTER + "KWH_REVERSO_RES, ";
                    vFILTER = vFILTER + "KWH_REVERSO_LID, ";
                    vFILTER = vFILTER + "KWH_REVERSO_FAT, ";
                    vFILTER = vFILTER + "MENSAGEM_BANDEIRA, ";
                    vFILTER = vFILTER + "LEIT_IRRIGANTE_ANTERIOR, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_LIDO, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_FATURADO, ";
                    vFILTER = vFILTER + "FRENTEVERSO, ";
                    vFILTER = vFILTER + "REAVISO_VECTO, ";
                    vFILTER = vFILTER + "REAVISO_NUMNF, ";
                    vFILTER = vFILTER + "REAVISO_VALOR, ";
                    vFILTER = vFILTER + "REAVISO_MESANO, ";
                    vFILTER = vFILTER + "REAVISO_IDENTIFICADOR, ";
                    vFILTER = vFILTER + "REAVISO_MENSAGEM, ";
                    vFILTER = vFILTER + "IRRIGACAO_AQUICULTURA, ";
                    vFILTER = vFILTER + "LIVRE_VERDE, ";
                    vFILTER = vFILTER + "MICRO_GERACAO, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES, ";
                    vFILTER = vFILTER + "NOME_CONJUGE, ";
                    vFILTER = vFILTER + "LEITURA_ANTER_PONTA, ";
                    vFILTER = vFILTER + "LEITURA_ATUAL_PONTA, ";
                    vFILTER = vFILTER + "LEITURA_ANTER_INTER, ";
                    vFILTER = vFILTER + "LEITURA_ATUAL_INTER, ";
                    vFILTER = vFILTER + "LEITURA_ANTER_FORAP, ";
                    vFILTER = vFILTER + "LEITURA_ATUAL_FORAP, ";
                    vFILTER = vFILTER + "RESIDUO_PONTA, ";
                    vFILTER = vFILTER + "RESIDUO_INTER, ";
                    vFILTER = vFILTER + "RESIDUO_FORAP, ";
                    vFILTER = vFILTER + "TARIFA_BRANCA, ";
                    vFILTER = vFILTER + "CONSUMO_PONTA, ";
                    vFILTER = vFILTER + "CONSUMO_INTER, ";
                    vFILTER = vFILTER + "CONSUMO_FORAP, ";
                    vFILTER = vFILTER + "CONSUMORESERVADO, ";
                    vFILTER = vFILTER + "IDTIPO_BANDEIRA, ";
                    vFILTER = vFILTER + "LEITRESERVADOANT, ";
                    vFILTER = vFILTER + "LEITRESERVADOATU, ";
                    vFILTER = vFILTER + "PAGTO_GOVERNO, ";
                    vFILTER = vFILTER + "PERDAS, ";
                    vFILTER = vFILTER + "SALDO_ARRED, ";
                    vFILTER = vFILTER + "VLRCONSUMORESERVADO, ";
                    vFILTER = vFILTER + "SALDOACUMULADO ";


                    vINNERJOIN = " ";

                    vORDERBY = " ";

                    vAND = vAND + "AND NOMEMAQUINA = ?NOMEMAQUINA ";


                    cmd = new MySqlCommand(this.QuerySelect);

                    cmd.Parameters.AddWithValue("?NOMEMAQUINA", objTempFaturaNF3EB.NOMEMAQUINA.ToString().ToUpper());

                    dt = objGerenciadorTransacao.GetDataTable(cmd);

                }

                return dt;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (cmd != null)
                    cmd.Dispose();
            }
        }

        public DataTable Select_1(entidadeTempFaturaNF3EB objTempFaturaNF3EB)
        {
            DataTable dt = null;
            MySqlCommand cmd = null;
            IGerenciadorTransacao objGerenciadorTransacao = null;
            ConexaoBD objconexaoBD = null;

            try
            {
                objconexaoBD = new ConexaoBD();

                objconexaoBD.SetarConexaoBanco(TipoBDConexao.fat_BD);

                using (objGerenciadorTransacao = FabricaGerenciadorTransacao.GetGerenciador(TipoBDGerenciador.MySql))
                {
                    vFILTER = vFILTER + "NUMNF, ";
                    vFILTER = vFILTER + "CFOP, ";
                    vFILTER = vFILTER + "ZONA, ";
                    vFILTER = vFILTER + "LIVRO, ";
                    vFILTER = vFILTER + "CONTA, ";
                    vFILTER = vFILTER + "CONS_ID, ";
                    vFILTER = vFILTER + "UNID_ID, ";
                    vFILTER = vFILTER + "ROTA, ";
                    vFILTER = vFILTER + "AGENC, ";
                    vFILTER = vFILTER + "CC, ";
                    vFILTER = vFILTER + "VALORTOT, ";
                    vFILTER = vFILTER + "VLRCONSUTRIB, ";
                    vFILTER = vFILTER + "CODCLAS, ";
                    vFILTER = vFILTER + "DATAVENC, ";
                    vFILTER = vFILTER + "BANCO_FATUR, ";
                    vFILTER = vFILTER + "MESANO, ";
                    vFILTER = vFILTER + "NOMECONS, ";
                    vFILTER = vFILTER + "REFCONS, ";
                    vFILTER = vFILTER + "CGC, ";
                    vFILTER = vFILTER + "INSC, ";
                    vFILTER = vFILTER + "DATAAPR, ";
                    vFILTER = vFILTER + "DATAEMISSAO, ";
                    vFILTER = vFILTER + "DATAPROXLEIT, ";
                    vFILTER = vFILTER + "DATALEIT, ";
                    vFILTER = vFILTER + "DATALEITANT, ";
                    vFILTER = vFILTER + "NUM_MED, ";
                    vFILTER = vFILTER + "CONST_MED, ";
                    vFILTER = vFILTER + "FASE, ";
                    vFILTER = vFILTER + "CODHASH, ";
                    vFILTER = vFILTER + "LEIT, ";
                    vFILTER = vFILTER + "DESCCLASSE, ";
                    vFILTER = vFILTER + "CONSFATURADO, ";
                    vFILTER = vFILTER + "CONSLIDO, ";
                    vFILTER = vFILTER + "CONSRESIDUO, ";
                    vFILTER = vFILTER + "LEITURAANT, ";
                    vFILTER = vFILTER + "FP, ";
                    vFILTER = vFILTER + "BASEICMS, ";
                    vFILTER = vFILTER + "ALIQICMS, ";
                    vFILTER = vFILTER + "VLRICMS, ";
                    vFILTER = vFILTER + "BASEICMS1, ";
                    vFILTER = vFILTER + "ALIQICMS1, ";
                    vFILTER = vFILTER + "VLRICMS1, ";
                    vFILTER = vFILTER + "BASEICMSTOTAL, ";
                    vFILTER = vFILTER + "VLRICMSTOTAL, ";
                    vFILTER = vFILTER + "BASEPIS, ";
                    vFILTER = vFILTER + "ALIQPIS, ";
                    vFILTER = vFILTER + "VLRPIS, ";
                    vFILTER = vFILTER + "BASECOFINS, ";
                    vFILTER = vFILTER + "ALIQCOFINS, ";
                    vFILTER = vFILTER + "VLRCOFINS, ";
                    vFILTER = vFILTER + "DIASCONSUMO, ";
                    vFILTER = vFILTER + "VLRDIARIO, ";
                    vFILTER = vFILTER + "MEDIACONSUMODIARIO, ";
                    vFILTER = vFILTER + "MAIORCONSUMO, ";
                    vFILTER = vFILTER + "MEDIACONSUMO3MESES, ";
                    vFILTER = vFILTER + "OCORRENCIA, ";
                    vFILTER = vFILTER + "CODBARRA, ";
                    vFILTER = vFILTER + "DVCODBARRA, ";
                    vFILTER = vFILTER + "MENSAGEM, ";
                    vFILTER = vFILTER + "VALORPEND, ";
                    vFILTER = vFILTER + "TOTALPEND, ";
                    vFILTER = vFILTER + "DEC_META, ";
                    vFILTER = vFILTER + "DEC_REA, ";
                    vFILTER = vFILTER + "FEC_META, ";
                    vFILTER = vFILTER + "FEC_REA, ";
                    vFILTER = vFILTER + "DIC_META, ";
                    vFILTER = vFILTER + "DIC_REA, ";
                    vFILTER = vFILTER + "FIC_META, ";
                    vFILTER = vFILTER + "FIC_REA, ";
                    vFILTER = vFILTER + "DMIC, ";
                    vFILTER = vFILTER + "DMICM, ";
                    vFILTER = vFILTER + "DMIC_REA, ";
                    vFILTER = vFILTER + "REFINDICADOR, ";
                    vFILTER = vFILTER + "CIDADE, ";
                    vFILTER = vFILTER + "DISTRITO, ";
                    vFILTER = vFILTER + "BAIRRO, ";
                    vFILTER = vFILTER + "RUA, ";
                    vFILTER = vFILTER + "NUMERO, ";
                    vFILTER = vFILTER + "COMPLEMENT, ";
                    vFILTER = vFILTER + "CEP, ";
                    vFILTER = vFILTER + "UF, ";
                    vFILTER = vFILTER + "QUADRA, ";
                    vFILTER = vFILTER + "LOTE, ";
                    vFILTER = vFILTER + "ENTREGA, ";
                    vFILTER = vFILTER + "CID_ENTREGA, ";
                    vFILTER = vFILTER + "DIS_ENTREGA, ";
                    vFILTER = vFILTER + "BAI_ENTREGA, ";
                    vFILTER = vFILTER + "END_ENTREGA, ";
                    vFILTER = vFILTER + "NUM_ENTREGA, ";
                    vFILTER = vFILTER + "COMPL_ENTREGA, ";
                    vFILTER = vFILTER + "CEP_ENTREGA, ";
                    vFILTER = vFILTER + "UF_ENTREGA, ";
                    vFILTER = vFILTER + "QUA_ENTREGA, ";
                    vFILTER = vFILTER + "LOT_ENTREGA, ";
                    vFILTER = vFILTER + "CPF_CNPJ, ";
                    vFILTER = vFILTER + "RG_IE, ";
                    vFILTER = vFILTER + "TENSAO, ";
                    vFILTER = vFILTER + "GRUPO, ";
                    vFILTER = vFILTER + "TA, ";
                    vFILTER = vFILTER + "MESMAIORCONSUMO, ";
                    vFILTER = vFILTER + "MENORCONSUMO, ";
                    vFILTER = vFILTER + "MESMENORCONSUMO, ";
                    vFILTER = vFILTER + "ORDIMP, ";
                    vFILTER = vFILTER + "AUXIMP, ";
                    vFILTER = vFILTER + "LEITURA_KVARH_ANTERIOR, ";
                    vFILTER = vFILTER + "LEITURA_KVARH_ATUAL, ";
                    vFILTER = vFILTER + "CONSUMO_KVARH, ";
                    vFILTER = vFILTER + "CONJUNTO, ";
                    vFILTER = vFILTER + "BANIDENT, ";
                    vFILTER = vFILTER + "RET_IRPJ, ";
                    vFILTER = vFILTER + "RET_PIS, ";
                    vFILTER = vFILTER + "RET_CSLL, ";
                    vFILTER = vFILTER + "RET_COFINS, ";
                    vFILTER = vFILTER + "VALORLIQ, ";
                    vFILTER = vFILTER + "SEGVIA, ";
                    vFILTER = vFILTER + "NOMEMAQUINA, ";
                    vFILTER = vFILTER + "COMP_ENERGIA, ";
                    vFILTER = vFILTER + "COMP_TRANSMISSAO, ";
                    vFILTER = vFILTER + "COMP_DISTRIBUICAO, ";
                    vFILTER = vFILTER + "COMP_ENCARGOS_SETORIAIS, ";
                    vFILTER = vFILTER + "COMP_PERDAS, ";
                    vFILTER = vFILTER + "COMP_TRIBUTOS, ";
                    vFILTER = vFILTER + "COMP_OUTROS, ";
                    vFILTER = vFILTER + "VALORCONSUMO, ";
                    vFILTER = vFILTER + "ITENSIMP, ";
                    vFILTER = vFILTER + "MESANOREF, ";
                    vFILTER = vFILTER + "BANDEIRA, ";
                    vFILTER = vFILTER + "LEIT_IRRIGANTE_ATUAL, ";
                    vFILTER = vFILTER + "LEIT_REVERSO_ATUAL, ";
                    vFILTER = vFILTER + "LEIT_REVERSO_ANTER, ";
                    vFILTER = vFILTER + "KWH_REVERSO_RES, ";
                    vFILTER = vFILTER + "KWH_REVERSO_LID, ";
                    vFILTER = vFILTER + "KWH_REVERSO_FAT, ";
                    vFILTER = vFILTER + "MENSAGEM_BANDEIRA, ";
                    vFILTER = vFILTER + "LEIT_IRRIGANTE_ANTERIOR, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_LIDO, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_FATURADO, ";
                    vFILTER = vFILTER + "FRENTEVERSO, ";
                    vFILTER = vFILTER + "REAVISO_VECTO, ";
                    vFILTER = vFILTER + "REAVISO_NUMNF, ";
                    vFILTER = vFILTER + "REAVISO_VALOR, ";
                    vFILTER = vFILTER + "REAVISO_MESANO, ";
                    vFILTER = vFILTER + "REAVISO_IDENTIFICADOR, ";
                    vFILTER = vFILTER + "REAVISO_MENSAGEM, ";
                    vFILTER = vFILTER + "IRRIGACAO_AQUICULTURA, ";
                    vFILTER = vFILTER + "LIVRE_VERDE, ";
                    vFILTER = vFILTER + "MICRO_GERACAO, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES, ";
                    vFILTER = vFILTER + "NOME_CONJUGE, ";
                    vFILTER = vFILTER + "LEITURA_ANTER_PONTA, ";
                    vFILTER = vFILTER + "LEITURA_ATUAL_PONTA, ";
                    vFILTER = vFILTER + "LEITURA_ANTER_INTER, ";
                    vFILTER = vFILTER + "LEITURA_ATUAL_INTER, ";
                    vFILTER = vFILTER + "LEITURA_ANTER_FORAP, ";
                    vFILTER = vFILTER + "LEITURA_ATUAL_FORAP, ";
                    vFILTER = vFILTER + "RESIDUO_PONTA, ";
                    vFILTER = vFILTER + "RESIDUO_INTER, ";
                    vFILTER = vFILTER + "RESIDUO_FORAP, ";
                    vFILTER = vFILTER + "TARIFA_BRANCA, ";
                    vFILTER = vFILTER + "CONSUMO_PONTA, ";
                    vFILTER = vFILTER + "CONSUMO_INTER, ";
                    vFILTER = vFILTER + "CONSUMO_FORAP, ";
                    vFILTER = vFILTER + "CONSUMORESERVADO, ";
                    vFILTER = vFILTER + "IDTIPO_BANDEIRA, ";
                    vFILTER = vFILTER + "LEITRESERVADOANT, ";
                    vFILTER = vFILTER + "LEITRESERVADOATU, ";
                    vFILTER = vFILTER + "PAGTO_GOVERNO, ";
                    vFILTER = vFILTER + "PERDAS, ";
                    vFILTER = vFILTER + "SALDO_ARRED, ";
                    vFILTER = vFILTER + "VLRCONSUMORESERVADO, ";
                    vFILTER = vFILTER + "SALDOACUMULADO ";


                    vINNERJOIN = " ";

                    vORDERBY = " ";

                    vAND = vAND + "AND MESANOREF = ?MESANOREF ";

                    vAND = vAND + "And enviadonf3e = 0 ";

                    // vAND = vAND + "and numnf in (115) ";

                    // vAND = vAND + "LIMIT 20 ";

                    // cmd = new MySqlCommand(this.QuerySelect);

                    cmd = new MySqlCommand(this.QuerySelectNovo);

                    cmd.Parameters.AddWithValue("?ENVIADONF3E", objTempFaturaNF3EB.ENVIADONF3E);
                    cmd.Parameters.AddWithValue("?MESANOREF", objTempFaturaNF3EB.MESANOREF);
                    
                    dt = objGerenciadorTransacao.GetDataTable(cmd);

                }

                return dt;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (cmd != null)
                    cmd.Dispose();
            }
        }

        public DataTable Select_2(entidadeTempFaturaNF3EB objTempFaturaNF3EB)
        {
            DataTable dt = null;
            MySqlCommand cmd = null;
            IGerenciadorTransacao objGerenciadorTransacao = null;
            ConexaoBD objconexaoBD = null;

            try
            {
                objconexaoBD = new ConexaoBD();

                objconexaoBD.SetarConexaoBanco(TipoBDConexao.fat_BD);

                using (objGerenciadorTransacao = FabricaGerenciadorTransacao.GetGerenciador(TipoBDGerenciador.MySql))
                {
                    vFILTER = vFILTER + "NUMNF, ";
                    vFILTER = vFILTER + "CFOP, ";
                    vFILTER = vFILTER + "ZONA, ";
                    vFILTER = vFILTER + "LIVRO, ";
                    vFILTER = vFILTER + "CONTA, ";
                    vFILTER = vFILTER + "CONS_ID, ";
                    vFILTER = vFILTER + "UNID_ID, ";
                    vFILTER = vFILTER + "ROTA, ";
                    vFILTER = vFILTER + "AGENC, ";
                    vFILTER = vFILTER + "CC, ";
                    vFILTER = vFILTER + "VALORTOT, ";
                    vFILTER = vFILTER + "VLRCONSUTRIB, ";
                    vFILTER = vFILTER + "CODCLAS, ";
                    vFILTER = vFILTER + "DATAVENC, ";
                    vFILTER = vFILTER + "BANCO_FATUR, ";
                    vFILTER = vFILTER + "MESANO, ";
                    vFILTER = vFILTER + "ANOMES_FAT, ";
                    vFILTER = vFILTER + "NOMECONS, ";
                    vFILTER = vFILTER + "REFCONS, ";
                    vFILTER = vFILTER + "CGC, ";
                    vFILTER = vFILTER + "INSC, ";
                    vFILTER = vFILTER + "DATAAPR, ";
                    vFILTER = vFILTER + "DATAEMISSAO, ";
                    vFILTER = vFILTER + "DATAPROXLEIT, ";
                    vFILTER = vFILTER + "DATALEIT, ";
                    vFILTER = vFILTER + "DATALEITANT, ";
                    vFILTER = vFILTER + "NUM_MED, ";
                    vFILTER = vFILTER + "CONST_MED, ";
                    vFILTER = vFILTER + "FASE, ";
                    vFILTER = vFILTER + "CODHASH, ";
                    vFILTER = vFILTER + "LEIT, ";
                    vFILTER = vFILTER + "DESCCLASSE, ";
                    vFILTER = vFILTER + "CONSFATURADO, ";
                    vFILTER = vFILTER + "CONSLIDO, ";
                    vFILTER = vFILTER + "CONSRESIDUO, ";
                    vFILTER = vFILTER + "LEITURAANT, ";
                    vFILTER = vFILTER + "FP, ";
                    vFILTER = vFILTER + "BASEICMS, ";
                    vFILTER = vFILTER + "ALIQICMS, ";
                    vFILTER = vFILTER + "VLRICMS, ";
                    vFILTER = vFILTER + "BASEICMS1, ";
                    vFILTER = vFILTER + "ALIQICMS1, ";
                    vFILTER = vFILTER + "VLRICMS1, ";
                    vFILTER = vFILTER + "BASEICMSTOTAL, ";
                    vFILTER = vFILTER + "VLRICMSTOTAL, ";
                    vFILTER = vFILTER + "BASEPIS, ";
                    vFILTER = vFILTER + "ALIQPIS, ";
                    vFILTER = vFILTER + "VLRPIS, ";
                    vFILTER = vFILTER + "BASECOFINS, ";
                    vFILTER = vFILTER + "ALIQCOFINS, ";
                    vFILTER = vFILTER + "VLRCOFINS, ";
                    vFILTER = vFILTER + "DIASCONSUMO, ";
                    vFILTER = vFILTER + "VLRDIARIO, ";
                    vFILTER = vFILTER + "MEDIACONSUMODIARIO, ";
                    vFILTER = vFILTER + "MAIORCONSUMO, ";
                    vFILTER = vFILTER + "MEDIACONSUMO3MESES, ";
                    vFILTER = vFILTER + "OCORRENCIA, ";
                    vFILTER = vFILTER + "CODBARRA, ";
                    vFILTER = vFILTER + "DVCODBARRA, ";
                    vFILTER = vFILTER + "MENSAGEM, ";
                    vFILTER = vFILTER + "VALORPEND, ";
                    vFILTER = vFILTER + "TOTALPEND, ";
                    vFILTER = vFILTER + "DEC_META, ";
                    vFILTER = vFILTER + "DEC_REA, ";
                    vFILTER = vFILTER + "FEC_META, ";
                    vFILTER = vFILTER + "FEC_REA, ";
                    vFILTER = vFILTER + "DIC_META, ";
                    vFILTER = vFILTER + "DIC_REA, ";
                    vFILTER = vFILTER + "FIC_META, ";
                    vFILTER = vFILTER + "FIC_REA, ";
                    vFILTER = vFILTER + "DMIC, ";
                    vFILTER = vFILTER + "DMICM, ";
                    vFILTER = vFILTER + "DMIC_REA, ";
                    vFILTER = vFILTER + "REFINDICADOR, ";
                    vFILTER = vFILTER + "CIDADE, ";
                    vFILTER = vFILTER + "DISTRITO, ";
                    vFILTER = vFILTER + "BAIRRO, ";
                    vFILTER = vFILTER + "RUA, ";
                    vFILTER = vFILTER + "NUMERO, ";
                    vFILTER = vFILTER + "COMPLEMENT, ";
                    vFILTER = vFILTER + "CEP, ";
                    vFILTER = vFILTER + "UF, ";
                    vFILTER = vFILTER + "QUADRA, ";
                    vFILTER = vFILTER + "LOTE, ";
                    vFILTER = vFILTER + "ENTREGA, ";
                    vFILTER = vFILTER + "CID_ENTREGA, ";
                    vFILTER = vFILTER + "DIS_ENTREGA, ";
                    vFILTER = vFILTER + "BAI_ENTREGA, ";
                    vFILTER = vFILTER + "END_ENTREGA, ";
                    vFILTER = vFILTER + "NUM_ENTREGA, ";
                    vFILTER = vFILTER + "COMPL_ENTREGA, ";
                    vFILTER = vFILTER + "CEP_ENTREGA, ";
                    vFILTER = vFILTER + "UF_ENTREGA, ";
                    vFILTER = vFILTER + "QUA_ENTREGA, ";
                    vFILTER = vFILTER + "LOT_ENTREGA, ";
                    vFILTER = vFILTER + "CPF_CNPJ, ";
                    vFILTER = vFILTER + "RG_IE, ";
                    vFILTER = vFILTER + "TENSAO, ";
                    vFILTER = vFILTER + "GRUPO, ";
                    vFILTER = vFILTER + "TA, ";
                    vFILTER = vFILTER + "MESMAIORCONSUMO, ";
                    vFILTER = vFILTER + "MENORCONSUMO, ";
                    vFILTER = vFILTER + "MESMENORCONSUMO, ";
                    vFILTER = vFILTER + "ORDIMP, ";
                    vFILTER = vFILTER + "AUXIMP, ";
                    vFILTER = vFILTER + "LEITURA_KVARH_ANTERIOR, ";
                    vFILTER = vFILTER + "LEITURA_KVARH_ATUAL, ";
                    vFILTER = vFILTER + "CONSUMO_KVARH, ";
                    vFILTER = vFILTER + "CONJUNTO, ";
                    vFILTER = vFILTER + "BANIDENT, ";
                    vFILTER = vFILTER + "RET_IRPJ, ";
                    vFILTER = vFILTER + "RET_PIS, ";
                    vFILTER = vFILTER + "RET_CSLL, ";
                    vFILTER = vFILTER + "RET_COFINS, ";
                    vFILTER = vFILTER + "VALORLIQ, ";
                    vFILTER = vFILTER + "SEGVIA, ";
                    vFILTER = vFILTER + "NOMEMAQUINA, ";
                    vFILTER = vFILTER + "COMP_ENERGIA, ";
                    vFILTER = vFILTER + "COMP_TRANSMISSAO, ";
                    vFILTER = vFILTER + "COMP_DISTRIBUICAO, ";
                    vFILTER = vFILTER + "COMP_ENCARGOS_SETORIAIS, ";
                    vFILTER = vFILTER + "COMP_PERDAS, ";
                    vFILTER = vFILTER + "COMP_TRIBUTOS, ";
                    vFILTER = vFILTER + "COMP_OUTROS, ";
                    vFILTER = vFILTER + "VALORCONSUMO, ";
                    vFILTER = vFILTER + "ITENSIMP, ";
                    vFILTER = vFILTER + "MESANOREF, ";
                    vFILTER = vFILTER + "BANDEIRA, ";
                    vFILTER = vFILTER + "LEIT_IRRIGANTE_ATUAL, ";
                    vFILTER = vFILTER + "LEIT_REVERSO_ATUAL, ";
                    vFILTER = vFILTER + "LEIT_REVERSO_ANTER, ";
                    vFILTER = vFILTER + "KWH_REVERSO_RES, ";
                    vFILTER = vFILTER + "KWH_REVERSO_LID, ";
                    vFILTER = vFILTER + "KWH_REVERSO_FAT, ";
                    vFILTER = vFILTER + "MENSAGEM_BANDEIRA, ";
                    vFILTER = vFILTER + "LEIT_IRRIGANTE_ANTERIOR, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_LIDO, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_FATURADO, ";
                    vFILTER = vFILTER + "FRENTEVERSO, ";
                    vFILTER = vFILTER + "REAVISO_VECTO, ";
                    vFILTER = vFILTER + "REAVISO_NUMNF, ";
                    vFILTER = vFILTER + "REAVISO_VALOR, ";
                    vFILTER = vFILTER + "REAVISO_MESANO, ";
                    vFILTER = vFILTER + "REAVISO_IDENTIFICADOR, ";
                    vFILTER = vFILTER + "REAVISO_MENSAGEM, ";
                    vFILTER = vFILTER + "IRRIGACAO_AQUICULTURA, ";
                    vFILTER = vFILTER + "LIVRE_VERDE, ";
                    vFILTER = vFILTER + "MICRO_GERACAO, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES, ";
                    vFILTER = vFILTER + "NOME_CONJUGE, ";
                    vFILTER = vFILTER + "LEITURA_ANTER_PONTA, ";
                    vFILTER = vFILTER + "LEITURA_ATUAL_PONTA, ";
                    vFILTER = vFILTER + "LEITURA_ANTER_INTER, ";
                    vFILTER = vFILTER + "LEITURA_ATUAL_INTER, ";
                    vFILTER = vFILTER + "LEITURA_ANTER_FORAP, ";
                    vFILTER = vFILTER + "LEITURA_ATUAL_FORAP, ";
                    vFILTER = vFILTER + "RESIDUO_PONTA, ";
                    vFILTER = vFILTER + "RESIDUO_INTER, ";
                    vFILTER = vFILTER + "RESIDUO_FORAP, ";
                    vFILTER = vFILTER + "TARIFA_BRANCA, ";
                    vFILTER = vFILTER + "CONSUMO_PONTA, ";
                    vFILTER = vFILTER + "CONSUMO_INTER, ";
                    vFILTER = vFILTER + "CONSUMO_FORAP, ";
                    vFILTER = vFILTER + "CONSUMORESERVADO, ";
                    vFILTER = vFILTER + "IDTIPO_BANDEIRA, ";
                    vFILTER = vFILTER + "LEITRESERVADOANT, ";
                    vFILTER = vFILTER + "LEITRESERVADOATU, ";
                    vFILTER = vFILTER + "PAGTO_GOVERNO, ";
                    vFILTER = vFILTER + "PERDAS, ";
                    vFILTER = vFILTER + "SALDO_ARRED, ";
                    vFILTER = vFILTER + "VLRCONSUMORESERVADO, ";
                    vFILTER = vFILTER + "SALDOACUMULADO ";


                    vINNERJOIN = " ";

                    vORDERBY = " ";

                    vAND = vAND + "AND ENVIADONF3E = ?ENVIADONF3E ";
                    vAND = vAND + "AND MESANOREF = ?MESANOREF ";
                    vAND = vAND + "AND NUMNF IN (" + objTempFaturaNF3EB.LISTNUMNF + ") ";

                    cmd = new MySqlCommand(this.QuerySelect);

                    cmd.Parameters.AddWithValue("?ENVIADONF3E", objTempFaturaNF3EB.ENVIADONF3E);
                    cmd.Parameters.AddWithValue("?MESANOREF", objTempFaturaNF3EB.MESANOREF);

                    dt = objGerenciadorTransacao.GetDataTable(cmd);

                }

                return dt;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (cmd != null)
                    cmd.Dispose();
            }
        }

        public DataTable Select_3(entidadeTempFaturaNF3EB objTempFaturaNF3EB)
        {
            DataTable dt = null;
            MySqlCommand cmd = null;
            IGerenciadorTransacao objGerenciadorTransacao = null;
            ConexaoBD objconexaoBD = null;

            try
            {
                objconexaoBD = new ConexaoBD();

                objconexaoBD.SetarConexaoBanco(TipoBDConexao.fatwin_BD);

                using (objGerenciadorTransacao = FabricaGerenciadorTransacao.GetGerenciador(TipoBDGerenciador.MySql))
                {
                    vFILTER = vFILTER + "NUMNF, ";
                    vFILTER = vFILTER + "CFOP, ";
                    vFILTER = vFILTER + "ZONA, ";
                    vFILTER = vFILTER + "LIVRO, ";
                    vFILTER = vFILTER + "CONTA, ";
                    vFILTER = vFILTER + "CONS_ID, ";
                    vFILTER = vFILTER + "UNID_ID, ";
                    vFILTER = vFILTER + "ROTA, ";
                    vFILTER = vFILTER + "AGENC, ";
                    vFILTER = vFILTER + "CC, ";
                    vFILTER = vFILTER + "VALORTOT, ";
                    vFILTER = vFILTER + "VLRCONSUTRIB, ";
                    vFILTER = vFILTER + "CODCLAS, ";
                    vFILTER = vFILTER + "DATAVENC, ";
                    vFILTER = vFILTER + "BANCO_FATUR, ";
                    vFILTER = vFILTER + "MESANO, ";
                    vFILTER = vFILTER + "NOMECONS, ";
                    vFILTER = vFILTER + "REFCONS, ";
                    vFILTER = vFILTER + "CGC, ";
                    vFILTER = vFILTER + "INSC, ";
                    vFILTER = vFILTER + "DATAAPR, ";
                    vFILTER = vFILTER + "DATAEMISSAO, ";
                    vFILTER = vFILTER + "DATAPROXLEIT, ";
                    vFILTER = vFILTER + "DATALEIT, ";
                    vFILTER = vFILTER + "DATALEITANT, ";
                    vFILTER = vFILTER + "NUM_MED, ";
                    vFILTER = vFILTER + "CONST_MED, ";
                    vFILTER = vFILTER + "FASE, ";
                    vFILTER = vFILTER + "CODHASH, ";
                    vFILTER = vFILTER + "LEIT, ";
                    vFILTER = vFILTER + "DESCCLASSE, ";
                    vFILTER = vFILTER + "CONSFATURADO, ";
                    vFILTER = vFILTER + "CONSLIDO, ";
                    vFILTER = vFILTER + "CONSRESIDUO, ";
                    vFILTER = vFILTER + "LEITURAANT, ";
                    vFILTER = vFILTER + "FP, ";
                    vFILTER = vFILTER + "BASEICMS, ";
                    vFILTER = vFILTER + "ALIQICMS, ";
                    vFILTER = vFILTER + "VLRICMS, ";
                    vFILTER = vFILTER + "BASEICMS1, ";
                    vFILTER = vFILTER + "ALIQICMS1, ";
                    vFILTER = vFILTER + "VLRICMS1, ";
                    vFILTER = vFILTER + "BASEICMSTOTAL, ";
                    vFILTER = vFILTER + "VLRICMSTOTAL, ";
                    vFILTER = vFILTER + "BASEPIS, ";
                    vFILTER = vFILTER + "ALIQPIS, ";
                    vFILTER = vFILTER + "VLRPIS, ";
                    vFILTER = vFILTER + "BASECOFINS, ";
                    vFILTER = vFILTER + "ALIQCOFINS, ";
                    vFILTER = vFILTER + "VLRCOFINS, ";
                    vFILTER = vFILTER + "DIASCONSUMO, ";
                    vFILTER = vFILTER + "VLRDIARIO, ";
                    vFILTER = vFILTER + "MEDIACONSUMODIARIO, ";
                    vFILTER = vFILTER + "MAIORCONSUMO, ";
                    vFILTER = vFILTER + "MEDIACONSUMO3MESES, ";
                    vFILTER = vFILTER + "OCORRENCIA, ";
                    vFILTER = vFILTER + "CODBARRA, ";
                    vFILTER = vFILTER + "DVCODBARRA, ";
                    vFILTER = vFILTER + "MENSAGEM, ";
                    vFILTER = vFILTER + "VALORPEND, ";
                    vFILTER = vFILTER + "TOTALPEND, ";
                    vFILTER = vFILTER + "DEC_META, ";
                    vFILTER = vFILTER + "DEC_REA, ";
                    vFILTER = vFILTER + "FEC_META, ";
                    vFILTER = vFILTER + "FEC_REA, ";
                    vFILTER = vFILTER + "DIC_META, ";
                    vFILTER = vFILTER + "DIC_REA, ";
                    vFILTER = vFILTER + "FIC_META, ";
                    vFILTER = vFILTER + "FIC_REA, ";
                    vFILTER = vFILTER + "DMIC, ";
                    vFILTER = vFILTER + "DMICM, ";
                    vFILTER = vFILTER + "DMIC_REA, ";
                    vFILTER = vFILTER + "REFINDICADOR, ";
                    vFILTER = vFILTER + "CIDADE, ";
                    vFILTER = vFILTER + "DISTRITO, ";
                    vFILTER = vFILTER + "BAIRRO, ";
                    vFILTER = vFILTER + "RUA, ";
                    vFILTER = vFILTER + "NUMERO, ";
                    vFILTER = vFILTER + "COMPLEMENT, ";
                    vFILTER = vFILTER + "CEP, ";
                    vFILTER = vFILTER + "UF, ";
                    vFILTER = vFILTER + "QUADRA, ";
                    vFILTER = vFILTER + "LOTE, ";
                    vFILTER = vFILTER + "ENTREGA, ";
                    vFILTER = vFILTER + "CID_ENTREGA, ";
                    vFILTER = vFILTER + "DIS_ENTREGA, ";
                    vFILTER = vFILTER + "BAI_ENTREGA, ";
                    vFILTER = vFILTER + "END_ENTREGA, ";
                    vFILTER = vFILTER + "NUM_ENTREGA, ";
                    vFILTER = vFILTER + "COMPL_ENTREGA, ";
                    vFILTER = vFILTER + "CEP_ENTREGA, ";
                    vFILTER = vFILTER + "UF_ENTREGA, ";
                    vFILTER = vFILTER + "QUA_ENTREGA, ";
                    vFILTER = vFILTER + "LOT_ENTREGA, ";
                    vFILTER = vFILTER + "CPF_CNPJ, ";
                    vFILTER = vFILTER + "RG_IE, ";
                    vFILTER = vFILTER + "TENSAO, ";
                    vFILTER = vFILTER + "GRUPO, ";
                    vFILTER = vFILTER + "TA, ";
                    vFILTER = vFILTER + "MESMAIORCONSUMO, ";
                    vFILTER = vFILTER + "MENORCONSUMO, ";
                    vFILTER = vFILTER + "MESMENORCONSUMO, ";
                    vFILTER = vFILTER + "ORDIMP, ";
                    vFILTER = vFILTER + "AUXIMP, ";
                    vFILTER = vFILTER + "LEITURA_KVARH_ANTERIOR, ";
                    vFILTER = vFILTER + "LEITURA_KVARH_ATUAL, ";
                    vFILTER = vFILTER + "CONSUMO_KVARH, ";
                    vFILTER = vFILTER + "CONJUNTO, ";
                    vFILTER = vFILTER + "BANIDENT, ";
                    vFILTER = vFILTER + "RET_IRPJ, ";
                    vFILTER = vFILTER + "RET_PIS, ";
                    vFILTER = vFILTER + "RET_CSLL, ";
                    vFILTER = vFILTER + "RET_COFINS, ";
                    vFILTER = vFILTER + "VALORLIQ, ";
                    vFILTER = vFILTER + "SEGVIA, ";
                    vFILTER = vFILTER + "NOMEMAQUINA, ";
                    vFILTER = vFILTER + "COMP_ENERGIA, ";
                    vFILTER = vFILTER + "COMP_TRANSMISSAO, ";
                    vFILTER = vFILTER + "COMP_DISTRIBUICAO, ";
                    vFILTER = vFILTER + "COMP_ENCARGOS_SETORIAIS, ";
                    vFILTER = vFILTER + "COMP_PERDAS, ";
                    vFILTER = vFILTER + "COMP_TRIBUTOS, ";
                    vFILTER = vFILTER + "COMP_OUTROS, ";
                    vFILTER = vFILTER + "VALORCONSUMO, ";
                    vFILTER = vFILTER + "ITENSIMP, ";
                    vFILTER = vFILTER + "MESANOREF, ";
                    vFILTER = vFILTER + "BANDEIRA, ";
                    vFILTER = vFILTER + "LEIT_IRRIGANTE_ATUAL, ";
                    vFILTER = vFILTER + "LEIT_REVERSO_ATUAL, ";
                    vFILTER = vFILTER + "LEIT_REVERSO_ANTER, ";
                    vFILTER = vFILTER + "KWH_REVERSO_RES, ";
                    vFILTER = vFILTER + "KWH_REVERSO_LID, ";
                    vFILTER = vFILTER + "KWH_REVERSO_FAT, ";
                    vFILTER = vFILTER + "MENSAGEM_BANDEIRA, ";
                    vFILTER = vFILTER + "LEIT_IRRIGANTE_ANTERIOR, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_LIDO, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_FATURADO, ";
                    vFILTER = vFILTER + "FRENTEVERSO, ";
                    vFILTER = vFILTER + "REAVISO_VECTO, ";
                    vFILTER = vFILTER + "REAVISO_NUMNF, ";
                    vFILTER = vFILTER + "REAVISO_VALOR, ";
                    vFILTER = vFILTER + "REAVISO_MESANO, ";
                    vFILTER = vFILTER + "REAVISO_IDENTIFICADOR, ";
                    vFILTER = vFILTER + "REAVISO_MENSAGEM, ";
                    vFILTER = vFILTER + "IRRIGACAO_AQUICULTURA, ";
                    vFILTER = vFILTER + "LIVRE_VERDE, ";
                    vFILTER = vFILTER + "MICRO_GERACAO, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES, ";
                    vFILTER = vFILTER + "NOME_CONJUGE, ";
                    vFILTER = vFILTER + "LEITURA_ANTER_PONTA, ";
                    vFILTER = vFILTER + "LEITURA_ATUAL_PONTA, ";
                    vFILTER = vFILTER + "LEITURA_ANTER_INTER, ";
                    vFILTER = vFILTER + "LEITURA_ATUAL_INTER, ";
                    vFILTER = vFILTER + "LEITURA_ANTER_FORAP, ";
                    vFILTER = vFILTER + "LEITURA_ATUAL_FORAP, ";
                    vFILTER = vFILTER + "RESIDUO_PONTA, ";
                    vFILTER = vFILTER + "RESIDUO_INTER, ";
                    vFILTER = vFILTER + "RESIDUO_FORAP, ";
                    vFILTER = vFILTER + "TARIFA_BRANCA, ";
                    vFILTER = vFILTER + "CONSUMO_PONTA, ";
                    vFILTER = vFILTER + "CONSUMO_INTER, ";
                    vFILTER = vFILTER + "CONSUMO_FORAP, ";
                    vFILTER = vFILTER + "CONSUMORESERVADO, ";
                    vFILTER = vFILTER + "IDTIPO_BANDEIRA, ";
                    vFILTER = vFILTER + "LEITRESERVADOANT, ";
                    vFILTER = vFILTER + "LEITRESERVADOATU, ";
                    vFILTER = vFILTER + "PAGTO_GOVERNO, ";
                    vFILTER = vFILTER + "PERDAS, ";
                    vFILTER = vFILTER + "SALDO_ARRED, ";
                    vFILTER = vFILTER + "VLRCONSUMORESERVADO, ";
                    vFILTER = vFILTER + "SALDOACUMULADO, ";
                    vFILTER = vFILTER + "JSONDADOSSEFAZ ";


                    vINNERJOIN = " ";

                    vORDERBY = " ";

                    vAND = vAND + "AND ENVIADONF3E = ?ENVIADONF3E ";
                    vAND = vAND + "AND NUMNF = ?NUMNF ";

                    cmd = new MySqlCommand(this.QuerySelect);

                    cmd.Parameters.AddWithValue("?ENVIADONF3E", objTempFaturaNF3EB.ENVIADONF3E);
                    cmd.Parameters.AddWithValue("?NUMNF", objTempFaturaNF3EB.NUMNF);

                    dt = objGerenciadorTransacao.GetDataTable(cmd);

                }

                return dt;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (cmd != null)
                    cmd.Dispose();
            }
        }

        public DataTable Select_4(entidadeTempFaturaNF3EB objTempFaturaNF3EB)
        {
            DataTable dt = null;
            MySqlCommand cmd = null;
            IGerenciadorTransacao objGerenciadorTransacao = null;
            ConexaoBD objconexaoBD = null;

            try
            {
                objconexaoBD = new ConexaoBD();

                objconexaoBD.SetarConexaoBanco(TipoBDConexao.fat_BD);

                using (objGerenciadorTransacao = FabricaGerenciadorTransacao.GetGerenciador(TipoBDGerenciador.MySql))
                {
                    vFILTER = vFILTER + "NUMNF, ";
                    vFILTER = vFILTER + "CFOP, ";
                    vFILTER = vFILTER + "ZONA, ";
                    vFILTER = vFILTER + "LIVRO, ";
                    vFILTER = vFILTER + "CONTA, ";
                    vFILTER = vFILTER + "CONS_ID, ";
                    vFILTER = vFILTER + "UNID_ID, ";
                    vFILTER = vFILTER + "ROTA, ";
                    vFILTER = vFILTER + "AGENC, ";
                    vFILTER = vFILTER + "CC, ";
                    vFILTER = vFILTER + "VALORTOT, ";
                    vFILTER = vFILTER + "VLRCONSUTRIB, ";
                    vFILTER = vFILTER + "CODCLAS, ";
                    vFILTER = vFILTER + "DATAVENC, ";
                    vFILTER = vFILTER + "BANCO_FATUR, ";
                    vFILTER = vFILTER + "MESANO, ";
                    vFILTER = vFILTER + "NOMECONS, ";
                    vFILTER = vFILTER + "REFCONS, ";
                    vFILTER = vFILTER + "CGC, ";
                    vFILTER = vFILTER + "INSC, ";
                    vFILTER = vFILTER + "DATAAPR, ";
                    vFILTER = vFILTER + "DATAEMISSAO, ";
                    vFILTER = vFILTER + "DATAPROXLEIT, ";
                    vFILTER = vFILTER + "DATALEIT, ";
                    vFILTER = vFILTER + "DATALEITANT, ";
                    vFILTER = vFILTER + "NUM_MED, ";
                    vFILTER = vFILTER + "CONST_MED, ";
                    vFILTER = vFILTER + "FASE, ";
                    vFILTER = vFILTER + "CODHASH, ";
                    vFILTER = vFILTER + "LEIT, ";
                    vFILTER = vFILTER + "DESCCLASSE, ";
                    vFILTER = vFILTER + "CONSFATURADO, ";
                    vFILTER = vFILTER + "CONSLIDO, ";
                    vFILTER = vFILTER + "CONSRESIDUO, ";
                    vFILTER = vFILTER + "LEITURAANT, ";
                    vFILTER = vFILTER + "FP, ";
                    vFILTER = vFILTER + "BASEICMS, ";
                    vFILTER = vFILTER + "ALIQICMS, ";
                    vFILTER = vFILTER + "VLRICMS, ";
                    vFILTER = vFILTER + "BASEICMS1, ";
                    vFILTER = vFILTER + "ALIQICMS1, ";
                    vFILTER = vFILTER + "VLRICMS1, ";
                    vFILTER = vFILTER + "BASEICMSTOTAL, ";
                    vFILTER = vFILTER + "VLRICMSTOTAL, ";
                    vFILTER = vFILTER + "BASEPIS, ";
                    vFILTER = vFILTER + "ALIQPIS, ";
                    vFILTER = vFILTER + "VLRPIS, ";
                    vFILTER = vFILTER + "BASECOFINS, ";
                    vFILTER = vFILTER + "ALIQCOFINS, ";
                    vFILTER = vFILTER + "VLRCOFINS, ";
                    vFILTER = vFILTER + "DIASCONSUMO, ";
                    vFILTER = vFILTER + "VLRDIARIO, ";
                    vFILTER = vFILTER + "MEDIACONSUMODIARIO, ";
                    vFILTER = vFILTER + "MAIORCONSUMO, ";
                    vFILTER = vFILTER + "MEDIACONSUMO3MESES, ";
                    vFILTER = vFILTER + "OCORRENCIA, ";
                    vFILTER = vFILTER + "CODBARRA, ";
                    vFILTER = vFILTER + "DVCODBARRA, ";
                    vFILTER = vFILTER + "MENSAGEM, ";
                    vFILTER = vFILTER + "VALORPEND, ";
                    vFILTER = vFILTER + "TOTALPEND, ";
                    vFILTER = vFILTER + "DEC_META, ";
                    vFILTER = vFILTER + "DEC_REA, ";
                    vFILTER = vFILTER + "FEC_META, ";
                    vFILTER = vFILTER + "FEC_REA, ";
                    vFILTER = vFILTER + "DIC_META, ";
                    vFILTER = vFILTER + "DIC_REA, ";
                    vFILTER = vFILTER + "FIC_META, ";
                    vFILTER = vFILTER + "FIC_REA, ";
                    vFILTER = vFILTER + "DMIC, ";
                    vFILTER = vFILTER + "DMICM, ";
                    vFILTER = vFILTER + "DMIC_REA, ";
                    vFILTER = vFILTER + "REFINDICADOR, ";
                    vFILTER = vFILTER + "CIDADE, ";
                    vFILTER = vFILTER + "DISTRITO, ";
                    vFILTER = vFILTER + "BAIRRO, ";
                    vFILTER = vFILTER + "RUA, ";
                    vFILTER = vFILTER + "NUMERO, ";
                    vFILTER = vFILTER + "COMPLEMENT, ";
                    vFILTER = vFILTER + "CEP, ";
                    vFILTER = vFILTER + "UF, ";
                    vFILTER = vFILTER + "QUADRA, ";
                    vFILTER = vFILTER + "LOTE, ";
                    vFILTER = vFILTER + "ENTREGA, ";
                    vFILTER = vFILTER + "CID_ENTREGA, ";
                    vFILTER = vFILTER + "DIS_ENTREGA, ";
                    vFILTER = vFILTER + "BAI_ENTREGA, ";
                    vFILTER = vFILTER + "END_ENTREGA, ";
                    vFILTER = vFILTER + "NUM_ENTREGA, ";
                    vFILTER = vFILTER + "COMPL_ENTREGA, ";
                    vFILTER = vFILTER + "CEP_ENTREGA, ";
                    vFILTER = vFILTER + "UF_ENTREGA, ";
                    vFILTER = vFILTER + "QUA_ENTREGA, ";
                    vFILTER = vFILTER + "LOT_ENTREGA, ";
                    vFILTER = vFILTER + "CPF_CNPJ, ";
                    vFILTER = vFILTER + "RG_IE, ";
                    vFILTER = vFILTER + "TENSAO, ";
                    vFILTER = vFILTER + "GRUPO, ";
                    vFILTER = vFILTER + "TA, ";
                    vFILTER = vFILTER + "MESMAIORCONSUMO, ";
                    vFILTER = vFILTER + "MENORCONSUMO, ";
                    vFILTER = vFILTER + "MESMENORCONSUMO, ";
                    vFILTER = vFILTER + "ORDIMP, ";
                    vFILTER = vFILTER + "AUXIMP, ";
                    vFILTER = vFILTER + "LEITURA_KVARH_ANTERIOR, ";
                    vFILTER = vFILTER + "LEITURA_KVARH_ATUAL, ";
                    vFILTER = vFILTER + "CONSUMO_KVARH, ";
                    vFILTER = vFILTER + "CONJUNTO, ";
                    vFILTER = vFILTER + "BANIDENT, ";
                    vFILTER = vFILTER + "RET_IRPJ, ";
                    vFILTER = vFILTER + "RET_PIS, ";
                    vFILTER = vFILTER + "RET_CSLL, ";
                    vFILTER = vFILTER + "RET_COFINS, ";
                    vFILTER = vFILTER + "VALORLIQ, ";
                    vFILTER = vFILTER + "SEGVIA, ";
                    vFILTER = vFILTER + "NOMEMAQUINA, ";
                    vFILTER = vFILTER + "COMP_ENERGIA, ";
                    vFILTER = vFILTER + "COMP_TRANSMISSAO, ";
                    vFILTER = vFILTER + "COMP_DISTRIBUICAO, ";
                    vFILTER = vFILTER + "COMP_ENCARGOS_SETORIAIS, ";
                    vFILTER = vFILTER + "COMP_PERDAS, ";
                    vFILTER = vFILTER + "COMP_TRIBUTOS, ";
                    vFILTER = vFILTER + "COMP_OUTROS, ";
                    vFILTER = vFILTER + "VALORCONSUMO, ";
                    vFILTER = vFILTER + "ITENSIMP, ";
                    vFILTER = vFILTER + "MESANOREF, ";
                    vFILTER = vFILTER + "BANDEIRA, ";
                    vFILTER = vFILTER + "LEIT_IRRIGANTE_ATUAL, ";
                    vFILTER = vFILTER + "LEIT_REVERSO_ATUAL, ";
                    vFILTER = vFILTER + "LEIT_REVERSO_ANTER, ";
                    vFILTER = vFILTER + "KWH_REVERSO_RES, ";
                    vFILTER = vFILTER + "KWH_REVERSO_LID, ";
                    vFILTER = vFILTER + "KWH_REVERSO_FAT, ";
                    vFILTER = vFILTER + "MENSAGEM_BANDEIRA, ";
                    vFILTER = vFILTER + "LEIT_IRRIGANTE_ANTERIOR, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_LIDO, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_FATURADO, ";
                    vFILTER = vFILTER + "FRENTEVERSO, ";
                    vFILTER = vFILTER + "REAVISO_VECTO, ";
                    vFILTER = vFILTER + "REAVISO_NUMNF, ";
                    vFILTER = vFILTER + "REAVISO_VALOR, ";
                    vFILTER = vFILTER + "REAVISO_MESANO, ";
                    vFILTER = vFILTER + "REAVISO_IDENTIFICADOR, ";
                    vFILTER = vFILTER + "REAVISO_MENSAGEM, ";
                    vFILTER = vFILTER + "IRRIGACAO_AQUICULTURA, ";
                    vFILTER = vFILTER + "LIVRE_VERDE, ";
                    vFILTER = vFILTER + "MICRO_GERACAO, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES, ";
                    vFILTER = vFILTER + "NOME_CONJUGE, ";
                    vFILTER = vFILTER + "LEITURA_ANTER_PONTA, ";
                    vFILTER = vFILTER + "LEITURA_ATUAL_PONTA, ";
                    vFILTER = vFILTER + "LEITURA_ANTER_INTER, ";
                    vFILTER = vFILTER + "LEITURA_ATUAL_INTER, ";
                    vFILTER = vFILTER + "LEITURA_ANTER_FORAP, ";
                    vFILTER = vFILTER + "LEITURA_ATUAL_FORAP, ";
                    vFILTER = vFILTER + "RESIDUO_PONTA, ";
                    vFILTER = vFILTER + "RESIDUO_INTER, ";
                    vFILTER = vFILTER + "RESIDUO_FORAP, ";
                    vFILTER = vFILTER + "TARIFA_BRANCA, ";
                    vFILTER = vFILTER + "CONSUMO_PONTA, ";
                    vFILTER = vFILTER + "CONSUMO_INTER, ";
                    vFILTER = vFILTER + "CONSUMO_FORAP, ";
                    vFILTER = vFILTER + "CONSUMORESERVADO, ";
                    vFILTER = vFILTER + "IDTIPO_BANDEIRA, ";
                    vFILTER = vFILTER + "LEITRESERVADOANT, ";
                    vFILTER = vFILTER + "LEITRESERVADOATU, ";
                    vFILTER = vFILTER + "PAGTO_GOVERNO, ";
                    vFILTER = vFILTER + "PERDAS, ";
                    vFILTER = vFILTER + "SALDO_ARRED, ";
                    vFILTER = vFILTER + "VLRCONSUMORESERVADO, ";
                    vFILTER = vFILTER + "SALDOACUMULADO, ";
                    vFILTER = vFILTER + "JSONDADOSSEFAZ ";


                    vINNERJOIN = " ";

                    vORDERBY = " ";

                    vAND = vAND + "AND ENVIADONF3E = ?ENVIADONF3E ";
                    vAND = vAND + "AND MESANOREF = ?MESANOREF ";

                    cmd = new MySqlCommand(this.QuerySelect);

                    cmd.Parameters.AddWithValue("?ENVIADONF3E", objTempFaturaNF3EB.ENVIADONF3E);
                    cmd.Parameters.AddWithValue("?MESANOREF", objTempFaturaNF3EB.MESANOREF);

                    dt = objGerenciadorTransacao.GetDataTable(cmd);

                }

                return dt;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (cmd != null)
                    cmd.Dispose();
            }
        }

        public DataTable Select_5(entidadeTempFaturaNF3EB objTempFaturaNF3EB)
        {
            DataTable dt = null;
            MySqlCommand cmd = null;
            IGerenciadorTransacao objGerenciadorTransacao = null;
            ConexaoBD objconexaoBD = null;

            try
            {
                objconexaoBD = new ConexaoBD();

                objconexaoBD.SetarConexaoBanco(TipoBDConexao.fat_BD);

                using (objGerenciadorTransacao = FabricaGerenciadorTransacao.GetGerenciador(TipoBDGerenciador.MySql))
                {
                    vFILTER = vFILTER + "NUMNF, ";
                    vFILTER = vFILTER + "CFOP, ";
                    vFILTER = vFILTER + "ZONA, ";
                    vFILTER = vFILTER + "LIVRO, ";
                    vFILTER = vFILTER + "CONTA, ";
                    vFILTER = vFILTER + "CONS_ID, ";
                    vFILTER = vFILTER + "UNID_ID, ";
                    vFILTER = vFILTER + "ROTA, ";
                    vFILTER = vFILTER + "AGENC, ";
                    vFILTER = vFILTER + "CC, ";
                    vFILTER = vFILTER + "VALORTOT, ";
                    vFILTER = vFILTER + "VLRCONSUTRIB, ";
                    vFILTER = vFILTER + "CODCLAS, ";
                    vFILTER = vFILTER + "DATAVENC, ";
                    vFILTER = vFILTER + "BANCO_FATUR, ";
                    vFILTER = vFILTER + "MESANO, ";
                    vFILTER = vFILTER + "NOMECONS, ";
                    vFILTER = vFILTER + "REFCONS, ";
                    vFILTER = vFILTER + "CGC, ";
                    vFILTER = vFILTER + "INSC, ";
                    vFILTER = vFILTER + "DATAAPR, ";
                    vFILTER = vFILTER + "DATAEMISSAO, ";
                    vFILTER = vFILTER + "DATAPROXLEIT, ";
                    vFILTER = vFILTER + "DATALEIT, ";
                    vFILTER = vFILTER + "DATALEITANT, ";
                    vFILTER = vFILTER + "NUM_MED, ";
                    vFILTER = vFILTER + "CONST_MED, ";
                    vFILTER = vFILTER + "FASE, ";
                    vFILTER = vFILTER + "CODHASH, ";
                    vFILTER = vFILTER + "LEIT, ";
                    vFILTER = vFILTER + "DESCCLASSE, ";
                    vFILTER = vFILTER + "CONSFATURADO, ";
                    vFILTER = vFILTER + "CONSLIDO, ";
                    vFILTER = vFILTER + "CONSRESIDUO, ";
                    vFILTER = vFILTER + "LEITURAANT, ";
                    vFILTER = vFILTER + "FP, ";
                    vFILTER = vFILTER + "BASEICMS, ";
                    vFILTER = vFILTER + "ALIQICMS, ";
                    vFILTER = vFILTER + "VLRICMS, ";
                    vFILTER = vFILTER + "BASEICMS1, ";
                    vFILTER = vFILTER + "ALIQICMS1, ";
                    vFILTER = vFILTER + "VLRICMS1, ";
                    vFILTER = vFILTER + "BASEICMSTOTAL, ";
                    vFILTER = vFILTER + "VLRICMSTOTAL, ";
                    vFILTER = vFILTER + "BASEPIS, ";
                    vFILTER = vFILTER + "ALIQPIS, ";
                    vFILTER = vFILTER + "VLRPIS, ";
                    vFILTER = vFILTER + "BASECOFINS, ";
                    vFILTER = vFILTER + "ALIQCOFINS, ";
                    vFILTER = vFILTER + "VLRCOFINS, ";
                    vFILTER = vFILTER + "DIASCONSUMO, ";
                    vFILTER = vFILTER + "VLRDIARIO, ";
                    vFILTER = vFILTER + "MEDIACONSUMODIARIO, ";
                    vFILTER = vFILTER + "MAIORCONSUMO, ";
                    vFILTER = vFILTER + "MEDIACONSUMO3MESES, ";
                    vFILTER = vFILTER + "OCORRENCIA, ";
                    vFILTER = vFILTER + "CODBARRA, ";
                    vFILTER = vFILTER + "DVCODBARRA, ";
                    vFILTER = vFILTER + "MENSAGEM, ";
                    vFILTER = vFILTER + "VALORPEND, ";
                    vFILTER = vFILTER + "TOTALPEND, ";
                    vFILTER = vFILTER + "DEC_META, ";
                    vFILTER = vFILTER + "DEC_REA, ";
                    vFILTER = vFILTER + "FEC_META, ";
                    vFILTER = vFILTER + "FEC_REA, ";
                    vFILTER = vFILTER + "DIC_META, ";
                    vFILTER = vFILTER + "DIC_REA, ";
                    vFILTER = vFILTER + "FIC_META, ";
                    vFILTER = vFILTER + "FIC_REA, ";
                    vFILTER = vFILTER + "DMIC, ";
                    vFILTER = vFILTER + "DMICM, ";
                    vFILTER = vFILTER + "DMIC_REA, ";
                    vFILTER = vFILTER + "REFINDICADOR, ";
                    vFILTER = vFILTER + "CIDADE, ";
                    vFILTER = vFILTER + "DISTRITO, ";
                    vFILTER = vFILTER + "BAIRRO, ";
                    vFILTER = vFILTER + "RUA, ";
                    vFILTER = vFILTER + "NUMERO, ";
                    vFILTER = vFILTER + "COMPLEMENT, ";
                    vFILTER = vFILTER + "CEP, ";
                    vFILTER = vFILTER + "UF, ";
                    vFILTER = vFILTER + "QUADRA, ";
                    vFILTER = vFILTER + "LOTE, ";
                    vFILTER = vFILTER + "ENTREGA, ";
                    vFILTER = vFILTER + "CID_ENTREGA, ";
                    vFILTER = vFILTER + "DIS_ENTREGA, ";
                    vFILTER = vFILTER + "BAI_ENTREGA, ";
                    vFILTER = vFILTER + "END_ENTREGA, ";
                    vFILTER = vFILTER + "NUM_ENTREGA, ";
                    vFILTER = vFILTER + "COMPL_ENTREGA, ";
                    vFILTER = vFILTER + "CEP_ENTREGA, ";
                    vFILTER = vFILTER + "UF_ENTREGA, ";
                    vFILTER = vFILTER + "QUA_ENTREGA, ";
                    vFILTER = vFILTER + "LOT_ENTREGA, ";
                    vFILTER = vFILTER + "CPF_CNPJ, ";
                    vFILTER = vFILTER + "RG_IE, ";
                    vFILTER = vFILTER + "TENSAO, ";
                    vFILTER = vFILTER + "GRUPO, ";
                    vFILTER = vFILTER + "TA, ";
                    vFILTER = vFILTER + "MESMAIORCONSUMO, ";
                    vFILTER = vFILTER + "MENORCONSUMO, ";
                    vFILTER = vFILTER + "MESMENORCONSUMO, ";
                    vFILTER = vFILTER + "ORDIMP, ";
                    vFILTER = vFILTER + "AUXIMP, ";
                    vFILTER = vFILTER + "LEITURA_KVARH_ANTERIOR, ";
                    vFILTER = vFILTER + "LEITURA_KVARH_ATUAL, ";
                    vFILTER = vFILTER + "CONSUMO_KVARH, ";
                    vFILTER = vFILTER + "CONJUNTO, ";
                    vFILTER = vFILTER + "BANIDENT, ";
                    vFILTER = vFILTER + "RET_IRPJ, ";
                    vFILTER = vFILTER + "RET_PIS, ";
                    vFILTER = vFILTER + "RET_CSLL, ";
                    vFILTER = vFILTER + "RET_COFINS, ";
                    vFILTER = vFILTER + "VALORLIQ, ";
                    vFILTER = vFILTER + "SEGVIA, ";
                    vFILTER = vFILTER + "NOMEMAQUINA, ";
                    vFILTER = vFILTER + "COMP_ENERGIA, ";
                    vFILTER = vFILTER + "COMP_TRANSMISSAO, ";
                    vFILTER = vFILTER + "COMP_DISTRIBUICAO, ";
                    vFILTER = vFILTER + "COMP_ENCARGOS_SETORIAIS, ";
                    vFILTER = vFILTER + "COMP_PERDAS, ";
                    vFILTER = vFILTER + "COMP_TRIBUTOS, ";
                    vFILTER = vFILTER + "COMP_OUTROS, ";
                    vFILTER = vFILTER + "VALORCONSUMO, ";
                    vFILTER = vFILTER + "ITENSIMP, ";
                    vFILTER = vFILTER + "MESANOREF, ";
                    vFILTER = vFILTER + "BANDEIRA, ";
                    vFILTER = vFILTER + "LEIT_IRRIGANTE_ATUAL, ";
                    vFILTER = vFILTER + "LEIT_REVERSO_ATUAL, ";
                    vFILTER = vFILTER + "LEIT_REVERSO_ANTER, ";
                    vFILTER = vFILTER + "KWH_REVERSO_RES, ";
                    vFILTER = vFILTER + "KWH_REVERSO_LID, ";
                    vFILTER = vFILTER + "KWH_REVERSO_FAT, ";
                    vFILTER = vFILTER + "MENSAGEM_BANDEIRA, ";
                    vFILTER = vFILTER + "LEIT_IRRIGANTE_ANTERIOR, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_LIDO, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_FATURADO, ";
                    vFILTER = vFILTER + "FRENTEVERSO, ";
                    vFILTER = vFILTER + "REAVISO_VECTO, ";
                    vFILTER = vFILTER + "REAVISO_NUMNF, ";
                    vFILTER = vFILTER + "REAVISO_VALOR, ";
                    vFILTER = vFILTER + "REAVISO_MESANO, ";
                    vFILTER = vFILTER + "REAVISO_IDENTIFICADOR, ";
                    vFILTER = vFILTER + "REAVISO_MENSAGEM, ";
                    vFILTER = vFILTER + "IRRIGACAO_AQUICULTURA, ";
                    vFILTER = vFILTER + "LIVRE_VERDE, ";
                    vFILTER = vFILTER + "MICRO_GERACAO, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES, ";
                    vFILTER = vFILTER + "NOME_CONJUGE, ";
                    vFILTER = vFILTER + "LEITURA_ANTER_PONTA, ";
                    vFILTER = vFILTER + "LEITURA_ATUAL_PONTA, ";
                    vFILTER = vFILTER + "LEITURA_ANTER_INTER, ";
                    vFILTER = vFILTER + "LEITURA_ATUAL_INTER, ";
                    vFILTER = vFILTER + "LEITURA_ANTER_FORAP, ";
                    vFILTER = vFILTER + "LEITURA_ATUAL_FORAP, ";
                    vFILTER = vFILTER + "RESIDUO_PONTA, ";
                    vFILTER = vFILTER + "RESIDUO_INTER, ";
                    vFILTER = vFILTER + "RESIDUO_FORAP, ";
                    vFILTER = vFILTER + "TARIFA_BRANCA, ";
                    vFILTER = vFILTER + "CONSUMO_PONTA, ";
                    vFILTER = vFILTER + "CONSUMO_INTER, ";
                    vFILTER = vFILTER + "CONSUMO_FORAP, ";
                    vFILTER = vFILTER + "CONSUMORESERVADO, ";
                    vFILTER = vFILTER + "IDTIPO_BANDEIRA, ";
                    vFILTER = vFILTER + "LEITRESERVADOANT, ";
                    vFILTER = vFILTER + "LEITRESERVADOATU, ";
                    vFILTER = vFILTER + "PAGTO_GOVERNO, ";
                    vFILTER = vFILTER + "PERDAS, ";
                    vFILTER = vFILTER + "SALDO_ARRED, ";
                    vFILTER = vFILTER + "VLRCONSUMORESERVADO, ";
                    vFILTER = vFILTER + "SALDOACUMULADO, ";
                    vFILTER = vFILTER + "JSONDADOSSEFAZ ";

                    vINNERJOIN = " ";

                    vORDERBY = " ";

                    vAND = vAND + " AND NUMNF IN (" + objTempFaturaNF3EB.LISTNUMNF + ") ";

                    cmd = new MySqlCommand(this.QuerySelect);

                    dt = objGerenciadorTransacao.GetDataTable(cmd);

                }

                return dt;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (cmd != null)
                    cmd.Dispose();
            }
        }

        public DataTable Select_6(entidadeTempFaturaNF3EB objTempFaturaNF3EB)
        {
            DataTable dt = null;
            MySqlCommand cmd = null;
            IGerenciadorTransacao objGerenciadorTransacao = null;
            ConexaoBD objconexaoBD = null;

            try
            {
                objconexaoBD = new ConexaoBD();

                objconexaoBD.SetarConexaoBanco(TipoBDConexao.fat_BD);

                using (objGerenciadorTransacao = FabricaGerenciadorTransacao.GetGerenciador(TipoBDGerenciador.MySql))
                {
                    vFILTER = vFILTER + "NUMNF, ";
                    vFILTER = vFILTER + "CFOP, ";
                    vFILTER = vFILTER + "ZONA, ";
                    vFILTER = vFILTER + "LIVRO, ";
                    vFILTER = vFILTER + "CONTA, ";
                    vFILTER = vFILTER + "CONS_ID, ";
                    vFILTER = vFILTER + "UNID_ID, ";
                    vFILTER = vFILTER + "ROTA, ";
                    vFILTER = vFILTER + "AGENC, ";
                    vFILTER = vFILTER + "CC, ";
                    vFILTER = vFILTER + "VALORTOT, ";
                    vFILTER = vFILTER + "VLRCONSUTRIB, ";
                    vFILTER = vFILTER + "CODCLAS, ";
                    vFILTER = vFILTER + "DATAVENC, ";
                    vFILTER = vFILTER + "BANCO_FATUR, ";
                    vFILTER = vFILTER + "MESANO, ";
                    vFILTER = vFILTER + "NOMECONS, ";
                    vFILTER = vFILTER + "REFCONS, ";
                    vFILTER = vFILTER + "CGC, ";
                    vFILTER = vFILTER + "INSC, ";
                    vFILTER = vFILTER + "DATAAPR, ";
                    vFILTER = vFILTER + "DATAEMISSAO, ";
                    vFILTER = vFILTER + "DATAPROXLEIT, ";
                    vFILTER = vFILTER + "DATALEIT, ";
                    vFILTER = vFILTER + "DATALEITANT, ";
                    vFILTER = vFILTER + "NUM_MED, ";
                    vFILTER = vFILTER + "CONST_MED, ";
                    vFILTER = vFILTER + "FASE, ";
                    vFILTER = vFILTER + "CODHASH, ";
                    vFILTER = vFILTER + "LEIT, ";
                    vFILTER = vFILTER + "DESCCLASSE, ";
                    vFILTER = vFILTER + "CONSFATURADO, ";
                    vFILTER = vFILTER + "CONSLIDO, ";
                    vFILTER = vFILTER + "CONSRESIDUO, ";
                    vFILTER = vFILTER + "LEITURAANT, ";
                    vFILTER = vFILTER + "FP, ";
                    vFILTER = vFILTER + "BASEICMS, ";
                    vFILTER = vFILTER + "ALIQICMS, ";
                    vFILTER = vFILTER + "VLRICMS, ";
                    vFILTER = vFILTER + "BASEICMS1, ";
                    vFILTER = vFILTER + "ALIQICMS1, ";
                    vFILTER = vFILTER + "VLRICMS1, ";
                    vFILTER = vFILTER + "BASEICMSTOTAL, ";
                    vFILTER = vFILTER + "VLRICMSTOTAL, ";
                    vFILTER = vFILTER + "BASEPIS, ";
                    vFILTER = vFILTER + "ALIQPIS, ";
                    vFILTER = vFILTER + "VLRPIS, ";
                    vFILTER = vFILTER + "BASECOFINS, ";
                    vFILTER = vFILTER + "ALIQCOFINS, ";
                    vFILTER = vFILTER + "VLRCOFINS, ";
                    vFILTER = vFILTER + "DIASCONSUMO, ";
                    vFILTER = vFILTER + "VLRDIARIO, ";
                    vFILTER = vFILTER + "MEDIACONSUMODIARIO, ";
                    vFILTER = vFILTER + "MAIORCONSUMO, ";
                    vFILTER = vFILTER + "MEDIACONSUMO3MESES, ";
                    vFILTER = vFILTER + "OCORRENCIA, ";
                    vFILTER = vFILTER + "CODBARRA, ";
                    vFILTER = vFILTER + "DVCODBARRA, ";
                    vFILTER = vFILTER + "MENSAGEM, ";
                    vFILTER = vFILTER + "VALORPEND, ";
                    vFILTER = vFILTER + "TOTALPEND, ";
                    vFILTER = vFILTER + "DEC_META, ";
                    vFILTER = vFILTER + "DEC_REA, ";
                    vFILTER = vFILTER + "FEC_META, ";
                    vFILTER = vFILTER + "FEC_REA, ";
                    vFILTER = vFILTER + "DIC_META, ";
                    vFILTER = vFILTER + "DIC_REA, ";
                    vFILTER = vFILTER + "FIC_META, ";
                    vFILTER = vFILTER + "FIC_REA, ";
                    vFILTER = vFILTER + "DMIC, ";
                    vFILTER = vFILTER + "DMICM, ";
                    vFILTER = vFILTER + "DMIC_REA, ";
                    vFILTER = vFILTER + "REFINDICADOR, ";
                    vFILTER = vFILTER + "CIDADE, ";
                    vFILTER = vFILTER + "DISTRITO, ";
                    vFILTER = vFILTER + "BAIRRO, ";
                    vFILTER = vFILTER + "RUA, ";
                    vFILTER = vFILTER + "NUMERO, ";
                    vFILTER = vFILTER + "COMPLEMENT, ";
                    vFILTER = vFILTER + "CEP, ";
                    vFILTER = vFILTER + "UF, ";
                    vFILTER = vFILTER + "QUADRA, ";
                    vFILTER = vFILTER + "LOTE, ";
                    vFILTER = vFILTER + "ENTREGA, ";
                    vFILTER = vFILTER + "CID_ENTREGA, ";
                    vFILTER = vFILTER + "DIS_ENTREGA, ";
                    vFILTER = vFILTER + "BAI_ENTREGA, ";
                    vFILTER = vFILTER + "END_ENTREGA, ";
                    vFILTER = vFILTER + "NUM_ENTREGA, ";
                    vFILTER = vFILTER + "COMPL_ENTREGA, ";
                    vFILTER = vFILTER + "CEP_ENTREGA, ";
                    vFILTER = vFILTER + "UF_ENTREGA, ";
                    vFILTER = vFILTER + "QUA_ENTREGA, ";
                    vFILTER = vFILTER + "LOT_ENTREGA, ";
                    vFILTER = vFILTER + "CPF_CNPJ, ";
                    vFILTER = vFILTER + "RG_IE, ";
                    vFILTER = vFILTER + "TENSAO, ";
                    vFILTER = vFILTER + "GRUPO, ";
                    vFILTER = vFILTER + "TA, ";
                    vFILTER = vFILTER + "MESMAIORCONSUMO, ";
                    vFILTER = vFILTER + "MENORCONSUMO, ";
                    vFILTER = vFILTER + "MESMENORCONSUMO, ";
                    vFILTER = vFILTER + "ORDIMP, ";
                    vFILTER = vFILTER + "AUXIMP, ";
                    vFILTER = vFILTER + "LEITURA_KVARH_ANTERIOR, ";
                    vFILTER = vFILTER + "LEITURA_KVARH_ATUAL, ";
                    vFILTER = vFILTER + "CONSUMO_KVARH, ";
                    vFILTER = vFILTER + "CONJUNTO, ";
                    vFILTER = vFILTER + "BANIDENT, ";
                    vFILTER = vFILTER + "RET_IRPJ, ";
                    vFILTER = vFILTER + "RET_PIS, ";
                    vFILTER = vFILTER + "RET_CSLL, ";
                    vFILTER = vFILTER + "RET_COFINS, ";
                    vFILTER = vFILTER + "VALORLIQ, ";
                    vFILTER = vFILTER + "SEGVIA, ";
                    vFILTER = vFILTER + "NOMEMAQUINA, ";
                    vFILTER = vFILTER + "COMP_ENERGIA, ";
                    vFILTER = vFILTER + "COMP_TRANSMISSAO, ";
                    vFILTER = vFILTER + "COMP_DISTRIBUICAO, ";
                    vFILTER = vFILTER + "COMP_ENCARGOS_SETORIAIS, ";
                    vFILTER = vFILTER + "COMP_PERDAS, ";
                    vFILTER = vFILTER + "COMP_TRIBUTOS, ";
                    vFILTER = vFILTER + "COMP_OUTROS, ";
                    vFILTER = vFILTER + "VALORCONSUMO, ";
                    vFILTER = vFILTER + "ITENSIMP, ";
                    vFILTER = vFILTER + "MESANOREF, ";
                    vFILTER = vFILTER + "BANDEIRA, ";
                    vFILTER = vFILTER + "LEIT_IRRIGANTE_ATUAL, ";
                    vFILTER = vFILTER + "LEIT_REVERSO_ATUAL, ";
                    vFILTER = vFILTER + "LEIT_REVERSO_ANTER, ";
                    vFILTER = vFILTER + "KWH_REVERSO_RES, ";
                    vFILTER = vFILTER + "KWH_REVERSO_LID, ";
                    vFILTER = vFILTER + "KWH_REVERSO_FAT, ";
                    vFILTER = vFILTER + "MENSAGEM_BANDEIRA, ";
                    vFILTER = vFILTER + "LEIT_IRRIGANTE_ANTERIOR, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_LIDO, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_FATURADO, ";
                    vFILTER = vFILTER + "FRENTEVERSO, ";
                    vFILTER = vFILTER + "REAVISO_VECTO, ";
                    vFILTER = vFILTER + "REAVISO_NUMNF, ";
                    vFILTER = vFILTER + "REAVISO_VALOR, ";
                    vFILTER = vFILTER + "REAVISO_MESANO, ";
                    vFILTER = vFILTER + "REAVISO_IDENTIFICADOR, ";
                    vFILTER = vFILTER + "REAVISO_MENSAGEM, ";
                    vFILTER = vFILTER + "IRRIGACAO_AQUICULTURA, ";
                    vFILTER = vFILTER + "LIVRE_VERDE, ";
                    vFILTER = vFILTER + "MICRO_GERACAO, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES, ";
                    vFILTER = vFILTER + "NOME_CONJUGE, ";
                    vFILTER = vFILTER + "LEITURA_ANTER_PONTA, ";
                    vFILTER = vFILTER + "LEITURA_ATUAL_PONTA, ";
                    vFILTER = vFILTER + "LEITURA_ANTER_INTER, ";
                    vFILTER = vFILTER + "LEITURA_ATUAL_INTER, ";
                    vFILTER = vFILTER + "LEITURA_ANTER_FORAP, ";
                    vFILTER = vFILTER + "LEITURA_ATUAL_FORAP, ";
                    vFILTER = vFILTER + "RESIDUO_PONTA, ";
                    vFILTER = vFILTER + "RESIDUO_INTER, ";
                    vFILTER = vFILTER + "RESIDUO_FORAP, ";
                    vFILTER = vFILTER + "TARIFA_BRANCA, ";
                    vFILTER = vFILTER + "CONSUMO_PONTA, ";
                    vFILTER = vFILTER + "CONSUMO_INTER, ";
                    vFILTER = vFILTER + "CONSUMO_FORAP, ";
                    vFILTER = vFILTER + "CONSUMORESERVADO, ";
                    vFILTER = vFILTER + "IDTIPO_BANDEIRA, ";
                    vFILTER = vFILTER + "LEITRESERVADOANT, ";
                    vFILTER = vFILTER + "LEITRESERVADOATU, ";
                    vFILTER = vFILTER + "PAGTO_GOVERNO, ";
                    vFILTER = vFILTER + "PERDAS, ";
                    vFILTER = vFILTER + "SALDO_ARRED, ";
                    vFILTER = vFILTER + "VLRCONSUMORESERVADO, ";
                    vFILTER = vFILTER + "SALDOACUMULADO, ";
                    vFILTER = vFILTER + "JSONDADOSSEFAZ, ";
                    vFILTER = vFILTER + "JSONDADOSSEFAZ_ORI ";

                    vINNERJOIN = " ";

                    vORDERBY = " ";

                    vAND = vAND + "AND ENVIADONF3E = ?ENVIADONF3E ";
                    vAND = vAND + "AND MESANOREF = ?MESANOREF ";

                    vAND = vAND + "AND NUMNF IN (" + objTempFaturaNF3EB.LISTNUMNF + ") ";

                    cmd = new MySqlCommand(this.QuerySelect);

                    cmd.Parameters.AddWithValue("?ENVIADONF3E", objTempFaturaNF3EB.ENVIADONF3E);
                    cmd.Parameters.AddWithValue("?MESANOREF", objTempFaturaNF3EB.MESANOREF);

                    dt = objGerenciadorTransacao.GetDataTable(cmd);

                }

                return dt;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (cmd != null)
                    cmd.Dispose();
            }
        }

        public DataTable Select_7(entidadeTempFaturaNF3EB objTempFaturaNF3EB)
        {
            DataTable dt = null;
            MySqlCommand cmd = null;
            IGerenciadorTransacao objGerenciadorTransacao = null;
            ConexaoBD objconexaoBD = null;

            try
            {
                objconexaoBD = new ConexaoBD();

                objconexaoBD.SetarConexaoBanco(TipoBDConexao.fat_BD);

                using (objGerenciadorTransacao = FabricaGerenciadorTransacao.GetGerenciador(TipoBDGerenciador.MySql))
                {
                    vFILTER = vFILTER + "NUMNF, ";
                    vFILTER = vFILTER + "CFOP, ";
                    vFILTER = vFILTER + "ZONA, ";
                    vFILTER = vFILTER + "LIVRO, ";
                    vFILTER = vFILTER + "CONTA, ";
                    vFILTER = vFILTER + "CONS_ID, ";
                    vFILTER = vFILTER + "UNID_ID, ";
                    vFILTER = vFILTER + "ROTA, ";
                    vFILTER = vFILTER + "AGENC, ";
                    vFILTER = vFILTER + "CC, ";
                    vFILTER = vFILTER + "VALORTOT, ";
                    vFILTER = vFILTER + "VLRCONSUTRIB, ";
                    vFILTER = vFILTER + "CODCLAS, ";
                    vFILTER = vFILTER + "DATAVENC, ";
                    vFILTER = vFILTER + "BANCO_FATUR, ";
                    vFILTER = vFILTER + "MESANO, ";
                    vFILTER = vFILTER + "NOMECONS, ";
                    vFILTER = vFILTER + "REFCONS, ";
                    vFILTER = vFILTER + "CGC, ";
                    vFILTER = vFILTER + "INSC, ";
                    vFILTER = vFILTER + "DATAAPR, ";
                    vFILTER = vFILTER + "DATAEMISSAO, ";
                    vFILTER = vFILTER + "DATAPROXLEIT, ";
                    vFILTER = vFILTER + "DATALEIT, ";
                    vFILTER = vFILTER + "DATALEITANT, ";
                    vFILTER = vFILTER + "NUM_MED, ";
                    vFILTER = vFILTER + "CONST_MED, ";
                    vFILTER = vFILTER + "FASE, ";
                    vFILTER = vFILTER + "CODHASH, ";
                    vFILTER = vFILTER + "LEIT, ";
                    vFILTER = vFILTER + "DESCCLASSE, ";
                    vFILTER = vFILTER + "CONSFATURADO, ";
                    vFILTER = vFILTER + "CONSLIDO, ";
                    vFILTER = vFILTER + "CONSRESIDUO, ";
                    vFILTER = vFILTER + "LEITURAANT, ";
                    vFILTER = vFILTER + "FP, ";
                    vFILTER = vFILTER + "BASEICMS, ";
                    vFILTER = vFILTER + "ALIQICMS, ";
                    vFILTER = vFILTER + "VLRICMS, ";
                    vFILTER = vFILTER + "BASEICMS1, ";
                    vFILTER = vFILTER + "ALIQICMS1, ";
                    vFILTER = vFILTER + "VLRICMS1, ";
                    vFILTER = vFILTER + "BASEICMSTOTAL, ";
                    vFILTER = vFILTER + "VLRICMSTOTAL, ";
                    vFILTER = vFILTER + "BASEPIS, ";
                    vFILTER = vFILTER + "ALIQPIS, ";
                    vFILTER = vFILTER + "VLRPIS, ";
                    vFILTER = vFILTER + "BASECOFINS, ";
                    vFILTER = vFILTER + "ALIQCOFINS, ";
                    vFILTER = vFILTER + "VLRCOFINS, ";
                    vFILTER = vFILTER + "DIASCONSUMO, ";
                    vFILTER = vFILTER + "VLRDIARIO, ";
                    vFILTER = vFILTER + "MEDIACONSUMODIARIO, ";
                    vFILTER = vFILTER + "MAIORCONSUMO, ";
                    vFILTER = vFILTER + "MEDIACONSUMO3MESES, ";
                    vFILTER = vFILTER + "OCORRENCIA, ";
                    vFILTER = vFILTER + "CODBARRA, ";
                    vFILTER = vFILTER + "DVCODBARRA, ";
                    vFILTER = vFILTER + "MENSAGEM, ";
                    vFILTER = vFILTER + "VALORPEND, ";
                    vFILTER = vFILTER + "TOTALPEND, ";
                    vFILTER = vFILTER + "DEC_META, ";
                    vFILTER = vFILTER + "DEC_REA, ";
                    vFILTER = vFILTER + "FEC_META, ";
                    vFILTER = vFILTER + "FEC_REA, ";
                    vFILTER = vFILTER + "DIC_META, ";
                    vFILTER = vFILTER + "DIC_REA, ";
                    vFILTER = vFILTER + "FIC_META, ";
                    vFILTER = vFILTER + "FIC_REA, ";
                    vFILTER = vFILTER + "DMIC, ";
                    vFILTER = vFILTER + "DMICM, ";
                    vFILTER = vFILTER + "DMIC_REA, ";
                    vFILTER = vFILTER + "REFINDICADOR, ";
                    vFILTER = vFILTER + "CIDADE, ";
                    vFILTER = vFILTER + "DISTRITO, ";
                    vFILTER = vFILTER + "BAIRRO, ";
                    vFILTER = vFILTER + "RUA, ";
                    vFILTER = vFILTER + "NUMERO, ";
                    vFILTER = vFILTER + "COMPLEMENT, ";
                    vFILTER = vFILTER + "CEP, ";
                    vFILTER = vFILTER + "UF, ";
                    vFILTER = vFILTER + "QUADRA, ";
                    vFILTER = vFILTER + "LOTE, ";
                    vFILTER = vFILTER + "ENTREGA, ";
                    vFILTER = vFILTER + "CID_ENTREGA, ";
                    vFILTER = vFILTER + "DIS_ENTREGA, ";
                    vFILTER = vFILTER + "BAI_ENTREGA, ";
                    vFILTER = vFILTER + "END_ENTREGA, ";
                    vFILTER = vFILTER + "NUM_ENTREGA, ";
                    vFILTER = vFILTER + "COMPL_ENTREGA, ";
                    vFILTER = vFILTER + "CEP_ENTREGA, ";
                    vFILTER = vFILTER + "UF_ENTREGA, ";
                    vFILTER = vFILTER + "QUA_ENTREGA, ";
                    vFILTER = vFILTER + "LOT_ENTREGA, ";
                    vFILTER = vFILTER + "CPF_CNPJ, ";
                    vFILTER = vFILTER + "RG_IE, ";
                    vFILTER = vFILTER + "TENSAO, ";
                    vFILTER = vFILTER + "GRUPO, ";
                    vFILTER = vFILTER + "TA, ";
                    vFILTER = vFILTER + "MESMAIORCONSUMO, ";
                    vFILTER = vFILTER + "MENORCONSUMO, ";
                    vFILTER = vFILTER + "MESMENORCONSUMO, ";
                    vFILTER = vFILTER + "ORDIMP, ";
                    vFILTER = vFILTER + "AUXIMP, ";
                    vFILTER = vFILTER + "LEITURA_KVARH_ANTERIOR, ";
                    vFILTER = vFILTER + "LEITURA_KVARH_ATUAL, ";
                    vFILTER = vFILTER + "CONSUMO_KVARH, ";
                    vFILTER = vFILTER + "CONJUNTO, ";
                    vFILTER = vFILTER + "BANIDENT, ";
                    vFILTER = vFILTER + "RET_IRPJ, ";
                    vFILTER = vFILTER + "RET_PIS, ";
                    vFILTER = vFILTER + "RET_CSLL, ";
                    vFILTER = vFILTER + "RET_COFINS, ";
                    vFILTER = vFILTER + "VALORLIQ, ";
                    vFILTER = vFILTER + "SEGVIA, ";
                    vFILTER = vFILTER + "NOMEMAQUINA, ";
                    vFILTER = vFILTER + "COMP_ENERGIA, ";
                    vFILTER = vFILTER + "COMP_TRANSMISSAO, ";
                    vFILTER = vFILTER + "COMP_DISTRIBUICAO, ";
                    vFILTER = vFILTER + "COMP_ENCARGOS_SETORIAIS, ";
                    vFILTER = vFILTER + "COMP_PERDAS, ";
                    vFILTER = vFILTER + "COMP_TRIBUTOS, ";
                    vFILTER = vFILTER + "COMP_OUTROS, ";
                    vFILTER = vFILTER + "VALORCONSUMO, ";
                    vFILTER = vFILTER + "ITENSIMP, ";
                    vFILTER = vFILTER + "MESANOREF, ";
                    vFILTER = vFILTER + "BANDEIRA, ";
                    vFILTER = vFILTER + "LEIT_IRRIGANTE_ATUAL, ";
                    vFILTER = vFILTER + "LEIT_REVERSO_ATUAL, ";
                    vFILTER = vFILTER + "LEIT_REVERSO_ANTER, ";
                    vFILTER = vFILTER + "KWH_REVERSO_RES, ";
                    vFILTER = vFILTER + "KWH_REVERSO_LID, ";
                    vFILTER = vFILTER + "KWH_REVERSO_FAT, ";
                    vFILTER = vFILTER + "MENSAGEM_BANDEIRA, ";
                    vFILTER = vFILTER + "LEIT_IRRIGANTE_ANTERIOR, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_LIDO, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_FATURADO, ";
                    vFILTER = vFILTER + "FRENTEVERSO, ";
                    vFILTER = vFILTER + "REAVISO_VECTO, ";
                    vFILTER = vFILTER + "REAVISO_NUMNF, ";
                    vFILTER = vFILTER + "REAVISO_VALOR, ";
                    vFILTER = vFILTER + "REAVISO_MESANO, ";
                    vFILTER = vFILTER + "REAVISO_IDENTIFICADOR, ";
                    vFILTER = vFILTER + "REAVISO_MENSAGEM, ";
                    vFILTER = vFILTER + "IRRIGACAO_AQUICULTURA, ";
                    vFILTER = vFILTER + "LIVRE_VERDE, ";
                    vFILTER = vFILTER + "MICRO_GERACAO, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES, ";
                    vFILTER = vFILTER + "NOME_CONJUGE, ";
                    vFILTER = vFILTER + "LEITURA_ANTER_PONTA, ";
                    vFILTER = vFILTER + "LEITURA_ATUAL_PONTA, ";
                    vFILTER = vFILTER + "LEITURA_ANTER_INTER, ";
                    vFILTER = vFILTER + "LEITURA_ATUAL_INTER, ";
                    vFILTER = vFILTER + "LEITURA_ANTER_FORAP, ";
                    vFILTER = vFILTER + "LEITURA_ATUAL_FORAP, ";
                    vFILTER = vFILTER + "RESIDUO_PONTA, ";
                    vFILTER = vFILTER + "RESIDUO_INTER, ";
                    vFILTER = vFILTER + "RESIDUO_FORAP, ";
                    vFILTER = vFILTER + "TARIFA_BRANCA, ";
                    vFILTER = vFILTER + "CONSUMO_PONTA, ";
                    vFILTER = vFILTER + "CONSUMO_INTER, ";
                    vFILTER = vFILTER + "CONSUMO_FORAP, ";
                    vFILTER = vFILTER + "CONSUMORESERVADO, ";
                    vFILTER = vFILTER + "IDTIPO_BANDEIRA, ";
                    vFILTER = vFILTER + "LEITRESERVADOANT, ";
                    vFILTER = vFILTER + "LEITRESERVADOATU, ";
                    vFILTER = vFILTER + "PAGTO_GOVERNO, ";
                    vFILTER = vFILTER + "PERDAS, ";
                    vFILTER = vFILTER + "SALDO_ARRED, ";
                    vFILTER = vFILTER + "VLRCONSUMORESERVADO, ";
                    vFILTER = vFILTER + "SALDOACUMULADO ";

                    vINNERJOIN = " ";

                    vORDERBY = " ";

                    vAND = vAND + "AND MESANOREF = ?MESANOREF ";

                    vAND = vAND + "And enviadonf3e = 0 ";

                    // vAND = vAND + "and numnf in (115) ";

                    // vAND = vAND + "LIMIT 20 ";

                    cmd = new MySqlCommand(this.QuerySelect);

                    cmd.Parameters.AddWithValue("?ENVIADONF3E", objTempFaturaNF3EB.ENVIADONF3E);
                    cmd.Parameters.AddWithValue("?MESANOREF", objTempFaturaNF3EB.MESANOREF);

                    dt = objGerenciadorTransacao.GetDataTable(cmd);

                }

                return dt;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (cmd != null)
                    cmd.Dispose();
            }
        }

        public DataTable Select_8(entidadeTempFaturaNF3EB objTempFaturaNF3EB)
        {
            DataTable dt = null;
            MySqlCommand cmd = null;
            IGerenciadorTransacao objGerenciadorTransacao = null;
            ConexaoBD objconexaoBD = null;

            try
            {
                objconexaoBD = new ConexaoBD();

                objconexaoBD.SetarConexaoBanco(TipoBDConexao.fatwin_BD);

                using (objGerenciadorTransacao = FabricaGerenciadorTransacao.GetGerenciador(TipoBDGerenciador.MySql))
                {
                    vFILTER = vFILTER + "NUMNF, ";
                    vFILTER = vFILTER + "CFOP, ";
                    vFILTER = vFILTER + "ZONA, ";
                    vFILTER = vFILTER + "LIVRO, ";
                    vFILTER = vFILTER + "CONTA, ";
                    vFILTER = vFILTER + "CONS_ID, ";
                    vFILTER = vFILTER + "UNID_ID, ";
                    vFILTER = vFILTER + "ROTA, ";
                    vFILTER = vFILTER + "AGENC, ";
                    vFILTER = vFILTER + "CC, ";
                    vFILTER = vFILTER + "VALORTOT, ";
                    vFILTER = vFILTER + "VLRCONSUTRIB, ";
                    vFILTER = vFILTER + "CODCLAS, ";
                    vFILTER = vFILTER + "DATAVENC, ";
                    vFILTER = vFILTER + "BANCO_FATUR, ";
                    vFILTER = vFILTER + "MESANO, ";
                    vFILTER = vFILTER + "NOMECONS, ";
                    vFILTER = vFILTER + "REFCONS, ";
                    vFILTER = vFILTER + "CGC, ";
                    vFILTER = vFILTER + "INSC, ";
                    vFILTER = vFILTER + "DATAAPR, ";
                    vFILTER = vFILTER + "DATAEMISSAO, ";
                    vFILTER = vFILTER + "DATAPROXLEIT, ";
                    vFILTER = vFILTER + "DATALEIT, ";
                    vFILTER = vFILTER + "DATALEITANT, ";
                    vFILTER = vFILTER + "NUM_MED, ";
                    vFILTER = vFILTER + "CONST_MED, ";
                    vFILTER = vFILTER + "FASE, ";
                    vFILTER = vFILTER + "CODHASH, ";
                    vFILTER = vFILTER + "LEIT, ";
                    vFILTER = vFILTER + "DESCCLASSE, ";
                    vFILTER = vFILTER + "CONSFATURADO, ";
                    vFILTER = vFILTER + "CONSLIDO, ";
                    vFILTER = vFILTER + "CONSRESIDUO, ";
                    vFILTER = vFILTER + "LEITURAANT, ";
                    vFILTER = vFILTER + "FP, ";
                    vFILTER = vFILTER + "BASEICMS, ";
                    vFILTER = vFILTER + "ALIQICMS, ";
                    vFILTER = vFILTER + "VLRICMS, ";
                    vFILTER = vFILTER + "BASEICMS1, ";
                    vFILTER = vFILTER + "ALIQICMS1, ";
                    vFILTER = vFILTER + "VLRICMS1, ";
                    vFILTER = vFILTER + "BASEICMSTOTAL, ";
                    vFILTER = vFILTER + "VLRICMSTOTAL, ";
                    vFILTER = vFILTER + "BASEPIS, ";
                    vFILTER = vFILTER + "ALIQPIS, ";
                    vFILTER = vFILTER + "VLRPIS, ";
                    vFILTER = vFILTER + "BASECOFINS, ";
                    vFILTER = vFILTER + "ALIQCOFINS, ";
                    vFILTER = vFILTER + "VLRCOFINS, ";
                    vFILTER = vFILTER + "DIASCONSUMO, ";
                    vFILTER = vFILTER + "VLRDIARIO, ";
                    vFILTER = vFILTER + "MEDIACONSUMODIARIO, ";
                    vFILTER = vFILTER + "MAIORCONSUMO, ";
                    vFILTER = vFILTER + "MEDIACONSUMO3MESES, ";
                    vFILTER = vFILTER + "OCORRENCIA, ";
                    vFILTER = vFILTER + "CODBARRA, ";
                    vFILTER = vFILTER + "DVCODBARRA, ";
                    vFILTER = vFILTER + "MENSAGEM, ";
                    vFILTER = vFILTER + "VALORPEND, ";
                    vFILTER = vFILTER + "TOTALPEND, ";
                    vFILTER = vFILTER + "DEC_META, ";
                    vFILTER = vFILTER + "DEC_REA, ";
                    vFILTER = vFILTER + "FEC_META, ";
                    vFILTER = vFILTER + "FEC_REA, ";
                    vFILTER = vFILTER + "DIC_META, ";
                    vFILTER = vFILTER + "DIC_REA, ";
                    vFILTER = vFILTER + "FIC_META, ";
                    vFILTER = vFILTER + "FIC_REA, ";
                    vFILTER = vFILTER + "DMIC, ";
                    vFILTER = vFILTER + "DMICM, ";
                    vFILTER = vFILTER + "DMIC_REA, ";
                    vFILTER = vFILTER + "REFINDICADOR, ";
                    vFILTER = vFILTER + "CIDADE, ";
                    vFILTER = vFILTER + "DISTRITO, ";
                    vFILTER = vFILTER + "BAIRRO, ";
                    vFILTER = vFILTER + "RUA, ";
                    vFILTER = vFILTER + "NUMERO, ";
                    vFILTER = vFILTER + "COMPLEMENT, ";
                    vFILTER = vFILTER + "CEP, ";
                    vFILTER = vFILTER + "UF, ";
                    vFILTER = vFILTER + "QUADRA, ";
                    vFILTER = vFILTER + "LOTE, ";
                    vFILTER = vFILTER + "ENTREGA, ";
                    vFILTER = vFILTER + "CID_ENTREGA, ";
                    vFILTER = vFILTER + "DIS_ENTREGA, ";
                    vFILTER = vFILTER + "BAI_ENTREGA, ";
                    vFILTER = vFILTER + "END_ENTREGA, ";
                    vFILTER = vFILTER + "NUM_ENTREGA, ";
                    vFILTER = vFILTER + "COMPL_ENTREGA, ";
                    vFILTER = vFILTER + "CEP_ENTREGA, ";
                    vFILTER = vFILTER + "UF_ENTREGA, ";
                    vFILTER = vFILTER + "QUA_ENTREGA, ";
                    vFILTER = vFILTER + "LOT_ENTREGA, ";
                    vFILTER = vFILTER + "CPF_CNPJ, ";
                    vFILTER = vFILTER + "RG_IE, ";
                    vFILTER = vFILTER + "TENSAO, ";
                    vFILTER = vFILTER + "GRUPO, ";
                    vFILTER = vFILTER + "TA, ";
                    vFILTER = vFILTER + "MESMAIORCONSUMO, ";
                    vFILTER = vFILTER + "MENORCONSUMO, ";
                    vFILTER = vFILTER + "MESMENORCONSUMO, ";
                    vFILTER = vFILTER + "ORDIMP, ";
                    vFILTER = vFILTER + "AUXIMP, ";
                    vFILTER = vFILTER + "LEITURA_KVARH_ANTERIOR, ";
                    vFILTER = vFILTER + "LEITURA_KVARH_ATUAL, ";
                    vFILTER = vFILTER + "CONSUMO_KVARH, ";
                    vFILTER = vFILTER + "CONJUNTO, ";
                    vFILTER = vFILTER + "BANIDENT, ";
                    vFILTER = vFILTER + "RET_IRPJ, ";
                    vFILTER = vFILTER + "RET_PIS, ";
                    vFILTER = vFILTER + "RET_CSLL, ";
                    vFILTER = vFILTER + "RET_COFINS, ";
                    vFILTER = vFILTER + "VALORLIQ, ";
                    vFILTER = vFILTER + "SEGVIA, ";
                    vFILTER = vFILTER + "NOMEMAQUINA, ";
                    vFILTER = vFILTER + "COMP_ENERGIA, ";
                    vFILTER = vFILTER + "COMP_TRANSMISSAO, ";
                    vFILTER = vFILTER + "COMP_DISTRIBUICAO, ";
                    vFILTER = vFILTER + "COMP_ENCARGOS_SETORIAIS, ";
                    vFILTER = vFILTER + "COMP_PERDAS, ";
                    vFILTER = vFILTER + "COMP_TRIBUTOS, ";
                    vFILTER = vFILTER + "COMP_OUTROS, ";
                    vFILTER = vFILTER + "VALORCONSUMO, ";
                    vFILTER = vFILTER + "ITENSIMP, ";
                    vFILTER = vFILTER + "MESANOREF, ";
                    vFILTER = vFILTER + "BANDEIRA, ";
                    vFILTER = vFILTER + "LEIT_IRRIGANTE_ATUAL, ";
                    vFILTER = vFILTER + "LEIT_REVERSO_ATUAL, ";
                    vFILTER = vFILTER + "LEIT_REVERSO_ANTER, ";
                    vFILTER = vFILTER + "KWH_REVERSO_RES, ";
                    vFILTER = vFILTER + "KWH_REVERSO_LID, ";
                    vFILTER = vFILTER + "KWH_REVERSO_FAT, ";
                    vFILTER = vFILTER + "MENSAGEM_BANDEIRA, ";
                    vFILTER = vFILTER + "LEIT_IRRIGANTE_ANTERIOR, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_LIDO, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_FATURADO, ";
                    vFILTER = vFILTER + "FRENTEVERSO, ";
                    vFILTER = vFILTER + "REAVISO_VECTO, ";
                    vFILTER = vFILTER + "REAVISO_NUMNF, ";
                    vFILTER = vFILTER + "REAVISO_VALOR, ";
                    vFILTER = vFILTER + "REAVISO_MESANO, ";
                    vFILTER = vFILTER + "REAVISO_IDENTIFICADOR, ";
                    vFILTER = vFILTER + "REAVISO_MENSAGEM, ";
                    vFILTER = vFILTER + "IRRIGACAO_AQUICULTURA, ";
                    vFILTER = vFILTER + "LIVRE_VERDE, ";
                    vFILTER = vFILTER + "MICRO_GERACAO, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES, ";
                    vFILTER = vFILTER + "NOME_CONJUGE, ";
                    vFILTER = vFILTER + "LEITURA_ANTER_PONTA, ";
                    vFILTER = vFILTER + "LEITURA_ATUAL_PONTA, ";
                    vFILTER = vFILTER + "LEITURA_ANTER_INTER, ";
                    vFILTER = vFILTER + "LEITURA_ATUAL_INTER, ";
                    vFILTER = vFILTER + "LEITURA_ANTER_FORAP, ";
                    vFILTER = vFILTER + "LEITURA_ATUAL_FORAP, ";
                    vFILTER = vFILTER + "RESIDUO_PONTA, ";
                    vFILTER = vFILTER + "RESIDUO_INTER, ";
                    vFILTER = vFILTER + "RESIDUO_FORAP, ";
                    vFILTER = vFILTER + "TARIFA_BRANCA, ";
                    vFILTER = vFILTER + "CONSUMO_PONTA, ";
                    vFILTER = vFILTER + "CONSUMO_INTER, ";
                    vFILTER = vFILTER + "CONSUMO_FORAP, ";
                    vFILTER = vFILTER + "CONSUMORESERVADO, ";
                    vFILTER = vFILTER + "IDTIPO_BANDEIRA, ";
                    vFILTER = vFILTER + "LEITRESERVADOANT, ";
                    vFILTER = vFILTER + "LEITRESERVADOATU, ";
                    vFILTER = vFILTER + "PAGTO_GOVERNO, ";
                    vFILTER = vFILTER + "PERDAS, ";
                    vFILTER = vFILTER + "SALDO_ARRED, ";
                    vFILTER = vFILTER + "VLRCONSUMORESERVADO, ";
                    vFILTER = vFILTER + "SALDOACUMULADO ";

                    vINNERJOIN = " ";

                    vORDERBY = " ";

                    vAND = vAND + "AND MESANOREF = ?MESANOREF ";

                    vAND = vAND + "And enviadonf3e = 0 ";

                     // vAND = vAND + "and numnf in (673083,673745,673798) ";

                    // vAND = vAND + "LIMIT 20 ";

                    cmd = new MySqlCommand(this.QuerySelectNovo);

                    cmd.Parameters.AddWithValue("?ENVIADONF3E", objTempFaturaNF3EB.ENVIADONF3E);
                    cmd.Parameters.AddWithValue("?MESANOREF", objTempFaturaNF3EB.MESANOREF);

                    dt = objGerenciadorTransacao.GetDataTable(cmd);

                }

                return dt;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (cmd != null)
                    cmd.Dispose();
            }
        }

        public DataTable Select_9(entidadeTempFaturaNF3EB objTempFaturaNF3EB)
        {
            DataTable dt = null;
            MySqlCommand cmd = null;
            IGerenciadorTransacao objGerenciadorTransacao = null;
            ConexaoBD objconexaoBD = null;

            try
            {
                objconexaoBD = new ConexaoBD();

                objconexaoBD.SetarConexaoBanco(TipoBDConexao.fatwin_BD);

                using (objGerenciadorTransacao = FabricaGerenciadorTransacao.GetGerenciador(TipoBDGerenciador.MySql))
                {
                    vFILTER = vFILTER + "NUMNF, ";
                    vFILTER = vFILTER + "CFOP, ";
                    vFILTER = vFILTER + "ZONA, ";
                    vFILTER = vFILTER + "LIVRO, ";
                    vFILTER = vFILTER + "CONTA, ";
                    vFILTER = vFILTER + "CONS_ID, ";
                    vFILTER = vFILTER + "UNID_ID, ";
                    vFILTER = vFILTER + "ROTA, ";
                    vFILTER = vFILTER + "AGENC, ";
                    vFILTER = vFILTER + "CC, ";
                    vFILTER = vFILTER + "VALORTOT, ";
                    vFILTER = vFILTER + "VLRCONSUTRIB, ";
                    vFILTER = vFILTER + "CODCLAS, ";
                    vFILTER = vFILTER + "DATAVENC, ";
                    vFILTER = vFILTER + "BANCO_FATUR, ";
                    vFILTER = vFILTER + "MESANO, ";
                    vFILTER = vFILTER + "NOMECONS, ";
                    vFILTER = vFILTER + "REFCONS, ";
                    vFILTER = vFILTER + "CGC, ";
                    vFILTER = vFILTER + "INSC, ";
                    vFILTER = vFILTER + "DATAAPR, ";
                    vFILTER = vFILTER + "DATAEMISSAO, ";
                    vFILTER = vFILTER + "DATAPROXLEIT, ";
                    vFILTER = vFILTER + "DATALEIT, ";
                    vFILTER = vFILTER + "DATALEITANT, ";
                    vFILTER = vFILTER + "NUM_MED, ";
                    vFILTER = vFILTER + "CONST_MED, ";
                    vFILTER = vFILTER + "FASE, ";
                    vFILTER = vFILTER + "CODHASH, ";
                    vFILTER = vFILTER + "LEIT, ";
                    vFILTER = vFILTER + "DESCCLASSE, ";
                    vFILTER = vFILTER + "CONSFATURADO, ";
                    vFILTER = vFILTER + "CONSLIDO, ";
                    vFILTER = vFILTER + "CONSRESIDUO, ";
                    vFILTER = vFILTER + "LEITURAANT, ";
                    vFILTER = vFILTER + "FP, ";
                    vFILTER = vFILTER + "BASEICMS, ";
                    vFILTER = vFILTER + "ALIQICMS, ";
                    vFILTER = vFILTER + "VLRICMS, ";
                    vFILTER = vFILTER + "BASEICMS1, ";
                    vFILTER = vFILTER + "ALIQICMS1, ";
                    vFILTER = vFILTER + "VLRICMS1, ";
                    vFILTER = vFILTER + "BASEICMSTOTAL, ";
                    vFILTER = vFILTER + "VLRICMSTOTAL, ";
                    vFILTER = vFILTER + "BASEPIS, ";
                    vFILTER = vFILTER + "ALIQPIS, ";
                    vFILTER = vFILTER + "VLRPIS, ";
                    vFILTER = vFILTER + "BASECOFINS, ";
                    vFILTER = vFILTER + "ALIQCOFINS, ";
                    vFILTER = vFILTER + "VLRCOFINS, ";
                    vFILTER = vFILTER + "DIASCONSUMO, ";
                    vFILTER = vFILTER + "VLRDIARIO, ";
                    vFILTER = vFILTER + "MEDIACONSUMODIARIO, ";
                    vFILTER = vFILTER + "MAIORCONSUMO, ";
                    vFILTER = vFILTER + "MEDIACONSUMO3MESES, ";
                    vFILTER = vFILTER + "OCORRENCIA, ";
                    vFILTER = vFILTER + "CODBARRA, ";
                    vFILTER = vFILTER + "DVCODBARRA, ";
                    vFILTER = vFILTER + "MENSAGEM, ";
                    vFILTER = vFILTER + "VALORPEND, ";
                    vFILTER = vFILTER + "TOTALPEND, ";
                    vFILTER = vFILTER + "DEC_META, ";
                    vFILTER = vFILTER + "DEC_REA, ";
                    vFILTER = vFILTER + "FEC_META, ";
                    vFILTER = vFILTER + "FEC_REA, ";
                    vFILTER = vFILTER + "DIC_META, ";
                    vFILTER = vFILTER + "DIC_REA, ";
                    vFILTER = vFILTER + "FIC_META, ";
                    vFILTER = vFILTER + "FIC_REA, ";
                    vFILTER = vFILTER + "DMIC, ";
                    vFILTER = vFILTER + "DMICM, ";
                    vFILTER = vFILTER + "DMIC_REA, ";
                    vFILTER = vFILTER + "REFINDICADOR, ";
                    vFILTER = vFILTER + "CIDADE, ";
                    vFILTER = vFILTER + "DISTRITO, ";
                    vFILTER = vFILTER + "BAIRRO, ";
                    vFILTER = vFILTER + "RUA, ";
                    vFILTER = vFILTER + "NUMERO, ";
                    vFILTER = vFILTER + "COMPLEMENT, ";
                    vFILTER = vFILTER + "CEP, ";
                    vFILTER = vFILTER + "UF, ";
                    vFILTER = vFILTER + "QUADRA, ";
                    vFILTER = vFILTER + "LOTE, ";
                    vFILTER = vFILTER + "ENTREGA, ";
                    vFILTER = vFILTER + "CID_ENTREGA, ";
                    vFILTER = vFILTER + "DIS_ENTREGA, ";
                    vFILTER = vFILTER + "BAI_ENTREGA, ";
                    vFILTER = vFILTER + "END_ENTREGA, ";
                    vFILTER = vFILTER + "NUM_ENTREGA, ";
                    vFILTER = vFILTER + "COMPL_ENTREGA, ";
                    vFILTER = vFILTER + "CEP_ENTREGA, ";
                    vFILTER = vFILTER + "UF_ENTREGA, ";
                    vFILTER = vFILTER + "QUA_ENTREGA, ";
                    vFILTER = vFILTER + "LOT_ENTREGA, ";
                    vFILTER = vFILTER + "CPF_CNPJ, ";
                    vFILTER = vFILTER + "RG_IE, ";
                    vFILTER = vFILTER + "TENSAO, ";
                    vFILTER = vFILTER + "GRUPO, ";
                    vFILTER = vFILTER + "TA, ";
                    vFILTER = vFILTER + "MESMAIORCONSUMO, ";
                    vFILTER = vFILTER + "MENORCONSUMO, ";
                    vFILTER = vFILTER + "MESMENORCONSUMO, ";
                    vFILTER = vFILTER + "ORDIMP, ";
                    vFILTER = vFILTER + "AUXIMP, ";
                    vFILTER = vFILTER + "LEITURA_KVARH_ANTERIOR, ";
                    vFILTER = vFILTER + "LEITURA_KVARH_ATUAL, ";
                    vFILTER = vFILTER + "CONSUMO_KVARH, ";
                    vFILTER = vFILTER + "CONJUNTO, ";
                    vFILTER = vFILTER + "BANIDENT, ";
                    vFILTER = vFILTER + "RET_IRPJ, ";
                    vFILTER = vFILTER + "RET_PIS, ";
                    vFILTER = vFILTER + "RET_CSLL, ";
                    vFILTER = vFILTER + "RET_COFINS, ";
                    vFILTER = vFILTER + "VALORLIQ, ";
                    vFILTER = vFILTER + "SEGVIA, ";
                    vFILTER = vFILTER + "NOMEMAQUINA, ";
                    vFILTER = vFILTER + "COMP_ENERGIA, ";
                    vFILTER = vFILTER + "COMP_TRANSMISSAO, ";
                    vFILTER = vFILTER + "COMP_DISTRIBUICAO, ";
                    vFILTER = vFILTER + "COMP_ENCARGOS_SETORIAIS, ";
                    vFILTER = vFILTER + "COMP_PERDAS, ";
                    vFILTER = vFILTER + "COMP_TRIBUTOS, ";
                    vFILTER = vFILTER + "COMP_OUTROS, ";
                    vFILTER = vFILTER + "VALORCONSUMO, ";
                    vFILTER = vFILTER + "ITENSIMP, ";
                    vFILTER = vFILTER + "MESANOREF, ";
                    vFILTER = vFILTER + "BANDEIRA, ";
                    vFILTER = vFILTER + "LEIT_IRRIGANTE_ATUAL, ";
                    vFILTER = vFILTER + "LEIT_REVERSO_ATUAL, ";
                    vFILTER = vFILTER + "LEIT_REVERSO_ANTER, ";
                    vFILTER = vFILTER + "KWH_REVERSO_RES, ";
                    vFILTER = vFILTER + "KWH_REVERSO_LID, ";
                    vFILTER = vFILTER + "KWH_REVERSO_FAT, ";
                    vFILTER = vFILTER + "MENSAGEM_BANDEIRA, ";
                    vFILTER = vFILTER + "LEIT_IRRIGANTE_ANTERIOR, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_LIDO, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_FATURADO, ";
                    vFILTER = vFILTER + "FRENTEVERSO, ";
                    vFILTER = vFILTER + "REAVISO_VECTO, ";
                    vFILTER = vFILTER + "REAVISO_NUMNF, ";
                    vFILTER = vFILTER + "REAVISO_VALOR, ";
                    vFILTER = vFILTER + "REAVISO_MESANO, ";
                    vFILTER = vFILTER + "REAVISO_IDENTIFICADOR, ";
                    vFILTER = vFILTER + "REAVISO_MENSAGEM, ";
                    vFILTER = vFILTER + "IRRIGACAO_AQUICULTURA, ";
                    vFILTER = vFILTER + "LIVRE_VERDE, ";
                    vFILTER = vFILTER + "MICRO_GERACAO, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES, ";
                    vFILTER = vFILTER + "NOME_CONJUGE, ";
                    vFILTER = vFILTER + "LEITURA_ANTER_PONTA, ";
                    vFILTER = vFILTER + "LEITURA_ATUAL_PONTA, ";
                    vFILTER = vFILTER + "LEITURA_ANTER_INTER, ";
                    vFILTER = vFILTER + "LEITURA_ATUAL_INTER, ";
                    vFILTER = vFILTER + "LEITURA_ANTER_FORAP, ";
                    vFILTER = vFILTER + "LEITURA_ATUAL_FORAP, ";
                    vFILTER = vFILTER + "RESIDUO_PONTA, ";
                    vFILTER = vFILTER + "RESIDUO_INTER, ";
                    vFILTER = vFILTER + "RESIDUO_FORAP, ";
                    vFILTER = vFILTER + "TARIFA_BRANCA, ";
                    vFILTER = vFILTER + "CONSUMO_PONTA, ";
                    vFILTER = vFILTER + "CONSUMO_INTER, ";
                    vFILTER = vFILTER + "CONSUMO_FORAP, ";
                    vFILTER = vFILTER + "CONSUMORESERVADO, ";
                    vFILTER = vFILTER + "IDTIPO_BANDEIRA, ";
                    vFILTER = vFILTER + "LEITRESERVADOANT, ";
                    vFILTER = vFILTER + "LEITRESERVADOATU, ";
                    vFILTER = vFILTER + "PAGTO_GOVERNO, ";
                    vFILTER = vFILTER + "PERDAS, ";
                    vFILTER = vFILTER + "SALDO_ARRED, ";
                    vFILTER = vFILTER + "VLRCONSUMORESERVADO, ";
                    vFILTER = vFILTER + "SALDOACUMULADO, ";
                    vFILTER = vFILTER + "JSONDADOSSEFAZ, ";
                    vFILTER = vFILTER + "JSONDADOSSEFAZ_ORI ";

                    vINNERJOIN = " ";

                    vORDERBY = " ";

                    vAND = vAND + "AND ENVIADONF3E = ?ENVIADONF3E ";
                    vAND = vAND + "AND MESANOREF = ?MESANOREF ";

                    vAND = vAND + "AND NUMNF IN (" + objTempFaturaNF3EB.LISTNUMNF + ") ";

                    cmd = new MySqlCommand(this.QuerySelect);

                    cmd.Parameters.AddWithValue("?ENVIADONF3E", objTempFaturaNF3EB.ENVIADONF3E);
                    cmd.Parameters.AddWithValue("?MESANOREF", objTempFaturaNF3EB.MESANOREF);

                    dt = objGerenciadorTransacao.GetDataTable(cmd);

                }

                return dt;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (cmd != null)
                    cmd.Dispose();
            }
        }

        public DataTable Select_10(entidadeTempFaturaNF3EB objTempFaturaNF3EB)
        {
            DataTable dt = null;
            MySqlCommand cmd = null;
            IGerenciadorTransacao objGerenciadorTransacao = null;
            ConexaoBD objconexaoBD = null;

            try
            {
                objconexaoBD = new ConexaoBD();

                objconexaoBD.SetarConexaoBanco(TipoBDConexao.fatwin_BD);

                using (objGerenciadorTransacao = FabricaGerenciadorTransacao.GetGerenciador(TipoBDGerenciador.MySql))
                {
                    vFILTER = vFILTER + "NUMNF, ";
                    vFILTER = vFILTER + "CFOP, ";
                    vFILTER = vFILTER + "ZONA, ";
                    vFILTER = vFILTER + "LIVRO, ";
                    vFILTER = vFILTER + "CONTA, ";
                    vFILTER = vFILTER + "CONS_ID, ";
                    vFILTER = vFILTER + "UNID_ID, ";
                    vFILTER = vFILTER + "ROTA, ";
                    vFILTER = vFILTER + "AGENC, ";
                    vFILTER = vFILTER + "CC, ";
                    vFILTER = vFILTER + "VALORTOT, ";
                    vFILTER = vFILTER + "VLRCONSUTRIB, ";
                    vFILTER = vFILTER + "CODCLAS, ";
                    vFILTER = vFILTER + "DATAVENC, ";
                    vFILTER = vFILTER + "BANCO_FATUR, ";
                    vFILTER = vFILTER + "MESANO, ";
                    vFILTER = vFILTER + "ANOMES_FAT, ";
                    vFILTER = vFILTER + "NOMECONS, ";
                    vFILTER = vFILTER + "REFCONS, ";
                    vFILTER = vFILTER + "CGC, ";
                    vFILTER = vFILTER + "INSC, ";
                    vFILTER = vFILTER + "DATAAPR, ";
                    vFILTER = vFILTER + "DATAEMISSAO, ";
                    vFILTER = vFILTER + "DATAPROXLEIT, ";
                    vFILTER = vFILTER + "DATALEIT, ";
                    vFILTER = vFILTER + "DATALEITANT, ";
                    vFILTER = vFILTER + "NUM_MED, ";
                    vFILTER = vFILTER + "CONST_MED, ";
                    vFILTER = vFILTER + "FASE, ";
                    vFILTER = vFILTER + "CODHASH, ";
                    vFILTER = vFILTER + "LEIT, ";
                    vFILTER = vFILTER + "DESCCLASSE, ";
                    vFILTER = vFILTER + "CONSFATURADO, ";
                    vFILTER = vFILTER + "CONSLIDO, ";
                    vFILTER = vFILTER + "CONSRESIDUO, ";
                    vFILTER = vFILTER + "LEITURAANT, ";
                    vFILTER = vFILTER + "FP, ";
                    vFILTER = vFILTER + "BASEICMS, ";
                    vFILTER = vFILTER + "ALIQICMS, ";
                    vFILTER = vFILTER + "VLRICMS, ";
                    vFILTER = vFILTER + "BASEICMS1, ";
                    vFILTER = vFILTER + "ALIQICMS1, ";
                    vFILTER = vFILTER + "VLRICMS1, ";
                    vFILTER = vFILTER + "BASEICMSTOTAL, ";
                    vFILTER = vFILTER + "VLRICMSTOTAL, ";
                    vFILTER = vFILTER + "BASEPIS, ";
                    vFILTER = vFILTER + "ALIQPIS, ";
                    vFILTER = vFILTER + "VLRPIS, ";
                    vFILTER = vFILTER + "BASECOFINS, ";
                    vFILTER = vFILTER + "ALIQCOFINS, ";
                    vFILTER = vFILTER + "VLRCOFINS, ";
                    vFILTER = vFILTER + "DIASCONSUMO, ";
                    vFILTER = vFILTER + "VLRDIARIO, ";
                    vFILTER = vFILTER + "MEDIACONSUMODIARIO, ";
                    vFILTER = vFILTER + "MAIORCONSUMO, ";
                    vFILTER = vFILTER + "MEDIACONSUMO3MESES, ";
                    vFILTER = vFILTER + "OCORRENCIA, ";
                    vFILTER = vFILTER + "CODBARRA, ";
                    vFILTER = vFILTER + "DVCODBARRA, ";
                    vFILTER = vFILTER + "MENSAGEM, ";
                    vFILTER = vFILTER + "VALORPEND, ";
                    vFILTER = vFILTER + "TOTALPEND, ";
                    vFILTER = vFILTER + "DEC_META, ";
                    vFILTER = vFILTER + "DEC_REA, ";
                    vFILTER = vFILTER + "FEC_META, ";
                    vFILTER = vFILTER + "FEC_REA, ";
                    vFILTER = vFILTER + "DIC_META, ";
                    vFILTER = vFILTER + "DIC_REA, ";
                    vFILTER = vFILTER + "FIC_META, ";
                    vFILTER = vFILTER + "FIC_REA, ";
                    vFILTER = vFILTER + "DMIC, ";
                    vFILTER = vFILTER + "DMICM, ";
                    vFILTER = vFILTER + "DMIC_REA, ";
                    vFILTER = vFILTER + "REFINDICADOR, ";
                    vFILTER = vFILTER + "CIDADE, ";
                    vFILTER = vFILTER + "DISTRITO, ";
                    vFILTER = vFILTER + "BAIRRO, ";
                    vFILTER = vFILTER + "RUA, ";
                    vFILTER = vFILTER + "NUMERO, ";
                    vFILTER = vFILTER + "COMPLEMENT, ";
                    vFILTER = vFILTER + "CEP, ";
                    vFILTER = vFILTER + "UF, ";
                    vFILTER = vFILTER + "QUADRA, ";
                    vFILTER = vFILTER + "LOTE, ";
                    vFILTER = vFILTER + "ENTREGA, ";
                    vFILTER = vFILTER + "CID_ENTREGA, ";
                    vFILTER = vFILTER + "DIS_ENTREGA, ";
                    vFILTER = vFILTER + "BAI_ENTREGA, ";
                    vFILTER = vFILTER + "END_ENTREGA, ";
                    vFILTER = vFILTER + "NUM_ENTREGA, ";
                    vFILTER = vFILTER + "COMPL_ENTREGA, ";
                    vFILTER = vFILTER + "CEP_ENTREGA, ";
                    vFILTER = vFILTER + "UF_ENTREGA, ";
                    vFILTER = vFILTER + "QUA_ENTREGA, ";
                    vFILTER = vFILTER + "LOT_ENTREGA, ";
                    vFILTER = vFILTER + "CPF_CNPJ, ";
                    vFILTER = vFILTER + "RG_IE, ";
                    vFILTER = vFILTER + "TENSAO, ";
                    vFILTER = vFILTER + "GRUPO, ";
                    vFILTER = vFILTER + "TA, ";
                    vFILTER = vFILTER + "MESMAIORCONSUMO, ";
                    vFILTER = vFILTER + "MENORCONSUMO, ";
                    vFILTER = vFILTER + "MESMENORCONSUMO, ";
                    vFILTER = vFILTER + "ORDIMP, ";
                    vFILTER = vFILTER + "AUXIMP, ";
                    vFILTER = vFILTER + "LEITURA_KVARH_ANTERIOR, ";
                    vFILTER = vFILTER + "LEITURA_KVARH_ATUAL, ";
                    vFILTER = vFILTER + "CONSUMO_KVARH, ";
                    vFILTER = vFILTER + "CONJUNTO, ";
                    vFILTER = vFILTER + "BANIDENT, ";
                    vFILTER = vFILTER + "RET_IRPJ, ";
                    vFILTER = vFILTER + "RET_PIS, ";
                    vFILTER = vFILTER + "RET_CSLL, ";
                    vFILTER = vFILTER + "RET_COFINS, ";
                    vFILTER = vFILTER + "VALORLIQ, ";
                    vFILTER = vFILTER + "SEGVIA, ";
                    vFILTER = vFILTER + "NOMEMAQUINA, ";
                    vFILTER = vFILTER + "COMP_ENERGIA, ";
                    vFILTER = vFILTER + "COMP_TRANSMISSAO, ";
                    vFILTER = vFILTER + "COMP_DISTRIBUICAO, ";
                    vFILTER = vFILTER + "COMP_ENCARGOS_SETORIAIS, ";
                    vFILTER = vFILTER + "COMP_PERDAS, ";
                    vFILTER = vFILTER + "COMP_TRIBUTOS, ";
                    vFILTER = vFILTER + "COMP_OUTROS, ";
                    vFILTER = vFILTER + "VALORCONSUMO, ";
                    vFILTER = vFILTER + "ITENSIMP, ";
                    vFILTER = vFILTER + "MESANOREF, ";
                    vFILTER = vFILTER + "BANDEIRA, ";
                    vFILTER = vFILTER + "LEIT_IRRIGANTE_ATUAL, ";
                    vFILTER = vFILTER + "LEIT_REVERSO_ATUAL, ";
                    vFILTER = vFILTER + "LEIT_REVERSO_ANTER, ";
                    vFILTER = vFILTER + "KWH_REVERSO_RES, ";
                    vFILTER = vFILTER + "KWH_REVERSO_LID, ";
                    vFILTER = vFILTER + "KWH_REVERSO_FAT, ";
                    vFILTER = vFILTER + "MENSAGEM_BANDEIRA, ";
                    vFILTER = vFILTER + "LEIT_IRRIGANTE_ANTERIOR, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_LIDO, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_FATURADO, ";
                    vFILTER = vFILTER + "FRENTEVERSO, ";
                    vFILTER = vFILTER + "REAVISO_VECTO, ";
                    vFILTER = vFILTER + "REAVISO_NUMNF, ";
                    vFILTER = vFILTER + "REAVISO_VALOR, ";
                    vFILTER = vFILTER + "REAVISO_MESANO, ";
                    vFILTER = vFILTER + "REAVISO_IDENTIFICADOR, ";
                    vFILTER = vFILTER + "REAVISO_MENSAGEM, ";
                    vFILTER = vFILTER + "IRRIGACAO_AQUICULTURA, ";
                    vFILTER = vFILTER + "LIVRE_VERDE, ";
                    vFILTER = vFILTER + "MICRO_GERACAO, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES, ";
                    vFILTER = vFILTER + "NOME_CONJUGE, ";
                    vFILTER = vFILTER + "LEITURA_ANTER_PONTA, ";
                    vFILTER = vFILTER + "LEITURA_ATUAL_PONTA, ";
                    vFILTER = vFILTER + "LEITURA_ANTER_INTER, ";
                    vFILTER = vFILTER + "LEITURA_ATUAL_INTER, ";
                    vFILTER = vFILTER + "LEITURA_ANTER_FORAP, ";
                    vFILTER = vFILTER + "LEITURA_ATUAL_FORAP, ";
                    vFILTER = vFILTER + "RESIDUO_PONTA, ";
                    vFILTER = vFILTER + "RESIDUO_INTER, ";
                    vFILTER = vFILTER + "RESIDUO_FORAP, ";
                    vFILTER = vFILTER + "TARIFA_BRANCA, ";
                    vFILTER = vFILTER + "CONSUMO_PONTA, ";
                    vFILTER = vFILTER + "CONSUMO_INTER, ";
                    vFILTER = vFILTER + "CONSUMO_FORAP, ";
                    vFILTER = vFILTER + "CONSUMORESERVADO, ";
                    vFILTER = vFILTER + "IDTIPO_BANDEIRA, ";
                    vFILTER = vFILTER + "LEITRESERVADOANT, ";
                    vFILTER = vFILTER + "LEITRESERVADOATU, ";
                    vFILTER = vFILTER + "PAGTO_GOVERNO, ";
                    vFILTER = vFILTER + "PERDAS, ";
                    vFILTER = vFILTER + "SALDO_ARRED, ";
                    vFILTER = vFILTER + "VLRCONSUMORESERVADO, ";
                    vFILTER = vFILTER + "SALDOACUMULADO ";

                    vINNERJOIN = " ";

                    vORDERBY = " ";

                    vAND = vAND + "AND ENVIADONF3E = ?ENVIADONF3E ";
                    vAND = vAND + "AND MESANOREF = ?MESANOREF ";
                    vAND = vAND + "AND NUMNF IN (" + objTempFaturaNF3EB.LISTNUMNF + ") ";

                    cmd = new MySqlCommand(this.QuerySelect);

                    cmd.Parameters.AddWithValue("?ENVIADONF3E", objTempFaturaNF3EB.ENVIADONF3E);
                    cmd.Parameters.AddWithValue("?MESANOREF", objTempFaturaNF3EB.MESANOREF);

                    dt = objGerenciadorTransacao.GetDataTable(cmd);

                }

                return dt;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (cmd != null)
                    cmd.Dispose();
            }
        }

        #endregion

        #region " Comandos SQL "

        StringBuilder sb = new StringBuilder();


        protected string QueryInsert
        {
            get
            {
                this.sb.Clear();

                this.sb.AppendLine("INSERT INTO  ");
                this.sb.AppendLine("temp_fatura_nf3e_b SET  ");
                this.sb.AppendLine(vFILTER);

                return sb.ToString();
            }
        }

        protected string QueryUpdate
        {
            get
            {
                this.sb.Clear();

                this.sb.AppendLine("UPDATE  ");
                this.sb.AppendLine("temp_fatura_nf3e_b SET  ");
                this.sb.AppendLine(vFILTER);
                this.sb.AppendLine("WHERE 1 = 1 ");
                this.sb.AppendLine(vAND);

                return sb.ToString();
            }
        }

        protected string QueryDelete
        {
            get
            {
                this.sb.Clear();

                this.sb.AppendLine("DELETE FROM temp_fatura_nf3e_b ");
                this.sb.AppendLine("WHERE 1 = 1 ");
                this.sb.AppendLine(vAND);
                this.sb.AppendLine(vORDERBY);

                return sb.ToString();
            }
        }

        protected string QuerySelect
        {
            get
            {
                this.sb.Clear();

                this.sb.AppendLine("SELECT ");
                this.sb.AppendLine(vFILTER);
                this.sb.AppendLine("FROM ");
                this.sb.AppendLine("temp_fatura_nf3e_b  ");
                this.sb.AppendLine(vINNERJOIN);
                this.sb.AppendLine("WHERE 1 = 1  ");
                this.sb.AppendLine(vAND);
                this.sb.AppendLine(vORDERBY);

                return sb.ToString();
            }
        }

        protected string QuerySelectNovo
        {
            get
            {
                this.sb.Clear();

                this.sb.AppendLine("SELECT ");
                this.sb.AppendLine(vFILTER);
                this.sb.AppendLine("FROM ");
                this.sb.AppendLine("temp_fatura_nf3e_b  ");
                this.sb.AppendLine(vINNERJOIN);
                this.sb.AppendLine("WHERE 1 = 1  ");
                this.sb.AppendLine(vAND);
                this.sb.AppendLine(vORDERBY);

                return sb.ToString();
            }
        }

        protected string QueryExecute
        {
            get
            {
                this.sb.Clear();

                this.sb.AppendLine(vAND);
                this.sb.AppendLine(vORDERBY);

                return sb.ToString();
            }
        }

        #endregion

    }
}
