1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287
| <%@ page language="java" contentType="text/html; charset=ISO-8859-1" %>
<%@ page import="java.sql.PreparedStatement" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.DriverManager" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%!
public int nullIntconv(String str)
{
int conv=0;
if(str==null)
{
str="0";
}
else if((str.trim()).equals("null"))
{
str="0";
}
else if(str.equals(""))
{
str="0";
}
try{
conv=Integer.parseInt(str);
}
catch(Exception e)
{
}
return conv;
}
%>
<%
Connection conn = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
// conn = DriverManager.getConnection("jdbc:mysql://localhost/mysql","root","realmadrid");
conn = DriverManager.getConnection("jdbc:mysql://localhost/mysql","root","realmadrid");
ResultSet rsPagination = null;
ResultSet rsRowCnt = null;
PreparedStatement psPagination=null;
PreparedStatement psRowCnt=null;
int iShowRows=5; // Number of records show on per page
int iTotalSearchRecords=10; // Number of pages index shown
int iTotalRows=nullIntconv(request.getParameter("iTotalRows"));
int iTotalPages=nullIntconv(request.getParameter("iTotalPages"));
int iPageNo=nullIntconv(request.getParameter("iPageNo"));
int cPageNo=nullIntconv(request.getParameter("cPageNo"));
int iStartResultNo=0;
int iEndResultNo=0;
if(iPageNo==0)
{
iPageNo=0;
}
else{
iPageNo=Math.abs((iPageNo-1)*iShowRows);
}
String sqlPagination="SELECT SQL_CALC_FOUND_ROWS * FROM ordinateur limit "+iPageNo+","+iShowRows+"" ;
//String sqlPagination="SELECT SQL_CALC_FOUND_ROWS * FROM inventaire where DEVICEID='"+request.getParameter("nom")+"' limit "+iPageNo+","+iShowRows+"";
//String sqlPagination="SELECT SQL_CALC_FOUND_ROWS * FROM ordinateur where OrdinateurNom='"+request.getParameter("nom")+"' limit "+iPageNo+","+iShowRows+"";
psPagination=conn.prepareStatement(sqlPagination);
rsPagination=psPagination.executeQuery();
//// this will count total number of rows
String sqlRowCnt="SELECT FOUND_ROWS() as cnt";
psRowCnt=conn.prepareStatement(sqlRowCnt);
rsRowCnt=psRowCnt.executeQuery();
if(rsRowCnt.next())
{
iTotalRows=rsRowCnt.getInt("cnt");
}
%>
<html>
<head>
<title>Liste Des Ordinateurs</title>
<SCRIPT type="text/javascript">
function poponload()
{
testwindow = window.open("Insertion.jsp", "Ajout", "location=0,status=0,scrollbars=1,width=800,height=900");
testwindow.moveTo(150, 80);
}
function poponload1()
{
testwindow = window.open("Suppression.jsp", "Suppression", "location=0,status=0,scrollbars=1,width=800,height=900");
testwindow.moveTo(150, 80);
}
function poponload2()
{
testwindow = window.open("Modif.jsp", "Suppression", "location=0,status=0,scrollbars=1,width=800,height=900");
testwindow.moveTo(150, 80);
}
</script>
</head>
<body background="http://localhost:8080/Essai/background2.jpg" style="height: 176px; ">
<FORM action="ConsulterOrdinateur.jsp" method="get" align="center" style="width:50%;margin:auto;background-color:#c1d9fc;padding-bottom:15px;">
<table>
<tr>
<td>
<SELECT NAME="Liste">
<OPTION>Choisir une option
<OPTION>DEVICEID
<OPTION>Name
<OPTION>WorkGroup
<OPTION>PROCESSORT
</SELECT>
</td>
<td><input type="text" name="nom" /> </td>
<td>
<input type="submit" value="Rehercher">
</td>
</tr>
</table>
</FORM>
<br>
<br>
<br>
<!-- le code suivant est pour l'affichage du tableau -->
<form ACTION="Gerer" method="Get" >
<input type="hidden" name="iPageNo" value="<%=iPageNo%>">
<input type="hidden" name="cPageNo" value="<%=cPageNo%>">
<input type="hidden" name="iShowRows" value="<%=iShowRows%>">
<table align="center" Border=1 style="height: 181px; width: 747px; ">
<caption><font color="#008000" size="6">Liste des Postes</font></caption>
<tr> </tr>
<tr>
<td><B>Select</B></td>
<td><b>OrdinateurId</b></td>
<td><b>OrdinateurNom </b></td>
<td><b>DateDerniereMaintenance</b></td>
<td><b>PeriodeMaintenance</b></td>
<td><b>Type</b></td>
</tr>
<%
int a;
while(rsPagination.next())
{
%>
<tr>
<td>
<% a =rsPagination.getInt("OrdinateurId");
//c++;
%>
<input type=checkbox name=list value="<%=a%>"><br>
</td>
<td><%=rsPagination.getInt("OrdinateurId")%></td>
<td><%=rsPagination.getString("OrdinateurNom")%></td>
<td><%=rsPagination.getDate("DateDerniereMaitenance")%></td>
<td><%=rsPagination.getInt("PeriodeMaintenance")%></td>
<td><%=rsPagination.getString("Type")%></td>
</tr>
<%
}
%>
<%
//// calculate next record start record and end record
try{
if(iTotalRows<(iPageNo+iShowRows))
{
iEndResultNo=iTotalRows;
}
else
{
iEndResultNo=(iPageNo+iShowRows);
}
iStartResultNo=(iPageNo+1);
iTotalPages=((int)(Math.ceil((double)iTotalRows/iShowRows)));
}
catch(Exception e)
{
e.printStackTrace();
}
%>
<tr>
<td colspan="3">
<div>
<%
//// index of pages
int i=0;
int cPage=0;
if(iTotalRows!=0)
{
cPage=((int)(Math.ceil((double)iEndResultNo/(iTotalSearchRecords*iShowRows))));
int prePageNo=(cPage*iTotalSearchRecords)-((iTotalSearchRecords-1)+iTotalSearchRecords);
if((cPage*iTotalSearchRecords)-(iTotalSearchRecords)>0)
{
%>
<a href="ConsulterOrdinateur.jsp?iPageNo=<%=prePageNo%>&cPageNo=<%=prePageNo%>"> Previous</a>
<%
}
for(i=((cPage*iTotalSearchRecords)-(iTotalSearchRecords-1));i<=(cPage*iTotalSearchRecords);i++)
{
if(i==((iPageNo/iShowRows)+1))
{
%>
<a href="ConsulterOrdinateur.jsp?iPageNo=<%=i%>" style="cursor:pointer;color: red"><b><%=i%></b></a>
<%
}
else if(i<=iTotalPages)
{
%>
<a href="ConsulterOrdinateur.jsp?iPageNo=<%=i%>"><%=i%></a>
<%
}
}
if(iTotalPages>iTotalSearchRecords && i<iTotalPages)
{
%>
<a href="ConsulterOrdinateur.jsp?iPageNo=<%=i%>&cPageNo=<%=i%>"> Next</a>
<%
}
}
%>
<b>Rows <%=iStartResultNo%> - <%=iEndResultNo%> Total Result <%=iTotalRows%> </b>
</div>
</td>
</tr>
</table>
<br>
<!-- 1ere possibilite une action sur un bouton et une nouvelle fenetre specifque au bouton s'ouvre -->
<!--
<tr>
<td> <input type="submit" name="ok" value="Ajouter" onClick="javascript: poponload()" style="height: 37px; width: 75px"> </td>
<td> <input type="submit" name="ok" value="Supprimer" onClick="javascript: poponload1()" style="height: 37px; width: 75px"> </td>
<td> <input type="submit" name="ok" value="Modifier" onClick="javascript: poponload2()" style="height: 37px; width: 75px"> </td></tr>
</tr> -->
<input type="submit" name="ok" value="supprimer" style="height: 37px; width: 75px">
<input type="submit" name="ok" value="modifier" onclick="poponload2()" style="height: 37px; width: 75px">
<br>
</form>
</body>
</html>
<%
try{
if(psPagination!=null){
psPagination.close();
}
if(rsPagination!=null){
rsPagination.close();
}
if(psRowCnt!=null){
psRowCnt.close();
}
if(rsRowCnt!=null){
rsRowCnt.close();
}
if(conn!=null){
conn.close();
}
}
catch(Exception e)
{
e.printStackTrace();
}
%>
<p>Cliquez <a href="Accueil.jsp" title="Wireless Fidelity">ici</a> pour retourner à l'accueil.</p> |
Partager