From 438ce8c510e1ac15d5383d7f37b340ef224e7133 Mon Sep 17 00:00:00 2001 From: gleimar Date: Wed, 8 Apr 2015 23:12:13 +0000 Subject: [PATCH] bug#6130 git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@42915 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../catalogos/EditarPuntoVentaController.java | 74 ++++++++++++------- 1 file changed, 48 insertions(+), 26 deletions(-) diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/catalogos/EditarPuntoVentaController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/catalogos/EditarPuntoVentaController.java index fd6c29e3d..abc4497dd 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/catalogos/EditarPuntoVentaController.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/catalogos/EditarPuntoVentaController.java @@ -6,6 +6,8 @@ package com.rjconsultores.ventaboletos.web.gui.controladores.catalogos; import java.io.IOException; import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.SQLException; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; @@ -99,6 +101,7 @@ import com.rjconsultores.ventaboletos.service.PuntoVentaService; import com.rjconsultores.ventaboletos.service.TipoPuntoVentaService; import com.rjconsultores.ventaboletos.service.UsuarioBancarioService; import com.rjconsultores.ventaboletos.service.UsuarioService; +import com.rjconsultores.ventaboletos.utilerias.DateUtil; import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; import com.rjconsultores.ventaboletos.web.gui.controladores.configuracioneccomerciales.FechamentoParamptovtaListItemRenderer; import com.rjconsultores.ventaboletos.web.utilerias.MyComboboxPuntoVenta; @@ -790,36 +793,55 @@ public class EditarPuntoVentaController extends MyGenericForwardComposer { return getString; } - public void onClick$btnIntegracao(Event ev) { + public void onClick$btnIntegracao(Event ev) throws InterruptedException { + + Connection myConn = null; + try { - Calendar cal = Calendar.getInstance(); - cal.setTime(fecFinal.getValue()); - cal.set(Calendar.HOUR_OF_DAY, 23); - cal.set(Calendar.MINUTE, 59); - cal.set(Calendar.SECOND, 59); - + myConn = dataSource.getConnection(); + myConn.setAutoCommit(false); + + Date dateInicio = fecInicio.getValue(); + Date dateFim = fecFinal.getValue(); + + dateInicio = DateUtil.inicioFecha(dateInicio); + dateFim = DateUtil.fimFecha(dateFim); - TotvsService.cadastrarTituloAReceber(puntoVenta.getPuntoventaId(), fecInicio.getValue(), cal.getTime(), dataSource.getConnection()); - puntoVentaService.getDBSession().close(); - } catch (WrongValueException e) { - log.error("", e); - try { - Messagebox.show( - e.getMessage(), - Labels.getLabel("editarPuntoVentaController.window.title"), - Messagebox.OK, Messagebox.ERROR); - } catch (InterruptedException e1) { - log.error("", e1); - } + log.info("puntoVentaId="+puntoVenta.getPuntoventaId()+";fecInicio="+dateInicio+";fecFin="+dateFim); + + TotvsService.cadastrarTituloAReceber(puntoVenta.getPuntoventaId(), fecInicio.getValue(), dateFim, myConn); + + myConn.commit(); } catch (Exception e) { + + if (myConn != null) { + try { + myConn.rollback(); + } catch (SQLException e1) { + log.error("Erro rollback",e1); + } + } + + + if (e instanceof WrongValueException){ + throw (WrongValueException)e; + } + log.error("", e); - try { - Messagebox.show( - e.getMessage(), - Labels.getLabel("editarPuntoVentaController.window.title"), - Messagebox.OK, Messagebox.ERROR); - } catch (InterruptedException e1) { - log.error("", e1); + + + Messagebox.show( + e.getMessage(), + Labels.getLabel("editarPuntoVentaController.window.title"), + Messagebox.OK, Messagebox.ERROR); + + }finally{ + if (myConn != null){ + try { + myConn.close(); + } catch (SQLException e) { + log.error("Erro ao fechar a conexão",e); + } } } }