using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace fatd_faturamento.DAL.Conexao
{
    public class ConexaoBD
    {
        public void SetarConexaoBanco(TipoBDConexao tipoBDConexao)
        {
            string server = null;
            string table = null;
            string user = null;
            string password = null;
            string port = null;

            try
            {
                if (tipoBDConexao == TipoBDConexao.fat_BD)
                {
                    user = ConfigurationManager.AppSettings["u_fat"];

                    password = ConfigurationManager.AppSettings["p_fat"];

                    table = ConfigurationManager.AppSettings["table_fat"];

                    server = ConfigurationManager.AppSettings["server_fat"];

                    port = ConfigurationManager.AppSettings["port_fat"];

                }

                else if (tipoBDConexao == TipoBDConexao.fatwin_BD)
                {
                    user = ConfigurationManager.AppSettings["u_fat"];

                    password = ConfigurationManager.AppSettings["p_fat"];

                    //table = ConfigurationManager.AppSettings["fatwin"];

                    table = "fatwin";

                    server = ConfigurationManager.AppSettings["server_fat"];

                    port = ConfigurationManager.AppSettings["port_fat"];

                }

                else if (tipoBDConexao == TipoBDConexao.fatonline_BD)
                {
                    user = ConfigurationManager.AppSettings["u_fatonline"];

                    password = ConfigurationManager.AppSettings["p_fatonline"];

                    table = ConfigurationManager.AppSettings["table_fatonline"];

                    server = ConfigurationManager.AppSettings["server_fatonline"];

                    port = ConfigurationManager.AppSettings["port_fatonline"];

                }

                else if (tipoBDConexao == TipoBDConexao.nss_BD)
                {
                    user = ConfigurationManager.AppSettings["u_nss"];

                    password = ConfigurationManager.AppSettings["p_nss"];

                    table = ConfigurationManager.AppSettings["table_nss"];

                    server = ConfigurationManager.AppSettings["server_nss"];

                    port = ConfigurationManager.AppSettings["port_nss"];
                }

                else if (tipoBDConexao == TipoBDConexao.lc_BD)
                {
                    user = ConfigurationManager.AppSettings["u_lc"];

                    password = ConfigurationManager.AppSettings["p_lc"];

                    table = ConfigurationManager.AppSettings["table_lc"];

                    server = ConfigurationManager.AppSettings["server_lc"];

                    port = ConfigurationManager.AppSettings["port_lc"];

                }
                else if (tipoBDConexao == TipoBDConexao.ctb_BD)
                {
                    user = ConfigurationManager.AppSettings["u_ctb"];

                    password = ConfigurationManager.AppSettings["p_ctb"];

                    table = ConfigurationManager.AppSettings["table_ctb"];

                    server = ConfigurationManager.AppSettings["server_ctb"];

                    port = ConfigurationManager.AppSettings["port_ctb"];

                }
                else if (tipoBDConexao == TipoBDConexao.ctbempresa_BD)
                {
                    user = ConfigurationManager.AppSettings["u_ctbempresa"];

                    password = ConfigurationManager.AppSettings["p_ctbempresa"];

                    table = ConfigurationManager.AppSettings["table_ctbempresa"];

                    server = ConfigurationManager.AppSettings["server_ctbempresa"];

                    port = ConfigurationManager.AppSettings["port_ctbempresa"];

                }
                else if (tipoBDConexao == TipoBDConexao.cepnss_BD)
                {
                    user = ConfigurationManager.AppSettings["u_cepnss"];

                    password = ConfigurationManager.AppSettings["p_cepnss"];

                    table = ConfigurationManager.AppSettings["table_cepnss"];

                    server = ConfigurationManager.AppSettings["server_cepnss"];

                    port = ConfigurationManager.AppSettings["port_cepnss"];

                }
                else if (tipoBDConexao == TipoBDConexao.agenciavirtual_BD)
                {
                    user = ConfigurationManager.AppSettings["u_agenciavirtual"];

                    password = ConfigurationManager.AppSettings["p_agenciavirtual"];

                    table = ConfigurationManager.AppSettings["table_agenciavirtual"];

                    server = ConfigurationManager.AppSettings["server_agenciavirtual"];

                    port = ConfigurationManager.AppSettings["port_agenciavirtual"];

                }

                FabricaGerenciadorTransacao.CriarUsuarioBD(server, user, password, table, port);
            }
            catch (Exception)
            {
                throw;
            }

        }

    }

}
