Beispiel #1
0
        public bool validaAnimal(Animal animal)
        {
            bool entrou = true;
            if (animal.nome.Length < 3)
            {
                MessageBox.Show("Insira o nome do animal!");
                entrou = false;

            }
            return entrou;
        }
Beispiel #2
0
        public void inserirAnimal(Animal animal)
        {
            using (OdbcConnection conexao = ConexaoPadrao.createConnection())
            {
                string sql = "insert into ANIMAL (CARTEIRINHA, NOME, ID_CLIENTE, RACA_PORTE, SEXO, PELAGEM_COR, NASCIMENTO, ID_VETERINARIO ) values(?,?,?,?,?,?,?,?)";
                OdbcCommand command = new OdbcCommand(sql, conexao);

                command.Parameters.AddWithValue("@CARTEIRINHA", animal.carteirinha);
                command.Parameters.AddWithValue("@NOME", animal.nome);
                command.Parameters.AddWithValue("@ID_CLIENTE", animal.idCliente);
                command.Parameters.AddWithValue("@RACA_PORTE", animal.racaPorte);
                command.Parameters.AddWithValue("@SEXO", animal.sexo);
                command.Parameters.AddWithValue("@PELAGEM_COR", animal.pelagemCor);
                command.Parameters.AddWithValue("@NASCIMENTO", animal.nascimento);
                command.Parameters.AddWithValue("@ID_VETERINARIO", animal.idVeterinario);

                conexao.Open();
                command.ExecuteNonQuery();
            }
        }
        public void alteraAnimal(Animal animal)
        {
            using (OdbcConnection conexao = ConexaoPadrao.createConnection())
            {
                string sql = "update ANIMAL set NOME = ?, ID_CLIENTE = ?, RACA_PORTE = ?, SEXO = ?, PELAGEM_COR = ?, NASCIMENTO = ?, ID_VETERINARIO = ?,  where ID_ANIMAL = ?";
                OdbcCommand command = new OdbcCommand(sql, conexao);

                command.Parameters.AddWithValue("@NOME", animal.nome);
                command.Parameters.AddWithValue("@ID_CLIENTE", animal.idCliente);
                command.Parameters.AddWithValue("@RACA_PORTE", animal.racaPorte);
                command.Parameters.AddWithValue("@SEXO", animal.sexo);
                command.Parameters.AddWithValue("@PELAGEM_COR", animal.pelagemCor);
                command.Parameters.AddWithValue("@NASCIMENTO", animal.nascimento);
                command.Parameters.AddWithValue("@ID_VETERINARIO", animal.idVeterinario);
                command.Parameters.AddWithValue("@ID_ANIMAL", animal.id);

                conexao.Open();
                command.ExecuteNonQuery();
            }
        }