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

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

        #region Métodos

        public void Insert(entidadeBanco objBanco)
        {
            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 + "NRBCO        = ?NRBCO , ";
                    vFILTER = vFILTER + "NRAG         = ?NRAG , ";
                    vFILTER = vFILTER + "NMBCO        = ?NMBCO , ";
                    vFILTER = vFILTER + "ENDER        = ?ENDER , ";
                    vFILTER = vFILTER + "BAIRRO       = ?BAIRRO , ";
                    vFILTER = vFILTER + "CIDADE       = ?CIDADE , ";
                    vFILTER = vFILTER + "UF           = ?UF , ";
                    vFILTER = vFILTER + "CEP          = ?CEP , ";
                    vFILTER = vFILTER + "DDDTEL       = ?DDDTEL , ";
                    vFILTER = vFILTER + "TEL          = ?TEL , ";
                    vFILTER = vFILTER + "CONVENIO     = ?CONVENIO , ";
                    vFILTER = vFILTER + "SEQUENCIAL   = ?SEQUENCIAL , ";
                    vFILTER = vFILTER + "NMARQUIVO    = ?NMARQUIVO , ";
                    vFILTER = vFILTER + "NMARQEXTESAO = ?NMARQEXTESAO , ";
                    vFILTER = vFILTER + "TPMOVTO      = ?TPMOVTO , ";
                    vFILTER = vFILTER + "GRUPO        = ?GRUPO , ";
                    vFILTER = vFILTER + "MASC_CONTA   = ?MASC_CONTA , ";

                    vFILTER = vFILTER + "CONTA_DEBITO    = ?CONTA_DEBITO , ";
                    vFILTER = vFILTER + "CONTA_CREDITO   = ?CONTA_CREDITO , ";
                    vFILTER = vFILTER + "ATIVO            = ?ATIVO , ";
                    vFILTER = vFILTER + "COMERCIO         = ?COMERCIO , ";
                    vFILTER = vFILTER + "CONTABILIZA      = ?CONTABILIZA, ";

                    vFILTER = vFILTER + "ID_CONTA_DEBITO      = ?ID_CONTA_DEBITO, ";
                    vFILTER = vFILTER + "ID_CONTA_CREDITO     = ?ID_CONTA_CREDITO ";

                    cmd = new MySqlCommand(this.QueryInsert);

                    cmd.Parameters.AddWithValue("?BAN_ID", objBanco.BAN_ID);
                    cmd.Parameters.AddWithValue("?NRBCO", objBanco.NRBCO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?NRAG", objBanco.NRAG.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?NMBCO", objBanco.NMBCO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?ENDER", objBanco.ENDER.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?BAIRRO", objBanco.BAIRRO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CIDADE", objBanco.CIDADE.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?UF", objBanco.UF.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CEP", objBanco.CEP.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?DDDTEL", objBanco.DDDTEL.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?TEL", objBanco.TEL.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CONVENIO", objBanco.CONVENIO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?SEQUENCIAL", objBanco.SEQUENCIAL);
                    cmd.Parameters.AddWithValue("?NMARQUIVO", objBanco.NMARQUIVO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?NMARQEXTESAO", objBanco.NMARQEXTESAO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?TPMOVTO", objBanco.TPMOVTO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?GRUPO", objBanco.GRUPO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?MASC_CONTA", objBanco.UF.ToString().ToUpper());

                    cmd.Parameters.AddWithValue("?CONTA_DEBITO", objBanco.CONTA_DEBITO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CONTA_CREDITO", objBanco.CONTA_CREDITO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?ATIVO", objBanco.ATIVO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?COMERCIO", objBanco.COMERCIO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CONTABILIZA", objBanco.CONTABILIZA.ToString().ToUpper());

                    cmd.Parameters.AddWithValue("?ID_CONTA_DEBITO", objBanco.ID_CONTA_DEBITO);
                    cmd.Parameters.AddWithValue("?ID_CONTA_CREDITO", objBanco.ID_CONTA_CREDITO);

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

        public void Update(entidadeBanco objBanco)
        {
            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 + "NRBCO        = ?NRBCO , ";
                    vFILTER = vFILTER + "NRAG         = ?NRAG , ";
                    vFILTER = vFILTER + "NMBCO        = ?NMBCO , ";
                    vFILTER = vFILTER + "ENDER        = ?ENDER , ";
                    vFILTER = vFILTER + "BAIRRO       = ?BAIRRO , ";
                    vFILTER = vFILTER + "CIDADE       = ?CIDADE , ";
                    vFILTER = vFILTER + "UF           = ?UF , ";
                    vFILTER = vFILTER + "CEP          = ?CEP , ";
                    vFILTER = vFILTER + "DDDTEL       = ?DDDTEL , ";
                    vFILTER = vFILTER + "TEL          = ?TEL , ";
                    vFILTER = vFILTER + "CONVENIO     = ?CONVENIO , ";
                    vFILTER = vFILTER + "SEQUENCIAL   = ?SEQUENCIAL , ";
                    vFILTER = vFILTER + "NMARQUIVO    = ?NMARQUIVO , ";
                    vFILTER = vFILTER + "NMARQEXTESAO = ?NMARQEXTESAO , ";
                    vFILTER = vFILTER + "TPMOVTO      = ?TPMOVTO , ";
                    vFILTER = vFILTER + "GRUPO        = ?GRUPO , ";
                    vFILTER = vFILTER + "MASC_CONTA   = ?MASC_CONTA , ";

                    vFILTER = vFILTER + "CONTA_DEBITO    = ?CONTA_DEBITO , ";
                    vFILTER = vFILTER + "CONTA_CREDITO   = ?CONTA_CREDITO , ";
                    vFILTER = vFILTER + "ATIVO            = ?ATIVO , ";
                    vFILTER = vFILTER + "COMERCIO         = ?COMERCIO , ";
                    vFILTER = vFILTER + "CONTABILIZA      = ?CONTABILIZA, ";

                    vFILTER = vFILTER + "ID_CONTA_DEBITO      = ?ID_CONTA_DEBITO, ";
                    vFILTER = vFILTER + "ID_CONTA_CREDITO     = ?ID_CONTA_CREDITO ";

                    vAND = vAND + "AND BAN_ID       = ?BAN_ID ";

                    cmd = new MySqlCommand(this.QueryUpdate);

                    cmd.Parameters.AddWithValue("?BAN_ID", objBanco.BAN_ID);
                    cmd.Parameters.AddWithValue("?NRBCO", objBanco.NRBCO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?NRAG", objBanco.NRAG.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?NMBCO", objBanco.NMBCO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?ENDER", objBanco.ENDER.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?BAIRRO", objBanco.BAIRRO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CIDADE", objBanco.CIDADE.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?UF", objBanco.UF.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CEP", objBanco.CEP.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?DDDTEL", objBanco.DDDTEL.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?TEL", objBanco.TEL.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CONVENIO", objBanco.CONVENIO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?SEQUENCIAL", objBanco.SEQUENCIAL);
                    cmd.Parameters.AddWithValue("?NMARQUIVO", objBanco.NMARQUIVO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?NMARQEXTESAO", objBanco.NMARQEXTESAO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?TPMOVTO", objBanco.TPMOVTO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?GRUPO", objBanco.GRUPO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?MASC_CONTA", objBanco.UF.ToString().ToUpper());

                    cmd.Parameters.AddWithValue("?CONTA_DEBITO", objBanco.CONTA_DEBITO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CONTA_CREDITO", objBanco.CONTA_CREDITO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?ATIVO", objBanco.ATIVO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?COMERCIO", objBanco.COMERCIO.ToString().ToUpper());
                    cmd.Parameters.AddWithValue("?CONTABILIZA", objBanco.CONTABILIZA.ToString().ToUpper());

                    cmd.Parameters.AddWithValue("?ID_CONTA_DEBITO", objBanco.ID_CONTA_DEBITO);
                    cmd.Parameters.AddWithValue("?ID_CONTA_CREDITO", objBanco.ID_CONTA_CREDITO);


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

        public DataTable Select(entidadeBanco objBanco)
        {
            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 + "BAN_ID, ";
                    vFILTER = vFILTER + "NRBCO, ";
                    vFILTER = vFILTER + "NRAG, ";
                    vFILTER = vFILTER + "NMBCO, ";
                    vFILTER = vFILTER + "ENDER, ";
                    vFILTER = vFILTER + "BAIRRO, ";
                    vFILTER = vFILTER + "CIDADE, ";
                    vFILTER = vFILTER + "UF, ";
                    vFILTER = vFILTER + "CEP, ";
                    vFILTER = vFILTER + "DDDTEL, ";
                    vFILTER = vFILTER + "TEL, ";
                    vFILTER = vFILTER + "TIPO, ";
                    vFILTER = vFILTER + "CONVENIO, ";
                    vFILTER = vFILTER + "SEQUENCIAL, ";
                    vFILTER = vFILTER + "NMARQUIVO, ";
                    vFILTER = vFILTER + "NMARQEXTESAO, ";
                    vFILTER = vFILTER + "TPMOVTO, ";
                    vFILTER = vFILTER + "GRUPO, ";
                    vFILTER = vFILTER + "MASC_CONTA, ";
                    vFILTER = vFILTER + "CONTA_DEBITO, ";
                    vFILTER = vFILTER + "CONTA_CREDITO, ";
                    vFILTER = vFILTER + "ATIVO, ";
                    vFILTER = vFILTER + "COMERCIO, ";
                    vFILTER = vFILTER + "CONTABILIZA, ";

                    vFILTER = vFILTER + "ID_CONTA_DEBITO, ";
                    vFILTER = vFILTER + "ID_CONTA_CREDITO ";

                    vINNERJOIN = " ";

                    vORDERBY = "ORDER BY NMBCO ";

                    vAND = " ";

                    cmd = new MySqlCommand(this.QuerySelect);

                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable Select_1(entidadeBanco objBanco)
        {
            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 + "BAN_ID, ";
                    vFILTER = vFILTER + "NRBCO, ";
                    vFILTER = vFILTER + "NRAG, ";
                    vFILTER = vFILTER + "NMBCO, ";
                    vFILTER = vFILTER + "ENDER, ";
                    vFILTER = vFILTER + "BAIRRO, ";
                    vFILTER = vFILTER + "CIDADE, ";
                    vFILTER = vFILTER + "UF, ";
                    vFILTER = vFILTER + "CEP, ";
                    vFILTER = vFILTER + "DDDTEL, ";
                    vFILTER = vFILTER + "TEL, ";
                    vFILTER = vFILTER + "TIPO, ";
                    vFILTER = vFILTER + "CONVENIO, ";
                    vFILTER = vFILTER + "SEQUENCIAL, ";
                    vFILTER = vFILTER + "NMARQUIVO, ";
                    vFILTER = vFILTER + "NMARQEXTESAO, ";
                    vFILTER = vFILTER + "TPMOVTO, ";
                    vFILTER = vFILTER + "GRUPO, ";
                    vFILTER = vFILTER + "MASC_CONTA, ";
                    vFILTER = vFILTER + "CONTA_DEBITO, ";
                    vFILTER = vFILTER + "CONTA_CREDITO, ";
                    vFILTER = vFILTER + "ATIVO, ";
                    vFILTER = vFILTER + "COMERCIO, ";
                    vFILTER = vFILTER + "CONTABILIZA, ";

                    vFILTER = vFILTER + "ID_CONTA_DEBITO, ";
                    vFILTER = vFILTER + "ID_CONTA_CREDITO ";

                    vINNERJOIN = " ";

                    vORDERBY = " ";

                    vAND = vAND + " AND NRBCO = ?NRBCO ";

                    cmd = new MySqlCommand(this.QuerySelect);

                    cmd.Parameters.AddWithValue("?NRBCO", objBanco.NRBCO.ToString().ToUpper());

                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable Select_2(entidadeBanco objBanco)
        {
            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 + "BAN_ID, ";
                    vFILTER = vFILTER + "NRBCO, ";
                    vFILTER = vFILTER + "NRAG, ";
                    vFILTER = vFILTER + "NMBCO, ";
                    vFILTER = vFILTER + "ENDER, ";
                    vFILTER = vFILTER + "BAIRRO, ";
                    vFILTER = vFILTER + "CIDADE, ";
                    vFILTER = vFILTER + "UF, ";
                    vFILTER = vFILTER + "CEP, ";
                    vFILTER = vFILTER + "DDDTEL, ";
                    vFILTER = vFILTER + "TEL, ";
                    vFILTER = vFILTER + "TIPO, ";
                    vFILTER = vFILTER + "CONVENIO, ";
                    vFILTER = vFILTER + "SEQUENCIAL, ";
                    vFILTER = vFILTER + "NMARQUIVO, ";
                    vFILTER = vFILTER + "NMARQEXTESAO, ";
                    vFILTER = vFILTER + "TPMOVTO, ";
                    vFILTER = vFILTER + "GRUPO, ";
                    vFILTER = vFILTER + "MASC_CONTA, ";
                    vFILTER = vFILTER + "CONTA_DEBITO, ";
                    vFILTER = vFILTER + "CONTA_CREDITO, ";
                    vFILTER = vFILTER + "ATIVO, ";
                    vFILTER = vFILTER + "COMERCIO, ";
                    vFILTER = vFILTER + "CONTABILIZA, ";

                    vFILTER = vFILTER + "ID_CONTA_DEBITO, ";
                    vFILTER = vFILTER + "ID_CONTA_CREDITO ";

                    vINNERJOIN = " ";

                    vORDERBY = " ";

                    vAND = vAND + " AND BAN_ID = ?BAN_ID ";

                    cmd = new MySqlCommand(this.QuerySelect);

                    cmd.Parameters.AddWithValue("?BAN_ID", objBanco.BAN_ID);

                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public void Delete(entidadeBanco objBanco)
        {
            MySqlCommand cmd = null;

            IGerenciadorTransacao objGerenciadorTransacao = null;

            ConexaoBD objconexaoBD = null;

            try
            {
                objconexaoBD = new ConexaoBD();

                objconexaoBD.SetarConexaoBanco(TipoBDConexao.fat_BD);

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

                    vAND = vAND + "AND BAN_ID  = ?BAN_ID ";

                    cmd = new MySqlCommand(this.QueryDelete);

                    cmd.Parameters.AddWithValue("?BAN_ID", objBanco.BAN_ID);

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

        public DataTable SelectOthersTables(entidadeBanco objBanco)
        {
            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 + "BAN_ID, ";
                    vFILTER = vFILTER + "CONCAT(NRBCO, ' - ', CASE WHEN TPMOVTO = 'D' THEN '(DEBITO)' ELSE '' END , '', CASE WHEN NMBCO = ' ' THEN '(NENHUM)' ELSE NMBCO END)  AS NMBCO ";

                    vINNERJOIN = " ";

                    vORDERBY = "ORDER BY NRBCO ASC, BAN_ID ASC  ";

                    vAND = vAND + "AND GRUPO = 'C' ";

                    cmd = new MySqlCommand(this.QuerySelect);

                    dt = objGerenciadorTransacao.GetDataTable(cmd);
                }

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

        public DataTable SelectOthersTables_1(entidadeBanco objBanco)
        {
            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 + "BAN_ID, ";
                    vFILTER = vFILTER + "CONCAT(NRBCO, ' - ', CASE WHEN TPMOVTO = 'D' THEN '(DEBITO)' ELSE '' END , '', CASE WHEN NMBCO = ' ' THEN '(NENHUM)' ELSE NMBCO END)  AS NMBCO  ";

                    vINNERJOIN = " ";

                    vORDERBY = "ORDER BY NRBCO ASC, BAN_ID ASC  ";

                    vAND = vAND + "AND GRUPO IN('C','G') ";

                    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("BANCOS SET  ");
                this.sb.AppendLine(vFILTER);

                return sb.ToString();
            }
        }

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

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

                return sb.ToString();
            }
        }

        #endregion

    }
}
