diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/configuracioneccomerciales/EditarMotivoCancelacionController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/configuracioneccomerciales/EditarMotivoCancelacionController.java index 058b8442c..e55fb11c3 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/configuracioneccomerciales/EditarMotivoCancelacionController.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/configuracioneccomerciales/EditarMotivoCancelacionController.java @@ -25,162 +25,163 @@ import org.zkoss.zul.Messagebox; import org.zkoss.zul.Textbox; /** - * + * * @author Rafius */ @Controller("editarMotivoCancelacionController") @Scope("prototype") public class EditarMotivoCancelacionController extends MyGenericForwardComposer { - @Autowired - private MotivoCancelacionService motivoCancelacionService; - private MotivoCancelacion motivoCancelacion; - private MyListbox motivoCancelacionList; - private static Logger log = Logger.getLogger(EditarMotivoCancelacionController.class); - private Textbox txtNome; - private Button btnApagar; - private Button btnSalvar; - private Combobox cmbTipoMotivo; + private static final long serialVersionUID = 1L; - public Button getBtnApagar() { - return btnApagar; - } + @Autowired + private MotivoCancelacionService motivoCancelacionService; + private MotivoCancelacion motivoCancelacion; + private MyListbox motivoCancelacionList; + private static Logger log = Logger.getLogger(EditarMotivoCancelacionController.class); + private Textbox txtNome; + private Button btnApagar; + private Combobox cmbTipoMotivo; - public void setBtnApagar(Button btnApagar) { - this.btnApagar = btnApagar; - } + public Button getBtnApagar() { + return btnApagar; + } - public Textbox getTxtNome() { - return txtNome; - } + public void setBtnApagar(Button btnApagar) { + this.btnApagar = btnApagar; + } - public void setTxtNome(Textbox txtNome) { - this.txtNome = txtNome; - } + public Textbox getTxtNome() { + return txtNome; + } - @Override - public void doAfterCompose(Component comp) throws Exception { - super.doAfterCompose(comp); + public void setTxtNome(Textbox txtNome) { + this.txtNome = txtNome; + } - motivoCancelacion = (MotivoCancelacion) Executions.getCurrent().getArg().get("motivoCancelacion"); - motivoCancelacionList = (MyListbox) Executions.getCurrent().getArg().get("motivoCancelacionList"); + @Override + public void doAfterCompose(Component comp) throws Exception { + super.doAfterCompose(comp); - if (motivoCancelacion.getMotivocancelacionId() == null) { - btnApagar.setVisible(Boolean.FALSE); - } else { - if (motivoCancelacion.getMotivocancelacionId() <= 35) { - btnApagar.setVisible(false); - txtNome.setDisabled(true); + motivoCancelacion = (MotivoCancelacion) Executions.getCurrent().getArg().get("motivoCancelacion"); + motivoCancelacionList = (MyListbox) Executions.getCurrent().getArg().get("motivoCancelacionList"); - Messagebox.show( - Labels.getLabel("MSG.noEditabled"), - Labels.getLabel("editarMotivoCancelacionController.window.title"), - Messagebox.OK, Messagebox.INFORMATION); - } - } + if (motivoCancelacion.getMotivocancelacionId() == null) { + btnApagar.setVisible(Boolean.FALSE); + } else { + if (motivoCancelacionService.validaMotivoCancelacionConstante(motivoCancelacion)) { + btnApagar.setVisible(false); + txtNome.setDisabled(true); - txtNome.focus(); - } + Messagebox.show( + Labels.getLabel("MSG.noEditabled"), + Labels.getLabel("editarMotivoCancelacionController.window.title"), + Messagebox.OK, Messagebox.INFORMATION); + } + } - public void onClick$btnSalvar(Event ev) throws InterruptedException { - txtNome.getValue(); - cmbTipoMotivo.getValue(); - try { - motivoCancelacion.setActivo(true); - motivoCancelacion.setFecmodif(Calendar.getInstance().getTime()); - motivoCancelacion.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); - if (motivoCancelacion.getTipomotivo() == null) { - Messagebox.show( - Labels.getLabel("editarMotivoCancelacionController.MSG.tipo"), - Labels.getLabel("editarMotivoCancelacionController.window.title"), - Messagebox.OK, Messagebox.EXCLAMATION); - } else { - if (motivoCancelacion.getMotivocancelacionId() == null) { - List lsMotivoCancelacion = - motivoCancelacionService.buscar(motivoCancelacion.getDescmotivo(), - motivoCancelacion.getTipomotivo()); + txtNome.focus(); + } - if (lsMotivoCancelacion.isEmpty()) { - motivoCancelacionService.suscribir(motivoCancelacion); - motivoCancelacionList.addItem(motivoCancelacion); + public void onClick$btnSalvar(Event ev) throws InterruptedException { + txtNome.getValue(); + cmbTipoMotivo.getValue(); + try { + motivoCancelacion.setActivo(true); + motivoCancelacion.setFecmodif(Calendar.getInstance().getTime()); + motivoCancelacion.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + if (motivoCancelacion.getTipomotivo() == null) { + Messagebox.show( + Labels.getLabel("editarMotivoCancelacionController.MSG.tipo"), + Labels.getLabel("editarMotivoCancelacionController.window.title"), + Messagebox.OK, Messagebox.EXCLAMATION); + } else { + if (motivoCancelacion.getMotivocancelacionId() == null) { + List lsMotivoCancelacion = + motivoCancelacionService.buscar(motivoCancelacion.getDescmotivo(), + motivoCancelacion.getTipomotivo()); - Messagebox.show( - Labels.getLabel("editarMotivoCancelacionController.MSG.suscribirOK"), - Labels.getLabel("editarMotivoCancelacionController.window.title"), - Messagebox.OK, Messagebox.INFORMATION); - } else { - Messagebox.show( - Labels.getLabel("MSG.Registro.Existe"), - Labels.getLabel("editarMotivoCancelacionController.window.title"), - Messagebox.OK, Messagebox.EXCLAMATION); - } - } else { - motivoCancelacionService.actualizacion(motivoCancelacion); - motivoCancelacionList.updateItem(motivoCancelacion); + if (lsMotivoCancelacion.isEmpty()) { + motivoCancelacionService.suscribir(motivoCancelacion); + motivoCancelacionList.addItem(motivoCancelacion); - Messagebox.show( - Labels.getLabel("editarMotivoCancelacionController.MSG.suscribirOK"), - Labels.getLabel("editarMotivoCancelacionController.window.title"), - Messagebox.OK, Messagebox.INFORMATION); - } + Messagebox.show( + Labels.getLabel("editarMotivoCancelacionController.MSG.suscribirOK"), + Labels.getLabel("editarMotivoCancelacionController.window.title"), + Messagebox.OK, Messagebox.INFORMATION); + } else { + Messagebox.show( + Labels.getLabel("MSG.Registro.Existe"), + Labels.getLabel("editarMotivoCancelacionController.window.title"), + Messagebox.OK, Messagebox.EXCLAMATION); + } + } else { + motivoCancelacionService.actualizacion(motivoCancelacion); + motivoCancelacionList.updateItem(motivoCancelacion); - closeWindow(); - } - } catch (Exception ex) { - log.error("editarMotivoCancelacionController: " + ex); - Messagebox.show( - Labels.getLabel("MSG.Error"), - Labels.getLabel("editarMotivoCancelacionController.window.title"), - Messagebox.OK, Messagebox.ERROR); - } - } + Messagebox.show( + Labels.getLabel("editarMotivoCancelacionController.MSG.suscribirOK"), + Labels.getLabel("editarMotivoCancelacionController.window.title"), + Messagebox.OK, Messagebox.INFORMATION); + } - public void onClick$btnApagar(Event ev) { - try { - int resp = Messagebox.show( - Labels.getLabel("editarMotivoCancelacionController.MSG.borrarPergunta"), - Labels.getLabel("editarMotivoCancelacionController.window.title"), - Messagebox.YES | Messagebox.NO, Messagebox.QUESTION); + closeWindow(); + } + } catch (Exception ex) { + log.error("editarMotivoCancelacionController: " + ex); + Messagebox.show( + Labels.getLabel("MSG.Error"), + Labels.getLabel("editarMotivoCancelacionController.window.title"), + Messagebox.OK, Messagebox.ERROR); + } + } - if (resp == Messagebox.YES) { + public void onClick$btnApagar(Event ev) { + try { + int resp = Messagebox.show( + Labels.getLabel("editarMotivoCancelacionController.MSG.borrarPergunta"), + Labels.getLabel("editarMotivoCancelacionController.window.title"), + Messagebox.YES | Messagebox.NO, Messagebox.QUESTION); - motivoCancelacionService.borrar(motivoCancelacion); + if (resp == Messagebox.YES) { - Messagebox.show( - Labels.getLabel("editarMotivoCancelacionController.MSG.borrarOK"), - Labels.getLabel("editarMotivoCancelacionController.window.title"), - Messagebox.OK, Messagebox.INFORMATION); + motivoCancelacionService.borrar(motivoCancelacion); - motivoCancelacionList.removeItem(motivoCancelacion); + Messagebox.show( + Labels.getLabel("editarMotivoCancelacionController.MSG.borrarOK"), + Labels.getLabel("editarMotivoCancelacionController.window.title"), + Messagebox.OK, Messagebox.INFORMATION); - closeWindow(); - } - } catch (Exception ex) { - log.error(ex); - } - } + motivoCancelacionList.removeItem(motivoCancelacion); - public MotivoCancelacion getMotivoCancelacion() { - return motivoCancelacion; - } + closeWindow(); + } + } catch (Exception ex) { + log.error(ex); + } + } - public void setMotivoCancelacion(MotivoCancelacion motivoCancelacion) { - this.motivoCancelacion = motivoCancelacion; - } + public MotivoCancelacion getMotivoCancelacion() { + return motivoCancelacion; + } - public MyListbox getMotivoCancelacionList() { - return motivoCancelacionList; - } + public void setMotivoCancelacion(MotivoCancelacion motivoCancelacion) { + this.motivoCancelacion = motivoCancelacion; + } - public void setMotivoCancelacionList(MyListbox motivoCancelacionList) { - this.motivoCancelacionList = motivoCancelacionList; - } + public MyListbox getMotivoCancelacionList() { + return motivoCancelacionList; + } - public MotivoCancelacionService getMotivoCancelacionService() { - return motivoCancelacionService; - } + public void setMotivoCancelacionList(MyListbox motivoCancelacionList) { + this.motivoCancelacionList = motivoCancelacionList; + } - public void setMotivoCancelacionService(MotivoCancelacionService motivoCancelacionService) { - this.motivoCancelacionService = motivoCancelacionService; - } + public MotivoCancelacionService getMotivoCancelacionService() { + return motivoCancelacionService; + } + + public void setMotivoCancelacionService(MotivoCancelacionService motivoCancelacionService) { + this.motivoCancelacionService = motivoCancelacionService; + } }