/*
 * GerenteBD.java
 *
 * Created on 27 de Abril de 2006, 09:52
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package veterinaria;

import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 *
 * @author aluno
 */
public class GerenteBD {
    Connection conexao;
    
    /** Creates a new instance of GerenteBD */
    public GerenteBD(Connection c) {
        conexao=c;
        
        
    }
    public boolean incluirAnimal(Animal animal){
        String sql="insert into animal values (? ,? ,? )";
        try {
            PreparedStatement pst;
            pst=conexao.prepareStatement(sql);
            pst.setString(1, animal.getRegistro());
            pst.setString(2, animal.getNome());
            pst.setDate(3, (Date) animal.getDataNascimento());
            return true;
        } catch (SQLException ex) {
            ex.printStackTrace();
            return false;
        }
        
    }
    
    public boolean incluirVacina(Vacina vacina){
        String sql=" INSERT INTO Vacina VALUES (nome, lote) (?, ?)"; 
        PreparedStatement pst;
        try {     
            pst= conexao.prepareStatement(sql);
            pst.setString (2, vacina.getLote());  
            pst.setString (1, vacina.getNome());
            return true;
        } catch (SQLException ex) {
            ex.printStackTrace();
            return false;
        }
        
        
              
    }

    public boolean incluirVeterinario(Veterinario veterinario){
        String sql="insert into Veterinario values (?,?,?,?)";
        try {
            PreparedStatement pst;
            pst=conexao.prepareStatement(sql);
            pst.setString(1,veterinario.getCrv());
            pst.setString(2,veterinario.getNome());
            pst.setFloat(3,veterinario.getSalario());
            //pst.setDate(1,veterinario.getDataAdmissao());
            return true;
        } catch (SQLException ex) {
            ex.printStackTrace();
            return false;
        }
    }

    public boolean incluirCliente(Cliente cliente){
        String sql= "INSERT INTO animal VALUES(?, ?, ?)";
        PreparedStatement pst;
        try {
            pst= conexao.prepareStatement(sql);
            pst.setString(1,cliente.getNome());
            pst.setString(2,cliente.getCPF());
            pst.setString(3,cliente.getTelefone());
            pst.setString(4,cliente.getEndereco());
        } catch (SQLException ex) {
            ex.printStackTrace();
            return false;
        }
        return true;
    }

     public boolean incluirMedicamento (Medicamento medicamento) {
        String sql = "INSERT INTO Medicamento (nome, preco) Values (?, ?)";
        PreparedStatement pst;
        try {
            pst = conexao.prepareStatement(sql);        
            pst.setString(1, medicamento.getNome());
            pst.setFloat(2, medicamento.getPreco());
            return true;
        } catch (SQLException ex) {
            ex.printStackTrace();
            return false;
        }

    } 
}


