use of entities.ElectronicDevice in project ConsoElectric by anakkarsara.
the class ElectronicDeviceDetails method doPost.
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
EntityManagerFactory factory = Persistence.createEntityManagerFactory("dev");
EntityManager manager = factory.createEntityManager();
DAO test = new DAO(manager);
EntityTransaction tx = manager.getTransaction();
tx.begin();
response.setContentType("text/html");
PrintWriter out = response.getWriter();
edd.createED(request.getParameter("name"), Double.parseDouble(request.getParameter("conso")), test.getPerson(Long.parseLong(request.getParameter("owner"))));
out.println("<h2><a href=\"index.html\">Retour page d'acueil</a></h2>");
out.println("<table border = 2 cellpadding = \"10\" cellspacing = \"10\" align= \"center\"> <tr> <th>Name</th> <th>Conso</th> <th>Proprietaire</th> </tr>");
for (ElectronicDevice next : edd.allEDs()) {
out.println(" <tr> <td>" + next.getEdName() + "</td> <td>" + next.getConsoMoy() + "</td> <td>" + next.getOwner().getFamilyName() + " " + next.getOwner().getFirstName() + "</td> </tr> ");
}
out.println("</table> ");
}
use of entities.ElectronicDevice in project ConsoElectric by anakkarsara.
the class ElectronicDeviceDetails method doGet.
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<h2><a href=\"index.html\">Retour page d'acueil</a></h2>");
out.println("<table border = 2 cellpadding = \"10\" cellspacing = \"10\" align= \"center\"> <tr> <th>Name</th> <th>Conso</th> <th>Proprietaire</th> </tr>");
for (ElectronicDevice next : edd.allEDs()) {
out.println(" <tr> <td>" + next.getEdName() + "</td> <td>" + next.getConsoMoy() + "</td> <td>" + next.getOwner().getFamilyName() + " " + next.getOwner().getFirstName() + "</td></tr> ");
}
out.println("</table> ");
}
use of entities.ElectronicDevice in project ConsoElectric by anakkarsara.
the class ElectronicDeviceDao method createED.
public void createED(String name, double conso, Person owner) {
tx.begin();
ElectronicDevice elec = new ElectronicDevice(name, conso, owner);
try {
manager.persist(elec);
} catch (Exception e) {
e.printStackTrace();
}
tx.commit();
}
Aggregations