Example #1
0
        // SALVA/EDITA OS DADOS NO BANCO DE DADOS
        protected void Salvar_Click(object sender, EventArgs e)
        {
            try
            {
                string comando = "";

                if (Codigo.Text == "")
                {
                    // 2. CRIA A STRING DE COMANDO SQL PARA INSEIR UMA LINHA
                    comando = "INSERT INTO Computadores(Nome,Endereco,Anotacoes) VALUES('" + Nome.Text + "','" + Endereco.Text + "','" + Anotacoes.Text + "');";
                }
                else
                {
                    // 2. COMANDO PARA EDITAR A LINHA SELECIONADA
                    comando = "UPDATE Computadores SET Nome='" + Nome.Text + "',Endereco='" + Endereco.Text + "',Anotacoes='" + Anotacoes.Text + "' WHERE Codigo=" + Codigo.Text;
                }
                // 3. ENVIAR O COMANDO AO BANCO DE DADOS
                AppDatabase.OleDBTransaction db = new AppDatabase.OleDBTransaction();
                db.ConnectionString = conexao;
                db.Query(comando);

                ExibirComputadores();
            }
            catch (Exception ex)
            {
                Mensagem.Text = "Houve uma falha ao gravar o registro; " + ex.Message;
                App_Code.RecoverExceptions re = new App_Code.RecoverExceptions();
                re.SaveException(ex);
            }
        }
Example #2
0
        protected void ExecutarPing_Click(object sender, EventArgs e)
        {
            Resposta.Text = "";
            int totalLinhas = Computadores.Rows.Count;

            for (int i = 0; i <= totalLinhas - 1; i++)
            {
                string nome     = Computadores.Rows[i].Cells[1].Text;
                string endereco = Computadores.Rows[i].Cells[2].Text;
                try
                {
                    //excutar o ping
                    System.Net.NetworkInformation.Ping      envia   = new System.Net.NetworkInformation.Ping();
                    System.Net.NetworkInformation.PingReply retorno = envia.Send(endereco);

                    if (retorno.Status == System.Net.NetworkInformation.IPStatus.Success)
                    {
                        Resposta.Text += "Nome: " + nome + "<br/>";
                        Resposta.Text += "Endereço IP: " + retorno.Address.ToString() + "<br/>";
                        Resposta.Text += "Status: " + retorno.Status.ToString() + "<br/>";
                        Resposta.Text += "Tempo: " + retorno.RoundtripTime.ToString() + "ms<br/>";
                        Resposta.Text += "Tempo de vida: " + retorno.Options.Ttl.ToString() + "ms<br/>";
                        Resposta.Text += "Tamanho do Buffer: " + retorno.Buffer.Length.ToString() + "Bytes<br/>";
                    }
                    else
                    {
                        Resposta.Text += "Nome: " + nome + "<br/>";
                        Resposta.Text += "Endereço: " + endereco + "<br/>";
                        Resposta.Text += "<b>FALHA NA CONEXÃO</b>";
                    }
                }
                catch (Exception ex)
                {
                    Resposta.Text += "Nome: " + nome + "<br/>";
                    Resposta.Text += "Endereço: " + endereco + "<br/>";
                    Resposta.Text += "<b>FALHA NA CONEXÃO</b>";

                    // Grave a exceção no banco de dados
                    // Envie os dados da exceção para o seu e-mail
                    App_Code.RecoverExceptions re = new App_Code.RecoverExceptions();
                    re.SaveException(ex);
                }
                Resposta.Text += "<hr><br/>";
            }
        }