|
|
@ -8,7 +8,13 @@ import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.jdbc.core.JdbcTemplate; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import com.vaadin.flow.component.html.Paragraph; |
|
|
|
import com.vaadin.flow.component.icon.Icon; |
|
|
|
import com.vaadin.flow.component.icon.VaadinIcon; |
|
|
|
import com.vaadin.flow.component.notification.Notification; |
|
|
|
import com.vaadin.flow.component.notification.NotificationVariant; |
|
|
|
import com.vaadin.flow.component.orderedlayout.FlexComponent.Alignment; |
|
|
|
import com.vaadin.flow.component.orderedlayout.HorizontalLayout; |
|
|
|
|
|
|
|
import java.sql.CallableStatement; |
|
|
|
import java.sql.Connection; |
|
|
@ -82,24 +88,85 @@ public class GuardarSolicitudService { |
|
|
|
*/ |
|
|
|
|
|
|
|
callableStatement.execute(); |
|
|
|
notifiSuccess("Solicitud guardada correctamente.."); |
|
|
|
return true; |
|
|
|
|
|
|
|
} catch (SQLException e) { |
|
|
|
//e.printStackTrace(); |
|
|
|
Notification notify; |
|
|
|
notify=new Notification(); |
|
|
|
Notification.show("Error al Guardar:"+e.getMessage()); |
|
|
|
notifiError("Error al Guardar:"+e.getMessage()); |
|
|
|
return false; |
|
|
|
} |
|
|
|
catch (Exception e) { |
|
|
|
//e.printStackTrace(); |
|
|
|
Notification notify; |
|
|
|
notify=new Notification(); |
|
|
|
Notification.show("Error al Guardar:"+e.getMessage()); |
|
|
|
notifiError("Error al Guardar:"+e.getMessage()); |
|
|
|
return false; |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
private void notifiError(String message) { |
|
|
|
Notification notification = new Notification(); |
|
|
|
notification.setPosition(Notification.Position.TOP_CENTER); |
|
|
|
notification.addThemeVariants(NotificationVariant.LUMO_ERROR); |
|
|
|
notification.setDuration(3000); |
|
|
|
|
|
|
|
Icon warningIcon = new Icon(VaadinIcon.CLOSE_CIRCLE_O); |
|
|
|
warningIcon.setSize("48px"); |
|
|
|
warningIcon.getStyle().set("margin-bottom", "10px"); |
|
|
|
|
|
|
|
|
|
|
|
Paragraph messajeTexto = new Paragraph(message); |
|
|
|
messajeTexto.getStyle().set("margin", "0").set("text-align", "center"); |
|
|
|
|
|
|
|
|
|
|
|
HorizontalLayout buttonsLayout = new HorizontalLayout(warningIcon, messajeTexto); |
|
|
|
buttonsLayout.setAlignItems(Alignment.CENTER); |
|
|
|
buttonsLayout.setSpacing(false); |
|
|
|
buttonsLayout.setPadding(false); |
|
|
|
buttonsLayout.setWidthFull(); |
|
|
|
|
|
|
|
HorizontalLayout wrapper = new HorizontalLayout(buttonsLayout); |
|
|
|
wrapper.setPadding(true); |
|
|
|
wrapper.setSpacing(false); |
|
|
|
wrapper.getStyle().set("position", "relative"); |
|
|
|
wrapper.getStyle().set("padding", "10px"); |
|
|
|
wrapper.setWidth("100%"); |
|
|
|
|
|
|
|
notification.add(wrapper); |
|
|
|
notification.open(); |
|
|
|
} |
|
|
|
|
|
|
|
private void notifiSuccess(String message) { |
|
|
|
Notification notification = new Notification(); |
|
|
|
notification.setPosition(Notification.Position.TOP_CENTER); |
|
|
|
notification.addThemeVariants(NotificationVariant.LUMO_SUCCESS); |
|
|
|
notification.setDuration(3000); |
|
|
|
|
|
|
|
Icon warningIcon = new Icon(VaadinIcon.CHECK_CIRCLE_O); |
|
|
|
warningIcon.setSize("48px"); |
|
|
|
warningIcon.getStyle().set("margin-bottom", "10px"); |
|
|
|
|
|
|
|
|
|
|
|
Paragraph messajeTexto = new Paragraph(message); |
|
|
|
messajeTexto.getStyle().set("margin", "0").set("text-align", "center"); |
|
|
|
|
|
|
|
|
|
|
|
HorizontalLayout buttonsLayout = new HorizontalLayout(warningIcon, messajeTexto); |
|
|
|
buttonsLayout.setAlignItems(Alignment.CENTER); |
|
|
|
buttonsLayout.setSpacing(false); |
|
|
|
buttonsLayout.setPadding(false); |
|
|
|
buttonsLayout.setWidthFull(); |
|
|
|
|
|
|
|
HorizontalLayout wrapper = new HorizontalLayout(buttonsLayout); |
|
|
|
wrapper.setPadding(true); |
|
|
|
wrapper.setSpacing(false); |
|
|
|
wrapper.getStyle().set("position", "relative"); |
|
|
|
wrapper.getStyle().set("padding", "10px"); |
|
|
|
wrapper.setWidth("100%"); |
|
|
|
|
|
|
|
notification.add(wrapper); |
|
|
|
notification.open(); |
|
|
|
} |
|
|
|
} |