<%-- Document : desp_listado_dependencias Created on : 25/02/2013, 09:45:04 AM Author : Martha --%> <%@page contentType="text/html"%> <%@page pageEncoding="UTF-8"%> <%@page import = "conexion.*" import = "java.sql.*" import = "general.Config" import = "general.Permisos" import = "own.codec.*" import = "java.text.NumberFormat" %> Desplegar UR de Dependencias del Sistema <% /****** Despliega la lista de dependencias del sistema filtrados por el texto de búsqueda de buscar_cines.jsp (no obligatorio)***********/ /********************************************creado por: Ing Martha*******************************************************/ out.println(""); String nompag[] = request.getRequestURI().split("/"); %> <% //Conexion c = null; //Connection lcnt_con = null; ResultSet lrs_res = null; Statement lst_stm = null; String ls_query = new String(""); /*INICIO. Segunda Conexión*/ ConexionDeclaranet cd = null; Connection lcd_connection = null; //Statement lstg_conecta=null; /*FIN. SEGUNDA CONEXIÓN*/ String emergent_error = new String(""); boolean lb_connection = false; String debug = new String("si"); boolean elementos_encontrados = false; //String patron_busqueda = new String(""); String patron_enviar = new String(""); //String tipo_enviar = new String(""); //String tipo_busqueda = new String(""); // String lower_limit = new String("0"); //String upper_limit = new String("50"); String total_ur = new String("0"); String fecha = "0000-00-00"; boolean permiso_agregar = false; boolean permiso_editar = false; boolean permiso_eliminar = false; boolean permiso_ver_ur = false; /********* INICIO. Conexión a la base de datos ********/ try { if (!Config.getParametro("debug").equals("si")) { debug = "no"; } cd = new ConexionDeclaranet(); lcd_connection = cd.getConnection(); lst_stm = lcd_connection.createStatement(); lb_connection = true; }catch (Exception e) { emergent_error = "Error al conectarse a la base de datos 2 "; if (debug.equals("si")) { emergent_error += "Trace: " + e.toString(); } lb_connection = false; } /*FIN. CONEXIÓN A LA BASE DE DATOS 2*/ //********* 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(); lrs_res.close(); lcd_connection.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 " + " COUNT(u.id_cat_dep_estatales) as total_ur " + "FROM ur u " + " where id_cat_dep_estatales="+request.getParameter("id_dep") +";"; //out.println(ls_query); lrs_res = lst_stm.executeQuery(ls_query); if (lrs_res.next()) { total_ur = lrs_res.getString("total_ur"); } else { total_ur = "0"; } permiso_agregar = Permisos.PermisoModulo("frm_agregar_ur.jsp", Integer.parseInt(session.getAttribute("id_user").toString())); permiso_eliminar = Permisos.PermisoModulo("desp_desactivar_ur.jsp", Integer.parseInt(session.getAttribute("id_user").toString())); permiso_editar = Permisos.PermisoModulo("frm_agregar_ur.jsp", Integer.parseInt(session.getAttribute("id_user").toString())); //permiso_ver_ur = Permisos.PermisoModulo("frm_agregar_ur.jsp", Integer.parseInt(session.getAttribute("id_user").toString())); %>
LISTADO DE UR DE LA UNIDAD PRESUPUESTAL PROGRAMATICA O DEPENDENCIA.
TOTAL DE UNIDAD RESPONSABLE: <%=total_ur%>
<% //Intentando recuperar variable de sesión para mensajes pendientes try { String mensaje_pendiente = session.getAttribute("mensaje_pendiente").toString(); %>
<%=mensaje_pendiente%>
<% session.removeAttribute("mensaje_pendiente"); } catch (Exception e) { } %>
<% ls_query = "SELECT d.nombre_dep, u.status, u.id_cat_unidades_responsables, " + " u.nombre_unidad_responsable, id_ur, id_cat_dep_estatales " + "from ur u left join dependencias d USING(id_cat_dep_estatales) " + " where u.id_cat_dep_estatales="+request.getParameter("id_dep")+";"; lrs_res = lst_stm.executeQuery(ls_query); if(lrs_res.next()){ %> <% if (permiso_editar) { %> <% } if (permiso_eliminar) { %> <% } //if (permiso_ver_ur) { %> <% //}%> <% do{ %> <% if(permiso_editar){ %> <% } %> <% if (permiso_eliminar) { if (lrs_res.getBoolean("status")) { %> <% } else { %> <% } } %> <% } while(lrs_res.next()); } %>
<%=lrs_res.getString("nombre_dep")%>
ID UR StatusEditarEliminar
<%=lrs_res.getString("id_ur")%> <%=lrs_res.getString("nombre_unidad_responsable")%> <% if (lrs_res.getString("status").equals("1")){ out.println("Alta"); } else{ out.print("Baja"); } %> &id_dep=<%=lrs_res.getString("id_cat_dep_estatales")%>"> " /> " /> " />
  <% if (permiso_agregar) { %> " id="id_dep" name="id_dep"/>    <% } %>
<% } catch (Exception e) { emergent_error += "Error: " + e.toString() + " Ultimo query: " + ls_query; %>
<%=emergent_error%>
<% } finally { //lrs_res.close(); lst_stm.close(); lcd_connection.close(); } } else { %>
<%=emergent_error%>
<% } //Registrar en la bitácora try { String mensaje_log = new String(""); if (patron_enviar.equals("")) { mensaje_log = "Usuario -" + session.getAttribute("username").toString() + "- desplegó lista de ur;"; } else { mensaje_log = "Usuario -" + session.getAttribute("username").toString() + "- realizó búsqueda de ur -" + patron_enviar.substring(17) + "-;"; } Config.GuardarLog(Integer.parseInt(session.getAttribute("id_user").toString()), mensaje_log, 3); } catch (Exception e) { } %>