<%-- Document : exec_agregar_sistemas_operativos Created on : 23/11/2011, 02:37:41 PM Author : psoto --%> <%@page contentType="text/html"%> <%@page pageEncoding="UTF-8"%> <%@page import = "conexion.*" import = "java.sql.*" import = "general.Config" import = "general.Permisos" %> Actualizando el sistema... <% /************************** Guarda los cambios hechos a los datos del usuario en la base de datos **************************************/ out.println(""); String nompag[] = request.getRequestURI().split("/"); %> <% Connection lcnt_con = null; ResultSet lrs_res = null; Statement lst_stm = null; String ls_query = new String(""); String emergent_error = new String(""); boolean lb_connection = false; String debug = new String("si"); boolean valido = true; // Conexión a la base de datos try { if (!Config.getParametro("debug").equals("si")) { debug = "no"; } ConexionEquipos c = new ConexionEquipos(); lcnt_con = c.getConnection(); lst_stm = lcnt_con.createStatement(); lb_connection = true; } catch (Exception e) { emergent_error = "Error al conectarse a la base de datos "; if (debug.equals("si")) { emergent_error += e; } lb_connection = false; } //********* Validación fundamental para evitar ejecución de código sin privilegios suficientes **********// try { if (!Permisos.PermisoModulo(nompag[nompag.length - 1].toString(), Integer.parseInt(session.getAttribute("id_user").toString()))) { if (lb_connection) { lst_stm.close(); lcnt_con.close(); } emergent_error += " Privilegios insuficientes. "; lb_connection = false; } } catch (Exception e) { emergent_error += " Privilegios insuficientes. "; if (debug.equals("si")) { emergent_error += "Trace: " + e.toString(); } lb_connection = false; } //*******************************************************************************************************// if (lb_connection) { try { ls_query = "Select nombre_categoria from cat_categorias where nombre_categoria='" + request.getParameter("nombre_categoria") + "'"; lrs_res = lst_stm.executeQuery(ls_query); if (lrs_res.next()) { %>
La Nombre proporcionado para la nueva Categoria ya existe. Pruebe con Otro.

  
<% }else { %>
Actualizando la base de datos, espere por favor...
<% lst_stm.executeUpdate("START TRANSACTION;"); ls_query = "INSERT INTO cat_categorias (nombre_categoria) " + "VALUES( " + " '" + request.getParameter("nombre_categoria") + "' " + " );"; lst_stm.executeUpdate(ls_query); //Registrar en la bitácora try { String mensaje_log = new String(""); mensaje_log = "Usuario -" + session.getAttribute("username").toString() + "- agrego la Categorias de Tickets - " + request.getParameter("nombre_categoria") + " -;"; Config.GuardarLog(Integer.parseInt(session.getAttribute("id_user").toString()), mensaje_log, 3); } catch (Exception e) { } session.setAttribute("mensaje_pendiente", "El sistema ha sido actualizado, los datos de la Categorias de Ticket's - " + request.getParameter("nombre_categoria") + " - fueron actualizados."); lst_stm.executeUpdate("COMMIT;"); %> <% } } catch (Exception e) { emergent_error = "Error al actualizar la base de datos "; lst_stm.executeUpdate("ROLLBACK;"); if (debug.equals("si")) { emergent_error += e + " Query actual: " + ls_query; } %>
<%=emergent_error%>
<% } finally { lst_stm.close(); lcnt_con.close(); } } else { %>
<%=emergent_error%>
<% } %>