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;
using Microsoft.VisualBasic;

namespace fatd_faturamento.DAL.Persistencia
{
    public class dalUCFaturamento
    {
        string vFILTER = null;
        string vINNERJOIN = null;
        string vAND = null;
        string vORDERBY = null;

        #region Métodos

        public DataTable Select(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "GRUPO_TAR, ";
                    vFILTER = vFILTER + "`uc`.ID, ";
                    vFILTER = vFILTER + "`uc`.ZONA, ";
                    vFILTER = vFILTER + "`uc`.LIVRO, ";
                    vFILTER = vFILTER + "`uc`.CONTA, ";
                    vFILTER = vFILTER + "ROTA, ";
                    vFILTER = vFILTER + "INSTAL, ";
                    vFILTER = vFILTER + "ENCARGO, ";
                    vFILTER = vFILTER + "MEDKW, ";
                    vFILTER = vFILTER + "CONST_CONSUMO, ";
                    vFILTER = vFILTER + "CFOP, ";
                    vFILTER = vFILTER + "LEIT, ";
                    vFILTER = vFILTER + "KVAR, ";
                    vFILTER = vFILTER + "TA, ";
                    vFILTER = vFILTER + "CLAS, ";
                    vFILTER = vFILTER + "TENSAO, ";
                    vFILTER = vFILTER + "MEDKVARK, ";
                    vFILTER = vFILTER + "ANTRESERV, ";
                    vFILTER = vFILTER + "ARREDONDA_TEMP, ";
                    vFILTER = vFILTER + "ATURESERV, ";
                    vFILTER = vFILTER + "COD_TIPO_MEDIDOR, ";
                    vFILTER = vFILTER + "DTAUTODEC, ";
                    vFILTER = vFILTER + "FLG_ALIQUOTADIF, ";
                    vFILTER = vFILTER + "ISENTOREATIVO, ";
                    vFILTER = vFILTER + "MEDIMEC, ";
                    vFILTER = vFILTER + "NOVAMECA, ";
                    vFILTER = vFILTER + "NUM_UNIVERSALIZACAO, ";
                    vFILTER = vFILTER + "OBSERVACAO, ";
                    vFILTER = vFILTER + "PAGTO_GOVERNO, ";
                    vFILTER = vFILTER + "RG_ORGAO, ";
                    vFILTER = vFILTER + "RG_UF, ";
                    vFILTER = vFILTER + "TIPO_MEDIDOR, ";
                    vFILTER = vFILTER + "UNIVERSALIZACAO, ";
                    vFILTER = vFILTER + "VECTOPROXMES, ";
                    vFILTER = vFILTER + "VIP_COMERCIAL, ";
                    vFILTER = vFILTER + "DEMANDA, ";
                    vFILTER = vFILTER + "KVARKN, ";
                    vFILTER = vFILTER + "LEITANT, ";
                    vFILTER = vFILTER + "DEMANDAANT, ";
                    vFILTER = vFILTER + "DEMALIDA, ";
                    vFILTER = vFILTER + "KVARKNANT, ";
                    vFILTER = vFILTER + "GRUPO, ";
                    vFILTER = vFILTER + "FASE, ";
                    vFILTER = vFILTER + "CONST_DEMANDA, ";
                    vFILTER = vFILTER + "CONST_DEMANDA_FP, ";
                    vFILTER = vFILTER + "MAXIMO, ";
                    vFILTER = vFILTER + "PERC, ";
                    vFILTER = vFILTER + "ISENTO, ";
                    vFILTER = vFILTER + "MAIOR, ";
                    vFILTER = vFILTER + "ELETR, ";
                    vFILTER = vFILTER + "CONST_CONS_FP, ";
                    vFILTER = vFILTER + "CONST_CONS_P, ";
                    vFILTER = vFILTER + "CAP, ";
                    vFILTER = vFILTER + "DAP, ";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA, ";
                    vFILTER = vFILTER + "DEM_CONTR_FP, ";
                    vFILTER = vFILTER + "ULTLEIT, ";
                    vFILTER = vFILTER + "CONST_KVARH_P, ";
                    vFILTER = vFILTER + "CONST_KVARH_FP, ";
                    vFILTER = vFILTER + "KVARHFPN, ";
                    vFILTER = vFILTER + "KVARHPN, ";
                    vFILTER = vFILTER + "CONSTKVP, ";
                    vFILTER = vFILTER + "CONSTKVFP, ";
                    vFILTER = vFILTER + "CICE, ";
                    vFILTER = vFILTER + "ILUM, ";
                    vFILTER = vFILTER + "SITUACAO, ";
                    vFILTER = vFILTER + "FONE, ";
                    vFILTER = vFILTER + "DATA_LIGACAO, ";
                    vFILTER = vFILTER + "DATA_RELIGACAO, ";
                    vFILTER = vFILTER + "DATA_DESLIGAMENTO, ";
                    vFILTER = vFILTER + "DATA_ENTRADA, ";
                    vFILTER = vFILTER + "DATA_CORTE, ";
                    vFILTER = vFILTER + "DP12, ";
                    vFILTER = vFILTER + "QH, ";
                    vFILTER = vFILTER + "CARGA, ";
                    vFILTER = vFILTER + "FINAL, ";
                    vFILTER = vFILTER + "DEMANDA_CONTR, ";
                    vFILTER = vFILTER + "`uc`.CONS_ID, ";
                    vFILTER = vFILTER + "`uc`.UNID_ID, ";
                    vFILTER = vFILTER + "CONSLOC_ID, ";
                    vFILTER = vFILTER + "CODEND, ";
                    vFILTER = vFILTER + "END, ";
                    vFILTER = vFILTER + "BAIRRO, ";
                    vFILTER = vFILTER + "CIDADE, ";
                    vFILTER = vFILTER + "UF, ";
                    vFILTER = vFILTER + "QUADRA, ";
                    vFILTER = vFILTER + "LOTE, ";
                    vFILTER = vFILTER + "NUMERO, ";
                    vFILTER = vFILTER + "ITENSESP, ";
                    vFILTER = vFILTER + "NUM, ";
                    vFILTER = vFILTER + "TIPOUC, ";
                    vFILTER = vFILTER + "BANCO, ";
                    vFILTER = vFILTER + "AGENC, ";
                    vFILTER = vFILTER + "CC, ";
                    vFILTER = vFILTER + "CEP, ";
                    vFILTER = vFILTER + "NOME, ";
                    vFILTER = vFILTER + "ARREDONDA, ";
                    vFILTER = vFILTER + "ARREDONDA_ANT, ";
                    vFILTER = vFILTER + "CONST_KVARH, ";
                    vFILTER = vFILTER + "CONST_RESERVADO, ";
                    vFILTER = vFILTER + "DATA_CONTRATO_DEMANDA, ";
                    vFILTER = vFILTER + "HISTORICO, ";
                    vFILTER = vFILTER + "DIAVENC, ";
                    vFILTER = vFILTER + "FORMULA_CIP, ";
                    vFILTER = vFILTER + "SOCIAL, ";
                    vFILTER = vFILTER + "IDCNAE, ";
                    vFILTER = vFILTER + "LOCALIDADE, ";
                    vFILTER = vFILTER + "FLG_SAZONAL, ";
                    vFILTER = vFILTER + "CODEND_ENTREGA, ";
                    vFILTER = vFILTER + "END_ENTREGA, ";
                    vFILTER = vFILTER + "NUM_ENTREGA, ";
                    vFILTER = vFILTER + "BAI_ENTREGA, ";
                    vFILTER = vFILTER + "COMPL_ENTREGA, ";
                    vFILTER = vFILTER + "DIS_ENTREGA, ";
                    vFILTER = vFILTER + "CID_ENTREGA, ";
                    vFILTER = vFILTER + "UF_ENTREGA, ";
                    vFILTER = vFILTER + "CEP_ENTREGA, ";
                    vFILTER = vFILTER + "QUA_ENTREGA, ";
                    vFILTER = vFILTER + "LOT_ENTREGA, ";
                    vFILTER = vFILTER + "CPF_CNPJ, ";
                    vFILTER = vFILTER + "RG, ";
                    vFILTER = vFILTER + "INSC, ";
                    vFILTER = vFILTER + "PESSOA, ";
                    vFILTER = vFILTER + "COMPLEMENT, ";
                    vFILTER = vFILTER + "ENTREGA, ";
                    vFILTER = vFILTER + "DMCR, ";
                    vFILTER = vFILTER + "DTAINSTMEDIDOR, ";
                    vFILTER = vFILTER + "DTAFABMEDIDOR, ";
                    vFILTER = vFILTER + "LACRE, ";
                    vFILTER = vFILTER + "DISTRITO, ";
                    vFILTER = vFILTER + "MARCA, ";
                    vFILTER = vFILTER + "ICMS_ISENTO_DEMANDA, ";
                    vFILTER = vFILTER + "ICMS_DIFERIDO, ";
                    vFILTER = vFILTER + "LEITDEMA, ";
                    vFILTER = vFILTER + "BANARREC, ";
                    vFILTER = vFILTER + "PERC_RETENCAO, ";
                    vFILTER = vFILTER + "LEITREATIVO, ";
                    vFILTER = vFILTER + "ALTA_TENSAO, ";
                    vFILTER = vFILTER + "CIRCUITO, ";
                    vFILTER = vFILTER + "TP_LIGACAO, ";
                    vFILTER = vFILTER + "SOLICITANTE, ";
                    vFILTER = vFILTER + "ICMS_DEMANDA_LIDA, ";
                    vFILTER = vFILTER + "REGIAO, ";
                    vFILTER = vFILTER + "SGDENVIO, ";
                    vFILTER = vFILTER + "ID_BCO_ANT, ";
                    vFILTER = vFILTER + "ID_BCO_ATUAL, ";
                    vFILTER = vFILTER + "LIVREESPECIAL, ";
                    vFILTER = vFILTER + "COMPROVANTE_RURAL, ";
                    vFILTER = vFILTER + "IDTIPO_MEDIDOR, ";
                    vFILTER = vFILTER + "MODELO, ";
                    vFILTER = vFILTER + "IDCONDUTOR, ";
                    vFILTER = vFILTER + "COMPRIMENTO_FIO, ";
                    vFILTER = vFILTER + "COD_TIPO_MEDICAO, ";
                    vFILTER = vFILTER + "TIPO_MEDICAO, ";
                    vFILTER = vFILTER + "IDTIPO_PADRAO_MEDICAO, ";
                    vFILTER = vFILTER + "TC_RELACAO_PRIMARIA, ";
                    vFILTER = vFILTER + "TC_RELACAO_SECUNDARIA, ";
                    vFILTER = vFILTER + "TP_RELACAO_PRIMARIA, ";
                    vFILTER = vFILTER + "TP_RELACAO_SECUNDARIA, ";
                    vFILTER = vFILTER + "IDALIMENTADOR, ";
                    vFILTER = vFILTER + "IDCORRENTE, ";
                    vFILTER = vFILTER + "AP_SAUDE, ";
                    vFILTER = vFILTER + "ESTUFA, ";
                    vFILTER = vFILTER + "RAMAL, ";
                    vFILTER = vFILTER + "DATA_RAMAL, ";
                    vFILTER = vFILTER + "CLIENTEPENDENTE, ";
                    vFILTER = vFILTER + "FLG_AVISO_DEBITO, ";
                    vFILTER = vFILTER + "IDMEDIDOR, ";
                    vFILTER = vFILTER + "AGRUPA, ";
                    vFILTER = vFILTER + "AGRUPA_CONTA, ";
                    vFILTER = vFILTER + "AGRUPA_LIVRO, ";
                    vFILTER = vFILTER + "AGRUPA_ZONA, ";
                    vFILTER = vFILTER + "AREA, ";
                    vFILTER = vFILTER + "BX0402, ";
                    vFILTER = vFILTER + "BXRENDA, ";
                    vFILTER = vFILTER + "DECAP_DATA, ";
                    vFILTER = vFILTER + "DECAP_NUM, ";
                    vFILTER = vFILTER + "DISJUNTOR, ";
                    vFILTER = vFILTER + "ELETROBRAS, ";
                    vFILTER = vFILTER + "FASELIG, ";
                    vFILTER = vFILTER + "FLGRES, ";
                    vFILTER = vFILTER + "FPFIXO, ";
                    vFILTER = vFILTER + "JUL2010, ";
                    vFILTER = vFILTER + "LUZ_TODOS, ";
                    vFILTER = vFILTER + "PAGTO_DUVIDOSO, ";
                    vFILTER = vFILTER + "RES694, ";
                    vFILTER = vFILTER + "RESIDUO_CONSUMO, ";
                    vFILTER = vFILTER + "TRANSF, ";
                    vFILTER = vFILTER + "ULTCONS, ";
                    vFILTER = vFILTER + "ULTKVARH, ";
                    vFILTER = vFILTER + "CONST, ";
                    vFILTER = vFILTER + "CONSTFP, ";
                    vFILTER = vFILTER + "KVARH, ";
                    vFILTER = vFILTER + "CNAE, ";
                    vFILTER = vFILTER + "IDCCEE, ";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO, ";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_P, ";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_I, ";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_FP, ";
                    vFILTER = vFILTER + "MICRO_GERACAO, ";
                    vFILTER = vFILTER + "KWH_REVERSO_RES, ";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_P, ";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_I, ";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_FP, ";
                    vFILTER = vFILTER + "PARCIALMENTE_CATIVO, ";
                    vFILTER = vFILTER + "DEMANDA_CONTR_ANTERIOR, ";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA_ANTERIOR, ";
                    vFILTER = vFILTER + "DEM_CONTR_FP_ANTERIOR, ";
                    vFILTER = vFILTER + "PERIODO_TESTE, ";
                    vFILTER = vFILTER + "VIP_TECNICO, ";
                    vFILTER = vFILTER + "MEDKVARH, ";
                    vFILTER = vFILTER + "IRRIGACAO_AQUICULTURA, ";
                    vFILTER = vFILTER + "ULTLEIT_IRRIGANTE, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES, ";
                    vFILTER = vFILTER + "LIVRE_VERDE, ";
                    vFILTER = vFILTER + "ULTLEIT_DESLIGAMENTO, ";
                    vFILTER = vFILTER + "LIVRE_LEITURA_CONSUMO, ";
                    vFILTER = vFILTER + "INI_PERIODO_TESTE, ";
                    vFILTER = vFILTER + "FIM_PERIODO_TESTE, ";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE, ";
                    vFILTER = vFILTER + "LATITUDE, ";
                    vFILTER = vFILTER + "LONGITUDE, ";
                    vFILTER = vFILTER + "IRR_HR_INI, ";
                    vFILTER = vFILTER + "IRR_HR_FIM, ";
                    vFILTER = vFILTER + "TARIFA_BRANCA, ";
                    vFILTER = vFILTER + "REATIVO, ";
                    vFILTER = vFILTER + "ISENTO_ICMS_TUSD, ";
                    vFILTER = vFILTER + "ENVIO_COB_JUDICIAL, ";
                    vFILTER = vFILTER + "BLOQUEA_SEG_VIA_FAT, ";
                    vFILTER = vFILTER + "BLOQUEA_RELIGACAO, ";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_P, ";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_I, ";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_FP, ";
                    vFILTER = vFILTER + "ULT_LEIT_KW_P, ";
                    vFILTER = vFILTER + "ULT_LEIT_KW_FP, ";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_P, ";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_I, ";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_FP, ";
                    vFILTER = vFILTER + "ULT_CONS_KWH_P, ";
                    vFILTER = vFILTER + "ULT_CONS_KWH_I, ";
                    vFILTER = vFILTER + "ULT_CONS_KWH_FP, ";
                    vFILTER = vFILTER + "ULT_CONS_KW_P, ";
                    vFILTER = vFILTER + "ULT_CONS_KW_FP, ";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_P, ";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_I, ";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_FP, ";
                    vFILTER = vFILTER + "KWH_RES_P, ";
                    vFILTER = vFILTER + "KWH_RES_I, ";
                    vFILTER = vFILTER + "KWH_RES_FP, ";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_P, ";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_I, ";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_FP, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_P, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_I, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_FP, ";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_P, ";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_I, ";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_FP, ";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_P, ";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_I, ";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_FP, ";
                    vFILTER = vFILTER + "CONST_KWH_P, ";
                    vFILTER = vFILTER + "CONST_KWH_I, ";
                    vFILTER = vFILTER + "CONST_KWH_FP, ";
                    vFILTER = vFILTER + "CONST_KW_P, ";
                    vFILTER = vFILTER + "CONST_KW_FP, ";
                    vFILTER = vFILTER + "CONST_KVARH_I, ";
                    vFILTER = vFILTER + "CONJUGE_FATURA, ";
                    vFILTER = vFILTER + "CADERNO, ";
                    vFILTER = vFILTER + "SEQUENCIA, ";
                    vFILTER = vFILTER + "ENVIO_EMAIL_FATURA, ";
                    vFILTER = vFILTER + "ISENTO_TAXA_CORREIO, ";
                    vFILTER = vFILTER + "IF(`gd`.`tipo` REGEXP '[[:<:]]GDI[[:>:]]', 1, 0) AS 'GDI',";
                    vFILTER = vFILTER + "IF(`gd`.`tipo` REGEXP '[[:<:]]GDII[[:>:]]', 1, 0) AS 'GDII',";
                    vFILTER = vFILTER + "IF(`gd`.`tipo` REGEXP '[[:<:]]GDIII[[:>:]]', 1, 0) AS 'GDIII'";                  
                    

                    vINNERJOIN = " `uc` LEFT JOIN `gd_tipo` `gd` ON `gd`.`unid_id` = `uc`.`id` ";

                    vORDERBY = " ";

                    if (objUCFaturamento.ID != 0)
                    {
                        if (vAND != String.Empty) { vAND = vAND + "AND `uc`.ID = ?ID "; }                      
                        else                      { vAND =        "AND `uc`.ID = ?ID "; }
                    }
                    if (objUCFaturamento.ZONA != "")
                    {
                        if (vAND != String.Empty) { vAND = vAND + "AND `uc`.ZONA = ?ZONA "; }
                        else                      { vAND =        "AND `uc`.ZONA = ?ZONA "; }
                    }
                    if (objUCFaturamento.LIVRO != "")
                    {
                        if (vAND != String.Empty) { vAND = vAND + "AND `uc`.LIVRO = ?LIVRO "; }
                        else                      { vAND =        "AND `uc`.LIVRO = ?LIVRO "; }
                    }
                    if (objUCFaturamento.CONTA != "")
                    {
                        if (vAND != String.Empty) { vAND = vAND + "AND `uc`.CONTA = ?CONTA "; }
                        else                      { vAND =        "AND `uc`.CONTA = ?CONTA "; }
                    }

                    cmd = new MySqlCommand(this.QuerySelect);

                    if (objUCFaturamento.ID != 0)     { cmd.Parameters.AddWithValue("?ID", objUCFaturamento.ID); }
                    if (objUCFaturamento.ZONA != "")  { cmd.Parameters.AddWithValue("?ZONA", objUCFaturamento.ZONA); }
                    if (objUCFaturamento.LIVRO != "") { cmd.Parameters.AddWithValue("?LIVRO", objUCFaturamento.LIVRO); }
                    if (objUCFaturamento.CONTA != "") { cmd.Parameters.AddWithValue("?CONTA", objUCFaturamento.CONTA); }

                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable Select_1(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "GRUPO_TAR, ";
                    vFILTER = vFILTER + "ID, ";
                    vFILTER = vFILTER + "ZONA, ";
                    vFILTER = vFILTER + "LIVRO, ";
                    vFILTER = vFILTER + "CONTA, ";
                    vFILTER = vFILTER + "ROTA, ";
                    vFILTER = vFILTER + "INSTAL, ";
                    vFILTER = vFILTER + "ENCARGO, ";
                    vFILTER = vFILTER + "MEDKW, ";
                    vFILTER = vFILTER + "CONST_CONSUMO, ";
                    vFILTER = vFILTER + "CFOP, ";
                    vFILTER = vFILTER + "LEIT, ";
                    vFILTER = vFILTER + "KVAR, ";
                    vFILTER = vFILTER + "TA, ";
                    vFILTER = vFILTER + "CLAS, ";
                    vFILTER = vFILTER + "TENSAO, ";
                    vFILTER = vFILTER + "MEDKVARK, ";
                    vFILTER = vFILTER + "ANTRESERV, ";
                    vFILTER = vFILTER + "ARREDONDA_TEMP, ";
                    vFILTER = vFILTER + "ATURESERV, ";
                    vFILTER = vFILTER + "COD_TIPO_MEDIDOR, ";
                    vFILTER = vFILTER + "DTAUTODEC, ";
                    vFILTER = vFILTER + "FLG_ALIQUOTADIF, ";
                    vFILTER = vFILTER + "ISENTOREATIVO, ";
                    vFILTER = vFILTER + "MEDIMEC, ";
                    vFILTER = vFILTER + "NOVAMECA, ";
                    vFILTER = vFILTER + "NUM_UNIVERSALIZACAO, ";
                    vFILTER = vFILTER + "OBSERVACAO, ";
                    vFILTER = vFILTER + "PAGTO_GOVERNO, ";
                    vFILTER = vFILTER + "RG_ORGAO, ";
                    vFILTER = vFILTER + "RG_UF, ";
                    vFILTER = vFILTER + "TIPO_MEDIDOR, ";
                    vFILTER = vFILTER + "UNIVERSALIZACAO, ";
                    vFILTER = vFILTER + "VECTOPROXMES, ";
                    vFILTER = vFILTER + "VIP_COMERCIAL, ";
                    vFILTER = vFILTER + "DEMANDA, ";
                    vFILTER = vFILTER + "KVARKN, ";
                    vFILTER = vFILTER + "LEITANT, ";
                    vFILTER = vFILTER + "DEMANDAANT, ";
                    vFILTER = vFILTER + "DEMALIDA, ";
                    vFILTER = vFILTER + "KVARKNANT, ";
                    vFILTER = vFILTER + "GRUPO, ";
                    vFILTER = vFILTER + "FASE, ";
                    vFILTER = vFILTER + "CONST_DEMANDA, ";
                    vFILTER = vFILTER + "CONST_DEMANDA_FP, ";
                    vFILTER = vFILTER + "MAXIMO, ";
                    vFILTER = vFILTER + "PERC, ";
                    vFILTER = vFILTER + "ISENTO, ";
                    vFILTER = vFILTER + "MAIOR, ";
                    vFILTER = vFILTER + "ELETR, ";
                    vFILTER = vFILTER + "CONST_CONS_FP, ";
                    vFILTER = vFILTER + "CONST_CONS_P, ";
                    vFILTER = vFILTER + "CAP, ";
                    vFILTER = vFILTER + "DAP, ";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA, ";
                    vFILTER = vFILTER + "DEM_CONTR_FP, ";
                    vFILTER = vFILTER + "ULTLEIT, ";
                    vFILTER = vFILTER + "CONST_KVARH_P, ";
                    vFILTER = vFILTER + "CONST_KVARH_FP, ";
                    vFILTER = vFILTER + "KVARHFPN, ";
                    vFILTER = vFILTER + "KVARHPN, ";
                    vFILTER = vFILTER + "CONSTKVP, ";
                    vFILTER = vFILTER + "CONSTKVFP, ";
                    vFILTER = vFILTER + "CICE, ";
                    vFILTER = vFILTER + "ILUM, ";
                    vFILTER = vFILTER + "SITUACAO, ";
                    vFILTER = vFILTER + "FONE, ";
                    vFILTER = vFILTER + "DATA_LIGACAO, ";
                    vFILTER = vFILTER + "DATA_RELIGACAO, ";
                    vFILTER = vFILTER + "DATA_DESLIGAMENTO, ";
                    vFILTER = vFILTER + "DATA_ENTRADA, ";
                    vFILTER = vFILTER + "DATA_CORTE, ";
                    vFILTER = vFILTER + "DP12, ";
                    vFILTER = vFILTER + "QH, ";
                    vFILTER = vFILTER + "CARGA, ";
                    vFILTER = vFILTER + "FINAL, ";
                    vFILTER = vFILTER + "DEMANDA_CONTR, ";
                    vFILTER = vFILTER + "CONS_ID, ";
                    vFILTER = vFILTER + "UNID_ID, ";
                    vFILTER = vFILTER + "CONSLOC_ID, ";
                    vFILTER = vFILTER + "CODEND, ";
                    vFILTER = vFILTER + "END, ";
                    vFILTER = vFILTER + "BAIRRO, ";
                    vFILTER = vFILTER + "CIDADE, ";
                    vFILTER = vFILTER + "UF, ";
                    vFILTER = vFILTER + "QUADRA, ";
                    vFILTER = vFILTER + "LOTE, ";
                    vFILTER = vFILTER + "NUMERO, ";
                    vFILTER = vFILTER + "ITENSESP, ";
                    vFILTER = vFILTER + "NUM, ";
                    vFILTER = vFILTER + "TIPOUC, ";
                    vFILTER = vFILTER + "BANCO, ";
                    vFILTER = vFILTER + "AGENC, ";
                    vFILTER = vFILTER + "CC, ";
                    vFILTER = vFILTER + "CEP, ";
                    vFILTER = vFILTER + "NOME, ";
                    vFILTER = vFILTER + "ARREDONDA, ";
                    vFILTER = vFILTER + "ARREDONDA_ANT, ";
                    vFILTER = vFILTER + "CONST_KVARH, ";
                    vFILTER = vFILTER + "CONST_RESERVADO, ";
                    vFILTER = vFILTER + "DATA_CONTRATO_DEMANDA, ";
                    vFILTER = vFILTER + "HISTORICO, ";
                    vFILTER = vFILTER + "DIAVENC, ";
                    vFILTER = vFILTER + "FORMULA_CIP, ";
                    vFILTER = vFILTER + "SOCIAL, ";
                    vFILTER = vFILTER + "IDCNAE, ";
                    vFILTER = vFILTER + "LOCALIDADE, ";
                    vFILTER = vFILTER + "FLG_SAZONAL, ";
                    vFILTER = vFILTER + "CODEND_ENTREGA, ";
                    vFILTER = vFILTER + "END_ENTREGA, ";
                    vFILTER = vFILTER + "NUM_ENTREGA, ";
                    vFILTER = vFILTER + "BAI_ENTREGA, ";
                    vFILTER = vFILTER + "COMPL_ENTREGA, ";
                    vFILTER = vFILTER + "DIS_ENTREGA, ";
                    vFILTER = vFILTER + "CID_ENTREGA, ";
                    vFILTER = vFILTER + "UF_ENTREGA, ";
                    vFILTER = vFILTER + "CEP_ENTREGA, ";
                    vFILTER = vFILTER + "QUA_ENTREGA, ";
                    vFILTER = vFILTER + "LOT_ENTREGA, ";
                    vFILTER = vFILTER + "CPF_CNPJ, ";
                    vFILTER = vFILTER + "RG, ";
                    vFILTER = vFILTER + "INSC, ";
                    vFILTER = vFILTER + "PESSOA, ";
                    vFILTER = vFILTER + "COMPLEMENT, ";
                    vFILTER = vFILTER + "ENTREGA, ";
                    vFILTER = vFILTER + "DMCR, ";
                    vFILTER = vFILTER + "DTAINSTMEDIDOR, ";
                    vFILTER = vFILTER + "DTAFABMEDIDOR, ";
                    vFILTER = vFILTER + "LACRE, ";
                    vFILTER = vFILTER + "DISTRITO, ";
                    vFILTER = vFILTER + "MARCA, ";
                    vFILTER = vFILTER + "ICMS_ISENTO_DEMANDA, ";
                    vFILTER = vFILTER + "ICMS_DIFERIDO, ";
                    vFILTER = vFILTER + "LEITDEMA, ";
                    vFILTER = vFILTER + "BANARREC, ";
                    vFILTER = vFILTER + "PERC_RETENCAO, ";
                    vFILTER = vFILTER + "LEITREATIVO, ";
                    vFILTER = vFILTER + "ALTA_TENSAO, ";
                    vFILTER = vFILTER + "CIRCUITO, ";
                    vFILTER = vFILTER + "TP_LIGACAO, ";
                    vFILTER = vFILTER + "SOLICITANTE, ";
                    vFILTER = vFILTER + "ICMS_DEMANDA_LIDA, ";
                    vFILTER = vFILTER + "REGIAO, ";
                    vFILTER = vFILTER + "SGDENVIO, ";
                    vFILTER = vFILTER + "ID_BCO_ANT, ";
                    vFILTER = vFILTER + "ID_BCO_ATUAL, ";
                    vFILTER = vFILTER + "LIVREESPECIAL, ";
                    vFILTER = vFILTER + "COMPROVANTE_RURAL, ";
                    vFILTER = vFILTER + "IDTIPO_MEDIDOR, ";
                    vFILTER = vFILTER + "MODELO, ";
                    vFILTER = vFILTER + "IDCONDUTOR, ";
                    vFILTER = vFILTER + "COMPRIMENTO_FIO, ";
                    vFILTER = vFILTER + "COD_TIPO_MEDICAO, ";
                    vFILTER = vFILTER + "TIPO_MEDICAO, ";
                    vFILTER = vFILTER + "IDTIPO_PADRAO_MEDICAO, ";
                    vFILTER = vFILTER + "TC_RELACAO_PRIMARIA, ";
                    vFILTER = vFILTER + "TC_RELACAO_SECUNDARIA, ";
                    vFILTER = vFILTER + "TP_RELACAO_PRIMARIA, ";
                    vFILTER = vFILTER + "TP_RELACAO_SECUNDARIA, ";
                    vFILTER = vFILTER + "IDALIMENTADOR, ";
                    vFILTER = vFILTER + "IDCORRENTE, ";
                    vFILTER = vFILTER + "AP_SAUDE, ";
                    vFILTER = vFILTER + "ESTUFA, ";
                    vFILTER = vFILTER + "RAMAL, ";
                    vFILTER = vFILTER + "DATA_RAMAL, ";
                    vFILTER = vFILTER + "CLIENTEPENDENTE, ";
                    vFILTER = vFILTER + "FLG_AVISO_DEBITO, ";
                    vFILTER = vFILTER + "IDMEDIDOR, ";
                    vFILTER = vFILTER + "AGRUPA, ";
                    vFILTER = vFILTER + "AGRUPA_CONTA, ";
                    vFILTER = vFILTER + "AGRUPA_LIVRO, ";
                    vFILTER = vFILTER + "AGRUPA_ZONA, ";
                    vFILTER = vFILTER + "AREA, ";
                    vFILTER = vFILTER + "BX0402, ";
                    vFILTER = vFILTER + "BXRENDA, ";
                    vFILTER = vFILTER + "DECAP_DATA, ";
                    vFILTER = vFILTER + "DECAP_NUM, ";
                    vFILTER = vFILTER + "DISJUNTOR, ";
                    vFILTER = vFILTER + "ELETROBRAS, ";
                    vFILTER = vFILTER + "FASELIG, ";
                    vFILTER = vFILTER + "FLGRES, ";
                    vFILTER = vFILTER + "FPFIXO, ";
                    vFILTER = vFILTER + "JUL2010, ";
                    vFILTER = vFILTER + "LUZ_TODOS, ";
                    vFILTER = vFILTER + "PAGTO_DUVIDOSO, ";
                    vFILTER = vFILTER + "RES694, ";
                    vFILTER = vFILTER + "RESIDUO_CONSUMO, ";
                    vFILTER = vFILTER + "TRANSF, ";
                    vFILTER = vFILTER + "ULTCONS, ";
                    vFILTER = vFILTER + "ULTKVARH, ";
                    vFILTER = vFILTER + "CONST, ";
                    vFILTER = vFILTER + "CONSTFP, ";
                    vFILTER = vFILTER + "KVARH, ";
                    vFILTER = vFILTER + "CNAE, ";
                    vFILTER = vFILTER + "IDCCEE, ";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO, ";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_P, ";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_I, ";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_FP, ";
                    vFILTER = vFILTER + "MICRO_GERACAO, ";
                    vFILTER = vFILTER + "KWH_REVERSO_RES, ";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_P, ";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_I, ";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_FP, ";
                    vFILTER = vFILTER + "PARCIALMENTE_CATIVO, ";
                    vFILTER = vFILTER + "DEMANDA_CONTR_ANTERIOR, ";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA_ANTERIOR, ";
                    vFILTER = vFILTER + "DEM_CONTR_FP_ANTERIOR, ";
                    vFILTER = vFILTER + "PERIODO_TESTE, ";
                    vFILTER = vFILTER + "VIP_TECNICO, ";
                    vFILTER = vFILTER + "MEDKVARH, ";
                    vFILTER = vFILTER + "IRRIGACAO_AQUICULTURA, ";
                    vFILTER = vFILTER + "ULTLEIT_IRRIGANTE, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES, ";
                    vFILTER = vFILTER + "LIVRE_VERDE, ";
                    vFILTER = vFILTER + "ULTLEIT_DESLIGAMENTO, ";
                    vFILTER = vFILTER + "LIVRE_LEITURA_CONSUMO, ";
                    vFILTER = vFILTER + "INI_PERIODO_TESTE, ";
                    vFILTER = vFILTER + "FIM_PERIODO_TESTE, ";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE, ";
                    vFILTER = vFILTER + "LATITUDE, ";
                    vFILTER = vFILTER + "LONGITUDE, ";
                    vFILTER = vFILTER + "IRR_HR_INI, ";
                    vFILTER = vFILTER + "IRR_HR_FIM, ";
                    vFILTER = vFILTER + "TARIFA_BRANCA, ";
                    vFILTER = vFILTER + "REATIVO, ";
                    vFILTER = vFILTER + "ISENTO_ICMS_TUSD, ";
                    vFILTER = vFILTER + "ENVIO_COB_JUDICIAL, ";
                    vFILTER = vFILTER + "BLOQUEA_SEG_VIA_FAT, ";
                    vFILTER = vFILTER + "BLOQUEA_RELIGACAO, ";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_P, ";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_I, ";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_FP, ";
                    vFILTER = vFILTER + "ULT_LEIT_KW_P, ";
                    vFILTER = vFILTER + "ULT_LEIT_KW_FP, ";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_P, ";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_I, ";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_FP, ";
                    vFILTER = vFILTER + "ULT_CONS_KWH_P, ";
                    vFILTER = vFILTER + "ULT_CONS_KWH_I, ";
                    vFILTER = vFILTER + "ULT_CONS_KWH_FP, ";
                    vFILTER = vFILTER + "ULT_CONS_KW_P, ";
                    vFILTER = vFILTER + "ULT_CONS_KW_FP, ";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_P, ";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_I, ";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_FP, ";
                    vFILTER = vFILTER + "KWH_RES_P, ";
                    vFILTER = vFILTER + "KWH_RES_I, ";
                    vFILTER = vFILTER + "KWH_RES_FP, ";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_P, ";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_I, ";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_FP, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_P, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_I, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_FP, ";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_P, ";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_I, ";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_FP, ";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_P, ";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_I, ";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_FP, ";
                    vFILTER = vFILTER + "CONST_KWH_P, ";
                    vFILTER = vFILTER + "CONST_KWH_I, ";
                    vFILTER = vFILTER + "CONST_KWH_FP, ";
                    vFILTER = vFILTER + "CONST_KW_P, ";
                    vFILTER = vFILTER + "CONST_KW_FP, ";
                    vFILTER = vFILTER + "CONST_KVARH_I, ";
                    vFILTER = vFILTER + "CONJUGE_FATURA, ";
                    vFILTER = vFILTER + "CADERNO, ";
                    vFILTER = vFILTER + "SEQUENCIA ";

                    vINNERJOIN = " ";

                    vORDERBY = "ORDER BY ZONA, LIVRO, CONTA ";

                    if (objUCFaturamento.CONS_ID != 0)
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND CONS_ID = ?CONS_ID "; }
                        else
                        { vAND = "AND CONS_ID = ?CONS_ID "; }

                    }
                    else
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + " "; }
                        else
                        { vAND = " "; }
                    }


                    cmd = new MySqlCommand(this.QuerySelect);

                    if (objUCFaturamento.CONS_ID != 0)
                    {
                        cmd.Parameters.AddWithValue("?CONS_ID", objUCFaturamento.CONS_ID);
                    }

                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable Select_2(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "GRUPO_TAR, ";
                    vFILTER = vFILTER + "ID, ";
                    vFILTER = vFILTER + "ZONA, ";
                    vFILTER = vFILTER + "LIVRO, ";
                    vFILTER = vFILTER + "CONTA, ";
                    vFILTER = vFILTER + "ROTA, ";
                    vFILTER = vFILTER + "INSTAL, ";
                    vFILTER = vFILTER + "ENCARGO, ";
                    vFILTER = vFILTER + "MEDKW, ";
                    vFILTER = vFILTER + "CONST_CONSUMO, ";
                    vFILTER = vFILTER + "CFOP, ";
                    vFILTER = vFILTER + "LEIT, ";
                    vFILTER = vFILTER + "KVAR, ";
                    vFILTER = vFILTER + "TA, ";
                    vFILTER = vFILTER + "CLAS, ";
                    vFILTER = vFILTER + "TENSAO, ";
                    vFILTER = vFILTER + "MEDKVARK, ";
                    vFILTER = vFILTER + "ANTRESERV, ";
                    vFILTER = vFILTER + "ARREDONDA_TEMP, ";
                    vFILTER = vFILTER + "ATURESERV, ";
                    vFILTER = vFILTER + "COD_TIPO_MEDIDOR, ";
                    vFILTER = vFILTER + "DTAUTODEC, ";
                    vFILTER = vFILTER + "FLG_ALIQUOTADIF, ";
                    vFILTER = vFILTER + "ISENTOREATIVO, ";
                    vFILTER = vFILTER + "MEDIMEC, ";
                    vFILTER = vFILTER + "NOVAMECA, ";
                    vFILTER = vFILTER + "NUM_UNIVERSALIZACAO, ";
                    vFILTER = vFILTER + "OBSERVACAO, ";
                    vFILTER = vFILTER + "PAGTO_GOVERNO, ";
                    vFILTER = vFILTER + "RG_ORGAO, ";
                    vFILTER = vFILTER + "RG_UF, ";
                    vFILTER = vFILTER + "TIPO_MEDIDOR, ";
                    vFILTER = vFILTER + "UNIVERSALIZACAO, ";
                    vFILTER = vFILTER + "VECTOPROXMES, ";
                    vFILTER = vFILTER + "VIP_COMERCIAL, ";
                    vFILTER = vFILTER + "DEMANDA, ";
                    vFILTER = vFILTER + "KVARKN, ";
                    vFILTER = vFILTER + "LEITANT, ";
                    vFILTER = vFILTER + "DEMANDAANT, ";
                    vFILTER = vFILTER + "DEMALIDA, ";
                    vFILTER = vFILTER + "KVARKNANT, ";
                    vFILTER = vFILTER + "GRUPO, ";
                    vFILTER = vFILTER + "FASE, ";
                    vFILTER = vFILTER + "CONST_DEMANDA, ";
                    vFILTER = vFILTER + "CONST_DEMANDA_FP, ";
                    vFILTER = vFILTER + "MAXIMO, ";
                    vFILTER = vFILTER + "PERC, ";
                    vFILTER = vFILTER + "ISENTO, ";
                    vFILTER = vFILTER + "MAIOR, ";
                    vFILTER = vFILTER + "ELETR, ";
                    vFILTER = vFILTER + "CONST_CONS_FP, ";
                    vFILTER = vFILTER + "CONST_CONS_P, ";
                    vFILTER = vFILTER + "CAP, ";
                    vFILTER = vFILTER + "DAP, ";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA, ";
                    vFILTER = vFILTER + "DEM_CONTR_FP, ";
                    vFILTER = vFILTER + "ULTLEIT, ";
                    vFILTER = vFILTER + "CONST_KVARH_P, ";
                    vFILTER = vFILTER + "CONST_KVARH_FP, ";
                    vFILTER = vFILTER + "KVARHFPN, ";
                    vFILTER = vFILTER + "KVARHPN, ";
                    vFILTER = vFILTER + "CONSTKVP, ";
                    vFILTER = vFILTER + "CONSTKVFP, ";
                    vFILTER = vFILTER + "CICE, ";
                    vFILTER = vFILTER + "ILUM, ";
                    vFILTER = vFILTER + "SITUACAO, ";
                    vFILTER = vFILTER + "FONE, ";
                    vFILTER = vFILTER + "DATA_LIGACAO, ";
                    vFILTER = vFILTER + "DATA_RELIGACAO, ";
                    vFILTER = vFILTER + "DATA_DESLIGAMENTO, ";
                    vFILTER = vFILTER + "DATA_ENTRADA, ";
                    vFILTER = vFILTER + "DATA_CORTE, ";
                    vFILTER = vFILTER + "DP12, ";
                    vFILTER = vFILTER + "QH, ";
                    vFILTER = vFILTER + "CARGA, ";
                    vFILTER = vFILTER + "FINAL, ";
                    vFILTER = vFILTER + "DEMANDA_CONTR, ";
                    vFILTER = vFILTER + "CONS_ID, ";
                    vFILTER = vFILTER + "UNID_ID, ";
                    vFILTER = vFILTER + "CONSLOC_ID, ";
                    vFILTER = vFILTER + "CODEND, ";
                    vFILTER = vFILTER + "END, ";
                    vFILTER = vFILTER + "BAIRRO, ";
                    vFILTER = vFILTER + "CIDADE, ";
                    vFILTER = vFILTER + "UF, ";
                    vFILTER = vFILTER + "QUADRA, ";
                    vFILTER = vFILTER + "LOTE, ";
                    vFILTER = vFILTER + "NUMERO, ";
                    vFILTER = vFILTER + "ITENSESP, ";
                    vFILTER = vFILTER + "NUM, ";
                    vFILTER = vFILTER + "TIPOUC, ";
                    vFILTER = vFILTER + "BANCO, ";
                    vFILTER = vFILTER + "AGENC, ";
                    vFILTER = vFILTER + "CC, ";
                    vFILTER = vFILTER + "CEP, ";
                    vFILTER = vFILTER + "NOME, ";
                    vFILTER = vFILTER + "ARREDONDA, ";
                    vFILTER = vFILTER + "ARREDONDA_ANT, ";
                    vFILTER = vFILTER + "CONST_KVARH, ";
                    vFILTER = vFILTER + "CONST_RESERVADO, ";
                    vFILTER = vFILTER + "DATA_CONTRATO_DEMANDA, ";
                    vFILTER = vFILTER + "HISTORICO, ";
                    vFILTER = vFILTER + "DIAVENC, ";
                    vFILTER = vFILTER + "FORMULA_CIP, ";
                    vFILTER = vFILTER + "SOCIAL, ";
                    vFILTER = vFILTER + "IDCNAE, ";
                    vFILTER = vFILTER + "LOCALIDADE, ";
                    vFILTER = vFILTER + "FLG_SAZONAL, ";
                    vFILTER = vFILTER + "CODEND_ENTREGA, ";
                    vFILTER = vFILTER + "END_ENTREGA, ";
                    vFILTER = vFILTER + "NUM_ENTREGA, ";
                    vFILTER = vFILTER + "BAI_ENTREGA, ";
                    vFILTER = vFILTER + "COMPL_ENTREGA, ";
                    vFILTER = vFILTER + "DIS_ENTREGA, ";
                    vFILTER = vFILTER + "CID_ENTREGA, ";
                    vFILTER = vFILTER + "UF_ENTREGA, ";
                    vFILTER = vFILTER + "CEP_ENTREGA, ";
                    vFILTER = vFILTER + "QUA_ENTREGA, ";
                    vFILTER = vFILTER + "LOT_ENTREGA, ";
                    vFILTER = vFILTER + "CPF_CNPJ, ";
                    vFILTER = vFILTER + "RG, ";
                    vFILTER = vFILTER + "INSC, ";
                    vFILTER = vFILTER + "PESSOA, ";
                    vFILTER = vFILTER + "COMPLEMENT, ";
                    vFILTER = vFILTER + "ENTREGA, ";
                    vFILTER = vFILTER + "DMCR, ";
                    vFILTER = vFILTER + "DTAINSTMEDIDOR, ";
                    vFILTER = vFILTER + "DTAFABMEDIDOR, ";
                    vFILTER = vFILTER + "LACRE, ";
                    vFILTER = vFILTER + "DISTRITO, ";
                    vFILTER = vFILTER + "MARCA, ";
                    vFILTER = vFILTER + "ICMS_ISENTO_DEMANDA, ";
                    vFILTER = vFILTER + "ICMS_DIFERIDO, ";
                    vFILTER = vFILTER + "LEITDEMA, ";
                    vFILTER = vFILTER + "BANARREC, ";
                    vFILTER = vFILTER + "PERC_RETENCAO, ";
                    vFILTER = vFILTER + "LEITREATIVO, ";
                    vFILTER = vFILTER + "ALTA_TENSAO, ";
                    vFILTER = vFILTER + "CIRCUITO, ";
                    vFILTER = vFILTER + "TP_LIGACAO, ";
                    vFILTER = vFILTER + "SOLICITANTE, ";
                    vFILTER = vFILTER + "ICMS_DEMANDA_LIDA, ";
                    vFILTER = vFILTER + "REGIAO, ";
                    vFILTER = vFILTER + "SGDENVIO, ";
                    vFILTER = vFILTER + "ID_BCO_ANT, ";
                    vFILTER = vFILTER + "ID_BCO_ATUAL, ";
                    vFILTER = vFILTER + "LIVREESPECIAL, ";
                    vFILTER = vFILTER + "COMPROVANTE_RURAL, ";
                    vFILTER = vFILTER + "IDTIPO_MEDIDOR, ";
                    vFILTER = vFILTER + "MODELO, ";
                    vFILTER = vFILTER + "IDCONDUTOR, ";
                    vFILTER = vFILTER + "COMPRIMENTO_FIO, ";
                    vFILTER = vFILTER + "COD_TIPO_MEDICAO, ";
                    vFILTER = vFILTER + "TIPO_MEDICAO, ";
                    vFILTER = vFILTER + "IDTIPO_PADRAO_MEDICAO, ";
                    vFILTER = vFILTER + "TC_RELACAO_PRIMARIA, ";
                    vFILTER = vFILTER + "TC_RELACAO_SECUNDARIA, ";
                    vFILTER = vFILTER + "TP_RELACAO_PRIMARIA, ";
                    vFILTER = vFILTER + "TP_RELACAO_SECUNDARIA, ";
                    vFILTER = vFILTER + "IDALIMENTADOR, ";
                    vFILTER = vFILTER + "IDCORRENTE, ";
                    vFILTER = vFILTER + "AP_SAUDE, ";
                    vFILTER = vFILTER + "ESTUFA, ";
                    vFILTER = vFILTER + "RAMAL, ";
                    vFILTER = vFILTER + "DATA_RAMAL, ";
                    vFILTER = vFILTER + "CLIENTEPENDENTE, ";
                    vFILTER = vFILTER + "FLG_AVISO_DEBITO, ";
                    vFILTER = vFILTER + "IDMEDIDOR, ";
                    vFILTER = vFILTER + "AGRUPA, ";
                    vFILTER = vFILTER + "AGRUPA_CONTA, ";
                    vFILTER = vFILTER + "AGRUPA_LIVRO, ";
                    vFILTER = vFILTER + "AGRUPA_ZONA, ";
                    vFILTER = vFILTER + "AREA, ";
                    vFILTER = vFILTER + "BX0402, ";
                    vFILTER = vFILTER + "BXRENDA, ";
                    vFILTER = vFILTER + "DECAP_DATA, ";
                    vFILTER = vFILTER + "DECAP_NUM, ";
                    vFILTER = vFILTER + "DISJUNTOR, ";
                    vFILTER = vFILTER + "ELETROBRAS, ";
                    vFILTER = vFILTER + "FASELIG, ";
                    vFILTER = vFILTER + "FLGRES, ";
                    vFILTER = vFILTER + "FPFIXO, ";
                    vFILTER = vFILTER + "JUL2010, ";
                    vFILTER = vFILTER + "LUZ_TODOS, ";
                    vFILTER = vFILTER + "PAGTO_DUVIDOSO, ";
                    vFILTER = vFILTER + "RES694, ";
                    vFILTER = vFILTER + "RESIDUO_CONSUMO, ";
                    vFILTER = vFILTER + "TRANSF, ";
                    vFILTER = vFILTER + "ULTCONS, ";
                    vFILTER = vFILTER + "ULTKVARH, ";
                    vFILTER = vFILTER + "CONST, ";
                    vFILTER = vFILTER + "CONSTFP, ";
                    vFILTER = vFILTER + "KVARH, ";
                    vFILTER = vFILTER + "CNAE, ";
                    vFILTER = vFILTER + "IDCCEE, ";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO, ";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_P, ";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_I, ";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_FP, ";
                    vFILTER = vFILTER + "MICRO_GERACAO, ";
                    vFILTER = vFILTER + "KWH_REVERSO_RES, ";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_P, ";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_I, ";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_FP, ";
                    vFILTER = vFILTER + "PARCIALMENTE_CATIVO, ";
                    vFILTER = vFILTER + "DEMANDA_CONTR_ANTERIOR, ";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA_ANTERIOR, ";
                    vFILTER = vFILTER + "DEM_CONTR_FP_ANTERIOR, ";
                    vFILTER = vFILTER + "PERIODO_TESTE, ";
                    vFILTER = vFILTER + "VIP_TECNICO, ";
                    vFILTER = vFILTER + "MEDKVARH, ";
                    vFILTER = vFILTER + "IRRIGACAO_AQUICULTURA, ";
                    vFILTER = vFILTER + "ULTLEIT_IRRIGANTE, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES, ";
                    vFILTER = vFILTER + "LIVRE_VERDE, ";
                    vFILTER = vFILTER + "ULTLEIT_DESLIGAMENTO, ";
                    vFILTER = vFILTER + "LIVRE_LEITURA_CONSUMO, ";
                    vFILTER = vFILTER + "INI_PERIODO_TESTE, ";
                    vFILTER = vFILTER + "FIM_PERIODO_TESTE, ";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE, ";
                    vFILTER = vFILTER + "LATITUDE, ";
                    vFILTER = vFILTER + "LONGITUDE, ";
                    vFILTER = vFILTER + "IRR_HR_INI, ";
                    vFILTER = vFILTER + "IRR_HR_FIM, ";
                    vFILTER = vFILTER + "TARIFA_BRANCA, ";
                    vFILTER = vFILTER + "REATIVO, ";
                    vFILTER = vFILTER + "ISENTO_ICMS_TUSD, ";
                    vFILTER = vFILTER + "ENVIO_COB_JUDICIAL, ";
                    vFILTER = vFILTER + "BLOQUEA_SEG_VIA_FAT, ";
                    vFILTER = vFILTER + "BLOQUEA_RELIGACAO, ";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_P, ";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_I, ";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_FP, ";
                    vFILTER = vFILTER + "ULT_LEIT_KW_P, ";
                    vFILTER = vFILTER + "ULT_LEIT_KW_FP, ";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_P, ";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_I, ";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_FP, ";
                    vFILTER = vFILTER + "ULT_CONS_KWH_P, ";
                    vFILTER = vFILTER + "ULT_CONS_KWH_I, ";
                    vFILTER = vFILTER + "ULT_CONS_KWH_FP, ";
                    vFILTER = vFILTER + "ULT_CONS_KW_P, ";
                    vFILTER = vFILTER + "ULT_CONS_KW_FP, ";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_P, ";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_I, ";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_FP, ";
                    vFILTER = vFILTER + "KWH_RES_P, ";
                    vFILTER = vFILTER + "KWH_RES_I, ";
                    vFILTER = vFILTER + "KWH_RES_FP, ";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_P, ";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_I, ";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_FP, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_P, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_I, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_FP, ";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_P, ";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_I, ";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_FP, ";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_P, ";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_I, ";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_FP, ";
                    vFILTER = vFILTER + "CONST_KWH_P, ";
                    vFILTER = vFILTER + "CONST_KWH_I, ";
                    vFILTER = vFILTER + "CONST_KWH_FP, ";
                    vFILTER = vFILTER + "CONST_KW_P, ";
                    vFILTER = vFILTER + "CONST_KW_FP, ";
                    vFILTER = vFILTER + "CONST_KVARH_I, ";
                    vFILTER = vFILTER + "CONJUGE_FATURA, ";
                    vFILTER = vFILTER + "CADERNO, ";
                    vFILTER = vFILTER + "SEQUENCIA ";

                    vINNERJOIN = " ";

                    vORDERBY = " ";

                    if (objUCFaturamento.ZONA != String.Empty)
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND ZONA = ?ZONA "; }
                        else
                        { vAND = "AND ZONA =  ?ZONA "; }

                    }
                    else
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + " "; }
                        else
                        { vAND = " "; }
                    }

                    if (objUCFaturamento.LIVRO != String.Empty)
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND LIVRO = ?LIVRO "; }
                        else
                        { vAND = "AND LIVRO =  ?LIVRO "; }

                    }
                    else
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + " "; }
                        else
                        { vAND = " "; }
                    }

                    if (objUCFaturamento.CONTA != String.Empty)
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND CONTA = ?CONTA "; }
                        else
                        { vAND = "AND CONTA =  ?CONTA "; }

                    }
                    else
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + " "; }
                        else
                        { vAND = " "; }
                    }

                    if (objUCFaturamento.CONS_ID != 0)
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND CONS_ID <> ?CONS_ID "; }
                        else
                        { vAND = "AND CONS_ID <> ?CONS_ID "; }

                    }
                    else
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + " "; }
                        else
                        { vAND = " "; }
                    }

                    if (objUCFaturamento.ID != 0)
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND ID <> ?ID "; }
                        else
                        { vAND = "AND ID <> ?ID "; }

                    }
                    else
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + " "; }
                        else
                        { vAND = " "; }
                    }


                    cmd = new MySqlCommand(this.QuerySelect);

                    if (objUCFaturamento.ZONA != String.Empty)
                    {
                        cmd.Parameters.AddWithValue("?ZONA", objUCFaturamento.ZONA);
                    }

                    if (objUCFaturamento.LIVRO != String.Empty)
                    {
                        cmd.Parameters.AddWithValue("?LIVRO", objUCFaturamento.LIVRO);
                    }

                    if (objUCFaturamento.CONTA != String.Empty)
                    {
                        cmd.Parameters.AddWithValue("?CONTA", objUCFaturamento.CONTA);
                    }

                    if (objUCFaturamento.CONS_ID != 0)
                    {
                        cmd.Parameters.AddWithValue("?CONS_ID", objUCFaturamento.CONS_ID);
                    }

                    if (objUCFaturamento.ID != 0)
                    {
                        cmd.Parameters.AddWithValue("?ID", objUCFaturamento.ID);
                    }

                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable Select_3(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "GRUPO_TAR, ";
                    vFILTER = vFILTER + "ID, ";
                    vFILTER = vFILTER + "ZONA ,";
                    vFILTER = vFILTER + "LIVRO ,";
                    vFILTER = vFILTER + "CONTA ,";
                    vFILTER = vFILTER + "ROTA ,";
                    vFILTER = vFILTER + "INSTAL ,";
                    vFILTER = vFILTER + "ENTREGA ,";
                    vFILTER = vFILTER + "BANCO ,";
                    vFILTER = vFILTER + "AGENC ,";
                    vFILTER = vFILTER + "CC ,";
                    vFILTER = vFILTER + "GRUPO ,";
                    vFILTER = vFILTER + "CLAS ,";
                    vFILTER = vFILTER + "FASE ,";
                    vFILTER = vFILTER + "NUM ,";
                    vFILTER = vFILTER + "MARCA ,";
                    vFILTER = vFILTER + "DTAFABMEDIDOR ,";
                    vFILTER = vFILTER + "DTAINSTMEDIDOR ,";
                    vFILTER = vFILTER + "CONST ,";
                    vFILTER = vFILTER + "SITUACAO ,";
                    vFILTER = vFILTER + "ULTLEIT ,";
                    vFILTER = vFILTER + "ULTCONS ,";
                    vFILTER = vFILTER + "ILUM ,";
                    vFILTER = vFILTER + "LEIT ,";
                    vFILTER = vFILTER + "FINAL ,";
                    vFILTER = vFILTER + "MEDKVARH ,";
                    vFILTER = vFILTER + "ULTKVARH ,";
                    vFILTER = vFILTER + "CONSTFP ,";
                    vFILTER = vFILTER + "KVARH ,";
                    vFILTER = vFILTER + "CICE ,";
                    vFILTER = vFILTER + "DATA_LIGACAO ,";
                    vFILTER = vFILTER + "DATA_RELIGACAO ,";
                    vFILTER = vFILTER + "DATA_DESLIGAMENTO ,";
                    vFILTER = vFILTER + "DATA_ENTRADA ,";
                    vFILTER = vFILTER + "DATA_CORTE ,";
                    vFILTER = vFILTER + "TENSAO ,";
                    vFILTER = vFILTER + "CARGA ,";
                    vFILTER = vFILTER + "TRANSF ,";
                    vFILTER = vFILTER + "FASELIG ,";
                    vFILTER = vFILTER + "ELETROBRAS ,";
                    vFILTER = vFILTER + "FPFIXO ,";
                    vFILTER = vFILTER + "CODEND ,";
                    vFILTER = vFILTER + "END ,";
                    vFILTER = vFILTER + "COMPLEMENT ,";
                    vFILTER = vFILTER + "BAIRRO ,";
                    vFILTER = vFILTER + "CIDADE ,";
                    vFILTER = vFILTER + "UF ,";
                    vFILTER = vFILTER + "QUADRA ,";
                    vFILTER = vFILTER + "LOTE ,";
                    vFILTER = vFILTER + "NUMERO ,";
                    vFILTER = vFILTER + "CONS_ID ,";
                    vFILTER = vFILTER + "CONSLOC_ID ,";
                    vFILTER = vFILTER + "FLGRES ,";
                    vFILTER = vFILTER + "UNID_ID ,";
                    vFILTER = vFILTER + "ITENSESP ,";
                    vFILTER = vFILTER + "TIPOUC ,";
                    vFILTER = vFILTER + "CEP ,";
                    vFILTER = vFILTER + "TA ,";
                    vFILTER = vFILTER + "ARREDONDA ,";
                    vFILTER = vFILTER + "ARREDONDA_ANT ,";
                    vFILTER = vFILTER + "HISTORICO ,";
                    vFILTER = vFILTER + "DIAVENC ,";
                    vFILTER = vFILTER + "FORMULA_CIP ,";
                    vFILTER = vFILTER + "SOCIAL ,";
                    vFILTER = vFILTER + "IDCNAE ,";
                    vFILTER = vFILTER + "LOCALIDADE ,";
                    vFILTER = vFILTER + "CODEND_ENTREGA ,";
                    vFILTER = vFILTER + "END_ENTREGA ,";
                    vFILTER = vFILTER + "NUM_ENTREGA ,";
                    vFILTER = vFILTER + "BAI_ENTREGA ,";
                    vFILTER = vFILTER + "COMPL_ENTREGA ,";
                    vFILTER = vFILTER + "DIS_ENTREGA ,";
                    vFILTER = vFILTER + "CID_ENTREGA ,";
                    vFILTER = vFILTER + "UF_ENTREGA ,";
                    vFILTER = vFILTER + "QUA_ENTREGA ,";
                    vFILTER = vFILTER + "LOT_ENTREGA ,";
                    vFILTER = vFILTER + "CEP_ENTREGA ,";
                    vFILTER = vFILTER + "CPF_CNPJ ,";
                    vFILTER = vFILTER + "RG ,";
                    vFILTER = vFILTER + "INSC ,";
                    vFILTER = vFILTER + "PESSOA ,";
                    vFILTER = vFILTER + "NOME ,";
                    vFILTER = vFILTER + "CIRCUITO ,";
                    vFILTER = vFILTER + "DISJUNTOR ,";
                    vFILTER = vFILTER + "DISTRITO ,";
                    vFILTER = vFILTER + "AREA ,";
                    vFILTER = vFILTER + "LACRE ,";
                    vFILTER = vFILTER + "RESIDUO_CONSUMO ,";
                    vFILTER = vFILTER + "DECAP_NUM ,";
                    vFILTER = vFILTER + "DECAP_DATA ,";
                    vFILTER = vFILTER + "BANARREC ,";
                    vFILTER = vFILTER + "AP_SAUDE ,";
                    vFILTER = vFILTER + "LUZ_TODOS ,";
                    vFILTER = vFILTER + "RES694 ,";
                    vFILTER = vFILTER + "ISENTO ,";
                    vFILTER = vFILTER + "ALTA_TENSAO ,";
                    vFILTER = vFILTER + "TP_LIGACAO ,";
                    vFILTER = vFILTER + "SOLICITANTE ,";
                    vFILTER = vFILTER + "AGRUPA ,";
                    vFILTER = vFILTER + "AGRUPA_ZONA ,";
                    vFILTER = vFILTER + "AGRUPA_LIVRO ,";
                    vFILTER = vFILTER + "AGRUPA_CONTA ,";
                    vFILTER = vFILTER + "BXRENDA ,";
                    vFILTER = vFILTER + "REGIAO ,";
                    vFILTER = vFILTER + "SGDENVIO ,";
                    vFILTER = vFILTER + "BX0402 ,";
                    vFILTER = vFILTER + "PAGTO_DUVIDOSO ,";
                    vFILTER = vFILTER + "ID_BCO_ANT ,";
                    vFILTER = vFILTER + "ID_BCO_ATUAL ,";
                    vFILTER = vFILTER + "COMPROVANTE_RURAL ,";
                    vFILTER = vFILTER + "JUL2010 ,";
                    vFILTER = vFILTER + "IDTIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "MODELO ,";
                    vFILTER = vFILTER + "IDCONDUTOR ,";
                    vFILTER = vFILTER + "COMPRIMENTO_FIO ,";
                    vFILTER = vFILTER + "COD_TIPO_MEDICAO ,";
                    vFILTER = vFILTER + "TIPO_MEDICAO ,";
                    vFILTER = vFILTER + "IDTIPO_PADRAO_MEDICAO ,";
                    vFILTER = vFILTER + "TC_RELACAO_PRIMARIA ,";
                    vFILTER = vFILTER + "TC_RELACAO_SECUNDARIA ,";
                    vFILTER = vFILTER + "TP_RELACAO_PRIMARIA ,";
                    vFILTER = vFILTER + "TP_RELACAO_SECUNDARIA ,";
                    vFILTER = vFILTER + "IDALIMENTADOR ,";
                    vFILTER = vFILTER + "IDCORRENTE ,";
                    vFILTER = vFILTER + "ESTUFA ,";
                    vFILTER = vFILTER + "RAMAL ,";
                    vFILTER = vFILTER + "DATA_RAMAL ,";
                    vFILTER = vFILTER + "CLIENTEPENDENTE ,";
                    vFILTER = vFILTER + "FLG_AVISO_DEBITO ,";
                    vFILTER = vFILTER + "IDMEDIDOR ,";
                    vFILTER = vFILTER + "CAP ,";
                    vFILTER = vFILTER + "CFOP ,";
                    vFILTER = vFILTER + "DAP ,";
                    vFILTER = vFILTER + "ENCARGO ,";
                    vFILTER = vFILTER + "FLG_SAZONAL ,";
                    vFILTER = vFILTER + "FONE ,";
                    vFILTER = vFILTER + "MAIOR ,";
                    vFILTER = vFILTER + "MAXIMO ,";
                    vFILTER = vFILTER + "PERC ,";
                    vFILTER = vFILTER + "PERC_RETENCAO ,";
                    vFILTER = vFILTER + "QH ,";
                    vFILTER = vFILTER + "CONST_CONS_FP ,";
                    vFILTER = vFILTER + "CONST_CONS_P ,";
                    vFILTER = vFILTER + "CONST_CONSUMO ,";
                    vFILTER = vFILTER + "CONST_DEMANDA ,";
                    vFILTER = vFILTER + "CONST_DEMANDA_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH ,";
                    vFILTER = vFILTER + "CONST_KVARH_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH_P ,";
                    vFILTER = vFILTER + "CONST_RESERVADO ,";
                    vFILTER = vFILTER + "CONSTKVFP ,";
                    vFILTER = vFILTER + "CONSTKVP ,";
                    vFILTER = vFILTER + "DATA_CONTRATO_DEMANDA ,";
                    vFILTER = vFILTER + "DEM_CONTR_FP ,";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA ,";
                    vFILTER = vFILTER + "DEMALIDA ,";
                    vFILTER = vFILTER + "DEMANDA ,";
                    vFILTER = vFILTER + "DEMANDA_CONTR ,";
                    vFILTER = vFILTER + "DEMANDAANT ,";
                    vFILTER = vFILTER + "DMCR ,";
                    vFILTER = vFILTER + "DP12 ,";
                    vFILTER = vFILTER + "ELETR ,";
                    vFILTER = vFILTER + "ICMS_DEMANDA_LIDA ,";
                    vFILTER = vFILTER + "ICMS_DIFERIDO ,";
                    vFILTER = vFILTER + "ICMS_ISENTO_DEMANDA ,";
                    vFILTER = vFILTER + "KVAR ,";
                    vFILTER = vFILTER + "KVARHFPN ,";
                    vFILTER = vFILTER + "KVARHPN ,";
                    vFILTER = vFILTER + "KVARKN ,";
                    vFILTER = vFILTER + "KVARKNANT ,";
                    vFILTER = vFILTER + "LEITANT ,";
                    vFILTER = vFILTER + "LEITDEMA ,";
                    vFILTER = vFILTER + "LEITREATIVO ,";
                    vFILTER = vFILTER + "LIVREESPECIAL ,";
                    vFILTER = vFILTER + "MEDKW ,";
                    vFILTER = vFILTER + "CNAE ,";
                    vFILTER = vFILTER + "IDCCEE ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_P ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_I ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_FP ,";
                    vFILTER = vFILTER + "MICRO_GERACAO ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_P ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_I ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_FP ,";
                    vFILTER = vFILTER + "PARCIALMENTE_CATIVO ,";
                    vFILTER = vFILTER + "DEMANDA_CONTR_ANTERIOR ,";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA_ANTERIOR ,";
                    vFILTER = vFILTER + "DEM_CONTR_FP_ANTERIOR ,";
                    vFILTER = vFILTER + "PERIODO_TESTE ,";
                    vFILTER = vFILTER + "MEDKVARK ,";
                    vFILTER = vFILTER + "ANTRESERV ,";
                    vFILTER = vFILTER + "ARREDONDA_TEMP ,";
                    vFILTER = vFILTER + "ATURESERV ,";
                    vFILTER = vFILTER + "COD_TIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "DTAUTODEC ,";
                    vFILTER = vFILTER + "FLG_ALIQUOTADIF ,";
                    vFILTER = vFILTER + "ISENTOREATIVO ,";
                    vFILTER = vFILTER + "MEDIMEC ,";
                    vFILTER = vFILTER + "NOVAMECA ,";
                    vFILTER = vFILTER + "NUM_UNIVERSALIZACAO ,";
                    vFILTER = vFILTER + "OBSERVACAO ,";
                    vFILTER = vFILTER + "PAGTO_GOVERNO ,";
                    vFILTER = vFILTER + "RG_ORGAO ,";
                    vFILTER = vFILTER + "RG_UF ,";
                    vFILTER = vFILTER + "TIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "UNIVERSALIZACAO ,";
                    vFILTER = vFILTER + "VECTOPROXMES ,";
                    vFILTER = vFILTER + "VIP_COMERCIAL ,";
                    vFILTER = vFILTER + "VIP_TECNICO ,";
                    vFILTER = vFILTER + "IRRIGACAO_AQUICULTURA ,";
                    vFILTER = vFILTER + "ULTLEIT_IRRIGANTE ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES ,";
                    vFILTER = vFILTER + "LIVRE_VERDE ,";
                    vFILTER = vFILTER + "ULTLEIT_DESLIGAMENTO ,";
                    vFILTER = vFILTER + "LIVRE_LEITURA_CONSUMO ,";
                    vFILTER = vFILTER + "INI_PERIODO_TESTE ,";
                    vFILTER = vFILTER + "FIM_PERIODO_TESTE ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE ,";
                    vFILTER = vFILTER + "LATITUDE ,";
                    vFILTER = vFILTER + "LONGITUDE ,";
                    vFILTER = vFILTER + "IRR_HR_INI ,";
                    vFILTER = vFILTER + "IRR_HR_FIM ,";
                    vFILTER = vFILTER + "TARIFA_BRANCA ,";
                    vFILTER = vFILTER + "REATIVO ,";
                    vFILTER = vFILTER + "ISENTO_ICMS_TUSD ,";
                    vFILTER = vFILTER + "ENVIO_COB_JUDICIAL ,";
                    vFILTER = vFILTER + "BLOQUEA_SEG_VIA_FAT ,";
                    vFILTER = vFILTER + "BLOQUEA_RELIGACAO ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_KW_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KW_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_I ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KW_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KW_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_I ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_FP ,";
                    vFILTER = vFILTER + "KWH_RES_P ,";
                    vFILTER = vFILTER + "KWH_RES_I ,";
                    vFILTER = vFILTER + "KWH_RES_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_FP ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_P ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_I ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_FP ,";
                    vFILTER = vFILTER + "CONST_KWH_P ,";
                    vFILTER = vFILTER + "CONST_KWH_I ,";
                    vFILTER = vFILTER + "CONST_KWH_FP ,";
                    vFILTER = vFILTER + "CONST_KW_P ,";
                    vFILTER = vFILTER + "CONST_KW_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH_I ,";
                    vFILTER = vFILTER + "CONJUGE_FATURA ,";
                    vFILTER = vFILTER + "CADERNO ,";
                    vFILTER = vFILTER + "SEQUENCIA  ";

                    vINNERJOIN = " ";

                    vORDERBY = " ";

                    if (objUCFaturamento.INSTAL != string.Empty && objUCFaturamento.INSC != string.Empty)
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND ( UC_FATURAMENTO.NUM <> '' AND UC_FATURAMENTO.NUM <> '0') AND (CONVERT (UC_FATURAMENTO.INSTAL, SIGNED) >= ?INSTAL_INI AND CONVERT (UC_FATURAMENTO.INSTAL,SIGNED) <= ?INSTAL_FIM)  "; }
                        else
                        { vAND = "AND ( UC_FATURAMENTO.NUM <> '' AND UC_FATURAMENTO.NUM <> '0') AND (CONVERT (UC_FATURAMENTO.INSTAL, SIGNED) >= ?INSTAL_INI AND CONVERT (UC_FATURAMENTO.INSTAL,SIGNED) <= ?INSTAL_FIM)  "; }

                    }
                    else
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + " "; }
                        else
                        { vAND = " "; }
                    }



                    cmd = new MySqlCommand(this.QuerySelect);


                    if (objUCFaturamento.INSTAL != string.Empty && objUCFaturamento.INSC != string.Empty)
                    {
                        cmd.Parameters.AddWithValue("?INSTAL_INI", objUCFaturamento.INSTAL.ToString().ToUpper());
                        cmd.Parameters.AddWithValue("?INSTAL_FIM", objUCFaturamento.INSC.ToString().ToUpper());
                    }

                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable Select_4(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "GRUPO_TAR, ";
                    vFILTER = vFILTER + "ID, ";
                    vFILTER = vFILTER + "ZONA ,";
                    vFILTER = vFILTER + "LIVRO ,";
                    vFILTER = vFILTER + "CONTA ,";
                    vFILTER = vFILTER + "ROTA ,";
                    vFILTER = vFILTER + "INSTAL ,";
                    vFILTER = vFILTER + "ENTREGA ,";
                    vFILTER = vFILTER + "BANCO ,";
                    vFILTER = vFILTER + "AGENC ,";
                    vFILTER = vFILTER + "CC ,";
                    vFILTER = vFILTER + "GRUPO ,";
                    vFILTER = vFILTER + "CLAS ,";
                    vFILTER = vFILTER + "FASE ,";
                    vFILTER = vFILTER + "NUM ,";
                    vFILTER = vFILTER + "MARCA ,";
                    vFILTER = vFILTER + "DTAFABMEDIDOR ,";
                    vFILTER = vFILTER + "DTAINSTMEDIDOR ,";
                    vFILTER = vFILTER + "CONST ,";
                    vFILTER = vFILTER + "SITUACAO ,";
                    vFILTER = vFILTER + "ULTLEIT ,";
                    vFILTER = vFILTER + "ULTCONS ,";
                    vFILTER = vFILTER + "ILUM ,";
                    vFILTER = vFILTER + "LEIT ,";
                    vFILTER = vFILTER + "FINAL ,";
                    vFILTER = vFILTER + "MEDKVARH ,";
                    vFILTER = vFILTER + "ULTKVARH ,";
                    vFILTER = vFILTER + "CONSTFP ,";
                    vFILTER = vFILTER + "KVARH ,";
                    vFILTER = vFILTER + "CICE ,";
                    vFILTER = vFILTER + "DATA_LIGACAO ,";
                    vFILTER = vFILTER + "DATA_RELIGACAO ,";
                    vFILTER = vFILTER + "DATA_DESLIGAMENTO ,";
                    vFILTER = vFILTER + "DATA_ENTRADA ,";
                    vFILTER = vFILTER + "DATA_CORTE ,";
                    vFILTER = vFILTER + "TENSAO ,";
                    vFILTER = vFILTER + "CARGA ,";
                    vFILTER = vFILTER + "TRANSF ,";
                    vFILTER = vFILTER + "FASELIG ,";
                    vFILTER = vFILTER + "ELETROBRAS ,";
                    vFILTER = vFILTER + "FPFIXO ,";
                    vFILTER = vFILTER + "CODEND ,";
                    vFILTER = vFILTER + "END ,";
                    vFILTER = vFILTER + "COMPLEMENT ,";
                    vFILTER = vFILTER + "BAIRRO ,";
                    vFILTER = vFILTER + "CIDADE ,";
                    vFILTER = vFILTER + "UF ,";
                    vFILTER = vFILTER + "QUADRA ,";
                    vFILTER = vFILTER + "LOTE ,";
                    vFILTER = vFILTER + "NUMERO ,";
                    vFILTER = vFILTER + "CONS_ID ,";
                    vFILTER = vFILTER + "CONSLOC_ID ,";
                    vFILTER = vFILTER + "FLGRES ,";
                    vFILTER = vFILTER + "UNID_ID ,";
                    vFILTER = vFILTER + "ITENSESP ,";
                    vFILTER = vFILTER + "TIPOUC ,";
                    vFILTER = vFILTER + "CEP ,";
                    vFILTER = vFILTER + "TA ,";
                    vFILTER = vFILTER + "ARREDONDA ,";
                    vFILTER = vFILTER + "ARREDONDA_ANT ,";
                    vFILTER = vFILTER + "HISTORICO ,";
                    vFILTER = vFILTER + "DIAVENC ,";
                    vFILTER = vFILTER + "FORMULA_CIP ,";
                    vFILTER = vFILTER + "SOCIAL ,";
                    vFILTER = vFILTER + "IDCNAE ,";
                    vFILTER = vFILTER + "LOCALIDADE ,";
                    vFILTER = vFILTER + "CODEND_ENTREGA ,";
                    vFILTER = vFILTER + "END_ENTREGA ,";
                    vFILTER = vFILTER + "NUM_ENTREGA ,";
                    vFILTER = vFILTER + "BAI_ENTREGA ,";
                    vFILTER = vFILTER + "COMPL_ENTREGA ,";
                    vFILTER = vFILTER + "DIS_ENTREGA ,";
                    vFILTER = vFILTER + "CID_ENTREGA ,";
                    vFILTER = vFILTER + "UF_ENTREGA ,";
                    vFILTER = vFILTER + "QUA_ENTREGA ,";
                    vFILTER = vFILTER + "LOT_ENTREGA ,";
                    vFILTER = vFILTER + "CEP_ENTREGA ,";
                    vFILTER = vFILTER + "CPF_CNPJ ,";
                    vFILTER = vFILTER + "RG ,";
                    vFILTER = vFILTER + "INSC ,";
                    vFILTER = vFILTER + "PESSOA ,";
                    vFILTER = vFILTER + "NOME ,";
                    vFILTER = vFILTER + "CIRCUITO ,";
                    vFILTER = vFILTER + "DISJUNTOR ,";
                    vFILTER = vFILTER + "DISTRITO ,";
                    vFILTER = vFILTER + "AREA ,";
                    vFILTER = vFILTER + "LACRE ,";
                    vFILTER = vFILTER + "RESIDUO_CONSUMO ,";
                    vFILTER = vFILTER + "DECAP_NUM ,";
                    vFILTER = vFILTER + "DECAP_DATA ,";
                    vFILTER = vFILTER + "BANARREC ,";
                    vFILTER = vFILTER + "AP_SAUDE ,";
                    vFILTER = vFILTER + "LUZ_TODOS ,";
                    vFILTER = vFILTER + "RES694 ,";
                    vFILTER = vFILTER + "ISENTO ,";
                    vFILTER = vFILTER + "ALTA_TENSAO ,";
                    vFILTER = vFILTER + "TP_LIGACAO ,";
                    vFILTER = vFILTER + "SOLICITANTE ,";
                    vFILTER = vFILTER + "AGRUPA ,";
                    vFILTER = vFILTER + "AGRUPA_ZONA ,";
                    vFILTER = vFILTER + "AGRUPA_LIVRO ,";
                    vFILTER = vFILTER + "AGRUPA_CONTA ,";
                    vFILTER = vFILTER + "BXRENDA ,";
                    vFILTER = vFILTER + "REGIAO ,";
                    vFILTER = vFILTER + "SGDENVIO ,";
                    vFILTER = vFILTER + "BX0402 ,";
                    vFILTER = vFILTER + "PAGTO_DUVIDOSO ,";
                    vFILTER = vFILTER + "ID_BCO_ANT ,";
                    vFILTER = vFILTER + "ID_BCO_ATUAL ,";
                    vFILTER = vFILTER + "COMPROVANTE_RURAL ,";
                    vFILTER = vFILTER + "JUL2010 ,";
                    vFILTER = vFILTER + "IDTIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "MODELO ,";
                    vFILTER = vFILTER + "IDCONDUTOR ,";
                    vFILTER = vFILTER + "COMPRIMENTO_FIO ,";
                    vFILTER = vFILTER + "COD_TIPO_MEDICAO ,";
                    vFILTER = vFILTER + "TIPO_MEDICAO ,";
                    vFILTER = vFILTER + "IDTIPO_PADRAO_MEDICAO ,";
                    vFILTER = vFILTER + "TC_RELACAO_PRIMARIA ,";
                    vFILTER = vFILTER + "TC_RELACAO_SECUNDARIA ,";
                    vFILTER = vFILTER + "TP_RELACAO_PRIMARIA ,";
                    vFILTER = vFILTER + "TP_RELACAO_SECUNDARIA ,";
                    vFILTER = vFILTER + "IDALIMENTADOR ,";
                    vFILTER = vFILTER + "IDCORRENTE ,";
                    vFILTER = vFILTER + "ESTUFA ,";
                    vFILTER = vFILTER + "RAMAL ,";
                    vFILTER = vFILTER + "DATA_RAMAL ,";
                    vFILTER = vFILTER + "CLIENTEPENDENTE ,";
                    vFILTER = vFILTER + "FLG_AVISO_DEBITO ,";
                    vFILTER = vFILTER + "IDMEDIDOR ,";
                    vFILTER = vFILTER + "CAP ,";
                    vFILTER = vFILTER + "CFOP ,";
                    vFILTER = vFILTER + "DAP ,";
                    vFILTER = vFILTER + "ENCARGO ,";
                    vFILTER = vFILTER + "FLG_SAZONAL ,";
                    vFILTER = vFILTER + "FONE ,";
                    vFILTER = vFILTER + "MAIOR ,";
                    vFILTER = vFILTER + "MAXIMO ,";
                    vFILTER = vFILTER + "PERC ,";
                    vFILTER = vFILTER + "PERC_RETENCAO ,";
                    vFILTER = vFILTER + "QH ,";
                    vFILTER = vFILTER + "CONST_CONS_FP ,";
                    vFILTER = vFILTER + "CONST_CONS_P ,";
                    vFILTER = vFILTER + "CONST_CONSUMO ,";
                    vFILTER = vFILTER + "CONST_DEMANDA ,";
                    vFILTER = vFILTER + "CONST_DEMANDA_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH ,";
                    vFILTER = vFILTER + "CONST_KVARH_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH_P ,";
                    vFILTER = vFILTER + "CONST_RESERVADO ,";
                    vFILTER = vFILTER + "CONSTKVFP ,";
                    vFILTER = vFILTER + "CONSTKVP ,";
                    vFILTER = vFILTER + "DATA_CONTRATO_DEMANDA ,";
                    vFILTER = vFILTER + "DEM_CONTR_FP ,";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA ,";
                    vFILTER = vFILTER + "DEMALIDA ,";
                    vFILTER = vFILTER + "DEMANDA ,";
                    vFILTER = vFILTER + "DEMANDA_CONTR ,";
                    vFILTER = vFILTER + "DEMANDAANT ,";
                    vFILTER = vFILTER + "DMCR ,";
                    vFILTER = vFILTER + "DP12 ,";
                    vFILTER = vFILTER + "ELETR ,";
                    vFILTER = vFILTER + "ICMS_DEMANDA_LIDA ,";
                    vFILTER = vFILTER + "ICMS_DIFERIDO ,";
                    vFILTER = vFILTER + "ICMS_ISENTO_DEMANDA ,";
                    vFILTER = vFILTER + "KVAR ,";
                    vFILTER = vFILTER + "KVARHFPN ,";
                    vFILTER = vFILTER + "KVARHPN ,";
                    vFILTER = vFILTER + "KVARKN ,";
                    vFILTER = vFILTER + "KVARKNANT ,";
                    vFILTER = vFILTER + "LEITANT ,";
                    vFILTER = vFILTER + "LEITDEMA ,";
                    vFILTER = vFILTER + "LEITREATIVO ,";
                    vFILTER = vFILTER + "LIVREESPECIAL ,";
                    vFILTER = vFILTER + "MEDKW ,";
                    vFILTER = vFILTER + "CNAE ,";
                    vFILTER = vFILTER + "IDCCEE ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_P ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_I ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_FP ,";
                    vFILTER = vFILTER + "MICRO_GERACAO ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_P ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_I ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_FP ,";
                    vFILTER = vFILTER + "PARCIALMENTE_CATIVO ,";
                    vFILTER = vFILTER + "DEMANDA_CONTR_ANTERIOR ,";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA_ANTERIOR ,";
                    vFILTER = vFILTER + "DEM_CONTR_FP_ANTERIOR ,";
                    vFILTER = vFILTER + "PERIODO_TESTE ,";
                    vFILTER = vFILTER + "MEDKVARK ,";
                    vFILTER = vFILTER + "ANTRESERV ,";
                    vFILTER = vFILTER + "ARREDONDA_TEMP ,";
                    vFILTER = vFILTER + "ATURESERV ,";
                    vFILTER = vFILTER + "COD_TIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "DTAUTODEC ,";
                    vFILTER = vFILTER + "FLG_ALIQUOTADIF ,";
                    vFILTER = vFILTER + "ISENTOREATIVO ,";
                    vFILTER = vFILTER + "MEDIMEC ,";
                    vFILTER = vFILTER + "NOVAMECA ,";
                    vFILTER = vFILTER + "NUM_UNIVERSALIZACAO ,";
                    vFILTER = vFILTER + "OBSERVACAO ,";
                    vFILTER = vFILTER + "PAGTO_GOVERNO ,";
                    vFILTER = vFILTER + "RG_ORGAO ,";
                    vFILTER = vFILTER + "RG_UF ,";
                    vFILTER = vFILTER + "TIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "UNIVERSALIZACAO ,";
                    vFILTER = vFILTER + "VECTOPROXMES ,";
                    vFILTER = vFILTER + "VIP_COMERCIAL ,";
                    vFILTER = vFILTER + "VIP_TECNICO ,";
                    vFILTER = vFILTER + "IRRIGACAO_AQUICULTURA ,";
                    vFILTER = vFILTER + "ULTLEIT_IRRIGANTE ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES ,";
                    vFILTER = vFILTER + "LIVRE_VERDE ,";
                    vFILTER = vFILTER + "ULTLEIT_DESLIGAMENTO ,";
                    vFILTER = vFILTER + "LIVRE_LEITURA_CONSUMO ,";
                    vFILTER = vFILTER + "INI_PERIODO_TESTE ,";
                    vFILTER = vFILTER + "FIM_PERIODO_TESTE ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE ,";
                    vFILTER = vFILTER + "LATITUDE ,";
                    vFILTER = vFILTER + "LONGITUDE ,";
                    vFILTER = vFILTER + "IRR_HR_INI ,";
                    vFILTER = vFILTER + "IRR_HR_FIM ,";
                    vFILTER = vFILTER + "TARIFA_BRANCA ,";
                    vFILTER = vFILTER + "REATIVO ,";
                    vFILTER = vFILTER + "ISENTO_ICMS_TUSD ,";
                    vFILTER = vFILTER + "ENVIO_COB_JUDICIAL ,";
                    vFILTER = vFILTER + "BLOQUEA_SEG_VIA_FAT ,";
                    vFILTER = vFILTER + "BLOQUEA_RELIGACAO ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_KW_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KW_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_I ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KW_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KW_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_I ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_FP ,";
                    vFILTER = vFILTER + "KWH_RES_P ,";
                    vFILTER = vFILTER + "KWH_RES_I ,";
                    vFILTER = vFILTER + "KWH_RES_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_FP ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_P ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_I ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_FP ,";
                    vFILTER = vFILTER + "CONST_KWH_P ,";
                    vFILTER = vFILTER + "CONST_KWH_I ,";
                    vFILTER = vFILTER + "CONST_KWH_FP ,";
                    vFILTER = vFILTER + "CONST_KW_P ,";
                    vFILTER = vFILTER + "CONST_KW_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH_I ,";
                    vFILTER = vFILTER + "CONJUGE_FATURA ,";
                    vFILTER = vFILTER + "CADERNO ,";
                    vFILTER = vFILTER + "SEQUENCIA  ";

                    vINNERJOIN = " ";

                    vORDERBY = " ";

                    vAND = vAND + "   AND ZONA  = ?ZONA ";
                    vAND = vAND + "   AND LIVRO = ?LIVRO ";
                    vAND = vAND + "   AND CONTA = ?CONTA ";



                    cmd = new MySqlCommand(this.QuerySelect);

                    cmd.Parameters.AddWithValue("?ZONA", objUCFaturamento.ZONA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?LIVRO", objUCFaturamento.LIVRO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CONTA", objUCFaturamento.CONTA.ToString().ToUpper());

                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable Select_5(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "GRUPO_TAR, ";
                    vFILTER = vFILTER + "ID, ";
                    vFILTER = vFILTER + "ZONA ,";
                    vFILTER = vFILTER + "LIVRO ,";
                    vFILTER = vFILTER + "CONTA ,";
                    vFILTER = vFILTER + "ROTA ,";
                    vFILTER = vFILTER + "INSTAL ,";
                    vFILTER = vFILTER + "ENTREGA ,";
                    vFILTER = vFILTER + "BANCO ,";
                    vFILTER = vFILTER + "AGENC ,";
                    vFILTER = vFILTER + "CC ,";
                    vFILTER = vFILTER + "GRUPO ,";
                    vFILTER = vFILTER + "CLAS ,";
                    vFILTER = vFILTER + "FASE ,";
                    vFILTER = vFILTER + "NUM ,";
                    vFILTER = vFILTER + "MARCA ,";
                    vFILTER = vFILTER + "DTAFABMEDIDOR ,";
                    vFILTER = vFILTER + "DTAINSTMEDIDOR ,";
                    vFILTER = vFILTER + "CONST ,";
                    vFILTER = vFILTER + "SITUACAO ,";
                    vFILTER = vFILTER + "ULTLEIT ,";
                    vFILTER = vFILTER + "ULTCONS ,";
                    vFILTER = vFILTER + "ILUM ,";
                    vFILTER = vFILTER + "LEIT ,";
                    vFILTER = vFILTER + "FINAL ,";
                    vFILTER = vFILTER + "MEDKVARH ,";
                    vFILTER = vFILTER + "ULTKVARH ,";
                    vFILTER = vFILTER + "CONSTFP ,";
                    vFILTER = vFILTER + "KVARH ,";
                    vFILTER = vFILTER + "CICE ,";
                    vFILTER = vFILTER + "DATA_LIGACAO ,";
                    vFILTER = vFILTER + "DATA_RELIGACAO ,";
                    vFILTER = vFILTER + "DATA_DESLIGAMENTO ,";
                    vFILTER = vFILTER + "DATA_ENTRADA ,";
                    vFILTER = vFILTER + "DATA_CORTE ,";
                    vFILTER = vFILTER + "TENSAO ,";
                    vFILTER = vFILTER + "CARGA ,";
                    vFILTER = vFILTER + "TRANSF ,";
                    vFILTER = vFILTER + "FASELIG ,";
                    vFILTER = vFILTER + "ELETROBRAS ,";
                    vFILTER = vFILTER + "FPFIXO ,";
                    vFILTER = vFILTER + "CODEND ,";
                    vFILTER = vFILTER + "END ,";
                    vFILTER = vFILTER + "COMPLEMENT ,";
                    vFILTER = vFILTER + "BAIRRO ,";
                    vFILTER = vFILTER + "CIDADE ,";
                    vFILTER = vFILTER + "UF ,";
                    vFILTER = vFILTER + "QUADRA ,";
                    vFILTER = vFILTER + "LOTE ,";
                    vFILTER = vFILTER + "NUMERO ,";
                    vFILTER = vFILTER + "CONS_ID ,";
                    vFILTER = vFILTER + "CONSLOC_ID ,";
                    vFILTER = vFILTER + "FLGRES ,";
                    vFILTER = vFILTER + "UNID_ID ,";
                    vFILTER = vFILTER + "ITENSESP ,";
                    vFILTER = vFILTER + "TIPOUC ,";
                    vFILTER = vFILTER + "CEP ,";
                    vFILTER = vFILTER + "TA ,";
                    vFILTER = vFILTER + "ARREDONDA ,";
                    vFILTER = vFILTER + "ARREDONDA_ANT ,";
                    vFILTER = vFILTER + "HISTORICO ,";
                    vFILTER = vFILTER + "DIAVENC ,";
                    vFILTER = vFILTER + "FORMULA_CIP ,";
                    vFILTER = vFILTER + "SOCIAL ,";
                    vFILTER = vFILTER + "IDCNAE ,";
                    vFILTER = vFILTER + "LOCALIDADE ,";
                    vFILTER = vFILTER + "CODEND_ENTREGA ,";
                    vFILTER = vFILTER + "END_ENTREGA ,";
                    vFILTER = vFILTER + "NUM_ENTREGA ,";
                    vFILTER = vFILTER + "BAI_ENTREGA ,";
                    vFILTER = vFILTER + "COMPL_ENTREGA ,";
                    vFILTER = vFILTER + "DIS_ENTREGA ,";
                    vFILTER = vFILTER + "CID_ENTREGA ,";
                    vFILTER = vFILTER + "UF_ENTREGA ,";
                    vFILTER = vFILTER + "QUA_ENTREGA ,";
                    vFILTER = vFILTER + "LOT_ENTREGA ,";
                    vFILTER = vFILTER + "CEP_ENTREGA ,";
                    vFILTER = vFILTER + "CPF_CNPJ ,";
                    vFILTER = vFILTER + "RG ,";
                    vFILTER = vFILTER + "INSC ,";
                    vFILTER = vFILTER + "PESSOA ,";
                    vFILTER = vFILTER + "NOME ,";
                    vFILTER = vFILTER + "CIRCUITO ,";
                    vFILTER = vFILTER + "DISJUNTOR ,";
                    vFILTER = vFILTER + "DISTRITO ,";
                    vFILTER = vFILTER + "AREA ,";
                    vFILTER = vFILTER + "LACRE ,";
                    vFILTER = vFILTER + "RESIDUO_CONSUMO ,";
                    vFILTER = vFILTER + "DECAP_NUM ,";
                    vFILTER = vFILTER + "DECAP_DATA ,";
                    vFILTER = vFILTER + "BANARREC ,";
                    vFILTER = vFILTER + "AP_SAUDE ,";
                    vFILTER = vFILTER + "LUZ_TODOS ,";
                    vFILTER = vFILTER + "RES694 ,";
                    vFILTER = vFILTER + "ISENTO ,";
                    vFILTER = vFILTER + "ALTA_TENSAO ,";
                    vFILTER = vFILTER + "TP_LIGACAO ,";
                    vFILTER = vFILTER + "SOLICITANTE ,";
                    vFILTER = vFILTER + "AGRUPA ,";
                    vFILTER = vFILTER + "AGRUPA_ZONA ,";
                    vFILTER = vFILTER + "AGRUPA_LIVRO ,";
                    vFILTER = vFILTER + "AGRUPA_CONTA ,";
                    vFILTER = vFILTER + "BXRENDA ,";
                    vFILTER = vFILTER + "REGIAO ,";
                    vFILTER = vFILTER + "SGDENVIO ,";
                    vFILTER = vFILTER + "BX0402 ,";
                    vFILTER = vFILTER + "PAGTO_DUVIDOSO ,";
                    vFILTER = vFILTER + "ID_BCO_ANT ,";
                    vFILTER = vFILTER + "ID_BCO_ATUAL ,";
                    vFILTER = vFILTER + "COMPROVANTE_RURAL ,";
                    vFILTER = vFILTER + "JUL2010 ,";
                    vFILTER = vFILTER + "IDTIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "MODELO ,";
                    vFILTER = vFILTER + "IDCONDUTOR ,";
                    vFILTER = vFILTER + "COMPRIMENTO_FIO ,";
                    vFILTER = vFILTER + "COD_TIPO_MEDICAO ,";
                    vFILTER = vFILTER + "TIPO_MEDICAO ,";
                    vFILTER = vFILTER + "IDTIPO_PADRAO_MEDICAO ,";
                    vFILTER = vFILTER + "TC_RELACAO_PRIMARIA ,";
                    vFILTER = vFILTER + "TC_RELACAO_SECUNDARIA ,";
                    vFILTER = vFILTER + "TP_RELACAO_PRIMARIA ,";
                    vFILTER = vFILTER + "TP_RELACAO_SECUNDARIA ,";
                    vFILTER = vFILTER + "IDALIMENTADOR ,";
                    vFILTER = vFILTER + "IDCORRENTE ,";
                    vFILTER = vFILTER + "ESTUFA ,";
                    vFILTER = vFILTER + "RAMAL ,";
                    vFILTER = vFILTER + "DATA_RAMAL ,";
                    vFILTER = vFILTER + "CLIENTEPENDENTE ,";
                    vFILTER = vFILTER + "FLG_AVISO_DEBITO ,";
                    vFILTER = vFILTER + "IDMEDIDOR ,";
                    vFILTER = vFILTER + "CAP ,";
                    vFILTER = vFILTER + "CFOP ,";
                    vFILTER = vFILTER + "DAP ,";
                    vFILTER = vFILTER + "ENCARGO ,";
                    vFILTER = vFILTER + "FLG_SAZONAL ,";
                    vFILTER = vFILTER + "FONE ,";
                    vFILTER = vFILTER + "MAIOR ,";
                    vFILTER = vFILTER + "MAXIMO ,";
                    vFILTER = vFILTER + "PERC ,";
                    vFILTER = vFILTER + "PERC_RETENCAO ,";
                    vFILTER = vFILTER + "QH ,";
                    vFILTER = vFILTER + "CONST_CONS_FP ,";
                    vFILTER = vFILTER + "CONST_CONS_P ,";
                    vFILTER = vFILTER + "CONST_CONSUMO ,";
                    vFILTER = vFILTER + "CONST_DEMANDA ,";
                    vFILTER = vFILTER + "CONST_DEMANDA_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH ,";
                    vFILTER = vFILTER + "CONST_KVARH_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH_P ,";
                    vFILTER = vFILTER + "CONST_RESERVADO ,";
                    vFILTER = vFILTER + "CONSTKVFP ,";
                    vFILTER = vFILTER + "CONSTKVP ,";
                    vFILTER = vFILTER + "DATA_CONTRATO_DEMANDA ,";
                    vFILTER = vFILTER + "DEM_CONTR_FP ,";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA ,";
                    vFILTER = vFILTER + "DEMALIDA ,";
                    vFILTER = vFILTER + "DEMANDA ,";
                    vFILTER = vFILTER + "DEMANDA_CONTR ,";
                    vFILTER = vFILTER + "DEMANDAANT ,";
                    vFILTER = vFILTER + "DMCR ,";
                    vFILTER = vFILTER + "DP12 ,";
                    vFILTER = vFILTER + "ELETR ,";
                    vFILTER = vFILTER + "ICMS_DEMANDA_LIDA ,";
                    vFILTER = vFILTER + "ICMS_DIFERIDO ,";
                    vFILTER = vFILTER + "ICMS_ISENTO_DEMANDA ,";
                    vFILTER = vFILTER + "KVAR ,";
                    vFILTER = vFILTER + "KVARHFPN ,";
                    vFILTER = vFILTER + "KVARHPN ,";
                    vFILTER = vFILTER + "KVARKN ,";
                    vFILTER = vFILTER + "KVARKNANT ,";
                    vFILTER = vFILTER + "LEITANT ,";
                    vFILTER = vFILTER + "LEITDEMA ,";
                    vFILTER = vFILTER + "LEITREATIVO ,";
                    vFILTER = vFILTER + "LIVREESPECIAL ,";
                    vFILTER = vFILTER + "MEDKW ,";
                    vFILTER = vFILTER + "CNAE ,";
                    vFILTER = vFILTER + "IDCCEE ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_P ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_I ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_FP ,";
                    vFILTER = vFILTER + "MICRO_GERACAO ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_P ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_I ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_FP ,";
                    vFILTER = vFILTER + "PARCIALMENTE_CATIVO ,";
                    vFILTER = vFILTER + "DEMANDA_CONTR_ANTERIOR ,";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA_ANTERIOR ,";
                    vFILTER = vFILTER + "DEM_CONTR_FP_ANTERIOR ,";
                    vFILTER = vFILTER + "PERIODO_TESTE ,";
                    vFILTER = vFILTER + "MEDKVARK ,";
                    vFILTER = vFILTER + "ANTRESERV ,";
                    vFILTER = vFILTER + "ARREDONDA_TEMP ,";
                    vFILTER = vFILTER + "ATURESERV ,";
                    vFILTER = vFILTER + "COD_TIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "DTAUTODEC ,";
                    vFILTER = vFILTER + "FLG_ALIQUOTADIF ,";
                    vFILTER = vFILTER + "ISENTOREATIVO ,";
                    vFILTER = vFILTER + "MEDIMEC ,";
                    vFILTER = vFILTER + "NOVAMECA ,";
                    vFILTER = vFILTER + "NUM_UNIVERSALIZACAO ,";
                    vFILTER = vFILTER + "OBSERVACAO ,";
                    vFILTER = vFILTER + "PAGTO_GOVERNO ,";
                    vFILTER = vFILTER + "RG_ORGAO ,";
                    vFILTER = vFILTER + "RG_UF ,";
                    vFILTER = vFILTER + "TIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "UNIVERSALIZACAO ,";
                    vFILTER = vFILTER + "VECTOPROXMES ,";
                    vFILTER = vFILTER + "VIP_COMERCIAL ,";
                    vFILTER = vFILTER + "VIP_TECNICO ,";
                    vFILTER = vFILTER + "IRRIGACAO_AQUICULTURA ,";
                    vFILTER = vFILTER + "ULTLEIT_IRRIGANTE ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES ,";
                    vFILTER = vFILTER + "LIVRE_VERDE ,";
                    vFILTER = vFILTER + "ULTLEIT_DESLIGAMENTO ,";
                    vFILTER = vFILTER + "LIVRE_LEITURA_CONSUMO ,";
                    vFILTER = vFILTER + "INI_PERIODO_TESTE ,";
                    vFILTER = vFILTER + "FIM_PERIODO_TESTE ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE ,";
                    vFILTER = vFILTER + "LATITUDE ,";
                    vFILTER = vFILTER + "LONGITUDE ,";
                    vFILTER = vFILTER + "IRR_HR_INI ,";
                    vFILTER = vFILTER + "IRR_HR_FIM ,";
                    vFILTER = vFILTER + "TARIFA_BRANCA ,";
                    vFILTER = vFILTER + "REATIVO ,";
                    vFILTER = vFILTER + "ISENTO_ICMS_TUSD ,";
                    vFILTER = vFILTER + "ENVIO_COB_JUDICIAL ,";
                    vFILTER = vFILTER + "BLOQUEA_SEG_VIA_FAT ,";
                    vFILTER = vFILTER + "BLOQUEA_RELIGACAO ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_KW_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KW_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_I ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KW_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KW_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_I ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_FP ,";
                    vFILTER = vFILTER + "KWH_RES_P ,";
                    vFILTER = vFILTER + "KWH_RES_I ,";
                    vFILTER = vFILTER + "KWH_RES_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_FP ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_P ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_I ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_FP ,";
                    vFILTER = vFILTER + "CONST_KWH_P ,";
                    vFILTER = vFILTER + "CONST_KWH_I ,";
                    vFILTER = vFILTER + "CONST_KWH_FP ,";
                    vFILTER = vFILTER + "CONST_KW_P ,";
                    vFILTER = vFILTER + "CONST_KW_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH_I ,";
                    vFILTER = vFILTER + "CONJUGE_FATURA ,";
                    vFILTER = vFILTER + "CADERNO ,";
                    vFILTER = vFILTER + "SEQUENCIA  ";

                    vINNERJOIN = " ";

                    vORDERBY = " ";

                    vAND = vAND + "   AND ZONA  = ?ZONA ";
                    vAND = vAND + "   AND LIVRO = ?LIVRO ";
                    vAND = vAND + "   AND CONTA = ?CONTA ";
                    vAND = vAND + "   AND UNID_ID = ?UNID_ID ";


                    cmd = new MySqlCommand(this.QuerySelect);

                    cmd.Parameters.AddWithValue("?ZONA", objUCFaturamento.ZONA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?LIVRO", objUCFaturamento.LIVRO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CONTA", objUCFaturamento.CONTA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?UNID_ID", objUCFaturamento.UNID_ID.ToString().ToUpper());

                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable Select_6(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "GRUPO_TAR, ";
                    vFILTER = vFILTER + "ID, ";
                    vFILTER = vFILTER + "ZONA ,";
                    vFILTER = vFILTER + "LIVRO ,";
                    vFILTER = vFILTER + "CONTA ,";
                    vFILTER = vFILTER + "ROTA ,";
                    vFILTER = vFILTER + "INSTAL ,";
                    vFILTER = vFILTER + "ENTREGA ,";
                    vFILTER = vFILTER + "BANCO ,";
                    vFILTER = vFILTER + "AGENC ,";
                    vFILTER = vFILTER + "CC ,";
                    vFILTER = vFILTER + "GRUPO ,";
                    vFILTER = vFILTER + "CLAS ,";
                    vFILTER = vFILTER + "FASE ,";
                    vFILTER = vFILTER + "NUM ,";
                    vFILTER = vFILTER + "MARCA ,";
                    vFILTER = vFILTER + "DTAFABMEDIDOR ,";
                    vFILTER = vFILTER + "DTAINSTMEDIDOR ,";
                    vFILTER = vFILTER + "CONST ,";
                    vFILTER = vFILTER + "SITUACAO ,";
                    vFILTER = vFILTER + "ULTLEIT ,";
                    vFILTER = vFILTER + "ULTCONS ,";
                    vFILTER = vFILTER + "ILUM ,";
                    vFILTER = vFILTER + "LEIT ,";
                    vFILTER = vFILTER + "FINAL ,";
                    vFILTER = vFILTER + "MEDKVARH ,";
                    vFILTER = vFILTER + "ULTKVARH ,";
                    vFILTER = vFILTER + "CONSTFP ,";
                    vFILTER = vFILTER + "KVARH ,";
                    vFILTER = vFILTER + "CICE ,";
                    vFILTER = vFILTER + "DATA_LIGACAO ,";
                    vFILTER = vFILTER + "DATA_RELIGACAO ,";
                    vFILTER = vFILTER + "DATA_DESLIGAMENTO ,";
                    vFILTER = vFILTER + "DATA_ENTRADA ,";
                    vFILTER = vFILTER + "DATA_CORTE ,";
                    vFILTER = vFILTER + "TENSAO ,";
                    vFILTER = vFILTER + "CARGA ,";
                    vFILTER = vFILTER + "TRANSF ,";
                    vFILTER = vFILTER + "FASELIG ,";
                    vFILTER = vFILTER + "ELETROBRAS ,";
                    vFILTER = vFILTER + "FPFIXO ,";
                    vFILTER = vFILTER + "CODEND ,";
                    vFILTER = vFILTER + "END ,";
                    vFILTER = vFILTER + "COMPLEMENT ,";
                    vFILTER = vFILTER + "BAIRRO ,";
                    vFILTER = vFILTER + "CIDADE ,";
                    vFILTER = vFILTER + "UF ,";
                    vFILTER = vFILTER + "QUADRA ,";
                    vFILTER = vFILTER + "LOTE ,";
                    vFILTER = vFILTER + "NUMERO ,";
                    vFILTER = vFILTER + "CONS_ID ,";
                    vFILTER = vFILTER + "CONSLOC_ID ,";
                    vFILTER = vFILTER + "FLGRES ,";
                    vFILTER = vFILTER + "UNID_ID ,";
                    vFILTER = vFILTER + "ITENSESP ,";
                    vFILTER = vFILTER + "TIPOUC ,";
                    vFILTER = vFILTER + "CEP ,";
                    vFILTER = vFILTER + "TA ,";
                    vFILTER = vFILTER + "ARREDONDA ,";
                    vFILTER = vFILTER + "ARREDONDA_ANT ,";
                    vFILTER = vFILTER + "HISTORICO ,";
                    vFILTER = vFILTER + "DIAVENC ,";
                    vFILTER = vFILTER + "FORMULA_CIP ,";
                    vFILTER = vFILTER + "SOCIAL ,";
                    vFILTER = vFILTER + "IDCNAE ,";
                    vFILTER = vFILTER + "LOCALIDADE ,";
                    vFILTER = vFILTER + "CODEND_ENTREGA ,";
                    vFILTER = vFILTER + "END_ENTREGA ,";
                    vFILTER = vFILTER + "NUM_ENTREGA ,";
                    vFILTER = vFILTER + "BAI_ENTREGA ,";
                    vFILTER = vFILTER + "COMPL_ENTREGA ,";
                    vFILTER = vFILTER + "DIS_ENTREGA ,";
                    vFILTER = vFILTER + "CID_ENTREGA ,";
                    vFILTER = vFILTER + "UF_ENTREGA ,";
                    vFILTER = vFILTER + "QUA_ENTREGA ,";
                    vFILTER = vFILTER + "LOT_ENTREGA ,";
                    vFILTER = vFILTER + "CEP_ENTREGA ,";
                    vFILTER = vFILTER + "CPF_CNPJ ,";
                    vFILTER = vFILTER + "RG ,";
                    vFILTER = vFILTER + "INSC ,";
                    vFILTER = vFILTER + "PESSOA ,";
                    vFILTER = vFILTER + "NOME ,";
                    vFILTER = vFILTER + "CIRCUITO ,";
                    vFILTER = vFILTER + "DISJUNTOR ,";
                    vFILTER = vFILTER + "DISTRITO ,";
                    vFILTER = vFILTER + "AREA ,";
                    vFILTER = vFILTER + "LACRE ,";
                    vFILTER = vFILTER + "RESIDUO_CONSUMO ,";
                    vFILTER = vFILTER + "DECAP_NUM ,";
                    vFILTER = vFILTER + "DECAP_DATA ,";
                    vFILTER = vFILTER + "BANARREC ,";
                    vFILTER = vFILTER + "AP_SAUDE ,";
                    vFILTER = vFILTER + "LUZ_TODOS ,";
                    vFILTER = vFILTER + "RES694 ,";
                    vFILTER = vFILTER + "ISENTO ,";
                    vFILTER = vFILTER + "ALTA_TENSAO ,";
                    vFILTER = vFILTER + "TP_LIGACAO ,";
                    vFILTER = vFILTER + "SOLICITANTE ,";
                    vFILTER = vFILTER + "AGRUPA ,";
                    vFILTER = vFILTER + "AGRUPA_ZONA ,";
                    vFILTER = vFILTER + "AGRUPA_LIVRO ,";
                    vFILTER = vFILTER + "AGRUPA_CONTA ,";
                    vFILTER = vFILTER + "BXRENDA ,";
                    vFILTER = vFILTER + "REGIAO ,";
                    vFILTER = vFILTER + "SGDENVIO ,";
                    vFILTER = vFILTER + "BX0402 ,";
                    vFILTER = vFILTER + "PAGTO_DUVIDOSO ,";
                    vFILTER = vFILTER + "ID_BCO_ANT ,";
                    vFILTER = vFILTER + "ID_BCO_ATUAL ,";
                    vFILTER = vFILTER + "COMPROVANTE_RURAL ,";
                    vFILTER = vFILTER + "JUL2010 ,";
                    vFILTER = vFILTER + "IDTIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "MODELO ,";
                    vFILTER = vFILTER + "IDCONDUTOR ,";
                    vFILTER = vFILTER + "COMPRIMENTO_FIO ,";
                    vFILTER = vFILTER + "COD_TIPO_MEDICAO ,";
                    vFILTER = vFILTER + "TIPO_MEDICAO ,";
                    vFILTER = vFILTER + "IDTIPO_PADRAO_MEDICAO ,";
                    vFILTER = vFILTER + "TC_RELACAO_PRIMARIA ,";
                    vFILTER = vFILTER + "TC_RELACAO_SECUNDARIA ,";
                    vFILTER = vFILTER + "TP_RELACAO_PRIMARIA ,";
                    vFILTER = vFILTER + "TP_RELACAO_SECUNDARIA ,";
                    vFILTER = vFILTER + "IDALIMENTADOR ,";
                    vFILTER = vFILTER + "IDCORRENTE ,";
                    vFILTER = vFILTER + "ESTUFA ,";
                    vFILTER = vFILTER + "RAMAL ,";
                    vFILTER = vFILTER + "DATA_RAMAL ,";
                    vFILTER = vFILTER + "CLIENTEPENDENTE ,";
                    vFILTER = vFILTER + "FLG_AVISO_DEBITO ,";
                    vFILTER = vFILTER + "IDMEDIDOR ,";
                    vFILTER = vFILTER + "CAP ,";
                    vFILTER = vFILTER + "CFOP ,";
                    vFILTER = vFILTER + "DAP ,";
                    vFILTER = vFILTER + "ENCARGO ,";
                    vFILTER = vFILTER + "FLG_SAZONAL ,";
                    vFILTER = vFILTER + "FONE ,";
                    vFILTER = vFILTER + "MAIOR ,";
                    vFILTER = vFILTER + "MAXIMO ,";
                    vFILTER = vFILTER + "PERC ,";
                    vFILTER = vFILTER + "PERC_RETENCAO ,";
                    vFILTER = vFILTER + "QH ,";
                    vFILTER = vFILTER + "CONST_CONS_FP ,";
                    vFILTER = vFILTER + "CONST_CONS_P ,";
                    vFILTER = vFILTER + "CONST_CONSUMO ,";
                    vFILTER = vFILTER + "CONST_DEMANDA ,";
                    vFILTER = vFILTER + "CONST_DEMANDA_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH ,";
                    vFILTER = vFILTER + "CONST_KVARH_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH_P ,";
                    vFILTER = vFILTER + "CONST_RESERVADO ,";
                    vFILTER = vFILTER + "CONSTKVFP ,";
                    vFILTER = vFILTER + "CONSTKVP ,";
                    vFILTER = vFILTER + "DATA_CONTRATO_DEMANDA ,";
                    vFILTER = vFILTER + "DEM_CONTR_FP ,";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA ,";
                    vFILTER = vFILTER + "DEMALIDA ,";
                    vFILTER = vFILTER + "DEMANDA ,";
                    vFILTER = vFILTER + "DEMANDA_CONTR ,";
                    vFILTER = vFILTER + "DEMANDAANT ,";
                    vFILTER = vFILTER + "DMCR ,";
                    vFILTER = vFILTER + "DP12 ,";
                    vFILTER = vFILTER + "ELETR ,";
                    vFILTER = vFILTER + "ICMS_DEMANDA_LIDA ,";
                    vFILTER = vFILTER + "ICMS_DIFERIDO ,";
                    vFILTER = vFILTER + "ICMS_ISENTO_DEMANDA ,";
                    vFILTER = vFILTER + "KVAR ,";
                    vFILTER = vFILTER + "KVARHFPN ,";
                    vFILTER = vFILTER + "KVARHPN ,";
                    vFILTER = vFILTER + "KVARKN ,";
                    vFILTER = vFILTER + "KVARKNANT ,";
                    vFILTER = vFILTER + "LEITANT ,";
                    vFILTER = vFILTER + "LEITDEMA ,";
                    vFILTER = vFILTER + "LEITREATIVO ,";
                    vFILTER = vFILTER + "LIVREESPECIAL ,";
                    vFILTER = vFILTER + "MEDKW ,";
                    vFILTER = vFILTER + "CNAE ,";
                    vFILTER = vFILTER + "IDCCEE ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_P ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_I ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_FP ,";
                    vFILTER = vFILTER + "MICRO_GERACAO ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_P ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_I ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_FP ,";
                    vFILTER = vFILTER + "PARCIALMENTE_CATIVO ,";
                    vFILTER = vFILTER + "DEMANDA_CONTR_ANTERIOR ,";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA_ANTERIOR ,";
                    vFILTER = vFILTER + "DEM_CONTR_FP_ANTERIOR ,";
                    vFILTER = vFILTER + "PERIODO_TESTE ,";
                    vFILTER = vFILTER + "MEDKVARK ,";
                    vFILTER = vFILTER + "ANTRESERV ,";
                    vFILTER = vFILTER + "ARREDONDA_TEMP ,";
                    vFILTER = vFILTER + "ATURESERV ,";
                    vFILTER = vFILTER + "COD_TIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "DTAUTODEC ,";
                    vFILTER = vFILTER + "FLG_ALIQUOTADIF ,";
                    vFILTER = vFILTER + "ISENTOREATIVO ,";
                    vFILTER = vFILTER + "MEDIMEC ,";
                    vFILTER = vFILTER + "NOVAMECA ,";
                    vFILTER = vFILTER + "NUM_UNIVERSALIZACAO ,";
                    vFILTER = vFILTER + "OBSERVACAO ,";
                    vFILTER = vFILTER + "PAGTO_GOVERNO ,";
                    vFILTER = vFILTER + "RG_ORGAO ,";
                    vFILTER = vFILTER + "RG_UF ,";
                    vFILTER = vFILTER + "TIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "UNIVERSALIZACAO ,";
                    vFILTER = vFILTER + "VECTOPROXMES ,";
                    vFILTER = vFILTER + "VIP_COMERCIAL ,";
                    vFILTER = vFILTER + "VIP_TECNICO ,";
                    vFILTER = vFILTER + "IRRIGACAO_AQUICULTURA ,";
                    vFILTER = vFILTER + "ULTLEIT_IRRIGANTE ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES ,";
                    vFILTER = vFILTER + "LIVRE_VERDE ,";
                    vFILTER = vFILTER + "ULTLEIT_DESLIGAMENTO ,";
                    vFILTER = vFILTER + "LIVRE_LEITURA_CONSUMO ,";
                    vFILTER = vFILTER + "INI_PERIODO_TESTE ,";
                    vFILTER = vFILTER + "FIM_PERIODO_TESTE ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE ,";
                    vFILTER = vFILTER + "LATITUDE ,";
                    vFILTER = vFILTER + "LONGITUDE ,";
                    vFILTER = vFILTER + "IRR_HR_INI ,";
                    vFILTER = vFILTER + "IRR_HR_FIM ,";
                    vFILTER = vFILTER + "TARIFA_BRANCA ,";
                    vFILTER = vFILTER + "REATIVO ,";
                    vFILTER = vFILTER + "ISENTO_ICMS_TUSD ,";
                    vFILTER = vFILTER + "ENVIO_COB_JUDICIAL ,";
                    vFILTER = vFILTER + "BLOQUEA_SEG_VIA_FAT ,";
                    vFILTER = vFILTER + "BLOQUEA_RELIGACAO ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_KW_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KW_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_I ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KW_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KW_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_I ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_FP ,";
                    vFILTER = vFILTER + "KWH_RES_P ,";
                    vFILTER = vFILTER + "KWH_RES_I ,";
                    vFILTER = vFILTER + "KWH_RES_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_FP ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_P ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_I ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_FP ,";
                    vFILTER = vFILTER + "CONST_KWH_P ,";
                    vFILTER = vFILTER + "CONST_KWH_I ,";
                    vFILTER = vFILTER + "CONST_KWH_FP ,";
                    vFILTER = vFILTER + "CONST_KW_P ,";
                    vFILTER = vFILTER + "CONST_KW_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH_I ,";
                    vFILTER = vFILTER + "CONJUGE_FATURA ,";
                    vFILTER = vFILTER + "CADERNO ,";
                    vFILTER = vFILTER + "SEQUENCIA  ";

                    vINNERJOIN = " ";

                    vORDERBY = "ORDER BY UC_FATURAMENTO.SEQUENCIA ASC ";

                    vAND = vAND + "   AND MID(TRIM(UC_FATURAMENTO.ROTA), 1, 4) = ?ROTA ";

                    if (objUCFaturamento.DIAVENC != " ")
                    {
                        vAND = vAND + "  AND UC_FATURAMENTO.DIAVENC = ?DIAVENC ";
                    }

                    vAND = vAND + "   AND MID(UC_FATURAMENTO.GRUPO, 1,1)  = 'B' ";
                    vAND = vAND + "   AND UC_FATURAMENTO.ZONA <> ?ZONA ";
                    vAND = vAND + "   AND UC_FATURAMENTO.SITUACAO IN( " + objUCFaturamento.SITUACAO.ToString().ToUpper() + ") ";
                    if (objUCFaturamento.MICRO_GERACAO == 1) { vAND = vAND + "   AND UC_FATURAMENTO.MICRO_GERACAO IN( " + objUCFaturamento.MICRO_GERACAO.ToString().ToUpper() + ") "; }
                    


                    cmd = new MySqlCommand(this.QuerySelect);

                    cmd.Parameters.AddWithValue("?ROTA", objUCFaturamento.ROTA.ToString().ToUpper());

                    if (objUCFaturamento.DIAVENC != " ")
                    {
                        cmd.Parameters.AddWithValue("?DIAVENC", objUCFaturamento.DIAVENC.ToString().ToUpper());
                    }

                    cmd.Parameters.AddWithValue("?ZONA", objUCFaturamento.ZONA.ToString().ToUpper());


                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable Select_7(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "GRUPO_TAR, ";
                    vFILTER = vFILTER + "ID, ";
                    vFILTER = vFILTER + "ZONA ,";
                    vFILTER = vFILTER + "LIVRO ,";
                    vFILTER = vFILTER + "CONTA ,";
                    vFILTER = vFILTER + "ROTA ,";
                    vFILTER = vFILTER + "INSTAL ,";
                    vFILTER = vFILTER + "ENTREGA ,";
                    vFILTER = vFILTER + "BANCO ,";
                    vFILTER = vFILTER + "AGENC ,";
                    vFILTER = vFILTER + "CC ,";
                    vFILTER = vFILTER + "GRUPO ,";
                    vFILTER = vFILTER + "CLAS ,";
                    vFILTER = vFILTER + "FASE ,";
                    vFILTER = vFILTER + "NUM ,";
                    vFILTER = vFILTER + "MARCA ,";
                    vFILTER = vFILTER + "DTAFABMEDIDOR ,";
                    vFILTER = vFILTER + "DTAINSTMEDIDOR ,";
                    vFILTER = vFILTER + "CONST ,";
                    vFILTER = vFILTER + "SITUACAO ,";
                    vFILTER = vFILTER + "ULTLEIT ,";
                    vFILTER = vFILTER + "ULTCONS ,";
                    vFILTER = vFILTER + "ILUM ,";
                    vFILTER = vFILTER + "LEIT ,";
                    vFILTER = vFILTER + "FINAL ,";
                    vFILTER = vFILTER + "MEDKVARH ,";
                    vFILTER = vFILTER + "ULTKVARH ,";
                    vFILTER = vFILTER + "CONSTFP ,";
                    vFILTER = vFILTER + "KVARH ,";
                    vFILTER = vFILTER + "CICE ,";
                    vFILTER = vFILTER + "DATA_LIGACAO ,";
                    vFILTER = vFILTER + "DATA_RELIGACAO ,";
                    vFILTER = vFILTER + "DATA_DESLIGAMENTO ,";
                    vFILTER = vFILTER + "DATA_ENTRADA ,";
                    vFILTER = vFILTER + "DATA_CORTE ,";
                    vFILTER = vFILTER + "TENSAO ,";
                    vFILTER = vFILTER + "CARGA ,";
                    vFILTER = vFILTER + "TRANSF ,";
                    vFILTER = vFILTER + "FASELIG ,";
                    vFILTER = vFILTER + "ELETROBRAS ,";
                    vFILTER = vFILTER + "FPFIXO ,";
                    vFILTER = vFILTER + "CODEND ,";
                    vFILTER = vFILTER + "END ,";
                    vFILTER = vFILTER + "COMPLEMENT ,";
                    vFILTER = vFILTER + "BAIRRO ,";
                    vFILTER = vFILTER + "CIDADE ,";
                    vFILTER = vFILTER + "UF ,";
                    vFILTER = vFILTER + "QUADRA ,";
                    vFILTER = vFILTER + "LOTE ,";
                    vFILTER = vFILTER + "NUMERO ,";
                    vFILTER = vFILTER + "CONS_ID ,";
                    vFILTER = vFILTER + "CONSLOC_ID ,";
                    vFILTER = vFILTER + "FLGRES ,";
                    vFILTER = vFILTER + "UNID_ID ,";
                    vFILTER = vFILTER + "ITENSESP ,";
                    vFILTER = vFILTER + "TIPOUC ,";
                    vFILTER = vFILTER + "CEP ,";
                    vFILTER = vFILTER + "TA ,";
                    vFILTER = vFILTER + "ARREDONDA ,";
                    vFILTER = vFILTER + "ARREDONDA_ANT ,";
                    vFILTER = vFILTER + "HISTORICO ,";
                    vFILTER = vFILTER + "DIAVENC ,";
                    vFILTER = vFILTER + "FORMULA_CIP ,";
                    vFILTER = vFILTER + "SOCIAL ,";
                    vFILTER = vFILTER + "IDCNAE ,";
                    vFILTER = vFILTER + "LOCALIDADE ,";
                    vFILTER = vFILTER + "CODEND_ENTREGA ,";
                    vFILTER = vFILTER + "END_ENTREGA ,";
                    vFILTER = vFILTER + "NUM_ENTREGA ,";
                    vFILTER = vFILTER + "BAI_ENTREGA ,";
                    vFILTER = vFILTER + "COMPL_ENTREGA ,";
                    vFILTER = vFILTER + "DIS_ENTREGA ,";
                    vFILTER = vFILTER + "CID_ENTREGA ,";
                    vFILTER = vFILTER + "UF_ENTREGA ,";
                    vFILTER = vFILTER + "QUA_ENTREGA ,";
                    vFILTER = vFILTER + "LOT_ENTREGA ,";
                    vFILTER = vFILTER + "CEP_ENTREGA ,";
                    vFILTER = vFILTER + "CPF_CNPJ ,";
                    vFILTER = vFILTER + "RG ,";
                    vFILTER = vFILTER + "INSC ,";
                    vFILTER = vFILTER + "PESSOA ,";
                    vFILTER = vFILTER + "NOME ,";
                    vFILTER = vFILTER + "CIRCUITO ,";
                    vFILTER = vFILTER + "DISJUNTOR ,";
                    vFILTER = vFILTER + "DISTRITO ,";
                    vFILTER = vFILTER + "AREA ,";
                    vFILTER = vFILTER + "LACRE ,";
                    vFILTER = vFILTER + "RESIDUO_CONSUMO ,";
                    vFILTER = vFILTER + "DECAP_NUM ,";
                    vFILTER = vFILTER + "DECAP_DATA ,";
                    vFILTER = vFILTER + "BANARREC ,";
                    vFILTER = vFILTER + "AP_SAUDE ,";
                    vFILTER = vFILTER + "LUZ_TODOS ,";
                    vFILTER = vFILTER + "RES694 ,";
                    vFILTER = vFILTER + "ISENTO ,";
                    vFILTER = vFILTER + "ALTA_TENSAO ,";
                    vFILTER = vFILTER + "TP_LIGACAO ,";
                    vFILTER = vFILTER + "SOLICITANTE ,";
                    vFILTER = vFILTER + "AGRUPA ,";
                    vFILTER = vFILTER + "AGRUPA_ZONA ,";
                    vFILTER = vFILTER + "AGRUPA_LIVRO ,";
                    vFILTER = vFILTER + "AGRUPA_CONTA ,";
                    vFILTER = vFILTER + "BXRENDA ,";
                    vFILTER = vFILTER + "REGIAO ,";
                    vFILTER = vFILTER + "SGDENVIO ,";
                    vFILTER = vFILTER + "BX0402 ,";
                    vFILTER = vFILTER + "PAGTO_DUVIDOSO ,";
                    vFILTER = vFILTER + "ID_BCO_ANT ,";
                    vFILTER = vFILTER + "ID_BCO_ATUAL ,";
                    vFILTER = vFILTER + "COMPROVANTE_RURAL ,";
                    vFILTER = vFILTER + "JUL2010 ,";
                    vFILTER = vFILTER + "IDTIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "MODELO ,";
                    vFILTER = vFILTER + "IDCONDUTOR ,";
                    vFILTER = vFILTER + "COMPRIMENTO_FIO ,";
                    vFILTER = vFILTER + "COD_TIPO_MEDICAO ,";
                    vFILTER = vFILTER + "TIPO_MEDICAO ,";
                    vFILTER = vFILTER + "IDTIPO_PADRAO_MEDICAO ,";
                    vFILTER = vFILTER + "TC_RELACAO_PRIMARIA ,";
                    vFILTER = vFILTER + "TC_RELACAO_SECUNDARIA ,";
                    vFILTER = vFILTER + "TP_RELACAO_PRIMARIA ,";
                    vFILTER = vFILTER + "TP_RELACAO_SECUNDARIA ,";
                    vFILTER = vFILTER + "IDALIMENTADOR ,";
                    vFILTER = vFILTER + "IDCORRENTE ,";
                    vFILTER = vFILTER + "ESTUFA ,";
                    vFILTER = vFILTER + "RAMAL ,";
                    vFILTER = vFILTER + "DATA_RAMAL ,";
                    vFILTER = vFILTER + "CLIENTEPENDENTE ,";
                    vFILTER = vFILTER + "FLG_AVISO_DEBITO ,";
                    vFILTER = vFILTER + "IDMEDIDOR ,";
                    vFILTER = vFILTER + "CAP ,";
                    vFILTER = vFILTER + "CFOP ,";
                    vFILTER = vFILTER + "DAP ,";
                    vFILTER = vFILTER + "ENCARGO ,";
                    vFILTER = vFILTER + "FLG_SAZONAL ,";
                    vFILTER = vFILTER + "FONE ,";
                    vFILTER = vFILTER + "MAIOR ,";
                    vFILTER = vFILTER + "MAXIMO ,";
                    vFILTER = vFILTER + "PERC ,";
                    vFILTER = vFILTER + "PERC_RETENCAO ,";
                    vFILTER = vFILTER + "QH ,";
                    vFILTER = vFILTER + "CONST_CONS_FP ,";
                    vFILTER = vFILTER + "CONST_CONS_P ,";
                    vFILTER = vFILTER + "CONST_CONSUMO ,";
                    vFILTER = vFILTER + "CONST_DEMANDA ,";
                    vFILTER = vFILTER + "CONST_DEMANDA_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH ,";
                    vFILTER = vFILTER + "CONST_KVARH_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH_P ,";
                    vFILTER = vFILTER + "CONST_RESERVADO ,";
                    vFILTER = vFILTER + "CONSTKVFP ,";
                    vFILTER = vFILTER + "CONSTKVP ,";
                    vFILTER = vFILTER + "DATA_CONTRATO_DEMANDA ,";
                    vFILTER = vFILTER + "DEM_CONTR_FP ,";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA ,";
                    vFILTER = vFILTER + "DEMALIDA ,";
                    vFILTER = vFILTER + "DEMANDA ,";
                    vFILTER = vFILTER + "DEMANDA_CONTR ,";
                    vFILTER = vFILTER + "DEMANDAANT ,";
                    vFILTER = vFILTER + "DMCR ,";
                    vFILTER = vFILTER + "DP12 ,";
                    vFILTER = vFILTER + "ELETR ,";
                    vFILTER = vFILTER + "ICMS_DEMANDA_LIDA ,";
                    vFILTER = vFILTER + "ICMS_DIFERIDO ,";
                    vFILTER = vFILTER + "ICMS_ISENTO_DEMANDA ,";
                    vFILTER = vFILTER + "KVAR ,";
                    vFILTER = vFILTER + "KVARHFPN ,";
                    vFILTER = vFILTER + "KVARHPN ,";
                    vFILTER = vFILTER + "KVARKN ,";
                    vFILTER = vFILTER + "KVARKNANT ,";
                    vFILTER = vFILTER + "LEITANT ,";
                    vFILTER = vFILTER + "LEITDEMA ,";
                    vFILTER = vFILTER + "LEITREATIVO ,";
                    vFILTER = vFILTER + "LIVREESPECIAL ,";
                    vFILTER = vFILTER + "MEDKW ,";
                    vFILTER = vFILTER + "CNAE ,";
                    vFILTER = vFILTER + "IDCCEE ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_P ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_I ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_FP ,";
                    vFILTER = vFILTER + "MICRO_GERACAO ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_P ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_I ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_FP ,";
                    vFILTER = vFILTER + "PARCIALMENTE_CATIVO ,";
                    vFILTER = vFILTER + "DEMANDA_CONTR_ANTERIOR ,";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA_ANTERIOR ,";
                    vFILTER = vFILTER + "DEM_CONTR_FP_ANTERIOR ,";
                    vFILTER = vFILTER + "PERIODO_TESTE ,";
                    vFILTER = vFILTER + "MEDKVARK ,";
                    vFILTER = vFILTER + "ANTRESERV ,";
                    vFILTER = vFILTER + "ARREDONDA_TEMP ,";
                    vFILTER = vFILTER + "ATURESERV ,";
                    vFILTER = vFILTER + "COD_TIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "DTAUTODEC ,";
                    vFILTER = vFILTER + "FLG_ALIQUOTADIF ,";
                    vFILTER = vFILTER + "ISENTOREATIVO ,";
                    vFILTER = vFILTER + "MEDIMEC ,";
                    vFILTER = vFILTER + "NOVAMECA ,";
                    vFILTER = vFILTER + "NUM_UNIVERSALIZACAO ,";
                    vFILTER = vFILTER + "OBSERVACAO ,";
                    vFILTER = vFILTER + "PAGTO_GOVERNO ,";
                    vFILTER = vFILTER + "RG_ORGAO ,";
                    vFILTER = vFILTER + "RG_UF ,";
                    vFILTER = vFILTER + "TIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "UNIVERSALIZACAO ,";
                    vFILTER = vFILTER + "VECTOPROXMES ,";
                    vFILTER = vFILTER + "VIP_COMERCIAL ,";
                    vFILTER = vFILTER + "VIP_TECNICO ,";
                    vFILTER = vFILTER + "IRRIGACAO_AQUICULTURA ,";
                    vFILTER = vFILTER + "ULTLEIT_IRRIGANTE ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES ,";
                    vFILTER = vFILTER + "LIVRE_VERDE ,";
                    vFILTER = vFILTER + "ULTLEIT_DESLIGAMENTO ,";
                    vFILTER = vFILTER + "LIVRE_LEITURA_CONSUMO ,";
                    vFILTER = vFILTER + "INI_PERIODO_TESTE ,";
                    vFILTER = vFILTER + "FIM_PERIODO_TESTE ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE ,";
                    vFILTER = vFILTER + "LATITUDE ,";
                    vFILTER = vFILTER + "LONGITUDE ,";
                    vFILTER = vFILTER + "IRR_HR_INI ,";
                    vFILTER = vFILTER + "IRR_HR_FIM ,";
                    vFILTER = vFILTER + "TARIFA_BRANCA ,";
                    vFILTER = vFILTER + "REATIVO ,";
                    vFILTER = vFILTER + "ISENTO_ICMS_TUSD ,";
                    vFILTER = vFILTER + "ENVIO_COB_JUDICIAL ,";
                    vFILTER = vFILTER + "BLOQUEA_SEG_VIA_FAT ,";
                    vFILTER = vFILTER + "BLOQUEA_RELIGACAO ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_KW_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KW_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_I ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KW_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KW_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_I ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_FP ,";
                    vFILTER = vFILTER + "KWH_RES_P ,";
                    vFILTER = vFILTER + "KWH_RES_I ,";
                    vFILTER = vFILTER + "KWH_RES_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_FP ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_P ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_I ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_FP ,";
                    vFILTER = vFILTER + "CONST_KWH_P ,";
                    vFILTER = vFILTER + "CONST_KWH_I ,";
                    vFILTER = vFILTER + "CONST_KWH_FP ,";
                    vFILTER = vFILTER + "CONST_KW_P ,";
                    vFILTER = vFILTER + "CONST_KW_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH_I ,";
                    vFILTER = vFILTER + "CONJUGE_FATURA ,";
                    vFILTER = vFILTER + "CADERNO ,";
                    vFILTER = vFILTER + "SEQUENCIA  ";

                    vINNERJOIN = " ";

                    vORDERBY = "ORDER BY UC_FATURAMENTO.ROTA ASC ";

                    vAND = vAND + "    AND UC_FATURAMENTO.ROTA >= ?ROTA ";
                    vAND = vAND + "    AND UC_FATURAMENTO.ROTA <= ?AGRUPA ";


                    if (objUCFaturamento.SITUACAO != " ")
                    {
                        vAND = vAND + "   ?SITUACAO ";
                    }


                    cmd = new MySqlCommand(this.QuerySelect);

                    cmd.Parameters.AddWithValue("?ROTA", objUCFaturamento.ROTA.ToString().ToUpper());

                    if (objUCFaturamento.SITUACAO != " ")
                    {
                        cmd.Parameters.AddWithValue("?SITUACAO", objUCFaturamento.SITUACAO.ToString().ToUpper());
                    }

                    cmd.Parameters.AddWithValue("?AGRUPA", objUCFaturamento.AGRUPA.ToString().ToUpper());


                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable Select_8(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "GRUPO_TAR, ";
                    vFILTER = vFILTER + "ID, ";
                    vFILTER = vFILTER + "ZONA ,";
                    vFILTER = vFILTER + "LIVRO ,";
                    vFILTER = vFILTER + "CONTA ,";
                    vFILTER = vFILTER + "ROTA ,";
                    vFILTER = vFILTER + "INSTAL ,";
                    vFILTER = vFILTER + "ENTREGA ,";
                    vFILTER = vFILTER + "BANCO ,";
                    vFILTER = vFILTER + "AGENC ,";
                    vFILTER = vFILTER + "CC ,";
                    vFILTER = vFILTER + "GRUPO ,";
                    vFILTER = vFILTER + "CLAS ,";
                    vFILTER = vFILTER + "FASE ,";
                    vFILTER = vFILTER + "NUM ,";
                    vFILTER = vFILTER + "MARCA ,";
                    vFILTER = vFILTER + "DTAFABMEDIDOR ,";
                    vFILTER = vFILTER + "DTAINSTMEDIDOR ,";
                    vFILTER = vFILTER + "CONST ,";
                    vFILTER = vFILTER + "SITUACAO ,";
                    vFILTER = vFILTER + "ULTLEIT ,";
                    vFILTER = vFILTER + "ULTCONS ,";
                    vFILTER = vFILTER + "ILUM ,";
                    vFILTER = vFILTER + "LEIT ,";
                    vFILTER = vFILTER + "FINAL ,";
                    vFILTER = vFILTER + "MEDKVARH ,";
                    vFILTER = vFILTER + "ULTKVARH ,";
                    vFILTER = vFILTER + "CONSTFP ,";
                    vFILTER = vFILTER + "KVARH ,";
                    vFILTER = vFILTER + "CICE ,";
                    vFILTER = vFILTER + "DATA_LIGACAO ,";
                    vFILTER = vFILTER + "DATA_RELIGACAO ,";
                    vFILTER = vFILTER + "DATA_DESLIGAMENTO ,";
                    vFILTER = vFILTER + "DATA_ENTRADA ,";
                    vFILTER = vFILTER + "DATA_CORTE ,";
                    vFILTER = vFILTER + "TENSAO ,";
                    vFILTER = vFILTER + "CARGA ,";
                    vFILTER = vFILTER + "TRANSF ,";
                    vFILTER = vFILTER + "FASELIG ,";
                    vFILTER = vFILTER + "ELETROBRAS ,";
                    vFILTER = vFILTER + "FPFIXO ,";
                    vFILTER = vFILTER + "CODEND ,";
                    vFILTER = vFILTER + "END ,";
                    vFILTER = vFILTER + "COMPLEMENT ,";
                    vFILTER = vFILTER + "BAIRRO ,";
                    vFILTER = vFILTER + "CIDADE ,";
                    vFILTER = vFILTER + "UF ,";
                    vFILTER = vFILTER + "QUADRA ,";
                    vFILTER = vFILTER + "LOTE ,";
                    vFILTER = vFILTER + "NUMERO ,";
                    vFILTER = vFILTER + "CONS_ID ,";
                    vFILTER = vFILTER + "CONSLOC_ID ,";
                    vFILTER = vFILTER + "FLGRES ,";
                    vFILTER = vFILTER + "UNID_ID ,";
                    vFILTER = vFILTER + "ITENSESP ,";
                    vFILTER = vFILTER + "TIPOUC ,";
                    vFILTER = vFILTER + "CEP ,";
                    vFILTER = vFILTER + "TA ,";
                    vFILTER = vFILTER + "ARREDONDA ,";
                    vFILTER = vFILTER + "ARREDONDA_ANT ,";
                    vFILTER = vFILTER + "HISTORICO ,";
                    vFILTER = vFILTER + "DIAVENC ,";
                    vFILTER = vFILTER + "FORMULA_CIP ,";
                    vFILTER = vFILTER + "SOCIAL ,";
                    vFILTER = vFILTER + "IDCNAE ,";
                    vFILTER = vFILTER + "LOCALIDADE ,";
                    vFILTER = vFILTER + "CODEND_ENTREGA ,";
                    vFILTER = vFILTER + "END_ENTREGA ,";
                    vFILTER = vFILTER + "NUM_ENTREGA ,";
                    vFILTER = vFILTER + "BAI_ENTREGA ,";
                    vFILTER = vFILTER + "COMPL_ENTREGA ,";
                    vFILTER = vFILTER + "DIS_ENTREGA ,";
                    vFILTER = vFILTER + "CID_ENTREGA ,";
                    vFILTER = vFILTER + "UF_ENTREGA ,";
                    vFILTER = vFILTER + "QUA_ENTREGA ,";
                    vFILTER = vFILTER + "LOT_ENTREGA ,";
                    vFILTER = vFILTER + "CEP_ENTREGA ,";
                    vFILTER = vFILTER + "CPF_CNPJ ,";
                    vFILTER = vFILTER + "RG ,";
                    vFILTER = vFILTER + "INSC ,";
                    vFILTER = vFILTER + "PESSOA ,";
                    vFILTER = vFILTER + "NOME ,";
                    vFILTER = vFILTER + "CIRCUITO ,";
                    vFILTER = vFILTER + "DISJUNTOR ,";
                    vFILTER = vFILTER + "DISTRITO ,";
                    vFILTER = vFILTER + "AREA ,";
                    vFILTER = vFILTER + "LACRE ,";
                    vFILTER = vFILTER + "RESIDUO_CONSUMO ,";
                    vFILTER = vFILTER + "DECAP_NUM ,";
                    vFILTER = vFILTER + "DECAP_DATA ,";
                    vFILTER = vFILTER + "BANARREC ,";
                    vFILTER = vFILTER + "AP_SAUDE ,";
                    vFILTER = vFILTER + "LUZ_TODOS ,";
                    vFILTER = vFILTER + "RES694 ,";
                    vFILTER = vFILTER + "ISENTO ,";
                    vFILTER = vFILTER + "ALTA_TENSAO ,";
                    vFILTER = vFILTER + "TP_LIGACAO ,";
                    vFILTER = vFILTER + "SOLICITANTE ,";
                    vFILTER = vFILTER + "AGRUPA ,";
                    vFILTER = vFILTER + "AGRUPA_ZONA ,";
                    vFILTER = vFILTER + "AGRUPA_LIVRO ,";
                    vFILTER = vFILTER + "AGRUPA_CONTA ,";
                    vFILTER = vFILTER + "BXRENDA ,";
                    vFILTER = vFILTER + "REGIAO ,";
                    vFILTER = vFILTER + "SGDENVIO ,";
                    vFILTER = vFILTER + "BX0402 ,";
                    vFILTER = vFILTER + "PAGTO_DUVIDOSO ,";
                    vFILTER = vFILTER + "ID_BCO_ANT ,";
                    vFILTER = vFILTER + "ID_BCO_ATUAL ,";
                    vFILTER = vFILTER + "COMPROVANTE_RURAL ,";
                    vFILTER = vFILTER + "JUL2010 ,";
                    vFILTER = vFILTER + "IDTIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "MODELO ,";
                    vFILTER = vFILTER + "IDCONDUTOR ,";
                    vFILTER = vFILTER + "COMPRIMENTO_FIO ,";
                    vFILTER = vFILTER + "COD_TIPO_MEDICAO ,";
                    vFILTER = vFILTER + "TIPO_MEDICAO ,";
                    vFILTER = vFILTER + "IDTIPO_PADRAO_MEDICAO ,";
                    vFILTER = vFILTER + "TC_RELACAO_PRIMARIA ,";
                    vFILTER = vFILTER + "TC_RELACAO_SECUNDARIA ,";
                    vFILTER = vFILTER + "TP_RELACAO_PRIMARIA ,";
                    vFILTER = vFILTER + "TP_RELACAO_SECUNDARIA ,";
                    vFILTER = vFILTER + "IDALIMENTADOR ,";
                    vFILTER = vFILTER + "IDCORRENTE ,";
                    vFILTER = vFILTER + "ESTUFA ,";
                    vFILTER = vFILTER + "RAMAL ,";
                    vFILTER = vFILTER + "DATA_RAMAL ,";
                    vFILTER = vFILTER + "CLIENTEPENDENTE ,";
                    vFILTER = vFILTER + "FLG_AVISO_DEBITO ,";
                    vFILTER = vFILTER + "IDMEDIDOR ,";
                    vFILTER = vFILTER + "CAP ,";
                    vFILTER = vFILTER + "CFOP ,";
                    vFILTER = vFILTER + "DAP ,";
                    vFILTER = vFILTER + "ENCARGO ,";
                    vFILTER = vFILTER + "FLG_SAZONAL ,";
                    vFILTER = vFILTER + "FONE ,";
                    vFILTER = vFILTER + "MAIOR ,";
                    vFILTER = vFILTER + "MAXIMO ,";
                    vFILTER = vFILTER + "PERC ,";
                    vFILTER = vFILTER + "PERC_RETENCAO ,";
                    vFILTER = vFILTER + "QH ,";
                    vFILTER = vFILTER + "CONST_CONS_FP ,";
                    vFILTER = vFILTER + "CONST_CONS_P ,";
                    vFILTER = vFILTER + "CONST_CONSUMO ,";
                    vFILTER = vFILTER + "CONST_DEMANDA ,";
                    vFILTER = vFILTER + "CONST_DEMANDA_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH ,";
                    vFILTER = vFILTER + "CONST_KVARH_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH_P ,";
                    vFILTER = vFILTER + "CONST_RESERVADO ,";
                    vFILTER = vFILTER + "CONSTKVFP ,";
                    vFILTER = vFILTER + "CONSTKVP ,";
                    vFILTER = vFILTER + "DATA_CONTRATO_DEMANDA ,";
                    vFILTER = vFILTER + "DEM_CONTR_FP ,";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA ,";
                    vFILTER = vFILTER + "DEMALIDA ,";
                    vFILTER = vFILTER + "DEMANDA ,";
                    vFILTER = vFILTER + "DEMANDA_CONTR ,";
                    vFILTER = vFILTER + "DEMANDAANT ,";
                    vFILTER = vFILTER + "DMCR ,";
                    vFILTER = vFILTER + "DP12 ,";
                    vFILTER = vFILTER + "ELETR ,";
                    vFILTER = vFILTER + "ICMS_DEMANDA_LIDA ,";
                    vFILTER = vFILTER + "ICMS_DIFERIDO ,";
                    vFILTER = vFILTER + "ICMS_ISENTO_DEMANDA ,";
                    vFILTER = vFILTER + "KVAR ,";
                    vFILTER = vFILTER + "KVARHFPN ,";
                    vFILTER = vFILTER + "KVARHPN ,";
                    vFILTER = vFILTER + "KVARKN ,";
                    vFILTER = vFILTER + "KVARKNANT ,";
                    vFILTER = vFILTER + "LEITANT ,";
                    vFILTER = vFILTER + "LEITDEMA ,";
                    vFILTER = vFILTER + "LEITREATIVO ,";
                    vFILTER = vFILTER + "LIVREESPECIAL ,";
                    vFILTER = vFILTER + "MEDKW ,";
                    vFILTER = vFILTER + "CNAE ,";
                    vFILTER = vFILTER + "IDCCEE ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_P ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_I ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_FP ,";
                    vFILTER = vFILTER + "MICRO_GERACAO ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_P ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_I ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_FP ,";
                    vFILTER = vFILTER + "PARCIALMENTE_CATIVO ,";
                    vFILTER = vFILTER + "DEMANDA_CONTR_ANTERIOR ,";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA_ANTERIOR ,";
                    vFILTER = vFILTER + "DEM_CONTR_FP_ANTERIOR ,";
                    vFILTER = vFILTER + "PERIODO_TESTE ,";
                    vFILTER = vFILTER + "MEDKVARK ,";
                    vFILTER = vFILTER + "ANTRESERV ,";
                    vFILTER = vFILTER + "ARREDONDA_TEMP ,";
                    vFILTER = vFILTER + "ATURESERV ,";
                    vFILTER = vFILTER + "COD_TIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "DTAUTODEC ,";
                    vFILTER = vFILTER + "FLG_ALIQUOTADIF ,";
                    vFILTER = vFILTER + "ISENTOREATIVO ,";
                    vFILTER = vFILTER + "MEDIMEC ,";
                    vFILTER = vFILTER + "NOVAMECA ,";
                    vFILTER = vFILTER + "NUM_UNIVERSALIZACAO ,";
                    vFILTER = vFILTER + "OBSERVACAO ,";
                    vFILTER = vFILTER + "PAGTO_GOVERNO ,";
                    vFILTER = vFILTER + "RG_ORGAO ,";
                    vFILTER = vFILTER + "RG_UF ,";
                    vFILTER = vFILTER + "TIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "UNIVERSALIZACAO ,";
                    vFILTER = vFILTER + "VECTOPROXMES ,";
                    vFILTER = vFILTER + "VIP_COMERCIAL ,";
                    vFILTER = vFILTER + "VIP_TECNICO ,";
                    vFILTER = vFILTER + "IRRIGACAO_AQUICULTURA ,";
                    vFILTER = vFILTER + "ULTLEIT_IRRIGANTE ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES ,";
                    vFILTER = vFILTER + "LIVRE_VERDE ,";
                    vFILTER = vFILTER + "ULTLEIT_DESLIGAMENTO ,";
                    vFILTER = vFILTER + "LIVRE_LEITURA_CONSUMO ,";
                    vFILTER = vFILTER + "INI_PERIODO_TESTE ,";
                    vFILTER = vFILTER + "FIM_PERIODO_TESTE ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE ,";
                    vFILTER = vFILTER + "LATITUDE ,";
                    vFILTER = vFILTER + "LONGITUDE ,";
                    vFILTER = vFILTER + "IRR_HR_INI ,";
                    vFILTER = vFILTER + "IRR_HR_FIM ,";
                    vFILTER = vFILTER + "TARIFA_BRANCA ,";
                    vFILTER = vFILTER + "REATIVO ,";
                    vFILTER = vFILTER + "ISENTO_ICMS_TUSD ,";
                    vFILTER = vFILTER + "ENVIO_COB_JUDICIAL ,";
                    vFILTER = vFILTER + "BLOQUEA_SEG_VIA_FAT ,";
                    vFILTER = vFILTER + "BLOQUEA_RELIGACAO ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_KW_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KW_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_I ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KW_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KW_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_I ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_FP ,";
                    vFILTER = vFILTER + "KWH_RES_P ,";
                    vFILTER = vFILTER + "KWH_RES_I ,";
                    vFILTER = vFILTER + "KWH_RES_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_FP ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_P ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_I ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_FP ,";
                    vFILTER = vFILTER + "CONST_KWH_P ,";
                    vFILTER = vFILTER + "CONST_KWH_I ,";
                    vFILTER = vFILTER + "CONST_KWH_FP ,";
                    vFILTER = vFILTER + "CONST_KW_P ,";
                    vFILTER = vFILTER + "CONST_KW_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH_I ,";
                    vFILTER = vFILTER + "CONJUGE_FATURA ,";
                    vFILTER = vFILTER + "CADERNO ,";
                    vFILTER = vFILTER + "SEQUENCIA  ";

                    vINNERJOIN = " ";

                    vORDERBY = " " + objUCFaturamento.ROTA.ToString().ToUpper();

                    vAND = vAND + "    AND DIAVENC =  ?DIAVENC ";


                    if (objUCFaturamento.SITUACAO != " ")
                    {
                        vAND = vAND + " AND SITUACAO <> ?SITUACAO ";
                    }


                    cmd = new MySqlCommand(this.QuerySelect);

                    cmd.Parameters.AddWithValue("?DIAVENC", objUCFaturamento.DIAVENC.ToString().ToUpper());

                    if (objUCFaturamento.SITUACAO != " ")
                    {
                        cmd.Parameters.AddWithValue("?SITUACAO", objUCFaturamento.SITUACAO.ToString().ToUpper());
                    }

                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable Select_9(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "GRUPO_TAR, ";
                    vFILTER = vFILTER + "ID, ";
                    vFILTER = vFILTER + "ZONA, ";
                    vFILTER = vFILTER + "LIVRO, ";
                    vFILTER = vFILTER + "CONTA, ";
                    vFILTER = vFILTER + "ROTA, ";
                    vFILTER = vFILTER + "INSTAL, ";
                    vFILTER = vFILTER + "ENCARGO, ";
                    vFILTER = vFILTER + "MEDKW, ";
                    vFILTER = vFILTER + "CONST_CONSUMO, ";
                    vFILTER = vFILTER + "CFOP, ";
                    vFILTER = vFILTER + "LEIT, ";
                    vFILTER = vFILTER + "KVAR, ";
                    vFILTER = vFILTER + "TA, ";
                    vFILTER = vFILTER + "CLAS, ";
                    vFILTER = vFILTER + "TENSAO, ";
                    vFILTER = vFILTER + "MEDKVARK, ";
                    vFILTER = vFILTER + "ANTRESERV, ";
                    vFILTER = vFILTER + "ARREDONDA_TEMP, ";
                    vFILTER = vFILTER + "ATURESERV, ";
                    vFILTER = vFILTER + "COD_TIPO_MEDIDOR, ";
                    vFILTER = vFILTER + "DTAUTODEC, ";
                    vFILTER = vFILTER + "FLG_ALIQUOTADIF, ";
                    vFILTER = vFILTER + "ISENTOREATIVO, ";
                    vFILTER = vFILTER + "MEDIMEC, ";
                    vFILTER = vFILTER + "NOVAMECA, ";
                    vFILTER = vFILTER + "NUM_UNIVERSALIZACAO, ";
                    vFILTER = vFILTER + "OBSERVACAO, ";
                    vFILTER = vFILTER + "PAGTO_GOVERNO, ";
                    vFILTER = vFILTER + "RG_ORGAO, ";
                    vFILTER = vFILTER + "RG_UF, ";
                    vFILTER = vFILTER + "TIPO_MEDIDOR, ";
                    vFILTER = vFILTER + "UNIVERSALIZACAO, ";
                    vFILTER = vFILTER + "VECTOPROXMES, ";
                    vFILTER = vFILTER + "VIP_COMERCIAL, ";
                    vFILTER = vFILTER + "DEMANDA, ";
                    vFILTER = vFILTER + "KVARKN, ";
                    vFILTER = vFILTER + "LEITANT, ";
                    vFILTER = vFILTER + "DEMANDAANT, ";
                    vFILTER = vFILTER + "DEMALIDA, ";
                    vFILTER = vFILTER + "KVARKNANT, ";
                    vFILTER = vFILTER + "GRUPO, ";
                    vFILTER = vFILTER + "FASE, ";
                    vFILTER = vFILTER + "CONST_DEMANDA, ";
                    vFILTER = vFILTER + "CONST_DEMANDA_FP, ";
                    vFILTER = vFILTER + "MAXIMO, ";
                    vFILTER = vFILTER + "PERC, ";
                    vFILTER = vFILTER + "ISENTO, ";
                    vFILTER = vFILTER + "MAIOR, ";
                    vFILTER = vFILTER + "ELETR, ";
                    vFILTER = vFILTER + "CONST_CONS_FP, ";
                    vFILTER = vFILTER + "CONST_CONS_P, ";
                    vFILTER = vFILTER + "CAP, ";
                    vFILTER = vFILTER + "DAP, ";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA, ";
                    vFILTER = vFILTER + "DEM_CONTR_FP, ";
                    vFILTER = vFILTER + "ULTLEIT, ";
                    vFILTER = vFILTER + "CONST_KVARH_P, ";
                    vFILTER = vFILTER + "CONST_KVARH_FP, ";
                    vFILTER = vFILTER + "KVARHFPN, ";
                    vFILTER = vFILTER + "KVARHPN, ";
                    vFILTER = vFILTER + "CONSTKVP, ";
                    vFILTER = vFILTER + "CONSTKVFP, ";
                    vFILTER = vFILTER + "CICE, ";
                    vFILTER = vFILTER + "ILUM, ";
                    vFILTER = vFILTER + "SITUACAO, ";
                    vFILTER = vFILTER + "FONE, ";
                    vFILTER = vFILTER + "DATA_LIGACAO, ";
                    vFILTER = vFILTER + "DATA_RELIGACAO, ";
                    vFILTER = vFILTER + "DATA_DESLIGAMENTO, ";
                    vFILTER = vFILTER + "DATA_ENTRADA, ";
                    vFILTER = vFILTER + "DATA_CORTE, ";
                    vFILTER = vFILTER + "DP12, ";
                    vFILTER = vFILTER + "QH, ";
                    vFILTER = vFILTER + "CARGA, ";
                    vFILTER = vFILTER + "FINAL, ";
                    vFILTER = vFILTER + "DEMANDA_CONTR, ";
                    vFILTER = vFILTER + "CONS_ID, ";
                    vFILTER = vFILTER + "UNID_ID, ";
                    vFILTER = vFILTER + "CONSLOC_ID, ";
                    vFILTER = vFILTER + "CODEND, ";
                    vFILTER = vFILTER + "END, ";
                    vFILTER = vFILTER + "BAIRRO, ";
                    vFILTER = vFILTER + "CIDADE, ";
                    vFILTER = vFILTER + "UF, ";
                    vFILTER = vFILTER + "QUADRA, ";
                    vFILTER = vFILTER + "LOTE, ";
                    vFILTER = vFILTER + "NUMERO, ";
                    vFILTER = vFILTER + "ITENSESP, ";
                    vFILTER = vFILTER + "NUM, ";
                    vFILTER = vFILTER + "TIPOUC, ";
                    vFILTER = vFILTER + "BANCO, ";
                    vFILTER = vFILTER + "AGENC, ";
                    vFILTER = vFILTER + "CC, ";
                    vFILTER = vFILTER + "CEP, ";
                    vFILTER = vFILTER + "NOME, ";
                    vFILTER = vFILTER + "ARREDONDA, ";
                    vFILTER = vFILTER + "ARREDONDA_ANT, ";
                    vFILTER = vFILTER + "CONST_KVARH, ";
                    vFILTER = vFILTER + "CONST_RESERVADO, ";
                    vFILTER = vFILTER + "DATA_CONTRATO_DEMANDA, ";
                    vFILTER = vFILTER + "HISTORICO, ";
                    vFILTER = vFILTER + "DIAVENC, ";
                    vFILTER = vFILTER + "FORMULA_CIP, ";
                    vFILTER = vFILTER + "SOCIAL, ";
                    vFILTER = vFILTER + "IDCNAE, ";
                    vFILTER = vFILTER + "LOCALIDADE, ";
                    vFILTER = vFILTER + "FLG_SAZONAL, ";
                    vFILTER = vFILTER + "CODEND_ENTREGA, ";
                    vFILTER = vFILTER + "END_ENTREGA, ";
                    vFILTER = vFILTER + "NUM_ENTREGA, ";
                    vFILTER = vFILTER + "BAI_ENTREGA, ";
                    vFILTER = vFILTER + "COMPL_ENTREGA, ";
                    vFILTER = vFILTER + "DIS_ENTREGA, ";
                    vFILTER = vFILTER + "CID_ENTREGA, ";
                    vFILTER = vFILTER + "UF_ENTREGA, ";
                    vFILTER = vFILTER + "CEP_ENTREGA, ";
                    vFILTER = vFILTER + "QUA_ENTREGA, ";
                    vFILTER = vFILTER + "LOT_ENTREGA, ";
                    vFILTER = vFILTER + "CPF_CNPJ, ";
                    vFILTER = vFILTER + "RG, ";
                    vFILTER = vFILTER + "INSC, ";
                    vFILTER = vFILTER + "PESSOA, ";
                    vFILTER = vFILTER + "COMPLEMENT, ";
                    vFILTER = vFILTER + "ENTREGA, ";
                    vFILTER = vFILTER + "DMCR, ";
                    vFILTER = vFILTER + "DTAINSTMEDIDOR, ";
                    vFILTER = vFILTER + "DTAFABMEDIDOR, ";
                    vFILTER = vFILTER + "LACRE, ";
                    vFILTER = vFILTER + "DISTRITO, ";
                    vFILTER = vFILTER + "MARCA, ";
                    vFILTER = vFILTER + "ICMS_ISENTO_DEMANDA, ";
                    vFILTER = vFILTER + "ICMS_DIFERIDO, ";
                    vFILTER = vFILTER + "LEITDEMA, ";
                    vFILTER = vFILTER + "BANARREC, ";
                    vFILTER = vFILTER + "PERC_RETENCAO, ";
                    vFILTER = vFILTER + "LEITREATIVO, ";
                    vFILTER = vFILTER + "ALTA_TENSAO, ";
                    vFILTER = vFILTER + "CIRCUITO, ";
                    vFILTER = vFILTER + "TP_LIGACAO, ";
                    vFILTER = vFILTER + "SOLICITANTE, ";
                    vFILTER = vFILTER + "ICMS_DEMANDA_LIDA, ";
                    vFILTER = vFILTER + "REGIAO, ";
                    vFILTER = vFILTER + "SGDENVIO, ";
                    vFILTER = vFILTER + "ID_BCO_ANT, ";
                    vFILTER = vFILTER + "ID_BCO_ATUAL, ";
                    vFILTER = vFILTER + "LIVREESPECIAL, ";
                    vFILTER = vFILTER + "COMPROVANTE_RURAL, ";
                    vFILTER = vFILTER + "IDTIPO_MEDIDOR, ";
                    vFILTER = vFILTER + "MODELO, ";
                    vFILTER = vFILTER + "IDCONDUTOR, ";
                    vFILTER = vFILTER + "COMPRIMENTO_FIO, ";
                    vFILTER = vFILTER + "COD_TIPO_MEDICAO, ";
                    vFILTER = vFILTER + "TIPO_MEDICAO, ";
                    vFILTER = vFILTER + "IDTIPO_PADRAO_MEDICAO, ";
                    vFILTER = vFILTER + "TC_RELACAO_PRIMARIA, ";
                    vFILTER = vFILTER + "TC_RELACAO_SECUNDARIA, ";
                    vFILTER = vFILTER + "TP_RELACAO_PRIMARIA, ";
                    vFILTER = vFILTER + "TP_RELACAO_SECUNDARIA, ";
                    vFILTER = vFILTER + "IDALIMENTADOR, ";
                    vFILTER = vFILTER + "IDCORRENTE, ";
                    vFILTER = vFILTER + "AP_SAUDE, ";
                    vFILTER = vFILTER + "ESTUFA, ";
                    vFILTER = vFILTER + "RAMAL, ";
                    vFILTER = vFILTER + "DATA_RAMAL, ";
                    vFILTER = vFILTER + "CLIENTEPENDENTE, ";
                    vFILTER = vFILTER + "FLG_AVISO_DEBITO, ";
                    vFILTER = vFILTER + "IDMEDIDOR, ";
                    vFILTER = vFILTER + "AGRUPA, ";
                    vFILTER = vFILTER + "AGRUPA_CONTA, ";
                    vFILTER = vFILTER + "AGRUPA_LIVRO, ";
                    vFILTER = vFILTER + "AGRUPA_ZONA, ";
                    vFILTER = vFILTER + "AREA, ";
                    vFILTER = vFILTER + "BX0402, ";
                    vFILTER = vFILTER + "BXRENDA, ";
                    vFILTER = vFILTER + "DECAP_DATA, ";
                    vFILTER = vFILTER + "DECAP_NUM, ";
                    vFILTER = vFILTER + "DISJUNTOR, ";
                    vFILTER = vFILTER + "ELETROBRAS, ";
                    vFILTER = vFILTER + "FASELIG, ";
                    vFILTER = vFILTER + "FLGRES, ";
                    vFILTER = vFILTER + "FPFIXO, ";
                    vFILTER = vFILTER + "JUL2010, ";
                    vFILTER = vFILTER + "LUZ_TODOS, ";
                    vFILTER = vFILTER + "PAGTO_DUVIDOSO, ";
                    vFILTER = vFILTER + "RES694, ";
                    vFILTER = vFILTER + "RESIDUO_CONSUMO, ";
                    vFILTER = vFILTER + "TRANSF, ";
                    vFILTER = vFILTER + "ULTCONS, ";
                    vFILTER = vFILTER + "ULTKVARH, ";
                    vFILTER = vFILTER + "CONST, ";
                    vFILTER = vFILTER + "CONSTFP, ";
                    vFILTER = vFILTER + "KVARH, ";
                    vFILTER = vFILTER + "CNAE, ";
                    vFILTER = vFILTER + "IDCCEE, ";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO, ";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_P, ";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_I, ";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_FP, ";
                    vFILTER = vFILTER + "MICRO_GERACAO, ";
                    vFILTER = vFILTER + "KWH_REVERSO_RES, ";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_P, ";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_I, ";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_FP, ";
                    vFILTER = vFILTER + "PARCIALMENTE_CATIVO, ";
                    vFILTER = vFILTER + "DEMANDA_CONTR_ANTERIOR, ";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA_ANTERIOR, ";
                    vFILTER = vFILTER + "DEM_CONTR_FP_ANTERIOR, ";
                    vFILTER = vFILTER + "PERIODO_TESTE, ";
                    vFILTER = vFILTER + "VIP_TECNICO, ";
                    vFILTER = vFILTER + "MEDKVARH, ";
                    vFILTER = vFILTER + "IRRIGACAO_AQUICULTURA, ";
                    vFILTER = vFILTER + "ULTLEIT_IRRIGANTE, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES, ";
                    vFILTER = vFILTER + "LIVRE_VERDE, ";
                    vFILTER = vFILTER + "ULTLEIT_DESLIGAMENTO, ";
                    vFILTER = vFILTER + "LIVRE_LEITURA_CONSUMO, ";
                    vFILTER = vFILTER + "INI_PERIODO_TESTE, ";
                    vFILTER = vFILTER + "FIM_PERIODO_TESTE, ";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE, ";
                    vFILTER = vFILTER + "LATITUDE, ";
                    vFILTER = vFILTER + "LONGITUDE, ";
                    vFILTER = vFILTER + "IRR_HR_INI, ";
                    vFILTER = vFILTER + "IRR_HR_FIM, ";
                    vFILTER = vFILTER + "TARIFA_BRANCA, ";
                    vFILTER = vFILTER + "REATIVO, ";
                    vFILTER = vFILTER + "ISENTO_ICMS_TUSD, ";
                    vFILTER = vFILTER + "ENVIO_COB_JUDICIAL, ";
                    vFILTER = vFILTER + "BLOQUEA_SEG_VIA_FAT, ";
                    vFILTER = vFILTER + "BLOQUEA_RELIGACAO, ";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_P, ";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_I, ";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_FP, ";
                    vFILTER = vFILTER + "ULT_LEIT_KW_P, ";
                    vFILTER = vFILTER + "ULT_LEIT_KW_FP, ";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_P, ";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_I, ";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_FP, ";
                    vFILTER = vFILTER + "ULT_CONS_KWH_P, ";
                    vFILTER = vFILTER + "ULT_CONS_KWH_I, ";
                    vFILTER = vFILTER + "ULT_CONS_KWH_FP, ";
                    vFILTER = vFILTER + "ULT_CONS_KW_P, ";
                    vFILTER = vFILTER + "ULT_CONS_KW_FP, ";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_P, ";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_I, ";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_FP, ";
                    vFILTER = vFILTER + "KWH_RES_P, ";
                    vFILTER = vFILTER + "KWH_RES_I, ";
                    vFILTER = vFILTER + "KWH_RES_FP, ";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_P, ";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_I, ";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_FP, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_P, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_I, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_FP, ";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_P, ";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_I, ";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_FP, ";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_P, ";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_I, ";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_FP, ";
                    vFILTER = vFILTER + "CONST_KWH_P, ";
                    vFILTER = vFILTER + "CONST_KWH_I, ";
                    vFILTER = vFILTER + "CONST_KWH_FP, ";
                    vFILTER = vFILTER + "CONST_KW_P, ";
                    vFILTER = vFILTER + "CONST_KW_FP, ";
                    vFILTER = vFILTER + "CONST_KVARH_I, ";
                    vFILTER = vFILTER + "CONJUGE_FATURA, ";
                    vFILTER = vFILTER + "CADERNO, ";
                    vFILTER = vFILTER + "SEQUENCIA ";

                    vINNERJOIN = " ";

                    vORDERBY = " ";

                    if (objUCFaturamento.UNID_ID != 0)
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND UNID_ID = ?UNID_ID "; }
                        else
                        { vAND = "AND UNID_ID = ?UNID_ID "; }

                    }
                    else
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + " "; }
                        else
                        { vAND = " "; }
                    }


                    cmd = new MySqlCommand(this.QuerySelect);

                    if (objUCFaturamento.UNID_ID != 0)
                    {
                        cmd.Parameters.AddWithValue("?UNID_ID", objUCFaturamento.UNID_ID);
                    }

                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable Select_10(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "SELECT CONVERT(MD5( ?HISTORICO ) USING LATIN1) AS HISTORICO ";

                    vINNERJOIN = " ";

                    vORDERBY = " ";

                    vAND = vFILTER;


                    cmd = new MySqlCommand(this.QueryExecute);


                    cmd.Parameters.AddWithValue("?HISTORICO", "'" + objUCFaturamento.HISTORICO.ToString().ToUpper() + "'");


                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable Select_11(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "GRUPO_TAR, ";
                    vFILTER = vFILTER + "ID, ";
                    vFILTER = vFILTER + "ZONA ,";
                    vFILTER = vFILTER + "LIVRO ,";
                    vFILTER = vFILTER + "CONTA ,";
                    vFILTER = vFILTER + "ROTA ,";
                    vFILTER = vFILTER + "INSTAL ,";
                    vFILTER = vFILTER + "ENTREGA ,";
                    vFILTER = vFILTER + "BANCO ,";
                    vFILTER = vFILTER + "AGENC ,";
                    vFILTER = vFILTER + "CC ,";
                    vFILTER = vFILTER + "GRUPO ,";
                    vFILTER = vFILTER + "CLAS ,";
                    vFILTER = vFILTER + "FASE ,";
                    vFILTER = vFILTER + "NUM ,";
                    vFILTER = vFILTER + "MARCA ,";
                    vFILTER = vFILTER + "DTAFABMEDIDOR ,";
                    vFILTER = vFILTER + "DTAINSTMEDIDOR ,";
                    vFILTER = vFILTER + "CONST ,";
                    vFILTER = vFILTER + "SITUACAO ,";
                    vFILTER = vFILTER + "ULTLEIT ,";
                    vFILTER = vFILTER + "ULTCONS ,";
                    vFILTER = vFILTER + "ILUM ,";
                    vFILTER = vFILTER + "LEIT ,";
                    vFILTER = vFILTER + "FINAL ,";
                    vFILTER = vFILTER + "MEDKVARH ,";
                    vFILTER = vFILTER + "ULTKVARH ,";
                    vFILTER = vFILTER + "CONSTFP ,";
                    vFILTER = vFILTER + "KVARH ,";
                    vFILTER = vFILTER + "CICE ,";
                    vFILTER = vFILTER + "DATA_LIGACAO ,";
                    vFILTER = vFILTER + "DATA_RELIGACAO ,";
                    vFILTER = vFILTER + "DATA_DESLIGAMENTO ,";
                    vFILTER = vFILTER + "DATA_ENTRADA ,";
                    vFILTER = vFILTER + "DATA_CORTE ,";
                    vFILTER = vFILTER + "TENSAO ,";
                    vFILTER = vFILTER + "CARGA ,";
                    vFILTER = vFILTER + "TRANSF ,";
                    vFILTER = vFILTER + "FASELIG ,";
                    vFILTER = vFILTER + "ELETROBRAS ,";
                    vFILTER = vFILTER + "FPFIXO ,";
                    vFILTER = vFILTER + "CODEND ,";
                    vFILTER = vFILTER + "END ,";
                    vFILTER = vFILTER + "COMPLEMENT ,";
                    vFILTER = vFILTER + "BAIRRO ,";
                    vFILTER = vFILTER + "CIDADE ,";
                    vFILTER = vFILTER + "UF ,";
                    vFILTER = vFILTER + "QUADRA ,";
                    vFILTER = vFILTER + "LOTE ,";
                    vFILTER = vFILTER + "NUMERO ,";
                    vFILTER = vFILTER + "CONS_ID ,";
                    vFILTER = vFILTER + "CONSLOC_ID ,";
                    vFILTER = vFILTER + "FLGRES ,";
                    vFILTER = vFILTER + "UNID_ID ,";
                    vFILTER = vFILTER + "ITENSESP ,";
                    vFILTER = vFILTER + "TIPOUC ,";
                    vFILTER = vFILTER + "CEP ,";
                    vFILTER = vFILTER + "TA ,";
                    vFILTER = vFILTER + "ARREDONDA ,";
                    vFILTER = vFILTER + "ARREDONDA_ANT ,";
                    vFILTER = vFILTER + "HISTORICO ,";
                    vFILTER = vFILTER + "DIAVENC ,";
                    vFILTER = vFILTER + "FORMULA_CIP ,";
                    vFILTER = vFILTER + "SOCIAL ,";
                    vFILTER = vFILTER + "IDCNAE ,";
                    vFILTER = vFILTER + "LOCALIDADE ,";
                    vFILTER = vFILTER + "CODEND_ENTREGA ,";
                    vFILTER = vFILTER + "END_ENTREGA ,";
                    vFILTER = vFILTER + "NUM_ENTREGA ,";
                    vFILTER = vFILTER + "BAI_ENTREGA ,";
                    vFILTER = vFILTER + "COMPL_ENTREGA ,";
                    vFILTER = vFILTER + "DIS_ENTREGA ,";
                    vFILTER = vFILTER + "CID_ENTREGA ,";
                    vFILTER = vFILTER + "UF_ENTREGA ,";
                    vFILTER = vFILTER + "QUA_ENTREGA ,";
                    vFILTER = vFILTER + "LOT_ENTREGA ,";
                    vFILTER = vFILTER + "CEP_ENTREGA ,";
                    vFILTER = vFILTER + "CPF_CNPJ ,";
                    vFILTER = vFILTER + "RG ,";
                    vFILTER = vFILTER + "INSC ,";
                    vFILTER = vFILTER + "PESSOA ,";
                    vFILTER = vFILTER + "NOME ,";
                    vFILTER = vFILTER + "CIRCUITO ,";
                    vFILTER = vFILTER + "DISJUNTOR ,";
                    vFILTER = vFILTER + "DISTRITO ,";
                    vFILTER = vFILTER + "AREA ,";
                    vFILTER = vFILTER + "LACRE ,";
                    vFILTER = vFILTER + "RESIDUO_CONSUMO ,";
                    vFILTER = vFILTER + "DECAP_NUM ,";
                    vFILTER = vFILTER + "DECAP_DATA ,";
                    vFILTER = vFILTER + "BANARREC ,";
                    vFILTER = vFILTER + "AP_SAUDE ,";
                    vFILTER = vFILTER + "LUZ_TODOS ,";
                    vFILTER = vFILTER + "RES694 ,";
                    vFILTER = vFILTER + "ISENTO ,";
                    vFILTER = vFILTER + "ALTA_TENSAO ,";
                    vFILTER = vFILTER + "TP_LIGACAO ,";
                    vFILTER = vFILTER + "SOLICITANTE ,";
                    vFILTER = vFILTER + "AGRUPA ,";
                    vFILTER = vFILTER + "AGRUPA_ZONA ,";
                    vFILTER = vFILTER + "AGRUPA_LIVRO ,";
                    vFILTER = vFILTER + "AGRUPA_CONTA ,";
                    vFILTER = vFILTER + "BXRENDA ,";
                    vFILTER = vFILTER + "REGIAO ,";
                    vFILTER = vFILTER + "SGDENVIO ,";
                    vFILTER = vFILTER + "BX0402 ,";
                    vFILTER = vFILTER + "PAGTO_DUVIDOSO ,";
                    vFILTER = vFILTER + "ID_BCO_ANT ,";
                    vFILTER = vFILTER + "ID_BCO_ATUAL ,";
                    vFILTER = vFILTER + "COMPROVANTE_RURAL ,";
                    vFILTER = vFILTER + "JUL2010 ,";
                    vFILTER = vFILTER + "IDTIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "MODELO ,";
                    vFILTER = vFILTER + "IDCONDUTOR ,";
                    vFILTER = vFILTER + "COMPRIMENTO_FIO ,";
                    vFILTER = vFILTER + "COD_TIPO_MEDICAO ,";
                    vFILTER = vFILTER + "TIPO_MEDICAO ,";
                    vFILTER = vFILTER + "IDTIPO_PADRAO_MEDICAO ,";
                    vFILTER = vFILTER + "TC_RELACAO_PRIMARIA ,";
                    vFILTER = vFILTER + "TC_RELACAO_SECUNDARIA ,";
                    vFILTER = vFILTER + "TP_RELACAO_PRIMARIA ,";
                    vFILTER = vFILTER + "TP_RELACAO_SECUNDARIA ,";
                    vFILTER = vFILTER + "IDALIMENTADOR ,";
                    vFILTER = vFILTER + "IDCORRENTE ,";
                    vFILTER = vFILTER + "ESTUFA ,";
                    vFILTER = vFILTER + "RAMAL ,";
                    vFILTER = vFILTER + "DATA_RAMAL ,";
                    vFILTER = vFILTER + "CLIENTEPENDENTE ,";
                    vFILTER = vFILTER + "FLG_AVISO_DEBITO ,";
                    vFILTER = vFILTER + "IDMEDIDOR ,";
                    vFILTER = vFILTER + "CAP ,";
                    vFILTER = vFILTER + "CFOP ,";
                    vFILTER = vFILTER + "DAP ,";
                    vFILTER = vFILTER + "ENCARGO ,";
                    vFILTER = vFILTER + "FLG_SAZONAL ,";
                    vFILTER = vFILTER + "FONE ,";
                    vFILTER = vFILTER + "MAIOR ,";
                    vFILTER = vFILTER + "MAXIMO ,";
                    vFILTER = vFILTER + "PERC ,";
                    vFILTER = vFILTER + "PERC_RETENCAO ,";
                    vFILTER = vFILTER + "QH ,";
                    vFILTER = vFILTER + "CONST_CONS_FP ,";
                    vFILTER = vFILTER + "CONST_CONS_P ,";
                    vFILTER = vFILTER + "CONST_CONSUMO ,";
                    vFILTER = vFILTER + "CONST_DEMANDA ,";
                    vFILTER = vFILTER + "CONST_DEMANDA_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH ,";
                    vFILTER = vFILTER + "CONST_KVARH_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH_P ,";
                    vFILTER = vFILTER + "CONST_RESERVADO ,";
                    vFILTER = vFILTER + "CONSTKVFP ,";
                    vFILTER = vFILTER + "CONSTKVP ,";
                    vFILTER = vFILTER + "DATA_CONTRATO_DEMANDA ,";
                    vFILTER = vFILTER + "DEM_CONTR_FP ,";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA ,";
                    vFILTER = vFILTER + "DEMALIDA ,";
                    vFILTER = vFILTER + "DEMANDA ,";
                    vFILTER = vFILTER + "DEMANDA_CONTR ,";
                    vFILTER = vFILTER + "DEMANDAANT ,";
                    vFILTER = vFILTER + "DMCR ,";
                    vFILTER = vFILTER + "DP12 ,";
                    vFILTER = vFILTER + "ELETR ,";
                    vFILTER = vFILTER + "ICMS_DEMANDA_LIDA ,";
                    vFILTER = vFILTER + "ICMS_DIFERIDO ,";
                    vFILTER = vFILTER + "ICMS_ISENTO_DEMANDA ,";
                    vFILTER = vFILTER + "KVAR ,";
                    vFILTER = vFILTER + "KVARHFPN ,";
                    vFILTER = vFILTER + "KVARHPN ,";
                    vFILTER = vFILTER + "KVARKN ,";
                    vFILTER = vFILTER + "KVARKNANT ,";
                    vFILTER = vFILTER + "LEITANT ,";
                    vFILTER = vFILTER + "LEITDEMA ,";
                    vFILTER = vFILTER + "LEITREATIVO ,";
                    vFILTER = vFILTER + "LIVREESPECIAL ,";
                    vFILTER = vFILTER + "MEDKW ,";
                    vFILTER = vFILTER + "CNAE ,";
                    vFILTER = vFILTER + "IDCCEE ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_P ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_I ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_FP ,";
                    vFILTER = vFILTER + "MICRO_GERACAO ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_P ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_I ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_FP ,";
                    vFILTER = vFILTER + "PARCIALMENTE_CATIVO ,";
                    vFILTER = vFILTER + "DEMANDA_CONTR_ANTERIOR ,";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA_ANTERIOR ,";
                    vFILTER = vFILTER + "DEM_CONTR_FP_ANTERIOR ,";
                    vFILTER = vFILTER + "PERIODO_TESTE ,";
                    vFILTER = vFILTER + "MEDKVARK ,";
                    vFILTER = vFILTER + "ANTRESERV ,";
                    vFILTER = vFILTER + "ARREDONDA_TEMP ,";
                    vFILTER = vFILTER + "ATURESERV ,";
                    vFILTER = vFILTER + "COD_TIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "DTAUTODEC ,";
                    vFILTER = vFILTER + "FLG_ALIQUOTADIF ,";
                    vFILTER = vFILTER + "ISENTOREATIVO ,";
                    vFILTER = vFILTER + "MEDIMEC ,";
                    vFILTER = vFILTER + "NOVAMECA ,";
                    vFILTER = vFILTER + "NUM_UNIVERSALIZACAO ,";
                    vFILTER = vFILTER + "OBSERVACAO ,";
                    vFILTER = vFILTER + "PAGTO_GOVERNO ,";
                    vFILTER = vFILTER + "RG_ORGAO ,";
                    vFILTER = vFILTER + "RG_UF ,";
                    vFILTER = vFILTER + "TIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "UNIVERSALIZACAO ,";
                    vFILTER = vFILTER + "VECTOPROXMES ,";
                    vFILTER = vFILTER + "VIP_COMERCIAL ,";
                    vFILTER = vFILTER + "VIP_TECNICO ,";
                    vFILTER = vFILTER + "IRRIGACAO_AQUICULTURA ,";
                    vFILTER = vFILTER + "ULTLEIT_IRRIGANTE ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES ,";
                    vFILTER = vFILTER + "LIVRE_VERDE ,";
                    vFILTER = vFILTER + "ULTLEIT_DESLIGAMENTO ,";
                    vFILTER = vFILTER + "LIVRE_LEITURA_CONSUMO ,";
                    vFILTER = vFILTER + "INI_PERIODO_TESTE ,";
                    vFILTER = vFILTER + "FIM_PERIODO_TESTE ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE ,";
                    vFILTER = vFILTER + "LATITUDE ,";
                    vFILTER = vFILTER + "LONGITUDE ,";
                    vFILTER = vFILTER + "IRR_HR_INI ,";
                    vFILTER = vFILTER + "IRR_HR_FIM ,";
                    vFILTER = vFILTER + "TARIFA_BRANCA ,";
                    vFILTER = vFILTER + "REATIVO ,";
                    vFILTER = vFILTER + "ISENTO_ICMS_TUSD ,";
                    vFILTER = vFILTER + "ENVIO_COB_JUDICIAL ,";
                    vFILTER = vFILTER + "BLOQUEA_SEG_VIA_FAT ,";
                    vFILTER = vFILTER + "BLOQUEA_RELIGACAO ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_KW_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KW_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_I ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KW_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KW_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_I ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_FP ,";
                    vFILTER = vFILTER + "KWH_RES_P ,";
                    vFILTER = vFILTER + "KWH_RES_I ,";
                    vFILTER = vFILTER + "KWH_RES_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_FP ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_P ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_I ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_FP ,";
                    vFILTER = vFILTER + "CONST_KWH_P ,";
                    vFILTER = vFILTER + "CONST_KWH_I ,";
                    vFILTER = vFILTER + "CONST_KWH_FP ,";
                    vFILTER = vFILTER + "CONST_KW_P ,";
                    vFILTER = vFILTER + "CONST_KW_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH_I ,";
                    vFILTER = vFILTER + "CONJUGE_FATURA ,";
                    vFILTER = vFILTER + "CADERNO ,";
                    vFILTER = vFILTER + "SEQUENCIA  ";

                    vINNERJOIN = " ";

                    vORDERBY = " ";

                    vAND = vAND + "   AND ZONA  = ?ZONA ";
                    vAND = vAND + "   AND LIVRO = ?LIVRO ";
                    vAND = vAND + "   AND CONTA = ?CONTA ";
                    vAND = vAND + "   AND left(GRUPO,1) = ?GRUPO ";


                    cmd = new MySqlCommand(this.QuerySelect);

                    cmd.Parameters.AddWithValue("?ZONA", objUCFaturamento.ZONA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?LIVRO", objUCFaturamento.LIVRO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CONTA", objUCFaturamento.CONTA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?GRUPO", objUCFaturamento.GRUPO.ToString().ToUpper());

                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable Select_12(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "GRUPO_TAR, ";
                    vFILTER = vFILTER + "ID, ";
                    vFILTER = vFILTER + "ZONA ,";
                    vFILTER = vFILTER + "LIVRO ,";
                    vFILTER = vFILTER + "CONTA ,";
                    vFILTER = vFILTER + "ROTA ,";
                    vFILTER = vFILTER + "INSTAL ,";
                    vFILTER = vFILTER + "ENTREGA ,";
                    vFILTER = vFILTER + "BANCO ,";
                    vFILTER = vFILTER + "AGENC ,";
                    vFILTER = vFILTER + "CC ,";
                    vFILTER = vFILTER + "GRUPO ,";
                    vFILTER = vFILTER + "CLAS ,";
                    vFILTER = vFILTER + "FASE ,";
                    vFILTER = vFILTER + "NUM ,";
                    vFILTER = vFILTER + "MARCA ,";
                    vFILTER = vFILTER + "DTAFABMEDIDOR ,";
                    vFILTER = vFILTER + "DTAINSTMEDIDOR ,";
                    vFILTER = vFILTER + "CONST ,";
                    vFILTER = vFILTER + "SITUACAO ,";
                    vFILTER = vFILTER + "ULTLEIT ,";
                    vFILTER = vFILTER + "ULTCONS ,";
                    vFILTER = vFILTER + "ILUM ,";
                    vFILTER = vFILTER + "LEIT ,";
                    vFILTER = vFILTER + "FINAL ,";
                    vFILTER = vFILTER + "MEDKVARH ,";
                    vFILTER = vFILTER + "ULTKVARH ,";
                    vFILTER = vFILTER + "CONSTFP ,";
                    vFILTER = vFILTER + "KVARH ,";
                    vFILTER = vFILTER + "CICE ,";
                    vFILTER = vFILTER + "DATA_LIGACAO ,";
                    vFILTER = vFILTER + "DATA_RELIGACAO ,";
                    vFILTER = vFILTER + "DATA_DESLIGAMENTO ,";
                    vFILTER = vFILTER + "DATA_ENTRADA ,";
                    vFILTER = vFILTER + "DATA_CORTE ,";
                    vFILTER = vFILTER + "TENSAO ,";
                    vFILTER = vFILTER + "CARGA ,";
                    vFILTER = vFILTER + "TRANSF ,";
                    vFILTER = vFILTER + "FASELIG ,";
                    vFILTER = vFILTER + "ELETROBRAS ,";
                    vFILTER = vFILTER + "FPFIXO ,";
                    vFILTER = vFILTER + "CODEND ,";
                    vFILTER = vFILTER + "END ,";
                    vFILTER = vFILTER + "COMPLEMENT ,";
                    vFILTER = vFILTER + "BAIRRO ,";
                    vFILTER = vFILTER + "CIDADE ,";
                    vFILTER = vFILTER + "UF ,";
                    vFILTER = vFILTER + "QUADRA ,";
                    vFILTER = vFILTER + "LOTE ,";
                    vFILTER = vFILTER + "NUMERO ,";
                    vFILTER = vFILTER + "CONS_ID ,";
                    vFILTER = vFILTER + "CONSLOC_ID ,";
                    vFILTER = vFILTER + "FLGRES ,";
                    vFILTER = vFILTER + "UNID_ID ,";
                    vFILTER = vFILTER + "ITENSESP ,";
                    vFILTER = vFILTER + "TIPOUC ,";
                    vFILTER = vFILTER + "CEP ,";
                    vFILTER = vFILTER + "TA ,";
                    vFILTER = vFILTER + "ARREDONDA ,";
                    vFILTER = vFILTER + "ARREDONDA_ANT ,";
                    vFILTER = vFILTER + "HISTORICO ,";
                    vFILTER = vFILTER + "DIAVENC ,";
                    vFILTER = vFILTER + "FORMULA_CIP ,";
                    vFILTER = vFILTER + "SOCIAL ,";
                    vFILTER = vFILTER + "IDCNAE ,";
                    vFILTER = vFILTER + "LOCALIDADE ,";
                    vFILTER = vFILTER + "CODEND_ENTREGA ,";
                    vFILTER = vFILTER + "END_ENTREGA ,";
                    vFILTER = vFILTER + "NUM_ENTREGA ,";
                    vFILTER = vFILTER + "BAI_ENTREGA ,";
                    vFILTER = vFILTER + "COMPL_ENTREGA ,";
                    vFILTER = vFILTER + "DIS_ENTREGA ,";
                    vFILTER = vFILTER + "CID_ENTREGA ,";
                    vFILTER = vFILTER + "UF_ENTREGA ,";
                    vFILTER = vFILTER + "QUA_ENTREGA ,";
                    vFILTER = vFILTER + "LOT_ENTREGA ,";
                    vFILTER = vFILTER + "CEP_ENTREGA ,";
                    vFILTER = vFILTER + "CPF_CNPJ ,";
                    vFILTER = vFILTER + "RG ,";
                    vFILTER = vFILTER + "INSC ,";
                    vFILTER = vFILTER + "PESSOA ,";
                    vFILTER = vFILTER + "NOME ,";
                    vFILTER = vFILTER + "CIRCUITO ,";
                    vFILTER = vFILTER + "DISJUNTOR ,";
                    vFILTER = vFILTER + "DISTRITO ,";
                    vFILTER = vFILTER + "AREA ,";
                    vFILTER = vFILTER + "LACRE ,";
                    vFILTER = vFILTER + "RESIDUO_CONSUMO ,";
                    vFILTER = vFILTER + "DECAP_NUM ,";
                    vFILTER = vFILTER + "DECAP_DATA ,";
                    vFILTER = vFILTER + "BANARREC ,";
                    vFILTER = vFILTER + "AP_SAUDE ,";
                    vFILTER = vFILTER + "LUZ_TODOS ,";
                    vFILTER = vFILTER + "RES694 ,";
                    vFILTER = vFILTER + "ISENTO ,";
                    vFILTER = vFILTER + "ALTA_TENSAO ,";
                    vFILTER = vFILTER + "TP_LIGACAO ,";
                    vFILTER = vFILTER + "SOLICITANTE ,";
                    vFILTER = vFILTER + "AGRUPA ,";
                    vFILTER = vFILTER + "AGRUPA_ZONA ,";
                    vFILTER = vFILTER + "AGRUPA_LIVRO ,";
                    vFILTER = vFILTER + "AGRUPA_CONTA ,";
                    vFILTER = vFILTER + "BXRENDA ,";
                    vFILTER = vFILTER + "REGIAO ,";
                    vFILTER = vFILTER + "SGDENVIO ,";
                    vFILTER = vFILTER + "BX0402 ,";
                    vFILTER = vFILTER + "PAGTO_DUVIDOSO ,";
                    vFILTER = vFILTER + "ID_BCO_ANT ,";
                    vFILTER = vFILTER + "ID_BCO_ATUAL ,";
                    vFILTER = vFILTER + "COMPROVANTE_RURAL ,";
                    vFILTER = vFILTER + "JUL2010 ,";
                    vFILTER = vFILTER + "IDTIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "MODELO ,";
                    vFILTER = vFILTER + "IDCONDUTOR ,";
                    vFILTER = vFILTER + "COMPRIMENTO_FIO ,";
                    vFILTER = vFILTER + "COD_TIPO_MEDICAO ,";
                    vFILTER = vFILTER + "TIPO_MEDICAO ,";
                    vFILTER = vFILTER + "IDTIPO_PADRAO_MEDICAO ,";
                    vFILTER = vFILTER + "TC_RELACAO_PRIMARIA ,";
                    vFILTER = vFILTER + "TC_RELACAO_SECUNDARIA ,";
                    vFILTER = vFILTER + "TP_RELACAO_PRIMARIA ,";
                    vFILTER = vFILTER + "TP_RELACAO_SECUNDARIA ,";
                    vFILTER = vFILTER + "IDALIMENTADOR ,";
                    vFILTER = vFILTER + "IDCORRENTE ,";
                    vFILTER = vFILTER + "ESTUFA ,";
                    vFILTER = vFILTER + "RAMAL ,";
                    vFILTER = vFILTER + "DATA_RAMAL ,";
                    vFILTER = vFILTER + "CLIENTEPENDENTE ,";
                    vFILTER = vFILTER + "FLG_AVISO_DEBITO ,";
                    vFILTER = vFILTER + "IDMEDIDOR ,";
                    vFILTER = vFILTER + "CAP ,";
                    vFILTER = vFILTER + "CFOP ,";
                    vFILTER = vFILTER + "DAP ,";
                    vFILTER = vFILTER + "ENCARGO ,";
                    vFILTER = vFILTER + "FLG_SAZONAL ,";
                    vFILTER = vFILTER + "FONE ,";
                    vFILTER = vFILTER + "MAIOR ,";
                    vFILTER = vFILTER + "MAXIMO ,";
                    vFILTER = vFILTER + "PERC ,";
                    vFILTER = vFILTER + "PERC_RETENCAO ,";
                    vFILTER = vFILTER + "QH ,";
                    vFILTER = vFILTER + "CONST_CONS_FP ,";
                    vFILTER = vFILTER + "CONST_CONS_P ,";
                    vFILTER = vFILTER + "CONST_CONSUMO ,";
                    vFILTER = vFILTER + "CONST_DEMANDA ,";
                    vFILTER = vFILTER + "CONST_DEMANDA_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH ,";
                    vFILTER = vFILTER + "CONST_KVARH_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH_P ,";
                    vFILTER = vFILTER + "CONST_RESERVADO ,";
                    vFILTER = vFILTER + "CONSTKVFP ,";
                    vFILTER = vFILTER + "CONSTKVP ,";
                    vFILTER = vFILTER + "DATA_CONTRATO_DEMANDA ,";
                    vFILTER = vFILTER + "DEM_CONTR_FP ,";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA ,";
                    vFILTER = vFILTER + "DEMALIDA ,";
                    vFILTER = vFILTER + "DEMANDA ,";
                    vFILTER = vFILTER + "DEMANDA_CONTR ,";
                    vFILTER = vFILTER + "DEMANDAANT ,";
                    vFILTER = vFILTER + "DMCR ,";
                    vFILTER = vFILTER + "DP12 ,";
                    vFILTER = vFILTER + "ELETR ,";
                    vFILTER = vFILTER + "ICMS_DEMANDA_LIDA ,";
                    vFILTER = vFILTER + "ICMS_DIFERIDO ,";
                    vFILTER = vFILTER + "ICMS_ISENTO_DEMANDA ,";
                    vFILTER = vFILTER + "KVAR ,";
                    vFILTER = vFILTER + "KVARHFPN ,";
                    vFILTER = vFILTER + "KVARHPN ,";
                    vFILTER = vFILTER + "KVARKN ,";
                    vFILTER = vFILTER + "KVARKNANT ,";
                    vFILTER = vFILTER + "LEITANT ,";
                    vFILTER = vFILTER + "LEITDEMA ,";
                    vFILTER = vFILTER + "LEITREATIVO ,";
                    vFILTER = vFILTER + "LIVREESPECIAL ,";
                    vFILTER = vFILTER + "MEDKW ,";
                    vFILTER = vFILTER + "CNAE ,";
                    vFILTER = vFILTER + "IDCCEE ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_P ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_I ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_FP ,";
                    vFILTER = vFILTER + "MICRO_GERACAO ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_P ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_I ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_FP ,";
                    vFILTER = vFILTER + "PARCIALMENTE_CATIVO ,";
                    vFILTER = vFILTER + "DEMANDA_CONTR_ANTERIOR ,";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA_ANTERIOR ,";
                    vFILTER = vFILTER + "DEM_CONTR_FP_ANTERIOR ,";
                    vFILTER = vFILTER + "PERIODO_TESTE ,";
                    vFILTER = vFILTER + "MEDKVARK ,";
                    vFILTER = vFILTER + "ANTRESERV ,";
                    vFILTER = vFILTER + "ARREDONDA_TEMP ,";
                    vFILTER = vFILTER + "ATURESERV ,";
                    vFILTER = vFILTER + "COD_TIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "DTAUTODEC ,";
                    vFILTER = vFILTER + "FLG_ALIQUOTADIF ,";
                    vFILTER = vFILTER + "ISENTOREATIVO ,";
                    vFILTER = vFILTER + "MEDIMEC ,";
                    vFILTER = vFILTER + "NOVAMECA ,";
                    vFILTER = vFILTER + "NUM_UNIVERSALIZACAO ,";
                    vFILTER = vFILTER + "OBSERVACAO ,";
                    vFILTER = vFILTER + "PAGTO_GOVERNO ,";
                    vFILTER = vFILTER + "RG_ORGAO ,";
                    vFILTER = vFILTER + "RG_UF ,";
                    vFILTER = vFILTER + "TIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "UNIVERSALIZACAO ,";
                    vFILTER = vFILTER + "VECTOPROXMES ,";
                    vFILTER = vFILTER + "VIP_COMERCIAL ,";
                    vFILTER = vFILTER + "VIP_TECNICO ,";
                    vFILTER = vFILTER + "IRRIGACAO_AQUICULTURA ,";
                    vFILTER = vFILTER + "ULTLEIT_IRRIGANTE ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES ,";
                    vFILTER = vFILTER + "LIVRE_VERDE ,";
                    vFILTER = vFILTER + "ULTLEIT_DESLIGAMENTO ,";
                    vFILTER = vFILTER + "LIVRE_LEITURA_CONSUMO ,";
                    vFILTER = vFILTER + "INI_PERIODO_TESTE ,";
                    vFILTER = vFILTER + "FIM_PERIODO_TESTE ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE ,";
                    vFILTER = vFILTER + "LATITUDE ,";
                    vFILTER = vFILTER + "LONGITUDE ,";
                    vFILTER = vFILTER + "IRR_HR_INI ,";
                    vFILTER = vFILTER + "IRR_HR_FIM ,";
                    vFILTER = vFILTER + "TARIFA_BRANCA ,";
                    vFILTER = vFILTER + "REATIVO ,";
                    vFILTER = vFILTER + "ISENTO_ICMS_TUSD ,";
                    vFILTER = vFILTER + "ENVIO_COB_JUDICIAL ,";
                    vFILTER = vFILTER + "BLOQUEA_SEG_VIA_FAT ,";
                    vFILTER = vFILTER + "BLOQUEA_RELIGACAO ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_KW_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KW_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_I ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KW_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KW_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_I ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_FP ,";
                    vFILTER = vFILTER + "KWH_RES_P ,";
                    vFILTER = vFILTER + "KWH_RES_I ,";
                    vFILTER = vFILTER + "KWH_RES_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_FP ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_P ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_I ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_FP ,";
                    vFILTER = vFILTER + "CONST_KWH_P ,";
                    vFILTER = vFILTER + "CONST_KWH_I ,";
                    vFILTER = vFILTER + "CONST_KWH_FP ,";
                    vFILTER = vFILTER + "CONST_KW_P ,";
                    vFILTER = vFILTER + "CONST_KW_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH_I ,";
                    vFILTER = vFILTER + "CONJUGE_FATURA ,";
                    vFILTER = vFILTER + "CADERNO ,";
                    vFILTER = vFILTER + "SEQUENCIA  ";

                    vINNERJOIN = " ";

                    vORDERBY = " ";

                    vAND = vAND + "   AND ZONA  = ?ZONA ";
                    vAND = vAND + "   AND LIVRO = ?LIVRO ";
                    vAND = vAND + "   AND CONTA = ?CONTA ";
                    vAND = vAND + "   AND GRUPO = ?GRUPO ";
                    vAND = vAND + "   AND UNID_ID = ?UNID_ID ";

                    cmd = new MySqlCommand(this.QuerySelect);

                    cmd.Parameters.AddWithValue("?ZONA", objUCFaturamento.ZONA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?LIVRO", objUCFaturamento.LIVRO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CONTA", objUCFaturamento.CONTA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?GRUPO", objUCFaturamento.GRUPO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?UNID_ID", objUCFaturamento.UNID_ID);

                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable Select_13(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "GRUPO_TAR, ";
                    vFILTER = vFILTER + "ID, ";
                    vFILTER = vFILTER + "ZONA ,";
                    vFILTER = vFILTER + "LIVRO ,";
                    vFILTER = vFILTER + "CONTA ,";
                    vFILTER = vFILTER + "ROTA ,";
                    vFILTER = vFILTER + "INSTAL ,";
                    vFILTER = vFILTER + "ENTREGA ,";
                    vFILTER = vFILTER + "BANCO ,";
                    vFILTER = vFILTER + "AGENC ,";
                    vFILTER = vFILTER + "CC ,";
                    vFILTER = vFILTER + "GRUPO ,";
                    vFILTER = vFILTER + "CLAS ,";
                    vFILTER = vFILTER + "FASE ,";
                    vFILTER = vFILTER + "NUM ,";
                    vFILTER = vFILTER + "MARCA ,";
                    vFILTER = vFILTER + "DTAFABMEDIDOR ,";
                    vFILTER = vFILTER + "DTAINSTMEDIDOR ,";
                    vFILTER = vFILTER + "CONST ,";
                    vFILTER = vFILTER + "SITUACAO ,";
                    vFILTER = vFILTER + "ULTLEIT ,";
                    vFILTER = vFILTER + "ULTCONS ,";
                    vFILTER = vFILTER + "ILUM ,";
                    vFILTER = vFILTER + "LEIT ,";
                    vFILTER = vFILTER + "FINAL ,";
                    vFILTER = vFILTER + "MEDKVARH ,";
                    vFILTER = vFILTER + "ULTKVARH ,";
                    vFILTER = vFILTER + "CONSTFP ,";
                    vFILTER = vFILTER + "KVARH ,";
                    vFILTER = vFILTER + "CICE ,";
                    vFILTER = vFILTER + "DATA_LIGACAO ,";
                    vFILTER = vFILTER + "DATA_RELIGACAO ,";
                    vFILTER = vFILTER + "DATA_DESLIGAMENTO ,";
                    vFILTER = vFILTER + "DATA_ENTRADA ,";
                    vFILTER = vFILTER + "DATA_CORTE ,";
                    vFILTER = vFILTER + "TENSAO ,";
                    vFILTER = vFILTER + "CARGA ,";
                    vFILTER = vFILTER + "TRANSF ,";
                    vFILTER = vFILTER + "FASELIG ,";
                    vFILTER = vFILTER + "ELETROBRAS ,";
                    vFILTER = vFILTER + "FPFIXO ,";
                    vFILTER = vFILTER + "CODEND ,";
                    vFILTER = vFILTER + "END ,";
                    vFILTER = vFILTER + "COMPLEMENT ,";
                    vFILTER = vFILTER + "BAIRRO ,";
                    vFILTER = vFILTER + "CIDADE ,";
                    vFILTER = vFILTER + "UF ,";
                    vFILTER = vFILTER + "QUADRA ,";
                    vFILTER = vFILTER + "LOTE ,";
                    vFILTER = vFILTER + "NUMERO ,";
                    vFILTER = vFILTER + "CONS_ID ,";
                    vFILTER = vFILTER + "CONSLOC_ID ,";
                    vFILTER = vFILTER + "FLGRES ,";
                    vFILTER = vFILTER + "UNID_ID ,";
                    vFILTER = vFILTER + "ITENSESP ,";
                    vFILTER = vFILTER + "TIPOUC ,";
                    vFILTER = vFILTER + "CEP ,";
                    vFILTER = vFILTER + "TA ,";
                    vFILTER = vFILTER + "ARREDONDA ,";
                    vFILTER = vFILTER + "ARREDONDA_ANT ,";
                    vFILTER = vFILTER + "HISTORICO ,";
                    vFILTER = vFILTER + "DIAVENC ,";
                    vFILTER = vFILTER + "FORMULA_CIP ,";
                    vFILTER = vFILTER + "SOCIAL ,";
                    vFILTER = vFILTER + "IDCNAE ,";
                    vFILTER = vFILTER + "LOCALIDADE ,";
                    vFILTER = vFILTER + "CODEND_ENTREGA ,";
                    vFILTER = vFILTER + "END_ENTREGA ,";
                    vFILTER = vFILTER + "NUM_ENTREGA ,";
                    vFILTER = vFILTER + "BAI_ENTREGA ,";
                    vFILTER = vFILTER + "COMPL_ENTREGA ,";
                    vFILTER = vFILTER + "DIS_ENTREGA ,";
                    vFILTER = vFILTER + "CID_ENTREGA ,";
                    vFILTER = vFILTER + "UF_ENTREGA ,";
                    vFILTER = vFILTER + "QUA_ENTREGA ,";
                    vFILTER = vFILTER + "LOT_ENTREGA ,";
                    vFILTER = vFILTER + "CEP_ENTREGA ,";
                    vFILTER = vFILTER + "CPF_CNPJ ,";
                    vFILTER = vFILTER + "RG ,";
                    vFILTER = vFILTER + "INSC ,";
                    vFILTER = vFILTER + "PESSOA ,";
                    vFILTER = vFILTER + "NOME ,";
                    vFILTER = vFILTER + "CIRCUITO ,";
                    vFILTER = vFILTER + "DISJUNTOR ,";
                    vFILTER = vFILTER + "DISTRITO ,";
                    vFILTER = vFILTER + "AREA ,";
                    vFILTER = vFILTER + "LACRE ,";
                    vFILTER = vFILTER + "RESIDUO_CONSUMO ,";
                    vFILTER = vFILTER + "DECAP_NUM ,";
                    vFILTER = vFILTER + "DECAP_DATA ,";
                    vFILTER = vFILTER + "BANARREC ,";
                    vFILTER = vFILTER + "AP_SAUDE ,";
                    vFILTER = vFILTER + "LUZ_TODOS ,";
                    vFILTER = vFILTER + "RES694 ,";
                    vFILTER = vFILTER + "ISENTO ,";
                    vFILTER = vFILTER + "ALTA_TENSAO ,";
                    vFILTER = vFILTER + "TP_LIGACAO ,";
                    vFILTER = vFILTER + "SOLICITANTE ,";
                    vFILTER = vFILTER + "AGRUPA ,";
                    vFILTER = vFILTER + "AGRUPA_ZONA ,";
                    vFILTER = vFILTER + "AGRUPA_LIVRO ,";
                    vFILTER = vFILTER + "AGRUPA_CONTA ,";
                    vFILTER = vFILTER + "BXRENDA ,";
                    vFILTER = vFILTER + "REGIAO ,";
                    vFILTER = vFILTER + "SGDENVIO ,";
                    vFILTER = vFILTER + "BX0402 ,";
                    vFILTER = vFILTER + "PAGTO_DUVIDOSO ,";
                    vFILTER = vFILTER + "ID_BCO_ANT ,";
                    vFILTER = vFILTER + "ID_BCO_ATUAL ,";
                    vFILTER = vFILTER + "COMPROVANTE_RURAL ,";
                    vFILTER = vFILTER + "JUL2010 ,";
                    vFILTER = vFILTER + "IDTIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "MODELO ,";
                    vFILTER = vFILTER + "IDCONDUTOR ,";
                    vFILTER = vFILTER + "COMPRIMENTO_FIO ,";
                    vFILTER = vFILTER + "COD_TIPO_MEDICAO ,";
                    vFILTER = vFILTER + "TIPO_MEDICAO ,";
                    vFILTER = vFILTER + "IDTIPO_PADRAO_MEDICAO ,";
                    vFILTER = vFILTER + "TC_RELACAO_PRIMARIA ,";
                    vFILTER = vFILTER + "TC_RELACAO_SECUNDARIA ,";
                    vFILTER = vFILTER + "TP_RELACAO_PRIMARIA ,";
                    vFILTER = vFILTER + "TP_RELACAO_SECUNDARIA ,";
                    vFILTER = vFILTER + "IDALIMENTADOR ,";
                    vFILTER = vFILTER + "IDCORRENTE ,";
                    vFILTER = vFILTER + "ESTUFA ,";
                    vFILTER = vFILTER + "RAMAL ,";
                    vFILTER = vFILTER + "DATA_RAMAL ,";
                    vFILTER = vFILTER + "CLIENTEPENDENTE ,";
                    vFILTER = vFILTER + "FLG_AVISO_DEBITO ,";
                    vFILTER = vFILTER + "IDMEDIDOR ,";
                    vFILTER = vFILTER + "CAP ,";
                    vFILTER = vFILTER + "CFOP ,";
                    vFILTER = vFILTER + "DAP ,";
                    vFILTER = vFILTER + "ENCARGO ,";
                    vFILTER = vFILTER + "FLG_SAZONAL ,";
                    vFILTER = vFILTER + "FONE ,";
                    vFILTER = vFILTER + "MAIOR ,";
                    vFILTER = vFILTER + "MAXIMO ,";
                    vFILTER = vFILTER + "PERC ,";
                    vFILTER = vFILTER + "PERC_RETENCAO ,";
                    vFILTER = vFILTER + "QH ,";
                    vFILTER = vFILTER + "CONST_CONS_FP ,";
                    vFILTER = vFILTER + "CONST_CONS_P ,";
                    vFILTER = vFILTER + "CONST_CONSUMO ,";
                    vFILTER = vFILTER + "CONST_DEMANDA ,";
                    vFILTER = vFILTER + "CONST_DEMANDA_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH ,";
                    vFILTER = vFILTER + "CONST_KVARH_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH_P ,";
                    vFILTER = vFILTER + "CONST_RESERVADO ,";
                    vFILTER = vFILTER + "CONSTKVFP ,";
                    vFILTER = vFILTER + "CONSTKVP ,";
                    vFILTER = vFILTER + "DATA_CONTRATO_DEMANDA ,";
                    vFILTER = vFILTER + "DEM_CONTR_FP ,";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA ,";
                    vFILTER = vFILTER + "DEMALIDA ,";
                    vFILTER = vFILTER + "DEMANDA ,";
                    vFILTER = vFILTER + "DEMANDA_CONTR ,";
                    vFILTER = vFILTER + "DEMANDAANT ,";
                    vFILTER = vFILTER + "DMCR ,";
                    vFILTER = vFILTER + "DP12 ,";
                    vFILTER = vFILTER + "ELETR ,";
                    vFILTER = vFILTER + "ICMS_DEMANDA_LIDA ,";
                    vFILTER = vFILTER + "ICMS_DIFERIDO ,";
                    vFILTER = vFILTER + "ICMS_ISENTO_DEMANDA ,";
                    vFILTER = vFILTER + "KVAR ,";
                    vFILTER = vFILTER + "KVARHFPN ,";
                    vFILTER = vFILTER + "KVARHPN ,";
                    vFILTER = vFILTER + "KVARKN ,";
                    vFILTER = vFILTER + "KVARKNANT ,";
                    vFILTER = vFILTER + "LEITANT ,";
                    vFILTER = vFILTER + "LEITDEMA ,";
                    vFILTER = vFILTER + "LEITREATIVO ,";
                    vFILTER = vFILTER + "LIVREESPECIAL ,";
                    vFILTER = vFILTER + "MEDKW ,";
                    vFILTER = vFILTER + "CNAE ,";
                    vFILTER = vFILTER + "IDCCEE ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_P ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_I ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_FP ,";
                    vFILTER = vFILTER + "MICRO_GERACAO ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_P ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_I ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_FP ,";
                    vFILTER = vFILTER + "PARCIALMENTE_CATIVO ,";
                    vFILTER = vFILTER + "DEMANDA_CONTR_ANTERIOR ,";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA_ANTERIOR ,";
                    vFILTER = vFILTER + "DEM_CONTR_FP_ANTERIOR ,";
                    vFILTER = vFILTER + "PERIODO_TESTE ,";
                    vFILTER = vFILTER + "MEDKVARK ,";
                    vFILTER = vFILTER + "ANTRESERV ,";
                    vFILTER = vFILTER + "ARREDONDA_TEMP ,";
                    vFILTER = vFILTER + "ATURESERV ,";
                    vFILTER = vFILTER + "COD_TIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "DTAUTODEC ,";
                    vFILTER = vFILTER + "FLG_ALIQUOTADIF ,";
                    vFILTER = vFILTER + "ISENTOREATIVO ,";
                    vFILTER = vFILTER + "MEDIMEC ,";
                    vFILTER = vFILTER + "NOVAMECA ,";
                    vFILTER = vFILTER + "NUM_UNIVERSALIZACAO ,";
                    vFILTER = vFILTER + "OBSERVACAO ,";
                    vFILTER = vFILTER + "PAGTO_GOVERNO ,";
                    vFILTER = vFILTER + "RG_ORGAO ,";
                    vFILTER = vFILTER + "RG_UF ,";
                    vFILTER = vFILTER + "TIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "UNIVERSALIZACAO ,";
                    vFILTER = vFILTER + "VECTOPROXMES ,";
                    vFILTER = vFILTER + "VIP_COMERCIAL ,";
                    vFILTER = vFILTER + "VIP_TECNICO ,";
                    vFILTER = vFILTER + "IRRIGACAO_AQUICULTURA ,";
                    vFILTER = vFILTER + "ULTLEIT_IRRIGANTE ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES ,";
                    vFILTER = vFILTER + "LIVRE_VERDE ,";
                    vFILTER = vFILTER + "ULTLEIT_DESLIGAMENTO ,";
                    vFILTER = vFILTER + "LIVRE_LEITURA_CONSUMO ,";
                    vFILTER = vFILTER + "INI_PERIODO_TESTE ,";
                    vFILTER = vFILTER + "FIM_PERIODO_TESTE ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE ,";
                    vFILTER = vFILTER + "LATITUDE ,";
                    vFILTER = vFILTER + "LONGITUDE ,";
                    vFILTER = vFILTER + "IRR_HR_INI ,";
                    vFILTER = vFILTER + "IRR_HR_FIM ,";
                    vFILTER = vFILTER + "TARIFA_BRANCA ,";
                    vFILTER = vFILTER + "REATIVO ,";
                    vFILTER = vFILTER + "ISENTO_ICMS_TUSD ,";
                    vFILTER = vFILTER + "ENVIO_COB_JUDICIAL ,";
                    vFILTER = vFILTER + "BLOQUEA_SEG_VIA_FAT ,";
                    vFILTER = vFILTER + "BLOQUEA_RELIGACAO ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_KW_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KW_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_I ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KW_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KW_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_I ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_FP ,";
                    vFILTER = vFILTER + "KWH_RES_P ,";
                    vFILTER = vFILTER + "KWH_RES_I ,";
                    vFILTER = vFILTER + "KWH_RES_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_FP ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_P ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_I ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_FP ,";
                    vFILTER = vFILTER + "CONST_KWH_P ,";
                    vFILTER = vFILTER + "CONST_KWH_I ,";
                    vFILTER = vFILTER + "CONST_KWH_FP ,";
                    vFILTER = vFILTER + "CONST_KW_P ,";
                    vFILTER = vFILTER + "CONST_KW_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH_I ,";
                    vFILTER = vFILTER + "CONJUGE_FATURA ,";
                    vFILTER = vFILTER + "CADERNO ,";
                    vFILTER = vFILTER + "SEQUENCIA  ";

                    vINNERJOIN = " ";

                    vORDERBY = " ";


                    vAND = vAND + "   AND CONS_ID = ?CONS_ID ";
                    vAND = vAND + "   AND GRUPO = ?GRUPO ";
                    vAND = vAND + "   AND UNID_ID = ?UNID_ID ";

                    cmd = new MySqlCommand(this.QuerySelect);


                    cmd.Parameters.AddWithValue("?CONS_ID", objUCFaturamento.CONS_ID);
                    cmd.Parameters.AddWithValue("?GRUPO", objUCFaturamento.GRUPO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?UNID_ID", objUCFaturamento.UNID_ID);

                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable Select_14(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "GRUPO_TAR, ";
                    vFILTER = vFILTER + "ID, ";
                    vFILTER = vFILTER + "ZONA ,";
                    vFILTER = vFILTER + "LIVRO ,";
                    vFILTER = vFILTER + "CONTA ,";
                    vFILTER = vFILTER + "ROTA ,";
                    vFILTER = vFILTER + "INSTAL ,";
                    vFILTER = vFILTER + "ENTREGA ,";
                    vFILTER = vFILTER + "BANCO ,";
                    vFILTER = vFILTER + "AGENC ,";
                    vFILTER = vFILTER + "CC ,";
                    vFILTER = vFILTER + "GRUPO ,";
                    vFILTER = vFILTER + "CLAS ,";
                    vFILTER = vFILTER + "FASE ,";
                    vFILTER = vFILTER + "NUM ,";
                    vFILTER = vFILTER + "MARCA ,";
                    vFILTER = vFILTER + "DTAFABMEDIDOR ,";
                    vFILTER = vFILTER + "DTAINSTMEDIDOR ,";
                    vFILTER = vFILTER + "CONST ,";
                    vFILTER = vFILTER + "SITUACAO ,";
                    vFILTER = vFILTER + "ULTLEIT ,";
                    vFILTER = vFILTER + "ULTCONS ,";
                    vFILTER = vFILTER + "ILUM ,";
                    vFILTER = vFILTER + "LEIT ,";
                    vFILTER = vFILTER + "FINAL ,";
                    vFILTER = vFILTER + "MEDKVARH ,";
                    vFILTER = vFILTER + "ULTKVARH ,";
                    vFILTER = vFILTER + "CONSTFP ,";
                    vFILTER = vFILTER + "KVARH ,";
                    vFILTER = vFILTER + "CICE ,";
                    vFILTER = vFILTER + "DATA_LIGACAO ,";
                    vFILTER = vFILTER + "DATA_RELIGACAO ,";
                    vFILTER = vFILTER + "DATA_DESLIGAMENTO ,";
                    vFILTER = vFILTER + "DATA_ENTRADA ,";
                    vFILTER = vFILTER + "DATA_CORTE ,";
                    vFILTER = vFILTER + "TENSAO ,";
                    vFILTER = vFILTER + "CARGA ,";
                    vFILTER = vFILTER + "TRANSF ,";
                    vFILTER = vFILTER + "FASELIG ,";
                    vFILTER = vFILTER + "ELETROBRAS ,";
                    vFILTER = vFILTER + "FPFIXO ,";
                    vFILTER = vFILTER + "CODEND ,";
                    vFILTER = vFILTER + "END ,";
                    vFILTER = vFILTER + "COMPLEMENT ,";
                    vFILTER = vFILTER + "BAIRRO ,";
                    vFILTER = vFILTER + "CIDADE ,";
                    vFILTER = vFILTER + "UF ,";
                    vFILTER = vFILTER + "QUADRA ,";
                    vFILTER = vFILTER + "LOTE ,";
                    vFILTER = vFILTER + "NUMERO ,";
                    vFILTER = vFILTER + "CONS_ID ,";
                    vFILTER = vFILTER + "CONSLOC_ID ,";
                    vFILTER = vFILTER + "FLGRES ,";
                    vFILTER = vFILTER + "UNID_ID ,";
                    vFILTER = vFILTER + "ITENSESP ,";
                    vFILTER = vFILTER + "TIPOUC ,";
                    vFILTER = vFILTER + "CEP ,";
                    vFILTER = vFILTER + "TA ,";
                    vFILTER = vFILTER + "ARREDONDA ,";
                    vFILTER = vFILTER + "ARREDONDA_ANT ,";
                    vFILTER = vFILTER + "HISTORICO ,";
                    vFILTER = vFILTER + "DIAVENC ,";
                    vFILTER = vFILTER + "FORMULA_CIP ,";
                    vFILTER = vFILTER + "SOCIAL ,";
                    vFILTER = vFILTER + "IDCNAE ,";
                    vFILTER = vFILTER + "LOCALIDADE ,";
                    vFILTER = vFILTER + "CODEND_ENTREGA ,";
                    vFILTER = vFILTER + "END_ENTREGA ,";
                    vFILTER = vFILTER + "NUM_ENTREGA ,";
                    vFILTER = vFILTER + "BAI_ENTREGA ,";
                    vFILTER = vFILTER + "COMPL_ENTREGA ,";
                    vFILTER = vFILTER + "DIS_ENTREGA ,";
                    vFILTER = vFILTER + "CID_ENTREGA ,";
                    vFILTER = vFILTER + "UF_ENTREGA ,";
                    vFILTER = vFILTER + "QUA_ENTREGA ,";
                    vFILTER = vFILTER + "LOT_ENTREGA ,";
                    vFILTER = vFILTER + "CEP_ENTREGA ,";
                    vFILTER = vFILTER + "CPF_CNPJ ,";
                    vFILTER = vFILTER + "RG ,";
                    vFILTER = vFILTER + "INSC ,";
                    vFILTER = vFILTER + "PESSOA ,";
                    vFILTER = vFILTER + "NOME ,";
                    vFILTER = vFILTER + "CIRCUITO ,";
                    vFILTER = vFILTER + "DISJUNTOR ,";
                    vFILTER = vFILTER + "DISTRITO ,";
                    vFILTER = vFILTER + "AREA ,";
                    vFILTER = vFILTER + "LACRE ,";
                    vFILTER = vFILTER + "RESIDUO_CONSUMO ,";
                    vFILTER = vFILTER + "DECAP_NUM ,";
                    vFILTER = vFILTER + "DECAP_DATA ,";
                    vFILTER = vFILTER + "BANARREC ,";
                    vFILTER = vFILTER + "AP_SAUDE ,";
                    vFILTER = vFILTER + "LUZ_TODOS ,";
                    vFILTER = vFILTER + "RES694 ,";
                    vFILTER = vFILTER + "ISENTO ,";
                    vFILTER = vFILTER + "ALTA_TENSAO ,";
                    vFILTER = vFILTER + "TP_LIGACAO ,";
                    vFILTER = vFILTER + "SOLICITANTE ,";
                    vFILTER = vFILTER + "AGRUPA ,";
                    vFILTER = vFILTER + "AGRUPA_ZONA ,";
                    vFILTER = vFILTER + "AGRUPA_LIVRO ,";
                    vFILTER = vFILTER + "AGRUPA_CONTA ,";
                    vFILTER = vFILTER + "BXRENDA ,";
                    vFILTER = vFILTER + "REGIAO ,";
                    vFILTER = vFILTER + "SGDENVIO ,";
                    vFILTER = vFILTER + "BX0402 ,";
                    vFILTER = vFILTER + "PAGTO_DUVIDOSO ,";
                    vFILTER = vFILTER + "ID_BCO_ANT ,";
                    vFILTER = vFILTER + "ID_BCO_ATUAL ,";
                    vFILTER = vFILTER + "COMPROVANTE_RURAL ,";
                    vFILTER = vFILTER + "JUL2010 ,";
                    vFILTER = vFILTER + "IDTIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "MODELO ,";
                    vFILTER = vFILTER + "IDCONDUTOR ,";
                    vFILTER = vFILTER + "COMPRIMENTO_FIO ,";
                    vFILTER = vFILTER + "COD_TIPO_MEDICAO ,";
                    vFILTER = vFILTER + "TIPO_MEDICAO ,";
                    vFILTER = vFILTER + "IDTIPO_PADRAO_MEDICAO ,";
                    vFILTER = vFILTER + "TC_RELACAO_PRIMARIA ,";
                    vFILTER = vFILTER + "TC_RELACAO_SECUNDARIA ,";
                    vFILTER = vFILTER + "TP_RELACAO_PRIMARIA ,";
                    vFILTER = vFILTER + "TP_RELACAO_SECUNDARIA ,";
                    vFILTER = vFILTER + "IDALIMENTADOR ,";
                    vFILTER = vFILTER + "IDCORRENTE ,";
                    vFILTER = vFILTER + "ESTUFA ,";
                    vFILTER = vFILTER + "RAMAL ,";
                    vFILTER = vFILTER + "DATA_RAMAL ,";
                    vFILTER = vFILTER + "CLIENTEPENDENTE ,";
                    vFILTER = vFILTER + "FLG_AVISO_DEBITO ,";
                    vFILTER = vFILTER + "IDMEDIDOR ,";
                    vFILTER = vFILTER + "CAP ,";
                    vFILTER = vFILTER + "CFOP ,";
                    vFILTER = vFILTER + "DAP ,";
                    vFILTER = vFILTER + "ENCARGO ,";
                    vFILTER = vFILTER + "FLG_SAZONAL ,";
                    vFILTER = vFILTER + "FONE ,";
                    vFILTER = vFILTER + "MAIOR ,";
                    vFILTER = vFILTER + "MAXIMO ,";
                    vFILTER = vFILTER + "PERC ,";
                    vFILTER = vFILTER + "PERC_RETENCAO ,";
                    vFILTER = vFILTER + "QH ,";
                    vFILTER = vFILTER + "CONST_CONS_FP ,";
                    vFILTER = vFILTER + "CONST_CONS_P ,";
                    vFILTER = vFILTER + "CONST_CONSUMO ,";
                    vFILTER = vFILTER + "CONST_DEMANDA ,";
                    vFILTER = vFILTER + "CONST_DEMANDA_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH ,";
                    vFILTER = vFILTER + "CONST_KVARH_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH_P ,";
                    vFILTER = vFILTER + "CONST_RESERVADO ,";
                    vFILTER = vFILTER + "CONSTKVFP ,";
                    vFILTER = vFILTER + "CONSTKVP ,";
                    vFILTER = vFILTER + "DATA_CONTRATO_DEMANDA ,";
                    vFILTER = vFILTER + "DEM_CONTR_FP ,";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA ,";
                    vFILTER = vFILTER + "DEMALIDA ,";
                    vFILTER = vFILTER + "DEMANDA ,";
                    vFILTER = vFILTER + "DEMANDA_CONTR ,";
                    vFILTER = vFILTER + "DEMANDAANT ,";
                    vFILTER = vFILTER + "DMCR ,";
                    vFILTER = vFILTER + "DP12 ,";
                    vFILTER = vFILTER + "ELETR ,";
                    vFILTER = vFILTER + "ICMS_DEMANDA_LIDA ,";
                    vFILTER = vFILTER + "ICMS_DIFERIDO ,";
                    vFILTER = vFILTER + "ICMS_ISENTO_DEMANDA ,";
                    vFILTER = vFILTER + "KVAR ,";
                    vFILTER = vFILTER + "KVARHFPN ,";
                    vFILTER = vFILTER + "KVARHPN ,";
                    vFILTER = vFILTER + "KVARKN ,";
                    vFILTER = vFILTER + "KVARKNANT ,";
                    vFILTER = vFILTER + "LEITANT ,";
                    vFILTER = vFILTER + "LEITDEMA ,";
                    vFILTER = vFILTER + "LEITREATIVO ,";
                    vFILTER = vFILTER + "LIVREESPECIAL ,";
                    vFILTER = vFILTER + "MEDKW ,";
                    vFILTER = vFILTER + "CNAE ,";
                    vFILTER = vFILTER + "IDCCEE ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_P ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_I ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_FP ,";
                    vFILTER = vFILTER + "MICRO_GERACAO ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_P ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_I ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_FP ,";
                    vFILTER = vFILTER + "PARCIALMENTE_CATIVO ,";
                    vFILTER = vFILTER + "DEMANDA_CONTR_ANTERIOR ,";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA_ANTERIOR ,";
                    vFILTER = vFILTER + "DEM_CONTR_FP_ANTERIOR ,";
                    vFILTER = vFILTER + "PERIODO_TESTE ,";
                    vFILTER = vFILTER + "MEDKVARK ,";
                    vFILTER = vFILTER + "ANTRESERV ,";
                    vFILTER = vFILTER + "ARREDONDA_TEMP ,";
                    vFILTER = vFILTER + "ATURESERV ,";
                    vFILTER = vFILTER + "COD_TIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "DTAUTODEC ,";
                    vFILTER = vFILTER + "FLG_ALIQUOTADIF ,";
                    vFILTER = vFILTER + "ISENTOREATIVO ,";
                    vFILTER = vFILTER + "MEDIMEC ,";
                    vFILTER = vFILTER + "NOVAMECA ,";
                    vFILTER = vFILTER + "NUM_UNIVERSALIZACAO ,";
                    vFILTER = vFILTER + "OBSERVACAO ,";
                    vFILTER = vFILTER + "PAGTO_GOVERNO ,";
                    vFILTER = vFILTER + "RG_ORGAO ,";
                    vFILTER = vFILTER + "RG_UF ,";
                    vFILTER = vFILTER + "TIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "UNIVERSALIZACAO ,";
                    vFILTER = vFILTER + "VECTOPROXMES ,";
                    vFILTER = vFILTER + "VIP_COMERCIAL ,";
                    vFILTER = vFILTER + "VIP_TECNICO ,";
                    vFILTER = vFILTER + "IRRIGACAO_AQUICULTURA ,";
                    vFILTER = vFILTER + "ULTLEIT_IRRIGANTE ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES ,";
                    vFILTER = vFILTER + "LIVRE_VERDE ,";
                    vFILTER = vFILTER + "ULTLEIT_DESLIGAMENTO ,";
                    vFILTER = vFILTER + "LIVRE_LEITURA_CONSUMO ,";
                    vFILTER = vFILTER + "INI_PERIODO_TESTE ,";
                    vFILTER = vFILTER + "FIM_PERIODO_TESTE ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE ,";
                    vFILTER = vFILTER + "LATITUDE ,";
                    vFILTER = vFILTER + "LONGITUDE ,";
                    vFILTER = vFILTER + "IRR_HR_INI ,";
                    vFILTER = vFILTER + "IRR_HR_FIM ,";
                    vFILTER = vFILTER + "TARIFA_BRANCA ,";
                    vFILTER = vFILTER + "REATIVO ,";
                    vFILTER = vFILTER + "ISENTO_ICMS_TUSD ,";
                    vFILTER = vFILTER + "ENVIO_COB_JUDICIAL ,";
                    vFILTER = vFILTER + "BLOQUEA_SEG_VIA_FAT ,";
                    vFILTER = vFILTER + "BLOQUEA_RELIGACAO ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_KW_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KW_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_I ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KW_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KW_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_I ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_FP ,";
                    vFILTER = vFILTER + "KWH_RES_P ,";
                    vFILTER = vFILTER + "KWH_RES_I ,";
                    vFILTER = vFILTER + "KWH_RES_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_FP ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_P ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_I ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_FP ,";
                    vFILTER = vFILTER + "CONST_KWH_P ,";
                    vFILTER = vFILTER + "CONST_KWH_I ,";
                    vFILTER = vFILTER + "CONST_KWH_FP ,";
                    vFILTER = vFILTER + "CONST_KW_P ,";
                    vFILTER = vFILTER + "CONST_KW_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH_I ,";
                    vFILTER = vFILTER + "CONJUGE_FATURA ,";
                    vFILTER = vFILTER + "CADERNO ,";
                    vFILTER = vFILTER + "SEQUENCIA  ";

                    vINNERJOIN = " ";

                    vORDERBY = " ";

                    vAND = vAND + "   AND ZONA  = ?ZONA ";
                    vAND = vAND + "   AND LIVRO = ?LIVRO ";
                    vAND = vAND + "   AND CONTA = ?CONTA ";
                    vAND = vAND + "   AND GRUPO = ?GRUPO ";
                    vAND = vAND + "   AND ID = ?ID ";
                    vAND = vAND + "   AND CONS_ID = ?CONS_ID ";

                    cmd = new MySqlCommand(this.QuerySelect);

                    cmd.Parameters.AddWithValue("?ZONA", objUCFaturamento.ZONA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?LIVRO", objUCFaturamento.LIVRO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CONTA", objUCFaturamento.CONTA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?GRUPO", objUCFaturamento.GRUPO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?ID", objUCFaturamento.ID);
                    cmd.Parameters.AddWithValue("?CONS_ID", objUCFaturamento.CONS_ID);

                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable Select_15(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "ZONA, ";
                    vFILTER = vFILTER + "LIVRO, ";
                    vFILTER = vFILTER + "CONTA, ";
                    vFILTER = vFILTER + "END, ";
                    vFILTER = vFILTER + "COMPLEMENT, ";
                    vFILTER = vFILTER + "BAIRRO, ";
                    vFILTER = vFILTER + "NUMERO, ";
                    vFILTER = vFILTER + "CPF_CNPJ, ";
                    vFILTER = vFILTER + "RG, ";
                    vFILTER = vFILTER + "INSC, ";
                    vFILTER = vFILTER + "NOME ";


                    vINNERJOIN = " ";

                    vORDERBY = " ";

                    if (objUCFaturamento.ID != 0)
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND ID = ?ID "; }
                        else
                        { vAND = "AND ID = ?ID "; }

                    }
                    else
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + " "; }
                        else
                        { vAND = " "; }
                    }


                    cmd = new MySqlCommand(this.QuerySelect);

                    if (objUCFaturamento.ID != 0)
                    {
                        cmd.Parameters.AddWithValue("?ID", objUCFaturamento.ID);
                    }

                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable Select_16(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "GRUPO_TAR, ";
                    vFILTER = vFILTER + "ID, ";
                    vFILTER = vFILTER + "ZONA, ";
                    vFILTER = vFILTER + "LIVRO, ";
                    vFILTER = vFILTER + "CONTA, ";
                    vFILTER = vFILTER + "ROTA, ";
                    vFILTER = vFILTER + "INSTAL, ";
                    vFILTER = vFILTER + "ENCARGO, ";
                    vFILTER = vFILTER + "MEDKW, ";
                    vFILTER = vFILTER + "CONST_CONSUMO, ";
                    vFILTER = vFILTER + "CFOP, ";
                    vFILTER = vFILTER + "LEIT, ";
                    vFILTER = vFILTER + "KVAR, ";
                    vFILTER = vFILTER + "TA, ";
                    vFILTER = vFILTER + "CLAS, ";
                    vFILTER = vFILTER + "TENSAO, ";
                    vFILTER = vFILTER + "MEDKVARK, ";
                    vFILTER = vFILTER + "ANTRESERV, ";
                    vFILTER = vFILTER + "ARREDONDA_TEMP, ";
                    vFILTER = vFILTER + "ATURESERV, ";
                    vFILTER = vFILTER + "COD_TIPO_MEDIDOR, ";
                    vFILTER = vFILTER + "DTAUTODEC, ";
                    vFILTER = vFILTER + "FLG_ALIQUOTADIF, ";
                    vFILTER = vFILTER + "ISENTOREATIVO, ";
                    vFILTER = vFILTER + "MEDIMEC, ";
                    vFILTER = vFILTER + "NOVAMECA, ";
                    vFILTER = vFILTER + "NUM_UNIVERSALIZACAO, ";
                    vFILTER = vFILTER + "OBSERVACAO, ";
                    vFILTER = vFILTER + "PAGTO_GOVERNO, ";
                    vFILTER = vFILTER + "RG_ORGAO, ";
                    vFILTER = vFILTER + "RG_UF, ";
                    vFILTER = vFILTER + "TIPO_MEDIDOR, ";
                    vFILTER = vFILTER + "UNIVERSALIZACAO, ";
                    vFILTER = vFILTER + "VECTOPROXMES, ";
                    vFILTER = vFILTER + "VIP_COMERCIAL, ";
                    vFILTER = vFILTER + "DEMANDA, ";
                    vFILTER = vFILTER + "KVARKN, ";
                    vFILTER = vFILTER + "LEITANT, ";
                    vFILTER = vFILTER + "DEMANDAANT, ";
                    vFILTER = vFILTER + "DEMALIDA, ";
                    vFILTER = vFILTER + "KVARKNANT, ";
                    vFILTER = vFILTER + "GRUPO, ";
                    vFILTER = vFILTER + "FASE, ";
                    vFILTER = vFILTER + "CONST_DEMANDA, ";
                    vFILTER = vFILTER + "CONST_DEMANDA_FP, ";
                    vFILTER = vFILTER + "MAXIMO, ";
                    vFILTER = vFILTER + "PERC, ";
                    vFILTER = vFILTER + "ISENTO, ";
                    vFILTER = vFILTER + "MAIOR, ";
                    vFILTER = vFILTER + "ELETR, ";
                    vFILTER = vFILTER + "CONST_CONS_FP, ";
                    vFILTER = vFILTER + "CONST_CONS_P, ";
                    vFILTER = vFILTER + "CAP, ";
                    vFILTER = vFILTER + "DAP, ";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA, ";
                    vFILTER = vFILTER + "DEM_CONTR_FP, ";
                    vFILTER = vFILTER + "ULTLEIT, ";
                    vFILTER = vFILTER + "CONST_KVARH_P, ";
                    vFILTER = vFILTER + "CONST_KVARH_FP, ";
                    vFILTER = vFILTER + "KVARHFPN, ";
                    vFILTER = vFILTER + "KVARHPN, ";
                    vFILTER = vFILTER + "CONSTKVP, ";
                    vFILTER = vFILTER + "CONSTKVFP, ";
                    vFILTER = vFILTER + "CICE, ";
                    vFILTER = vFILTER + "ILUM, ";
                    vFILTER = vFILTER + "SITUACAO, ";
                    vFILTER = vFILTER + "FONE, ";
                    vFILTER = vFILTER + "DATA_LIGACAO, ";
                    vFILTER = vFILTER + "DATA_RELIGACAO, ";
                    vFILTER = vFILTER + "DATA_DESLIGAMENTO, ";
                    vFILTER = vFILTER + "DATA_ENTRADA, ";
                    vFILTER = vFILTER + "DATA_CORTE, ";
                    vFILTER = vFILTER + "DP12, ";
                    vFILTER = vFILTER + "QH, ";
                    vFILTER = vFILTER + "CARGA, ";
                    vFILTER = vFILTER + "FINAL, ";
                    vFILTER = vFILTER + "DEMANDA_CONTR, ";
                    vFILTER = vFILTER + "CONS_ID, ";
                    vFILTER = vFILTER + "UNID_ID, ";
                    vFILTER = vFILTER + "CONSLOC_ID, ";
                    vFILTER = vFILTER + "CODEND, ";
                    vFILTER = vFILTER + "END, ";
                    vFILTER = vFILTER + "BAIRRO, ";
                    vFILTER = vFILTER + "CIDADE, ";
                    vFILTER = vFILTER + "UF, ";
                    vFILTER = vFILTER + "QUADRA, ";
                    vFILTER = vFILTER + "LOTE, ";
                    vFILTER = vFILTER + "NUMERO, ";
                    vFILTER = vFILTER + "ITENSESP, ";
                    vFILTER = vFILTER + "NUM, ";
                    vFILTER = vFILTER + "TIPOUC, ";
                    vFILTER = vFILTER + "BANCO, ";
                    vFILTER = vFILTER + "AGENC, ";
                    vFILTER = vFILTER + "CC, ";
                    vFILTER = vFILTER + "CEP, ";
                    vFILTER = vFILTER + "NOME, ";
                    vFILTER = vFILTER + "ARREDONDA, ";
                    vFILTER = vFILTER + "ARREDONDA_ANT, ";
                    vFILTER = vFILTER + "CONST_KVARH, ";
                    vFILTER = vFILTER + "CONST_RESERVADO, ";
                    vFILTER = vFILTER + "DATA_CONTRATO_DEMANDA, ";
                    vFILTER = vFILTER + "HISTORICO, ";
                    vFILTER = vFILTER + "DIAVENC, ";
                    vFILTER = vFILTER + "FORMULA_CIP, ";
                    vFILTER = vFILTER + "SOCIAL, ";
                    vFILTER = vFILTER + "IDCNAE, ";
                    vFILTER = vFILTER + "LOCALIDADE, ";
                    vFILTER = vFILTER + "FLG_SAZONAL, ";
                    vFILTER = vFILTER + "CODEND_ENTREGA, ";
                    vFILTER = vFILTER + "END_ENTREGA, ";
                    vFILTER = vFILTER + "NUM_ENTREGA, ";
                    vFILTER = vFILTER + "BAI_ENTREGA, ";
                    vFILTER = vFILTER + "COMPL_ENTREGA, ";
                    vFILTER = vFILTER + "DIS_ENTREGA, ";
                    vFILTER = vFILTER + "CID_ENTREGA, ";
                    vFILTER = vFILTER + "UF_ENTREGA, ";
                    vFILTER = vFILTER + "CEP_ENTREGA, ";
                    vFILTER = vFILTER + "QUA_ENTREGA, ";
                    vFILTER = vFILTER + "LOT_ENTREGA, ";
                    vFILTER = vFILTER + "CPF_CNPJ, ";
                    vFILTER = vFILTER + "RG, ";
                    vFILTER = vFILTER + "INSC, ";
                    vFILTER = vFILTER + "PESSOA, ";
                    vFILTER = vFILTER + "COMPLEMENT, ";
                    vFILTER = vFILTER + "ENTREGA, ";
                    vFILTER = vFILTER + "DMCR, ";
                    vFILTER = vFILTER + "DTAINSTMEDIDOR, ";
                    vFILTER = vFILTER + "DTAFABMEDIDOR, ";
                    vFILTER = vFILTER + "LACRE, ";
                    vFILTER = vFILTER + "DISTRITO, ";
                    vFILTER = vFILTER + "MARCA, ";
                    vFILTER = vFILTER + "ICMS_ISENTO_DEMANDA, ";
                    vFILTER = vFILTER + "ICMS_DIFERIDO, ";
                    vFILTER = vFILTER + "LEITDEMA, ";
                    vFILTER = vFILTER + "BANARREC, ";
                    vFILTER = vFILTER + "PERC_RETENCAO, ";
                    vFILTER = vFILTER + "LEITREATIVO, ";
                    vFILTER = vFILTER + "ALTA_TENSAO, ";
                    vFILTER = vFILTER + "CIRCUITO, ";
                    vFILTER = vFILTER + "TP_LIGACAO, ";
                    vFILTER = vFILTER + "SOLICITANTE, ";
                    vFILTER = vFILTER + "ICMS_DEMANDA_LIDA, ";
                    vFILTER = vFILTER + "REGIAO, ";
                    vFILTER = vFILTER + "SGDENVIO, ";
                    vFILTER = vFILTER + "ID_BCO_ANT, ";
                    vFILTER = vFILTER + "ID_BCO_ATUAL, ";
                    vFILTER = vFILTER + "LIVREESPECIAL, ";
                    vFILTER = vFILTER + "COMPROVANTE_RURAL, ";
                    vFILTER = vFILTER + "IDTIPO_MEDIDOR, ";
                    vFILTER = vFILTER + "MODELO, ";
                    vFILTER = vFILTER + "IDCONDUTOR, ";
                    vFILTER = vFILTER + "COMPRIMENTO_FIO, ";
                    vFILTER = vFILTER + "COD_TIPO_MEDICAO, ";
                    vFILTER = vFILTER + "TIPO_MEDICAO, ";
                    vFILTER = vFILTER + "IDTIPO_PADRAO_MEDICAO, ";
                    vFILTER = vFILTER + "TC_RELACAO_PRIMARIA, ";
                    vFILTER = vFILTER + "TC_RELACAO_SECUNDARIA, ";
                    vFILTER = vFILTER + "TP_RELACAO_PRIMARIA, ";
                    vFILTER = vFILTER + "TP_RELACAO_SECUNDARIA, ";
                    vFILTER = vFILTER + "IDALIMENTADOR, ";
                    vFILTER = vFILTER + "IDCORRENTE, ";
                    vFILTER = vFILTER + "AP_SAUDE, ";
                    vFILTER = vFILTER + "ESTUFA, ";
                    vFILTER = vFILTER + "RAMAL, ";
                    vFILTER = vFILTER + "DATA_RAMAL, ";
                    vFILTER = vFILTER + "CLIENTEPENDENTE, ";
                    vFILTER = vFILTER + "FLG_AVISO_DEBITO, ";
                    vFILTER = vFILTER + "IDMEDIDOR, ";
                    vFILTER = vFILTER + "AGRUPA, ";
                    vFILTER = vFILTER + "AGRUPA_CONTA, ";
                    vFILTER = vFILTER + "AGRUPA_LIVRO, ";
                    vFILTER = vFILTER + "AGRUPA_ZONA, ";
                    vFILTER = vFILTER + "AREA, ";
                    vFILTER = vFILTER + "BX0402, ";
                    vFILTER = vFILTER + "BXRENDA, ";
                    vFILTER = vFILTER + "DECAP_DATA, ";
                    vFILTER = vFILTER + "DECAP_NUM, ";
                    vFILTER = vFILTER + "DISJUNTOR, ";
                    vFILTER = vFILTER + "ELETROBRAS, ";
                    vFILTER = vFILTER + "FASELIG, ";
                    vFILTER = vFILTER + "FLGRES, ";
                    vFILTER = vFILTER + "FPFIXO, ";
                    vFILTER = vFILTER + "JUL2010, ";
                    vFILTER = vFILTER + "LUZ_TODOS, ";
                    vFILTER = vFILTER + "PAGTO_DUVIDOSO, ";
                    vFILTER = vFILTER + "RES694, ";
                    vFILTER = vFILTER + "RESIDUO_CONSUMO, ";
                    vFILTER = vFILTER + "TRANSF, ";
                    vFILTER = vFILTER + "ULTCONS, ";
                    vFILTER = vFILTER + "ULTKVARH, ";
                    vFILTER = vFILTER + "CONST, ";
                    vFILTER = vFILTER + "CONSTFP, ";
                    vFILTER = vFILTER + "KVARH, ";
                    vFILTER = vFILTER + "CNAE, ";
                    vFILTER = vFILTER + "IDCCEE, ";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO, ";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_P, ";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_I, ";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_FP, ";
                    vFILTER = vFILTER + "MICRO_GERACAO, ";
                    vFILTER = vFILTER + "KWH_REVERSO_RES, ";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_P, ";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_I, ";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_FP, ";
                    vFILTER = vFILTER + "PARCIALMENTE_CATIVO, ";
                    vFILTER = vFILTER + "DEMANDA_CONTR_ANTERIOR, ";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA_ANTERIOR, ";
                    vFILTER = vFILTER + "DEM_CONTR_FP_ANTERIOR, ";
                    vFILTER = vFILTER + "PERIODO_TESTE, ";
                    vFILTER = vFILTER + "VIP_TECNICO, ";
                    vFILTER = vFILTER + "MEDKVARH, ";
                    vFILTER = vFILTER + "IRRIGACAO_AQUICULTURA, ";
                    vFILTER = vFILTER + "ULTLEIT_IRRIGANTE, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES, ";
                    vFILTER = vFILTER + "LIVRE_VERDE, ";
                    vFILTER = vFILTER + "ULTLEIT_DESLIGAMENTO, ";
                    vFILTER = vFILTER + "LIVRE_LEITURA_CONSUMO, ";
                    vFILTER = vFILTER + "INI_PERIODO_TESTE, ";
                    vFILTER = vFILTER + "FIM_PERIODO_TESTE, ";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE, ";
                    vFILTER = vFILTER + "LATITUDE, ";
                    vFILTER = vFILTER + "LONGITUDE, ";
                    vFILTER = vFILTER + "IRR_HR_INI, ";
                    vFILTER = vFILTER + "IRR_HR_FIM, ";
                    vFILTER = vFILTER + "TARIFA_BRANCA, ";
                    vFILTER = vFILTER + "REATIVO, ";
                    vFILTER = vFILTER + "ISENTO_ICMS_TUSD, ";
                    vFILTER = vFILTER + "ENVIO_COB_JUDICIAL, ";
                    vFILTER = vFILTER + "BLOQUEA_SEG_VIA_FAT, ";
                    vFILTER = vFILTER + "BLOQUEA_RELIGACAO, ";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_P, ";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_I, ";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_FP, ";
                    vFILTER = vFILTER + "ULT_LEIT_KW_P, ";
                    vFILTER = vFILTER + "ULT_LEIT_KW_FP, ";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_P, ";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_I, ";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_FP, ";
                    vFILTER = vFILTER + "ULT_CONS_KWH_P, ";
                    vFILTER = vFILTER + "ULT_CONS_KWH_I, ";
                    vFILTER = vFILTER + "ULT_CONS_KWH_FP, ";
                    vFILTER = vFILTER + "ULT_CONS_KW_P, ";
                    vFILTER = vFILTER + "ULT_CONS_KW_FP, ";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_P, ";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_I, ";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_FP, ";
                    vFILTER = vFILTER + "KWH_RES_P, ";
                    vFILTER = vFILTER + "KWH_RES_I, ";
                    vFILTER = vFILTER + "KWH_RES_FP, ";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_P, ";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_I, ";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_FP, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_P, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_I, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_FP, ";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_P, ";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_I, ";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_FP, ";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_P, ";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_I, ";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_FP, ";
                    vFILTER = vFILTER + "CONST_KWH_P, ";
                    vFILTER = vFILTER + "CONST_KWH_I, ";
                    vFILTER = vFILTER + "CONST_KWH_FP, ";
                    vFILTER = vFILTER + "CONST_KW_P, ";
                    vFILTER = vFILTER + "CONST_KW_FP, ";
                    vFILTER = vFILTER + "CONST_KVARH_I, ";
                    vFILTER = vFILTER + "CONJUGE_FATURA, ";
                    vFILTER = vFILTER + "CADERNO, ";
                    vFILTER = vFILTER + "SEQUENCIA, ";
                    vFILTER = vFILTER + "ENVIO_EMAIL_FATURA ";


                    vINNERJOIN = " ";

                    vORDERBY = " ";

                    vAND = vAND + "AND IDMEDIDOR = ?IDMEDIDOR ";

                    if (objUCFaturamento.CLAS != String.Empty)
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND CLAS  ?CLAS "; }
                        else
                        { vAND = "AND CLAS  ?CLAS "; }

                    }
                    else
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + " "; }
                        else
                        { vAND = " "; }
                    }

                    if (objUCFaturamento.SITUACAO != String.Empty)
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND SITUACAO = ?SITUACAO "; }
                        else
                        { vAND = "AND SITUACAO = ?SITUACAO "; }

                    }
                    else
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + " "; }
                        else
                        { vAND = " "; }
                    }

                    if (objUCFaturamento.GRUPO != String.Empty)
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND LEFT(GRUPO, 1) = ?GRUPO "; }
                        else
                        { vAND = "AND LEFT(GRUPO, 1) = ?GRUPO "; }

                    }
                    else
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + " "; }
                        else
                        { vAND = " "; }
                    }


                    cmd = new MySqlCommand(this.QuerySelect);

                    cmd.Parameters.AddWithValue("?IDMEDIDOR", objUCFaturamento.IDMEDIDOR);

                    if (objUCFaturamento.CLAS != String.Empty)
                    {
                        cmd.Parameters.AddWithValue("?CLAS", objUCFaturamento.CLAS.ToString().ToUpper());
                    }

                    if (objUCFaturamento.SITUACAO != String.Empty)
                    {
                        cmd.Parameters.AddWithValue("?SITUACAO", objUCFaturamento.SITUACAO.ToString().ToUpper());
                    }

                    if (objUCFaturamento.GRUPO != String.Empty)
                    {
                        cmd.Parameters.AddWithValue("?GRUPO", objUCFaturamento.GRUPO.ToString().ToUpper());
                    }

                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable Select_17(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "GRUPO_TAR, ";
                    vFILTER = vFILTER + "ID, ";
                    vFILTER = vFILTER + "ZONA, ";
                    vFILTER = vFILTER + "LIVRO, ";
                    vFILTER = vFILTER + "CONTA, ";
                    vFILTER = vFILTER + "ROTA, ";
                    vFILTER = vFILTER + "INSTAL, ";
                    vFILTER = vFILTER + "ENCARGO, ";
                    vFILTER = vFILTER + "MEDKW, ";
                    vFILTER = vFILTER + "CONST_CONSUMO, ";
                    vFILTER = vFILTER + "CFOP, ";
                    vFILTER = vFILTER + "LEIT, ";
                    vFILTER = vFILTER + "KVAR, ";
                    vFILTER = vFILTER + "TA, ";
                    vFILTER = vFILTER + "CLAS, ";
                    vFILTER = vFILTER + "TENSAO, ";
                    vFILTER = vFILTER + "MEDKVARK, ";
                    vFILTER = vFILTER + "ANTRESERV, ";
                    vFILTER = vFILTER + "ARREDONDA_TEMP, ";
                    vFILTER = vFILTER + "ATURESERV, ";
                    vFILTER = vFILTER + "COD_TIPO_MEDIDOR, ";
                    vFILTER = vFILTER + "DTAUTODEC, ";
                    vFILTER = vFILTER + "FLG_ALIQUOTADIF, ";
                    vFILTER = vFILTER + "ISENTOREATIVO, ";
                    vFILTER = vFILTER + "MEDIMEC, ";
                    vFILTER = vFILTER + "NOVAMECA, ";
                    vFILTER = vFILTER + "NUM_UNIVERSALIZACAO, ";
                    vFILTER = vFILTER + "OBSERVACAO, ";
                    vFILTER = vFILTER + "PAGTO_GOVERNO, ";
                    vFILTER = vFILTER + "RG_ORGAO, ";
                    vFILTER = vFILTER + "RG_UF, ";
                    vFILTER = vFILTER + "TIPO_MEDIDOR, ";
                    vFILTER = vFILTER + "UNIVERSALIZACAO, ";
                    vFILTER = vFILTER + "VECTOPROXMES, ";
                    vFILTER = vFILTER + "VIP_COMERCIAL, ";
                    vFILTER = vFILTER + "DEMANDA, ";
                    vFILTER = vFILTER + "KVARKN, ";
                    vFILTER = vFILTER + "LEITANT, ";
                    vFILTER = vFILTER + "DEMANDAANT, ";
                    vFILTER = vFILTER + "DEMALIDA, ";
                    vFILTER = vFILTER + "KVARKNANT, ";
                    vFILTER = vFILTER + "GRUPO, ";
                    vFILTER = vFILTER + "FASE, ";
                    vFILTER = vFILTER + "CONST_DEMANDA, ";
                    vFILTER = vFILTER + "CONST_DEMANDA_FP, ";
                    vFILTER = vFILTER + "MAXIMO, ";
                    vFILTER = vFILTER + "PERC, ";
                    vFILTER = vFILTER + "ISENTO, ";
                    vFILTER = vFILTER + "MAIOR, ";
                    vFILTER = vFILTER + "ELETR, ";
                    vFILTER = vFILTER + "CONST_CONS_FP, ";
                    vFILTER = vFILTER + "CONST_CONS_P, ";
                    vFILTER = vFILTER + "CAP, ";
                    vFILTER = vFILTER + "DAP, ";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA, ";
                    vFILTER = vFILTER + "DEM_CONTR_FP, ";
                    vFILTER = vFILTER + "ULTLEIT, ";
                    vFILTER = vFILTER + "CONST_KVARH_P, ";
                    vFILTER = vFILTER + "CONST_KVARH_FP, ";
                    vFILTER = vFILTER + "KVARHFPN, ";
                    vFILTER = vFILTER + "KVARHPN, ";
                    vFILTER = vFILTER + "CONSTKVP, ";
                    vFILTER = vFILTER + "CONSTKVFP, ";
                    vFILTER = vFILTER + "CICE, ";
                    vFILTER = vFILTER + "ILUM, ";
                    vFILTER = vFILTER + "SITUACAO, ";
                    vFILTER = vFILTER + "FONE, ";
                    vFILTER = vFILTER + "DATA_LIGACAO, ";
                    vFILTER = vFILTER + "DATA_RELIGACAO, ";
                    vFILTER = vFILTER + "DATA_DESLIGAMENTO, ";
                    vFILTER = vFILTER + "DATA_ENTRADA, ";
                    vFILTER = vFILTER + "DATA_CORTE, ";
                    vFILTER = vFILTER + "DP12, ";
                    vFILTER = vFILTER + "QH, ";
                    vFILTER = vFILTER + "CARGA, ";
                    vFILTER = vFILTER + "FINAL, ";
                    vFILTER = vFILTER + "DEMANDA_CONTR, ";
                    vFILTER = vFILTER + "CONS_ID, ";
                    vFILTER = vFILTER + "UNID_ID, ";
                    vFILTER = vFILTER + "CONSLOC_ID, ";
                    vFILTER = vFILTER + "CODEND, ";
                    vFILTER = vFILTER + "END, ";
                    vFILTER = vFILTER + "BAIRRO, ";
                    vFILTER = vFILTER + "CIDADE, ";
                    vFILTER = vFILTER + "UF, ";
                    vFILTER = vFILTER + "QUADRA, ";
                    vFILTER = vFILTER + "LOTE, ";
                    vFILTER = vFILTER + "NUMERO, ";
                    vFILTER = vFILTER + "ITENSESP, ";
                    vFILTER = vFILTER + "NUM, ";
                    vFILTER = vFILTER + "TIPOUC, ";
                    vFILTER = vFILTER + "BANCO, ";
                    vFILTER = vFILTER + "AGENC, ";
                    vFILTER = vFILTER + "CC, ";
                    vFILTER = vFILTER + "CEP, ";
                    vFILTER = vFILTER + "NOME, ";
                    vFILTER = vFILTER + "ARREDONDA, ";
                    vFILTER = vFILTER + "ARREDONDA_ANT, ";
                    vFILTER = vFILTER + "CONST_KVARH, ";
                    vFILTER = vFILTER + "CONST_RESERVADO, ";
                    vFILTER = vFILTER + "DATA_CONTRATO_DEMANDA, ";
                    vFILTER = vFILTER + "HISTORICO, ";
                    vFILTER = vFILTER + "DIAVENC, ";
                    vFILTER = vFILTER + "FORMULA_CIP, ";
                    vFILTER = vFILTER + "SOCIAL, ";
                    vFILTER = vFILTER + "IDCNAE, ";
                    vFILTER = vFILTER + "LOCALIDADE, ";
                    vFILTER = vFILTER + "FLG_SAZONAL, ";
                    vFILTER = vFILTER + "CODEND_ENTREGA, ";
                    vFILTER = vFILTER + "END_ENTREGA, ";
                    vFILTER = vFILTER + "NUM_ENTREGA, ";
                    vFILTER = vFILTER + "BAI_ENTREGA, ";
                    vFILTER = vFILTER + "COMPL_ENTREGA, ";
                    vFILTER = vFILTER + "DIS_ENTREGA, ";
                    vFILTER = vFILTER + "CID_ENTREGA, ";
                    vFILTER = vFILTER + "UF_ENTREGA, ";
                    vFILTER = vFILTER + "CEP_ENTREGA, ";
                    vFILTER = vFILTER + "QUA_ENTREGA, ";
                    vFILTER = vFILTER + "LOT_ENTREGA, ";
                    vFILTER = vFILTER + "CPF_CNPJ, ";
                    vFILTER = vFILTER + "RG, ";
                    vFILTER = vFILTER + "INSC, ";
                    vFILTER = vFILTER + "PESSOA, ";
                    vFILTER = vFILTER + "COMPLEMENT, ";
                    vFILTER = vFILTER + "ENTREGA, ";
                    vFILTER = vFILTER + "DMCR, ";
                    vFILTER = vFILTER + "DTAINSTMEDIDOR, ";
                    vFILTER = vFILTER + "DTAFABMEDIDOR, ";
                    vFILTER = vFILTER + "LACRE, ";
                    vFILTER = vFILTER + "DISTRITO, ";
                    vFILTER = vFILTER + "MARCA, ";
                    vFILTER = vFILTER + "ICMS_ISENTO_DEMANDA, ";
                    vFILTER = vFILTER + "ICMS_DIFERIDO, ";
                    vFILTER = vFILTER + "LEITDEMA, ";
                    vFILTER = vFILTER + "BANARREC, ";
                    vFILTER = vFILTER + "PERC_RETENCAO, ";
                    vFILTER = vFILTER + "LEITREATIVO, ";
                    vFILTER = vFILTER + "ALTA_TENSAO, ";
                    vFILTER = vFILTER + "CIRCUITO, ";
                    vFILTER = vFILTER + "TP_LIGACAO, ";
                    vFILTER = vFILTER + "SOLICITANTE, ";
                    vFILTER = vFILTER + "ICMS_DEMANDA_LIDA, ";
                    vFILTER = vFILTER + "REGIAO, ";
                    vFILTER = vFILTER + "SGDENVIO, ";
                    vFILTER = vFILTER + "ID_BCO_ANT, ";
                    vFILTER = vFILTER + "ID_BCO_ATUAL, ";
                    vFILTER = vFILTER + "LIVREESPECIAL, ";
                    vFILTER = vFILTER + "COMPROVANTE_RURAL, ";
                    vFILTER = vFILTER + "IDTIPO_MEDIDOR, ";
                    vFILTER = vFILTER + "MODELO, ";
                    vFILTER = vFILTER + "IDCONDUTOR, ";
                    vFILTER = vFILTER + "COMPRIMENTO_FIO, ";
                    vFILTER = vFILTER + "COD_TIPO_MEDICAO, ";
                    vFILTER = vFILTER + "TIPO_MEDICAO, ";
                    vFILTER = vFILTER + "IDTIPO_PADRAO_MEDICAO, ";
                    vFILTER = vFILTER + "TC_RELACAO_PRIMARIA, ";
                    vFILTER = vFILTER + "TC_RELACAO_SECUNDARIA, ";
                    vFILTER = vFILTER + "TP_RELACAO_PRIMARIA, ";
                    vFILTER = vFILTER + "TP_RELACAO_SECUNDARIA, ";
                    vFILTER = vFILTER + "IDALIMENTADOR, ";
                    vFILTER = vFILTER + "IDCORRENTE, ";
                    vFILTER = vFILTER + "AP_SAUDE, ";
                    vFILTER = vFILTER + "ESTUFA, ";
                    vFILTER = vFILTER + "RAMAL, ";
                    vFILTER = vFILTER + "DATA_RAMAL, ";
                    vFILTER = vFILTER + "CLIENTEPENDENTE, ";
                    vFILTER = vFILTER + "FLG_AVISO_DEBITO, ";
                    vFILTER = vFILTER + "IDMEDIDOR, ";
                    vFILTER = vFILTER + "AGRUPA, ";
                    vFILTER = vFILTER + "AGRUPA_CONTA, ";
                    vFILTER = vFILTER + "AGRUPA_LIVRO, ";
                    vFILTER = vFILTER + "AGRUPA_ZONA, ";
                    vFILTER = vFILTER + "AREA, ";
                    vFILTER = vFILTER + "BX0402, ";
                    vFILTER = vFILTER + "BXRENDA, ";
                    vFILTER = vFILTER + "DECAP_DATA, ";
                    vFILTER = vFILTER + "DECAP_NUM, ";
                    vFILTER = vFILTER + "DISJUNTOR, ";
                    vFILTER = vFILTER + "ELETROBRAS, ";
                    vFILTER = vFILTER + "FASELIG, ";
                    vFILTER = vFILTER + "FLGRES, ";
                    vFILTER = vFILTER + "FPFIXO, ";
                    vFILTER = vFILTER + "JUL2010, ";
                    vFILTER = vFILTER + "LUZ_TODOS, ";
                    vFILTER = vFILTER + "PAGTO_DUVIDOSO, ";
                    vFILTER = vFILTER + "RES694, ";
                    vFILTER = vFILTER + "RESIDUO_CONSUMO, ";
                    vFILTER = vFILTER + "TRANSF, ";
                    vFILTER = vFILTER + "ULTCONS, ";
                    vFILTER = vFILTER + "ULTKVARH, ";
                    vFILTER = vFILTER + "CONST, ";
                    vFILTER = vFILTER + "CONSTFP, ";
                    vFILTER = vFILTER + "KVARH, ";
                    vFILTER = vFILTER + "CNAE, ";
                    vFILTER = vFILTER + "IDCCEE, ";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO, ";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_P, ";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_I, ";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_FP, ";
                    vFILTER = vFILTER + "MICRO_GERACAO, ";
                    vFILTER = vFILTER + "KWH_REVERSO_RES, ";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_P, ";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_I, ";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_FP, ";
                    vFILTER = vFILTER + "PARCIALMENTE_CATIVO, ";
                    vFILTER = vFILTER + "DEMANDA_CONTR_ANTERIOR, ";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA_ANTERIOR, ";
                    vFILTER = vFILTER + "DEM_CONTR_FP_ANTERIOR, ";
                    vFILTER = vFILTER + "PERIODO_TESTE, ";
                    vFILTER = vFILTER + "VIP_TECNICO, ";
                    vFILTER = vFILTER + "MEDKVARH, ";
                    vFILTER = vFILTER + "IRRIGACAO_AQUICULTURA, ";
                    vFILTER = vFILTER + "ULTLEIT_IRRIGANTE, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES, ";
                    vFILTER = vFILTER + "LIVRE_VERDE, ";
                    vFILTER = vFILTER + "ULTLEIT_DESLIGAMENTO, ";
                    vFILTER = vFILTER + "LIVRE_LEITURA_CONSUMO, ";
                    vFILTER = vFILTER + "INI_PERIODO_TESTE, ";
                    vFILTER = vFILTER + "FIM_PERIODO_TESTE, ";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE, ";
                    vFILTER = vFILTER + "LATITUDE, ";
                    vFILTER = vFILTER + "LONGITUDE, ";
                    vFILTER = vFILTER + "IRR_HR_INI, ";
                    vFILTER = vFILTER + "IRR_HR_FIM, ";
                    vFILTER = vFILTER + "TARIFA_BRANCA, ";
                    vFILTER = vFILTER + "REATIVO, ";
                    vFILTER = vFILTER + "ISENTO_ICMS_TUSD, ";
                    vFILTER = vFILTER + "ENVIO_COB_JUDICIAL, ";
                    vFILTER = vFILTER + "BLOQUEA_SEG_VIA_FAT, ";
                    vFILTER = vFILTER + "BLOQUEA_RELIGACAO, ";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_P, ";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_I, ";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_FP, ";
                    vFILTER = vFILTER + "ULT_LEIT_KW_P, ";
                    vFILTER = vFILTER + "ULT_LEIT_KW_FP, ";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_P, ";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_I, ";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_FP, ";
                    vFILTER = vFILTER + "ULT_CONS_KWH_P, ";
                    vFILTER = vFILTER + "ULT_CONS_KWH_I, ";
                    vFILTER = vFILTER + "ULT_CONS_KWH_FP, ";
                    vFILTER = vFILTER + "ULT_CONS_KW_P, ";
                    vFILTER = vFILTER + "ULT_CONS_KW_FP, ";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_P, ";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_I, ";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_FP, ";
                    vFILTER = vFILTER + "KWH_RES_P, ";
                    vFILTER = vFILTER + "KWH_RES_I, ";
                    vFILTER = vFILTER + "KWH_RES_FP, ";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_P, ";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_I, ";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_FP, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_P, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_I, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_FP, ";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_P, ";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_I, ";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_FP, ";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_P, ";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_I, ";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_FP, ";
                    vFILTER = vFILTER + "CONST_KWH_P, ";
                    vFILTER = vFILTER + "CONST_KWH_I, ";
                    vFILTER = vFILTER + "CONST_KWH_FP, ";
                    vFILTER = vFILTER + "CONST_KW_P, ";
                    vFILTER = vFILTER + "CONST_KW_FP, ";
                    vFILTER = vFILTER + "CONST_KVARH_I, ";
                    vFILTER = vFILTER + "CONJUGE_FATURA, ";
                    vFILTER = vFILTER + "CADERNO, ";
                    vFILTER = vFILTER + "SEQUENCIA, ";
                    vFILTER = vFILTER + "ENVIO_EMAIL_FATURA, ";
                    vFILTER = vFILTER + "FAT_QUANT ";

                    vINNERJOIN = " ";

                    vORDERBY = " ";

                    vAND = vAND + "AND ID = ?ID ";

                    vAND = vAND + "AND LEFT(GRUPO, 1) = ?GRUPO ";


                    cmd = new MySqlCommand(this.QuerySelect);

                    cmd.Parameters.AddWithValue("?ID", objUCFaturamento.ID);
                    cmd.Parameters.AddWithValue("?GRUPO", objUCFaturamento.GRUPO.ToString().ToUpper());

                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable Select_18(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "SITUACAO, ";
                    vFILTER = vFILTER + "COUNT(*) AS QTDE ";


                    vINNERJOIN = " ";

                    vORDERBY = "GROUP BY SITUACAO ";

                    if (objUCFaturamento.ROTA_INICIAL != string.Empty && objUCFaturamento.ROTA_FINAL != string.Empty)
                    {
                        vAND = vAND + "   AND(ROTA BETWEEN ?ROTA_INICIAL AND ?ROTA_FINAL) ";
                    }

                    if (objUCFaturamento.ZONA != string.Empty)
                    {
                        vAND = vAND + "   AND ZONA = ?ZONA ";
                    }

                    if (objUCFaturamento.LIVRO != string.Empty)
                    {
                        vAND = vAND + "   AND LIVRO = ?LIVRO ";
                    }

                    if (objUCFaturamento.CONTA != string.Empty)
                    {
                        vAND = vAND + "   AND CONTA = ?CONTA ";
                    }

                    if (objUCFaturamento.ROTA != string.Empty)
                    {
                        vAND = vAND + "    AND MID(TRIM(ROTA), 1, 4) IN ( ?ROTA ) ";
                    }


                    cmd = new MySqlCommand(this.QuerySelect);

                    if (objUCFaturamento.ROTA_INICIAL != string.Empty && objUCFaturamento.ROTA_FINAL != string.Empty)
                    {
                        cmd.Parameters.AddWithValue("?ROTA_INICIAL", objUCFaturamento.ROTA_INICIAL.ToString().ToUpper());
                        cmd.Parameters.AddWithValue("?ROTA_FINAL", objUCFaturamento.ROTA_FINAL.ToString().ToUpper());
                    }

                    if (objUCFaturamento.ZONA != string.Empty)
                    {
                        cmd.Parameters.AddWithValue("?ZONA", objUCFaturamento.ZONA.ToString().ToUpper());
                    }

                    if (objUCFaturamento.LIVRO != string.Empty)
                    {
                        cmd.Parameters.AddWithValue("?LIVRO", objUCFaturamento.LIVRO.ToString().ToUpper());
                    }

                    if (objUCFaturamento.CONTA != string.Empty)
                    {
                        cmd.Parameters.AddWithValue("?CONTA", objUCFaturamento.CONTA.ToString().ToUpper());
                    }

                    if (objUCFaturamento.ROTA != string.Empty)
                    {
                        cmd.Parameters.AddWithValue("?ROTA", objUCFaturamento.ROTA.ToString().ToUpper());
                    }


                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable Select_19(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "GRUPO_TAR, ";
                    vFILTER = vFILTER + "ID, ";
                    vFILTER = vFILTER + "ZONA, ";
                    vFILTER = vFILTER + "LIVRO, ";
                    vFILTER = vFILTER + "CONTA, ";
                    vFILTER = vFILTER + "ROTA, ";
                    vFILTER = vFILTER + "INSTAL, ";
                    vFILTER = vFILTER + "ENCARGO, ";
                    vFILTER = vFILTER + "MEDKW, ";
                    vFILTER = vFILTER + "CONST_CONSUMO, ";
                    vFILTER = vFILTER + "CFOP, ";
                    vFILTER = vFILTER + "LEIT, ";
                    vFILTER = vFILTER + "KVAR, ";
                    vFILTER = vFILTER + "TA, ";
                    vFILTER = vFILTER + "CLAS, ";
                    vFILTER = vFILTER + "TENSAO, ";
                    vFILTER = vFILTER + "MEDKVARK, ";
                    vFILTER = vFILTER + "ANTRESERV, ";
                    vFILTER = vFILTER + "ARREDONDA_TEMP, ";
                    vFILTER = vFILTER + "ATURESERV, ";
                    vFILTER = vFILTER + "COD_TIPO_MEDIDOR, ";
                    vFILTER = vFILTER + "DTAUTODEC, ";
                    vFILTER = vFILTER + "FLG_ALIQUOTADIF, ";
                    vFILTER = vFILTER + "ISENTOREATIVO, ";
                    vFILTER = vFILTER + "MEDIMEC, ";
                    vFILTER = vFILTER + "NOVAMECA, ";
                    vFILTER = vFILTER + "NUM_UNIVERSALIZACAO, ";
                    vFILTER = vFILTER + "OBSERVACAO, ";
                    vFILTER = vFILTER + "PAGTO_GOVERNO, ";
                    vFILTER = vFILTER + "RG_ORGAO, ";
                    vFILTER = vFILTER + "RG_UF, ";
                    vFILTER = vFILTER + "TIPO_MEDIDOR, ";
                    vFILTER = vFILTER + "UNIVERSALIZACAO, ";
                    vFILTER = vFILTER + "VECTOPROXMES, ";
                    vFILTER = vFILTER + "VIP_COMERCIAL, ";
                    vFILTER = vFILTER + "DEMANDA, ";
                    vFILTER = vFILTER + "KVARKN, ";
                    vFILTER = vFILTER + "LEITANT, ";
                    vFILTER = vFILTER + "DEMANDAANT, ";
                    vFILTER = vFILTER + "DEMALIDA, ";
                    vFILTER = vFILTER + "KVARKNANT, ";
                    vFILTER = vFILTER + "GRUPO, ";
                    vFILTER = vFILTER + "FASE, ";
                    vFILTER = vFILTER + "CONST_DEMANDA, ";
                    vFILTER = vFILTER + "CONST_DEMANDA_FP, ";
                    vFILTER = vFILTER + "MAXIMO, ";
                    vFILTER = vFILTER + "PERC, ";
                    vFILTER = vFILTER + "ISENTO, ";
                    vFILTER = vFILTER + "MAIOR, ";
                    vFILTER = vFILTER + "ELETR, ";
                    vFILTER = vFILTER + "CONST_CONS_FP, ";
                    vFILTER = vFILTER + "CONST_CONS_P, ";
                    vFILTER = vFILTER + "CAP, ";
                    vFILTER = vFILTER + "DAP, ";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA, ";
                    vFILTER = vFILTER + "DEM_CONTR_FP, ";
                    vFILTER = vFILTER + "ULTLEIT, ";
                    vFILTER = vFILTER + "CONST_KVARH_P, ";
                    vFILTER = vFILTER + "CONST_KVARH_FP, ";
                    vFILTER = vFILTER + "KVARHFPN, ";
                    vFILTER = vFILTER + "KVARHPN, ";
                    vFILTER = vFILTER + "CONSTKVP, ";
                    vFILTER = vFILTER + "CONSTKVFP, ";
                    vFILTER = vFILTER + "CICE, ";
                    vFILTER = vFILTER + "ILUM, ";
                    vFILTER = vFILTER + "SITUACAO, ";
                    vFILTER = vFILTER + "FONE, ";
                    vFILTER = vFILTER + "DATA_LIGACAO, ";
                    vFILTER = vFILTER + "DATA_RELIGACAO, ";
                    vFILTER = vFILTER + "DATA_DESLIGAMENTO, ";
                    vFILTER = vFILTER + "DATA_ENTRADA, ";
                    vFILTER = vFILTER + "DATA_CORTE, ";
                    vFILTER = vFILTER + "DP12, ";
                    vFILTER = vFILTER + "QH, ";
                    vFILTER = vFILTER + "CARGA, ";
                    vFILTER = vFILTER + "FINAL, ";
                    vFILTER = vFILTER + "DEMANDA_CONTR, ";
                    vFILTER = vFILTER + "CONS_ID, ";
                    vFILTER = vFILTER + "UNID_ID, ";
                    vFILTER = vFILTER + "CONSLOC_ID, ";
                    vFILTER = vFILTER + "CODEND, ";
                    vFILTER = vFILTER + "END, ";
                    vFILTER = vFILTER + "BAIRRO, ";
                    vFILTER = vFILTER + "CIDADE, ";
                    vFILTER = vFILTER + "UF, ";
                    vFILTER = vFILTER + "QUADRA, ";
                    vFILTER = vFILTER + "LOTE, ";
                    vFILTER = vFILTER + "NUMERO, ";
                    vFILTER = vFILTER + "ITENSESP, ";
                    vFILTER = vFILTER + "NUM, ";
                    vFILTER = vFILTER + "TIPOUC, ";
                    vFILTER = vFILTER + "BANCO, ";
                    vFILTER = vFILTER + "AGENC, ";
                    vFILTER = vFILTER + "CC, ";
                    vFILTER = vFILTER + "CEP, ";
                    vFILTER = vFILTER + "NOME, ";
                    vFILTER = vFILTER + "ARREDONDA, ";
                    vFILTER = vFILTER + "ARREDONDA_ANT, ";
                    vFILTER = vFILTER + "CONST_KVARH, ";
                    vFILTER = vFILTER + "CONST_RESERVADO, ";
                    vFILTER = vFILTER + "DATA_CONTRATO_DEMANDA, ";
                    vFILTER = vFILTER + "HISTORICO, ";
                    vFILTER = vFILTER + "DIAVENC, ";
                    vFILTER = vFILTER + "FORMULA_CIP, ";
                    vFILTER = vFILTER + "SOCIAL, ";
                    vFILTER = vFILTER + "IDCNAE, ";
                    vFILTER = vFILTER + "LOCALIDADE, ";
                    vFILTER = vFILTER + "FLG_SAZONAL, ";
                    vFILTER = vFILTER + "CODCIDADE, ";
                    vFILTER = vFILTER + "CODEND_ENTREGA, ";
                    vFILTER = vFILTER + "END_ENTREGA, ";
                    vFILTER = vFILTER + "NUM_ENTREGA, ";
                    vFILTER = vFILTER + "BAI_ENTREGA, ";
                    vFILTER = vFILTER + "COMPL_ENTREGA, ";
                    vFILTER = vFILTER + "DIS_ENTREGA, ";
                    vFILTER = vFILTER + "CID_ENTREGA, ";
                    vFILTER = vFILTER + "UF_ENTREGA, ";
                    vFILTER = vFILTER + "CEP_ENTREGA, ";
                    vFILTER = vFILTER + "QUA_ENTREGA, ";
                    vFILTER = vFILTER + "LOT_ENTREGA, ";
                    vFILTER = vFILTER + "CPF_CNPJ, ";
                    vFILTER = vFILTER + "RG, ";
                    vFILTER = vFILTER + "INSC, ";
                    vFILTER = vFILTER + "PESSOA, ";
                    vFILTER = vFILTER + "COMPLEMENT, ";
                    vFILTER = vFILTER + "ENTREGA, ";
                    vFILTER = vFILTER + "DMCR, ";
                    vFILTER = vFILTER + "DTAINSTMEDIDOR, ";
                    vFILTER = vFILTER + "DTAFABMEDIDOR, ";
                    vFILTER = vFILTER + "LACRE, ";
                    vFILTER = vFILTER + "DISTRITO, ";
                    vFILTER = vFILTER + "MARCA, ";
                    vFILTER = vFILTER + "ICMS_ISENTO_DEMANDA, ";
                    vFILTER = vFILTER + "ICMS_DIFERIDO, ";
                    vFILTER = vFILTER + "LEITDEMA, ";
                    vFILTER = vFILTER + "BANARREC, ";
                    vFILTER = vFILTER + "PERC_RETENCAO, ";
                    vFILTER = vFILTER + "LEITREATIVO, ";
                    vFILTER = vFILTER + "ALTA_TENSAO, ";
                    vFILTER = vFILTER + "CIRCUITO, ";
                    vFILTER = vFILTER + "TP_LIGACAO, ";
                    vFILTER = vFILTER + "SOLICITANTE, ";
                    vFILTER = vFILTER + "ICMS_DEMANDA_LIDA, ";
                    vFILTER = vFILTER + "REGIAO, ";
                    vFILTER = vFILTER + "SGDENVIO, ";
                    vFILTER = vFILTER + "ID_BCO_ANT, ";
                    vFILTER = vFILTER + "ID_BCO_ATUAL, ";
                    vFILTER = vFILTER + "LIVREESPECIAL, ";
                    vFILTER = vFILTER + "COMPROVANTE_RURAL, ";
                    vFILTER = vFILTER + "IDTIPO_MEDIDOR, ";
                    vFILTER = vFILTER + "MODELO, ";
                    vFILTER = vFILTER + "IDCONDUTOR, ";
                    vFILTER = vFILTER + "COMPRIMENTO_FIO, ";
                    vFILTER = vFILTER + "COD_TIPO_MEDICAO, ";
                    vFILTER = vFILTER + "TIPO_MEDICAO, ";
                    vFILTER = vFILTER + "IDTIPO_PADRAO_MEDICAO, ";
                    vFILTER = vFILTER + "TC_RELACAO_PRIMARIA, ";
                    vFILTER = vFILTER + "TC_RELACAO_SECUNDARIA, ";
                    vFILTER = vFILTER + "TP_RELACAO_PRIMARIA, ";
                    vFILTER = vFILTER + "TP_RELACAO_SECUNDARIA, ";
                    vFILTER = vFILTER + "IDALIMENTADOR, ";
                    vFILTER = vFILTER + "IDCORRENTE, ";
                    vFILTER = vFILTER + "AP_SAUDE, ";
                    vFILTER = vFILTER + "ESTUFA, ";
                    vFILTER = vFILTER + "RAMAL, ";
                    vFILTER = vFILTER + "DATA_RAMAL, ";
                    vFILTER = vFILTER + "CLIENTEPENDENTE, ";
                    vFILTER = vFILTER + "FLG_AVISO_DEBITO, ";
                    vFILTER = vFILTER + "IDMEDIDOR, ";
                    vFILTER = vFILTER + "AGRUPA, ";
                    vFILTER = vFILTER + "AGRUPA_CONTA, ";
                    vFILTER = vFILTER + "AGRUPA_LIVRO, ";
                    vFILTER = vFILTER + "AGRUPA_ZONA, ";
                    vFILTER = vFILTER + "AREA, ";
                    vFILTER = vFILTER + "BX0402, ";
                    vFILTER = vFILTER + "BXRENDA, ";
                    vFILTER = vFILTER + "DECAP_DATA, ";
                    vFILTER = vFILTER + "DECAP_NUM, ";
                    vFILTER = vFILTER + "DISJUNTOR, ";
                    vFILTER = vFILTER + "ELETROBRAS, ";
                    vFILTER = vFILTER + "FASELIG, ";
                    vFILTER = vFILTER + "FLGRES, ";
                    vFILTER = vFILTER + "FPFIXO, ";
                    vFILTER = vFILTER + "JUL2010, ";
                    vFILTER = vFILTER + "LUZ_TODOS, ";
                    vFILTER = vFILTER + "PAGTO_DUVIDOSO, ";
                    vFILTER = vFILTER + "RES694, ";
                    vFILTER = vFILTER + "RESIDUO_CONSUMO, ";
                    vFILTER = vFILTER + "TRANSF, ";
                    vFILTER = vFILTER + "ULTCONS, ";
                    vFILTER = vFILTER + "ULTKVARH, ";
                    vFILTER = vFILTER + "CONST, ";
                    vFILTER = vFILTER + "CONSTFP, ";
                    vFILTER = vFILTER + "KVARH, ";
                    vFILTER = vFILTER + "CNAE, ";
                    vFILTER = vFILTER + "IDCCEE, ";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO, ";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_P, ";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_I, ";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_FP, ";
                    vFILTER = vFILTER + "MICRO_GERACAO, ";
                    vFILTER = vFILTER + "KWH_REVERSO_RES, ";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_P, ";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_I, ";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_FP, ";
                    vFILTER = vFILTER + "PARCIALMENTE_CATIVO, ";
                    vFILTER = vFILTER + "DEMANDA_CONTR_ANTERIOR, ";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA_ANTERIOR, ";
                    vFILTER = vFILTER + "DEM_CONTR_FP_ANTERIOR, ";
                    vFILTER = vFILTER + "PERIODO_TESTE, ";
                    vFILTER = vFILTER + "VIP_TECNICO, ";
                    vFILTER = vFILTER + "MEDKVARH, ";
                    vFILTER = vFILTER + "IRRIGACAO_AQUICULTURA, ";
                    vFILTER = vFILTER + "ULTLEIT_IRRIGANTE, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES, ";
                    vFILTER = vFILTER + "LIVRE_VERDE, ";
                    vFILTER = vFILTER + "ULTLEIT_DESLIGAMENTO, ";
                    vFILTER = vFILTER + "LIVRE_LEITURA_CONSUMO, ";
                    vFILTER = vFILTER + "INI_PERIODO_TESTE, ";
                    vFILTER = vFILTER + "FIM_PERIODO_TESTE, ";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE, ";
                    vFILTER = vFILTER + "LATITUDE, ";
                    vFILTER = vFILTER + "LONGITUDE, ";
                    vFILTER = vFILTER + "IRR_HR_INI, ";
                    vFILTER = vFILTER + "IRR_HR_FIM, ";
                    vFILTER = vFILTER + "TARIFA_BRANCA, ";
                    vFILTER = vFILTER + "REATIVO, ";
                    vFILTER = vFILTER + "ISENTO_ICMS_TUSD, ";
                    vFILTER = vFILTER + "ENVIO_COB_JUDICIAL, ";
                    vFILTER = vFILTER + "BLOQUEA_SEG_VIA_FAT, ";
                    vFILTER = vFILTER + "BLOQUEA_RELIGACAO, ";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_P, ";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_I, ";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_FP, ";
                    vFILTER = vFILTER + "ULT_LEIT_KW_P, ";
                    vFILTER = vFILTER + "ULT_LEIT_KW_FP, ";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_P, ";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_I, ";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_FP, ";
                    vFILTER = vFILTER + "ULT_CONS_KWH_P, ";
                    vFILTER = vFILTER + "ULT_CONS_KWH_I, ";
                    vFILTER = vFILTER + "ULT_CONS_KWH_FP, ";
                    vFILTER = vFILTER + "ULT_CONS_KW_P, ";
                    vFILTER = vFILTER + "ULT_CONS_KW_FP, ";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_P, ";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_I, ";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_FP, ";
                    vFILTER = vFILTER + "KWH_RES_P, ";
                    vFILTER = vFILTER + "KWH_RES_I, ";
                    vFILTER = vFILTER + "KWH_RES_FP, ";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_P, ";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_I, ";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_FP, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_P, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_I, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_FP, ";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_P, ";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_I, ";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_FP, ";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_P, ";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_I, ";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_FP, ";
                    vFILTER = vFILTER + "CONST_KWH_P, ";
                    vFILTER = vFILTER + "CONST_KWH_I, ";
                    vFILTER = vFILTER + "CONST_KWH_FP, ";
                    vFILTER = vFILTER + "CONST_KW_P, ";
                    vFILTER = vFILTER + "CONST_KW_FP, ";
                    vFILTER = vFILTER + "CONST_KVARH_I, ";
                    vFILTER = vFILTER + "CONJUGE_FATURA, ";
                    vFILTER = vFILTER + "CADERNO, ";
                    vFILTER = vFILTER + "SEQUENCIA ";

                    vINNERJOIN = " ";

                    vORDERBY = " ";

                    if (objUCFaturamento.ZONA != string.Empty)
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND ZONA = ?ZONA "; }
                        else
                        { vAND = "AND ZONA = ?ZONA "; }

                    }
                    else
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + " "; }
                        else
                        { vAND = " "; }
                    }

                    if (objUCFaturamento.LIVRO != string.Empty)
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND LIVRO = ?LIVRO "; }
                        else
                        { vAND = "AND LIVRO = ?LIVRO "; }

                    }
                    else
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + " "; }
                        else
                        { vAND = " "; }
                    }

                    if (objUCFaturamento.CONTA != string.Empty)
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND CONTA = ?CONTA "; }
                        else
                        { vAND = "AND CONTA = ?CONTA "; }

                    }
                    else
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + " "; }
                        else
                        { vAND = " "; }
                    }

                    if (objUCFaturamento.ID != 0)
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND ID = ?ID "; }
                        else
                        { vAND = "AND ID = ?ID "; }

                    }
                    else
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + " "; }
                        else
                        { vAND = " "; }
                    }

                    if (objUCFaturamento.GRUPO != string.Empty)
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND LEFT(GRUPO,1) = ?GRUPO "; }
                        else
                        { vAND = "AND LEFT(GRUPO,1) = ?GRUPO "; }

                    }
                    else
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + " "; }
                        else
                        { vAND = " "; }
                    }

                    if (objUCFaturamento.CONS_ID != 0)
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND CONS_ID = ?CONS_ID "; }
                        else
                        { vAND = "AND CONS_ID = ?CONS_ID "; }

                    }
                    else
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + " "; }
                        else
                        { vAND = " "; }
                    }

                    cmd = new MySqlCommand(this.QuerySelect);

                    if (objUCFaturamento.ZONA != string.Empty)
                    {
                        cmd.Parameters.AddWithValue("?ZONA", objUCFaturamento.ZONA.ToString().ToUpper());
                    }

                    if (objUCFaturamento.LIVRO != string.Empty)
                    {
                        cmd.Parameters.AddWithValue("?LIVRO", objUCFaturamento.LIVRO.ToString().ToUpper());
                    }

                    if (objUCFaturamento.CONTA != string.Empty)
                    {
                        cmd.Parameters.AddWithValue("?CONTA", objUCFaturamento.CONTA.ToString().ToUpper());
                    }

                    if (objUCFaturamento.ID != 0)
                    {
                        cmd.Parameters.AddWithValue("?ID", objUCFaturamento.ID);
                    }

                    if (objUCFaturamento.GRUPO != string.Empty)
                    {
                        cmd.Parameters.AddWithValue("?GRUPO", objUCFaturamento.GRUPO.ToString().ToUpper());
                    }

                    if (objUCFaturamento.CONS_ID != 0)
                    {
                        cmd.Parameters.AddWithValue("?CONS_ID", objUCFaturamento.CONS_ID);
                    }

                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable Select_20(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "GRUPO_TAR, ";
                    vFILTER = vFILTER + "ID, ";
                    vFILTER = vFILTER + "ZONA ,";
                    vFILTER = vFILTER + "LIVRO ,";
                    vFILTER = vFILTER + "CONTA ,";
                    vFILTER = vFILTER + "ROTA ,";
                    vFILTER = vFILTER + "INSTAL ,";
                    vFILTER = vFILTER + "ENTREGA ,";
                    vFILTER = vFILTER + "BANCO ,";
                    vFILTER = vFILTER + "AGENC ,";
                    vFILTER = vFILTER + "CC ,";
                    vFILTER = vFILTER + "GRUPO ,";
                    vFILTER = vFILTER + "CLAS ,";
                    vFILTER = vFILTER + "FASE ,";
                    vFILTER = vFILTER + "NUM ,";
                    vFILTER = vFILTER + "MARCA ,";
                    vFILTER = vFILTER + "DTAFABMEDIDOR ,";
                    vFILTER = vFILTER + "DTAINSTMEDIDOR ,";
                    vFILTER = vFILTER + "CONST ,";
                    vFILTER = vFILTER + "SITUACAO ,";
                    vFILTER = vFILTER + "ULTLEIT ,";
                    vFILTER = vFILTER + "ULTCONS ,";
                    vFILTER = vFILTER + "ILUM ,";
                    vFILTER = vFILTER + "LEIT ,";
                    vFILTER = vFILTER + "FINAL ,";
                    vFILTER = vFILTER + "MEDKVARH ,";
                    vFILTER = vFILTER + "ULTKVARH ,";
                    vFILTER = vFILTER + "CONSTFP ,";
                    vFILTER = vFILTER + "KVARH ,";
                    vFILTER = vFILTER + "CICE ,";
                    vFILTER = vFILTER + "DATA_LIGACAO ,";
                    vFILTER = vFILTER + "DATA_RELIGACAO ,";
                    vFILTER = vFILTER + "DATA_DESLIGAMENTO ,";
                    vFILTER = vFILTER + "DATA_ENTRADA ,";
                    vFILTER = vFILTER + "DATA_CORTE ,";
                    vFILTER = vFILTER + "TENSAO ,";
                    vFILTER = vFILTER + "CARGA ,";
                    vFILTER = vFILTER + "TRANSF ,";
                    vFILTER = vFILTER + "FASELIG ,";
                    vFILTER = vFILTER + "ELETROBRAS ,";
                    vFILTER = vFILTER + "FPFIXO ,";
                    vFILTER = vFILTER + "CODEND ,";
                    vFILTER = vFILTER + "END ,";
                    vFILTER = vFILTER + "COMPLEMENT ,";
                    vFILTER = vFILTER + "BAIRRO ,";
                    vFILTER = vFILTER + "CIDADE ,";
                    vFILTER = vFILTER + "UF ,";
                    vFILTER = vFILTER + "QUADRA ,";
                    vFILTER = vFILTER + "LOTE ,";
                    vFILTER = vFILTER + "NUMERO ,";
                    vFILTER = vFILTER + "CONS_ID ,";
                    vFILTER = vFILTER + "CONSLOC_ID ,";
                    vFILTER = vFILTER + "FLGRES ,";
                    vFILTER = vFILTER + "UNID_ID ,";
                    vFILTER = vFILTER + "ITENSESP ,";
                    vFILTER = vFILTER + "TIPOUC ,";
                    vFILTER = vFILTER + "CEP ,";
                    vFILTER = vFILTER + "TA ,";
                    vFILTER = vFILTER + "ARREDONDA ,";
                    vFILTER = vFILTER + "ARREDONDA_ANT ,";
                    vFILTER = vFILTER + "HISTORICO ,";
                    vFILTER = vFILTER + "DIAVENC ,";
                    vFILTER = vFILTER + "FORMULA_CIP ,";
                    vFILTER = vFILTER + "SOCIAL ,";
                    vFILTER = vFILTER + "IDCNAE ,";
                    vFILTER = vFILTER + "LOCALIDADE ,";
                    vFILTER = vFILTER + "CODEND_ENTREGA ,";
                    vFILTER = vFILTER + "END_ENTREGA ,";
                    vFILTER = vFILTER + "NUM_ENTREGA ,";
                    vFILTER = vFILTER + "BAI_ENTREGA ,";
                    vFILTER = vFILTER + "COMPL_ENTREGA ,";
                    vFILTER = vFILTER + "DIS_ENTREGA ,";
                    vFILTER = vFILTER + "CID_ENTREGA ,";
                    vFILTER = vFILTER + "UF_ENTREGA ,";
                    vFILTER = vFILTER + "QUA_ENTREGA ,";
                    vFILTER = vFILTER + "LOT_ENTREGA ,";
                    vFILTER = vFILTER + "CEP_ENTREGA ,";
                    vFILTER = vFILTER + "CPF_CNPJ ,";
                    vFILTER = vFILTER + "RG ,";
                    vFILTER = vFILTER + "INSC ,";
                    vFILTER = vFILTER + "PESSOA ,";
                    vFILTER = vFILTER + "NOME ,";
                    vFILTER = vFILTER + "CIRCUITO ,";
                    vFILTER = vFILTER + "DISJUNTOR ,";
                    vFILTER = vFILTER + "DISTRITO ,";
                    vFILTER = vFILTER + "AREA ,";
                    vFILTER = vFILTER + "LACRE ,";
                    vFILTER = vFILTER + "RESIDUO_CONSUMO ,";
                    vFILTER = vFILTER + "DECAP_NUM ,";
                    vFILTER = vFILTER + "DECAP_DATA ,";
                    vFILTER = vFILTER + "BANARREC ,";
                    vFILTER = vFILTER + "AP_SAUDE ,";
                    vFILTER = vFILTER + "LUZ_TODOS ,";
                    vFILTER = vFILTER + "RES694 ,";
                    vFILTER = vFILTER + "ISENTO ,";
                    vFILTER = vFILTER + "ALTA_TENSAO ,";
                    vFILTER = vFILTER + "TP_LIGACAO ,";
                    vFILTER = vFILTER + "SOLICITANTE ,";
                    vFILTER = vFILTER + "AGRUPA ,";
                    vFILTER = vFILTER + "AGRUPA_ZONA ,";
                    vFILTER = vFILTER + "AGRUPA_LIVRO ,";
                    vFILTER = vFILTER + "AGRUPA_CONTA ,";
                    vFILTER = vFILTER + "BXRENDA ,";
                    vFILTER = vFILTER + "REGIAO ,";
                    vFILTER = vFILTER + "SGDENVIO ,";
                    vFILTER = vFILTER + "BX0402 ,";
                    vFILTER = vFILTER + "PAGTO_DUVIDOSO ,";
                    vFILTER = vFILTER + "ID_BCO_ANT ,";
                    vFILTER = vFILTER + "ID_BCO_ATUAL ,";
                    vFILTER = vFILTER + "COMPROVANTE_RURAL ,";
                    vFILTER = vFILTER + "JUL2010 ,";
                    vFILTER = vFILTER + "IDTIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "MODELO ,";
                    vFILTER = vFILTER + "IDCONDUTOR ,";
                    vFILTER = vFILTER + "COMPRIMENTO_FIO ,";
                    vFILTER = vFILTER + "COD_TIPO_MEDICAO ,";
                    vFILTER = vFILTER + "TIPO_MEDICAO ,";
                    vFILTER = vFILTER + "IDTIPO_PADRAO_MEDICAO ,";
                    vFILTER = vFILTER + "TC_RELACAO_PRIMARIA ,";
                    vFILTER = vFILTER + "TC_RELACAO_SECUNDARIA ,";
                    vFILTER = vFILTER + "TP_RELACAO_PRIMARIA ,";
                    vFILTER = vFILTER + "TP_RELACAO_SECUNDARIA ,";
                    vFILTER = vFILTER + "IDALIMENTADOR ,";
                    vFILTER = vFILTER + "IDCORRENTE ,";
                    vFILTER = vFILTER + "ESTUFA ,";
                    vFILTER = vFILTER + "RAMAL ,";
                    vFILTER = vFILTER + "DATA_RAMAL ,";
                    vFILTER = vFILTER + "CLIENTEPENDENTE ,";
                    vFILTER = vFILTER + "FLG_AVISO_DEBITO ,";
                    vFILTER = vFILTER + "IDMEDIDOR ,";
                    vFILTER = vFILTER + "CAP ,";
                    vFILTER = vFILTER + "CFOP ,";
                    vFILTER = vFILTER + "DAP ,";
                    vFILTER = vFILTER + "ENCARGO ,";
                    vFILTER = vFILTER + "FLG_SAZONAL ,";
                    vFILTER = vFILTER + "FONE ,";
                    vFILTER = vFILTER + "MAIOR ,";
                    vFILTER = vFILTER + "MAXIMO ,";
                    vFILTER = vFILTER + "PERC ,";
                    vFILTER = vFILTER + "PERC_RETENCAO ,";
                    vFILTER = vFILTER + "QH ,";
                    vFILTER = vFILTER + "CONST_CONS_FP ,";
                    vFILTER = vFILTER + "CONST_CONS_P ,";
                    vFILTER = vFILTER + "CONST_CONSUMO ,";
                    vFILTER = vFILTER + "CONST_DEMANDA ,";
                    vFILTER = vFILTER + "CONST_DEMANDA_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH ,";
                    vFILTER = vFILTER + "CONST_KVARH_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH_P ,";
                    vFILTER = vFILTER + "CONST_RESERVADO ,";
                    vFILTER = vFILTER + "CONSTKVFP ,";
                    vFILTER = vFILTER + "CONSTKVP ,";
                    vFILTER = vFILTER + "DATA_CONTRATO_DEMANDA ,";
                    vFILTER = vFILTER + "DEM_CONTR_FP ,";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA ,";
                    vFILTER = vFILTER + "DEMALIDA ,";
                    vFILTER = vFILTER + "DEMANDA ,";
                    vFILTER = vFILTER + "DEMANDA_CONTR ,";
                    vFILTER = vFILTER + "DEMANDAANT ,";
                    vFILTER = vFILTER + "DMCR ,";
                    vFILTER = vFILTER + "DP12 ,";
                    vFILTER = vFILTER + "ELETR ,";
                    vFILTER = vFILTER + "ICMS_DEMANDA_LIDA ,";
                    vFILTER = vFILTER + "ICMS_DIFERIDO ,";
                    vFILTER = vFILTER + "ICMS_ISENTO_DEMANDA ,";
                    vFILTER = vFILTER + "KVAR ,";
                    vFILTER = vFILTER + "KVARHFPN ,";
                    vFILTER = vFILTER + "KVARHPN ,";
                    vFILTER = vFILTER + "KVARKN ,";
                    vFILTER = vFILTER + "KVARKNANT ,";
                    vFILTER = vFILTER + "LEITANT ,";
                    vFILTER = vFILTER + "LEITDEMA ,";
                    vFILTER = vFILTER + "LEITREATIVO ,";
                    vFILTER = vFILTER + "LIVREESPECIAL ,";
                    vFILTER = vFILTER + "MEDKW ,";
                    vFILTER = vFILTER + "CNAE ,";
                    vFILTER = vFILTER + "IDCCEE ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_P ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_I ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_FP ,";
                    vFILTER = vFILTER + "MICRO_GERACAO ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_P ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_I ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_FP ,";
                    vFILTER = vFILTER + "PARCIALMENTE_CATIVO ,";
                    vFILTER = vFILTER + "DEMANDA_CONTR_ANTERIOR ,";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA_ANTERIOR ,";
                    vFILTER = vFILTER + "DEM_CONTR_FP_ANTERIOR ,";
                    vFILTER = vFILTER + "PERIODO_TESTE ,";
                    vFILTER = vFILTER + "MEDKVARK ,";
                    vFILTER = vFILTER + "ANTRESERV ,";
                    vFILTER = vFILTER + "ARREDONDA_TEMP ,";
                    vFILTER = vFILTER + "ATURESERV ,";
                    vFILTER = vFILTER + "COD_TIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "DTAUTODEC ,";
                    vFILTER = vFILTER + "FLG_ALIQUOTADIF ,";
                    vFILTER = vFILTER + "ISENTOREATIVO ,";
                    vFILTER = vFILTER + "MEDIMEC ,";
                    vFILTER = vFILTER + "NOVAMECA ,";
                    vFILTER = vFILTER + "NUM_UNIVERSALIZACAO ,";
                    vFILTER = vFILTER + "OBSERVACAO ,";
                    vFILTER = vFILTER + "PAGTO_GOVERNO ,";
                    vFILTER = vFILTER + "RG_ORGAO ,";
                    vFILTER = vFILTER + "RG_UF ,";
                    vFILTER = vFILTER + "TIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "UNIVERSALIZACAO ,";
                    vFILTER = vFILTER + "VECTOPROXMES ,";
                    vFILTER = vFILTER + "VIP_COMERCIAL ,";
                    vFILTER = vFILTER + "VIP_TECNICO ,";
                    vFILTER = vFILTER + "IRRIGACAO_AQUICULTURA ,";
                    vFILTER = vFILTER + "ULTLEIT_IRRIGANTE ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES ,";
                    vFILTER = vFILTER + "LIVRE_VERDE ,";
                    vFILTER = vFILTER + "ULTLEIT_DESLIGAMENTO ,";
                    vFILTER = vFILTER + "LIVRE_LEITURA_CONSUMO ,";
                    vFILTER = vFILTER + "INI_PERIODO_TESTE ,";
                    vFILTER = vFILTER + "FIM_PERIODO_TESTE ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE ,";
                    vFILTER = vFILTER + "LATITUDE ,";
                    vFILTER = vFILTER + "LONGITUDE ,";
                    vFILTER = vFILTER + "IRR_HR_INI ,";
                    vFILTER = vFILTER + "IRR_HR_FIM ,";
                    vFILTER = vFILTER + "TARIFA_BRANCA ,";
                    vFILTER = vFILTER + "REATIVO ,";
                    vFILTER = vFILTER + "ISENTO_ICMS_TUSD ,";
                    vFILTER = vFILTER + "ENVIO_COB_JUDICIAL ,";
                    vFILTER = vFILTER + "BLOQUEA_SEG_VIA_FAT ,";
                    vFILTER = vFILTER + "BLOQUEA_RELIGACAO ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_KW_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KW_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_I ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KW_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KW_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_I ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_FP ,";
                    vFILTER = vFILTER + "KWH_RES_P ,";
                    vFILTER = vFILTER + "KWH_RES_I ,";
                    vFILTER = vFILTER + "KWH_RES_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_FP ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_P ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_I ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_FP ,";
                    vFILTER = vFILTER + "CONST_KWH_P ,";
                    vFILTER = vFILTER + "CONST_KWH_I ,";
                    vFILTER = vFILTER + "CONST_KWH_FP ,";
                    vFILTER = vFILTER + "CONST_KW_P ,";
                    vFILTER = vFILTER + "CONST_KW_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH_I ,";
                    vFILTER = vFILTER + "CONJUGE_FATURA ,";
                    vFILTER = vFILTER + "CADERNO ,";

                    vFILTER = vFILTER + "CalculaMediaConsumo( UNID_ID, CONS_ID " + " , " + objUCFaturamento.ANO_MES + " ) MediaConsumoMensal, ";
                    vFILTER = vFILTER + "IFNULL(Numero_Caixa ,  SUBSTR(COMPLEMENT,3,6) ) as Numero_Caixa ,";

                    vFILTER = vFILTER + "SEQUENCIA  ";

                    vINNERJOIN = " ";

                    vORDERBY = "ORDER BY LPAD(LEFT(ROTA, 4), 4,'0'), SEQUENCIA  ";

                    vAND = " ";

                    if (!String.IsNullOrEmpty(objUCFaturamento.SITUACAO))
                    {
                        vAND = vAND + " AND SITUACAO IN (" + objUCFaturamento.SITUACAO + ") ";


                    }

                    if (!String.IsNullOrEmpty(objUCFaturamento.ROTA))
                    {
                        vAND = vAND + " AND LPAD(LEFT(ROTA, 4), 4,'0') IN (" + objUCFaturamento.ROTA + ") ";

                    }

                    vAND = vAND + " AND DATA_LIGACAO < '" +   objUCFaturamento.DATALIGACAO.ToString() + "'";

                    cmd = new MySqlCommand(this.QuerySelect);

                    if (!String.IsNullOrEmpty(objUCFaturamento.DIAVENC))
                    {
                        cmd.Parameters.AddWithValue("?DIAVENC", objUCFaturamento.DIAVENC.ToString().ToUpper());
                    }

                    if (!String.IsNullOrEmpty(objUCFaturamento.SITUACAO))
                    {
                        cmd.Parameters.AddWithValue("?SITUACAO", objUCFaturamento.SITUACAO.ToString().ToUpper());
                    }

                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable Select_21(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "GRUPO_TAR, ";
                    vFILTER = vFILTER + "ID, ";
                    vFILTER = vFILTER + "ZONA ,";
                    vFILTER = vFILTER + "LIVRO ,";
                    vFILTER = vFILTER + "CONTA ,";
                    vFILTER = vFILTER + "ROTA ,";
                    vFILTER = vFILTER + "INSTAL ,";
                    vFILTER = vFILTER + "ENTREGA ,";
                    vFILTER = vFILTER + "BANCO ,";
                    vFILTER = vFILTER + "AGENC ,";
                    vFILTER = vFILTER + "CC ,";
                    vFILTER = vFILTER + "GRUPO ,";
                    vFILTER = vFILTER + "CLAS ,";
                    vFILTER = vFILTER + "FASE ,";
                    vFILTER = vFILTER + "NUM ,";
                    vFILTER = vFILTER + "MARCA ,";
                    vFILTER = vFILTER + "DTAFABMEDIDOR ,";
                    vFILTER = vFILTER + "DTAINSTMEDIDOR ,";
                    vFILTER = vFILTER + "CONST ,";
                    vFILTER = vFILTER + "SITUACAO ,";
                    vFILTER = vFILTER + "ULTLEIT ,";
                    vFILTER = vFILTER + "ULTCONS ,";
                    vFILTER = vFILTER + "ILUM ,";
                    vFILTER = vFILTER + "LEIT ,";
                    vFILTER = vFILTER + "FINAL ,";
                    vFILTER = vFILTER + "MEDKVARH ,";
                    vFILTER = vFILTER + "ULTKVARH ,";
                    vFILTER = vFILTER + "CONSTFP ,";
                    vFILTER = vFILTER + "KVARH ,";
                    vFILTER = vFILTER + "CICE ,";
                    vFILTER = vFILTER + "DATA_LIGACAO ,";
                    vFILTER = vFILTER + "DATA_RELIGACAO ,";
                    vFILTER = vFILTER + "DATA_DESLIGAMENTO ,";
                    vFILTER = vFILTER + "DATA_ENTRADA ,";
                    vFILTER = vFILTER + "DATA_CORTE ,";
                    vFILTER = vFILTER + "TENSAO ,";
                    vFILTER = vFILTER + "CARGA ,";
                    vFILTER = vFILTER + "TRANSF ,";
                    vFILTER = vFILTER + "FASELIG ,";
                    vFILTER = vFILTER + "ELETROBRAS ,";
                    vFILTER = vFILTER + "FPFIXO ,";
                    vFILTER = vFILTER + "CODEND ,";
                    vFILTER = vFILTER + "END ,";
                    vFILTER = vFILTER + "COMPLEMENT ,";
                    vFILTER = vFILTER + "BAIRRO ,";
                    vFILTER = vFILTER + "CIDADE ,";
                    vFILTER = vFILTER + "UF ,";
                    vFILTER = vFILTER + "QUADRA ,";
                    vFILTER = vFILTER + "LOTE ,";
                    vFILTER = vFILTER + "NUMERO ,";
                    vFILTER = vFILTER + "CONS_ID ,";
                    vFILTER = vFILTER + "CONSLOC_ID ,";
                    vFILTER = vFILTER + "FLGRES ,";
                    vFILTER = vFILTER + "UNID_ID ,";
                    vFILTER = vFILTER + "ITENSESP ,";
                    vFILTER = vFILTER + "TIPOUC ,";
                    vFILTER = vFILTER + "CEP ,";
                    vFILTER = vFILTER + "TA ,";
                    vFILTER = vFILTER + "ARREDONDA ,";
                    vFILTER = vFILTER + "ARREDONDA_ANT ,";
                    vFILTER = vFILTER + "HISTORICO ,";
                    vFILTER = vFILTER + "DIAVENC ,";
                    vFILTER = vFILTER + "FORMULA_CIP ,";
                    vFILTER = vFILTER + "SOCIAL ,";
                    vFILTER = vFILTER + "IDCNAE ,";
                    vFILTER = vFILTER + "LOCALIDADE ,";
                    vFILTER = vFILTER + "CODEND_ENTREGA ,";
                    vFILTER = vFILTER + "END_ENTREGA ,";
                    vFILTER = vFILTER + "NUM_ENTREGA ,";
                    vFILTER = vFILTER + "BAI_ENTREGA ,";
                    vFILTER = vFILTER + "COMPL_ENTREGA ,";
                    vFILTER = vFILTER + "DIS_ENTREGA ,";
                    vFILTER = vFILTER + "CID_ENTREGA ,";
                    vFILTER = vFILTER + "UF_ENTREGA ,";
                    vFILTER = vFILTER + "QUA_ENTREGA ,";
                    vFILTER = vFILTER + "LOT_ENTREGA ,";
                    vFILTER = vFILTER + "CEP_ENTREGA ,";
                    vFILTER = vFILTER + "CPF_CNPJ ,";
                    vFILTER = vFILTER + "RG ,";
                    vFILTER = vFILTER + "INSC ,";
                    vFILTER = vFILTER + "PESSOA ,";
                    vFILTER = vFILTER + "NOME ,";
                    vFILTER = vFILTER + "CIRCUITO ,";
                    vFILTER = vFILTER + "DISJUNTOR ,";
                    vFILTER = vFILTER + "DISTRITO ,";
                    vFILTER = vFILTER + "AREA ,";
                    vFILTER = vFILTER + "LACRE ,";
                    vFILTER = vFILTER + "RESIDUO_CONSUMO ,";
                    vFILTER = vFILTER + "DECAP_NUM ,";
                    vFILTER = vFILTER + "DECAP_DATA ,";
                    vFILTER = vFILTER + "BANARREC ,";
                    vFILTER = vFILTER + "AP_SAUDE ,";
                    vFILTER = vFILTER + "LUZ_TODOS ,";
                    vFILTER = vFILTER + "RES694 ,";
                    vFILTER = vFILTER + "ISENTO ,";
                    vFILTER = vFILTER + "ALTA_TENSAO ,";
                    vFILTER = vFILTER + "TP_LIGACAO ,";
                    vFILTER = vFILTER + "SOLICITANTE ,";
                    vFILTER = vFILTER + "AGRUPA ,";
                    vFILTER = vFILTER + "AGRUPA_ZONA ,";
                    vFILTER = vFILTER + "AGRUPA_LIVRO ,";
                    vFILTER = vFILTER + "AGRUPA_CONTA ,";
                    vFILTER = vFILTER + "BXRENDA ,";
                    vFILTER = vFILTER + "REGIAO ,";
                    vFILTER = vFILTER + "SGDENVIO ,";
                    vFILTER = vFILTER + "BX0402 ,";
                    vFILTER = vFILTER + "PAGTO_DUVIDOSO ,";
                    vFILTER = vFILTER + "ID_BCO_ANT ,";
                    vFILTER = vFILTER + "ID_BCO_ATUAL ,";
                    vFILTER = vFILTER + "COMPROVANTE_RURAL ,";
                    vFILTER = vFILTER + "JUL2010 ,";
                    vFILTER = vFILTER + "IDTIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "MODELO ,";
                    vFILTER = vFILTER + "IDCONDUTOR ,";
                    vFILTER = vFILTER + "COMPRIMENTO_FIO ,";
                    vFILTER = vFILTER + "COD_TIPO_MEDICAO ,";
                    vFILTER = vFILTER + "TIPO_MEDICAO ,";
                    vFILTER = vFILTER + "IDTIPO_PADRAO_MEDICAO ,";
                    vFILTER = vFILTER + "TC_RELACAO_PRIMARIA ,";
                    vFILTER = vFILTER + "TC_RELACAO_SECUNDARIA ,";
                    vFILTER = vFILTER + "TP_RELACAO_PRIMARIA ,";
                    vFILTER = vFILTER + "TP_RELACAO_SECUNDARIA ,";
                    vFILTER = vFILTER + "IDALIMENTADOR ,";
                    vFILTER = vFILTER + "IDCORRENTE ,";
                    vFILTER = vFILTER + "ESTUFA ,";
                    vFILTER = vFILTER + "RAMAL ,";
                    vFILTER = vFILTER + "DATA_RAMAL ,";
                    vFILTER = vFILTER + "CLIENTEPENDENTE ,";
                    vFILTER = vFILTER + "FLG_AVISO_DEBITO ,";
                    vFILTER = vFILTER + "IDMEDIDOR ,";
                    vFILTER = vFILTER + "CAP ,";
                    vFILTER = vFILTER + "CFOP ,";
                    vFILTER = vFILTER + "DAP ,";
                    vFILTER = vFILTER + "ENCARGO ,";
                    vFILTER = vFILTER + "FLG_SAZONAL ,";
                    vFILTER = vFILTER + "FONE ,";
                    vFILTER = vFILTER + "MAIOR ,";
                    vFILTER = vFILTER + "MAXIMO ,";
                    vFILTER = vFILTER + "PERC ,";
                    vFILTER = vFILTER + "PERC_RETENCAO ,";
                    vFILTER = vFILTER + "QH ,";
                    vFILTER = vFILTER + "CONST_CONS_FP ,";
                    vFILTER = vFILTER + "CONST_CONS_P ,";
                    vFILTER = vFILTER + "CONST_CONSUMO ,";
                    vFILTER = vFILTER + "CONST_DEMANDA ,";
                    vFILTER = vFILTER + "CONST_DEMANDA_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH ,";
                    vFILTER = vFILTER + "CONST_KVARH_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH_P ,";
                    vFILTER = vFILTER + "CONST_RESERVADO ,";
                    vFILTER = vFILTER + "CONSTKVFP ,";
                    vFILTER = vFILTER + "CONSTKVP ,";
                    vFILTER = vFILTER + "DATA_CONTRATO_DEMANDA ,";
                    vFILTER = vFILTER + "DEM_CONTR_FP ,";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA ,";
                    vFILTER = vFILTER + "DEMALIDA ,";
                    vFILTER = vFILTER + "DEMANDA ,";
                    vFILTER = vFILTER + "DEMANDA_CONTR ,";
                    vFILTER = vFILTER + "DEMANDAANT ,";
                    vFILTER = vFILTER + "DMCR ,";
                    vFILTER = vFILTER + "DP12 ,";
                    vFILTER = vFILTER + "ELETR ,";
                    vFILTER = vFILTER + "ICMS_DEMANDA_LIDA ,";
                    vFILTER = vFILTER + "ICMS_DIFERIDO ,";
                    vFILTER = vFILTER + "ICMS_ISENTO_DEMANDA ,";
                    vFILTER = vFILTER + "KVAR ,";
                    vFILTER = vFILTER + "KVARHFPN ,";
                    vFILTER = vFILTER + "KVARHPN ,";
                    vFILTER = vFILTER + "KVARKN ,";
                    vFILTER = vFILTER + "KVARKNANT ,";
                    vFILTER = vFILTER + "LEITANT ,";
                    vFILTER = vFILTER + "LEITDEMA ,";
                    vFILTER = vFILTER + "LEITREATIVO ,";
                    vFILTER = vFILTER + "LIVREESPECIAL ,";
                    vFILTER = vFILTER + "MEDKW ,";
                    vFILTER = vFILTER + "CNAE ,";
                    vFILTER = vFILTER + "IDCCEE ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_P ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_I ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_FP ,";
                    vFILTER = vFILTER + "MICRO_GERACAO ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_P ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_I ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_FP ,";
                    vFILTER = vFILTER + "PARCIALMENTE_CATIVO ,";
                    vFILTER = vFILTER + "DEMANDA_CONTR_ANTERIOR ,";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA_ANTERIOR ,";
                    vFILTER = vFILTER + "DEM_CONTR_FP_ANTERIOR ,";
                    vFILTER = vFILTER + "PERIODO_TESTE ,";
                    vFILTER = vFILTER + "MEDKVARK ,";
                    vFILTER = vFILTER + "ANTRESERV ,";
                    vFILTER = vFILTER + "ARREDONDA_TEMP ,";
                    vFILTER = vFILTER + "ATURESERV ,";
                    vFILTER = vFILTER + "COD_TIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "DTAUTODEC ,";
                    vFILTER = vFILTER + "FLG_ALIQUOTADIF ,";
                    vFILTER = vFILTER + "ISENTOREATIVO ,";
                    vFILTER = vFILTER + "MEDIMEC ,";
                    vFILTER = vFILTER + "NOVAMECA ,";
                    vFILTER = vFILTER + "NUM_UNIVERSALIZACAO ,";
                    vFILTER = vFILTER + "OBSERVACAO ,";
                    vFILTER = vFILTER + "PAGTO_GOVERNO ,";
                    vFILTER = vFILTER + "RG_ORGAO ,";
                    vFILTER = vFILTER + "RG_UF ,";
                    vFILTER = vFILTER + "TIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "UNIVERSALIZACAO ,";
                    vFILTER = vFILTER + "VECTOPROXMES ,";
                    vFILTER = vFILTER + "VIP_COMERCIAL ,";
                    vFILTER = vFILTER + "VIP_TECNICO ,";
                    vFILTER = vFILTER + "IRRIGACAO_AQUICULTURA ,";
                    vFILTER = vFILTER + "ULTLEIT_IRRIGANTE ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES ,";
                    vFILTER = vFILTER + "LIVRE_VERDE ,";
                    vFILTER = vFILTER + "ULTLEIT_DESLIGAMENTO ,";
                    vFILTER = vFILTER + "LIVRE_LEITURA_CONSUMO ,";
                    vFILTER = vFILTER + "INI_PERIODO_TESTE ,";
                    vFILTER = vFILTER + "FIM_PERIODO_TESTE ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE ,";
                    vFILTER = vFILTER + "LATITUDE ,";
                    vFILTER = vFILTER + "LONGITUDE ,";
                    vFILTER = vFILTER + "IRR_HR_INI ,";
                    vFILTER = vFILTER + "IRR_HR_FIM ,";
                    vFILTER = vFILTER + "TARIFA_BRANCA ,";
                    vFILTER = vFILTER + "REATIVO ,";
                    vFILTER = vFILTER + "ISENTO_ICMS_TUSD ,";
                    vFILTER = vFILTER + "ENVIO_COB_JUDICIAL ,";
                    vFILTER = vFILTER + "BLOQUEA_SEG_VIA_FAT ,";
                    vFILTER = vFILTER + "BLOQUEA_RELIGACAO ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_KW_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KW_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_I ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KW_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KW_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_I ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_FP ,";
                    vFILTER = vFILTER + "KWH_RES_P ,";
                    vFILTER = vFILTER + "KWH_RES_I ,";
                    vFILTER = vFILTER + "KWH_RES_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_FP ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_P ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_I ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_FP ,";
                    vFILTER = vFILTER + "CONST_KWH_P ,";
                    vFILTER = vFILTER + "CONST_KWH_I ,";
                    vFILTER = vFILTER + "CONST_KWH_FP ,";
                    vFILTER = vFILTER + "CONST_KW_P ,";
                    vFILTER = vFILTER + "CONST_KW_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH_I ,";
                    vFILTER = vFILTER + "CONJUGE_FATURA ,";
                    vFILTER = vFILTER + "CADERNO ,";
                    vFILTER = vFILTER + "SEQUENCIA  ";

                    vINNERJOIN = " ";

                    //vORDERBY = "ORDER BY UC_FATURAMENTO.ROTA ASC ";
                    vORDERBY = "ORDER BY UC_FATURAMENTO.SEQUENCIA ASC ";

                    vAND = vAND + "    AND UC_FATURAMENTO.ROTA >= ?ROTA ";
                    vAND = vAND + "    AND UC_FATURAMENTO.ROTA <= ?AGRUPA ";


                    if (!String.IsNullOrEmpty(objUCFaturamento.SITUACAO))
                    {
                        vAND = vAND + " AND SITUACAO NOT IN (" + objUCFaturamento.SITUACAO + ") ";
                    }

                  
                    cmd = new MySqlCommand(this.QuerySelect);

                    cmd.Parameters.AddWithValue("?ROTA", objUCFaturamento.ROTA.ToString().ToUpper());

                 
                    if (!String.IsNullOrEmpty(objUCFaturamento.SITUACAO))
                    {
                        cmd.Parameters.AddWithValue("?SITUACAO", objUCFaturamento.SITUACAO.ToString().ToUpper());
                    }

                    cmd.Parameters.AddWithValue("?AGRUPA", objUCFaturamento.AGRUPA.ToString().ToUpper());


                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable Select_22(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "GRUPO_TAR, ";
                    vFILTER = vFILTER + "ID, ";
                    vFILTER = vFILTER + "ZONA ,";
                    vFILTER = vFILTER + "LIVRO ,";
                    vFILTER = vFILTER + "CONTA ,";
                    vFILTER = vFILTER + "ROTA ,";
                    vFILTER = vFILTER + "INSTAL ,";
                    vFILTER = vFILTER + "ENTREGA ,";
                    vFILTER = vFILTER + "BANCO ,";
                    vFILTER = vFILTER + "AGENC ,";
                    vFILTER = vFILTER + "CC ,";
                    vFILTER = vFILTER + "GRUPO ,";
                    vFILTER = vFILTER + "CLAS ,";
                    vFILTER = vFILTER + "FASE ,";
                    vFILTER = vFILTER + "NUM ,";
                    vFILTER = vFILTER + "MARCA ,";
                    vFILTER = vFILTER + "DTAFABMEDIDOR ,";
                    vFILTER = vFILTER + "DTAINSTMEDIDOR ,";
                    vFILTER = vFILTER + "CONST ,";
                    vFILTER = vFILTER + "SITUACAO ,";
                    vFILTER = vFILTER + "ULTLEIT ,";
                    vFILTER = vFILTER + "ULTCONS ,";
                    vFILTER = vFILTER + "ILUM ,";
                    vFILTER = vFILTER + "LEIT ,";
                    vFILTER = vFILTER + "FINAL ,";
                    vFILTER = vFILTER + "MEDKVARH ,";
                    vFILTER = vFILTER + "ULTKVARH ,";
                    vFILTER = vFILTER + "CONSTFP ,";
                    vFILTER = vFILTER + "KVARH ,";
                    vFILTER = vFILTER + "CICE ,";
                    vFILTER = vFILTER + "DATA_LIGACAO ,";
                    vFILTER = vFILTER + "DATA_RELIGACAO ,";
                    vFILTER = vFILTER + "DATA_DESLIGAMENTO ,";
                    vFILTER = vFILTER + "DATA_ENTRADA ,";
                    vFILTER = vFILTER + "DATA_CORTE ,";
                    vFILTER = vFILTER + "TENSAO ,";
                    vFILTER = vFILTER + "CARGA ,";
                    vFILTER = vFILTER + "TRANSF ,";
                    vFILTER = vFILTER + "FASELIG ,";
                    vFILTER = vFILTER + "ELETROBRAS ,";
                    vFILTER = vFILTER + "FPFIXO ,";
                    vFILTER = vFILTER + "CODEND ,";
                    vFILTER = vFILTER + "END ,";
                    vFILTER = vFILTER + "COMPLEMENT ,";
                    vFILTER = vFILTER + "BAIRRO ,";
                    vFILTER = vFILTER + "CIDADE ,";
                    vFILTER = vFILTER + "UF ,";
                    vFILTER = vFILTER + "QUADRA ,";
                    vFILTER = vFILTER + "LOTE ,";
                    vFILTER = vFILTER + "NUMERO ,";
                    vFILTER = vFILTER + "CONS_ID ,";
                    vFILTER = vFILTER + "CONSLOC_ID ,";
                    vFILTER = vFILTER + "FLGRES ,";
                    vFILTER = vFILTER + "UNID_ID ,";
                    vFILTER = vFILTER + "ITENSESP ,";
                    vFILTER = vFILTER + "TIPOUC ,";
                    vFILTER = vFILTER + "CEP ,";
                    vFILTER = vFILTER + "TA ,";
                    vFILTER = vFILTER + "ARREDONDA ,";
                    vFILTER = vFILTER + "ARREDONDA_ANT ,";
                    vFILTER = vFILTER + "HISTORICO ,";
                    vFILTER = vFILTER + "DIAVENC ,";
                    vFILTER = vFILTER + "FORMULA_CIP ,";
                    vFILTER = vFILTER + "SOCIAL ,";
                    vFILTER = vFILTER + "IDCNAE ,";
                    vFILTER = vFILTER + "LOCALIDADE ,";
                    vFILTER = vFILTER + "CODEND_ENTREGA ,";
                    vFILTER = vFILTER + "END_ENTREGA ,";
                    vFILTER = vFILTER + "NUM_ENTREGA ,";
                    vFILTER = vFILTER + "BAI_ENTREGA ,";
                    vFILTER = vFILTER + "COMPL_ENTREGA ,";
                    vFILTER = vFILTER + "DIS_ENTREGA ,";
                    vFILTER = vFILTER + "CID_ENTREGA ,";
                    vFILTER = vFILTER + "UF_ENTREGA ,";
                    vFILTER = vFILTER + "QUA_ENTREGA ,";
                    vFILTER = vFILTER + "LOT_ENTREGA ,";
                    vFILTER = vFILTER + "CEP_ENTREGA ,";
                    vFILTER = vFILTER + "CPF_CNPJ ,";
                    vFILTER = vFILTER + "RG ,";
                    vFILTER = vFILTER + "INSC ,";
                    vFILTER = vFILTER + "PESSOA ,";
                    vFILTER = vFILTER + "NOME ,";
                    vFILTER = vFILTER + "CIRCUITO ,";
                    vFILTER = vFILTER + "DISJUNTOR ,";
                    vFILTER = vFILTER + "DISTRITO ,";
                    vFILTER = vFILTER + "AREA ,";
                    vFILTER = vFILTER + "LACRE ,";
                    vFILTER = vFILTER + "RESIDUO_CONSUMO ,";
                    vFILTER = vFILTER + "DECAP_NUM ,";
                    vFILTER = vFILTER + "DECAP_DATA ,";
                    vFILTER = vFILTER + "BANARREC ,";
                    vFILTER = vFILTER + "AP_SAUDE ,";
                    vFILTER = vFILTER + "LUZ_TODOS ,";
                    vFILTER = vFILTER + "RES694 ,";
                    vFILTER = vFILTER + "ISENTO ,";
                    vFILTER = vFILTER + "ALTA_TENSAO ,";
                    vFILTER = vFILTER + "TP_LIGACAO ,";
                    vFILTER = vFILTER + "SOLICITANTE ,";
                    vFILTER = vFILTER + "AGRUPA ,";
                    vFILTER = vFILTER + "AGRUPA_ZONA ,";
                    vFILTER = vFILTER + "AGRUPA_LIVRO ,";
                    vFILTER = vFILTER + "AGRUPA_CONTA ,";
                    vFILTER = vFILTER + "BXRENDA ,";
                    vFILTER = vFILTER + "REGIAO ,";
                    vFILTER = vFILTER + "SGDENVIO ,";
                    vFILTER = vFILTER + "BX0402 ,";
                    vFILTER = vFILTER + "PAGTO_DUVIDOSO ,";
                    vFILTER = vFILTER + "ID_BCO_ANT ,";
                    vFILTER = vFILTER + "ID_BCO_ATUAL ,";
                    vFILTER = vFILTER + "COMPROVANTE_RURAL ,";
                    vFILTER = vFILTER + "JUL2010 ,";
                    vFILTER = vFILTER + "IDTIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "MODELO ,";
                    vFILTER = vFILTER + "IDCONDUTOR ,";
                    vFILTER = vFILTER + "COMPRIMENTO_FIO ,";
                    vFILTER = vFILTER + "COD_TIPO_MEDICAO ,";
                    vFILTER = vFILTER + "TIPO_MEDICAO ,";
                    vFILTER = vFILTER + "IDTIPO_PADRAO_MEDICAO ,";
                    vFILTER = vFILTER + "TC_RELACAO_PRIMARIA ,";
                    vFILTER = vFILTER + "TC_RELACAO_SECUNDARIA ,";
                    vFILTER = vFILTER + "TP_RELACAO_PRIMARIA ,";
                    vFILTER = vFILTER + "TP_RELACAO_SECUNDARIA ,";
                    vFILTER = vFILTER + "IDALIMENTADOR ,";
                    vFILTER = vFILTER + "IDCORRENTE ,";
                    vFILTER = vFILTER + "ESTUFA ,";
                    vFILTER = vFILTER + "RAMAL ,";
                    vFILTER = vFILTER + "DATA_RAMAL ,";
                    vFILTER = vFILTER + "CLIENTEPENDENTE ,";
                    vFILTER = vFILTER + "FLG_AVISO_DEBITO ,";
                    vFILTER = vFILTER + "IDMEDIDOR ,";
                    vFILTER = vFILTER + "CAP ,";
                    vFILTER = vFILTER + "CFOP ,";
                    vFILTER = vFILTER + "DAP ,";
                    vFILTER = vFILTER + "ENCARGO ,";
                    vFILTER = vFILTER + "FLG_SAZONAL ,";
                    vFILTER = vFILTER + "FONE ,";
                    vFILTER = vFILTER + "MAIOR ,";
                    vFILTER = vFILTER + "MAXIMO ,";
                    vFILTER = vFILTER + "PERC ,";
                    vFILTER = vFILTER + "PERC_RETENCAO ,";
                    vFILTER = vFILTER + "QH ,";
                    vFILTER = vFILTER + "CONST_CONS_FP ,";
                    vFILTER = vFILTER + "CONST_CONS_P ,";
                    vFILTER = vFILTER + "CONST_CONSUMO ,";
                    vFILTER = vFILTER + "CONST_DEMANDA ,";
                    vFILTER = vFILTER + "CONST_DEMANDA_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH ,";
                    vFILTER = vFILTER + "CONST_KVARH_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH_P ,";
                    vFILTER = vFILTER + "CONST_RESERVADO ,";
                    vFILTER = vFILTER + "CONSTKVFP ,";
                    vFILTER = vFILTER + "CONSTKVP ,";
                    vFILTER = vFILTER + "DATA_CONTRATO_DEMANDA ,";
                    vFILTER = vFILTER + "DEM_CONTR_FP ,";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA ,";
                    vFILTER = vFILTER + "DEMALIDA ,";
                    vFILTER = vFILTER + "DEMANDA ,";
                    vFILTER = vFILTER + "DEMANDA_CONTR ,";
                    vFILTER = vFILTER + "DEMANDAANT ,";
                    vFILTER = vFILTER + "DMCR ,";
                    vFILTER = vFILTER + "DP12 ,";
                    vFILTER = vFILTER + "ELETR ,";
                    vFILTER = vFILTER + "ICMS_DEMANDA_LIDA ,";
                    vFILTER = vFILTER + "ICMS_DIFERIDO ,";
                    vFILTER = vFILTER + "ICMS_ISENTO_DEMANDA ,";
                    vFILTER = vFILTER + "KVAR ,";
                    vFILTER = vFILTER + "KVARHFPN ,";
                    vFILTER = vFILTER + "KVARHPN ,";
                    vFILTER = vFILTER + "KVARKN ,";
                    vFILTER = vFILTER + "KVARKNANT ,";
                    vFILTER = vFILTER + "LEITANT ,";
                    vFILTER = vFILTER + "LEITDEMA ,";
                    vFILTER = vFILTER + "LEITREATIVO ,";
                    vFILTER = vFILTER + "LIVREESPECIAL ,";
                    vFILTER = vFILTER + "MEDKW ,";
                    vFILTER = vFILTER + "CNAE ,";
                    vFILTER = vFILTER + "IDCCEE ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_P ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_I ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_FP ,";
                    vFILTER = vFILTER + "MICRO_GERACAO ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_P ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_I ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_FP ,";
                    vFILTER = vFILTER + "PARCIALMENTE_CATIVO ,";
                    vFILTER = vFILTER + "DEMANDA_CONTR_ANTERIOR ,";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA_ANTERIOR ,";
                    vFILTER = vFILTER + "DEM_CONTR_FP_ANTERIOR ,";
                    vFILTER = vFILTER + "PERIODO_TESTE ,";
                    vFILTER = vFILTER + "MEDKVARK ,";
                    vFILTER = vFILTER + "ANTRESERV ,";
                    vFILTER = vFILTER + "ARREDONDA_TEMP ,";
                    vFILTER = vFILTER + "ATURESERV ,";
                    vFILTER = vFILTER + "COD_TIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "DTAUTODEC ,";
                    vFILTER = vFILTER + "FLG_ALIQUOTADIF ,";
                    vFILTER = vFILTER + "ISENTOREATIVO ,";
                    vFILTER = vFILTER + "MEDIMEC ,";
                    vFILTER = vFILTER + "NOVAMECA ,";
                    vFILTER = vFILTER + "NUM_UNIVERSALIZACAO ,";
                    vFILTER = vFILTER + "OBSERVACAO ,";
                    vFILTER = vFILTER + "PAGTO_GOVERNO ,";
                    vFILTER = vFILTER + "RG_ORGAO ,";
                    vFILTER = vFILTER + "RG_UF ,";
                    vFILTER = vFILTER + "TIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "UNIVERSALIZACAO ,";
                    vFILTER = vFILTER + "VECTOPROXMES ,";
                    vFILTER = vFILTER + "VIP_COMERCIAL ,";
                    vFILTER = vFILTER + "VIP_TECNICO ,";
                    vFILTER = vFILTER + "IRRIGACAO_AQUICULTURA ,";
                    vFILTER = vFILTER + "ULTLEIT_IRRIGANTE ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES ,";
                    vFILTER = vFILTER + "LIVRE_VERDE ,";
                    vFILTER = vFILTER + "ULTLEIT_DESLIGAMENTO ,";
                    vFILTER = vFILTER + "LIVRE_LEITURA_CONSUMO ,";
                    vFILTER = vFILTER + "INI_PERIODO_TESTE ,";
                    vFILTER = vFILTER + "FIM_PERIODO_TESTE ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE ,";
                    vFILTER = vFILTER + "LATITUDE ,";
                    vFILTER = vFILTER + "LONGITUDE ,";
                    vFILTER = vFILTER + "IRR_HR_INI ,";
                    vFILTER = vFILTER + "IRR_HR_FIM ,";
                    vFILTER = vFILTER + "TARIFA_BRANCA ,";
                    vFILTER = vFILTER + "REATIVO ,";
                    vFILTER = vFILTER + "ISENTO_ICMS_TUSD ,";
                    vFILTER = vFILTER + "ENVIO_COB_JUDICIAL ,";
                    vFILTER = vFILTER + "BLOQUEA_SEG_VIA_FAT ,";
                    vFILTER = vFILTER + "BLOQUEA_RELIGACAO ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_KW_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KW_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_I ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KW_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KW_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_I ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_FP ,";
                    vFILTER = vFILTER + "KWH_RES_P ,";
                    vFILTER = vFILTER + "KWH_RES_I ,";
                    vFILTER = vFILTER + "KWH_RES_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_FP ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_P ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_I ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_FP ,";
                    vFILTER = vFILTER + "CONST_KWH_P ,";
                    vFILTER = vFILTER + "CONST_KWH_I ,";
                    vFILTER = vFILTER + "CONST_KWH_FP ,";
                    vFILTER = vFILTER + "CONST_KW_P ,";
                    vFILTER = vFILTER + "CONST_KW_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH_I ,";
                    vFILTER = vFILTER + "CONJUGE_FATURA ,";
                    vFILTER = vFILTER + "CADERNO ,";
                    vFILTER = vFILTER + "SEQUENCIA  ";

                    vINNERJOIN = " ";

                    vORDERBY = " ";

                    vAND = vAND + "   AND ZONA  = ?ZONA ";
                    vAND = vAND + "   AND LIVRO = ?LIVRO ";
                    vAND = vAND + "   AND CONTA = ?CONTA ";
                    vAND = vAND + "   AND ID = ?ID ";
                    // vAND = vAND + "   AND UNID_ID = ?UNID_ID ";

                    cmd = new MySqlCommand(this.QuerySelect);

                    cmd.Parameters.AddWithValue("?ZONA", objUCFaturamento.ZONA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?LIVRO", objUCFaturamento.LIVRO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CONTA", objUCFaturamento.CONTA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?ID", objUCFaturamento.ID.ToString().ToUpper());

                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable Select_23(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "UNID_ID, ";
                    vFILTER = vFILTER + "CONS_ID, ";
                    vFILTER = vFILTER + "ZONA, ";
                    vFILTER = vFILTER + "LIVRO, ";
                    vFILTER = vFILTER + "CONTA, ";
                    vFILTER = vFILTER + "NOME, ";
                    vFILTER = vFILTER + "SITUACAO, ";
                    vFILTER = vFILTER + "NUM, ";
                    vFILTER = vFILTER + "CONST, ";
                    vFILTER = vFILTER + "ROTA, ";
                    vFILTER = vFILTER + "SEQUENCIA, ";
                    vFILTER = vFILTER + "ULTLEIT, "  ;
                    vFILTER = vFILTER + "ULT_LEIT_CORTE, ";
                    vFILTER = vFILTER + "LEIT, ";
                    vFILTER = vFILTER + "MEDKVARH, ";
                    vFILTER = vFILTER + "ULTKVARH, ";
                    vFILTER = vFILTER + "KVARH, ";
                    vFILTER = vFILTER + "RESIDUO_CONSUMO, ";
                    vFILTER = vFILTER + "DATA_LIGACAO, ";
                    vFILTER = vFILTER + "MICRO_GERACAO, ";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO, ";
                    vFILTER = vFILTER + "KWH_REVERSO_RES, ";
                    vFILTER = vFILTER + "IRRIGACAO_AQUICULTURA, ";
                    vFILTER = vFILTER + "ULTLEIT_IRRIGANTE, ";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES, ";
                    vFILTER = vFILTER + "TARIFA_BRANCA, ";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_P, ";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_I, ";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_FP, ";
                    vFILTER = vFILTER + "KWH_RES_P, ";
                    vFILTER = vFILTER + "KWH_RES_I, ";
                    vFILTER = vFILTER + "KWH_RES_FP, ";
                    vFILTER = vFILTER + "CONST_KWH_P, ";
                    vFILTER = vFILTER + "CONST_KWH_I, ";
                    vFILTER = vFILTER + "CONST_KWH_FP ";

                    vINNERJOIN = " ";

                    vORDERBY = "ORDER BY UC_FATURAMENTO.SEQUENCIA ASC ";

                    vAND = vAND + "   AND MID(TRIM(UC_FATURAMENTO.ROTA), 1, 4) = ?ROTA ";

                    if (objUCFaturamento.DIAVENC != " ")
                    {
                        vAND = vAND + "  AND UC_FATURAMENTO.DIAVENC = ?DIAVENC ";
                    }

                    vAND = vAND + "   AND MID(UC_FATURAMENTO.GRUPO, 1,1)  = 'B' ";
                    vAND = vAND + "   AND UC_FATURAMENTO.ZONA <> ?ZONA ";
                    vAND = vAND + "   AND UC_FATURAMENTO.SITUACAO IN( " + objUCFaturamento.SITUACAO.ToString().ToUpper() + ") ";


                    cmd = new MySqlCommand(this.QuerySelect);

                    cmd.Parameters.AddWithValue("?ROTA", objUCFaturamento.ROTA.ToString().ToUpper());

                    if (objUCFaturamento.DIAVENC != " ")
                    {
                        cmd.Parameters.AddWithValue("?DIAVENC", objUCFaturamento.DIAVENC.ToString().ToUpper());
                    }

                    cmd.Parameters.AddWithValue("?ZONA", objUCFaturamento.ZONA.ToString().ToUpper());


                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable Select_24(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "grupo AS GRUPO_TAR, ";
                    vFILTER = vFILTER + "convert(concat(ZONA ,LIVRO ,CONTA),decimal) as ID, ";
                    vFILTER = vFILTER + "ZONA ,";
                    vFILTER = vFILTER + "LIVRO ,";
                    vFILTER = vFILTER + "CONTA ,";
                    vFILTER = vFILTER + "ROTA ,";
                    vFILTER = vFILTER + "INSTAL ,";
                    vFILTER = vFILTER + "ENTREGA ,";
                    vFILTER = vFILTER + "BANCO ,";
                    vFILTER = vFILTER + "AGENC ,";
                    vFILTER = vFILTER + "CC ,";
                    vFILTER = vFILTER + "GRUPO ,";
                    vFILTER = vFILTER + "CLAS ,";
                    vFILTER = vFILTER + "FASE ,";
                    vFILTER = vFILTER + "NUM ,";
                    vFILTER = vFILTER + "MARCA ,";
                    vFILTER = vFILTER + "DTAFABMEDIDOR ,";
                    vFILTER = vFILTER + "DTAINSTMEDIDOR ,";
                    vFILTER = vFILTER + "CONST ,";
                    vFILTER = vFILTER + "SITUACAO ,";
                    vFILTER = vFILTER + "ULTLEIT ,";
                    vFILTER = vFILTER + "ULTCONS ,";
                    vFILTER = vFILTER + "ILUM ,";
                    vFILTER = vFILTER + "LEIT ,";
                    vFILTER = vFILTER + "FINAL ,";
                    vFILTER = vFILTER + "MEDKVARH ,";
                    vFILTER = vFILTER + "ULTKVARH ,";
                    vFILTER = vFILTER + "CONSTFP ,";
                    vFILTER = vFILTER + "KVARH ,";
                    vFILTER = vFILTER + "CICE ,";
                    vFILTER = vFILTER + "DATA_LIGACAO ,";
                    vFILTER = vFILTER + "DATA_RELIGACAO ,";
                    vFILTER = vFILTER + "DATA_DESLIGAMENTO ,";
                    vFILTER = vFILTER + "DATA_ENTRADA ,";
                    vFILTER = vFILTER + "DATA_CORTE ,";
                    vFILTER = vFILTER + "TENSAO ,";
                    vFILTER = vFILTER + "CARGA ,";
                    vFILTER = vFILTER + "TRANSF ,";
                    vFILTER = vFILTER + "FASELIG ,";
                    vFILTER = vFILTER + "ELETROBRAS ,";
                    vFILTER = vFILTER + "FPFIXO ,";
                    vFILTER = vFILTER + "CODEND ,";
                    vFILTER = vFILTER + "END ,";
                    vFILTER = vFILTER + "COMPLEMENT ,";
                    vFILTER = vFILTER + "BAIRRO ,";
                    vFILTER = vFILTER + "CIDADE ,";
                    vFILTER = vFILTER + "UF ,";
                    vFILTER = vFILTER + "QUADRA ,";
                    vFILTER = vFILTER + "LOTE ,";
                    vFILTER = vFILTER + "NUMERO ,";
                    vFILTER = vFILTER + "CONS_ID ,";
                    vFILTER = vFILTER + "CONSLOC_ID ,";
                    vFILTER = vFILTER + "FLGRES ,";
                    vFILTER = vFILTER + "UNID_ID ,";
                    vFILTER = vFILTER + "ITENSESP ,";
                    vFILTER = vFILTER + "TIPOUC ,";
                    vFILTER = vFILTER + "CEP ,";
                    vFILTER = vFILTER + "TA ,";
                    vFILTER = vFILTER + "ARREDONDA ,";
                    vFILTER = vFILTER + "ARREDONDA_ANT ,";
                    vFILTER = vFILTER + "HISTORICO ,";
                    vFILTER = vFILTER + "DIAVENC ,";
                    vFILTER = vFILTER + "FORMULA_CIP ,";
                    vFILTER = vFILTER + "SOCIAL ,";
                    vFILTER = vFILTER + "IDCNAE ,";
                    vFILTER = vFILTER + "LOCALIDADE ,";
                    vFILTER = vFILTER + "CODEND_ENTREGA ,";
                    vFILTER = vFILTER + "END_ENTREGA ,";
                    vFILTER = vFILTER + "NUM_ENTREGA ,";
                    vFILTER = vFILTER + "BAI_ENTREGA ,";
                    vFILTER = vFILTER + "COMPL_ENTREGA ,";
                    vFILTER = vFILTER + "DIS_ENTREGA ,";
                    vFILTER = vFILTER + "CID_ENTREGA ,";
                    vFILTER = vFILTER + "UF_ENTREGA ,";
                    vFILTER = vFILTER + "QUA_ENTREGA ,";
                    vFILTER = vFILTER + "LOT_ENTREGA ,";
                    vFILTER = vFILTER + "CEP_ENTREGA ,";
                    vFILTER = vFILTER + "CPF_CNPJ ,";
                    vFILTER = vFILTER + "RG ,";
                    vFILTER = vFILTER + "INSC ,";
                    vFILTER = vFILTER + "PESSOA ,";
                    vFILTER = vFILTER + "NOME ,";
                    vFILTER = vFILTER + "CIRCUITO ,";
                    vFILTER = vFILTER + "DISJUNTOR ,";
                    vFILTER = vFILTER + "DISTRITO ,";
                    vFILTER = vFILTER + "AREA ,";
                    vFILTER = vFILTER + "LACRE ,";
                    vFILTER = vFILTER + "RESIDUO_CONSUMO ,";
                    vFILTER = vFILTER + "DECAP_NUM ,";
                    vFILTER = vFILTER + "DECAP_DATA ,";
                    vFILTER = vFILTER + "BANARREC ,";
                    vFILTER = vFILTER + "AP_SAUDE ,";
                    vFILTER = vFILTER + "LUZ_TODOS ,";
                    vFILTER = vFILTER + "RES694 ,";
                    vFILTER = vFILTER + "ISENTO ,";
                    vFILTER = vFILTER + "ALTA_TENSAO ,";
                    vFILTER = vFILTER + "TP_LIGACAO ,";
                    vFILTER = vFILTER + "SOLICITANTE ,";
                    vFILTER = vFILTER + "AGRUPA ,";
                    vFILTER = vFILTER + "AGRUPA_ZONA ,";
                    vFILTER = vFILTER + "AGRUPA_LIVRO ,";
                    vFILTER = vFILTER + "AGRUPA_CONTA ,";
                    vFILTER = vFILTER + "BXRENDA ,";
                    vFILTER = vFILTER + "REGIAO ,";
                    vFILTER = vFILTER + "SGDENVIO ,";
                    vFILTER = vFILTER + "BX0402 ,";
                    vFILTER = vFILTER + "PAGTO_DUVIDOSO ,";
                    vFILTER = vFILTER + "ID_BCO_ANT ,";
                    vFILTER = vFILTER + "ID_BCO_ATUAL ,";
                    vFILTER = vFILTER + "COMPROVANTE_RURAL ,";
                    vFILTER = vFILTER + "JUL2010 ,";
                    vFILTER = vFILTER + "IDTIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "MODELO ,";
                    vFILTER = vFILTER + "IDCONDUTOR ,";
                    vFILTER = vFILTER + "COMPRIMENTO_FIO ,";
                    vFILTER = vFILTER + "COD_TIPO_MEDICAO ,";
                    vFILTER = vFILTER + "TIPO_MEDICAO ,";
                    vFILTER = vFILTER + "IDTIPO_PADRAO_MEDICAO ,";
                    vFILTER = vFILTER + "TC_RELACAO_PRIMARIA ,";
                    vFILTER = vFILTER + "TC_RELACAO_SECUNDARIA ,";
                    vFILTER = vFILTER + "TP_RELACAO_PRIMARIA ,";
                    vFILTER = vFILTER + "TP_RELACAO_SECUNDARIA ,";
                    vFILTER = vFILTER + "IDALIMENTADOR ,";
                    vFILTER = vFILTER + "IDCORRENTE ,";
                    vFILTER = vFILTER + "ESTUFA ,";
                    vFILTER = vFILTER + "RAMAL ,";
                    vFILTER = vFILTER + "DATA_RAMAL ,";
                    vFILTER = vFILTER + "CLIENTEPENDENTE ,";
                    vFILTER = vFILTER + "FLG_AVISO_DEBITO ,";
                    vFILTER = vFILTER + "IDMEDIDOR ,";
                    vFILTER = vFILTER + "CAP ,";
                    vFILTER = vFILTER + "CFOP ,";
                    vFILTER = vFILTER + "DAP ,";
                    vFILTER = vFILTER + "ENCARGO ,";
                    vFILTER = vFILTER + "FLG_SAZONAL ,";
                    vFILTER = vFILTER + "FONE ,";
                    vFILTER = vFILTER + "MAIOR ,";
                    vFILTER = vFILTER + "MAXIMO ,";
                    vFILTER = vFILTER + "PERC ,";
                    vFILTER = vFILTER + "PERC_RETENCAO ,";
                    vFILTER = vFILTER + "QH ,";
                    vFILTER = vFILTER + "CONST_CONS_FP ,";
                    vFILTER = vFILTER + "CONST_CONS_P ,";
                    vFILTER = vFILTER + "CONST_CONSUMO ,";
                    vFILTER = vFILTER + "CONST_DEMANDA ,";
                    vFILTER = vFILTER + "CONST_DEMANDA_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH ,";
                    vFILTER = vFILTER + "CONST_KVARH_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH_P ,";
                    vFILTER = vFILTER + "CONST_RESERVADO ,";
                    vFILTER = vFILTER + "CONSTKVFP ,";
                    vFILTER = vFILTER + "CONSTKVP ,";
                    vFILTER = vFILTER + "DATA_CONTRATO_DEMANDA ,";
                    vFILTER = vFILTER + "DEM_CONTR_FP ,";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA ,";
                    vFILTER = vFILTER + "DEMALIDA ,";
                    vFILTER = vFILTER + "DEMANDA ,";
                    vFILTER = vFILTER + "DEMANDA_CONTR ,";
                    vFILTER = vFILTER + "DEMANDAANT ,";
                    vFILTER = vFILTER + "DMCR ,";
                    vFILTER = vFILTER + "DP12 ,";
                    vFILTER = vFILTER + "ELETR ,";
                    vFILTER = vFILTER + "ICMS_DEMANDA_LIDA ,";
                    vFILTER = vFILTER + "ICMS_DIFERIDO ,";
                    vFILTER = vFILTER + "ICMS_ISENTO_DEMANDA ,";
                    vFILTER = vFILTER + "KVAR ,";
                    vFILTER = vFILTER + "KVARHFPN ,";
                    vFILTER = vFILTER + "KVARHPN ,";
                    vFILTER = vFILTER + "KVARKN ,";
                    vFILTER = vFILTER + "KVARKNANT ,";
                    vFILTER = vFILTER + "LEITANT ,";
                    vFILTER = vFILTER + "LEITDEMA ,";
                    vFILTER = vFILTER + "LEITREATIVO ,";
                    vFILTER = vFILTER + "LIVREESPECIAL ,";
                    vFILTER = vFILTER + "MEDKW ,";
                    vFILTER = vFILTER + "CNAE ,";
                    vFILTER = vFILTER + "IDCCEE ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_P ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_I ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_FP ,";
                    vFILTER = vFILTER + "MICRO_GERACAO ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_P ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_I ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_FP ,";
                    vFILTER = vFILTER + "PARCIALMENTE_CATIVO ,";
                    vFILTER = vFILTER + "DEMANDA_CONTR_ANTERIOR ,";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA_ANTERIOR ,";
                    vFILTER = vFILTER + "DEM_CONTR_FP_ANTERIOR ,";
                    vFILTER = vFILTER + "PERIODO_TESTE ,";
                    vFILTER = vFILTER + "MEDKVARK ,";
                    vFILTER = vFILTER + "ANTRESERV ,";
                    vFILTER = vFILTER + "ARREDONDA_TEMP ,";
                    vFILTER = vFILTER + "ATURESERV ,";
                    vFILTER = vFILTER + "COD_TIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "DTAUTODEC ,";
                    vFILTER = vFILTER + "FLG_ALIQUOTADIF ,";
                    vFILTER = vFILTER + "ISENTOREATIVO ,";
                    vFILTER = vFILTER + "MEDIMEC ,";
                    vFILTER = vFILTER + "NOVAMECA ,";
                    vFILTER = vFILTER + "NUM_UNIVERSALIZACAO ,";
                    vFILTER = vFILTER + "OBSERVACAO ,";
                    vFILTER = vFILTER + "PAGTO_GOVERNO ,";
                    vFILTER = vFILTER + "RG_ORGAO ,";
                    vFILTER = vFILTER + "RG_UF ,";
                    vFILTER = vFILTER + "TIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "UNIVERSALIZACAO ,";
                    vFILTER = vFILTER + "VECTOPROXMES ,";
                    vFILTER = vFILTER + "VIP_COMERCIAL ,";
                    vFILTER = vFILTER + "VIP_TECNICO ,";
                    vFILTER = vFILTER + "IRRIGACAO_AQUICULTURA ,";
                    vFILTER = vFILTER + "ULTLEIT_IRRIGANTE ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES ,";
                    vFILTER = vFILTER + "LIVRE_VERDE ,";
                    vFILTER = vFILTER + "ULTLEIT_DESLIGAMENTO ,";
                    vFILTER = vFILTER + "LIVRE_LEITURA_CONSUMO ,";
                    vFILTER = vFILTER + "INI_PERIODO_TESTE ,";
                    vFILTER = vFILTER + "FIM_PERIODO_TESTE ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE ,";
                    vFILTER = vFILTER + "LATITUDE ,";
                    vFILTER = vFILTER + "LONGITUDE ,";
                    vFILTER = vFILTER + "IRR_HR_INI ,";
                    vFILTER = vFILTER + "IRR_HR_FIM ,";
                    vFILTER = vFILTER + "TARIFA_BRANCA ,";
                    vFILTER = vFILTER + "REATIVO ,";
                    vFILTER = vFILTER + "ISENTO_ICMS_TUSD ,";
                    vFILTER = vFILTER + "ENVIO_COB_JUDICIAL ,";
                    vFILTER = vFILTER + "BLOQUEA_SEG_VIA_FAT ,";
                    vFILTER = vFILTER + "BLOQUEA_RELIGACAO ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_KW_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KW_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_I ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KW_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KW_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_I ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_FP ,";
                    vFILTER = vFILTER + "KWH_RES_P ,";
                    vFILTER = vFILTER + "KWH_RES_I ,";
                    vFILTER = vFILTER + "KWH_RES_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_FP ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_P ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_I ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_FP ,";
                    vFILTER = vFILTER + "CONST_KWH_P ,";
                    vFILTER = vFILTER + "CONST_KWH_I ,";
                    vFILTER = vFILTER + "CONST_KWH_FP ,";
                    vFILTER = vFILTER + "CONST_KW_P ,";
                    vFILTER = vFILTER + "CONST_KW_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH_I ,";
                    vFILTER = vFILTER + "CONJUGE_FATURA ,";
                    vFILTER = vFILTER + "'' AS CADERNO ,";
                    vFILTER = vFILTER + "ROW_NUMBER() OVER (ORDER BY convert(concat(ZONA ,LIVRO ,CONTA),decimal)) AS SEQUENCIA  ";

                    vINNERJOIN = " ";

                    vORDERBY = " ";

                    vAND = vAND + "   AND ZONA  = ?ZONA ";
                    vAND = vAND + "   AND LIVRO = ?LIVRO ";
                    vAND = vAND + "   AND CONTA = ?CONTA ";

                    cmd = new MySqlCommand(this.QuerySelectFatwin_B);

                    cmd.Parameters.AddWithValue("?ZONA", objUCFaturamento.ZONA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?LIVRO", objUCFaturamento.LIVRO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CONTA", objUCFaturamento.CONTA.ToString().ToUpper());

                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable Select_25(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "grupo AS GRUPO_TAR, ";
                    vFILTER = vFILTER + "convert(concat(ZONA ,LIVRO ,CONTA),decimal) as ID, ";
                    vFILTER = vFILTER + "ZONA ,";
                    vFILTER = vFILTER + "LIVRO ,";
                    vFILTER = vFILTER + "CONTA ,";
                    vFILTER = vFILTER + "ROTA ,";
                    vFILTER = vFILTER + "INSTAL ,";
                    vFILTER = vFILTER + "ENTREGA ,";
                    vFILTER = vFILTER + "BANCO ,";
                    vFILTER = vFILTER + "AGENC ,";
                    vFILTER = vFILTER + "CC ,";
                    vFILTER = vFILTER + "GRUPO ,";
                    vFILTER = vFILTER + "CLAS ,";
                    vFILTER = vFILTER + "FASE ,";
                    vFILTER = vFILTER + "NUM ,";
                    vFILTER = vFILTER + "MARCA ,";
                    vFILTER = vFILTER + "DTAFABMEDIDOR ,";
                    vFILTER = vFILTER + "DTAINSTMEDIDOR ,";
                    vFILTER = vFILTER + "CONST ,";
                    vFILTER = vFILTER + "SITUACAO ,";
                    vFILTER = vFILTER + "ULTLEIT ,";
                    vFILTER = vFILTER + "ULTCONS ,";
                    vFILTER = vFILTER + "ILUM ,";
                    vFILTER = vFILTER + "LEIT ,";
                    vFILTER = vFILTER + "FINAL ,";
                    vFILTER = vFILTER + "MEDKVARH ,";
                    vFILTER = vFILTER + "ULTKVARH ,";
                    vFILTER = vFILTER + "CONSTFP ,";
                    vFILTER = vFILTER + "KVARH ,";
                    vFILTER = vFILTER + "CICE ,";
                    vFILTER = vFILTER + "DATA_LIGACAO ,";
                    vFILTER = vFILTER + "DATA_RELIGACAO ,";
                    vFILTER = vFILTER + "DATA_DESLIGAMENTO ,";
                    vFILTER = vFILTER + "DATA_ENTRADA ,";
                    vFILTER = vFILTER + "DATA_CORTE ,";
                    vFILTER = vFILTER + "TENSAO ,";
                    vFILTER = vFILTER + "CARGA ,";
                    vFILTER = vFILTER + "TRANSF ,";
                    vFILTER = vFILTER + "FASELIG ,";
                    vFILTER = vFILTER + "ELETROBRAS ,";
                    vFILTER = vFILTER + "FPFIXO ,";
                    vFILTER = vFILTER + "CODEND ,";
                    vFILTER = vFILTER + "END ,";
                    vFILTER = vFILTER + "COMPLEMENT ,";
                    vFILTER = vFILTER + "BAIRRO ,";
                    vFILTER = vFILTER + "CIDADE ,";
                    vFILTER = vFILTER + "UF ,";
                    vFILTER = vFILTER + "QUADRA ,";
                    vFILTER = vFILTER + "LOTE ,";
                    vFILTER = vFILTER + "NUMERO ,";
                    vFILTER = vFILTER + "CONS_ID ,";
                    vFILTER = vFILTER + "CONSLOC_ID ,";
                    vFILTER = vFILTER + "FLGRES ,";
                    vFILTER = vFILTER + "UNID_ID ,";
                    vFILTER = vFILTER + "ITENSESP ,";
                    vFILTER = vFILTER + "TIPOUC ,";
                    vFILTER = vFILTER + "CEP ,";
                    vFILTER = vFILTER + "TA ,";
                    vFILTER = vFILTER + "ARREDONDA ,";
                    vFILTER = vFILTER + "ARREDONDA_ANT ,";
                    vFILTER = vFILTER + "HISTORICO ,";
                    vFILTER = vFILTER + "DIAVENC ,";
                    vFILTER = vFILTER + "FORMULA_CIP ,";
                    vFILTER = vFILTER + "SOCIAL ,";
                    vFILTER = vFILTER + "IDCNAE ,";
                    vFILTER = vFILTER + "LOCALIDADE ,";
                    vFILTER = vFILTER + "CODEND_ENTREGA ,";
                    vFILTER = vFILTER + "END_ENTREGA ,";
                    vFILTER = vFILTER + "NUM_ENTREGA ,";
                    vFILTER = vFILTER + "BAI_ENTREGA ,";
                    vFILTER = vFILTER + "COMPL_ENTREGA ,";
                    vFILTER = vFILTER + "DIS_ENTREGA ,";
                    vFILTER = vFILTER + "CID_ENTREGA ,";
                    vFILTER = vFILTER + "UF_ENTREGA ,";
                    vFILTER = vFILTER + "QUA_ENTREGA ,";
                    vFILTER = vFILTER + "LOT_ENTREGA ,";
                    vFILTER = vFILTER + "CEP_ENTREGA ,";
                    vFILTER = vFILTER + "CPF_CNPJ ,";
                    vFILTER = vFILTER + "RG ,";
                    vFILTER = vFILTER + "INSC ,";
                    vFILTER = vFILTER + "PESSOA ,";
                    vFILTER = vFILTER + "NOME ,";
                    vFILTER = vFILTER + "CIRCUITO ,";
                    vFILTER = vFILTER + "DISJUNTOR ,";
                    vFILTER = vFILTER + "DISTRITO ,";
                    vFILTER = vFILTER + "AREA ,";
                    vFILTER = vFILTER + "LACRE ,";
                    vFILTER = vFILTER + "RESIDUO_CONSUMO ,";
                    vFILTER = vFILTER + "DECAP_NUM ,";
                    vFILTER = vFILTER + "DECAP_DATA ,";
                    vFILTER = vFILTER + "BANARREC ,";
                    vFILTER = vFILTER + "AP_SAUDE ,";
                    vFILTER = vFILTER + "LUZ_TODOS ,";
                    vFILTER = vFILTER + "RES694 ,";
                    vFILTER = vFILTER + "ISENTO ,";
                    vFILTER = vFILTER + "ALTA_TENSAO ,";
                    vFILTER = vFILTER + "TP_LIGACAO ,";
                    vFILTER = vFILTER + "SOLICITANTE ,";
                    vFILTER = vFILTER + "AGRUPA ,";
                    vFILTER = vFILTER + "AGRUPA_ZONA ,";
                    vFILTER = vFILTER + "AGRUPA_LIVRO ,";
                    vFILTER = vFILTER + "AGRUPA_CONTA ,";
                    vFILTER = vFILTER + "BXRENDA ,";
                    vFILTER = vFILTER + "REGIAO ,";
                    vFILTER = vFILTER + "SGDENVIO ,";
                    vFILTER = vFILTER + "BX0402 ,";
                    vFILTER = vFILTER + "PAGTO_DUVIDOSO ,";
                    vFILTER = vFILTER + "ID_BCO_ANT ,";
                    vFILTER = vFILTER + "ID_BCO_ATUAL ,";
                    vFILTER = vFILTER + "COMPROVANTE_RURAL ,";
                    vFILTER = vFILTER + "JUL2010 ,";
                    vFILTER = vFILTER + "IDTIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "MODELO ,";
                    vFILTER = vFILTER + "IDCONDUTOR ,";
                    vFILTER = vFILTER + "COMPRIMENTO_FIO ,";
                    vFILTER = vFILTER + "COD_TIPO_MEDICAO ,";
                    vFILTER = vFILTER + "TIPO_MEDICAO ,";
                    vFILTER = vFILTER + "IDTIPO_PADRAO_MEDICAO ,";
                    vFILTER = vFILTER + "TC_RELACAO_PRIMARIA ,";
                    vFILTER = vFILTER + "TC_RELACAO_SECUNDARIA ,";
                    vFILTER = vFILTER + "TP_RELACAO_PRIMARIA ,";
                    vFILTER = vFILTER + "TP_RELACAO_SECUNDARIA ,";
                    vFILTER = vFILTER + "IDALIMENTADOR ,";
                    vFILTER = vFILTER + "IDCORRENTE ,";
                    vFILTER = vFILTER + "ESTUFA ,";
                    vFILTER = vFILTER + "RAMAL ,";
                    vFILTER = vFILTER + "DATA_RAMAL ,";
                    vFILTER = vFILTER + "CLIENTEPENDENTE ,";
                    vFILTER = vFILTER + "FLG_AVISO_DEBITO ,";
                    vFILTER = vFILTER + "IDMEDIDOR ,";
                    vFILTER = vFILTER + "CAP ,";
                    vFILTER = vFILTER + "CFOP ,";
                    vFILTER = vFILTER + "DAP ,";
                    vFILTER = vFILTER + "ENCARGO ,";
                    vFILTER = vFILTER + "FLG_SAZONAL ,";
                    vFILTER = vFILTER + "FONE ,";
                    vFILTER = vFILTER + "MAIOR ,";
                    vFILTER = vFILTER + "MAXIMO ,";
                    vFILTER = vFILTER + "PERC ,";
                    vFILTER = vFILTER + "PERC_RETENCAO ,";
                    vFILTER = vFILTER + "QH ,";
                    vFILTER = vFILTER + "CONST_CONS_FP ,";
                    vFILTER = vFILTER + "CONST_CONS_P ,";
                    vFILTER = vFILTER + "CONST_CONSUMO ,";
                    vFILTER = vFILTER + "CONST_DEMANDA ,";
                    vFILTER = vFILTER + "CONST_DEMANDA_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH ,";
                    vFILTER = vFILTER + "CONST_KVARH_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH_P ,";
                    vFILTER = vFILTER + "CONST_RESERVADO ,";
                    vFILTER = vFILTER + "CONSTKVFP ,";
                    vFILTER = vFILTER + "CONSTKVP ,";
                    vFILTER = vFILTER + "DATA_CONTRATO_DEMANDA ,";
                    vFILTER = vFILTER + "DEM_CONTR_FP ,";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA ,";
                    vFILTER = vFILTER + "DEMALIDA ,";
                    vFILTER = vFILTER + "DEMANDA ,";
                    vFILTER = vFILTER + "DEMANDA_CONTR ,";
                    vFILTER = vFILTER + "DEMANDAANT ,";
                    vFILTER = vFILTER + "DMCR ,";
                    vFILTER = vFILTER + "DP12 ,";
                    vFILTER = vFILTER + "ELETR ,";
                    vFILTER = vFILTER + "ICMS_DEMANDA_LIDA ,";
                    vFILTER = vFILTER + "ICMS_DIFERIDO ,";
                    vFILTER = vFILTER + "ICMS_ISENTO_DEMANDA ,";
                    vFILTER = vFILTER + "KVAR ,";
                    vFILTER = vFILTER + "KVARHFPN ,";
                    vFILTER = vFILTER + "KVARHPN ,";
                    vFILTER = vFILTER + "KVARKN ,";
                    vFILTER = vFILTER + "KVARKNANT ,";
                    vFILTER = vFILTER + "LEITANT ,";
                    vFILTER = vFILTER + "LEITDEMA ,";
                    vFILTER = vFILTER + "LEITREATIVO ,";
                    vFILTER = vFILTER + "LIVREESPECIAL ,";
                    vFILTER = vFILTER + "MEDKW ,";
                    vFILTER = vFILTER + "CNAE ,";
                    vFILTER = vFILTER + "IDCCEE ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_P ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_I ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_FP ,";
                    vFILTER = vFILTER + "MICRO_GERACAO ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_P ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_I ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_FP ,";
                    vFILTER = vFILTER + "PARCIALMENTE_CATIVO ,";
                    vFILTER = vFILTER + "DEMANDA_CONTR_ANTERIOR ,";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA_ANTERIOR ,";
                    vFILTER = vFILTER + "DEM_CONTR_FP_ANTERIOR ,";
                    vFILTER = vFILTER + "PERIODO_TESTE ,";
                    vFILTER = vFILTER + "MEDKVARK ,";
                    vFILTER = vFILTER + "ANTRESERV ,";
                    vFILTER = vFILTER + "ARREDONDA_TEMP ,";
                    vFILTER = vFILTER + "ATURESERV ,";
                    vFILTER = vFILTER + "COD_TIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "DTAUTODEC ,";
                    vFILTER = vFILTER + "FLG_ALIQUOTADIF ,";
                    vFILTER = vFILTER + "ISENTOREATIVO ,";
                    vFILTER = vFILTER + "MEDIMEC ,";
                    vFILTER = vFILTER + "NOVAMECA ,";
                    vFILTER = vFILTER + "NUM_UNIVERSALIZACAO ,";
                    vFILTER = vFILTER + "OBSERVACAO ,";
                    vFILTER = vFILTER + "PAGTO_GOVERNO ,";
                    vFILTER = vFILTER + "RG_ORGAO ,";
                    vFILTER = vFILTER + "RG_UF ,";
                    vFILTER = vFILTER + "TIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "UNIVERSALIZACAO ,";
                    vFILTER = vFILTER + "VECTOPROXMES ,";
                    vFILTER = vFILTER + "VIP_COMERCIAL ,";
                    vFILTER = vFILTER + "VIP_TECNICO ,";
                    vFILTER = vFILTER + "IRRIGACAO_AQUICULTURA ,";
                    vFILTER = vFILTER + "ULTLEIT_IRRIGANTE ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES ,";
                    vFILTER = vFILTER + "LIVRE_VERDE ,";
                    vFILTER = vFILTER + "ULTLEIT_DESLIGAMENTO ,";
                    vFILTER = vFILTER + "LIVRE_LEITURA_CONSUMO ,";
                    vFILTER = vFILTER + "INI_PERIODO_TESTE ,";
                    vFILTER = vFILTER + "FIM_PERIODO_TESTE ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE ,";
                    vFILTER = vFILTER + "LATITUDE ,";
                    vFILTER = vFILTER + "LONGITUDE ,";
                    vFILTER = vFILTER + "IRR_HR_INI ,";
                    vFILTER = vFILTER + "IRR_HR_FIM ,";
                    vFILTER = vFILTER + "TARIFA_BRANCA ,";
                    vFILTER = vFILTER + "REATIVO ,";
                    vFILTER = vFILTER + "ISENTO_ICMS_TUSD ,";
                    vFILTER = vFILTER + "ENVIO_COB_JUDICIAL ,";
                    vFILTER = vFILTER + "BLOQUEA_SEG_VIA_FAT ,";
                    vFILTER = vFILTER + "BLOQUEA_RELIGACAO ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_KW_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KW_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_I ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KW_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KW_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_I ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_FP ,";
                    vFILTER = vFILTER + "KWH_RES_P ,";
                    vFILTER = vFILTER + "KWH_RES_I ,";
                    vFILTER = vFILTER + "KWH_RES_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_FP ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_P ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_I ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_FP ,";
                    vFILTER = vFILTER + "CONST_KWH_P ,";
                    vFILTER = vFILTER + "CONST_KWH_I ,";
                    vFILTER = vFILTER + "CONST_KWH_FP ,";
                    vFILTER = vFILTER + "CONST_KW_P ,";
                    vFILTER = vFILTER + "CONST_KW_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH_I ,";
                    vFILTER = vFILTER + "CONJUGE_FATURA ,";
                    vFILTER = vFILTER + "'' AS CADERNO ,";
                    vFILTER = vFILTER + "ROW_NUMBER() OVER (ORDER BY convert(concat(ZONA ,LIVRO ,CONTA),decimal)) AS SEQUENCIA  ";

                    vINNERJOIN = " ";

                    vORDERBY = " ";

                    vAND = vAND + "   AND ZONA  = ?ZONA ";
                    vAND = vAND + "   AND LIVRO = ?LIVRO ";
                    vAND = vAND + "   AND CONTA = ?CONTA ";

                    cmd = new MySqlCommand(this.QuerySelectFatwin_A);

                    cmd.Parameters.AddWithValue("?ZONA", objUCFaturamento.ZONA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?LIVRO", objUCFaturamento.LIVRO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CONTA", objUCFaturamento.CONTA.ToString().ToUpper());

                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable Select_EnviaAPP(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "GRUPO_TAR, ";
                    vFILTER = vFILTER + "ID, ";
                    vFILTER = vFILTER + "ZONA ,";
                    vFILTER = vFILTER + "LIVRO ,";
                    vFILTER = vFILTER + "CONTA ,";
                    vFILTER = vFILTER + "ROTA ,";
                    vFILTER = vFILTER + "INSTAL ,";
                    vFILTER = vFILTER + "ENTREGA ,";
                    vFILTER = vFILTER + "BANCO ,";
                    vFILTER = vFILTER + "AGENC ,";
                    vFILTER = vFILTER + "CC ,";
                    vFILTER = vFILTER + "GRUPO ,";
                    vFILTER = vFILTER + "CLAS ,";
                    vFILTER = vFILTER + "FASE ,";
                    vFILTER = vFILTER + "NUM ,";
                    vFILTER = vFILTER + "MARCA ,";
                    vFILTER = vFILTER + "DTAFABMEDIDOR ,";
                    vFILTER = vFILTER + "DTAINSTMEDIDOR ,";
                    vFILTER = vFILTER + "CONST ,";
                    vFILTER = vFILTER + "SITUACAO ,";
                    vFILTER = vFILTER + "ULTLEIT ,";
                    vFILTER = vFILTER + "ULTCONS ,";
                    vFILTER = vFILTER + "ILUM ,";
                    vFILTER = vFILTER + "LEIT ,";
                    vFILTER = vFILTER + "FINAL ,";
                    vFILTER = vFILTER + "MEDKVARH ,";
                    vFILTER = vFILTER + "ULTKVARH ,";
                    vFILTER = vFILTER + "CONSTFP ,";
                    vFILTER = vFILTER + "KVARH ,";
                    vFILTER = vFILTER + "CICE ,";
                    vFILTER = vFILTER + "DATA_LIGACAO ,";
                    vFILTER = vFILTER + "DATA_RELIGACAO ,";
                    vFILTER = vFILTER + "DATA_DESLIGAMENTO ,";
                    vFILTER = vFILTER + "DATA_ENTRADA ,";
                    vFILTER = vFILTER + "DATA_CORTE ,";
                    vFILTER = vFILTER + "TENSAO ,";
                    vFILTER = vFILTER + "CARGA ,";
                    vFILTER = vFILTER + "TRANSF ,";
                    vFILTER = vFILTER + "FASELIG ,";
                    vFILTER = vFILTER + "ELETROBRAS ,";
                    vFILTER = vFILTER + "FPFIXO ,";
                    vFILTER = vFILTER + "CODEND ,";
                    vFILTER = vFILTER + "END ,";
                    vFILTER = vFILTER + "COMPLEMENT ,";
                    vFILTER = vFILTER + "BAIRRO ,";
                    vFILTER = vFILTER + "CIDADE ,";
                    vFILTER = vFILTER + "UF ,";
                    vFILTER = vFILTER + "QUADRA ,";
                    vFILTER = vFILTER + "LOTE ,";
                    vFILTER = vFILTER + "NUMERO ,";
                    vFILTER = vFILTER + "CONS_ID ,";
                    vFILTER = vFILTER + "CONSLOC_ID ,";
                    vFILTER = vFILTER + "FLGRES ,";
                    vFILTER = vFILTER + "UNID_ID ,";
                    vFILTER = vFILTER + "ITENSESP ,";
                    vFILTER = vFILTER + "TIPOUC ,";
                    vFILTER = vFILTER + "CEP ,";
                    vFILTER = vFILTER + "TA ,";
                    vFILTER = vFILTER + "ARREDONDA ,";
                    vFILTER = vFILTER + "ARREDONDA_ANT ,";
                    vFILTER = vFILTER + "HISTORICO ,";
                    vFILTER = vFILTER + "DIAVENC ,";
                    vFILTER = vFILTER + "FORMULA_CIP ,";
                    vFILTER = vFILTER + "SOCIAL ,";
                    vFILTER = vFILTER + "IDCNAE ,";
                    vFILTER = vFILTER + "LOCALIDADE ,";
                    vFILTER = vFILTER + "CODEND_ENTREGA ,";
                    vFILTER = vFILTER + "END_ENTREGA ,";
                    vFILTER = vFILTER + "NUM_ENTREGA ,";
                    vFILTER = vFILTER + "BAI_ENTREGA ,";
                    vFILTER = vFILTER + "COMPL_ENTREGA ,";
                    vFILTER = vFILTER + "DIS_ENTREGA ,";
                    vFILTER = vFILTER + "CID_ENTREGA ,";
                    vFILTER = vFILTER + "UF_ENTREGA ,";
                    vFILTER = vFILTER + "QUA_ENTREGA ,";
                    vFILTER = vFILTER + "LOT_ENTREGA ,";
                    vFILTER = vFILTER + "CEP_ENTREGA ,";
                    vFILTER = vFILTER + "CPF_CNPJ ,";
                    vFILTER = vFILTER + "RG ,";
                    vFILTER = vFILTER + "INSC ,";
                    vFILTER = vFILTER + "PESSOA ,";
                    vFILTER = vFILTER + "NOME ,";
                    vFILTER = vFILTER + "CIRCUITO ,";
                    vFILTER = vFILTER + "DISJUNTOR ,";
                    vFILTER = vFILTER + "DISTRITO ,";
                    vFILTER = vFILTER + "AREA ,";
                    vFILTER = vFILTER + "LACRE ,";
                    vFILTER = vFILTER + "RESIDUO_CONSUMO ,";
                    vFILTER = vFILTER + "DECAP_NUM ,";
                    vFILTER = vFILTER + "DECAP_DATA ,";
                    vFILTER = vFILTER + "BANARREC ,";
                    vFILTER = vFILTER + "AP_SAUDE ,";
                    vFILTER = vFILTER + "LUZ_TODOS ,";
                    vFILTER = vFILTER + "RES694 ,";
                    vFILTER = vFILTER + "ISENTO ,";
                    vFILTER = vFILTER + "ALTA_TENSAO ,";
                    vFILTER = vFILTER + "TP_LIGACAO ,";
                    vFILTER = vFILTER + "SOLICITANTE ,";
                    vFILTER = vFILTER + "AGRUPA ,";
                    vFILTER = vFILTER + "AGRUPA_ZONA ,";
                    vFILTER = vFILTER + "AGRUPA_LIVRO ,";
                    vFILTER = vFILTER + "AGRUPA_CONTA ,";
                    vFILTER = vFILTER + "BXRENDA ,";
                    vFILTER = vFILTER + "REGIAO ,";
                    vFILTER = vFILTER + "SGDENVIO ,";
                    vFILTER = vFILTER + "BX0402 ,";
                    vFILTER = vFILTER + "PAGTO_DUVIDOSO ,";
                    vFILTER = vFILTER + "ID_BCO_ANT ,";
                    vFILTER = vFILTER + "ID_BCO_ATUAL ,";
                    vFILTER = vFILTER + "COMPROVANTE_RURAL ,";
                    vFILTER = vFILTER + "JUL2010 ,";
                    vFILTER = vFILTER + "IDTIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "MODELO ,";
                    vFILTER = vFILTER + "IDCONDUTOR ,";
                    vFILTER = vFILTER + "COMPRIMENTO_FIO ,";
                    vFILTER = vFILTER + "COD_TIPO_MEDICAO ,";
                    vFILTER = vFILTER + "TIPO_MEDICAO ,";
                    vFILTER = vFILTER + "IDTIPO_PADRAO_MEDICAO ,";
                    vFILTER = vFILTER + "TC_RELACAO_PRIMARIA ,";
                    vFILTER = vFILTER + "TC_RELACAO_SECUNDARIA ,";
                    vFILTER = vFILTER + "TP_RELACAO_PRIMARIA ,";
                    vFILTER = vFILTER + "TP_RELACAO_SECUNDARIA ,";
                    vFILTER = vFILTER + "IDALIMENTADOR ,";
                    vFILTER = vFILTER + "IDCORRENTE ,";
                    vFILTER = vFILTER + "ESTUFA ,";
                    vFILTER = vFILTER + "RAMAL ,";
                    vFILTER = vFILTER + "DATA_RAMAL ,";
                    vFILTER = vFILTER + "CLIENTEPENDENTE ,";
                    vFILTER = vFILTER + "FLG_AVISO_DEBITO ,";
                    vFILTER = vFILTER + "IDMEDIDOR ,";
                    vFILTER = vFILTER + "CAP ,";
                    vFILTER = vFILTER + "CFOP ,";
                    vFILTER = vFILTER + "DAP ,";
                    vFILTER = vFILTER + "ENCARGO ,";
                    vFILTER = vFILTER + "FLG_SAZONAL ,";
                    vFILTER = vFILTER + "FONE ,";
                    vFILTER = vFILTER + "MAIOR ,";
                    vFILTER = vFILTER + "MAXIMO ,";
                    vFILTER = vFILTER + "PERC ,";
                    vFILTER = vFILTER + "PERC_RETENCAO ,";
                    vFILTER = vFILTER + "QH ,";
                    vFILTER = vFILTER + "CONST_CONS_FP ,";
                    vFILTER = vFILTER + "CONST_CONS_P ,";
                    vFILTER = vFILTER + "CONST_CONSUMO ,";
                    vFILTER = vFILTER + "CONST_DEMANDA ,";
                    vFILTER = vFILTER + "CONST_DEMANDA_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH ,";
                    vFILTER = vFILTER + "CONST_KVARH_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH_P ,";
                    vFILTER = vFILTER + "CONST_RESERVADO ,";
                    vFILTER = vFILTER + "CONSTKVFP ,";
                    vFILTER = vFILTER + "CONSTKVP ,";
                    vFILTER = vFILTER + "DATA_CONTRATO_DEMANDA ,";
                    vFILTER = vFILTER + "DEM_CONTR_FP ,";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA ,";
                    vFILTER = vFILTER + "DEMALIDA ,";
                    vFILTER = vFILTER + "DEMANDA ,";
                    vFILTER = vFILTER + "DEMANDA_CONTR ,";
                    vFILTER = vFILTER + "DEMANDAANT ,";
                    vFILTER = vFILTER + "DMCR ,";
                    vFILTER = vFILTER + "DP12 ,";
                    vFILTER = vFILTER + "ELETR ,";
                    vFILTER = vFILTER + "ICMS_DEMANDA_LIDA ,";
                    vFILTER = vFILTER + "ICMS_DIFERIDO ,";
                    vFILTER = vFILTER + "ICMS_ISENTO_DEMANDA ,";
                    vFILTER = vFILTER + "KVAR ,";
                    vFILTER = vFILTER + "KVARHFPN ,";
                    vFILTER = vFILTER + "KVARHPN ,";
                    vFILTER = vFILTER + "KVARKN ,";
                    vFILTER = vFILTER + "KVARKNANT ,";
                    vFILTER = vFILTER + "LEITANT ,";
                    vFILTER = vFILTER + "LEITDEMA ,";
                    vFILTER = vFILTER + "LEITREATIVO ,";
                    vFILTER = vFILTER + "LIVREESPECIAL ,";
                    vFILTER = vFILTER + "MEDKW ,";
                    vFILTER = vFILTER + "CNAE ,";
                    vFILTER = vFILTER + "IDCCEE ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_P ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_I ,";
                    vFILTER = vFILTER + "ULTLEIT_REVERSO_FP ,";
                    vFILTER = vFILTER + "MICRO_GERACAO ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_P ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_I ,";
                    vFILTER = vFILTER + "KWH_REVERSO_RES_FP ,";
                    vFILTER = vFILTER + "PARCIALMENTE_CATIVO ,";
                    vFILTER = vFILTER + "DEMANDA_CONTR_ANTERIOR ,";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA_ANTERIOR ,";
                    vFILTER = vFILTER + "DEM_CONTR_FP_ANTERIOR ,";
                    vFILTER = vFILTER + "PERIODO_TESTE ,";
                    vFILTER = vFILTER + "MEDKVARK ,";
                    vFILTER = vFILTER + "ANTRESERV ,";
                    vFILTER = vFILTER + "ARREDONDA_TEMP ,";
                    vFILTER = vFILTER + "ATURESERV ,";
                    vFILTER = vFILTER + "COD_TIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "DTAUTODEC ,";
                    vFILTER = vFILTER + "FLG_ALIQUOTADIF ,";
                    vFILTER = vFILTER + "ISENTOREATIVO ,";
                    vFILTER = vFILTER + "MEDIMEC ,";
                    vFILTER = vFILTER + "NOVAMECA ,";
                    vFILTER = vFILTER + "NUM_UNIVERSALIZACAO ,";
                    vFILTER = vFILTER + "OBSERVACAO ,";
                    vFILTER = vFILTER + "PAGTO_GOVERNO ,";
                    vFILTER = vFILTER + "RG_ORGAO ,";
                    vFILTER = vFILTER + "RG_UF ,";
                    vFILTER = vFILTER + "TIPO_MEDIDOR ,";
                    vFILTER = vFILTER + "UNIVERSALIZACAO ,";
                    vFILTER = vFILTER + "VECTOPROXMES ,";
                    vFILTER = vFILTER + "VIP_COMERCIAL ,";
                    vFILTER = vFILTER + "VIP_TECNICO ,";
                    vFILTER = vFILTER + "IRRIGACAO_AQUICULTURA ,";
                    vFILTER = vFILTER + "ULTLEIT_IRRIGANTE ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES ,";
                    vFILTER = vFILTER + "LIVRE_VERDE ,";
                    vFILTER = vFILTER + "ULTLEIT_DESLIGAMENTO ,";
                    vFILTER = vFILTER + "LIVRE_LEITURA_CONSUMO ,";
                    vFILTER = vFILTER + "INI_PERIODO_TESTE ,";
                    vFILTER = vFILTER + "FIM_PERIODO_TESTE ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE ,";
                    vFILTER = vFILTER + "LATITUDE ,";
                    vFILTER = vFILTER + "LONGITUDE ,";
                    vFILTER = vFILTER + "IRR_HR_INI ,";
                    vFILTER = vFILTER + "IRR_HR_FIM ,";
                    vFILTER = vFILTER + "TARIFA_BRANCA ,";
                    vFILTER = vFILTER + "REATIVO ,";
                    vFILTER = vFILTER + "ISENTO_ICMS_TUSD ,";
                    vFILTER = vFILTER + "ENVIO_COB_JUDICIAL ,";
                    vFILTER = vFILTER + "BLOQUEA_SEG_VIA_FAT ,";
                    vFILTER = vFILTER + "BLOQUEA_RELIGACAO ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_KWH_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_KW_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KW_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_KVARH_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_I ,";
                    vFILTER = vFILTER + "ULT_CONS_KWH_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KW_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KW_FP ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_P ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_I ,";
                    vFILTER = vFILTER + "ULT_CONS_KVARH_FP ,";
                    vFILTER = vFILTER + "KWH_RES_P ,";
                    vFILTER = vFILTER + "KWH_RES_I ,";
                    vFILTER = vFILTER + "KWH_RES_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_FP ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_P ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_I ,";
                    vFILTER = vFILTER + "KWH_IRRIGANTE_RES_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_FP ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_P ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_I ,";
                    vFILTER = vFILTER + "ULT_LEIT_CORTE_FP ,";
                    vFILTER = vFILTER + "CONST_KWH_P ,";
                    vFILTER = vFILTER + "CONST_KWH_I ,";
                    vFILTER = vFILTER + "CONST_KWH_FP ,";
                    vFILTER = vFILTER + "CONST_KW_P ,";
                    vFILTER = vFILTER + "CONST_KW_FP ,";
                    vFILTER = vFILTER + "CONST_KVARH_I ,";
                    vFILTER = vFILTER + "CONJUGE_FATURA ,";
                    vFILTER = vFILTER + "CADERNO ,";
                    vFILTER = vFILTER + "SEQUENCIA  ";

                    vINNERJOIN = " ";

                    vORDERBY = " "; 

                    vAND = " ";


                    if (!String.IsNullOrEmpty(objUCFaturamento.SITUACAO))
                    {
                        vAND = vAND + " AND SITUACAO IN (" + objUCFaturamento.SITUACAO + ") ";
                    }

                    if (!String.IsNullOrEmpty(objUCFaturamento.ROTA))
                    {
                        vAND = vAND + " AND LPAD(LEFT(ROTA, 4), 4,'0') IN (" + objUCFaturamento.ROTA + ") ";
                    }


                    cmd = new MySqlCommand(this.QuerySelect);

                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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


        public DataTable SelectOthersTables_24(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "UC_FATURAMENTO.CONS_ID, ";
                    vFILTER = vFILTER + "UC_FATURAMENTO.ENVIO_EMAIL_FATURA, ";
                    vFILTER = vFILTER + "IFNULL(UC_FATURAMENTO.NOME,CONSUM.NOME) NOMEUC  ";

                    vINNERJOIN = vINNERJOIN + "LEFT JOIN CONSUM ON(UC_FATURAMENTO.ZONA  = ?ZONA ";
                    vINNERJOIN = vINNERJOIN + "AND    UC_FATURAMENTO.LIVRO = ?LIVRO ";
                    vINNERJOIN = vINNERJOIN + "AND    UC_FATURAMENTO.CONTA = ?CONTA ";
                    vINNERJOIN = vINNERJOIN + "AND    UC_FATURAMENTO.CONS_ID = CONSUM.CONSREG) ";
                    //vINNERJOIN = vINNERJOIN + "AND    UC_FATURAMENTO.ID = ?UNID_ID) ";
                    //vINNERJOIN = vINNERJOIN + "LEFT JOIN UC_FATURAMENTO ON(UC_FATURAMENTO.ZONA  = ?ZONA ";
                    //vINNERJOIN = vINNERJOIN + "AND   UC_FATURAMENTO.LIVRO = ?LIVRO ";
                    //vINNERJOIN = vINNERJOIN + "AND   UC_FATURAMENTO.CONTA = ?CONTA ";
                    //vINNERJOIN = vINNERJOIN + "AND   UC_FATURAMENTO.CONS_ID = CONSUM.CONSREG ";
                    //vINNERJOIN = vINNERJOIN + "AND   UC_FATURAMENTO.ID = ?UNID_ID) ";

                    vORDERBY = " ";

                    vAND = vAND + "AND UC_FATURAMENTO.CONS_ID = ?CONS_ID ";


                    cmd = new MySqlCommand(this.QuerySelect);


                    cmd.Parameters.AddWithValue("?ZONA", objUCFaturamento.ZONA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?LIVRO", objUCFaturamento.LIVRO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CONTA", objUCFaturamento.CONTA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?UNID_ID", Convert.ToInt64(objUCFaturamento.UNID_ID.ToString().ToUpper()));
                    cmd.Parameters.AddWithValue("?CONS_ID", Convert.ToInt64(objUCFaturamento.CONS_ID.ToString().ToUpper()));




                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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









        public DataTable SelectOthersTables(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "ID, ";
                    vFILTER = vFILTER + "CONS_ID, ";
                    vFILTER = vFILTER + "UNID_ID, ";
                    vFILTER = vFILTER + "ZONA, ";
                    vFILTER = vFILTER + "LIVRO, ";
                    vFILTER = vFILTER + "CONTA ";

                    vINNERJOIN = " ";

                    vORDERBY = "ORDER BY NOME ASC ";

                    vAND = vAND + "AND CODEND =  ?CODEND ";

                    cmd = new MySqlCommand(this.QuerySelect);

                    cmd.Parameters.AddWithValue("?CODEND", objUCFaturamento.CODEND.ToString().ToUpper());

                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable SelectOthersTables_1(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "ID, ";
                    vFILTER = vFILTER + "CONS_ID, ";
                    vFILTER = vFILTER + "UNID_ID, ";
                    vFILTER = vFILTER + "ZONA, ";
                    vFILTER = vFILTER + "LIVRO, ";
                    vFILTER = vFILTER + "CONTA ";

                    vINNERJOIN = " ";

                    vORDERBY = "ORDER BY NOME ASC ";

                    vAND = vAND + "AND  CODEND_ENTREGA =  ?CODEND_ENTREGA ";


                    cmd = new MySqlCommand(this.QuerySelect);

                    cmd.Parameters.AddWithValue("?CODEND_ENTREGA", objUCFaturamento.CODEND_ENTREGA.ToString().ToUpper());

                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable SelectOthersTables_2(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "ID, ";
                    vFILTER = vFILTER + "CONS_ID, ";
                    vFILTER = vFILTER + "UNID_ID, ";
                    vFILTER = vFILTER + "NOME, ";
                    vFILTER = vFILTER + "TA ";

                    vINNERJOIN = " ";

                    vORDERBY = " ";

                    vAND = vAND + "AND ZONA  = ?ZONA ";
                    vAND = vAND + "AND LIVRO = ?LIVRO ";
                    vAND = vAND + "AND CONTA = ?CONTA ";

                    cmd = new MySqlCommand(this.QuerySelect);

                    cmd.Parameters.AddWithValue("?ZONA", objUCFaturamento.ZONA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?LIVRO", objUCFaturamento.LIVRO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CONTA", objUCFaturamento.CONTA.ToString().ToUpper());

                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable SelectOthersTables_3(entidadeUCFaturamento objUCFaturamento)
        {
            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))
                {
                    if (objUCFaturamento.GRUPO == "A")
                    { vFILTER = vFILTER + "'A'  AS GRUPO, "; }
                    else if (objUCFaturamento.GRUPO == "B")
                    { vFILTER = vFILTER + "'B'  AS GRUPO, "; }
                    else
                    { vFILTER = vFILTER + "LEFT(GRUPO, 1) AS GRUPO, "; }

                    vFILTER = vFILTER + "GRUPO_TAR, ";
                    vFILTER = vFILTER + "ID, ";
                    vFILTER = vFILTER + "UNID_ID, ";
                    vFILTER = vFILTER + "CONS_ID, ";
                    vFILTER = vFILTER + "UC.ZONA, ";
                    vFILTER = vFILTER + "UC.LIVRO, ";
                    vFILTER = vFILTER + "UC.CONTA, ";
                    vFILTER = vFILTER + "ROTA, ";

                    if (objUCFaturamento.GRUPO == "A")
                    { vFILTER = vFILTER + "ELETR AS MEDIDOR, "; }
                    else if (objUCFaturamento.GRUPO == "B")
                    { vFILTER = vFILTER + "NUM AS MEDIDOR, "; }
                    else
                    { vFILTER = vFILTER + "CASE WHEN NUM <> '' THEN NUM WHEN ELETR <> '' THEN ELETR WHEN NUM <> 0 THEN ELETR END  AS MEDIDOR , "; }

                    vFILTER = vFILTER + "CPF_CNPJ, ";
                    vFILTER = vFILTER + "RG, ";
                    vFILTER = vFILTER + "INSC, ";
                    vFILTER = vFILTER + "NOME, ";
                    vFILTER = vFILTER + "UF, ";
                    vFILTER = vFILTER + "CIDADE, ";
                    vFILTER = vFILTER + "DISTRITO, ";
                    vFILTER = vFILTER + "CEP, ";
                    vFILTER = vFILTER + "END, ";
                    vFILTER = vFILTER + "NUMERO, ";
                    vFILTER = vFILTER + "COMPLEMENT, ";
                    vFILTER = vFILTER + "QUADRA, ";
                    vFILTER = vFILTER + "LOTE, ";
                    vFILTER = vFILTER + "BAIRRO, ";
                    vFILTER = vFILTER + "SITUACAO, ";
                    vFILTER = vFILTER + "BANCO, ";
                    vFILTER = vFILTER + "AGENC, ";
                    vFILTER = vFILTER + "CC, \n";

                    vFILTER = vFILTER + "TARIFA_BRANCA, \n";
                    vFILTER = vFILTER + "MICRO_GERACAO, IRRIGACAO_AQUICULTURA, \n";
                    vFILTER = vFILTER + "IF(DIST.MICROGERADOR_DISTRIBUIDO > 0, 1, 0) AS MICROGERADOR_DISTRIBUIDO, \n";
                    vFILTER = vFILTER + "IF(REC.MICROGERADOR_DISTRIBUIDO > 0, 1, 0) AS RECEBE_MICROGERACAO \n";


                    vINNERJOIN = " ";
                    vINNERJOIN += " UC \n";
                    vINNERJOIN += " LEFT JOIN CLASSE CLS ON CLS.CODIGO = UC.CLAS \n";
                    vINNERJOIN += " LEFT JOIN(SELECT ZONA, LIVRO, CONTA, COUNT(*) AS MICROGERADOR_DISTRIBUIDO FROM microgeracao_distribuida GROUP BY ZONA, LIVRO, CONTA) AS DIST ON DIST.ZONA = UC.ZONA AND DIST.LIVRO = UC.LIVRO AND DIST.CONTA = UC.CONTA \n";
                    vINNERJOIN += " LEFT JOIN(SELECT ZONA_D, LIVRO_D, CONTA_D, COUNT(*) AS MICROGERADOR_DISTRIBUIDO FROM microgeracao_distribuida GROUP BY ZONA_D, LIVRO_D, CONTA_D) AS REC ON REC.ZONA_D = UC.ZONA AND REC.LIVRO_D = UC.LIVRO AND REC.CONTA_D = UC.CONTA \n";

                    vORDERBY = " ";

                    if (objUCFaturamento.ZONA != string.Empty && objUCFaturamento.ZONA != "000")
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND UC.ZONA = ?ZONA "; }
                        else
                        { vAND = "AND UC.ZONA = ?ZONA "; }
                    }
                  
                    if (objUCFaturamento.LIVRO != string.Empty && objUCFaturamento.LIVRO != "00")
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND UC.LIVRO = ?LIVRO "; }
                        else
                        { vAND = "AND UC.LIVRO = ?LIVRO "; }
                    }             

                    if (objUCFaturamento.CONTA != string.Empty && objUCFaturamento.CONTA != "000000")
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND UC.CONTA = ?CONTA "; }
                        else
                        { vAND = "AND UC.CONTA = ?CONTA "; }

                    }                   

                    if (objUCFaturamento.ZONA != string.Empty && objUCFaturamento.LIVRO != string.Empty && objUCFaturamento.CONTA != string.Empty)
                    { vORDERBY = vORDERBY + " ORDER BY UC.ZONA ASC, UC.LIVRO ASC, UC.CONTA ASC  "; }

                    if (objUCFaturamento.ID != 0)
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND ID = ?ID "; }
                        else
                        { vAND = "AND ID = ?ID "; }

                        vORDERBY = vORDERBY + " ORDER BY ID ASC ";
                    }               

                    if (objUCFaturamento.NOME != string.Empty)
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND NOME LIKE ?NOME "; }
                        else
                        { vAND = "AND NOME LIKE ?NOME "; }
                        vORDERBY = vORDERBY + " ORDER BY NOME ASC ";
                    }
                   
                    if (objUCFaturamento.GRUPO == "A")
                    {
                        if (objUCFaturamento.ELETR != string.Empty)
                        {
                            if (vAND != String.Empty)
                            { vAND = vAND + "AND ELETR LIKE ?ELETR "; }
                            else
                            { vAND = "AND ELETR LIKE ?ELETR "; }

                            vORDERBY = vORDERBY + " ORDER BY MEDIDOR ASC ";
                        }                        
                    }
                    else if (objUCFaturamento.GRUPO == "B")
                    {
                        if (objUCFaturamento.NUM != string.Empty)
                        {
                            if (vAND != String.Empty)
                            { vAND = vAND + "AND NUM LIKE ?NUM "; }
                            else
                            { vAND = "AND NUM LIKE ?NUM "; }

                            vORDERBY = vORDERBY + " ORDER BY MEDIDOR ASC ";
                        }                     
                    }
                    else
                    {

                        if (objUCFaturamento.ELETR != string.Empty)
                        {
                            if (vAND != String.Empty)
                            { vAND = vAND + "AND ELETR LIKE ?ELETR "; }
                            else
                            { vAND = "AND ELETR LIKE ?ELETR "; }
                            vORDERBY = vORDERBY + " ORDER BY MEDIDOR ASC ";
                        }                     

                        if (objUCFaturamento.NUM != string.Empty)
                        {
                            if (vAND != String.Empty)
                            { vAND = vAND + "AND NUM LIKE ?NUM "; }
                            else
                            { vAND = "AND NUM LIKE ?NUM "; }
                            vORDERBY = vORDERBY + " ORDER BY MEDIDOR ASC ";
                        }                        
                    }

                    if (objUCFaturamento.CPF_CNPJ != string.Empty)
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND CPF_CNPJ LIKE ?CPF_CNPJ "; }
                        else
                        { vAND = "AND CPF_CNPJ LIKE ?CPF_CNPJ "; }
                        vORDERBY = vORDERBY + " ORDER BY CPF_CNPJ ASC ";
                    }
                    
                    if (objUCFaturamento.RG != string.Empty)
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND RG LIKE ?RG "; }
                        else
                        { vAND = "AND RG LIKE ?RG "; }
                        vORDERBY = vORDERBY + " ORDER BY RG ASC ";
                    }

                    if (objUCFaturamento.INSC != string.Empty)
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND INSC LIKE ?INSC "; }
                        else
                        { vAND = "AND INSC LIKE ?INSC "; }
                        vORDERBY = vORDERBY + " ORDER BY INSC ASC ";
                    }
                    
                    if (objUCFaturamento.DIS_ENTREGA != string.Empty)
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND CONCAT(CIDADE, DISTRITO, BAIRRO, END, NUMERO, QUADRA, LOTE) LIKE ?DIS_ENTREGA "; }
                        else
                        { vAND = "AND CONCAT(CIDADE, DISTRITO, BAIRRO, END, NUMERO, QUADRA, LOTE) LIKE ?DIS_ENTREGA "; }

                        vORDERBY = vORDERBY + " ORDER BY CIDADE ASC, DISTRITO ASC, BAIRRO ASC, END ASC, NUMERO ASC, QUADRA ASC, LOTE ASC ";

                    }
                    
                    if (objUCFaturamento.END != string.Empty)
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND END LIKE ?END "; }
                        else
                        { vAND = "AND END LIKE ?END "; }
                        vORDERBY = vORDERBY + " ORDER BY END ASC ";
                    }
                   
                    if (objUCFaturamento.BAIRRO != string.Empty)
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND BAIRRO LIKE ?BAIRRO "; }
                        else
                        { vAND = "AND BAIRRO LIKE ?BAIRRO "; }
                        vORDERBY = vORDERBY + " ORDER BY BAIRRO ASC ";

                    }
                    
                    if (objUCFaturamento.NUMERO != string.Empty)
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND NUMERO LIKE ?NUMERO "; }
                        else
                        { vAND = "AND NUMERO LIKE ?NUMERO "; }
                        vORDERBY = vORDERBY + " ORDER BY NUMERO ASC ";

                    }
                    
                    if (objUCFaturamento.COMPLEMENT != string.Empty)
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND COMPLEMENT LIKE ?COMPLEMENT "; }
                        else
                        { vAND = "AND COMPLEMENT LIKE ?COMPLEMENT "; }
                        vORDERBY = vORDERBY + " ORDER BY COMPLEMENT ASC ";

                    }
                   
                    if (objUCFaturamento.CIDADE != string.Empty)
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND CIDADE LIKE ?CIDADE "; }
                        else
                        { vAND = "AND CIDADE LIKE ?CIDADE "; }
                        vORDERBY = vORDERBY + " ORDER BY CIDADE ASC ";

                    }             

                    if (objUCFaturamento.DISTRITO != string.Empty)
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND DISTRITO LIKE ?DISTRITO "; }
                        else
                        { vAND = "AND DISTRITO LIKE ?DISTRITO "; }
                        vORDERBY = vORDERBY + " ORDER BY DISTRITO ASC ";

                    }

                    if (objUCFaturamento.UF != string.Empty)
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND UF LIKE ?UF "; }
                        else
                        { vAND = "AND UF LIKE ?UF "; }
                        vORDERBY = vORDERBY + " ORDER BY UF ASC ";

                    }

                    if (objUCFaturamento.CEP != string.Empty)
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND CEP LIKE ?CEP "; }
                        else
                        { vAND = "AND CEP LIKE ?CEP "; }
                        vORDERBY = vORDERBY + " ORDER BY CEP ASC ";

                    }

                    if (objUCFaturamento.QUADRA != string.Empty)
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND CONCAT(QUADRA, LOTE) LIKE ?QUADRA "; }
                        else
                        { vAND = "AND CONCAT(QUADRA, LOTE) LIKE ?QUADRA "; }
                        vORDERBY = vORDERBY + " ORDER BY QUADRA ASC, LOTE ASC ";

                    }

                    if (objUCFaturamento.BANCO != string.Empty)
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND BANCO = ?BANCO "; }
                        else
                        { vAND = "AND BANCO = ?BANCO "; }
                        vORDERBY = vORDERBY + " ORDER BY BANCO ASC ";

                    }

                    if (objUCFaturamento.AGRUPA_ZONA != string.Empty)
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND UC.ZONA <> ?AGRUPA_ZONA "; }
                        else
                        { vAND = "AND UC.ZONA <> ?AGRUPA_ZONA "; }

                    }

                    if (objUCFaturamento.CONS_ID != 0)
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND CONS_ID = ?CONS_ID "; }
                        else
                        { vAND = "AND CONS_ID = ?CONS_ID "; }
                    }

                    if (objUCFaturamento.IRRIGACAO_AQUICULTURA == 1)
                        vAND = vAND + " AND CLS.DESCRICAO LIKE '%" + objUCFaturamento.CLAS + "%' ";

                    if (objUCFaturamento.CLAS != null)                   
                        vAND = vAND + " AND CLS.DESCRICAO LIKE '%" + objUCFaturamento.CLAS + "%' ";

                    if (objUCFaturamento.MICRO_GERACAO == 1)
                        vAND = vAND + " AND MICRO_GERACAO = 1";

                    if (objUCFaturamento.MICRO_GERACAO == 2)
                        vAND = vAND + " AND DIST.MICROGERADOR_DISTRIBUIDO > 0";

                    if (objUCFaturamento.IRRIGACAO_AQUICULTURA == 1)
                        vAND = vAND + " AND REC.IRRIGACAO_AQUICULTURA = 1 ";



                    cmd = new MySqlCommand(this.QuerySelect);

                    if (objUCFaturamento.ZONA != string.Empty && objUCFaturamento.ZONA != "000")
                    { 
                        cmd.Parameters.AddWithValue("?ZONA", objUCFaturamento.ZONA.ToString().ToUpper());
                    }

                    if (objUCFaturamento.LIVRO != string.Empty && objUCFaturamento.LIVRO != "00")
                    {
                        cmd.Parameters.AddWithValue("?LIVRO", objUCFaturamento.LIVRO.ToString().ToUpper());
                    }

                    if (objUCFaturamento.CONTA != string.Empty && objUCFaturamento.CONTA != "000000")
                    {
                        cmd.Parameters.AddWithValue("?CONTA", objUCFaturamento.CONTA.ToString().ToUpper());
                    }

                    if (objUCFaturamento.ID != 0)
                    {
                        cmd.Parameters.AddWithValue("?ID", objUCFaturamento.ID);
                    }

                    if (objUCFaturamento.NOME != string.Empty)
                    {
                        cmd.Parameters.AddWithValue("?NOME", "%" + objUCFaturamento.NOME.ToString().ToUpper() + "%");
                    }

                    if (objUCFaturamento.GRUPO == "A")
                    {
                        if (objUCFaturamento.ELETR != string.Empty)
                        {
                            cmd.Parameters.AddWithValue("?ELETR", "%" + objUCFaturamento.ELETR.ToString().ToUpper() + "%");
                        }
                    }
                    else if (objUCFaturamento.GRUPO == "B")
                    {
                        if (objUCFaturamento.NUM != string.Empty)
                        {
                            cmd.Parameters.AddWithValue("?NUM", "%" + objUCFaturamento.NUM.ToString().ToUpper() + "%");
                        }
                    }
                    else
                    {

                        if (objUCFaturamento.NUM != string.Empty)
                        {
                            cmd.Parameters.AddWithValue("?NUM", "%" + objUCFaturamento.NUM.ToString().ToUpper() + "%");
                        }

                        if (objUCFaturamento.ELETR != string.Empty)
                        {
                            cmd.Parameters.AddWithValue("?ELETR", "%" + objUCFaturamento.ELETR.ToString().ToUpper() + "%");
                        }

                    }

                    if (objUCFaturamento.CPF_CNPJ != string.Empty)
                    {
                        cmd.Parameters.AddWithValue("?CPF_CNPJ", "%" + objUCFaturamento.CPF_CNPJ.ToString().ToUpper() + "%");
                    }

                    if (objUCFaturamento.RG != string.Empty)
                    {
                        cmd.Parameters.AddWithValue("?RG", "%" + objUCFaturamento.RG.ToString().ToUpper() + "%");
                    }

                    if (objUCFaturamento.INSC != string.Empty)
                    {
                        cmd.Parameters.AddWithValue("?INSC", "%" + objUCFaturamento.INSC.ToString().ToUpper() + "%");
                    }

                    if (objUCFaturamento.DIS_ENTREGA != string.Empty)
                    {
                        cmd.Parameters.AddWithValue("?DIS_ENTREGA", "%" + objUCFaturamento.DIS_ENTREGA.ToString().ToUpper() + "%");
                    }

                    if (objUCFaturamento.END != string.Empty)
                    {
                        cmd.Parameters.AddWithValue("?END", "%" + objUCFaturamento.END.ToString().ToUpper() + "%");
                    }

                    if (objUCFaturamento.BAIRRO != string.Empty)
                    {
                        cmd.Parameters.AddWithValue("?BAIRRO", "%" + objUCFaturamento.BAIRRO.ToString().ToUpper() + "%");
                    }

                    if (objUCFaturamento.NUMERO != string.Empty)
                    {
                        cmd.Parameters.AddWithValue("?NUMERO", "%" + objUCFaturamento.NUMERO.ToString().ToUpper() + "%");
                    }

                    if (objUCFaturamento.COMPLEMENT != string.Empty)
                    {
                        cmd.Parameters.AddWithValue("?COMPLEMENT", "%" + objUCFaturamento.COMPLEMENT.ToString().ToUpper() + "%");
                    }

                    if (objUCFaturamento.CIDADE != string.Empty)
                    {
                        cmd.Parameters.AddWithValue("?CIDADE", "%" + objUCFaturamento.CIDADE.ToString().ToUpper() + "%");
                    }

                    if (objUCFaturamento.DISTRITO != string.Empty)
                    {
                        cmd.Parameters.AddWithValue("?DISTRITO", "%" + objUCFaturamento.DISTRITO.ToString().ToUpper() + "%");
                    }

                    if (objUCFaturamento.UF != string.Empty)
                    {
                        cmd.Parameters.AddWithValue("?UF", "%" + objUCFaturamento.UF.ToString().ToUpper() + "%");
                    }

                    if (objUCFaturamento.CEP != string.Empty)
                    {
                        cmd.Parameters.AddWithValue("?CEP", "%" + objUCFaturamento.CEP.ToString().ToUpper() + "%");
                    }

                    if (objUCFaturamento.QUADRA != string.Empty)
                    {
                        cmd.Parameters.AddWithValue("?QUADRA", "%" + objUCFaturamento.QUADRA.ToString().ToUpper() + "%");
                    }

                    if (objUCFaturamento.BANCO != string.Empty)
                    {
                        cmd.Parameters.AddWithValue("?BANCO", objUCFaturamento.BANCO.ToString().ToUpper());
                    }

                    if (objUCFaturamento.AGRUPA_ZONA != string.Empty)
                    {
                        cmd.Parameters.AddWithValue("?AGRUPA_ZONA", "'" + objUCFaturamento.AGRUPA_ZONA.ToString().ToUpper() + "'");
                    }

                    if (objUCFaturamento.CONS_ID != 0)
                    {
                        cmd.Parameters.AddWithValue("?CONS_ID", objUCFaturamento.CONS_ID);
                    }

                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable SelectOthersTables_4(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "GRUPO_TAR, ";
                    vFILTER = vFILTER + "ID, ";
                    vFILTER = vFILTER + "ZONA, ";
                    vFILTER = vFILTER + "LIVRO, ";
                    vFILTER = vFILTER + "CONTA, ";
                    vFILTER = vFILTER + "CONS_ID, ";
                    vFILTER = vFILTER + "UNID_ID, ";
                    vFILTER = vFILTER + "GRUPO,";
                    vFILTER = vFILTER + "TA, ";
                    vFILTER = vFILTER + "REGIAO, ";
                    vFILTER = vFILTER + "TENSAO ";

                    vINNERJOIN = " ";

                    vORDERBY = " ";

                    vAND = vAND + "AND ZONA  = ?ZONA ";
                    vAND = vAND + "AND LIVRO = ?LIVRO ";
                    vAND = vAND + "AND CONTA = ?CONTA ";

                    cmd = new MySqlCommand(this.QuerySelect);

                    cmd.Parameters.AddWithValue("?ZONA", objUCFaturamento.ZONA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?LIVRO", objUCFaturamento.LIVRO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CONTA", objUCFaturamento.CONTA.ToString().ToUpper());

                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable SelectOthersTables_5(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "ID, ";
                    vFILTER = vFILTER + "ZONA,  ";
                    vFILTER = vFILTER + "LIVRO,  ";
                    vFILTER = vFILTER + "CONTA,  ";
                    vFILTER = vFILTER + "NOME ";

                    vINNERJOIN = " ";

                    vORDERBY = " ";

                    vAND = "AND ID <> ?ID ";
                    //vAND = "UNID_ID <> ?UNID_ID ";

                    if (objUCFaturamento.GRUPO == "B")
                    {
                        if (objUCFaturamento.NUM != string.Empty)
                        {
                            if (vAND != String.Empty)
                            { vAND = vAND + "AND NUM = ?NUM "; }
                            else
                            { vAND = "AND NUM = ?NUM "; }

                        }
                        else
                        {
                            if (vAND != String.Empty)
                            { vAND = vAND + " "; }
                            else
                            { vAND = " "; }
                        }

                        if (objUCFaturamento.MEDKW != 0)
                        {
                            if (vAND != String.Empty)
                            { vAND = vAND + "AND MEDKW = ?MEDKW "; }
                            else
                            { vAND = "AND MEDKW = ?MEDKW "; }

                        }
                        else
                        {
                            if (vAND != String.Empty)
                            { vAND = vAND + " "; }
                            else
                            { vAND = " "; }
                        }

                        if (objUCFaturamento.MEDKVARH != string.Empty)
                        {
                            if (vAND != String.Empty)
                            { vAND = vAND + "AND MEDKVARH = ?MEDKVARH "; }
                            else
                            { vAND = "AND MEDKVARH = ?MEDKVARH "; }

                        }
                        else
                        {
                            if (vAND != String.Empty)
                            { vAND = vAND + " "; }
                            else
                            { vAND = " "; }
                        }
                    }
                    else
                    {
                        if (objUCFaturamento.ELETR != string.Empty)
                        {
                            if (vAND != String.Empty)
                            { vAND = vAND + "AND ELETR = ?ELETR "; }
                            else
                            { vAND = "AND ELETR = ?ELETR "; }

                        }
                        else
                        {
                            if (vAND != String.Empty)
                            { vAND = vAND + " "; }
                            else
                            { vAND = " "; }
                        }

                        if (objUCFaturamento.MEDKW != 0)
                        {
                            if (vAND != String.Empty)
                            { vAND = vAND + "AND MEDKW = ?MEDKW "; }
                            else
                            { vAND = "AND MEDKW = ?MEDKW "; }

                        }
                        else
                        {
                            if (vAND != String.Empty)
                            { vAND = vAND + " "; }
                            else
                            { vAND = " "; }
                        }

                        if (objUCFaturamento.MEDKVARK != 0)
                        {
                            if (vAND != String.Empty)
                            { vAND = vAND + "AND MEDKVARH = ?MEDKVARK "; }
                            else
                            { vAND = "AND MEDKVARH = ?MEDKVARK "; }

                        }
                        else
                        {
                            if (vAND != String.Empty)
                            { vAND = vAND + " "; }
                            else
                            { vAND = " "; }
                        }

                    }

                    cmd = new MySqlCommand(this.QuerySelect);

                    cmd.Parameters.AddWithValue("?ID", objUCFaturamento.ID);

                    if (objUCFaturamento.GRUPO == "B")
                    {
                        if (objUCFaturamento.NUM != string.Empty)
                        {
                            cmd.Parameters.AddWithValue("?NUM", objUCFaturamento.NUM.ToString().ToUpper());
                        }

                        if (objUCFaturamento.MEDKW != 0)
                        {
                            cmd.Parameters.AddWithValue("?MEDKW", objUCFaturamento.MEDKW);
                        }

                        if (objUCFaturamento.MEDKVARH != string.Empty)
                        {
                            cmd.Parameters.AddWithValue("?MEDKVARH", objUCFaturamento.MEDKVARH.ToString().ToUpper());
                        }
                    }

                    else

                    {

                        if (objUCFaturamento.ELETR != string.Empty)
                        {
                            cmd.Parameters.AddWithValue("?ELETR", objUCFaturamento.ELETR.ToString().ToUpper());
                        }

                        if (objUCFaturamento.MEDKW != 0)
                        {
                            cmd.Parameters.AddWithValue("?MEDKW", objUCFaturamento.MEDKW);
                        }

                        if (objUCFaturamento.MEDKVARK != 0)
                        {
                            cmd.Parameters.AddWithValue("?MEDKVARK", objUCFaturamento.MEDKVARK.ToString().ToUpper());
                        }
                    }

                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable SelectOthersTables_6(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "MICRO_GERACAO,  ";
                    vFILTER = vFILTER + "TARIFA_BRANCA,   ";
                    vFILTER = vFILTER + "IRRIGACAO_AQUICULTURA,  ";
                    vFILTER = vFILTER + "LIVREESPECIAL,   ";
                    vFILTER = vFILTER + "PARCIALMENTE_CATIVO  ";

                    vINNERJOIN = " ";

                    vORDERBY = " ";


                    if (objUCFaturamento.UNID_ID != 0)
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "UNID_ID = ?UNID_ID "; }
                        else
                        { vAND = "UNID_ID = ?UNID_ID "; }

                    }
                    else
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + " "; }
                        else
                        { vAND = " "; }
                    }



                    cmd = new MySqlCommand(this.QuerySelect);


                    if (objUCFaturamento.UNID_ID != 0)
                    {
                        cmd.Parameters.AddWithValue("?UNID_ID", objUCFaturamento.UNID_ID);
                    }


                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable SelectOthersTables_7(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "ID, ";
                    vFILTER = vFILTER + "ZONA,   ";
                    vFILTER = vFILTER + "LIVRO,   ";
                    vFILTER = vFILTER + "CONTA,    ";
                    vFILTER = vFILTER + "TA,    ";
                    vFILTER = vFILTER + "NOME,    ";
                    vFILTER = vFILTER + "CPF_CNPJ,    ";
                    vFILTER = vFILTER + "CLAS   ";

                    vINNERJOIN = " ";

                    vORDERBY = " ";


                    if (objUCFaturamento.UNID_ID != 0)
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND ID = ?UNID_ID "; }
                        else
                        { vAND = "ID = ?UNID_ID "; }

                    }
                    else
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + " "; }
                        else
                        { vAND = " "; }
                    }

                    if (objUCFaturamento.CONS_ID != 0)
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + " AND CONS_ID = ?CONS_ID "; }
                        else
                        { vAND = "CONS_ID = ?CONS_ID "; }

                    }
                    else
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + " "; }
                        else
                        { vAND = " "; }
                    }



                    cmd = new MySqlCommand(this.QuerySelect);


                    if (objUCFaturamento.UNID_ID != 0)
                    {
                        cmd.Parameters.AddWithValue("?UNID_ID", objUCFaturamento.UNID_ID);
                    }

                    if (objUCFaturamento.CONS_ID != 0)
                    {
                        cmd.Parameters.AddWithValue("?CONS_ID", objUCFaturamento.CONS_ID);
                    }

                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable SelectOthersTables_8(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "ID, ";
                    vFILTER = vFILTER + "CONS_ID, ";
                    vFILTER = vFILTER + "UNID_ID, ";
                    vFILTER = vFILTER + "NOME, ";
                    vFILTER = vFILTER + "TA,  ";
                    vFILTER = vFILTER + "CLAS ";

                    vINNERJOIN = " ";

                    vORDERBY = " ";

                    vAND = vAND + "AND  ZONA  = ?ZONA ";
                    vAND = vAND + "AND LIVRO = ?LIVRO ";
                    vAND = vAND + "AND CONTA = ?CONTA ";

                    cmd = new MySqlCommand(this.QuerySelect);

                    cmd.Parameters.AddWithValue("?ZONA", objUCFaturamento.ZONA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?LIVRO", objUCFaturamento.LIVRO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CONTA", objUCFaturamento.CONTA.ToString().ToUpper());

                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable SelectOthersTables_9(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "ID, ";
                    vFILTER = vFILTER + "ZONA,  ";
                    vFILTER = vFILTER + "LIVRO,  ";
                    vFILTER = vFILTER + "CONTA,  ";
                    vFILTER = vFILTER + "NOME ";

                    vINNERJOIN = " ";

                    vORDERBY = " ";


                    if (objUCFaturamento.UNID_ID != 0)
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND UNID_ID = ?UNID_ID "; }
                        else
                        { vAND = "AND UNID_ID = ?UNID_ID "; }

                    }
                    else
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + " "; }
                        else
                        { vAND = " "; }
                    }


                    cmd = new MySqlCommand(this.QuerySelect);

                    if (objUCFaturamento.UNID_ID != 0)
                    {
                        cmd.Parameters.AddWithValue("?UNID_ID", objUCFaturamento.UNID_ID);
                    }


                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable SelectOthersTables_10(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "GRUPO_TAR, ";
                    vFILTER = vFILTER + "ID, ";
                    vFILTER = vFILTER + "CONS_ID,  ";
                    vFILTER = vFILTER + "UNID_ID,  ";
                    vFILTER = vFILTER + "ZONA,  ";
                    vFILTER = vFILTER + "LIVRO,  ";
                    vFILTER = vFILTER + "CONTA, ";
                    vFILTER = vFILTER + "ROTA, ";
                    vFILTER = vFILTER + "NOME,   ";
                    vFILTER = vFILTER + "CLAS,   ";
                    vFILTER = vFILTER + "CLASSE.DESCRICAO AS DESCRICAO_CLASSE,  ";
                    vFILTER = vFILTER + "INSTAL,  ";
                    vFILTER = vFILTER + "CASE WHEN SUBSTRING(GRUPO, 1, 1) = 'A' THEN 'ABCN' ELSE FASELIG END AS  FASELIG,  ";
                    vFILTER = vFILTER + "END,    ";
                    vFILTER = vFILTER + "NUMERO,";
                    vFILTER = vFILTER + "COMPLEMENT,   ";
                    vFILTER = vFILTER + " LOTE,   ";
                    vFILTER = vFILTER + "QUADRA,    ";
                    vFILTER = vFILTER + "BAIRRO, ";
                    vFILTER = vFILTER + "CIDADE,   ";
                    vFILTER = vFILTER + "CEP,    ";
                    vFILTER = vFILTER + "DISTRITO,   ";
                    vFILTER = vFILTER + "UF,    ";
                    vFILTER = vFILTER + "GRUPO,   ";
                    vFILTER = vFILTER + "CASE WHEN SUBSTRING(GRUPO, 1, 1) = 'A' THEN CONST_CONSUMO ELSE CONST END AS CONSTKWH,     ";
                    vFILTER = vFILTER + "CASE WHEN SUBSTRING(GRUPO, 1, 1) = 'A' THEN CONST_DEMANDA ELSE 0 END AS   CONSKW,    ";
                    vFILTER = vFILTER + "CASE WHEN SUBSTRING(GRUPO, 1, 1) = 'A' THEN CONST_KVARH ELSE CONSTFP END AS CONSTKVARH,  ";
                    vFILTER = vFILTER + "CASE WHEN SUBSTRING(GRUPO, 1, 1) = 'A' THEN CONST_CONS_P ELSE 0 END AS  CONSTKWHP,  ";
                    vFILTER = vFILTER + "CASE WHEN SUBSTRING(GRUPO, 1, 1) = 'A' THEN CONST_DEMANDA ELSE 0 END AS  CONSKWP,  ";
                    vFILTER = vFILTER + "CASE WHEN SUBSTRING(GRUPO, 1, 1) = 'A' THEN CONST_KVARH_P ELSE 0 END AS  CONSTKVARHP,  ";
                    vFILTER = vFILTER + "CASE WHEN SUBSTRING(GRUPO, 1, 1) = 'A' THEN CONST_CONS_FP ELSE 0 END AS  CONSTKWHFP,  ";
                    vFILTER = vFILTER + "CASE WHEN SUBSTRING(GRUPO, 1, 1) = 'A' THEN CONST_DEMANDA_FP ELSE 0 END AS  CONSKWFP,  ";
                    vFILTER = vFILTER + "CASE WHEN SUBSTRING(GRUPO, 1, 1) = 'A' THEN CONST_KVARH_FP ELSE 0 END AS  CONSTKVARHFP  ";


                    vINNERJOIN = vINNERJOIN + "LEFT JOIN CLASSE ON(CLASSE.CODIGO = UC_FATURAMENTO.CLAS)  ";

                    vORDERBY = " ";


                    if (objUCFaturamento.IDMEDIDOR != 0)
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND IDMEDIDOR = ?IDMEDIDOR "; }
                        else
                        { vAND = "AND IDMEDIDOR = ?IDMEDIDOR "; }

                    }
                    else
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + " "; }
                        else
                        { vAND = " "; }
                    }


                    cmd = new MySqlCommand(this.QuerySelect);

                    if (objUCFaturamento.IDMEDIDOR != 0)
                    {
                        cmd.Parameters.AddWithValue("?IDMEDIDOR", objUCFaturamento.IDMEDIDOR);
                    }

                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable SelectOthersTables_11(entidadeUCFaturamento objUCFaturamento)
        {
            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 + " DISTINCT LEFT(ROTA ,4) AS ROTA ";
                    vFILTER = vFILTER + " DISTINCT CAST(LEFT(ROTA ,4) AS DECIMAL) AS ROTA  ";

                    vINNERJOIN = " ";

                    vORDERBY = "ORDER BY ROTA ASC  ";

                    vAND = vAND + " AND ROTA IS NOT NULL ";

                    cmd = new MySqlCommand(this.QuerySelect);


                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable SelectOthersTables_12(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "LEFT(ROTA, 4) AS ROTA ";

                    vINNERJOIN = " ";

                    vORDERBY = "GROUP BY 1 ASC ORDER BY LPAD(LEFT(ROTA, 4), 4,'0') ASC ";

                    vAND = vAND + " AND SITUACAO IN (" + objUCFaturamento.SITUACAO.ToString().ToUpper() + ") ";

                    vAND += " AND LPAD(LEFT(ROTA, 4), 4, '0') <> '9999' ";

                    cmd = new MySqlCommand(this.QuerySelect);

                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable SelectOthersTables_13(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "MICRO_GERACAO,  ";
                    vFILTER = vFILTER + "TARIFA_BRANCA,   ";
                    vFILTER = vFILTER + "IRRIGACAO_AQUICULTURA,  ";
                    vFILTER = vFILTER + "LIVREESPECIAL,   ";
                    vFILTER = vFILTER + "PARCIALMENTE_CATIVO  ";

                    vINNERJOIN = " ";

                    vORDERBY = " ";

                    vAND = vAND + "   AND ID = ?ID  ";


                    cmd = new MySqlCommand(this.QuerySelect);


                    if (objUCFaturamento.ID != 0)
                    {
                        cmd.Parameters.AddWithValue("?ID", objUCFaturamento.ID);
                    }


                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable SelectOthersTables_14(entidadeUCFaturamento objUCFaturamento)
        {
            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 + " DISTINCT CADERNO AS CADERNO ";

                    vINNERJOIN = " ";

                    vORDERBY = "ORDER BY CADERNO ASC  ";

                    vAND = " ";

                    cmd = new MySqlCommand(this.QuerySelect);


                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable SelectCount(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "SELECT 'B' AS NAME, COUNT(*) AS COUNT ";
                    vFILTER = vFILTER + "FROM UC_FATURAMENTO ";
                    vFILTER = vFILTER + "WHERE LEFT(UC_FATURAMENTO.CODEND, ?COD0 ) = ?COD1 ";
                    vFILTER = vFILTER + "OR LEFT(UC_FATURAMENTO.CODEND_ENTREGA, ?COD0 ) = ?COD1 ";
                    vFILTER = vFILTER + "UNION ";
                    vFILTER = vFILTER + "SELECT 'A' AS NAME, COUNT(*) AS COUNT ";
                    vFILTER = vFILTER + "FROM UC_FATURAMENTO ";
                    vFILTER = vFILTER + "WHERE LEFT(UC_FATURAMENTO.CODEND, ?COD0 ) = ?COD1 ";
                    vFILTER = vFILTER + "OR LEFT(UC_FATURAMENTO.CODEND_ENTREGA, ?COD0 ) = ?COD1 ";
                    vFILTER = vFILTER + "UNION ";
                    vFILTER = vFILTER + "SELECT 'C' AS NAME, COUNT(*) AS COUNT ";
                    vFILTER = vFILTER + "FROM CONSUM ";
                    vFILTER = vFILTER + "WHERE LEFT(CONSUM.CODEND, ?COD0 ) = ?COD1 ";
                    vFILTER = vFILTER + "GROUP BY 1 ";

                    vORDERBY = " ";

                    vAND = vFILTER;


                    cmd = new MySqlCommand(this.QueryExecute);

                    cmd.Parameters.AddWithValue("?COD0", objUCFaturamento.GRUPO.ToString().Length);
                    cmd.Parameters.AddWithValue("?COD1", objUCFaturamento.GRUPO.ToString().ToUpper());

                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public void Insert(entidadeUCFaturamento objUCFaturamento)
        {
            MySqlCommand cmd = null;
            IGerenciadorTransacao objGerenciadorTransacao = null;
            ConexaoBD objconexaoBD = null;
            int idCod = 0;

            try
            {
                objconexaoBD = new ConexaoBD();

                objconexaoBD.SetarConexaoBanco(TipoBDConexao.fat_BD);

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

                    vFILTER = vFILTER + "MAX(UNID_ID) AS UNID_ID ";

                    vINNERJOIN = " ";

                    vORDERBY = " ";

                    vAND = " ";

                    cmd = new MySqlCommand(this.QuerySelect);

                    idCod = (int)objGerenciadorTransacao.ExecuteScalar(cmd);

                    idCod = idCod + 1;

                    objUCFaturamento.UNID_ID = idCod;

                    cmd = null;

                    vFILTER = " ";

                    vFILTER = vFILTER + "UNID_ID = ?UNID_ID , ";
                    vFILTER = vFILTER + "CONS_ID = ?CONS_ID  , ";
                    vFILTER = vFILTER + "ZONA = ?ZONA  , ";
                    vFILTER = vFILTER + "LIVRO = ?LIVRO  , ";
                    vFILTER = vFILTER + "CONTA = ?CONTA  , ";
                    vFILTER = vFILTER + "ROTA = ?ROTA  , ";
                    vFILTER = vFILTER + "SITUACAO = ?SITUACAO  , ";
                    vFILTER = vFILTER + "NOME = ?NOME  , ";
                    vFILTER = vFILTER + "GRUPO = ?GRUPO  , ";
                    vFILTER = vFILTER + "CLAS = ?CLAS  , ";
                    vFILTER = vFILTER + "TA = ?TA  , ";
                    vFILTER = vFILTER + "DATA_LIGACAO = ?DATA_LIGACAO  , ";
                    vFILTER = vFILTER + "DATA_ENTRADA = ?DATA_ENTRADA  , ";
                    vFILTER = vFILTER + "FPFIXO = ?FPFIXO  , ";
                    vFILTER = vFILTER + "FINAL = ?FINAL  , ";
                    vFILTER = vFILTER + "IDCCEE = ?IDCCEE  , ";
                    vFILTER = vFILTER + "CARGA = ?CARGA  ,";
                    vFILTER = vFILTER + "LATITUDE = ?LATITUDE  , ";
                    vFILTER = vFILTER + "LONGITUDE = ?LONGITUDE  , ";
                    vFILTER = vFILTER + "AREA = ?AREA  , ";
                    vFILTER = vFILTER + "CICE = ?CICE  , ";
                    vFILTER = vFILTER + "TIPOUC = ?TIPOUC  , ";
                    vFILTER = vFILTER + "CIRCUITO = ?CIRCUITO  , ";
                    vFILTER = vFILTER + "REGIAO = ?REGIAO  , ";
                    vFILTER = vFILTER + "TENSAO = ?TENSAO  , ";
                    vFILTER = vFILTER + "FASE = ?FASE  , ";
                    vFILTER = vFILTER + "DIAVENC = ?DIAVENC , ";
                    vFILTER = vFILTER + "IRR_HR_INI = ?IRR_HR_INI  , ";
                    vFILTER = vFILTER + "IRR_HR_FIM = ?IRR_HR_FIM  , ";
                    vFILTER = vFILTER + "BXRENDA = ?BXRENDA  , ";
                    vFILTER = vFILTER + "AP_SAUDE = ?AP_SAUDE  , ";
                    vFILTER = vFILTER + "ESTUFA = ?ESTUFA  , ";
                    vFILTER = vFILTER + "ALTA_TENSAO = ?ALTA_TENSAO  , ";
                    vFILTER = vFILTER + "VECTOPROXMES = ?VECTOPROXMES  , ";
                    vFILTER = vFILTER + "FLG_AVISO_DEBITO = ?FLG_AVISO_DEBITO  , ";
                    vFILTER = vFILTER + "PAGTO_GOVERNO = ?PAGTO_GOVERNO  , ";
                    vFILTER = vFILTER + "LUZ_TODOS = ?LUZ_TODOS  , ";
                    vFILTER = vFILTER + "ISENTOREATIVO = ?ISENTOREATIVO  , ";
                    vFILTER = vFILTER + "ISENTO = ?ISENTO  , ";
                    vFILTER = vFILTER + "ICMS_ISENTO_DEMANDA = ?ICMS_ISENTO_DEMANDA  , ";
                    vFILTER = vFILTER + "ICMS_DEMANDA_LIDA = ?ICMS_DEMANDA_LIDA  , ";
                    vFILTER = vFILTER + "ICMS_DIFERIDO = ?ICMS_DIFERIDO  , ";
                    vFILTER = vFILTER + "FLG_ALIQUOTADIF = ?FLG_ALIQUOTADIF  , ";
                    vFILTER = vFILTER + "ILUM = ?ILUM  , ";
                    vFILTER = vFILTER + "QH = ?QH  , ";
                    vFILTER = vFILTER + "ENCARGO = ?ENCARGO  , ";
                    vFILTER = vFILTER + "VIP_COMERCIAL = ?VIP_COMERCIAL  , ";
                    vFILTER = vFILTER + "VIP_TECNICO = ?VIP_TECNICO  , ";
                    vFILTER = vFILTER + "PAGTO_DUVIDOSO = ?PAGTO_DUVIDOSO  , ";
                    vFILTER = vFILTER + "LEITREATIVO = ?LEITREATIVO  , ";
                    vFILTER = vFILTER + "LEITDEMA = ?LEITDEMA  , ";
                    vFILTER = vFILTER + "ISENTO_ICMS_TUSD = ?ISENTO_ICMS_TUSD  , ";
                    vFILTER = vFILTER + "ENVIO_COB_JUDICIAL = ?ENVIO_COB_JUDICIAL  , ";
                    vFILTER = vFILTER + "BLOQUEA_SEG_VIA_FAT = ?BLOQUEA_SEG_VIA_FAT  , ";
                    vFILTER = vFILTER + "BLOQUEA_RELIGACAO = ?BLOQUEA_RELIGACAO  , ";
                    vFILTER = vFILTER + "TARIFA_BRANCA = ?TARIFA_BRANCA  , ";
                    vFILTER = vFILTER + "MICRO_GERACAO = ?MICRO_GERACAO  , ";
                    vFILTER = vFILTER + "IRRIGACAO_AQUICULTURA = ?IRRIGACAO_AQUICULTURA  , ";
                    vFILTER = vFILTER + "LIVRE_LEITURA_CONSUMO = ?LIVRE_LEITURA_CONSUMO  , ";
                    vFILTER = vFILTER + "LIVRE_VERDE = ?LIVRE_VERDE  , ";
                    vFILTER = vFILTER + "PARCIALMENTE_CATIVO = ?PARCIALMENTE_CATIVO  , ";
                    vFILTER = vFILTER + "LIVREESPECIAL = ?LIVREESPECIAL  , ";
                    vFILTER = vFILTER + "CONJUGE_FATURA = ?CONJUGE_FATURA  , ";
                    vFILTER = vFILTER + "ENVIO_EMAIL_FATURA = ?ENVIO_EMAIL_FATURA  , ";
                    vFILTER = vFILTER + "CONST = ?CONST  , ";

                    if (objUCFaturamento.GRUPO.Substring(0, 1) == "B")
                    {

                        vFILTER = vFILTER + "ULT_LEIT_KWH_P = ?ULT_LEIT_KWH_P  , ";
                        vFILTER = vFILTER + "ULT_LEIT_KWH_I = ?ULT_LEIT_KWH_I  , ";
                        vFILTER = vFILTER + "ULT_LEIT_KWH_FP = ?ULT_LEIT_KWH_FP  , ";
                        vFILTER = vFILTER + "KWH_RES_P = ?KWH_RES_P  , ";
                        vFILTER = vFILTER + "KWH_RES_I = ?KWH_RES_I  , ";
                        vFILTER = vFILTER + "KWH_RES_FP = ?KWH_RES_FP  , ";
                        vFILTER = vFILTER + "CONST_KWH_P = ?CONST_KWH_P  , ";
                        vFILTER = vFILTER + "CONST_KWH_I = ?CONST_KWH_I  , ";
                        vFILTER = vFILTER + "CONST_KWH_FP = ?CONST_KWH_FP  , ";
                        vFILTER = vFILTER + "ULT_CONS_KWH_P = ?ULT_CONS_KWH_P  , ";
                        vFILTER = vFILTER + "ULT_CONS_KWH_I = ?ULT_CONS_KWH_I  , ";
                        vFILTER = vFILTER + "ULT_CONS_KWH_FP = ?ULT_CONS_KWH_FP  , ";
                        vFILTER = vFILTER + "ULT_LEIT_KVARH_P = ?ULT_LEIT_KVARH_P  , ";
                        vFILTER = vFILTER + "ULT_LEIT_KVARH_I = ?ULT_LEIT_KVARH_I  , ";
                        vFILTER = vFILTER + "ULT_LEIT_KVARH_FP = ?ULT_LEIT_KVARH_FP  , ";
                        vFILTER = vFILTER + "CONST_KVARH_P = ?CONST_KVARH_P  , ";
                        vFILTER = vFILTER + "CONST_KVARH_I = ?CONST_KVARH_I  , ";
                        vFILTER = vFILTER + "CONST_KVARH_FP = ?CONST_KVARH_FP  , ";
                        vFILTER = vFILTER + "ULT_CONS_KVARH_P = ?ULT_CONS_KVARH_P  , ";
                        vFILTER = vFILTER + "ULT_CONS_KVARH_I = ?ULT_CONS_KVARH_I  , ";
                        vFILTER = vFILTER + "ULT_CONS_KVARH_FP = ?ULT_CONS_KVARH_FP  , ";
                        vFILTER = vFILTER + "ULTLEIT_REVERSO_P = ?ULTLEIT_REVERSO_P  , ";
                        vFILTER = vFILTER + "ULTLEIT_REVERSO_I = ?ULTLEIT_REVERSO_I  , ";
                        vFILTER = vFILTER + "ULTLEIT_REVERSO_FP = ?ULTLEIT_REVERSO_FP  , ";
                        vFILTER = vFILTER + "KWH_REVERSO_RES_P = ?KWH_REVERSO_RES_P  , ";
                        vFILTER = vFILTER + "KWH_REVERSO_RES_I = ?KWH_REVERSO_RES_I  , ";
                        vFILTER = vFILTER + "KWH_REVERSO_RES_FP = ?KWH_REVERSO_RES_FP  , ";
                        vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_P = ?ULT_LEIT_IRRIGANTE_P  , ";
                        vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_I = ?ULT_LEIT_IRRIGANTE_I  , ";
                        vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_FP = ?ULT_LEIT_IRRIGANTE_FP  , ";
                        vFILTER = vFILTER + "KWH_IRRIGANTE_RES_P = ?KWH_IRRIGANTE_RES_P  , ";
                        vFILTER = vFILTER + "KWH_IRRIGANTE_RES_I = ?KWH_IRRIGANTE_RES_I  , ";
                        vFILTER = vFILTER + "KWH_IRRIGANTE_RES_FP = ?KWH_IRRIGANTE_RES_FP  , ";
                        vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_P = ?ULT_LEIT_DESLIGAMENTO_P  , ";
                        vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_I = ?ULT_LEIT_DESLIGAMENTO_I  , ";
                        vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_FP = ?ULT_LEIT_DESLIGAMENTO_FP  , ";
                        vFILTER = vFILTER + "ULT_LEIT_CORTE_P = ?ULT_LEIT_CORTE_P  , ";
                        vFILTER = vFILTER + "ULT_LEIT_CORTE_I = ?ULT_LEIT_CORTE_I  , ";
                        vFILTER = vFILTER + "ULT_LEIT_CORTE_FP = ?ULT_LEIT_CORTE_FP  , ";

                    }

                    if (objUCFaturamento.GRUPO.Substring(0, 1) == "A")
                    {

                        vFILTER = vFILTER + "ULT_LEIT_KWH_P  = ?ULT_LEIT_KWH_P  , ";
                        vFILTER = vFILTER + "ULT_LEIT_KWH_FP  = ?ULT_LEIT_KWH_FP  , ";
                        vFILTER = vFILTER + "KWH_RES_P  = ?KWH_RES_P  , ";
                        vFILTER = vFILTER + "KWH_RES_FP  = ?KWH_RES_FP  , ";
                        vFILTER = vFILTER + "CONST_KWH_P  = ?CONST_KWH_P  , ";
                        vFILTER = vFILTER + "CONST_KWH_FP  = ?CONST_KWH_FP  , ";
                        vFILTER = vFILTER + "ULT_CONS_KWH_P  = ?ULT_CONS_KWH_P  , ";
                        vFILTER = vFILTER + "ULT_CONS_KWH_FP  = ?ULT_CONS_KWH_FP  , ";
                        vFILTER = vFILTER + "ULT_LEIT_KW_P  = ?ULT_LEIT_KW_P  , ";
                        vFILTER = vFILTER + "ULT_LEIT_KW_FP  = ?ULT_LEIT_KW_FP  , ";
                        vFILTER = vFILTER + "CONST_KW_P  = ?CONST_KW_P  , ";
                        vFILTER = vFILTER + "CONST_KW_FP  = ?CONST_KW_FP  , ";
                        vFILTER = vFILTER + "ULT_CONS_KW_P  = ?ULT_CONS_KW_P  , ";
                        vFILTER = vFILTER + "ULT_CONS_KW_FP  = ?ULT_CONS_KW_FP  , ";
                        vFILTER = vFILTER + "ULT_LEIT_KVARH_P  = ?ULT_LEIT_KVARH_P  , ";
                        vFILTER = vFILTER + "ULT_LEIT_KVARH_FP  = ?ULT_LEIT_KVARH_FP  , ";
                        vFILTER = vFILTER + "CONST_KVARH_P  = ?CONST_KVARH_P  , ";
                        vFILTER = vFILTER + "CONST_KVARH_FP  = ?CONST_KVARH_FP  , ";
                        vFILTER = vFILTER + "ULT_CONS_KVARH_P  = ?ULT_CONS_KVARH_P  , ";
                        vFILTER = vFILTER + "ULT_CONS_KVARH_FP  = ?ULT_CONS_KVARH_FP  , ";
                        vFILTER = vFILTER + "ULTLEIT_REVERSO_P  = ?ULTLEIT_REVERSO_P  , ";
                        vFILTER = vFILTER + "ULTLEIT_REVERSO_FP  = ?ULTLEIT_REVERSO_FP  , ";
                        vFILTER = vFILTER + "KWH_REVERSO_RES_P  = ?KWH_REVERSO_RES_P  , ";
                        vFILTER = vFILTER + "KWH_REVERSO_RES_FP  = ?KWH_REVERSO_RES_FP  , ";
                        vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_P  = ?ULT_LEIT_IRRIGANTE_P  , ";
                        vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_FP  = ?ULT_LEIT_IRRIGANTE_FP  , ";
                        vFILTER = vFILTER + "KWH_IRRIGANTE_RES_P  = ?KWH_IRRIGANTE_RES_P  , ";
                        vFILTER = vFILTER + "KWH_IRRIGANTE_RES_FP  = ?KWH_IRRIGANTE_RES_FP  , ";
                        vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_P  = ?ULT_LEIT_DESLIGAMENTO_P  , ";
                        vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_FP  = ?ULT_LEIT_DESLIGAMENTO_FP  , ";
                        vFILTER = vFILTER + "ULT_LEIT_CORTE_P  = ?ULT_LEIT_CORTE_P  , ";
                        vFILTER = vFILTER + "ULT_LEIT_CORTE_FP  = ?ULT_LEIT_CORTE_FP  , ";

                    }

                    vFILTER = vFILTER + "CODEND  = ?CODEND  , ";
                    vFILTER = vFILTER + "UF  = ?UF  , ";
                    vFILTER = vFILTER + "CEP  = ?CEP  , ";
                    vFILTER = vFILTER + "CIDADE  = ?CIDADE  , ";
                    vFILTER = vFILTER + "DISTRITO  = ?DISTRITO  , ";
                    vFILTER = vFILTER + "BAIRRO  = ?BAIRRO  , ";
                    vFILTER = vFILTER + "END  = ?END  , ";
                    vFILTER = vFILTER + "NUMERO  = ?NUMERO  , ";
                    vFILTER = vFILTER + "COMPLEMENT  = ?COMPLEMENT  , ";
                    vFILTER = vFILTER + "LOTE  = ?LOTE  , ";
                    vFILTER = vFILTER + "QUADRA  = ?QUADRA  , ";
                    vFILTER = vFILTER + "FONE  = ?FONE  , ";
                    vFILTER = vFILTER + "BANCO  = ?BANCO  , ";
                    vFILTER = vFILTER + "AGENC  = ?AGENC  , ";
                    vFILTER = vFILTER + "CC  = ?CC  , ";
                    vFILTER = vFILTER + "ENTREGA  = ?ENTREGA  , ";
                    vFILTER = vFILTER + "CODEND_ENTREGA  = ?CODEND_ENTREGA  , ";
                    vFILTER = vFILTER + "UF_ENTREGA  = ?UF_ENTREGA  , ";
                    vFILTER = vFILTER + "CEP_ENTREGA  = ?CEP_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 + "LOT_ENTREGA  = ?LOT_ENTREGA  , ";
                    vFILTER = vFILTER + "QUA_ENTREGA  = ?QUA_ENTREGA  , ";
                    vFILTER = vFILTER + "PESSOA  = ?PESSOA  , ";
                    vFILTER = vFILTER + "RG  = ?RG  , ";
                    vFILTER = vFILTER + "CPF_CNPJ  = ?CPF_CNPJ  , ";
                    vFILTER = vFILTER + "INSC  = ?INSC  , ";
                    vFILTER = vFILTER + "CNAE  = ?CNAE  , ";
                    vFILTER = vFILTER + "IDCNAE  = ?IDCNAE  , ";
                    vFILTER = vFILTER + "AGRUPA_ZONA  = ?AGRUPA_ZONA  , ";
                    vFILTER = vFILTER + "AGRUPA_LIVRO  = ?AGRUPA_LIVRO  , ";
                    vFILTER = vFILTER + "AGRUPA_CONTA  = ?AGRUPA_CONTA  , ";
                    vFILTER = vFILTER + "AGRUPA  = ?AGRUPA  , ";
                    vFILTER = vFILTER + "NUM  = ?NUM  , ";
                    vFILTER = vFILTER + "ELETR  = ?ELETR  , ";
                    vFILTER = vFILTER + "MEDKVARH  = ?MEDKVARH  , ";
                    vFILTER = vFILTER + "MEDKW  = ?MEDKW  , ";
                    vFILTER = vFILTER + "MEDKVARK  = ?MEDKVARK  , ";
                    vFILTER = vFILTER + "MARCA  = ?MARCA  , ";
                    vFILTER = vFILTER + "MODELO  = ?MODELO  , ";
                    vFILTER = vFILTER + "DTAFABMEDIDOR  = ?DTAFABMEDIDOR  , ";
                    vFILTER = vFILTER + "DTAINSTMEDIDOR  = ?DTAINSTMEDIDOR  , ";
                    vFILTER = vFILTER + "LACRE  = ?LACRE  , ";
                    vFILTER = vFILTER + "DISJUNTOR  = ?DISJUNTOR  , ";
                    vFILTER = vFILTER + "TRANSF  = ?TRANSF  , ";
                    vFILTER = vFILTER + "FASELIG  = ?FASELIG  , ";
                    vFILTER = vFILTER + "IDCONDUTOR  = ?IDCONDUTOR  , ";
                    vFILTER = vFILTER + "TIPO_MEDICAO  = ?TIPO_MEDICAO  , ";
                    vFILTER = vFILTER + "IDTIPO_PADRAO_MEDICAO  = ?IDTIPO_PADRAO_MEDICAO  , ";
                    vFILTER = vFILTER + "IDCORRENTE  = ?IDCORRENTE  , ";
                    vFILTER = vFILTER + "COMPRIMENTO_FIO  = ?COMPRIMENTO_FIO  , ";
                    vFILTER = vFILTER + "IDALIMENTADOR  = ?IDALIMENTADOR  , ";
                    vFILTER = vFILTER + "IDTIPO_MEDIDOR  = ?IDTIPO_MEDIDOR  , ";
                    vFILTER = vFILTER + "COD_TIPO_MEDICAO  = ?COD_TIPO_MEDICAO  , ";
                    vFILTER = vFILTER + "TC_RELACAO_PRIMARIA  = ?TC_RELACAO_PRIMARIA  , ";
                    vFILTER = vFILTER + "TC_RELACAO_SECUNDARIA  = ?TC_RELACAO_SECUNDARIA  , ";
                    vFILTER = vFILTER + "TP_RELACAO_PRIMARIA  = ?TP_RELACAO_PRIMARIA  , ";
                    vFILTER = vFILTER + "TP_RELACAO_SECUNDARIA  = ?TP_RELACAO_SECUNDARIA  , ";
                    vFILTER = vFILTER + "PERIODO_TESTE  = ?PERIODO_TESTE  , ";
                    vFILTER = vFILTER + "INI_PERIODO_TESTE  = ?INI_PERIODO_TESTE  , ";
                    vFILTER = vFILTER + "FIM_PERIODO_TESTE  = ?FIM_PERIODO_TESTE  , ";
                    vFILTER = vFILTER + "DATA_CONTRATO_DEMANDA  = ?DATA_CONTRATO_DEMANDA  , ";
                    vFILTER = vFILTER + "DEMANDA_CONTR  = ?DEMANDA_CONTR  , ";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA  = ?DEM_CONTR_PONTA  , ";
                    vFILTER = vFILTER + "DEM_CONTR_FP  = ?DEM_CONTR_FP  , ";
                    vFILTER = vFILTER + "DEMANDA_CONTR_ANTERIOR  = ?DEMANDA_CONTR_ANTERIOR  , ";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA_ANTERIOR  = ?DEM_CONTR_PONTA_ANTERIOR  , ";
                    vFILTER = vFILTER + "DEM_CONTR_FP_ANTERIOR  = ?DEM_CONTR_FP_ANTERIOR  , ";

                    if (objUCFaturamento.GRUPO.Substring(0, 1) == "B")
                    {
                        vFILTER = vFILTER + "ULTLEIT  = ?ULTLEIT  , ";
                        vFILTER = vFILTER + "RESIDUO_CONSUMO  = ?RESIDUO_CONSUMO  , ";
                    }

                    vFILTER = vFILTER + "ITENSESP  = ?ITENSESP  , ";
                    vFILTER = vFILTER + "TP_LIGACAO  = ?TP_LIGACAO   ";

                    cmd = new MySqlCommand(this.QueryInsert);

                    cmd.Parameters.AddWithValue("?UNID_ID", objUCFaturamento.UNID_ID);
                    cmd.Parameters.AddWithValue("?CONS_ID", objUCFaturamento.CONS_ID);
                    cmd.Parameters.AddWithValue("?ZONA", objUCFaturamento.ZONA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?LIVRO", objUCFaturamento.LIVRO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CONTA", objUCFaturamento.CONTA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?ROTA", objUCFaturamento.ROTA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?SITUACAO", objUCFaturamento.SITUACAO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?NOME", objUCFaturamento.NOME.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?GRUPO", objUCFaturamento.GRUPO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CLAS", objUCFaturamento.CLAS.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?TA", objUCFaturamento.TA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?DATA_LIGACAO", objUCFaturamento.DATA_LIGACAO);
                    cmd.Parameters.AddWithValue("?DATA_ENTRADA", objUCFaturamento.DATA_ENTRADA);
                    cmd.Parameters.AddWithValue("?FPFIXO", objUCFaturamento.FPFIXO);
                    cmd.Parameters.AddWithValue("?FINAL", objUCFaturamento.FINAL);
                    cmd.Parameters.AddWithValue("?IDCCEE", objUCFaturamento.IDCCEE);
                    cmd.Parameters.AddWithValue("?CARGA", objUCFaturamento.CARGA);
                    cmd.Parameters.AddWithValue("?LATITUDE", objUCFaturamento.LATITUDE.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?LONGITUDE", objUCFaturamento.LONGITUDE.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?AREA", objUCFaturamento.AREA);
                    cmd.Parameters.AddWithValue("?CICE", objUCFaturamento.CICE.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?TIPOUC", objUCFaturamento.TIPOUC.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CIRCUITO", objUCFaturamento.CIRCUITO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?REGIAO", objUCFaturamento.REGIAO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?TENSAO", objUCFaturamento.TENSAO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?FASE", objUCFaturamento.FASE.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?DIAVENC", objUCFaturamento.DIAVENC.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?IRR_HR_INI", objUCFaturamento.IRR_HR_INI.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?IRR_HR_FIM", objUCFaturamento.IRR_HR_FIM.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?BXRENDA", objUCFaturamento.BXRENDA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?AP_SAUDE", objUCFaturamento.AP_SAUDE.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?ESTUFA", objUCFaturamento.ESTUFA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?ALTA_TENSAO", objUCFaturamento.ALTA_TENSAO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?VECTOPROXMES", objUCFaturamento.VECTOPROXMES.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?FLG_AVISO_DEBITO", objUCFaturamento.FLG_AVISO_DEBITO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?PAGTO_GOVERNO", objUCFaturamento.PAGTO_GOVERNO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?LUZ_TODOS", objUCFaturamento.LUZ_TODOS.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?ISENTOREATIVO", objUCFaturamento.ISENTOREATIVO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?ISENTO", objUCFaturamento.ISENTO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?ICMS_ISENTO_DEMANDA", objUCFaturamento.ICMS_ISENTO_DEMANDA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?ICMS_DEMANDA_LIDA", objUCFaturamento.ICMS_DEMANDA_LIDA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?ICMS_DIFERIDO", objUCFaturamento.ICMS_DIFERIDO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?FLG_ALIQUOTADIF", objUCFaturamento.FLG_ALIQUOTADIF.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?ILUM", objUCFaturamento.ILUM.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?QH", objUCFaturamento.QH.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?ENCARGO", objUCFaturamento.ENCARGO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?VIP_COMERCIAL", objUCFaturamento.VIP_COMERCIAL.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?VIP_TECNICO", objUCFaturamento.VIP_TECNICO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?PAGTO_DUVIDOSO", objUCFaturamento.PAGTO_DUVIDOSO);
                    cmd.Parameters.AddWithValue("?LEITREATIVO", objUCFaturamento.LEITREATIVO);
                    cmd.Parameters.AddWithValue("?LEITDEMA", objUCFaturamento.LEITDEMA);
                    cmd.Parameters.AddWithValue("?ISENTO_ICMS_TUSD", objUCFaturamento.ISENTO_ICMS_TUSD);
                    cmd.Parameters.AddWithValue("?ENVIO_COB_JUDICIAL", objUCFaturamento.ENVIO_COB_JUDICIAL);
                    cmd.Parameters.AddWithValue("?BLOQUEA_SEG_VIA_FAT", objUCFaturamento.BLOQUEA_SEG_VIA_FAT);
                    cmd.Parameters.AddWithValue("?BLOQUEA_RELIGACAO", objUCFaturamento.BLOQUEA_RELIGACAO);
                    cmd.Parameters.AddWithValue("?TARIFA_BRANCA", objUCFaturamento.TARIFA_BRANCA);
                    cmd.Parameters.AddWithValue("?MICRO_GERACAO", objUCFaturamento.MICRO_GERACAO);
                    cmd.Parameters.AddWithValue("?IRRIGACAO_AQUICULTURA", objUCFaturamento.IRRIGACAO_AQUICULTURA);
                    cmd.Parameters.AddWithValue("?LIVRE_LEITURA_CONSUMO", objUCFaturamento.LIVRE_LEITURA_CONSUMO);
                    cmd.Parameters.AddWithValue("?LIVRE_VERDE", objUCFaturamento.LIVRE_VERDE);
                    cmd.Parameters.AddWithValue("?PARCIALMENTE_CATIVO", objUCFaturamento.PARCIALMENTE_CATIVO);
                    cmd.Parameters.AddWithValue("?LIVREESPECIAL", objUCFaturamento.LIVREESPECIAL);
                    cmd.Parameters.AddWithValue("?CONJUGE_FATURA", objUCFaturamento.CONJUGE_FATURA);
                    cmd.Parameters.AddWithValue("?ENVIO_EMAIL_FATURA", objUCFaturamento.ENVIO_EMAIL_FATURA);
                    cmd.Parameters.AddWithValue("?CONST", objUCFaturamento.CONST);

                    if (objUCFaturamento.GRUPO.Substring(0, 1) == "B")
                    {

                        cmd.Parameters.AddWithValue("?ULT_LEIT_KWH_P", objUCFaturamento.ULT_LEIT_KWH_P);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_KWH_I", objUCFaturamento.ULT_LEIT_KWH_I);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_KWH_FP", objUCFaturamento.ULT_LEIT_KWH_FP);
                        cmd.Parameters.AddWithValue("?KWH_RES_P", objUCFaturamento.KWH_RES_P);
                        cmd.Parameters.AddWithValue("?KWH_RES_I", objUCFaturamento.KWH_RES_I);
                        cmd.Parameters.AddWithValue("?KWH_RES_FP", objUCFaturamento.KWH_RES_FP);
                        cmd.Parameters.AddWithValue("?CONST_KWH_P", objUCFaturamento.CONST_KWH_P);
                        cmd.Parameters.AddWithValue("?CONST_KWH_I", objUCFaturamento.CONST_KWH_I);
                        cmd.Parameters.AddWithValue("?CONST_KWH_FP", objUCFaturamento.CONST_KWH_FP);
                        cmd.Parameters.AddWithValue("?ULT_CONS_KWH_P", objUCFaturamento.ULT_CONS_KWH_P);
                        cmd.Parameters.AddWithValue("?ULT_CONS_KWH_I", objUCFaturamento.ULT_CONS_KWH_I);
                        cmd.Parameters.AddWithValue("?ULT_CONS_KWH_FP", objUCFaturamento.ULT_CONS_KWH_FP);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_KVARH_P", objUCFaturamento.ULT_LEIT_KVARH_P);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_KVARH_I", objUCFaturamento.ULT_LEIT_KVARH_I);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_KVARH_FP", objUCFaturamento.ULT_LEIT_KVARH_FP);
                        cmd.Parameters.AddWithValue("?CONST_KVARH_P", objUCFaturamento.CONST_KVARH_P);
                        cmd.Parameters.AddWithValue("?CONST_KVARH_I", objUCFaturamento.CONST_KVARH_I);
                        cmd.Parameters.AddWithValue("?CONST_KVARH_FP", objUCFaturamento.CONST_KVARH_FP);
                        cmd.Parameters.AddWithValue("?ULT_CONS_KVARH_P", objUCFaturamento.ULT_CONS_KVARH_P);
                        cmd.Parameters.AddWithValue("?ULT_CONS_KVARH_I", objUCFaturamento.ULT_CONS_KVARH_I);
                        cmd.Parameters.AddWithValue("?ULT_CONS_KVARH_FP", objUCFaturamento.ULT_CONS_KVARH_FP);
                        cmd.Parameters.AddWithValue("?ULTLEIT_REVERSO_P", objUCFaturamento.ULTLEIT_REVERSO_P);
                        cmd.Parameters.AddWithValue("?ULTLEIT_REVERSO_I", objUCFaturamento.ULTLEIT_REVERSO_I);
                        cmd.Parameters.AddWithValue("?ULTLEIT_REVERSO_FP", objUCFaturamento.ULTLEIT_REVERSO_FP);
                        cmd.Parameters.AddWithValue("?KWH_REVERSO_RES_P", objUCFaturamento.KWH_REVERSO_RES_P);
                        cmd.Parameters.AddWithValue("?KWH_REVERSO_RES_I", objUCFaturamento.KWH_REVERSO_RES_I);
                        cmd.Parameters.AddWithValue("?KWH_REVERSO_RES_FP", objUCFaturamento.KWH_REVERSO_RES_FP);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_IRRIGANTE_P", objUCFaturamento.ULT_LEIT_IRRIGANTE_P);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_IRRIGANTE_I", objUCFaturamento.ULT_LEIT_IRRIGANTE_I);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_IRRIGANTE_FP", objUCFaturamento.ULT_LEIT_IRRIGANTE_FP);
                        cmd.Parameters.AddWithValue("?KWH_IRRIGANTE_RES_P", objUCFaturamento.KWH_IRRIGANTE_RES_P);
                        cmd.Parameters.AddWithValue("?KWH_IRRIGANTE_RES_I", objUCFaturamento.KWH_IRRIGANTE_RES_I);
                        cmd.Parameters.AddWithValue("?KWH_IRRIGANTE_RES_FP", objUCFaturamento.KWH_IRRIGANTE_RES_FP);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_DESLIGAMENTO_P", objUCFaturamento.ULT_LEIT_DESLIGAMENTO_P);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_DESLIGAMENTO_I", objUCFaturamento.ULT_LEIT_DESLIGAMENTO_I);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_DESLIGAMENTO_FP", objUCFaturamento.ULT_LEIT_DESLIGAMENTO_FP);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_CORTE_P", objUCFaturamento.ULT_LEIT_CORTE_P);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_CORTE_I", objUCFaturamento.ULT_LEIT_CORTE_I);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_CORTE_FP", objUCFaturamento.ULT_LEIT_CORTE_FP);

                    }

                    if (objUCFaturamento.GRUPO.Substring(0, 1) == "A")
                    {

                        cmd.Parameters.AddWithValue("?ULT_LEIT_KWH_P", objUCFaturamento.ULT_LEIT_KWH_P);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_KWH_FP", objUCFaturamento.ULT_LEIT_KWH_FP);
                        cmd.Parameters.AddWithValue("?KWH_RES_P", objUCFaturamento.KWH_RES_P);
                        cmd.Parameters.AddWithValue("?KWH_RES_FP", objUCFaturamento.KWH_RES_FP);
                        cmd.Parameters.AddWithValue("?CONST_KWH_P", objUCFaturamento.CONST_KWH_P);
                        cmd.Parameters.AddWithValue("?CONST_KWH_FP", objUCFaturamento.CONST_KWH_FP);
                        cmd.Parameters.AddWithValue("?ULT_CONS_KWH_P", objUCFaturamento.ULT_CONS_KWH_P);
                        cmd.Parameters.AddWithValue("?ULT_CONS_KWH_FP", objUCFaturamento.ULT_CONS_KWH_FP);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_KW_P", objUCFaturamento.ULT_LEIT_KW_P);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_KW_FP", objUCFaturamento.ULT_LEIT_KW_FP);
                        cmd.Parameters.AddWithValue("?CONST_KW_P", objUCFaturamento.CONST_KW_P);
                        cmd.Parameters.AddWithValue("?CONST_KW_FP", objUCFaturamento.CONST_KW_FP);
                        cmd.Parameters.AddWithValue("?ULT_CONS_KW_P", objUCFaturamento.ULT_CONS_KW_P);
                        cmd.Parameters.AddWithValue("?ULT_CONS_KW_FP", objUCFaturamento.ULT_CONS_KW_FP);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_KVARH_P", objUCFaturamento.ULT_LEIT_KVARH_P);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_KVARH_FP", objUCFaturamento.ULT_LEIT_KVARH_FP);
                        cmd.Parameters.AddWithValue("?CONST_KVARH_P", objUCFaturamento.CONST_KVARH_P);
                        cmd.Parameters.AddWithValue("?CONST_KVARH_FP", objUCFaturamento.CONST_KVARH_FP);
                        cmd.Parameters.AddWithValue("?ULT_CONS_KVARH_P", objUCFaturamento.ULT_CONS_KVARH_P);
                        cmd.Parameters.AddWithValue("?ULT_CONS_KVARH_FP", objUCFaturamento.ULT_CONS_KVARH_FP);
                        cmd.Parameters.AddWithValue("?ULTLEIT_REVERSO_P", objUCFaturamento.ULTLEIT_REVERSO_P);
                        cmd.Parameters.AddWithValue("?ULTLEIT_REVERSO_FP", objUCFaturamento.ULTLEIT_REVERSO_FP);
                        cmd.Parameters.AddWithValue("?KWH_REVERSO_RES_P", objUCFaturamento.KWH_REVERSO_RES_P);
                        cmd.Parameters.AddWithValue("?KWH_REVERSO_RES_FP", objUCFaturamento.KWH_REVERSO_RES_FP);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_IRRIGANTE_P", objUCFaturamento.ULT_LEIT_IRRIGANTE_P);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_IRRIGANTE_FP", objUCFaturamento.ULT_LEIT_IRRIGANTE_FP);
                        cmd.Parameters.AddWithValue("?KWH_IRRIGANTE_RES_P", objUCFaturamento.KWH_IRRIGANTE_RES_P);
                        cmd.Parameters.AddWithValue("?KWH_IRRIGANTE_RES_FP", objUCFaturamento.KWH_IRRIGANTE_RES_FP);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_DESLIGAMENTO_P", objUCFaturamento.ULT_LEIT_DESLIGAMENTO_P);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_DESLIGAMENTO_FP", objUCFaturamento.ULT_LEIT_DESLIGAMENTO_FP);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_CORTE_P", objUCFaturamento.ULT_LEIT_CORTE_P);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_CORTE_FP", objUCFaturamento.ULT_LEIT_CORTE_FP);

                    }

                    cmd.Parameters.AddWithValue("?CODEND", objUCFaturamento.CODEND.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?UF", objUCFaturamento.UF.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CEP", objUCFaturamento.CEP.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CIDADE", objUCFaturamento.CIDADE.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?DISTRITO", objUCFaturamento.DISTRITO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?BAIRRO", objUCFaturamento.BAIRRO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?END", objUCFaturamento.END.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?NUMERO", objUCFaturamento.NUMERO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?COMPLEMENT", objUCFaturamento.COMPLEMENT.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?LOTE", objUCFaturamento.LOTE.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?QUADRA", objUCFaturamento.QUADRA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?FONE", objUCFaturamento.FONE.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?BANCO", objUCFaturamento.BANCO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?AGENC", objUCFaturamento.AGENC.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CC", objUCFaturamento.CC.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?ENTREGA", objUCFaturamento.ENTREGA);
                    cmd.Parameters.AddWithValue("?CODEND_ENTREGA", objUCFaturamento.CODEND_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?UF_ENTREGA", objUCFaturamento.UF_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CEP_ENTREGA", objUCFaturamento.CEP_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CID_ENTREGA", objUCFaturamento.CID_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?DIS_ENTREGA", objUCFaturamento.DIS_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?BAI_ENTREGA", objUCFaturamento.BAI_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?END_ENTREGA", objUCFaturamento.END_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?NUM_ENTREGA", objUCFaturamento.NUM_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?COMPL_ENTREGA", objUCFaturamento.COMPL_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?LOT_ENTREGA", objUCFaturamento.LOT_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?QUA_ENTREGA", objUCFaturamento.QUA_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?PESSOA", objUCFaturamento.PESSOA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?RG", objUCFaturamento.RG.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CPF_CNPJ", objUCFaturamento.CPF_CNPJ.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?INSC", objUCFaturamento.INSC.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CNAE", objUCFaturamento.CNAE.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?IDCNAE", objUCFaturamento.IDCNAE.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?AGRUPA_ZONA", objUCFaturamento.AGRUPA_ZONA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?AGRUPA_LIVRO", objUCFaturamento.AGRUPA_LIVRO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?AGRUPA_CONTA", objUCFaturamento.AGRUPA_CONTA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?AGRUPA", objUCFaturamento.AGRUPA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?NUM", objUCFaturamento.NUM.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?ELETR", objUCFaturamento.ELETR.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?MEDKVARH", objUCFaturamento.MEDKVARH.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?MEDKW", objUCFaturamento.MEDKW);
                    cmd.Parameters.AddWithValue("?MEDKVARK", objUCFaturamento.MEDKVARK);
                    cmd.Parameters.AddWithValue("?MARCA", objUCFaturamento.MARCA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?MODELO", objUCFaturamento.MODELO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?DTAFABMEDIDOR", objUCFaturamento.DTAFABMEDIDOR);
                    cmd.Parameters.AddWithValue("?DTAINSTMEDIDOR", objUCFaturamento.DTAINSTMEDIDOR);
                    cmd.Parameters.AddWithValue("?LACRE", objUCFaturamento.LACRE.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?DISJUNTOR", objUCFaturamento.DISJUNTOR.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?TRANSF", objUCFaturamento.TRANSF.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?FASELIG", objUCFaturamento.FASELIG.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?IDCONDUTOR", objUCFaturamento.IDCONDUTOR);
                    cmd.Parameters.AddWithValue("?TIPO_MEDICAO", objUCFaturamento.TIPO_MEDICAO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?IDTIPO_PADRAO_MEDICAO", objUCFaturamento.IDTIPO_PADRAO_MEDICAO);
                    cmd.Parameters.AddWithValue("?IDCORRENTE", objUCFaturamento.IDCORRENTE);
                    cmd.Parameters.AddWithValue("?COMPRIMENTO_FIO", objUCFaturamento.COMPRIMENTO_FIO);
                    cmd.Parameters.AddWithValue("?IDALIMENTADOR", objUCFaturamento.IDALIMENTADOR);
                    cmd.Parameters.AddWithValue("?IDTIPO_MEDIDOR", objUCFaturamento.IDTIPO_MEDIDOR);
                    cmd.Parameters.AddWithValue("?COD_TIPO_MEDICAO", objUCFaturamento.COD_TIPO_MEDICAO);
                    cmd.Parameters.AddWithValue("?TC_RELACAO_PRIMARIA", objUCFaturamento.TC_RELACAO_PRIMARIA);
                    cmd.Parameters.AddWithValue("?TC_RELACAO_SECUNDARIA", objUCFaturamento.TC_RELACAO_SECUNDARIA);
                    cmd.Parameters.AddWithValue("?TP_RELACAO_PRIMARIA", objUCFaturamento.TP_RELACAO_PRIMARIA);
                    cmd.Parameters.AddWithValue("?TP_RELACAO_SECUNDARIA", objUCFaturamento.TP_RELACAO_SECUNDARIA);
                    cmd.Parameters.AddWithValue("?PERIODO_TESTE", objUCFaturamento.PERIODO_TESTE);
                    cmd.Parameters.AddWithValue("?INI_PERIODO_TESTE", objUCFaturamento.INI_PERIODO_TESTE);
                    cmd.Parameters.AddWithValue("?FIM_PERIODO_TESTE", objUCFaturamento.FIM_PERIODO_TESTE);
                    cmd.Parameters.AddWithValue("?DATA_CONTRATO_DEMANDA", objUCFaturamento.DATA_CONTRATO_DEMANDA);
                    cmd.Parameters.AddWithValue("?DEMANDA_CONTR", objUCFaturamento.DEMANDA_CONTR);
                    cmd.Parameters.AddWithValue("?DEM_CONTR_PONTA", objUCFaturamento.DEM_CONTR_PONTA);
                    cmd.Parameters.AddWithValue("?DEM_CONTR_FP", objUCFaturamento.DEM_CONTR_FP);
                    cmd.Parameters.AddWithValue("?DEMANDA_CONTR_ANTERIOR", objUCFaturamento.DEMANDA_CONTR_ANTERIOR);
                    cmd.Parameters.AddWithValue("?DEM_CONTR_PONTA_ANTERIOR", objUCFaturamento.DEM_CONTR_PONTA_ANTERIOR);
                    cmd.Parameters.AddWithValue("?DEM_CONTR_FP_ANTERIOR", objUCFaturamento.DEM_CONTR_FP_ANTERIOR);

                    if (objUCFaturamento.GRUPO.Substring(0, 1) == "B")
                    {
                        cmd.Parameters.AddWithValue("?ULTLEIT", objUCFaturamento.ULTLEIT);
                        cmd.Parameters.AddWithValue("?RESIDUO_CONSUMO", objUCFaturamento.RESIDUO_CONSUMO);
                    }

                    cmd.Parameters.AddWithValue("?ITENSESP", objUCFaturamento.ITENSESP.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?TP_LIGACAO", objUCFaturamento.TP_LIGACAO.ToString().ToUpper());


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

        public void Update(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "CODEND   = ?CODENDNEW , ";
                    vFILTER = vFILTER + "UF       = ?UF , ";
                    vFILTER = vFILTER + "CEP      = ?CEP , ";
                    vFILTER = vFILTER + "CIDADE   = ?CIDADE , ";
                    vFILTER = vFILTER + "DISTRITO = ?DISTRITO , ";
                    vFILTER = vFILTER + "BAIRRO   = ?BAIRRO , ";
                    vFILTER = vFILTER + "END      = ?END  ";
                    vAND = vAND + "AND CODEND   = ?CODEND  ";
                    vAND = vAND + "AND CONS_ID  = ?CONS_ID ";
                    vAND = vAND + "AND UNID_ID  = ?UNID_ID ";
                    vAND = vAND + "AND ZONA     = ?ZONA ";
                    vAND = vAND + "AND LIVRO    = ?LIVRO ";
                    vAND = vAND + "AND CONTA    = ?CONTA ";


                    cmd = new MySqlCommand(this.QueryUpdate);

                    cmd.Parameters.AddWithValue("?CODENDNEW", objUCFaturamento.CODEND_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?UF", objUCFaturamento.UF.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CEP", objUCFaturamento.CEP.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CIDADE", objUCFaturamento.CIDADE.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?DISTRITO", objUCFaturamento.DISTRITO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?BAIRRO", objUCFaturamento.BAIRRO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?END", objUCFaturamento.END.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CODEND", objUCFaturamento.CODEND.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CONS_ID", objUCFaturamento.CONS_ID);
                    cmd.Parameters.AddWithValue("?UNID_ID", objUCFaturamento.UNID_ID);
                    cmd.Parameters.AddWithValue("?ZONA", objUCFaturamento.ZONA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?LIVRO", objUCFaturamento.LIVRO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CONTA", objUCFaturamento.CONTA.ToString().ToUpper());


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

        public void Update_1(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "CODEND_ENTREGA   = ?CODEND_ENTREGANEW , ";
                    vFILTER = vFILTER + "UF_ENTREGA       = ?UF_ENTREGA , ";
                    vFILTER = vFILTER + "CEP_ENTREGA      = ?CEP_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 ";
                    vAND = vAND + "AND CODEND_ENTREGA   = ?CODEND_ENTREGA  ";
                    vAND = vAND + "AND CONS_ID  = ?CONS_ID ";
                    vAND = vAND + "AND UNID_ID  = ?UNID_ID ";
                    vAND = vAND + "AND ZONA     = ?ZONA ";
                    vAND = vAND + "AND LIVRO    = ?LIVRO ";
                    vAND = vAND + "AND CONTA    = ?CONTA";

                    cmd = new MySqlCommand(this.QueryUpdate);

                    cmd.Parameters.AddWithValue("?CODEND_ENTREGANEW", objUCFaturamento.CODEND.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?UF_ENTREGA", objUCFaturamento.UF_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CEP_ENTREGA", objUCFaturamento.CEP_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CID_ENTREGA", objUCFaturamento.CID_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?DIS_ENTREGA", objUCFaturamento.DIS_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?BAI_ENTREGA", objUCFaturamento.BAI_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?END_ENTREGA", objUCFaturamento.END_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CODEND_ENTREGA", objUCFaturamento.CODEND_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CONS_ID", objUCFaturamento.CONS_ID);
                    cmd.Parameters.AddWithValue("?UNID_ID", objUCFaturamento.UNID_ID);
                    cmd.Parameters.AddWithValue("?ZONA", objUCFaturamento.ZONA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?LIVRO", objUCFaturamento.LIVRO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CONTA", objUCFaturamento.CONTA.ToString().ToUpper());


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

        public void Update_2(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "REGIAO = ?REGIAO ";
                    vAND = vAND + "AND ZONA   = ?ZONA ";
                    vAND = vAND + "AND LIVRO  = ?LIVRO ";
                    vAND = vAND + "AND CONTA  = ?CONTA ";

                    cmd = new MySqlCommand(this.QueryUpdate);

                    cmd.Parameters.AddWithValue("?REGIAO", objUCFaturamento.REGIAO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?ZONA", objUCFaturamento.ZONA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?LIVRO", objUCFaturamento.LIVRO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CONTA", objUCFaturamento.CONTA.ToString().ToUpper());


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

        public void Update_3(entidadeUCFaturamento objUCFaturamento)
        {
            MySqlCommand cmd = null;

            IGerenciadorTransacao objGerenciadorTransacao = null;
            ConexaoBD objconexaoBD = null;

            try
            {
                objconexaoBD = new ConexaoBD();

                objconexaoBD.SetarConexaoBanco(TipoBDConexao.fat_BD);

                using (objGerenciadorTransacao = FabricaGerenciadorTransacao.GetGerenciador(TipoBDGerenciador.MySql))
                {
                    if (objUCFaturamento.GRUPO == "A")
                    {

                        vFILTER = vFILTER + "INSTAL       = ?INSTAL ,";
                        vFILTER = vFILTER + "MARCA = ?MARCA ,";
                        vFILTER = vFILTER + "MODELO =  ?MODELO ,";
                        vFILTER = vFILTER + "DISJUNTOR  = ?DISJUNTOR ,";
                        vFILTER = vFILTER + "FASELIG    = ?FASELIG ,";
                        vFILTER = vFILTER + "IDTIPO_MEDIDOR = ?IDTIPO_MEDIDOR ,";
                        vFILTER = vFILTER + "ELETR            = ?ELETR ,";
                        vFILTER = vFILTER + "MEDKW            = ?MEDKW ,";
                        vFILTER = vFILTER + "MEDKVARK          = ?MEDKVARK ,";
                        vFILTER = vFILTER + "CONST_CONSUMO     = ?CONST_CONSUMO ,";
                        vFILTER = vFILTER + "CONST_DEMANDA     = ?CONST_DEMANDA ,";
                        vFILTER = vFILTER + "CONST_KVARH       = ?CONST_KVARH ,";
                        vFILTER = vFILTER + "CONST_CONS_P     = ?CONST_CONS_P ,";
                        vFILTER = vFILTER + "CONST_CONS_FP    = ?CONST_CONS_FP ,";
                        vFILTER = vFILTER + "CONST_DEMANDA     = ?CONST_DEMANDA ,";
                        vFILTER = vFILTER + "CONST_DEMANDA_FP  = ?CONST_DEMANDA_FP ,";
                        vFILTER = vFILTER + "CONST_KVARH_P     = ?CONST_KVARH_P ,";
                        vFILTER = vFILTER + "CONST_KVARH_FP    = ?CONST_KVARH_FP ,";
                        vAND = vAND + "AND IDMEDIDOR =  ?IDMEDIDOR ";

                    }
                    else if (objUCFaturamento.GRUPO == "B")
                    {

                        vFILTER = vFILTER + "INSTAL       = ?INSTAL ,";
                        vFILTER = vFILTER + "MARCA = ?MARCA ,";
                        vFILTER = vFILTER + "MODELO =  ?MODELO ,";
                        vFILTER = vFILTER + "DISJUNTOR  = ?DISJUNTOR ,";
                        vFILTER = vFILTER + "FASELIG    = ?FASELIG ,";
                        vFILTER = vFILTER + "IDTIPO_MEDIDOR = ?IDTIPO_MEDIDOR ,";
                        vFILTER = vFILTER + "NUM            = ?NUM ,";
                        vFILTER = vFILTER + "MEDKVARH            = ?MEDKVARH ,";
                        vFILTER = vFILTER + "CONST          = ?CONST ";
                        vAND = vAND + "AND IDMEDIDOR =  ?IDMEDIDOR ";

                    }

                    cmd = new MySqlCommand(this.QueryUpdate);

                    if (objUCFaturamento.GRUPO == "A")
                    {

                        cmd.Parameters.AddWithValue("?INSTAL", objUCFaturamento.INSTAL.ToString().ToUpper());
                        cmd.Parameters.AddWithValue("?MARCA", objUCFaturamento.MARCA.ToString().ToUpper());
                        cmd.Parameters.AddWithValue("?MODELO", objUCFaturamento.MODELO.ToString().ToUpper());
                        cmd.Parameters.AddWithValue("?DISJUNTOR", objUCFaturamento.DISJUNTOR.ToString().ToUpper());
                        cmd.Parameters.AddWithValue("?FASELIG", objUCFaturamento.FASELIG.ToString().ToUpper());
                        cmd.Parameters.AddWithValue("?IDTIPO_MEDIDOR", objUCFaturamento.IDTIPO_MEDIDOR);
                        cmd.Parameters.AddWithValue("?ELETR", objUCFaturamento.ELETR.ToString().ToUpper());
                        cmd.Parameters.AddWithValue("?MEDKW", objUCFaturamento.MEDKW);
                        cmd.Parameters.AddWithValue("?MEDKVARK", objUCFaturamento.MEDKVARK);
                        cmd.Parameters.AddWithValue("?CONST_CONSUMO", objUCFaturamento.CONST_CONSUMO);
                        cmd.Parameters.AddWithValue("?CONST_DEMANDA", objUCFaturamento.CONST_DEMANDA);
                        cmd.Parameters.AddWithValue("?CONST_KVARH", objUCFaturamento.CONST_KVARH);
                        cmd.Parameters.AddWithValue("?CONST_CONS_P", objUCFaturamento.CONST_CONS_P);
                        cmd.Parameters.AddWithValue("?CONST_CONS_FP", objUCFaturamento.CONST_CONS_FP);
                        cmd.Parameters.AddWithValue("?CONST_DEMANDA", objUCFaturamento.CONST_DEMANDA);
                        cmd.Parameters.AddWithValue("?CONST_DEMANDA_FP", objUCFaturamento.CONST_DEMANDA_FP);
                        cmd.Parameters.AddWithValue("?CONST_KVARH_P", objUCFaturamento.CONST_KVARH_P);
                        cmd.Parameters.AddWithValue("?CONST_KVARH_FP", objUCFaturamento.CONST_KVARH_FP);
                        cmd.Parameters.AddWithValue("?IDMEDIDOR", objUCFaturamento.IDMEDIDOR);

                    }
                    else if (objUCFaturamento.GRUPO == "B")
                    {

                        cmd.Parameters.AddWithValue("?INSTAL", objUCFaturamento.INSTAL.ToString().ToUpper());
                        cmd.Parameters.AddWithValue("?MARCA", objUCFaturamento.MARCA.ToString().ToUpper());
                        cmd.Parameters.AddWithValue("?MODELO", objUCFaturamento.MODELO.ToString().ToUpper());
                        cmd.Parameters.AddWithValue("?DISJUNTOR", objUCFaturamento.DISJUNTOR.ToString().ToUpper());
                        cmd.Parameters.AddWithValue("?FASELIG", objUCFaturamento.FASELIG.ToString().ToUpper());
                        cmd.Parameters.AddWithValue("?IDTIPO_MEDIDOR", objUCFaturamento.IDTIPO_MEDIDOR);
                        cmd.Parameters.AddWithValue("?NUM", objUCFaturamento.NUM.ToString().ToUpper());
                        cmd.Parameters.AddWithValue("?MEDKVARH", objUCFaturamento.MEDKVARH.ToString().ToUpper());
                        cmd.Parameters.AddWithValue("?CONST", objUCFaturamento.CONST);
                        cmd.Parameters.AddWithValue("?IDMEDIDOR", objUCFaturamento.IDMEDIDOR);

                    }

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

        public void Update_4(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "CARGA   = ?CARGA ";
                    vAND = vAND + "AND UNID_ID =  ?UNID_ID ";

                    cmd = new MySqlCommand(this.QueryUpdate);

                    cmd.Parameters.AddWithValue("?CARGA", objUCFaturamento.CARGA);
                    cmd.Parameters.AddWithValue("?UNID_ID", objUCFaturamento.UNID_ID);


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




        public void Update_5(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "UNID_ID = ?UNID_ID  , ";
                    vFILTER = vFILTER + "CONS_ID = ?CONS_ID  , ";
                    vFILTER = vFILTER + "ZONA = ?ZONA  , ";
                    vFILTER = vFILTER + "LIVRO = ?LIVRO  , ";
                    vFILTER = vFILTER + "CONTA = ?CONTA  , ";
                    vFILTER = vFILTER + "ROTA = ?ROTA  , ";
                    vFILTER = vFILTER + "SEQUENCIA = ?SEQUENCIA  , ";
                    vFILTER = vFILTER + "SITUACAO = ?SITUACAO  , ";
                    vFILTER = vFILTER + "NOME = ?NOME  , ";
                    vFILTER = vFILTER + "GRUPO = ?GRUPO  , ";
                    vFILTER = vFILTER + "CLAS = ?CLAS  , ";
                    vFILTER = vFILTER + "TA = ?TA  , ";
                    vFILTER = vFILTER + "DATA_LIGACAO = ?DATA_LIGACAO  , ";
                    vFILTER = vFILTER + "DATA_ENTRADA = ?DATA_ENTRADA  , ";
                    vFILTER = vFILTER + "FPFIXO = ?FPFIXO  , ";
                    vFILTER = vFILTER + "FINAL = ?FINAL  , ";
                    vFILTER = vFILTER + "IDCCEE = ?IDCCEE  , ";
                    vFILTER = vFILTER + "CARGA = ?CARGA  ,";
                    vFILTER = vFILTER + "LATITUDE = ?LATITUDE  , ";
                    vFILTER = vFILTER + "LONGITUDE = ?LONGITUDE  , ";
                    vFILTER = vFILTER + "AREA = ?AREA  , ";
                    vFILTER = vFILTER + "CICE = ?CICE  , ";
                    vFILTER = vFILTER + "TIPOUC = ?TIPOUC  , ";
                    vFILTER = vFILTER + "CIRCUITO = ?CIRCUITO  , ";
                    vFILTER = vFILTER + "REGIAO = ?REGIAO  , ";
                    vFILTER = vFILTER + "TENSAO = ?TENSAO  , ";
                    vFILTER = vFILTER + "FASE = ?FASE  , ";
                    vFILTER = vFILTER + "DIAVENC = ?DIAVENC , ";
                    vFILTER = vFILTER + "IRR_HR_INI = ?IRR_HR_INI  , ";
                    vFILTER = vFILTER + "IRR_HR_FIM = ?IRR_HR_FIM  , ";
                    vFILTER = vFILTER + "BXRENDA = ?BXRENDA  , ";
                    vFILTER = vFILTER + "AP_SAUDE = ?AP_SAUDE  , ";
                    vFILTER = vFILTER + "ESTUFA = ?ESTUFA  , ";
                    vFILTER = vFILTER + "ALTA_TENSAO = ?ALTA_TENSAO  , ";
                    vFILTER = vFILTER + "VECTOPROXMES = ?VECTOPROXMES  , ";
                    vFILTER = vFILTER + "FLG_AVISO_DEBITO = ?FLG_AVISO_DEBITO  , ";
                    vFILTER = vFILTER + "PAGTO_GOVERNO = ?PAGTO_GOVERNO  , ";
                    vFILTER = vFILTER + "LUZ_TODOS = ?LUZ_TODOS  , ";
                    vFILTER = vFILTER + "ISENTOREATIVO = ?ISENTOREATIVO  , ";
                    vFILTER = vFILTER + "ISENTO = ?ISENTO  , ";
                    vFILTER = vFILTER + "ICMS_ISENTO_DEMANDA = ?ICMS_ISENTO_DEMANDA  , ";
                    vFILTER = vFILTER + "ICMS_DEMANDA_LIDA = ?ICMS_DEMANDA_LIDA  , ";
                    vFILTER = vFILTER + "ICMS_DIFERIDO = ?ICMS_DIFERIDO  , ";
                    vFILTER = vFILTER + "FLG_ALIQUOTADIF = ?FLG_ALIQUOTADIF  , ";
                    vFILTER = vFILTER + "ILUM = ?ILUM  , ";
                    vFILTER = vFILTER + "QH = ?QH  , ";
                    vFILTER = vFILTER + "ENCARGO = ?ENCARGO  , ";
                    vFILTER = vFILTER + "VIP_COMERCIAL = ?VIP_COMERCIAL  , ";
                    vFILTER = vFILTER + "VIP_TECNICO = ?VIP_TECNICO  , ";
                    vFILTER = vFILTER + "PAGTO_DUVIDOSO = ?PAGTO_DUVIDOSO  , ";
                    vFILTER = vFILTER + "LEITREATIVO = ?LEITREATIVO  , ";
                    vFILTER = vFILTER + "LEITDEMA = ?LEITDEMA  , ";
                    vFILTER = vFILTER + "ISENTO_ICMS_TUSD = ?ISENTO_ICMS_TUSD  , ";
                    vFILTER = vFILTER + "ENVIO_COB_JUDICIAL = ?ENVIO_COB_JUDICIAL  , ";
                    vFILTER = vFILTER + "BLOQUEA_SEG_VIA_FAT = ?BLOQUEA_SEG_VIA_FAT  , ";
                    vFILTER = vFILTER + "BLOQUEA_RELIGACAO = ?BLOQUEA_RELIGACAO  , ";
                    vFILTER = vFILTER + "TARIFA_BRANCA = ?TARIFA_BRANCA  , ";
                    vFILTER = vFILTER + "MICRO_GERACAO = ?MICRO_GERACAO  , ";
                    vFILTER = vFILTER + "IRRIGACAO_AQUICULTURA = ?IRRIGACAO_AQUICULTURA  , ";
                    vFILTER = vFILTER + "LIVRE_LEITURA_CONSUMO = ?LIVRE_LEITURA_CONSUMO  , ";
                    vFILTER = vFILTER + "LIVRE_VERDE = ?LIVRE_VERDE  , ";
                    vFILTER = vFILTER + "PARCIALMENTE_CATIVO = ?PARCIALMENTE_CATIVO  , ";
                    vFILTER = vFILTER + "LIVREESPECIAL = ?LIVREESPECIAL  , ";
                    vFILTER = vFILTER + "CONJUGE_FATURA = ?CONJUGE_FATURA  , ";
                    vFILTER = vFILTER + "ENVIO_EMAIL_FATURA = ?ENVIO_EMAIL_FATURA  , ";
                    vFILTER = vFILTER + "ISENTO_TAXA_CORREIO = ?ISENTO_TAXA_CORREIO  , ";
                    vFILTER = vFILTER + "CONST = ?CONST  , ";

                    if (objUCFaturamento.GRUPO.Substring(0, 1) == "B")
                    {

                        vFILTER = vFILTER + "ULT_LEIT_KWH_P = ?ULT_LEIT_KWH_P  , ";
                        vFILTER = vFILTER + "ULT_LEIT_KWH_I = ?ULT_LEIT_KWH_I  , ";
                        vFILTER = vFILTER + "ULT_LEIT_KWH_FP = ?ULT_LEIT_KWH_FP  , ";
                        vFILTER = vFILTER + "KWH_RES_P = ?KWH_RES_P  , ";
                        vFILTER = vFILTER + "KWH_RES_I = ?KWH_RES_I  , ";
                        vFILTER = vFILTER + "KWH_RES_FP = ?KWH_RES_FP  , ";
                        vFILTER = vFILTER + "CONST_KWH_P = ?CONST_KWH_P  , ";
                        vFILTER = vFILTER + "CONST_KWH_I = ?CONST_KWH_I  , ";
                        vFILTER = vFILTER + "CONST_KWH_FP = ?CONST_KWH_FP  , ";
                        vFILTER = vFILTER + "ULT_CONS_KWH_P = ?ULT_CONS_KWH_P  , ";
                        vFILTER = vFILTER + "ULT_CONS_KWH_I = ?ULT_CONS_KWH_I  , ";
                        vFILTER = vFILTER + "ULT_CONS_KWH_FP = ?ULT_CONS_KWH_FP  , ";
                        vFILTER = vFILTER + "ULT_LEIT_KVARH_P = ?ULT_LEIT_KVARH_P  , ";
                        vFILTER = vFILTER + "ULT_LEIT_KVARH_I = ?ULT_LEIT_KVARH_I  , ";
                        vFILTER = vFILTER + "ULT_LEIT_KVARH_FP = ?ULT_LEIT_KVARH_FP  , ";
                        vFILTER = vFILTER + "CONST_KVARH_P = ?CONST_KVARH_P  , ";
                        vFILTER = vFILTER + "CONST_KVARH_I = ?CONST_KVARH_I  , ";
                        vFILTER = vFILTER + "CONST_KVARH_FP = ?CONST_KVARH_FP  , ";
                        vFILTER = vFILTER + "ULT_CONS_KVARH_P = ?ULT_CONS_KVARH_P  , ";
                        vFILTER = vFILTER + "ULT_CONS_KVARH_I = ?ULT_CONS_KVARH_I  , ";
                        vFILTER = vFILTER + "ULT_CONS_KVARH_FP = ?ULT_CONS_KVARH_FP  , ";
                        vFILTER = vFILTER + "ULTLEIT_REVERSO_P = ?ULTLEIT_REVERSO_P  , ";
                        vFILTER = vFILTER + "ULTLEIT_REVERSO_I = ?ULTLEIT_REVERSO_I  , ";
                        vFILTER = vFILTER + "ULTLEIT_REVERSO_FP = ?ULTLEIT_REVERSO_FP  , ";
                        vFILTER = vFILTER + "KWH_REVERSO_RES_P = ?KWH_REVERSO_RES_P  , ";
                        vFILTER = vFILTER + "KWH_REVERSO_RES_I = ?KWH_REVERSO_RES_I  , ";
                        vFILTER = vFILTER + "KWH_REVERSO_RES_FP = ?KWH_REVERSO_RES_FP  , ";
                        vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_P = ?ULT_LEIT_IRRIGANTE_P  , ";
                        vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_I = ?ULT_LEIT_IRRIGANTE_I  , ";
                        vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_FP = ?ULT_LEIT_IRRIGANTE_FP  , ";
                        vFILTER = vFILTER + "KWH_IRRIGANTE_RES_P = ?KWH_IRRIGANTE_RES_P  , ";
                        vFILTER = vFILTER + "KWH_IRRIGANTE_RES_I = ?KWH_IRRIGANTE_RES_I  , ";
                        vFILTER = vFILTER + "KWH_IRRIGANTE_RES_FP = ?KWH_IRRIGANTE_RES_FP  , ";
                        vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_P = ?ULT_LEIT_DESLIGAMENTO_P  , ";
                        vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_I = ?ULT_LEIT_DESLIGAMENTO_I  , ";
                        vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_FP = ?ULT_LEIT_DESLIGAMENTO_FP  , ";
                        vFILTER = vFILTER + "ULT_LEIT_CORTE_P = ?ULT_LEIT_CORTE_P  , ";
                        vFILTER = vFILTER + "ULT_LEIT_CORTE_I = ?ULT_LEIT_CORTE_I  , ";
                        vFILTER = vFILTER + "ULT_LEIT_CORTE_FP = ?ULT_LEIT_CORTE_FP  , ";

                    }

                    if (objUCFaturamento.GRUPO.Substring(0, 1) == "A")
                    {

                        vFILTER = vFILTER + "ULT_LEIT_KWH_P  = ?ULT_LEIT_KWH_P  , ";
                        vFILTER = vFILTER + "ULT_LEIT_KWH_FP  = ?ULT_LEIT_KWH_FP  , ";
                        vFILTER = vFILTER + "KWH_RES_P  = ?KWH_RES_P  , ";
                        vFILTER = vFILTER + "KWH_RES_FP  = ?KWH_RES_FP  , ";
                        vFILTER = vFILTER + "CONST_KWH_P  = ?CONST_KWH_P  , ";
                        vFILTER = vFILTER + "CONST_KWH_FP  = ?CONST_KWH_FP  , ";
                        vFILTER = vFILTER + "ULT_CONS_KWH_P  = ?ULT_CONS_KWH_P  , ";
                        vFILTER = vFILTER + "ULT_CONS_KWH_FP  = ?ULT_CONS_KWH_FP  , ";
                        vFILTER = vFILTER + "ULT_LEIT_KW_P  = ?ULT_LEIT_KW_P  , ";
                        vFILTER = vFILTER + "ULT_LEIT_KW_FP  = ?ULT_LEIT_KW_FP  , ";
                        vFILTER = vFILTER + "CONST_KW_P  = ?CONST_KW_P  , ";
                        vFILTER = vFILTER + "CONST_KW_FP  = ?CONST_KW_FP  , ";
                        vFILTER = vFILTER + "ULT_CONS_KW_P  = ?ULT_CONS_KW_P  , ";
                        vFILTER = vFILTER + "ULT_CONS_KW_FP  = ?ULT_CONS_KW_FP  , ";
                        vFILTER = vFILTER + "ULT_LEIT_KVARH_P  = ?ULT_LEIT_KVARH_P  , ";
                        vFILTER = vFILTER + "ULT_LEIT_KVARH_FP  = ?ULT_LEIT_KVARH_FP  , ";
                        vFILTER = vFILTER + "CONST_KVARH_P  = ?CONST_KVARH_P  , ";
                        vFILTER = vFILTER + "CONST_KVARH_FP  = ?CONST_KVARH_FP  , ";
                        vFILTER = vFILTER + "ULT_CONS_KVARH_P  = ?ULT_CONS_KVARH_P  , ";
                        vFILTER = vFILTER + "ULT_CONS_KVARH_FP  = ?ULT_CONS_KVARH_FP  , ";
                        vFILTER = vFILTER + "ULTLEIT_REVERSO_P  = ?ULTLEIT_REVERSO_P  , ";
                        vFILTER = vFILTER + "ULTLEIT_REVERSO_FP  = ?ULTLEIT_REVERSO_FP  , ";
                        vFILTER = vFILTER + "KWH_REVERSO_RES_P  = ?KWH_REVERSO_RES_P  , ";
                        vFILTER = vFILTER + "KWH_REVERSO_RES_FP  = ?KWH_REVERSO_RES_FP  , ";
                        vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_P  = ?ULT_LEIT_IRRIGANTE_P  , ";
                        vFILTER = vFILTER + "ULT_LEIT_IRRIGANTE_FP  = ?ULT_LEIT_IRRIGANTE_FP  , ";
                        vFILTER = vFILTER + "KWH_IRRIGANTE_RES_P  = ?KWH_IRRIGANTE_RES_P  , ";
                        vFILTER = vFILTER + "KWH_IRRIGANTE_RES_FP  = ?KWH_IRRIGANTE_RES_FP  , ";
                        vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_P  = ?ULT_LEIT_DESLIGAMENTO_P  , ";
                        vFILTER = vFILTER + "ULT_LEIT_DESLIGAMENTO_FP  = ?ULT_LEIT_DESLIGAMENTO_FP  , ";
                        vFILTER = vFILTER + "ULT_LEIT_CORTE_P  = ?ULT_LEIT_CORTE_P  , ";
                        vFILTER = vFILTER + "ULT_LEIT_CORTE_FP  = ?ULT_LEIT_CORTE_FP  , ";

                    }

                    vFILTER = vFILTER + "CODEND  = ?CODEND  , ";
                    vFILTER = vFILTER + "UF  = ?UF  , ";
                    vFILTER = vFILTER + "CEP  = ?CEP  , ";
                    vFILTER = vFILTER + "CIDADE  = ?CIDADE  , ";
                    vFILTER = vFILTER + "DISTRITO  = ?DISTRITO  , ";
                    vFILTER = vFILTER + "BAIRRO  = ?BAIRRO  , ";
                    vFILTER = vFILTER + "END  = ?END  , ";
                    vFILTER = vFILTER + "NUMERO  = ?NUMERO  , ";
                    vFILTER = vFILTER + "COMPLEMENT  = ?COMPLEMENT  , ";
                    vFILTER = vFILTER + "LOTE  = ?LOTE  , ";
                    vFILTER = vFILTER + "QUADRA  = ?QUADRA  , ";
                    vFILTER = vFILTER + "FONE  = ?FONE  , ";
                    vFILTER = vFILTER + "BANCO  = ?BANCO  , ";
                    vFILTER = vFILTER + "AGENC  = ?AGENC  , ";
                    vFILTER = vFILTER + "CC  = ?CC  , ";
                    vFILTER = vFILTER + "ENTREGA  = ?ENTREGA  , ";
                    vFILTER = vFILTER + "CODEND_ENTREGA  = ?CODEND_ENTREGA  , ";
                    vFILTER = vFILTER + "UF_ENTREGA  = ?UF_ENTREGA  , ";
                    vFILTER = vFILTER + "CEP_ENTREGA  = ?CEP_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 + "LOT_ENTREGA  = ?LOT_ENTREGA  , ";
                    vFILTER = vFILTER + "QUA_ENTREGA  = ?QUA_ENTREGA  , ";
                    vFILTER = vFILTER + "PESSOA  = ?PESSOA  , ";
                    vFILTER = vFILTER + "RG  = ?RG  , ";
                    vFILTER = vFILTER + "CPF_CNPJ  = ?CPF_CNPJ  , ";
                    vFILTER = vFILTER + "INSC  = ?INSC  , ";
                    vFILTER = vFILTER + "CNAE  = ?CNAE  , ";
                    vFILTER = vFILTER + "IDCNAE  = ?IDCNAE  , ";
                    vFILTER = vFILTER + "AGRUPA_ZONA  = ?AGRUPA_ZONA  , ";
                    vFILTER = vFILTER + "AGRUPA_LIVRO  = ?AGRUPA_LIVRO  , ";
                    vFILTER = vFILTER + "AGRUPA_CONTA  = ?AGRUPA_CONTA  , ";
                    vFILTER = vFILTER + "AGRUPA  = ?AGRUPA  , ";
                    vFILTER = vFILTER + "NUM  = ?NUM  , ";
                    vFILTER = vFILTER + "ELETR  = ?ELETR  , ";
                    vFILTER = vFILTER + "MEDKVARH  = ?MEDKVARH  , ";
                    vFILTER = vFILTER + "MEDKW  = ?MEDKW  , ";
                    vFILTER = vFILTER + "MEDKVARK  = ?MEDKVARK  , ";
                    vFILTER = vFILTER + "MARCA  = ?MARCA  , ";
                    vFILTER = vFILTER + "MODELO  = ?MODELO  , ";
                    vFILTER = vFILTER + "DTAFABMEDIDOR  = ?DTAFABMEDIDOR  , ";
                    vFILTER = vFILTER + "DTAINSTMEDIDOR  = ?DTAINSTMEDIDOR  , ";
                    vFILTER = vFILTER + "LACRE  = ?LACRE  , ";
                    vFILTER = vFILTER + "DISJUNTOR  = ?DISJUNTOR  , ";
                    vFILTER = vFILTER + "TRANSF  = ?TRANSF  , ";
                    vFILTER = vFILTER + "FASELIG  = ?FASELIG  , ";
                    vFILTER = vFILTER + "IDCONDUTOR  = ?IDCONDUTOR  , ";
                    vFILTER = vFILTER + "TIPO_MEDICAO  = ?TIPO_MEDICAO  , ";
                    vFILTER = vFILTER + "IDTIPO_PADRAO_MEDICAO  = ?IDTIPO_PADRAO_MEDICAO  , ";
                    vFILTER = vFILTER + "IDCORRENTE  = ?IDCORRENTE  , ";
                    vFILTER = vFILTER + "COMPRIMENTO_FIO  = ?COMPRIMENTO_FIO  , ";
                    vFILTER = vFILTER + "IDALIMENTADOR  = ?IDALIMENTADOR  , ";
                    vFILTER = vFILTER + "IDTIPO_MEDIDOR  = ?IDTIPO_MEDIDOR  , ";
                    vFILTER = vFILTER + "COD_TIPO_MEDICAO  = ?COD_TIPO_MEDICAO  , ";
                    vFILTER = vFILTER + "TC_RELACAO_PRIMARIA  = ?TC_RELACAO_PRIMARIA  , ";
                    vFILTER = vFILTER + "TC_RELACAO_SECUNDARIA  = ?TC_RELACAO_SECUNDARIA  , ";
                    vFILTER = vFILTER + "TP_RELACAO_PRIMARIA  = ?TP_RELACAO_PRIMARIA  , ";
                    vFILTER = vFILTER + "TP_RELACAO_SECUNDARIA  = ?TP_RELACAO_SECUNDARIA  , ";
                    vFILTER = vFILTER + "PERIODO_TESTE  = ?PERIODO_TESTE  , ";
                    vFILTER = vFILTER + "INI_PERIODO_TESTE  = ?INI_PERIODO_TESTE  , ";
                    vFILTER = vFILTER + "FIM_PERIODO_TESTE  = ?FIM_PERIODO_TESTE  , ";
                    vFILTER = vFILTER + "DATA_CONTRATO_DEMANDA  = ?DATA_CONTRATO_DEMANDA  , ";
                    vFILTER = vFILTER + "DEMANDA_CONTR  = ?DEMANDA_CONTR  , ";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA  = ?DEM_CONTR_PONTA  , ";
                    vFILTER = vFILTER + "DEM_CONTR_FP  = ?DEM_CONTR_FP  , ";
                    vFILTER = vFILTER + "DEMANDA_CONTR_ANTERIOR  = ?DEMANDA_CONTR_ANTERIOR  , ";
                    vFILTER = vFILTER + "DEM_CONTR_PONTA_ANTERIOR  = ?DEM_CONTR_PONTA_ANTERIOR  , ";
                    vFILTER = vFILTER + "DEM_CONTR_FP_ANTERIOR  = ?DEM_CONTR_FP_ANTERIOR  , ";

                    if (objUCFaturamento.GRUPO.Substring(0, 1) == "B")
                    {
                        vFILTER = vFILTER + "ULTLEIT  = ?ULTLEIT  , ";
                        vFILTER = vFILTER + "RESIDUO_CONSUMO  = ?RESIDUO_CONSUMO  , ";
                    }

                    vFILTER = vFILTER + "ITENSESP  = ?ITENSESP  , ";
                    vFILTER = vFILTER + "TP_LIGACAO  = ?TP_LIGACAO   ";

                    vAND = vAND + "AND ID = ?ID   ";

                    cmd = new MySqlCommand(this.QueryUpdate);

                    cmd.Parameters.AddWithValue("?UNID_ID", objUCFaturamento.UNID_ID);
                    cmd.Parameters.AddWithValue("?CONS_ID", objUCFaturamento.CONS_ID);
                    cmd.Parameters.AddWithValue("?ZONA", objUCFaturamento.ZONA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?LIVRO", objUCFaturamento.LIVRO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CONTA", objUCFaturamento.CONTA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?ROTA", objUCFaturamento.ROTA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?SEQUENCIA", objUCFaturamento.SEQUENCIA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?SITUACAO", objUCFaturamento.SITUACAO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?NOME", objUCFaturamento.NOME.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?GRUPO", objUCFaturamento.GRUPO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CLAS", objUCFaturamento.CLAS.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?TA", objUCFaturamento.TA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?DATA_LIGACAO", objUCFaturamento.DATA_LIGACAO);
                    cmd.Parameters.AddWithValue("?DATA_ENTRADA", objUCFaturamento.DATA_ENTRADA);
                    cmd.Parameters.AddWithValue("?FPFIXO", objUCFaturamento.FPFIXO);
                    cmd.Parameters.AddWithValue("?FINAL", objUCFaturamento.FINAL);
                    cmd.Parameters.AddWithValue("?IDCCEE", objUCFaturamento.IDCCEE);
                    cmd.Parameters.AddWithValue("?CARGA", objUCFaturamento.CARGA);
                    cmd.Parameters.AddWithValue("?LATITUDE", objUCFaturamento.LATITUDE.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?LONGITUDE", objUCFaturamento.LONGITUDE.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?AREA", objUCFaturamento.AREA);
                    cmd.Parameters.AddWithValue("?CICE", objUCFaturamento.CICE.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?TIPOUC", objUCFaturamento.TIPOUC.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CIRCUITO", objUCFaturamento.CIRCUITO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?REGIAO", objUCFaturamento.REGIAO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?TENSAO", objUCFaturamento.TENSAO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?FASE", objUCFaturamento.FASE.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?DIAVENC", objUCFaturamento.DIAVENC.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?IRR_HR_INI", objUCFaturamento.IRR_HR_INI.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?IRR_HR_FIM", objUCFaturamento.IRR_HR_FIM.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?BXRENDA", objUCFaturamento.BXRENDA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?AP_SAUDE", objUCFaturamento.AP_SAUDE.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?ESTUFA", objUCFaturamento.ESTUFA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?ALTA_TENSAO", objUCFaturamento.ALTA_TENSAO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?VECTOPROXMES", objUCFaturamento.VECTOPROXMES.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?FLG_AVISO_DEBITO", objUCFaturamento.FLG_AVISO_DEBITO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?PAGTO_GOVERNO", objUCFaturamento.PAGTO_GOVERNO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?LUZ_TODOS", objUCFaturamento.LUZ_TODOS.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?ISENTOREATIVO", objUCFaturamento.ISENTOREATIVO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?ISENTO", objUCFaturamento.ISENTO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?ICMS_ISENTO_DEMANDA", objUCFaturamento.ICMS_ISENTO_DEMANDA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?ICMS_DEMANDA_LIDA", objUCFaturamento.ICMS_DEMANDA_LIDA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?ICMS_DIFERIDO", objUCFaturamento.ICMS_DIFERIDO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?FLG_ALIQUOTADIF", objUCFaturamento.FLG_ALIQUOTADIF.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?ILUM", objUCFaturamento.ILUM.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?QH", objUCFaturamento.QH.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?ENCARGO", objUCFaturamento.ENCARGO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?VIP_COMERCIAL", objUCFaturamento.VIP_COMERCIAL.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?VIP_TECNICO", objUCFaturamento.VIP_TECNICO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?PAGTO_DUVIDOSO", objUCFaturamento.PAGTO_DUVIDOSO);
                    cmd.Parameters.AddWithValue("?LEITREATIVO", objUCFaturamento.LEITREATIVO);
                    cmd.Parameters.AddWithValue("?LEITDEMA", objUCFaturamento.LEITDEMA);
                    cmd.Parameters.AddWithValue("?ISENTO_ICMS_TUSD", objUCFaturamento.ISENTO_ICMS_TUSD);
                    cmd.Parameters.AddWithValue("?ENVIO_COB_JUDICIAL", objUCFaturamento.ENVIO_COB_JUDICIAL);
                    cmd.Parameters.AddWithValue("?BLOQUEA_SEG_VIA_FAT", objUCFaturamento.BLOQUEA_SEG_VIA_FAT);
                    cmd.Parameters.AddWithValue("?BLOQUEA_RELIGACAO", objUCFaturamento.BLOQUEA_RELIGACAO);
                    cmd.Parameters.AddWithValue("?TARIFA_BRANCA", objUCFaturamento.TARIFA_BRANCA);
                    cmd.Parameters.AddWithValue("?MICRO_GERACAO", objUCFaturamento.MICRO_GERACAO);
                    cmd.Parameters.AddWithValue("?IRRIGACAO_AQUICULTURA", objUCFaturamento.IRRIGACAO_AQUICULTURA);
                    cmd.Parameters.AddWithValue("?LIVRE_LEITURA_CONSUMO", objUCFaturamento.LIVRE_LEITURA_CONSUMO);
                    cmd.Parameters.AddWithValue("?LIVRE_VERDE", objUCFaturamento.LIVRE_VERDE);
                    cmd.Parameters.AddWithValue("?PARCIALMENTE_CATIVO", objUCFaturamento.PARCIALMENTE_CATIVO);
                    cmd.Parameters.AddWithValue("?LIVREESPECIAL", objUCFaturamento.LIVREESPECIAL);
                    cmd.Parameters.AddWithValue("?CONJUGE_FATURA", objUCFaturamento.CONJUGE_FATURA);
                    cmd.Parameters.AddWithValue("?ENVIO_EMAIL_FATURA", objUCFaturamento.ENVIO_EMAIL_FATURA);
                    cmd.Parameters.AddWithValue("?ISENTO_TAXA_CORREIO", objUCFaturamento.ISENTO_TAXA_CORREIO);
                    cmd.Parameters.AddWithValue("?CONST", objUCFaturamento.CONST);

                    if (objUCFaturamento.GRUPO.Substring(0, 1) == "B")
                    {

                        cmd.Parameters.AddWithValue("?ULT_LEIT_KWH_P", objUCFaturamento.ULT_LEIT_KWH_P);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_KWH_I", objUCFaturamento.ULT_LEIT_KWH_I);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_KWH_FP", objUCFaturamento.ULT_LEIT_KWH_FP);
                        cmd.Parameters.AddWithValue("?KWH_RES_P", objUCFaturamento.KWH_RES_P);
                        cmd.Parameters.AddWithValue("?KWH_RES_I", objUCFaturamento.KWH_RES_I);
                        cmd.Parameters.AddWithValue("?KWH_RES_FP", objUCFaturamento.KWH_RES_FP);
                        cmd.Parameters.AddWithValue("?CONST_KWH_P", objUCFaturamento.CONST_KWH_P);
                        cmd.Parameters.AddWithValue("?CONST_KWH_I", objUCFaturamento.CONST_KWH_I);
                        cmd.Parameters.AddWithValue("?CONST_KWH_FP", objUCFaturamento.CONST_KWH_FP);
                        cmd.Parameters.AddWithValue("?ULT_CONS_KWH_P", objUCFaturamento.ULT_CONS_KWH_P);
                        cmd.Parameters.AddWithValue("?ULT_CONS_KWH_I", objUCFaturamento.ULT_CONS_KWH_I);
                        cmd.Parameters.AddWithValue("?ULT_CONS_KWH_FP", objUCFaturamento.ULT_CONS_KWH_FP);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_KVARH_P", objUCFaturamento.ULT_LEIT_KVARH_P);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_KVARH_I", objUCFaturamento.ULT_LEIT_KVARH_I);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_KVARH_FP", objUCFaturamento.ULT_LEIT_KVARH_FP);
                        cmd.Parameters.AddWithValue("?CONST_KVARH_P", objUCFaturamento.CONST_KVARH_P);
                        cmd.Parameters.AddWithValue("?CONST_KVARH_I", objUCFaturamento.CONST_KVARH_I);
                        cmd.Parameters.AddWithValue("?CONST_KVARH_FP", objUCFaturamento.CONST_KVARH_FP);
                        cmd.Parameters.AddWithValue("?ULT_CONS_KVARH_P", objUCFaturamento.ULT_CONS_KVARH_P);
                        cmd.Parameters.AddWithValue("?ULT_CONS_KVARH_I", objUCFaturamento.ULT_CONS_KVARH_I);
                        cmd.Parameters.AddWithValue("?ULT_CONS_KVARH_FP", objUCFaturamento.ULT_CONS_KVARH_FP);
                        cmd.Parameters.AddWithValue("?ULTLEIT_REVERSO_P", objUCFaturamento.ULTLEIT_REVERSO_P);
                        cmd.Parameters.AddWithValue("?ULTLEIT_REVERSO_I", objUCFaturamento.ULTLEIT_REVERSO_I);
                        cmd.Parameters.AddWithValue("?ULTLEIT_REVERSO_FP", objUCFaturamento.ULTLEIT_REVERSO_FP);
                        cmd.Parameters.AddWithValue("?KWH_REVERSO_RES_P", objUCFaturamento.KWH_REVERSO_RES_P);
                        cmd.Parameters.AddWithValue("?KWH_REVERSO_RES_I", objUCFaturamento.KWH_REVERSO_RES_I);
                        cmd.Parameters.AddWithValue("?KWH_REVERSO_RES_FP", objUCFaturamento.KWH_REVERSO_RES_FP);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_IRRIGANTE_P", objUCFaturamento.ULT_LEIT_IRRIGANTE_P);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_IRRIGANTE_I", objUCFaturamento.ULT_LEIT_IRRIGANTE_I);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_IRRIGANTE_FP", objUCFaturamento.ULT_LEIT_IRRIGANTE_FP);
                        cmd.Parameters.AddWithValue("?KWH_IRRIGANTE_RES_P", objUCFaturamento.KWH_IRRIGANTE_RES_P);
                        cmd.Parameters.AddWithValue("?KWH_IRRIGANTE_RES_I", objUCFaturamento.KWH_IRRIGANTE_RES_I);
                        cmd.Parameters.AddWithValue("?KWH_IRRIGANTE_RES_FP", objUCFaturamento.KWH_IRRIGANTE_RES_FP);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_DESLIGAMENTO_P", objUCFaturamento.ULT_LEIT_DESLIGAMENTO_P);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_DESLIGAMENTO_I", objUCFaturamento.ULT_LEIT_DESLIGAMENTO_I);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_DESLIGAMENTO_FP", objUCFaturamento.ULT_LEIT_DESLIGAMENTO_FP);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_CORTE_P", objUCFaturamento.ULT_LEIT_CORTE_P);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_CORTE_I", objUCFaturamento.ULT_LEIT_CORTE_I);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_CORTE_FP", objUCFaturamento.ULT_LEIT_CORTE_FP);

                    }

                    if (objUCFaturamento.GRUPO.Substring(0, 1) == "A")
                    {

                        cmd.Parameters.AddWithValue("?ULT_LEIT_KWH_P", objUCFaturamento.ULT_LEIT_KWH_P);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_KWH_FP", objUCFaturamento.ULT_LEIT_KWH_FP);
                        cmd.Parameters.AddWithValue("?KWH_RES_P", objUCFaturamento.KWH_RES_P);
                        cmd.Parameters.AddWithValue("?KWH_RES_FP", objUCFaturamento.KWH_RES_FP);
                        cmd.Parameters.AddWithValue("?CONST_KWH_P", objUCFaturamento.CONST_KWH_P);
                        cmd.Parameters.AddWithValue("?CONST_KWH_FP", objUCFaturamento.CONST_KWH_FP);
                        cmd.Parameters.AddWithValue("?ULT_CONS_KWH_P", objUCFaturamento.ULT_CONS_KWH_P);
                        cmd.Parameters.AddWithValue("?ULT_CONS_KWH_FP", objUCFaturamento.ULT_CONS_KWH_FP);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_KW_P", objUCFaturamento.ULT_LEIT_KW_P);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_KW_FP", objUCFaturamento.ULT_LEIT_KW_FP);
                        cmd.Parameters.AddWithValue("?CONST_KW_P", objUCFaturamento.CONST_KW_P);
                        cmd.Parameters.AddWithValue("?CONST_KW_FP", objUCFaturamento.CONST_KW_FP);
                        cmd.Parameters.AddWithValue("?ULT_CONS_KW_P", objUCFaturamento.ULT_CONS_KW_P);
                        cmd.Parameters.AddWithValue("?ULT_CONS_KW_FP", objUCFaturamento.ULT_CONS_KW_FP);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_KVARH_P", objUCFaturamento.ULT_LEIT_KVARH_P);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_KVARH_FP", objUCFaturamento.ULT_LEIT_KVARH_FP);
                        cmd.Parameters.AddWithValue("?CONST_KVARH_P", objUCFaturamento.CONST_KVARH_P);
                        cmd.Parameters.AddWithValue("?CONST_KVARH_FP", objUCFaturamento.CONST_KVARH_FP);
                        cmd.Parameters.AddWithValue("?ULT_CONS_KVARH_P", objUCFaturamento.ULT_CONS_KVARH_P);
                        cmd.Parameters.AddWithValue("?ULT_CONS_KVARH_FP", objUCFaturamento.ULT_CONS_KVARH_FP);
                        cmd.Parameters.AddWithValue("?ULTLEIT_REVERSO_P", objUCFaturamento.ULTLEIT_REVERSO_P);
                        cmd.Parameters.AddWithValue("?ULTLEIT_REVERSO_FP", objUCFaturamento.ULTLEIT_REVERSO_FP);
                        cmd.Parameters.AddWithValue("?KWH_REVERSO_RES_P", objUCFaturamento.KWH_REVERSO_RES_P);
                        cmd.Parameters.AddWithValue("?KWH_REVERSO_RES_FP", objUCFaturamento.KWH_REVERSO_RES_FP);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_IRRIGANTE_P", objUCFaturamento.ULT_LEIT_IRRIGANTE_P);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_IRRIGANTE_FP", objUCFaturamento.ULT_LEIT_IRRIGANTE_FP);
                        cmd.Parameters.AddWithValue("?KWH_IRRIGANTE_RES_P", objUCFaturamento.KWH_IRRIGANTE_RES_P);
                        cmd.Parameters.AddWithValue("?KWH_IRRIGANTE_RES_FP", objUCFaturamento.KWH_IRRIGANTE_RES_FP);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_DESLIGAMENTO_P", objUCFaturamento.ULT_LEIT_DESLIGAMENTO_P);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_DESLIGAMENTO_FP", objUCFaturamento.ULT_LEIT_DESLIGAMENTO_FP);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_CORTE_P", objUCFaturamento.ULT_LEIT_CORTE_P);
                        cmd.Parameters.AddWithValue("?ULT_LEIT_CORTE_FP", objUCFaturamento.ULT_LEIT_CORTE_FP);

                    }

                    cmd.Parameters.AddWithValue("?CODEND", objUCFaturamento.CODEND.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?UF", objUCFaturamento.UF.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CEP", objUCFaturamento.CEP.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CIDADE", objUCFaturamento.CIDADE.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?DISTRITO", objUCFaturamento.DISTRITO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?BAIRRO", objUCFaturamento.BAIRRO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?END", objUCFaturamento.END.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?NUMERO", objUCFaturamento.NUMERO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?COMPLEMENT", objUCFaturamento.COMPLEMENT.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?LOTE", objUCFaturamento.LOTE.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?QUADRA", objUCFaturamento.QUADRA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?FONE", objUCFaturamento.FONE.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?BANCO", objUCFaturamento.BANCO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?AGENC", objUCFaturamento.AGENC.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CC", objUCFaturamento.CC.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?ENTREGA", objUCFaturamento.ENTREGA);
                    cmd.Parameters.AddWithValue("?CODEND_ENTREGA", objUCFaturamento.CODEND_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?UF_ENTREGA", objUCFaturamento.UF_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CEP_ENTREGA", objUCFaturamento.CEP_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CID_ENTREGA", objUCFaturamento.CID_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?DIS_ENTREGA", objUCFaturamento.DIS_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?BAI_ENTREGA", objUCFaturamento.BAI_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?END_ENTREGA", objUCFaturamento.END_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?NUM_ENTREGA", objUCFaturamento.NUM_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?COMPL_ENTREGA", objUCFaturamento.COMPL_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?LOT_ENTREGA", objUCFaturamento.LOT_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?QUA_ENTREGA", objUCFaturamento.QUA_ENTREGA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?PESSOA", objUCFaturamento.PESSOA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?RG", objUCFaturamento.RG.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CPF_CNPJ", objUCFaturamento.CPF_CNPJ.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?INSC", objUCFaturamento.INSC.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CNAE", objUCFaturamento.CNAE.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?IDCNAE", objUCFaturamento.IDCNAE.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?AGRUPA_ZONA", objUCFaturamento.AGRUPA_ZONA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?AGRUPA_LIVRO", objUCFaturamento.AGRUPA_LIVRO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?AGRUPA_CONTA", objUCFaturamento.AGRUPA_CONTA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?AGRUPA", objUCFaturamento.AGRUPA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?NUM", objUCFaturamento.NUM.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?ELETR", objUCFaturamento.ELETR.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?MEDKVARH", objUCFaturamento.MEDKVARH.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?MEDKW", objUCFaturamento.MEDKW);
                    cmd.Parameters.AddWithValue("?MEDKVARK", objUCFaturamento.MEDKVARK);
                    cmd.Parameters.AddWithValue("?MARCA", objUCFaturamento.MARCA.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?MODELO", objUCFaturamento.MODELO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?DTAFABMEDIDOR", objUCFaturamento.DTAFABMEDIDOR);
                    cmd.Parameters.AddWithValue("?DTAINSTMEDIDOR", objUCFaturamento.DTAINSTMEDIDOR);
                    cmd.Parameters.AddWithValue("?LACRE", objUCFaturamento.LACRE.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?DISJUNTOR", objUCFaturamento.DISJUNTOR.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?TRANSF", objUCFaturamento.TRANSF.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?FASELIG", objUCFaturamento.FASELIG.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?IDCONDUTOR", objUCFaturamento.IDCONDUTOR);
                    cmd.Parameters.AddWithValue("?TIPO_MEDICAO", objUCFaturamento.TIPO_MEDICAO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?IDTIPO_PADRAO_MEDICAO", objUCFaturamento.IDTIPO_PADRAO_MEDICAO);
                    cmd.Parameters.AddWithValue("?IDCORRENTE", objUCFaturamento.IDCORRENTE);
                    cmd.Parameters.AddWithValue("?COMPRIMENTO_FIO", objUCFaturamento.COMPRIMENTO_FIO);
                    cmd.Parameters.AddWithValue("?IDALIMENTADOR", objUCFaturamento.IDALIMENTADOR);
                    cmd.Parameters.AddWithValue("?IDTIPO_MEDIDOR", objUCFaturamento.IDTIPO_MEDIDOR);
                    cmd.Parameters.AddWithValue("?COD_TIPO_MEDICAO", objUCFaturamento.COD_TIPO_MEDICAO);
                    cmd.Parameters.AddWithValue("?TC_RELACAO_PRIMARIA", objUCFaturamento.TC_RELACAO_PRIMARIA);
                    cmd.Parameters.AddWithValue("?TC_RELACAO_SECUNDARIA", objUCFaturamento.TC_RELACAO_SECUNDARIA);
                    cmd.Parameters.AddWithValue("?TP_RELACAO_PRIMARIA", objUCFaturamento.TP_RELACAO_PRIMARIA);
                    cmd.Parameters.AddWithValue("?TP_RELACAO_SECUNDARIA", objUCFaturamento.TP_RELACAO_SECUNDARIA);
                    cmd.Parameters.AddWithValue("?PERIODO_TESTE", objUCFaturamento.PERIODO_TESTE);
                    cmd.Parameters.AddWithValue("?INI_PERIODO_TESTE", objUCFaturamento.INI_PERIODO_TESTE);
                    cmd.Parameters.AddWithValue("?FIM_PERIODO_TESTE", objUCFaturamento.FIM_PERIODO_TESTE);
                    cmd.Parameters.AddWithValue("?DATA_CONTRATO_DEMANDA", objUCFaturamento.DATA_CONTRATO_DEMANDA);
                    cmd.Parameters.AddWithValue("?DEMANDA_CONTR", objUCFaturamento.DEMANDA_CONTR);
                    cmd.Parameters.AddWithValue("?DEM_CONTR_PONTA", objUCFaturamento.DEM_CONTR_PONTA);
                    cmd.Parameters.AddWithValue("?DEM_CONTR_FP", objUCFaturamento.DEM_CONTR_FP);
                    cmd.Parameters.AddWithValue("?DEMANDA_CONTR_ANTERIOR", objUCFaturamento.DEMANDA_CONTR_ANTERIOR);
                    cmd.Parameters.AddWithValue("?DEM_CONTR_PONTA_ANTERIOR", objUCFaturamento.DEM_CONTR_PONTA_ANTERIOR);
                    cmd.Parameters.AddWithValue("?DEM_CONTR_FP_ANTERIOR", objUCFaturamento.DEM_CONTR_FP_ANTERIOR);

                    if (objUCFaturamento.GRUPO.Substring(0, 1) == "B")
                    {
                        cmd.Parameters.AddWithValue("?ULTLEIT", objUCFaturamento.ULTLEIT);
                        cmd.Parameters.AddWithValue("?RESIDUO_CONSUMO", objUCFaturamento.RESIDUO_CONSUMO);
                    }

                    cmd.Parameters.AddWithValue("?ITENSESP", objUCFaturamento.ITENSESP.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?TP_LIGACAO", objUCFaturamento.TP_LIGACAO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?ID", objUCFaturamento.ID);

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

        public void Update_6(entidadeUCFaturamento objUCFaturamento)
        {
            MySqlCommand cmd = null;
            IGerenciadorTransacao objGerenciadorTransacao = null;
            ConexaoBD objconexaoBD = null;

            try
            {
                objconexaoBD = new ConexaoBD();

                objconexaoBD.SetarConexaoBanco(TipoBDConexao.fat_BD);

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

                    //LEITURA
                    vFILTER = vFILTER + " ULT_LEIT_KWH_P = ?ULT_LEIT_KWH_P ,";
                    vFILTER = vFILTER + " ULT_LEIT_KWH_FP = ?ULT_LEIT_KWH_P ,";
                    vFILTER = vFILTER + " ULT_LEIT_KW_P = ?ULT_LEIT_KW_P ,";
                    vFILTER = vFILTER + " ULT_LEIT_KW_FP = ?ULT_LEIT_KW_FP ,";
                    vFILTER = vFILTER + " ULT_LEIT_KVARH_P = ?ULT_LEIT_KVARH_P ,";
                    vFILTER = vFILTER + " ULT_LEIT_KVARH_FP = ?ULT_LEIT_KVARH_FP ,";
                    vFILTER = vFILTER + " ULTLEIT_REVERSO_P = ?ULTLEIT_REVERSO_P ,";
                    vFILTER = vFILTER + " ULTLEIT_REVERSO_FP = ?ULTLEIT_REVERSO_FP ,";
                    //                 vFILTER = vFILTER +   " ULT_LEIT_IRRIGANTE_P = ?ULT_LEIT_IRRIGANTE_P ,";  
                    //                 vFILTER = vFILTER +   " ULT_LEIT_IRRIGANTE_FP = ?ULT_LEIT_IRRIGANTE_FP ,";  
                    //CONSUMO
                    vFILTER = vFILTER + " ULT_CONS_KWH_P = ?ULT_CONS_KWH_P ,";
                    vFILTER = vFILTER + " ULT_CONS_KWH_FP = ?ULT_CONS_KWH_FP ,";
                    vFILTER = vFILTER + " ULT_CONS_KW_P = ?ULT_CONS_KW_P ,";
                    vFILTER = vFILTER + " ULT_CONS_KW_FP = ?ULT_CONS_KW_FP ,";
                    vFILTER = vFILTER + " ULT_CONS_KVARH_P = ?ULT_CONS_KVARH_P ,";
                    vFILTER = vFILTER + " ULT_CONS_KVARH_FP = ?ULT_CONS_KVARH_FP ,";
                    //RESIDUO
                    //                 vFILTER = vFILTER +   " KWH_RES_P = ?KWH_RES_P ,"; 
                    //                 vFILTER = vFILTER +   " KWH_RES_FP = ?KWH_RES_FP ,"; 
                    //                 vFILTER = vFILTER +   " KWH_IRRIGANTE_RES_P = ?KWH_IRRIGANTE_RES_P ,"; 
                    //                 vFILTER = vFILTER +   " KWH_IRRIGANTE_RES_FP = ?KWH_IRRIGANTE_RES_FP ,";  
                    //                 vFILTER = vFILTER +   " KWH_REVERSO_RES_P = ?KWH_REVERSO_RES_P ,";
                    //                 vFILTER = vFILTER +   " KWH_REVERSO_RES_FP = ?KWH_REVERSO_RES_FP ,";
                    //ARREDONDAMENTO
                    vFILTER = vFILTER + " ARREDONDA = ARREDONDA_ANT ";
                    vAND = vAND + " AND ID = ?UNID_ID ";

                    cmd = new MySqlCommand(this.QueryUpdate);

                    //LEITURA
                    cmd.Parameters.AddWithValue("?ULT_LEIT_KWH_P", objUCFaturamento.ULT_LEIT_KWH_P);
                    cmd.Parameters.AddWithValue("?ULT_LEIT_KWH_FP", objUCFaturamento.ULT_LEIT_KWH_P);
                    cmd.Parameters.AddWithValue("?ULT_LEIT_KW_P", objUCFaturamento.ULT_LEIT_KW_P);
                    cmd.Parameters.AddWithValue("?ULT_LEIT_KW_FP", objUCFaturamento.ULT_LEIT_KW_FP);
                    cmd.Parameters.AddWithValue("?ULT_LEIT_KVARH_P", objUCFaturamento.ULT_LEIT_KVARH_P);
                    cmd.Parameters.AddWithValue("?ULT_LEIT_KVARH_FP", objUCFaturamento.ULT_LEIT_KVARH_FP);
                    cmd.Parameters.AddWithValue("?ULTLEIT_REVERSO_P", objUCFaturamento.ULTLEIT_REVERSO_P);
                    cmd.Parameters.AddWithValue("?ULTLEIT_REVERSO_FP", objUCFaturamento.ULTLEIT_REVERSO_FP);
                    //                cmd.Parameters.AddWithValue("?ULT_LEIT_IRRIGANTE_P", objUCFaturamento.ULT_LEIT_IRRIGANTE_P );  
                    //                cmd.Parameters.AddWithValue("?ULT_LEIT_IRRIGANTE_FP", objUCFaturamento.ULT_LEIT_IRRIGANTE_FP );  
                    //CONSUMO
                    cmd.Parameters.AddWithValue("?ULT_CONS_KWH_P", objUCFaturamento.ULT_CONS_KWH_P);
                    cmd.Parameters.AddWithValue("?ULT_CONS_KWH_FP", objUCFaturamento.ULT_CONS_KWH_FP);
                    cmd.Parameters.AddWithValue("?ULT_CONS_KW_P", objUCFaturamento.ULT_CONS_KW_P);
                    cmd.Parameters.AddWithValue("?ULT_CONS_KW_FP", objUCFaturamento.ULT_CONS_KW_FP);
                    cmd.Parameters.AddWithValue("?ULT_CONS_KVARH_P", objUCFaturamento.ULT_CONS_KVARH_P);
                    cmd.Parameters.AddWithValue("?ULT_CONS_KVARH_FP", objUCFaturamento.ULT_CONS_KVARH_FP);
                    //RESIDUO
                    //                cmd.Parameters.AddWithValue("?KWH_RES_P", objUCFaturamento.KWH_RES_P ); 
                    //                cmd.Parameters.AddWithValue("?KWH_RES_FP", objUCFaturamento.KWH_RES_FP ); 
                    //                cmd.Parameters.AddWithValue("?KWH_IRRIGANTE_RES_P", objUCFaturamento.KWH_IRRIGANTE_RES_P ); 
                    //                cmd.Parameters.AddWithValue("?KWH_IRRIGANTE_RES_FP", objUCFaturamento.KWH_IRRIGANTE_RES_FP );  
                    //                cmd.Parameters.AddWithValue("?KWH_REVERSO_RES_P", objUCFaturamento.KWH_REVERSO_RES_P );
                    //                cmd.Parameters.AddWithValue("?KWH_REVERSO_RES_FP", objUCFaturamento.KWH_REVERSO_RES_FP );
                    //ARREDONDAMENTO
                    cmd.Parameters.AddWithValue("?UNID_ID", objUCFaturamento.ID);





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

        public void Update_7(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "       ULTLEIT         = ?ULTLEIT , ";
                    vFILTER = vFILTER + "       KVARH           = ?KVARH , ";
                    vFILTER = vFILTER + "       ULTKVARH        = ?ULTKVARH , ";
                    vFILTER = vFILTER + "       LEIT            = ?LEIT , ";

                    //IRRIGAÇÃO
                    vFILTER = vFILTER + "       ULTLEIT_IRRIGANTE = ?ULTLEIT_IRRIGANTE , ";
                    // vFILTER = vFILTER + "       ULT_LEIT_IRRIGANTE_P = ?ULT_LEIT_IRRIGANTE_P , ";
                    // vFILTER = vFILTER + "       ULT_LEIT_IRRIGANTE_I = ?ULT_LEIT_IRRIGANTE_I , ";
                    vFILTER = vFILTER + "       ULT_LEIT_IRRIGANTE_FP = ?ULT_LEIT_IRRIGANTE_FP , ";
                    vFILTER = vFILTER + "       KWH_IRRIGANTE_RES = ?KWH_IRRIGANTE_RES , ";
                    vFILTER = vFILTER + "       KWH_IRRIGANTE_RES_P = ?KWH_IRRIGANTE_RES_P , ";
                    vFILTER = vFILTER + "       KWH_IRRIGANTE_RES_I = ?KWH_IRRIGANTE_RES_I , ";
                    vFILTER = vFILTER + "       KWH_IRRIGANTE_RES_FP = ?KWH_IRRIGANTE_RES_FP , ";

                    //MICRO GERAÇÃO
                    vFILTER = vFILTER + "       ULTLEIT_REVERSO = ?ULTLEIT_REVERSO , ";
                    // vFILTER = vFILTER + "       ULTLEIT_REVERSO_P = ?ULTLEIT_REVERSO_P , ";
                    // vFILTER = vFILTER + "       ULTLEIT_REVERSO_I = ?ULTLEIT_REVERSO_I , ";
                    vFILTER = vFILTER + "       ULTLEIT_REVERSO_FP = ?ULTLEIT_REVERSO_FP , ";
                    vFILTER = vFILTER + "       KWH_REVERSO_RES_P = ?KWH_REVERSO_RES_P , ";
                    vFILTER = vFILTER + "       KWH_REVERSO_RES_I = ?KWH_REVERSO_RES_I , ";
                    vFILTER = vFILTER + "       KWH_REVERSO_RES_FP = ?KWH_REVERSO_RES_FP , ";
                    // vFILTER = vFILTER + "       ULT_LEIT_KVARH_P  = ?ULT_LEIT_KVARH_P , ";
                    // vFILTER = vFILTER + "       ULT_LEIT_KVARH_I  = ?ULT_LEIT_KVARH_I , ";
                    vFILTER = vFILTER + "       ULT_LEIT_KVARH_FP = ?ULT_LEIT_KVARH_FP , ";
                    // vFILTER = vFILTER + "       ULT_CONS_KVARH_P  = ?ULT_CONS_KVARH_P , ";
                    // vFILTER = vFILTER + "       ULT_CONS_KVARH_I  = ?ULT_CONS_KVARH_I , ";
                    vFILTER = vFILTER + "       ULT_CONS_KVARH_FP = ?ULT_CONS_KVARH_FP , ";
                    vFILTER = vFILTER + "       ULT_LEIT_KWH_P = ?ULT_LEIT_KWH_P , ";
                    vFILTER = vFILTER + "       ULT_LEIT_KWH_I = ?ULT_LEIT_KWH_I , ";
                    vFILTER = vFILTER + "       ULT_CONS_KWH_P = ?ULT_CONS_KWH_P , ";
                    vFILTER = vFILTER + "       ULT_CONS_KWH_I = ?ULT_CONS_KWH_I , ";
                    vFILTER = vFILTER + "       ULT_LEIT_KWH_FP = ?ULT_LEIT_KWH_FP , ";
                    vFILTER = vFILTER + "       ULT_CONS_KWH_FP = ?ULT_CONS_KWH_FP , ";


                    if (objUCFaturamento.RESIDUO_CONSUMO == 0 && objUCFaturamento.KWH_RES_P == 0 && objUCFaturamento.KWH_RES_I == 0 && objUCFaturamento.KWH_RES_FP == 0)
                    {
                        vFILTER = vFILTER + "       RESIDUO_CONSUMO = ?RESIDUO_CONSUMO , ";
                        vFILTER = vFILTER + "       KWH_RES_P = ?KWH_RES_P , ";
                        vFILTER = vFILTER + "       KWH_RES_I = ?KWH_RES_I , ";
                        vFILTER = vFILTER + "       KWH_RES_FP = ?KWH_RES_FP , ";

                    }

                    vFILTER = vFILTER + "  ARREDONDA       = ARREDONDA_ANT ";

                    vAND = vAND + " AND ID  = ?UNID_ID ";

                    cmd = new MySqlCommand(this.QueryUpdate);


                    cmd.Parameters.AddWithValue("?ULTLEIT", objUCFaturamento.ULTLEIT);
                    cmd.Parameters.AddWithValue("?KVARH", objUCFaturamento.KVARH);
                    cmd.Parameters.AddWithValue("?ULTKVARH", objUCFaturamento.ULTKVARH);
                    cmd.Parameters.AddWithValue("?LEIT", objUCFaturamento.LEIT);

                    //IRRIGAÇÃO
                    cmd.Parameters.AddWithValue("?ULTLEIT_IRRIGANTE", objUCFaturamento.ULTLEIT_IRRIGANTE);
                    // cmd.Parameters.AddWithValue("?ULT_LEIT_IRRIGANTE_P", objUCFaturamento.ULT_LEIT_IRRIGANTE_P);
                    // cmd.Parameters.AddWithValue("?ULT_LEIT_IRRIGANTE_I", objUCFaturamento.ULT_LEIT_IRRIGANTE_I);
                    cmd.Parameters.AddWithValue("?ULT_LEIT_IRRIGANTE_FP", objUCFaturamento.ULT_LEIT_IRRIGANTE_FP);
                    cmd.Parameters.AddWithValue("?KWH_IRRIGANTE_RES", objUCFaturamento.KWH_IRRIGANTE_RES);
                    cmd.Parameters.AddWithValue("?KWH_IRRIGANTE_RES_P", objUCFaturamento.KWH_IRRIGANTE_RES_P);
                    cmd.Parameters.AddWithValue("?KWH_IRRIGANTE_RES_I", objUCFaturamento.KWH_IRRIGANTE_RES_I);
                    cmd.Parameters.AddWithValue("?KWH_IRRIGANTE_RES_FP", objUCFaturamento.KWH_IRRIGANTE_RES_FP);

                    //MICRO GERAÇÃO
                    cmd.Parameters.AddWithValue("?ULTLEIT_REVERSO", objUCFaturamento.ULTLEIT_REVERSO);
                    // cmd.Parameters.AddWithValue("?ULTLEIT_REVERSO_P", objUCFaturamento.ULTLEIT_REVERSO_P);
                    // cmd.Parameters.AddWithValue("?ULTLEIT_REVERSO_I", objUCFaturamento.ULTLEIT_REVERSO_I);
                    cmd.Parameters.AddWithValue("?ULTLEIT_REVERSO_FP", objUCFaturamento.ULTLEIT_REVERSO_FP);
                    cmd.Parameters.AddWithValue("?KWH_REVERSO_RES_P", objUCFaturamento.KWH_REVERSO_RES_P);
                    cmd.Parameters.AddWithValue("?KWH_REVERSO_RES_I", objUCFaturamento.KWH_REVERSO_RES_I);
                    cmd.Parameters.AddWithValue("?KWH_REVERSO_RES_FP", objUCFaturamento.KWH_REVERSO_RES_FP);
                    // cmd.Parameters.AddWithValue("?ULT_LEIT_KVARH_P ", objUCFaturamento.ULT_LEIT_KVARH_P);
                    // cmd.Parameters.AddWithValue("?ULT_LEIT_KVARH_I", objUCFaturamento.ULT_LEIT_KVARH_I);
                    cmd.Parameters.AddWithValue("?ULT_LEIT_KVARH_FP", objUCFaturamento.ULT_LEIT_KVARH_FP);
                    // cmd.Parameters.AddWithValue("?ULT_CONS_KVARH_P", objUCFaturamento.ULT_CONS_KVARH_P);
                    // cmd.Parameters.AddWithValue("?ULT_CONS_KVARH_I", objUCFaturamento.ULT_CONS_KVARH_I);
                    cmd.Parameters.AddWithValue("?ULT_CONS_KVARH_FP", objUCFaturamento.ULT_CONS_KVARH_FP);
                    cmd.Parameters.AddWithValue("?ULT_LEIT_KWH_P", objUCFaturamento.ULT_LEIT_KWH_P);
                    cmd.Parameters.AddWithValue("?ULT_LEIT_KWH_I", objUCFaturamento.ULT_LEIT_KWH_I);
                    cmd.Parameters.AddWithValue("?ULT_CONS_KWH_P", objUCFaturamento.ULT_CONS_KWH_P);
                    cmd.Parameters.AddWithValue("?ULT_CONS_KWH_I", objUCFaturamento.ULT_CONS_KWH_I);
                    cmd.Parameters.AddWithValue("?ULT_LEIT_KWH_FP", objUCFaturamento.ULT_LEIT_KWH_FP);
                    cmd.Parameters.AddWithValue("?ULT_CONS_KWH_FP", objUCFaturamento.ULT_CONS_KWH_FP);


                    if (objUCFaturamento.RESIDUO_CONSUMO == 0 && objUCFaturamento.KWH_RES_P == 0 && objUCFaturamento.KWH_RES_I == 0 && objUCFaturamento.KWH_RES_FP == 0)
                    {
                        cmd.Parameters.AddWithValue("?RESIDUO_CONSUMO", objUCFaturamento.RESIDUO_CONSUMO);
                        cmd.Parameters.AddWithValue("?KWH_RES_P", objUCFaturamento.KWH_RES_P);
                        cmd.Parameters.AddWithValue("?KWH_RES_I", objUCFaturamento.KWH_RES_I);
                        cmd.Parameters.AddWithValue("?KWH_RES_FP", objUCFaturamento.KWH_RES_FP);
                    }

                    cmd.Parameters.AddWithValue("?UNID_ID", objUCFaturamento.ID);




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

        public void Update_8(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "  ARREDONDA_ANT       = ?ARREDONDA_ANT ";

                    vAND = vAND + " AND ID  = ?UNID_ID ";

                    cmd = new MySqlCommand(this.QueryUpdate);

                    cmd.Parameters.AddWithValue("?ARREDONDA_ANT", objUCFaturamento.ARREDONDA_ANT);

                    cmd.Parameters.AddWithValue("?UNID_ID ", objUCFaturamento.UNID_ID);


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

        public void Update_9(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "  ARREDONDA_TEMP       = ?ARREDONDA_TEMP ";

                    vAND = vAND + " AND ID  = ?ID ";

                    cmd = new MySqlCommand(this.QueryUpdate);

                    cmd.Parameters.AddWithValue("?ARREDONDA_TEMP", objUCFaturamento.ARREDONDA_TEMP);

                    cmd.Parameters.AddWithValue("?ID ", objUCFaturamento.ID);


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

        public DataTable Delete(entidadeUCFaturamento objUCFaturamento)
        {
            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))
                {
                    vORDERBY = " ";


                    if (objUCFaturamento.UNID_ID != 0)
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND UNID_ID = ?UNID_ID "; }
                        else
                        { vAND = "AND UNID_ID = ?UNID_ID "; }

                    }
                    else
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + " "; }
                        else
                        { vAND = " "; }
                    }


                    cmd = new MySqlCommand(this.QueryDelete);


                    if (objUCFaturamento.UNID_ID != 0)
                    {
                        cmd.Parameters.AddWithValue("?UNID_ID", objUCFaturamento.UNID_ID);
                    }

                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable Delete_1(entidadeUCFaturamento objUCFaturamento)
        {
            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))
                {
                    vORDERBY = " ";


                    if (objUCFaturamento.ID != 0)
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + "AND ID = ?ID "; }
                        else
                        { vAND = "AND ID = ?ID "; }

                    }
                    else
                    {
                        if (vAND != String.Empty)
                        { vAND = vAND + " "; }
                        else
                        { vAND = " "; }
                    }


                    cmd = new MySqlCommand(this.QueryDelete);


                    if (objUCFaturamento.ID != 0)
                    {
                        cmd.Parameters.AddWithValue("?ID", objUCFaturamento.ID);
                    }

                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable SelectMax(entidadeUCFaturamento objUCFaturamento)
        {
            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 + "MAX(ID) AS ID  ";

                    vINNERJOIN = " ";
                    vORDERBY = " ";
                    vAND = " ";

                    cmd = new MySqlCommand(this.QuerySelect);

                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

                return dt;
            }
            catch (Exception)
            {
                throw;
            }
            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("UC_FATURAMENTO SET  ");
                this.sb.AppendLine(vFILTER);

                return sb.ToString();
            }
        }

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

                this.sb.AppendLine("UPDATE  ");
                this.sb.AppendLine("UC_FATURAMENTO 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 UC_FATURAMENTO ");
                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("UC_FATURAMENTO  ");
                this.sb.AppendLine(vINNERJOIN);
                this.sb.AppendLine("WHERE 1 = 1  ");
                this.sb.AppendLine(vAND);
                this.sb.AppendLine(vORDERBY);

                return sb.ToString();
            }
        }

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

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

                return sb.ToString();
            }
        }

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

                this.sb.AppendLine("SELECT ");
                this.sb.AppendLine(vFILTER);
                this.sb.AppendLine("FROM ");
                this.sb.AppendLine("unida AS UC_FATURAMENTO  ");
                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


    }
}
