<%@page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*"%> <%@ include file="Connections/library.jsp" %> <% // *** Edit Operations: declare variables // set the form action variable String MM_editAction = request.getRequestURI(); if (request.getQueryString() != null && request.getQueryString().length() > 0) { MM_editAction += "?" + request.getQueryString(); } // connection information String MM_editDriver = null, MM_editConnection = null, MM_editUserName = null, MM_editPassword = null; // redirect information String MM_editRedirectUrl = null; // query string to execute StringBuffer MM_editQuery = null; // boolean to abort record edit boolean MM_abortEdit = false; // table information String MM_editTable = null, MM_editColumn = null, MM_recordId = null; // form field information String[] MM_fields = null, MM_columns = null; %> <% // *** Update Record: set variables if (request.getParameter("MM_update") != null && request.getParameter("MM_recordId") != null) { MM_editDriver = MM_library_DRIVER; MM_editConnection = MM_library_STRING; MM_editUserName = MM_library_USERNAME; MM_editPassword = MM_library_PASSWORD; MM_editTable = "livres"; MM_editColumn = "document_id"; MM_recordId = "" + request.getParameter("MM_recordId") + ""; MM_editRedirectUrl = "docindex.jsp"; String MM_fieldsStr = "noinventaire|value|nombreexemplaires|value|noisbn|value|typedocument|value|titre|value|titreexposition|value|lieupublication|value|datepublication|value|nbpages|value|nbpagesillustr|value|nbpagesnb|value|nbpagescoul|value|pagesfrac|value|modeacquisition|value|thematique|value|resume|value|date_modification_fiche|value||value"; String MM_columnsStr = "noinventaire|',none,''|nombreexemplaires|none,none,NULL|noisbn|',none,''|typedocument|',none,''|titre|',none,''|titreexposition|',none,''|lieupublication|',none,''|datepublication|none,none,NULL|nbpages|none,none,NULL|nbpagesillustr|none,none,NULL|nbpagesnb|none,none,NULL|nbpagescoul|none,none,NULL|pagesfrac|',none,''|modeacquisition|',none,''|thematique|',none,''|resume|',none,''|date_modification_fiche|',none,''||none,none,NULL"; // create the MM_fields and MM_columns arrays java.util.StringTokenizer tokens = new java.util.StringTokenizer(MM_fieldsStr,"|"); MM_fields = new String[tokens.countTokens()]; for (int i=0; tokens.hasMoreTokens(); i++) MM_fields[i] = tokens.nextToken(); tokens = new java.util.StringTokenizer(MM_columnsStr,"|"); MM_columns = new String[tokens.countTokens()]; for (int i=0; tokens.hasMoreTokens(); i++) MM_columns[i] = tokens.nextToken(); // set the form values for (int i=0; i+1 < MM_fields.length; i+=2) { MM_fields[i+1] = ((request.getParameter(MM_fields[i])!=null)?(String)request.getParameter(MM_fields[i]):""); } // append the query string to the redirect URL if (MM_editRedirectUrl.length() != 0 && request.getQueryString() != null) { MM_editRedirectUrl += ((MM_editRedirectUrl.indexOf('?') == -1)?"?":"&") + request.getQueryString(); } } %> <% // *** Update Record: construct a sql update statement and execute it if (request.getParameter("MM_update") != null && request.getParameter("MM_recordId") != null) { // create the update sql statement MM_editQuery = new StringBuffer("update ").append(MM_editTable).append(" set "); for (int i=0; i+1 < MM_fields.length; i+=2) { String formVal = MM_fields[i+1]; String elem; java.util.StringTokenizer tokens = new java.util.StringTokenizer(MM_columns[i+1],","); String delim = ((elem = (String)tokens.nextToken()) != null && elem.compareTo("none")!=0)?elem:""; String altVal = ((elem = (String)tokens.nextToken()) != null && elem.compareTo("none")!=0)?elem:""; String emptyVal = ((elem = (String)tokens.nextToken()) != null && elem.compareTo("none")!=0)?elem:""; if (formVal.length() == 0) { formVal = emptyVal; } else { if (altVal.length() != 0) { formVal = altVal; } else if (delim.compareTo("'") == 0) { // escape quotes StringBuffer escQuotes = new StringBuffer(formVal); for (int j=0; j < escQuotes.length(); j++) if (escQuotes.charAt(j) == '\'') escQuotes.insert(j++,'\''); formVal = "'" + escQuotes + "'"; } else { formVal = delim + formVal + delim; } } MM_editQuery.append((i!=0)?",":"").append(MM_columns[i]).append(" = ").append(formVal); } MM_editQuery.append(" where ").append(MM_editColumn).append(" = ").append(MM_recordId); if (!MM_abortEdit) { // finish the sql and execute it Driver MM_driver = (Driver)Class.forName(MM_editDriver).newInstance(); Connection MM_connection = DriverManager.getConnection(MM_editConnection,MM_editUserName,MM_editPassword); PreparedStatement MM_editStatement = MM_connection.prepareStatement(MM_editQuery.toString()); MM_editStatement.executeUpdate(); MM_connection.close(); // redirect with URL parameters if (MM_editRedirectUrl.length() != 0) { response.sendRedirect(response.encodeRedirectURL(MM_editRedirectUrl)); } } } %> <% Driver Driverlivres = (Driver)Class.forName(MM_library_DRIVER).newInstance(); Connection Connlivres = DriverManager.getConnection(MM_library_STRING,MM_library_USERNAME,MM_library_PASSWORD); PreparedStatement Statementlivres = Connlivres.prepareStatement("SELECT * FROM livres"); ResultSet livres = Statementlivres.executeQuery(); boolean livres_isEmpty = !livres.next(); boolean livres_hasData = !livres_isEmpty; Object livres_data; int livres_numRows = 0; %> <% String editeur__varDoc = "1"; if (request.getParameter("document_id") !=null) {editeur__varDoc = (String)request.getParameter("document_id");} %> <% Driver Driverediteur = (Driver)Class.forName(MM_library_DRIVER).newInstance(); Connection Connediteur = DriverManager.getConnection(MM_library_STRING,MM_library_USERNAME,MM_library_PASSWORD); PreparedStatement Statementediteur = Connediteur.prepareStatement("SELECT nom_editeur, editeur.editeur_id, livres.document_id, a_publie.document_id FROM editeur, a_publie, livres WHERE a_publie.editeur_id = editeur.editeur_id AND a_publie.document_id = livres.document_id AND livres.document_id = '" + editeur__varDoc + "'"); ResultSet editeur = Statementediteur.executeQuery(); boolean editeur_isEmpty = !editeur.next(); boolean editeur_hasData = !editeur_isEmpty; Object editeur_data; int editeur_numRows = 0; %> <% String artiste__varDoc = "1"; if (request.getParameter("document_id") !=null) {artiste__varDoc = (String)request.getParameter("document_id");} %> <% Driver Driverartiste = (Driver)Class.forName(MM_library_DRIVER).newInstance(); Connection Connartiste = DriverManager.getConnection(MM_library_STRING,MM_library_USERNAME,MM_library_PASSWORD); PreparedStatement Statementartiste = Connartiste.prepareStatement("SELECT artiste.artiste_id, nom, prenom, refere_a.artiste_id, refere_a.document_id, livres.document_id FROM artiste, refere_a, livres WHERE livres.document_id = refere_a.document_id and refere_a.artiste_id = artiste.artiste_id AND livres.document_id = '" + artiste__varDoc + "' ORDER BY nom"); ResultSet artiste = Statementartiste.executeQuery(); boolean artiste_isEmpty = !artiste.next(); boolean artiste_hasData = !artiste_isEmpty; Object artiste_data; int artiste_numRows = 0; %> <% String auteur__varDoc = "1"; if (request.getParameter("document_id") !=null) {auteur__varDoc = (String)request.getParameter("document_id") ;} %> <% Driver Driverauteur = (Driver)Class.forName(MM_library_DRIVER).newInstance(); Connection Connauteur = DriverManager.getConnection(MM_library_STRING,MM_library_USERNAME,MM_library_PASSWORD); PreparedStatement Statementauteur = Connauteur.prepareStatement("SELECT nom, prenom, auteur.auteur_id, auteur_de.document_id, livres.document_id FROM auteur, auteur_de, livres WHERE livres.document_id = auteur_de.document_id and auteur_de.auteur_id = auteur.auteur_id and livres.document_id = ('" + auteur__varDoc + "') ORDER BY nom"); ResultSet auteur = Statementauteur.executeQuery(); boolean auteur_isEmpty = !auteur.next(); boolean auteur_hasData = !auteur_isEmpty; Object auteur_data; int auteur_numRows = 0; %> <% int Repeat1__numRows = -1; int Repeat1__index = 0; artiste_numRows += Repeat1__numRows; %> <% int Repeat2__numRows = -1; int Repeat2__index = 0; auteur_numRows += Repeat2__numRows; %> <% // *** Recordset Stats, Move To Record, and Go To Record: declare stats variables int livres_first = 1; int livres_last = 1; int livres_total = -1; if (livres_isEmpty) { livres_total = livres_first = livres_last = 0; } //set the number of rows displayed on this page if (livres_numRows == 0) { livres_numRows = 1; } %> <% String MM_paramName = ""; %> <% // *** Move To Record and Go To Record: declare variables ResultSet MM_rs = livres; int MM_rsCount = livres_total; int MM_size = livres_numRows; String MM_uniqueCol = "document_id"; MM_paramName = "document_id"; int MM_offset = 0; boolean MM_atTotal = false; boolean MM_paramIsDefined = (MM_paramName.length() != 0 && request.getParameter(MM_paramName) != null); %> <% // *** Move To Specific Record: handle detail parameter if (MM_paramIsDefined && MM_rsCount != 0) { // get the value of the parameter String param = request.getParameter(MM_paramName); // find the record with the unique column value equal to the parameter value String colVal; while (livres_hasData) { colVal = ((MM_rs.getObject(MM_uniqueCol)!=null)?MM_rs.getObject(MM_uniqueCol).toString():""); if (colVal.equals(param)) break; livres_hasData = MM_rs.next(); MM_offset++; } // if not found, set the number of records and reset the cursor if (!livres_hasData) { if (MM_rsCount < 0) MM_rsCount = MM_offset; if (MM_size < 0 || MM_size > MM_rsCount) MM_size = MM_rsCount; MM_offset = 0; // reset the cursor to the beginning livres.close(); livres = Statementlivres.executeQuery(); livres_hasData = livres.next(); MM_rs = livres; } } %> <% // *** Move To Record: if we dont know the record count, check the display range if (MM_rsCount == -1) { // walk to the end of the display range for this page int i; for (i=MM_offset; livres_hasData && (MM_size < 0 || i < MM_offset + MM_size); i++) { livres_hasData = MM_rs.next(); } // if we walked off the end of the recordset, set MM_rsCount and MM_size if (!livres_hasData) { MM_rsCount = i; if (MM_size < 0 || MM_size > MM_rsCount) MM_size = MM_rsCount; } // if we walked off the end, set the offset based on page size if (!livres_hasData && !MM_paramIsDefined) { if (MM_offset > MM_rsCount - MM_size || MM_offset == -1) { //check if past end or last if (MM_rsCount % MM_size != 0) //last page has less records than MM_size MM_offset = MM_rsCount - MM_rsCount % MM_size; else MM_offset = MM_rsCount - MM_size; } } // reset the cursor to the beginning livres.close(); livres = Statementlivres.executeQuery(); livres_hasData = livres.next(); MM_rs = livres; // move the cursor to the selected record for (i=0; livres_hasData && i < MM_offset; i++) { livres_hasData = MM_rs.next(); } } %> <% // *** Move To Record: update recordset stats // set the first and last displayed record livres_first = MM_offset + 1; livres_last = MM_offset + MM_size; if (MM_rsCount != -1) { livres_first = Math.min(livres_first, MM_rsCount); livres_last = Math.min(livres_last, MM_rsCount); } // set the boolean used by hide region to check if we are on the last record MM_atTotal = (MM_rsCount != -1 && MM_offset + MM_size >= MM_rsCount); %> MAJ livres

   MAJ d'un document

Document_id: <%=(((livres_data = livres.getObject("document_id"))==null || livres.wasNull())?"":livres_data)%> No inventaire: " size="32">  
','','scrollbars=yes,width=400,height=200')"> ','','scrollbars=yes,width=400,height=200')"> ','','scrollbars=yes,width=400,height=200')"> ','','')"> ','','')"> ','','')">
Nombre exemplaires: " size="32"> No isbn: " size="32">
Type document: " size="32"> Titre: " size="32">
Titre exposition: " size="32">    
Editeur: <% if (!editeur_isEmpty ) { %> <%=(((editeur_data = editeur.getObject("nom_editeur"))==null || editeur.wasNull())?"":editeur_data)%> <% } /* end !editeur_isEmpty */ %> Lieu publication: " size="32">
Date publication: " size="32">    
Nb pages: " size="32"> Nb pages illustr: " size="32">
Nb pages nb: " size="32"> Nb pages coul: " size="32">
Pages frac: " size="32"> Mode acquisition: " size="32">
Thematique: Resume:
       
Date saisie: <%=(((livres_data = livres.getObject("date_fiche"))==null || livres.wasNull())?"":livres_data)%> Date modification fiche: <%=(((livres_data = livres.getObject("date_modification_fiche"))==null || livres.wasNull())?"":livres_data)%>
Artistes: <% while ((artiste_hasData)&&(Repeat1__numRows-- != 0)) { %> <% if (!artiste_isEmpty ) { %> <% } /* end !artiste_isEmpty */ %> <% Repeat1__index++; artiste_hasData = artiste.next(); } %>
<%=(((artiste_data = artiste.getObject("prenom"))==null || artiste.wasNull())?"":artiste_data)%> <%=(((artiste_data = artiste.getObject("nom"))==null || artiste.wasNull())?"":artiste_data)%>
Auteurs: <% while ((auteur_hasData)&&(Repeat2__numRows-- != 0)) { %> <% if (!auteur_isEmpty ) { %> <% } /* end !auteur_isEmpty */ %> <% Repeat2__index++; auteur_hasData = auteur.next(); } %>
<%=(((auteur_data = auteur.getObject("prenom"))==null || auteur.wasNull())?"":auteur_data)%> <%=(((auteur_data = auteur.getObject("nom"))==null || auteur.wasNull())?"":auteur_data)%>
     
">
 
<% livres.close(); Connlivres.close(); %> <% editeur.close(); Connediteur.close(); %> <% artiste.close(); Connartiste.close(); %> <% auteur.close(); Connauteur.close(); %>