Example #1
0
        private void tentaInserirRegistro(UServidorEmail servidor)
        {
            DAL.Connection conexao = new DAL.Connection();
            conexao.Conectar();
            String query = "INSERT INTO TN_SERVIDOREMAIL(SMTP,SMTPPORTA,POP,POPPORTA,NOME,STATUS,EHSSLSMTP,EHSSLPOP)" +
                           "VALUES('" + servidor.Smtp + "'," + servidor.Smtpporta + ",'" + servidor.Pop + "'," + servidor.Popporta + ",'" + servidor.Nome + "'," +
                           StatusServidorEmail.Ativo + ",'" + servidor.Sslsmtp + "','" + servidor.Sslpop + "')";

            try
            {
                SqlDataReader reader = conexao.Pesquisa(query);
                MessageBox.Show("Inserido com sucesso!");
                reader.Close();
                conexao.Desconectar();
                conexao.Conectar();
                String        atualizaHandle = "SELECT MAX(HANDLE) HANDLE FROM TN_SERVIDOREMAIL";
                SqlDataReader reader2        = conexao.Pesquisa(atualizaHandle);
                while (reader2.Read())
                {
                    internalHandle = Convert.ToInt32(reader2["HANDLE"]);
                }
                reader2.Close();
                conexao.Desconectar();
                verificaStatus(internalHandle);
            }
            catch (SqlException e)
            {
                MessageBox.Show(e.Message);
            }
        }
Example #2
0
 private void verificaStatus(int handle)
 {
     if (handle == 0 || handle == 1)
     {
         button1.Text = "Liberar";
         button2.Text = "Limpar";
     }
     else if (handle > 0)
     {
         String         query   = "SELECT STATUS FROM TN_SERVIDOREMAIL WHERE HANDLE = " + handle;
         DAL.Connection conexao = new DAL.Connection();
         conexao.Conectar();
         SqlDataReader reader = conexao.Pesquisa(query);
         while (reader.Read())
         {
             if (Convert.ToInt32(reader["STATUS"]) == StatusServidorEmail.Cadastrado)
             {
                 button1.Text = "Liberar";
                 button2.Text = "Limpar";
             }
             else if (Convert.ToInt32(reader["STATUS"]) == StatusServidorEmail.Encerrado)
             {
                 button1.Text = "Voltar";
                 button2.Text = "Cancelar";
             }
         }
         conexao.Desconectar();
         reader.Close();
     }
 }
Example #3
0
 private void botaoLimpar(int handle)
 {
     if (handle == 0)
     {
         richTextBoxPop.Text       = "";
         richTextBoxPopPorta.Text  = "";
         richTextBoxSmtp.Text      = "";
         richTextBoxSmtpPorta.Text = "";
         richTextBoxNome.Text      = "";
     }
     else
     {
         DAL.Connection conexao = new DAL.Connection();
         conexao.Conectar();
         String        query  = "SELECT * FROM TN_SERVIDOREMAIL WHERE HANDLE = " + handle;
         SqlDataReader reader = conexao.Pesquisa(query);
         while (reader.Read())
         {
             richTextBoxSmtp.Text      = reader["SMTP"].ToString();
             richTextBoxSmtpPorta.Text = reader["SMTPPORTA"].ToString();
             richTextBoxPop.Text       = reader["POP"].ToString();
             richTextBoxPopPorta.Text  = reader["POPPORTA"].ToString();
             richTextBoxNome.Text      = reader["NOME"].ToString();
         }
         reader.Close();
         conexao.Desconectar();
     }
 }
Example #4
0
        public static int BuscarHandleRegistro(String tabela, String campo, String valorCampo)
        {
            int    handle = 0;
            String query;

            query = "SELECT HANDLE FROM " + tabela + " WHERE " + campo + " = " + valorCampo;
            DAL.Connection conexao = new DAL.Connection();
            conexao.Conectar();
            conexao.Pesquisa(query);
            SqlDataReader resultSet;

            resultSet = conexao.Pesquisa(query);
            while (resultSet.Read())
            {
                try
                {
                    handle = Convert.ToInt32(resultSet["HANDLE"]);
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message);
                }
            }
            resultSet.Close();
            conexao.Desconectar();

            if (String.IsNullOrEmpty(handle.ToString()) || handle == 0)
            {
                MessageBox.Show("Não é possível instanciar objeto com handle = 0");
            }

            return(handle);
        }
Example #5
0
        public static int getHandleUsuarioAtual(String usuario)
        {
            int    handleAtual = 0;
            String query       = "SELECT HANDLE FROM US_USUARIO WHERE USUARIO = " + usuario;

            DAL.Connection conexao = new DAL.Connection();
            conexao.Conectar();

            SqlDataReader reader = conexao.Pesquisa(query);

            while (reader.Read())
            {
                handleAtual = Convert.ToInt32(reader["HANDLE"]);

                if (handleAtual == 0)
                {
                    MessageBox.Show("Não foi possível atribuir um handle para o usuário : " + usuario);
                }
            }
            reader.Close();
            conexao.Desconectar();
            return(handleAtual);
        }