gleimar 2015-04-08 23:12:13 +00:00
parent 666c749932
commit 438ce8c510
1 changed files with 48 additions and 26 deletions

View File

@ -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) {
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);
public void onClick$btnIntegracao(Event ev) throws InterruptedException {
Connection myConn = null;
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);
}
myConn = dataSource.getConnection();
myConn.setAutoCommit(false);
Date dateInicio = fecInicio.getValue();
Date dateFim = fecFinal.getValue();
dateInicio = DateUtil.inicioFecha(dateInicio);
dateFim = DateUtil.fimFecha(dateFim);
log.info("puntoVentaId="+puntoVenta.getPuntoventaId()+";fecInicio="+dateInicio+";fecFin="+dateFim);
TotvsService.cadastrarTituloAReceber(puntoVenta.getPuntoventaId(), fecInicio.getValue(), dateFim, myConn);
myConn.commit();
} catch (Exception e) {
log.error("", 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);
Messagebox.show(
e.getMessage(),
Labels.getLabel("editarPuntoVentaController.window.title"),
Messagebox.OK, Messagebox.ERROR);
} catch (InterruptedException e1) {
log.error("", e1);
}finally{
if (myConn != null){
try {
myConn.close();
} catch (SQLException e) {
log.error("Erro ao fechar a conexão",e);
}
}
}
}