<%@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;
%>
<%
// *** Delete Record: construct a sql delete statement and execute it

if (request.getParameter("MM_delete") != 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 = "refere_a";
  MM_editColumn = "artiste_id";
  MM_recordId = "" + request.getParameter("MM_recordId") + "";
  MM_editRedirectUrl = "";

  // append the query string to the redirect URL
  if (MM_editRedirectUrl.length() != 0 && request.getQueryString() != null) {
    MM_editRedirectUrl += ((MM_editRedirectUrl.indexOf('?') == -1)?"?":"&") + request.getQueryString();
  }
}
%>
<%
// *** Delete Record: construct a sql delete statement and execute it

if (request.getParameter("MM_delete") != null &&
    request.getParameter("MM_recordId") != null) {

  // create the delete sql statement
  MM_editQuery = new StringBuffer("delete from ").append(MM_editTable);
  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));
    }
  }
}
%>
<%
String artiste__MMColParam = "1";
if (request.getParameter("artiste_id") !=null) {artiste__MMColParam = (String)request.getParameter("artiste_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 *  FROM refere_a  WHERE artiste_id = " + artiste__MMColParam + "");
ResultSet artiste = Statementartiste.executeQuery();
boolean artiste_isEmpty = !artiste.next();
boolean artiste_hasData = !artiste_isEmpty;
Object artiste_data;
int artiste_numRows = 0;
%>
<html>
<head>
<title>Supprime artiste</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="lmstk.css" type="text/css">
</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0">
  <tr>
    <td bgcolor="#4A494A"><img src="images/lmstk.png" width="760" height="82"></td>
  </tr>
  <tr>
    <td><br> &nbsp;&nbsp;<span class="rubFat">Supprimer un artiste</span> <form name="form1" method="POST" action="<%=MM_editAction%>">
        <table width="550" border="0" cellspacing="0" cellpadding="0" align="center">
          <% if (!artiste_isEmpty ) { %>
          <tr> 
            <td><%=(((artiste_data = artiste.getObject("document_id"))==null || artiste.wasNull())?"":artiste_data)%></td>
            <td>&nbsp;</td>
            <td><%=(((artiste_data = artiste.getObject("artiste_id"))==null || artiste.wasNull())?"":artiste_data)%></td>
            <td> <input type="submit" name="Submit" value="Supprime"> </td>
          </tr>
          <% } /* end !artiste_isEmpty */ %>
        </table>
        <input type="hidden" name="MM_delete" value="form1">
        <input type="hidden" name="MM_recordId" value="<%=(((artiste_data = artiste.getObject("artiste_id"))==null || artiste.wasNull())?"":artiste_data)%>">
      </form></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
</table>
</body>
</html>
<%
artiste.close();
Connartiste.close();
%>