frederico 2016-10-25 12:36:47 +00:00
parent 804d51da7e
commit 93abef2f6c
1 changed files with 42 additions and 2 deletions

View File

@ -27,11 +27,13 @@ import com.rjconsultores.ventaboletos.entidad.MensajeEmpresa;
import com.rjconsultores.ventaboletos.entidad.MensajePuntoVenta; import com.rjconsultores.ventaboletos.entidad.MensajePuntoVenta;
import com.rjconsultores.ventaboletos.entidad.MensajeUsuario; import com.rjconsultores.ventaboletos.entidad.MensajeUsuario;
import com.rjconsultores.ventaboletos.entidad.PuntoVenta; import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
import com.rjconsultores.ventaboletos.service.EmpresaService;
import com.rjconsultores.ventaboletos.service.MensajeEmpresaService; import com.rjconsultores.ventaboletos.service.MensajeEmpresaService;
import com.rjconsultores.ventaboletos.service.MensajePuntaVentaService; import com.rjconsultores.ventaboletos.service.MensajePuntaVentaService;
import com.rjconsultores.ventaboletos.service.MensajeService; import com.rjconsultores.ventaboletos.service.MensajeService;
import com.rjconsultores.ventaboletos.service.MensajeUsuarioService; import com.rjconsultores.ventaboletos.service.MensajeUsuarioService;
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
import com.rjconsultores.ventaboletos.web.utilerias.MyComboboxPuntoVenta;
import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer; import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer;
import com.rjconsultores.ventaboletos.web.utilerias.MyListbox; import com.rjconsultores.ventaboletos.web.utilerias.MyListbox;
import com.rjconsultores.ventaboletos.web.utilerias.render.RenderMensajeEmpresa; import com.rjconsultores.ventaboletos.web.utilerias.render.RenderMensajeEmpresa;
@ -52,6 +54,8 @@ public class EditarMensajeController extends MyGenericForwardComposer {
private MensajeUsuarioService mensajeUsuarioService; private MensajeUsuarioService mensajeUsuarioService;
@Autowired @Autowired
private MensajeService mensajeService; private MensajeService mensajeService;
@Autowired
private EmpresaService empresaService;
private Mensaje mensaje; private Mensaje mensaje;
private Datebox txtDataInicial; private Datebox txtDataInicial;
@ -75,10 +79,11 @@ public class EditarMensajeController extends MyGenericForwardComposer {
@Override @Override
public void doAfterCompose(Component comp) throws Exception { public void doAfterCompose(Component comp) throws Exception {
busquedaMensajeController = (BusquedaMensajeController) Executions.getCurrent().getArg().get("busquedaMensajeController"); busquedaMensajeController = (BusquedaMensajeController) Executions.getCurrent().getArg().get("busquedaMensajeController");
lsEmpresa = UsuarioLogado.getUsuarioLogado().getEmpresa(); lsEmpresa = UsuarioLogado.getUsuarioLogado().getEmpresa();
lsEmpresa.add(getEmpresaTodas());
mensajeEmpresaToUpdate = new ArrayList<MensajeEmpresa>(); mensajeEmpresaToUpdate = new ArrayList<MensajeEmpresa>();
mensajePuntoVentasToUpdate = new ArrayList<MensajePuntoVenta>(); mensajePuntoVentasToUpdate = new ArrayList<MensajePuntoVenta>();
@ -111,6 +116,10 @@ public class EditarMensajeController extends MyGenericForwardComposer {
puntoVentaList.setData(lsAddPuntoVenta); puntoVentaList.setData(lsAddPuntoVenta);
} }
private Empresa getEmpresaTodas() {
return empresaService.obtenerID(-1);
}
public void onClick$btnSalvar(Event ev) throws InterruptedException, ParseException { public void onClick$btnSalvar(Event ev) throws InterruptedException, ParseException {
txtDataFinal.getValue(); txtDataFinal.getValue();
txtDataInicial.getValue(); txtDataInicial.getValue();
@ -119,6 +128,8 @@ public class EditarMensajeController extends MyGenericForwardComposer {
SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy"); SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
Date dataAtual = format.parse(format.format(new Date())); Date dataAtual = format.parse(format.format(new Date()));
validarListaTodos();
if (mensaje.getMensajeId() == null && if (mensaje.getMensajeId() == null &&
mensaje.getFecFin().before(dataAtual)) { mensaje.getFecFin().before(dataAtual)) {
Messagebox.show( Messagebox.show(
@ -186,6 +197,35 @@ public class EditarMensajeController extends MyGenericForwardComposer {
} }
} }
private void validarListaTodos() {
MensajeEmpresa empresaTodas = null;
for (MensajeEmpresa empresa : lsAddEmpresa) {
if (empresa.getEmpresa().getEmpresaId().equals(-1)) {
empresaTodas = empresa;
break;
}
}
if (empresaTodas != null) {
lsAddEmpresa.clear();
lsAddEmpresa.add(empresaTodas);
}
MensajePuntoVenta puntoVentaTodas = null;
for(MensajePuntoVenta puntoVenta : lsAddPuntoVenta){
if(puntoVenta.getPuntoVenda().getPuntoventaId().equals(-1)){
puntoVentaTodas = puntoVenta;
break;
}
}
if(puntoVentaTodas != null){
lsAddPuntoVenta.clear();
lsAddPuntoVenta.add(puntoVentaTodas);
}
}
public void onClick$btnApagar(Event ev) throws InterruptedException { public void onClick$btnApagar(Event ev) throws InterruptedException {
try { try {
int opcao = Messagebox.show( int opcao = Messagebox.show(