public void registarAssembleia(String key, AssembleiaDeVoto value) { try { conn = SqlConnect.connect(); for (Eleitor e : value.getResponsaveis()) { if (e.getCargoVP() == Eleitor.vPresidenteType) { PreparedStatement sql2 = conn.prepareStatement( "INSERT INTO `AVConstituintes` VALUES ('" + e.getNrEleitor() + "','" + key + "','" + value.getEleicao() + "',false,true,false,false)"); sql2.executeUpdate(); } if (e.getCargoVP() == Eleitor.presidenteType) { PreparedStatement sql2 = conn.prepareStatement( "INSERT INTO `AVConstituintes` VALUES ('" + e.getNrEleitor() + "','" + key + "','" + value.getEleicao() + "',true,false,false,false)"); sql2.executeUpdate(); } if (e.getCargoVP() == Eleitor.secType) { PreparedStatement sql2 = conn.prepareStatement( "INSERT INTO `AVConstituintes` VALUES ('" + e.getNrEleitor() + "','" + key + "','" + value.getEleicao() + "',false,false,true,false)"); sql2.executeUpdate(); } if (e.getCargoVP() == Eleitor.escType) { PreparedStatement sql2 = conn.prepareStatement( "INSERT INTO `AVConstituintes` VALUES ('" + e.getNrEleitor() + "','" + key + "','" + value.getEleicao() + "',false,false,false,true)"); sql2.executeUpdate(); } } } catch (SQLException | ClassNotFoundException e) { e.printStackTrace(); } finally { try { conn.close(); } catch (Exception e) { e.printStackTrace(); } } }
public AssembleiaDeVoto put(String key, AssembleiaDeVoto value) { try { conn = SqlConnect.connect(); String s = "Replace INTO `assembleia de voto` VALUES ('" + key + "','" + value.getEleicao() + "','" + value.getConcelho() + "','" + value.getFreguesia() + "','" + value.getHabertura() + "','" + value.getHencerramento() + "','" + value.getLocal() + "','" + value.getNrEleitores() + "','" + value.getNrVotantes() + "','" + value.getVotosBrancos() + "','" + value.getVotosNulos() + "','" + value.getNrReclamacoes() + "')"; PreparedStatement sql = conn.prepareStatement(s); for (Eleitor e : value.getResponsaveis()) { if (e.getCargoVP() == Eleitor.vPresidenteType) { PreparedStatement sql2 = conn.prepareStatement( "INSERT INTO `AVConstituintes` VALUES ('" + e.getNrEleitor() + "','" + key + "','" + value.getEleicao() + "',false,true,false,false)"); sql2.executeUpdate(); } if (e.getCargoVP() == Eleitor.presidenteType) { PreparedStatement sql2 = conn.prepareStatement( "INSERT INTO `AVConstituintes` VALUES ('" + e.getNrEleitor() + "','" + key + "','" + value.getEleicao() + "',true,false,false,false)"); sql2.executeUpdate(); } if (e.getCargoVP() == Eleitor.secType) { PreparedStatement sql2 = conn.prepareStatement( "INSERT INTO `AVConstituintes` VALUES ('" + e.getNrEleitor() + "','" + key + "','" + value.getEleicao() + "',false,false,true,false)"); sql2.executeUpdate(); } if (e.getCargoVP() == Eleitor.escType) { PreparedStatement sql2 = conn.prepareStatement( "INSERT INTO `AVConstituintes` VALUES ('" + e.getNrEleitor() + "','" + key + "','" + value.getEleicao() + "',false,false,false,true)"); sql2.executeUpdate(); } } } catch (SQLException | ClassNotFoundException e) { e.printStackTrace(); } finally { try { conn.close(); } catch (Exception e) { e.printStackTrace(); return null; } } return value; }