begin process at 2012 02 11 23:27:52
  Trouver un code source :
 
dans
 
Accueil > Forum > 

JAVA / J2EE / J2ME

 > 

Réseau & internet

 > 

JavaServerPage (JSP)

 > 

ajout


Derniers messages déposésPoser une question dans le forum ou lancer une discussion

ajout

samedi 7 juin 2008 à 13:09:06 | ajout

jspimen

bonjour;
voici mon code qui permet d'ajouter des données dans une base Mysql

<%//@ page import="java.sql.*" %>

<%@ page import="java.io.File" %>
<%@ page import="java.io.BufferedWriter" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.io.*" %>
<%@ page import="java.*" %>
<%@ page import="java.util.GregorianCalendar" %>
<%@ page import="java.util.LinkedList" %>
<%
boolean Ajouter=false;
String IDTA="";
String Password="";
String Nom="";
String Prenom="";
String CIN="";
String ProfilTA="";
String ProfilAD="";
String ProfilSUP="";
boolean SaveFile=false;

DiskFileUpload upload = new DiskFileUpload();
List items = upload.parseRequest(request);
Iterator itr = items.iterator();
File fullFile=null;
File savedFile=null;
File Toren=null;
FileItem Fitm=null;
while(itr.hasNext()){
FileItem item = (FileItem) itr.next();
if(item.isFormField()) {
String fieldName = item.getFieldName();
if(fieldName.equals("IDTA")) IDTA=item.getString();
if(fieldName.equals("Password")) Password=item.getString();
if(fieldName.equals("Nom")) Nom=item.getString();
if(fieldName.equals("Prenom")) Prenom=item.getString();
if(fieldName.equals("CIN")) CIN=item.getString();
if(fieldName.equals("ProfilTA")) ProfilTA=item.getString();
if(fieldName.equals("ProfilSUP")) ProfilSUP=item.getString();
if(fieldName.equals("ProfilAD")) ProfilAD=item.getString();
if(fieldName.equals("Ajouter")) Ajouter=true;
}else{
if(!item.getName().equals("")){
fullFile = new File(item.getName());
savedFile = new File(getServletContext().getRealPath("/")+"\\Photo\\", fullFile.getName());//fullFile.getName()
System.out.print(getServletContext().getRealPath("/")+"/Photo/"+fullFile.getName());
SaveFile=true;
Fitm=item;
}
}}


if(Ajouter==true)
{
Connection con;
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection ("jdbc:mysql://localhost:3306/tunis", "root", "admin");
Statement Stmt = con.createStatement();
ResultSet rs=Stmt.executeQuery("select count(*) from personnel where ID='"+IDTA+"'");
rs.next();
if(rs.getInt(1)==1)
{
%>
<html>
<head>
<title>
paged'accueil
</title>

<script LANGUAGE="JavaScript" TYPE="text/javascript">
function isBlank(val){
if(val==null){return true;}
for(var i=0;i<val.length;i++) {
if ((val.charAt(i)==' ')||(val.charAt(i)=="\t")||(val.charAt(i)=="\n")||(val.charAt(i)=="\r")){return true;}
}
return false;
}

function isBeginBlank(val){
if(val==null){return true;}

if ((val.charAt(0)!=' ')&&(val.charAt(0)!="\t")&&(val.charAt(0)!="\n")&&(val.charAt(0)!="\r")){ return false;}

return true;
}

function isInteger(s)
{ var i;
for (i = 0; i < s.length; i++)
{
// Check that current character is number.
var c = s.charAt(i);
if (((c < "0") || (c > "9"))) return false;
}
// All characters are numbers.
return true;
}

function NoOnIsChecked()
{
if(document.F.ProfilTA.checked=="" && document.F.ProfilAD.checked=="" && document.F.ProfilSUP.checked=="" ){return true;}
return false;
}


function check() {
if (document.F.IDTA.value == "" || isBlank(document.F.IDTA.value) || document.F.IDTA.value.length >55 ) {
alert("Identifiant obligatoire et ne doit pas contenir des blancs.\n");
document.F.IDTA.focus();
return false;
}else{
if(document.F.Password.value == "" || isBlank(document.F.Password.value) || document.F.Password.value.length >55 ){
alert("Mot de passe obligatoire et ne doit pas contenir des blancs.\n");
document.F.Password.focus();
return false;
}else{
if(document.F.Nom.value == "" || isBeginBlank(document.F.Nom.value) || document.F.Nom.value.length >55){
alert("Nom obligatoire et ne doit pas commencer par des blancs.\n");
document.F.Nom.focus();
return false;
}else{
if(document.F.CIN.value.length < 8 || document.F.CIN.value.length >12 || ! isInteger(document.F.CIN.value)|| isBeginBlank(document.F.CIN.value) ){
alert("Numéro CIN est incorrecte ou trop long.\n");
document.F.CIN.focus();
return false;
}else{
if(NoOnIsChecked()){
alert("Un profil doit etre montionné.\n");
document.F.ProfilTA.focus();
document.F.ProfilAD.focus();
document.F.ProfilSUP.focus();
return false;
}
}
}
}
}
return true;
}
</script></head>

<body bgcolor="#248F9B">
<img src="file:///C|/access/image 2 int jpg.JPG" />
<form action="" name="form1" onSubmit="return check()" method="post" enctype="multipart/form-data" >

<table width="628" height="383" border="0" align="center" background="images/container-top-bg[1].gif">
<tr><td height="150">
</form>
</font>
<!--<table width="100%">



</td>
</tr>
</table>-->
<!--<form action="Personnel1.jsp" name="F" onSubmit="return check()" method="post" enctype="multipart/form-data" >
--> <center><br>
<font color="blue" size="+1"><A href="index.jsp"><font size="+6" color="#cc3366" ><em><strong>Page d'Accueil</strong></em></font></A></font></A></font>
</center>
<table align="center" border="2" width="60%">
<tr>
<td colspan="2"><p align="center"><font size="+3" color="BLUE"> Formulaire d'ajout de nouveaux personnels</font></p></td>
</td>
</tr>
<tr>
<td width="40%">

<p align="justify"><font size="+1"><em><strong>Entrer Identifiant *</strong></em></font></p>
</td>
<td>
<input type="text" name="IDTA" align="middle" size="30%" value="<%out.print(IDTA);%>">
</td>

</tr>
<tr>
<td width="40%">

<p align="justify"><font size="+1" ><em><strong>Entrer Mot de passe *</strong></em></font></p>
</td>
<td>
<input type="password" name="Password" align="middle" size="30%" value="">
</td>

</tr>
<tr>
<td>
<p align="justify"><font size="+1" ><em><strong>Entrer le Nom *</strong></em></font></p>
</td>
<td>
<input type="text" name="Nom" align="middle" size="30%" value="<%out.print(Nom);%>">
</td>
</tr>
<tr>
<td>
<p align="justify"><font size="+1"><em><strong>Entrer le Prénom *</strong></em></font></p>
</td>
<td>
<label for="Prenom"><input type="text" name="Prenom" align="middle" size="30%" value="<%out.print(Prenom);%>"></label>
</td>
</tr>
<tr>
<td>
<p align="justify"><font size="+1" ><em><strong>N° CIN </strong></em></font></p>
</td>
<td>
<label for="prenom"><input type="text" name="CIN" size="30%" value="<%out.print(CIN);%>"></label>
</td>
</tr>
<tr>
<td>
<p align="justify"><font size="+1" ><em><strong>Photo</strong></em></font></p>
</td>
<td>
<label for="prenom"><input type="file" name="PHOTO" size="30%"></label>
</td>
</tr>
<tr>

<td>
<p align="justify"><font size="+1"><em><strong>Profil TA </strong></em></font></p>
</td>
<td>

<input type="CheckBox" name="ProfilTA" value="1" align="middle">
</td>
</tr>
<tr>
<td>

<p align="justify"><font size="+1" ><em><strong>Profil Administrateur</strong></em></font></p>
</td>
<td>

<input type="CheckBox" name="ProfilAD" value="2" align="middle">
</td>
</tr>
<tr>
<td>
<p align="justify"><font size="+1"><em><strong>Profil Superviseur </strong></em></font></p>
</td>
<td>
<input type="CheckBox" name="ProfilSUP" value="3" align="middle"> </td>
</td>
</tr>
</table>
<table align="center" width="60%">

<tr align="center">
<td width="40%">

<p align="center"><input type="Submit" name="Ajouter" value="Ajouter" align="middle" size="15">
<input type="reset" value="Reset" align="middle" size="15"></p>
</td>
</tr>
<tr align="center">
<td bgcolor="blue">
<font color="red" size="+1"><b>Identifiant existe déjà: Veuillez choisir un autre</b></font>
</font>
</td>
</tr>
</table>
</form>
</body>
</html>

<%
}else{
Statement StmtI=con.createStatement();
String reqins="insert into personnel values('"+IDTA+"','"+Password+"','"+
Nom+"','"+Prenom+"',"+
CIN+"";

if(ProfilTA!=""){reqins+=",1,";}else reqins+=",0,";

if(ProfilAD!=""){reqins+="1,";}else reqins+="0,";

if(ProfilSUP!=""){reqins+="1,";}else reqins+="0,";


reqins+="0,";
reqins+="'00:00:00','00:00:00','Poste_101')";
System.out.print(reqins);
StmtI.executeUpdate(reqins);

if(SaveFile){
Fitm.write(savedFile);
Toren=new File(getServletContext().getRealPath("/")+"\\Photo\\"+IDTA+".jpg");
savedFile.renameTo(Toren);
savedFile.delete();

}


%>

<html>
<head>
<title>
AjoutTA
</title>

<script LANGUAGE="JavaScript" TYPE="text/javascript">
function isBlank(val){
if(val==null){return true;}
for(var i=0;i<val.length;i++) {
if ((val.charAt(i)==' ')||(val.charAt(i)=="\t")||(val.charAt(i)=="\n")||(val.charAt(i)=="\r")){return true;}
}
return false;
}

function isBeginBlank(val){
if(val==null){return true;}

if ((val.charAt(0)!=' ')&&(val.charAt(0)!="\t")&&(val.charAt(0)!="\n")&&(val.charAt(0)!="\r")){ return false;}

return true;
}

function isInteger(s)
{ var i;
for (i = 0; i < s.length; i++)
{
// Check that current character is number.
var c = s.charAt(i);
if (((c < "0") || (c > "9"))) return false;
}
// All characters are numbers.
return true;
}

function NoOnIsChecked()
{
if(document.F.ProfilTA.checked=="" && document.F.ProfilAD.checked=="" && document.F.ProfilSUP.checked=="" ){return true;}
return false;
}


function check() {
if (document.F.IDTA.value == "" || isBlank(document.F.IDTA.value) || document.F.IDTA.value.length >55 ) {
alert("Identifiant obligatoire et ne doit pas contenir des blancs.\n");
document.F.IDTA.focus();
return false;
}else{
if(document.F.Password.value == "" || isBlank(document.F.Password.value) || document.F.Password.value.length >55 ){
alert("Mot de passe obligatoire et ne doit pas contenir des blancs.\n");
document.F.Password.focus();
return false;
}else{
if(document.F.Nom.value == "" || isBeginBlank(document.F.Nom.value) || document.F.Nom.value.length >55){
alert("Nom obligatoire et ne doit pas commencer par des blancs.\n");
document.F.Nom.focus();
return false;
}else{
if(document.F.CIN.value.length < 8 || document.F.CIN.value.length >12 || ! isInteger(document.F.CIN.value)|| isBeginBlank(document.F.CIN.value) ){
alert("Numéro CIN est incorrecte ou trop long.\n");
document.F.CIN.focus();
return false;
}else{
if(NoOnIsChecked()){
alert("Un profil doit etre montionné.\n");
document.F.ProfilTA.focus();
document.F.ProfilAD.focus();
document.F.ProfilSUP.focus();
return false;
}
}
}
}
}
return true;
}
</script></head>


<body bgcolor="#ffAfff" background="Image1.jpg">
<table width="100%">
<tr>
<td height="150">




</td>
</tr>
</table>
<form action="" name="form1" onSubmit="return check()" method="post" enctype="multipart/form-data">
<table align="center" border="2" width="60%">
<tr>
<td colspan="2"><p align="center"><font size="+3" color="BLUE"> Formulaire d'ajout de nouveaux personnels</font></p></td>
</td>
</tr>
<tr>
<td width="40%">

<p align="justify"><font size="+1">Entrer Identifiant *</font></p>
</td>
<td>
<input type="text" name="IDTA" align="middle" size="30%">
</td>

</tr>
<tr>
<td width="40%">

<p align="justify"><font size="+1">Entrer Mot de passe * </font></p>
</td>
<td>
<input type="password" name="Password" align="middle" size="30%">
</td>

</tr>
<tr>
<td>
<p align="justify"><font size="+1">Entrer le Nom * </font></p>
</td>
<td>
<input type="text" name="Nom" align="middle" size="30%">
</td>
</tr>
<tr>
<td>
<p align="justify"><font size="+1">Entrer le Prénom * </font></p>
</td>
<td>
<label for="Prenom"><input type="text" name="Prenom" align="middle" size="30%"></label>
</td>
</tr>
<tr>
<td>
<p align="justify">N° CIN </p>
</td>
<td>
<label for="prenom"><input type="text" name="CIN" size="30%"></label>
</td>
</tr>
<tr>
<td>
<p align="justify"><font size="+1" color="#666699"><em><strong>Photo</strong></em></font></p>
</td>
<td>
<label for="prenom"><input type="file" name="PHOTO" size="30%"></label>
</td>
</tr>
<tr>

<td>
<p align="justify">Profil TA </p>
</td>
<td>

<input type="CheckBox" name="ProfilTA" value="1" align="middle">
</td>
</tr>
<tr>
<td>

<p align="justify">Profil Administrateur </p>
</td>
<td>

<input type="CheckBox" name="ProfilAD" value="2" align="middle">
</td>
</tr>
<tr>
<td>
<p align="justify">Profil Superviseur </p>
</td>
<td>
<input type="CheckBox" name="ProfilSUP" value="3" align="middle"> </td>
</td>
</tr>
</table>
<table align="center" width="60%">

<tr align="center">
<td align="center">

<p align="center"><input type="Submit" name="Ajouter" value="Ajouter" align="middle" size="15">
<input type="reset" value="Reset" align="middle" size="15"></p>
</td>
</tr>
<tr align="center" bgcolor="AAKJ00" >
<td width="40%">
<font color="blue" size="+2">Personnel ajouté avec succés</font>
</font>
</td>
</tr>

</table>
</form>
</body>
</html>


mais ce code affiche des erreurs:
<%//@ page import="java.sql.*" %>

<%@ page import="java.io.File" %>
<%@ page import="java.io.BufferedWriter" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.io.*" %>
<%@ page import="java.*" %>
<%@ page import="java.util.GregorianCalendar" %>
<%@ page import="java.util.LinkedList" %>
<%
boolean Ajouter=false;
String IDTA="";
String Password="";
String Nom="";
String Prenom="";
String CIN="";
String ProfilTA="";
String ProfilAD="";
String ProfilSUP="";
boolean SaveFile=false;

DiskFileUpload upload = new DiskFileUpload();
List items = upload.parseRequest(request);
Iterator itr = items.iterator();
File fullFile=null;
File savedFile=null;
File Toren=null;
FileItem Fitm=null;
while(itr.hasNext()){
FileItem item = (FileItem) itr.next();
if(item.isFormField()) {
String fieldName = item.getFieldName();
if(fieldName.equals("IDTA")) IDTA=item.getString();
if(fieldName.equals("Password")) Password=item.getString();
if(fieldName.equals("Nom")) Nom=item.getString();
if(fieldName.equals("Prenom")) Prenom=item.getString();
if(fieldName.equals("CIN")) CIN=item.getString();
if(fieldName.equals("ProfilTA")) ProfilTA=item.getString();
if(fieldName.equals("ProfilSUP")) ProfilSUP=item.getString();
if(fieldName.equals("ProfilAD")) ProfilAD=item.getString();
if(fieldName.equals("Ajouter")) Ajouter=true;
}else{
if(!item.getName().equals("")){
fullFile = new File(item.getName());
savedFile = new File(getServletContext().getRealPath("/")+"\\Photo\\", fullFile.getName());//fullFile.getName()
System.out.print(getServletContext().getRealPath("/")+"/Photo/"+fullFile.getName());
SaveFile=true;
Fitm=item;
}
}}


if(Ajouter==true)
{
Connection con;
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection ("jdbc:mysql://localhost:3306/tunis", "root", "admin");
Statement Stmt = con.createStatement();
ResultSet rs=Stmt.executeQuery("select count(*) from personnel where ID='"+IDTA+"'");
rs.next();
if(rs.getInt(1)==1)
{
%>
<html>
<head>
<title>
paged'accueil
</title>

<script LANGUAGE="JavaScript" TYPE="text/javascript">
function isBlank(val){
if(val==null){return true;}
for(var i=0;i<val.length;i++) {
if ((val.charAt(i)==' ')||(val.charAt(i)=="\t")||(val.charAt(i)=="\n")||(val.charAt(i)=="\r")){return true;}
}
return false;
}

function isBeginBlank(val){
if(val==null){return true;}

if ((val.charAt(0)!=' ')&&(val.charAt(0)!="\t")&&(val.charAt(0)!="\n")&&(val.charAt(0)!="\r")){ return false;}

return true;
}

function isInteger(s)
{ var i;
for (i = 0; i < s.length; i++)
{
// Check that current character is number.
var c = s.charAt(i);
if (((c < "0") || (c > "9"))) return false;
}
// All characters are numbers.
return true;
}

function NoOnIsChecked()
{
if(document.F.ProfilTA.checked=="" && document.F.ProfilAD.checked=="" && document.F.ProfilSUP.checked=="" ){return true;}
return false;
}


function check() {
if (document.F.IDTA.value == "" || isBlank(document.F.IDTA.value) || document.F.IDTA.value.length >55 ) {
alert("Identifiant obligatoire et ne doit pas contenir des blancs.\n");
document.F.IDTA.focus();
return false;
}else{
if(document.F.Password.value == "" || isBlank(document.F.Password.value) || document.F.Password.value.length >55 ){
alert("Mot de passe obligatoire et ne doit pas contenir des blancs.\n");
document.F.Password.focus();
return false;
}else{
if(document.F.Nom.value == "" || isBeginBlank(document.F.Nom.value) || document.F.Nom.value.length >55){
alert("Nom obligatoire et ne doit pas commencer par des blancs.\n");
document.F.Nom.focus();
return false;
}else{
if(document.F.CIN.value.length < 8 || document.F.CIN.value.length >12 || ! isInteger(document.F.CIN.value)|| isBeginBlank(document.F.CIN.value) ){
alert("Numéro CIN est incorrecte ou trop long.\n");
document.F.CIN.focus();
return false;
}else{
if(NoOnIsChecked()){
alert("Un profil doit etre montionné.\n");
document.F.ProfilTA.focus();
document.F.ProfilAD.focus();
document.F.ProfilSUP.focus();
return false;
}
}
}
}
}
return true;
}
</script></head>

<body bgcolor="#248F9B">
<img src="file:///C|/access/image 2 int jpg.JPG" />
<form action="" name="form1" onSubmit="return check()" method="post" enctype="multipart/form-data" >

<table width="628" height="383" border="0" align="center" background="images/container-top-bg[1].gif">
<tr><td height="150">
</form>
</font>
<!--<table width="100%">



</td>
</tr>
</table>-->
<!--<form action="Personnel1.jsp" name="F" onSubmit="return check()" method="post" enctype="multipart/form-data" >
--> <center><br>
<font color="blue" size="+1"><A href="index.jsp"><font size="+6" color="#cc3366" ><em><strong>Page d'Accueil</strong></em></font></A></font></A></font>
</center>
<table align="center" border="2" width="60%">
<tr>
<td colspan="2"><p align="center"><font size="+3" color="BLUE"> Formulaire d'ajout de nouveaux personnels</font></p></td>
</td>
</tr>
<tr>
<td width="40%">

<p align="justify"><font size="+1"><em><strong>Entrer Identifiant *</strong></em></font></p>
</td>
<td>
<input type="text" name="IDTA" align="middle" size="30%" value="<%out.print(IDTA);%>">
</td>

</tr>
<tr>
<td width="40%">

<p align="justify"><font size="+1" ><em><strong>Entrer Mot de passe *</strong></em></font></p>
</td>
<td>
<input type="password" name="Password" align="middle" size="30%" value="">
</td>

</tr>
<tr>
<td>
<p align="justify"><font size="+1" ><em><strong>Entrer le Nom *</strong></em></font></p>
</td>
<td>
<input type="text" name="Nom" align="middle" size="30%" value="<%out.print(Nom);%>">
</td>
</tr>
<tr>
<td>
<p align="justify"><font size="+1"><em><strong>Entrer le Prénom *</strong></em></font></p>
</td>
<td>
<label for="Prenom"><input type="text" name="Prenom" align="middle" size="30%" value="<%out.print(Prenom);%>"></label>
</td>
</tr>
<tr>
<td>
<p align="justify"><font size="+1" ><em><strong>N° CIN </strong></em></font></p>
</td>
<td>
<label for="prenom"><input type="text" name="CIN" size="30%" value="<%out.print(CIN);%>"></label>
</td>
</tr>
<tr>
<td>
<p align="justify"><font size="+1" ><em><strong>Photo</strong></em></font></p>
</td>
<td>
<label for="prenom"><input type="file" name="PHOTO" size="30%"></label>
</td>
</tr>
<tr>

<td>
<p align="justify"><font size="+1"><em><strong>Profil TA </strong></em></font></p>
</td>
<td>

<input type="CheckBox" name="ProfilTA" value="1" align="middle">
</td>
</tr>
<tr>
<td>

<p align="justify"><font size="+1" ><em><strong>Profil Administrateur</strong></em></font></p>
</td>
<td>

<input type="CheckBox" name="ProfilAD" value="2" align="middle">
</td>
</tr>
<tr>
<td>
<p align="justify"><font size="+1"><em><strong>Profil Superviseur </strong></em></font></p>
</td>
<td>
<input type="CheckBox" name="ProfilSUP" value="3" align="middle"> </td>
</td>
</tr>
</table>
<table align="center" width="60%">

<tr align="center">
<td width="40%">

<p align="center"><input type="Submit" name="Ajouter" value="Ajouter" align="middle" size="15">
<input type="reset" value="Reset" align="middle" size="15"></p>
</td>
</tr>
<tr align="center">
<td bgcolor="blue">
<font color="red" size="+1"><b>Identifiant existe déjà: Veuillez choisir un autre</b></font>
</font>
</td>
</tr>
</table>
</form>
</body>
</html>

<%
}else{
Statement StmtI=con.createStatement();
String reqins="insert into personnel values('"+IDTA+"','"+Password+"','"+
Nom+"','"+Prenom+"',"+
CIN+"";

if(ProfilTA!=""){reqins+=",1,";}else reqins+=",0,";

if(ProfilAD!=""){reqins+="1,";}else reqins+="0,";

if(ProfilSUP!=""){reqins+="1,";}else reqins+="0,";


reqins+="0,";
reqins+="'00:00:00','00:00:00','Poste_101')";
System.out.print(reqins);
StmtI.executeUpdate(reqins);

if(SaveFile){
Fitm.write(savedFile);
Toren=new File(getServletContext().getRealPath("/")+"\\Photo\\"+IDTA+".jpg");
savedFile.renameTo(Toren);
savedFile.delete();

}


%>

<html>
<head>
<title>
AjoutTA
</title>

<script LANGUAGE="JavaScript" TYPE="text/javascript">
function isBlank(val){
if(val==null){return true;}
for(var i=0;i<val.length;i++) {
if ((val.charAt(i)==' ')||(val.charAt(i)=="\t")||(val.charAt(i)=="\n")||(val.charAt(i)=="\r")){return true;}
}
return false;
}

function isBeginBlank(val){
if(val==null){return true;}

if ((val.charAt(0)!=' ')&&(val.charAt(0)!="\t")&&(val.charAt(0)!="\n")&&(val.charAt(0)!="\r")){ return false;}

return true;
}

function isInteger(s)
{ var i;
for (i = 0; i < s.length; i++)
{
// Check that current character is number.
var c = s.charAt(i);
if (((c < "0") || (c > "9"))) return false;
}
// All characters are numbers.
return true;
}

function NoOnIsChecked()
{
if(document.F.ProfilTA.checked=="" && document.F.ProfilAD.checked=="" && document.F.ProfilSUP.checked=="" ){return true;}
return false;
}


function check() {
if (document.F.IDTA.value == "" || isBlank(document.F.IDTA.value) || document.F.IDTA.value.length >55 ) {
alert("Identifiant obligatoire et ne doit pas contenir des blancs.\n");
document.F.IDTA.focus();
return false;
}else{
if(document.F.Password.value == "" || isBlank(document.F.Password.value) || document.F.Password.value.length >55 ){
alert("Mot de passe obligatoire et ne doit pas contenir des blancs.\n");
document.F.Password.focus();
return false;
}else{
if(document.F.Nom.value == "" || isBeginBlank(document.F.Nom.value) || document.F.Nom.value.length >55){
alert("Nom obligatoire et ne doit pas commencer par des blancs.\n");
document.F.Nom.focus();
return false;
}else{
if(document.F.CIN.value.length < 8 || document.F.CIN.value.length >12 || ! isInteger(document.F.CIN.value)|| isBeginBlank(document.F.CIN.value) ){
alert("Numéro CIN est incorrecte ou trop long.\n");
document.F.CIN.focus();
return false;
}else{
if(NoOnIsChecked()){
alert("Un profil doit etre montionné.\n");
document.F.ProfilTA.focus();
document.F.ProfilAD.focus();
document.F.ProfilSUP.focus();
return false;
}
}
}
}
}
return true;
}
</script></head>


<body bgcolor="#ffAfff" background="Image1.jpg">
<table width="100%">
<tr>
<td height="150">




</td>
</tr>
</table>
<form action="" name="form1" onSubmit="return check()" method="post" enctype="multipart/form-data">
<table align="center" border="2" width="60%">
<tr>
<td colspan="2"><p align="center"><font size="+3" color="BLUE"> Formulaire d'ajout de nouveaux personnels</font></p></td>
</td>
</tr>
<tr>
<td width="40%">

<p align="justify"><font size="+1">Entrer Identifiant *</font></p>
</td>
<td>
<input type="text" name="IDTA" align="middle" size="30%">
</td>

</tr>
<tr>
<td width="40%">

<p align="justify"><font size="+1">Entrer Mot de passe * </font></p>
</td>
<td>
<input type="password" name="Password" align="middle" size="30%">
</td>

</tr>
<tr>
<td>
<p align="justify"><font size="+1">Entrer le Nom * </font></p>
</td>
<td>
<input type="text" name="Nom" align="middle" size="30%">
</td>
</tr>
<tr>
<td>
<p align="justify"><font size="+1">Entrer le Prénom * </font></p>
</td>
<td>
<label for="Prenom"><input type="text" name="Prenom" align="middle" size="30%"></label>
</td>
</tr>
<tr>
<td>
<p align="justify">N° CIN </p>
</td>
<td>
<label for="prenom"><input type="text" name="CIN" size="30%"></label>
</td>
</tr>
<tr>
<td>
<p align="justify"><font size="+1" color="#666699"><em><strong>Photo</strong></em></font></p>
</td>
<td>
<label for="prenom"><input type="file" name="PHOTO" size="30%"></label>
</td>
</tr>
<tr>

<td>
<p align="justify">Profil TA </p>
</td>
<td>

<input type="CheckBox" name="ProfilTA" value="1" align="middle">
</td>
</tr>
<tr>
<td>

<p align="justify">Profil Administrateur </p>
</td>
<td>

<input type="CheckBox" name="ProfilAD" value="2" align="middle">
</td>
</tr>
<tr>
<td>
<p align="justify">Profil Superviseur </p>
</td>
<td>
<input type="CheckBox" name="ProfilSUP" value="3" align="middle"> </td>
</td>
</tr>
</table>
<table align="center" width="60%">

<tr align="center">
<td align="center">

<p align="center"><input type="Submit" name="Ajouter" value="Ajouter" align="middle" size="15">
<input type="reset" value="Reset" align="middle" size="15"></p>
</td>
</tr>
<tr align="center" bgcolor="AAKJ00" >
<td width="40%">
<font color="blue" size="+2">Personnel ajouté avec succés</font>
</font>
</td>
</tr>

</table>
</form>
</body>
</html>



<%//@ page import="java.sql.*" %>

<%@ page import="java.io.File" %>
<%@ page import="java.io.BufferedWriter" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.io.*" %>
<%@ page import="java.*" %>
<%@ page import="java.util.GregorianCalendar" %>
<%@ page import="java.util.LinkedList" %>
<%
boolean Ajouter=false;
String IDTA="";
String Password="";
String Nom="";
String Prenom="";
String CIN="";
String ProfilTA="";
String ProfilAD="";
String ProfilSUP="";
boolean SaveFile=false;

DiskFileUpload upload = new DiskFileUpload();
List items = upload.parseRequest(request);
Iterator itr = items.iterator();
File fullFile=null;
File savedFile=null;
File Toren=null;
FileItem Fitm=null;
while(itr.hasNext()){
FileItem item = (FileItem) itr.next();
if(item.isFormField()) {
String fieldName = item.getFieldName();
if(fieldName.equals("IDTA")) IDTA=item.getString();
if(fieldName.equals("Password")) Password=item.getString();
if(fieldName.equals("Nom")) Nom=item.getString();
if(fieldName.equals("Prenom")) Prenom=item.getString();
if(fieldName.equals("CIN")) CIN=item.getString();
if(fieldName.equals("ProfilTA")) ProfilTA=item.getString();
if(fieldName.equals("ProfilSUP")) ProfilSUP=item.getString();
if(fieldName.equals("ProfilAD")) ProfilAD=item.getString();
if(fieldName.equals("Ajouter")) Ajouter=true;
}else{
if(!item.getName().equals("")){
fullFile = new File(item.getName());
savedFile = new File(getServletContext().getRealPath("/")+"\\Photo\\", fullFile.getName());//fullFile.getName()
System.out.print(getServletContext().getRealPath("/")+"/Photo/"+fullFile.getName());
SaveFile=true;
Fitm=item;
}
}}


if(Ajouter==true)
{
Connection con;
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection ("jdbc:mysql://localhost:3306/tunis", "root", "admin");
Statement Stmt = con.createStatement();
ResultSet rs=Stmt.executeQuery("select count(*) from personnel where ID='"+IDTA+"'");
rs.next();
if(rs.getInt(1)==1)
{
%>
<html>
<head>
<title>
paged'accueil
</title>

<script LANGUAGE="JavaScript" TYPE="text/javascript">
function isBlank(val){
if(val==null){return true;}
for(var i=0;i<val.length;i++) {
if ((val.charAt(i)==' ')||(val.charAt(i)=="\t")||(val.charAt(i)=="\n")||(val.charAt(i)=="\r")){return true;}
}
return false;
}

function isBeginBlank(val){
if(val==null){return true;}

if ((val.charAt(0)!=' ')&&(val.charAt(0)!="\t")&&(val.charAt(0)!="\n")&&(val.charAt(0)!="\r")){ return false;}

return true;
}

function isInteger(s)
{ var i;
for (i = 0; i < s.length; i++)
{
// Check that current character is number.
var c = s.charAt(i);
if (((c < "0") || (c > "9"))) return false;
}
// All characters are numbers.
return true;
}

function NoOnIsChecked()
{
if(document.F.ProfilTA.checked=="" && document.F.ProfilAD.checked=="" && document.F.ProfilSUP.checked=="" ){return true;}
return false;
}


function check() {
if (document.F.IDTA.value == "" || isBlank(document.F.IDTA.value) || document.F.IDTA.value.length >55 ) {
alert("Identifiant obligatoire et ne doit pas contenir des blancs.\n");
document.F.IDTA.focus();
return false;
}else{
if(document.F.Password.value == "" || isBlank(document.F.Password.value) || document.F.Password.value.length >55 ){
alert("Mot de passe obligatoire et ne doit pas contenir des blancs.\n");
document.F.Password.focus();
return false;
}else{
if(document.F.Nom.value == "" || isBeginBlank(document.F.Nom.value) || document.F.Nom.value.length >55){
alert("Nom obligatoire et ne doit pas commencer par des blancs.\n");
document.F.Nom.focus();
return false;
}else{
if(document.F.CIN.value.length < 8 || document.F.CIN.value.length >12 || ! isInteger(document.F.CIN.value)|| isBeginBlank(document.F.CIN.value) ){
alert("Numéro CIN est incorrecte ou trop long.\n");
document.F.CIN.focus();
return false;
}else{
if(NoOnIsChecked()){
alert("Un profil doit etre montionné.\n");
document.F.ProfilTA.focus();
document.F.ProfilAD.focus();
document.F.ProfilSUP.focus();
return false;
}
}
}
}
}
return true;
}
</script></head>

<body bgcolor="#248F9B">
<img src="file:///C|/access/image 2 int jpg.JPG" />
<form action="" name="form1" onSubmit="return check()" method="post" enctype="multipart/form-data" >

<table width="628" height="383" border="0" align="center" background="images/container-top-bg[1].gif">
<tr><td height="150">
</form>
</font>
<!--<table width="100%">



</td>
</tr>
</table>-->
<!--<form action="Personnel1.jsp" name="F" onSubmit="return check()" method="post" enctype="multipart/form-data" >
--> <center><br>
<font color="blue" size="+1"><A href="index.jsp"><font size="+6" color="#cc3366" ><em><strong>Page d'Accueil</strong></em></font></A></font></A></font>
</center>
<table align="center" border="2" width="60%">
<tr>
<td colspan="2"><p align="center"><font size="+3" color="BLUE"> Formulaire d'ajout de nouveaux personnels</font></p></td>
</td>
</tr>
<tr>
<td width="40%">

<p align="justify"><font size="+1"><em><strong>Entrer Identifiant *</strong></em></font></p>
</td>
<td>
<input type="text" name="IDTA" align="middle" size="30%" value="<%out.print(IDTA);%>">
</td>

</tr>
<tr>
<td width="40%">

<p align="justify"><font size="+1" ><em><strong>Entrer Mot de passe *</strong></em></font></p>
</td>
<td>
<input type="password" name="Password" align="middle" size="30%" value="">
</td>

</tr>
<tr>
<td>
<p align="justify"><font size="+1" ><em><strong>Entrer le Nom *</strong></em></font></p>
</td>
<td>
<input type="text" name="Nom" align="middle" size="30%" value="<%out.print(Nom);%>">
</td>
</tr>
<tr>
<td>
<p align="justify"><font size="+1"><em><strong>Entrer le Prénom *</strong></em></font></p>
</td>
<td>
<label for="Prenom"><input type="text" name="Prenom" align="middle" size="30%" value="<%out.print(Prenom);%>"></label>
</td>
</tr>
<tr>
<td>
<p align="justify"><font size="+1" ><em><strong>N° CIN </strong></em></font></p>
</td>
<td>
<label for="prenom"><input type="text" name="CIN" size="30%" value="<%out.print(CIN);%>"></label>
</td>
</tr>
<tr>
<td>
<p align="justify"><font size="+1" ><em><strong>Photo</strong></em></font></p>
</td>
<td>
<label for="prenom"><input type="file" name="PHOTO" size="30%"></label>
</td>
</tr>
<tr>

<td>
<p align="justify"><font size="+1"><em><strong>Profil TA </strong></em></font></p>
</td>
<td>

<input type="CheckBox" name="ProfilTA" value="1" align="middle">
</td>
</tr>
<tr>
<td>

<p align="justify"><font size="+1" ><em><strong>Profil Administrateur</strong></em></font></p>
</td>
<td>

<input type="CheckBox" name="ProfilAD" value="2" align="middle">
</td>
</tr>
<tr>
<td>
<p align="justify"><font size="+1"><em><strong>Profil Superviseur </strong></em></font></p>
</td>
<td>
<input type="CheckBox" name="ProfilSUP" value="3" align="middle"> </td>
</td>
</tr>
</table>
<table align="center" width="60%">

<tr align="center">
<td width="40%">

<p align="center"><input type="Submit" name="Ajouter" value="Ajouter" align="middle" size="15">
<input type="reset" value="Reset" align="middle" size="15"></p>
</td>
</tr>
<tr align="center">
<td bgcolor="blue">
<font color="red" size="+1"><b>Identifiant existe déjà: Veuillez choisir un autre</b></font>
</font>
</td>
</tr>
</table>
</form>
</body>
</html>

<%
}else{
Statement StmtI=con.createStatement();
String reqins="insert into personnel values('"+IDTA+"','"+Password+"','"+
Nom+"','"+Prenom+"',"+
CIN+"";

if(ProfilTA!=""){reqins+=",1,";}else reqins+=",0,";

if(ProfilAD!=""){reqins+="1,";}else reqins+="0,";

if(ProfilSUP!=""){reqins+="1,";}else reqins+="0,";


reqins+="0,";
reqins+="'00:00:00','00:00:00','Poste_101')";
System.out.print(reqins);
StmtI.executeUpdate(reqins);

if(SaveFile){
Fitm.write(savedFile);
Toren=new File(getServletContext().getRealPath("/")+"\\Photo\\"+IDTA+".jpg");
savedFile.renameTo(Toren);
savedFile.delete();

}


%>

<html>
<head>
<title>
AjoutTA
</title>

<script LANGUAGE="JavaScript" TYPE="text/javascript">
function isBlank(val){
if(val==null){return true;}
for(var i=0;i<val.length;i++) {
if ((val.charAt(i)==' ')||(val.charAt(i)=="\t")||(val.charAt(i)=="\n")||(val.charAt(i)=="\r")){return true;}
}
return false;
}

function isBeginBlank(val){
if(val==null){return true;}

if ((val.charAt(0)!=' ')&&(val.charAt(0)!="\t")&&(val.charAt(0)!="\n")&&(val.charAt(0)!="\r")){ return false;}

return true;
}

function isInteger(s)
{ var i;
for (i = 0; i < s.length; i++)
{
// Check that current character is number.
var c = s.charAt(i);
if (((c < "0") || (c > "9"))) return false;
}
// All characters are numbers.
return true;
}

function NoOnIsChecked()
{
if(document.F.ProfilTA.checked=="" && document.F.ProfilAD.checked=="" && document.F.ProfilSUP.checked=="" ){return true;}
return false;
}


function check() {
if (document.F.IDTA.value == "" || isBlank(document.F.IDTA.value) || document.F.IDTA.value.length >55 ) {
alert("Identifiant obligatoire et ne doit pas contenir des blancs.\n");
document.F.IDTA.focus();
return false;
}else{
if(document.F.Password.value == "" || isBlank(document.F.Password.value) || document.F.Password.value.length >55 ){
alert("Mot de passe obligatoire et ne doit pas contenir des blancs.\n");
document.F.Password.focus();
return false;
}else{
if(document.F.Nom.value == "" || isBeginBlank(document.F.Nom.value) || document.F.Nom.value.length >55){
alert("Nom obligatoire et ne doit pas commencer par des blancs.\n");
document.F.Nom.focus();
return false;
}else{
if(document.F.CIN.value.length < 8 || document.F.CIN.value.length >12 || ! isInteger(document.F.CIN.value)|| isBeginBlank(document.F.CIN.value) ){
alert("Numéro CIN est incorrecte ou trop long.\n");
document.F.CIN.focus();
return false;
}else{
if(NoOnIsChecked()){
alert("Un profil doit etre montionné.\n");
document.F.ProfilTA.focus();
document.F.ProfilAD.focus();
document.F.ProfilSUP.focus();
return false;
}
}
}
}
}
return true;
}
</script></head>


<body bgcolor="#ffAfff" background="Image1.jpg">
<table width="100%">
<tr>
<td height="150">




</td>
</tr>
</table>
<form action="" name="form1" onSubmit="return check()" method="post" enctype="multipart/form-data">
<table align="center" border="2" width="60%">
<tr>
<td colspan="2"><p align="center"><font size="+3" color="BLUE"> Formulaire d'ajout de nouveaux personnels</font></p></td>
</td>
</tr>
<tr>
<td width="40%">

<p align="justify"><font size="+1">Entrer Identifiant *</font></p>
</td>
<td>
<input type="text" name="IDTA" align="middle" size="30%">
</td>

</tr>
<tr>
<td width="40%">

<p align="justify"><font size="+1">Entrer Mot de passe * </font></p>
</td>
<td>
<input type="password" name="Password" align="middle" size="30%">
</td>

</tr>
<tr>
<td>
<p align="justify"><font size="+1">Entrer le Nom * </font></p>
</td>
<td>
<input type="text" name="Nom" align="middle" size="30%">
</td>
</tr>
<tr>
<td>
<p align="justify"><font size="+1">Entrer le Prénom * </font></p>
</td>
<td>
<label for="Prenom"><input type="text" name="Prenom" align="middle" size="30%"></label>
</td>
</tr>
<tr>
<td>
<p align="justify">N° CIN </p>
</td>
<td>
<label for="prenom"><input type="text" name="CIN" size="30%"></label>
</td>
</tr>
<tr>
<td>
<p align="justify"><font size="+1" color="#666699"><em><strong>Photo</strong></em></font></p>
</td>
<td>
<label for="prenom"><input type="file" name="PHOTO" size="30%"></label>
</td>
</tr>
<tr>

<td>
<p align="justify">Profil TA </p>
</td>
<td>

<input type="CheckBox" name="ProfilTA" value="1" align="middle">
</td>
</tr>
<tr>
<td>

<p align="justify">Profil Administrateur </p>
</td>
<td>

<input type="CheckBox" name="ProfilAD" value="2" align="middle">
</td>
</tr>
<tr>
<td>
<p align="justify">Profil Superviseur </p>
</td>
<td>
<input type="CheckBox" name="ProfilSUP" value="3" align="middle"> </td>
</td>
</tr>
</table>
<table align="center" width="60%">

<tr align="center">
<td align="center">

<p align="center"><input type="Submit" name="Ajouter" value="Ajouter" align="middle" size="15">
<input type="reset" value="Reset" align="middle" size="15"></p>
</td>
</tr>
<tr align="center" bgcolor="AAKJ00" >
<td width="40%">
<font color="blue" size="+2">Personnel ajouté avec succés</font>
</font>
</td>
</tr>

</table>
</form>
</body>
</html>



<%//@ page import="java.sql.*" %>

<%@ page import="java.io.File" %>
<%@ page import="java.io.BufferedWriter" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.io.*" %>
<%@ page import="java.*" %>
<%@ page import="java.util.GregorianCalendar" %>
<%@ page import="java.util.LinkedList" %>
<%
boolean Ajouter=false;
String IDTA="";
String Password="";
String Nom="";
String Prenom="";
String CIN="";
String ProfilTA="";
String ProfilAD="";
String ProfilSUP="";
boolean SaveFile=false;

DiskFileUpload upload = new DiskFileUpload();
List items = upload.parseRequest(request);
Iterator itr = items.iterator();
File fullFile=null;
File savedFile=null;
File Toren=null;
FileItem Fitm=null;
while(itr.hasNext()){
FileItem item = (FileItem) itr.next();
if(item.isFormField()) {
String fieldName = item.getFieldName();
if(fieldName.equals("IDTA")) IDTA=item.getString();
if(fieldName.equals("Password")) Password=item.getString();
if(fieldName.equals("Nom")) Nom=item.getString();
if(fieldName.equals("Prenom")) Prenom=item.getString();
if(fieldName.equals("CIN")) CIN=item.getString();
if(fieldName.equals("ProfilTA")) ProfilTA=item.getString();
if(fieldName.equals("ProfilSUP")) ProfilSUP=item.getString();
if(fieldName.equals("ProfilAD")) ProfilAD=item.getString();
if(fieldName.equals("Ajouter")) Ajouter=true;
}else{
if(!item.getName().equals("")){
fullFile = new File(item.getName());
savedFile = new File(getServletContext().getRealPath("/")+"\\Photo\\", fullFile.getName());//fullFile.getName()
System.out.print(getServletContext().getRealPath("/")+"/Photo/"+fullFile.getName());
SaveFile=true;
Fitm=item;
}
}}


if(Ajouter==true)
{
Connection con;
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection ("jdbc:mysql://localhost:3306/tunis", "root", "admin");
Statement Stmt = con.createStatement();
ResultSet rs=Stmt.executeQuery("select count(*) from personnel where ID='"+IDTA+"'");
rs.next();
if(rs.getInt(1)==1)
{
%>
<html>
<head>
<title>
paged'accueil
</title>

<script LANGUAGE="JavaScript" TYPE="text/javascript">
function isBlank(val){
if(val==null){return true;}
for(var i=0;i<val.length;i++) {
if ((val.charAt(i)==' ')||(val.charAt(i)=="\t")||(val.charAt(i)=="\n")||(val.charAt(i)=="\r")){return true;}
}
return false;
}

function isBeginBlank(val){
if(val==null){return true;}

if ((val.charAt(0)!=' ')&&(val.charAt(0)!="\t")&&(val.charAt(0)!="\n")&&(val.charAt(0)!="\r")){ return false;}

return true;
}

function isInteger(s)
{ var i;
for (i = 0; i < s.length; i++)
{
// Check that current character is number.
var c = s.charAt(i);
if (((c < "0") || (c > "9"))) return false;
}
// All characters are numbers.
return true;
}

function NoOnIsChecked()
{
if(document.F.ProfilTA.checked=="" && document.F.ProfilAD.checked=="" && document.F.ProfilSUP.checked=="" ){return true;}
return false;
}


function check() {
if (document.F.IDTA.value == "" || isBlank(document.F.IDTA.value) || document.F.IDTA.value.length >55 ) {
alert("Identifiant obligatoire et ne doit pas contenir des blancs.\n");
document.F.IDTA.focus();
return false;
}else{
if(document.F.Password.value == "" || isBlank(document.F.Password.value) || document.F.Password.value.length >55 ){
alert("Mot de passe obligatoire et ne doit pas contenir des blancs.\n");
document.F.Password.focus();
return false;
}else{
if(document.F.Nom.value == "" || isBeginBlank(document.F.Nom.value) || document.F.Nom.value.length >55){
alert("Nom obligatoire et ne doit pas commencer par des blancs.\n");
document.F.Nom.focus();
return false;
}else{
if(document.F.CIN.value.length < 8 || document.F.CIN.value.length >12 || ! isInteger(document.F.CIN.value)|| isBeginBlank(document.F.CIN.value) ){
alert("Numéro CIN est incorrecte ou trop long.\n");
document.F.CIN.focus();
return false;
}else{
if(NoOnIsChecked()){
alert("Un profil doit etre montionné.\n");
document.F.ProfilTA.focus();
document.F.ProfilAD.focus();
document.F.ProfilSUP.focus();
return false;
}
}
}
}
}
return true;
}
</script></head>

<body bgcolor="#248F9B">
<img src="file:///C|/access/image 2 int jpg.JPG" />
<form action="" name="form1" onSubmit="return check()" method="post" enctype="multipart/form-data" >

<table width="628" height="383" border="0" align="center" background="images/container-top-bg[1].gif">
<tr><td height="150">
</form>
</font>
<!--<table width="100%">



</td>
</tr>
</table>-->
<!--<form action="Personnel1.jsp" name="F" onSubmit="return check()" method="post" enctype="multipart/form-data" >
--> <center><br>
<font color="blue" size="+1"><A href="index.jsp"><font size="+6" color="#cc3366" ><em><strong>Page d'Accueil</strong></em></font></A></font></A></font>
</center>
<table align="center" border="2" width="60%">
<tr>
<td colspan="2"><p align="center"><font size="+3" color="BLUE"> Formulaire d'ajout de nouveaux personnels</font></p></td>
</td>
</tr>
<tr>
<td width="40%">

<p align="justify"><font size="+1"><em><strong>Entrer Identifiant *</strong></em></font></p>
</td>
<td>
<input type="text" name="IDTA" align="middle" size="30%" value="<%out.print(IDTA);%>">
</td>

</tr>
<tr>
<td width="40%">

<p align="justify"><font size="+1" ><em><strong>Entrer Mot de passe *</strong></em></font></p>
</td>
<td>
<input type="password" name="Password" align="middle" size="30%" value="">
</td>

</tr>
<tr>
<td>
<p align="justify"><font size="+1" ><em><strong>Entrer le Nom *</strong></em></font></p>
</td>
<td>
<input type="text" name="Nom" align="middle" size="30%" value="<%out.print(Nom);%>">
</td>
</tr>
<tr>
<td>
<p align="justify"><font size="+1"><em><strong>Entrer le Prénom *</strong></em></font></p>
</td>
<td>
<label for="Prenom"><input type="text" name="Prenom" align="middle" size="30%" value="<%out.print(Prenom);%>"></label>
</td>
</tr>
<tr>
<td>
<p align="justify"><font size="+1" ><em><strong>N° CIN </strong></em></font></p>
</td>
<td>
<label for="prenom"><input type="text" name="CIN" size="30%" value="<%out.print(CIN);%>"></label>
</td>
</tr>
<tr>
<td>
<p align="justify"><font size="+1" ><em><strong>Photo</strong></em></font></p>
</td>
<td>
<label for="prenom"><input type="file" name="PHOTO" size="30%"></label>
</td>
</tr>
<tr>

<td>
<p align="justify"><font size="+1"><em><strong>Profil TA </strong></em></font></p>
</td>
<td>

<input type="CheckBox" name="ProfilTA" value="1" align="middle">
</td>
</tr>
<tr>
<td>

<p align="justify"><font size="+1" ><em><strong>Profil Administrateur</strong></em></font></p>
</td>
<td>

<input type="CheckBox" name="ProfilAD" value="2" align="middle">
</td>
</tr>
<tr>
<td>
<p align="justify"><font size="+1"><em><strong>Profil Superviseur </strong></em></font></p>
</td>
<td>
<input type="CheckBox" name="ProfilSUP" value="3" align="middle"> </td>
</td>
</tr>
</table>
<table align="center" width="60%">

<tr align="center">
<td width="40%">

<p align="center"><input type="Submit" name="Ajouter" value="Ajouter" align="middle" size="15">
<input type="reset" value="Reset" align="middle" size="15"></p>
</td>
</tr>
<tr align="center">
<td bgcolor="blue">
<font color="red" size="+1"><b>Identifiant existe déjà: Veuillez choisir un autre</b></font>
</font>
</td>
</tr>
</table>
</form>
</body>
</html>

<%
}else{
Statement StmtI=con.createStatement();
String reqins="insert into personnel values('"+IDTA+"','"+Password+"','"+
Nom+"','"+Prenom+"',"+
CIN+"";

if(ProfilTA!=""){reqins+=",1,";}else reqins+=",0,";

if(ProfilAD!=""){reqins+="1,";}else reqins+="0,";

if(ProfilSUP!=""){reqins+="1,";}else reqins+="0,";


reqins+="0,";
reqins+="'00:00:00','00:00:00','Poste_101')";
System.out.print(reqins);
StmtI.executeUpdate(reqins);

if(SaveFile){
Fitm.write(savedFile);
Toren=new File(getServletContext().getRealPath("/")+"\\Photo\\"+IDTA+".jpg");
savedFile.renameTo(Toren);
savedFile.delete();

}


%>

<html>
<head>
<title>
AjoutTA
</title>

<script LANGUAGE="JavaScript" TYPE="text/javascript">
function isBlank(val){
if(val==null){return true;}
for(var i=0;i<val.length;i++) {
if ((val.charAt(i)==' ')||(val.charAt(i)=="\t")||(val.charAt(i)=="\n")||(val.charAt(i)=="\r")){return true;}
}
return false;
}

function isBeginBlank(val){
if(val==null){return true;}

if ((val.charAt(0)!=' ')&&(val.charAt(0)!="\t")&&(val.charAt(0)!="\n")&&(val.charAt(0)!="\r")){ return false;}

return true;
}

function isInteger(s)
{ var i;
for (i = 0; i < s.length; i++)
{
// Check that current character is number.
var c = s.charAt(i);
if (((c < "0") || (c > "9"))) return false;
}
// All characters are numbers.
return true;
}

function NoOnIsChecked()
{
if(document.F.ProfilTA.checked=="" && document.F.ProfilAD.checked=="" && document.F.ProfilSUP.checked=="" ){return true;}
return false;
}


function check() {
if (document.F.IDTA.value == "" || isBlank(document.F.IDTA.value) || document.F.IDTA.value.length >55 ) {
alert("Identifiant obligatoire et ne doit pas contenir des blancs.\n");
document.F.IDTA.focus();
return false;
}else{
if(document.F.Password.value == "" || isBlank(document.F.Password.value) || document.F.Password.value.length >55 ){
alert("Mot de passe obligatoire et ne doit pas contenir des blancs.\n");
document.F.Password.focus();
return false;
}else{
if(document.F.Nom.value == "" || isBeginBlank(document.F.Nom.value) || document.F.Nom.value.length >55){
alert("Nom obligatoire et ne doit pas commencer par des blancs.\n");
document.F.Nom.focus();
return false;
}else{
if(document.F.CIN.value.length < 8 || document.F.CIN.value.length >12 || ! isInteger(document.F.CIN.value)|| isBeginBlank(document.F.CIN.value) ){
alert("Numéro CIN est incorrecte ou trop long.\n");
document.F.CIN.focus();
return false;
}else{
if(NoOnIsChecked()){
alert("Un profil doit etre montionné.\n");
document.F.ProfilTA.focus();
document.F.ProfilAD.focus();
document.F.ProfilSUP.focus();
return false;
}
}
}
}
}
return true;
}
</script></head>


<body bgcolor="#ffAfff" background="Image1.jpg">
<table width="100%">
<tr>
<td height="150">




</td>
</tr>
</table>
<form action="" name="form1" onSubmit="return check()" method="post" enctype="multipart/form-data">
<table align="center" border="2" width="60%">
<tr>
<td colspan="2"><p align="center"><font size="+3" color="BLUE"> Formulaire d'ajout de nouveaux personnels</font></p></td>
</td>
</tr>
<tr>
<td width="40%">

<p align="justify"><font size="+1">Entrer Identifiant *</font></p>
</td>
<td>
<input type="text" name="IDTA" align="middle" size="30%">
</td>

</tr>
<tr>
<td width="40%">

<p align="justify"><font size="+1">Entrer Mot de passe * </font></p>
</td>
<td>
<input type="password" name="Password" align="middle" size="30%">
</td>

</tr>
<tr>
<td>
<p align="justify"><font size="+1">Entrer le Nom * </font></p>
</td>
<td>
<input type="text" name="Nom" align="middle" size="30%">
</td>
</tr>
<tr>
<td>
<p align="justify"><font size="+1">Entrer le Prénom * </font></p>
</td>
<td>
<label for="Prenom"><input type="text" name="Prenom" align="middle" size="30%"></label>
</td>
</tr>
<tr>
<td>
<p align="justify">N° CIN </p>
</td>
<td>
<label for="prenom"><input type="text" name="CIN" size="30%"></label>
</td>
</tr>
<tr>
<td>
<p align="justify"><font size="+1" color="#666699"><em><strong>Photo</strong></em></font></p>
</td>
<td>
<label for="prenom"><input type="file" name="PHOTO" size="30%"></label>
</td>
</tr>
<tr>

<td>
<p align="justify">Profil TA </p>
</td>
<td>

<input type="CheckBox" name="ProfilTA" value="1" align="middle">
</td>
</tr>
<tr>
<td>

<p align="justify">Profil Administrateur </p>
</td>
<td>

<input type="CheckBox" name="ProfilAD" value="2" align="middle">
</td>
</tr>
<tr>
<td>
<p align="justify">Profil Superviseur </p>
</td>
<td>
<input type="CheckBox" name="ProfilSUP" value="3" align="middle"> </td>
</td>
</tr>
</table>
<table align="center" width="60%">

<tr align="center">
<td align="center">

<p align="center"><input type="Submit" name="Ajouter" value="Ajouter" align="middle" size="15">
<input type="reset" value="Reset" align="middle" size="15"></p>
</td>
</tr>
<tr align="center" bgcolor="AAKJ00" >
<td width="40%">
<font color="blue" size="+2">Personnel ajouté avec succés</font>
</font>
</td>
</tr>

</table>
</form>
</body>
</html>



<%//@ page import="java.sql.*" %>

<%@ page import="java.io.File" %>
<%@ page import="java.io.BufferedWriter" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.io.*" %>
<%@ page import="java.*" %>
<%@ page import="java.util.GregorianCalendar" %>
<%@ page import="java.util.LinkedList" %>
<%
boolean Ajouter=false;
String IDTA="";
String Password="";
String Nom="";
String Prenom="";
String CIN="";
String ProfilTA="";
String ProfilAD="";
String ProfilSUP="";
boolean SaveFile=false;

DiskFileUpload upload = new DiskFileUpload();
List items = upload.parseRequest(request);
Iterator itr = items.iterator();
File fullFile=null;
File savedFile=null;
File Toren=null;
FileItem Fitm=null;
while(itr.hasNext()){
FileItem item = (FileItem) itr.next();
if(item.isFormField()) {
String fieldName = item.getFieldName();
if(fieldName.equals("IDTA")) IDTA=item.getString();
if(fieldName.equals("Password")) Password=item.getString();
if(fieldName.equals("Nom")) Nom=item.getString();
if(fieldName.equals("Prenom")) Prenom=item.getString();
if(fieldName.equals("CIN")) CIN=item.getString();
if(fieldName.equals("ProfilTA")) ProfilTA=item.getString();
if(fieldName.equals("ProfilSUP")) ProfilSUP=item.getString();
if(fieldName.equals("ProfilAD")) ProfilAD=item.getString();
if(fieldName.equals("Ajouter")) Ajouter=true;
}else{
if(!item.getName().equals("")){
fullFile = new File(item.getName());
savedFile = new File(getServletContext().getRealPath("/")+"\\Photo\\", fullFile.getName());//fullFile.getName()
System.out.print(getServletContext().getRealPath("/")+"/Photo/"+fullFile.getName());
SaveFile=true;
Fitm=item;
}
}}


if(Ajouter==true)
{
Connection con;
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection ("jdbc:mysql://localhost:3306/tunis", "root", "admin");
Statement Stmt = con.createStatement();
ResultSet rs=Stmt.executeQuery("select count(*) from personnel where ID='"+IDTA+"'");
rs.next();
if(rs.getInt(1)==1)
{
%>
<html>
<head>
<title>
paged'accueil
</title>

<script LANGUAGE="JavaScript" TYPE="text/javascript">
function isBlank(val){
if(val==null){return true;}
for(var i=0;i<val.length;i++) {
if ((val.charAt(i)==' ')||(val.charAt(i)=="\t")||(val.charAt(i)=="\n")||(val.charAt(i)=="\r")){return true;}
}
return false;
}

function isBeginBlank(val){
if(val==null){return true;}

if ((val.charAt(0)!=' ')&&(val.charAt(0)!="\t")&&(val.charAt(0)!="\n")&&(val.charAt(0)!="\r")){ return false;}

return true;
}

function isInteger(s)
{ var i;
for (i = 0; i < s.length; i++)
{
// Check that current character is number.
var c = s.charAt(i);
if (((c < "0") || (c > "9"))) return false;
}
// All characters are numbers.
return true;
}

function NoOnIsChecked()
{
if(document.F.ProfilTA.checked=="" && document.F.ProfilAD.checked=="" && document.F.ProfilSUP.checked=="" ){return true;}
return false;
}


function check() {
if (document.F.IDTA.value == "" || isBlank(document.F.IDTA.value) || document.F.IDTA.value.length >55 ) {
alert("Identifiant obligatoire et ne doit pas contenir des blancs.\n");
document.F.IDTA.focus();
return false;
}else{
if(document.F.Password.value == "" || isBlank(document.F.Password.value) || document.F.Password.value.length >55 ){
alert("Mot de passe obligatoire et ne doit pas contenir des blancs.\n");
document.F.Password.focus();
return false;
}else{
if(document.F.Nom.value == "" || isBeginBlank(document.F.Nom.value) || document.F.Nom.value.length >55){
alert("Nom obligatoire et ne doit pas commencer par des blancs.\n");
document.F.Nom.focus();
return false;
}else{
if(document.F.CIN.value.length < 8 || document.F.CIN.value.length >12 || ! isInteger(document.F.CIN.value)|| isBeginBlank(document.F.CIN.value) ){
alert("Numéro CIN est incorrecte ou trop long.\n");
document.F.CIN.focus();
return false;
}else{
if(NoOnIsChecked()){
alert("Un profil doit etre montionné.\n");
document.F.ProfilTA.focus();
document.F.ProfilAD.focus();
document.F.ProfilSUP.focus();
return false;
}
}
}
}
}
return true;
}
</script></head>

<body bgcolor="#248F9B">
<img src="file:///C|/access/image 2 int jpg.JPG" />
<form action="" name="form1" onSubmit="return check()" method="post" enctype="multipart/form-data" >

<table width="628" height="383" border="0" align="center" background="images/container-top-bg[1].gif">
<tr><td height="150">
</form>
</font>
<!--<table width="100%">



</td>
</tr>
</table>-->
<!--<form action="Personnel1.jsp" name="F" onSubmit="return check()" method="post" enctype="multipart/form-data" >
--> <center><br>
<font color="blue" size="+1"><A href="index.jsp"><font size="+6" color="#cc3366" ><em><strong>Page d'Accueil</strong></em></font></A></font></A></font>
</center>
<table align="center" border="2" width="60%">
<tr>
<td colspan="2"><p align="center"><font size="+3" color="BLUE"> Formulaire d'ajout de nouveaux personnels</font></p></td>
</td>
</tr>
<tr>
<td width="40%">

<p align="justify"><font size="+1"><em><strong>Entrer Identifiant *</strong></em></font></p>
</td>
<td>
<input type="text" name="IDTA" align="middle" size="30%" value="<%out.print(IDTA);%>">
</td>

</tr>
<tr>
<td width="40%">

<p align="justify"><font size="+1" ><em><strong>Entrer Mot de passe *</strong></em></font></p>
</td>
<td>
<input type="password" name="Password" align="middle" size="30%" value="">
</td>

</tr>
<tr>
<td>
<p align="justify"><font size="+1" ><em><strong>Entrer le Nom *</strong></em></font></p>
</td>
<td>
<input type="text" name="Nom" align="middle" size="30%" value="<%out.print(Nom);%>">
</td>
</tr>
<tr>
<td>
<p align="justify"><font size="+1"><em><strong>Entrer le Prénom *</strong></em></font></p>
</td>
<td>
<label for="Prenom"><input type="text" name="Prenom" align="middle" size="30%" value="<%out.print(Prenom);%>"></label>
</td>
</tr>
<tr>
<td>
<p align="justify"><font size="+1" ><em><strong>N° CIN </strong></em></font></p>
</td>
<td>
<label for="prenom"><input type="text" name="CIN" size="30%" value="<%out.print(CIN);%>"></label>
</td>
</tr>
<tr>
<td>
<p align="justify"><font size="+1" ><em><strong>Photo</strong></em></font></p>
</td>
<td>
<label for="prenom"><input type="file" name="PHOTO" size="30%"></label>
</td>
</tr>
<tr>

<td>
<p align="justify"><font size="+1"><em><strong>Profil TA </strong></em></font></p>
</td>
<td>

<input type="CheckBox" name="ProfilTA" value="1" align="middle">
</td>
</tr>
<tr>
<td>

<p align="justify"><font size="+1" ><em><strong>Profil Administrateur</strong></em></font></p>
</td>
<td>

<input type="CheckBox" name="ProfilAD" value="2" align="middle">
</td>
</tr>
<tr>
<td>
<p align="justify"><font size="+1"><em><strong>Profil Superviseur </strong></em></font></p>
</td>
<td>
<input type="CheckBox" name="ProfilSUP" value="3" align="middle"> </td>
</td>
</tr>
</table>
<table align="center" width="60%">

<tr align="center">
<td width="40%">

<p align="center"><input type="Submit" name="Ajouter" value="Ajouter" align="middle" size="15">
<input type="reset" value="Reset" align="middle" size="15"></p>
</td>
</tr>
<tr align="center">
<td bgcolor="blue">
<font color="red" size="+1"><b>Identifiant existe déjà: Veuillez choisir un autre</b></font>
</font>
</td>
</tr>
</table>
</form>
</body>
</html>

<%
}else{
Statement StmtI=con.createStatement();
String reqins="insert into personnel values('"+IDTA+"','"+Password+"','"+
Nom+"','"+Prenom+"',"+
CIN+"";

if(ProfilTA!=""){reqins+=",1,";}else reqins+=",0,";

if(ProfilAD!=""){reqins+="1,";}else reqins+="0,";

if(ProfilSUP!=""){reqins+="1,";}else reqins+="0,";


reqins+="0,";
reqins+="'00:00:00','00:00:00','Poste_101')";
System.out.print(reqins);
StmtI.executeUpdate(reqins);

if(SaveFile){
Fitm.write(savedFile);
Toren=new File(getServletContext().getRealPath("/")+"\\Photo\\"+IDTA+".jpg");
savedFile.renameTo(Toren);
savedFile.delete();

}


%>

<html>
<head>
<title>
AjoutTA
</title>

<script LANGUAGE="JavaScript" TYPE="text/javascript">
function isBlank(val){
if(val==null){return true;}
for(var i=0;i<val.length;i++) {
if ((val.charAt(i)==' ')||(val.charAt(i)=="\t")||(val.charAt(i)=="\n")||(val.charAt(i)=="\r")){return true;}
}
return false;
}

function isBeginBlank(val){
if(val==null){return true;}

if ((val.charAt(0)!=' ')&&(val.charAt(0)!="\t")&&(val.charAt(0)!="\n")&&(val.charAt(0)!="\r")){ return false;}

return true;
}

function isInteger(s)
{ var i;
for (i = 0; i < s.length; i++)
{
// Check that current character is number.
var c = s.charAt(i);
if (((c < "0") || (c > "9"))) return false;
}
// All characters are numbers.
return true;
}

function NoOnIsChecked()
{
if(document.F.ProfilTA.checked=="" && document.F.ProfilAD.checked=="" && document.F.ProfilSUP.checked=="" ){return true;}
return false;
}


function check() {
if (document.F.IDTA.value == "" || isBlank(document.F.IDTA.value) || document.F.IDTA.value.length >55 ) {
alert("Identifiant obligatoire et ne doit pas contenir des blancs.\n");
document.F.IDTA.focus();
return false;
}else{
if(document.F.Password.value == "" || isBlank(document.F.Password.value) || document.F.Password.value.length >55 ){
alert("Mot de passe obligatoire et ne doit pas contenir des blancs.\n");
document.F.Password.focus();
return false;
}else{
if(document.F.Nom.value == "" || isBeginBlank(document.F.Nom.value) || document.F.Nom.value.length >55){
alert("Nom obligatoire et ne doit pas commencer par des blancs.\n");
document.F.Nom.focus();
return false;
}else{
if(document.F.CIN.value.length < 8 || document.F.CIN.value.length >12 || ! isInteger(document.F.CIN.value)|| isBeginBlank(document.F.CIN.value) ){
alert("Numéro CIN est incorrecte ou trop long.\n");
document.F.CIN.focus();
return false;
}else{
if(NoOnIsChecked()){
alert("Un profil doit etre montionné.\n");
document.F.ProfilTA.focus();
document.F.ProfilAD.focus();
document.F.ProfilSUP.focus();
return false;
}
}
}
}
}
return true;
}
</script></head>


<body bgcolor="#ffAfff" background="Image1.jpg">
<table width="100%">
<tr>
<td height="150">




</td>
</tr>
</table>
<form action="" name="form1" onSubmit="return check()" method="post" enctype="multipart/form-data">
<table align="center" border="2" width="60%">
<tr>
<td colspan="2"><p align="center"><font size="+3" color="BLUE"> Formulaire d'ajout de nouveaux personnels</font></p></td>
</td>
</tr>
<tr>
<td width="40%">

<p align="justify"><font size="+1">Entrer Identifiant *</font></p>
</td>
<td>
<input type="text" name="IDTA" align="middle" size="30%">
</td>

</tr>
<tr>
<td width="40%">

<p align="justify"><font size="+1">Entrer Mot de passe * </font></p>
</td>
<td>
<input type="password" name="Password" align="middle" size="30%">
</td>

</tr>
<tr>
<td>
<p align="justify"><font size="+1">Entrer le Nom * </font></p>
</td>
<td>
<input type="text" name="Nom" align="middle" size="30%">
</td>
</tr>
<tr>
<td>
<p align="justify"><font size="+1">Entrer le Prénom * </font></p>
</td>
<td>
<label for="Prenom"><input type="text" name="Prenom" align="middle" size="30%"></label>
</td>
</tr>
<tr>
<td>
<p align="justify">N° CIN </p>
</td>
<td>
<label for="prenom"><input type="text" name="CIN" size="30%"></label>
</td>
</tr>
<tr>
<td>
<p align="justify"><font size="+1" color="#666699"><em><strong>Photo</strong></em></font></p>
</td>
<td>
<label for="prenom"><input type="file" name="PHOTO" size="30%"></label>
</td>
</tr>
<tr>

<td>
<p align="justify">Profil TA </p>
</td>
<td>

<input type="CheckBox" name="ProfilTA" value="1" align="middle">
</td>
</tr>
<tr>
<td>

<p align="justify">Profil Administrateur </p>
</td>
<td>

<input type="CheckBox" name="ProfilAD" value="2" align="middle">
</td>
</tr>
<tr>
<td>
<p align="justify">Profil Superviseur </p>
</td>
<td>
<input type="CheckBox" name="ProfilSUP" value="3" align="middle"> </td>
</td>
</tr>
</table>
<table align="center" width="60%">

<tr align="center">
<td align="center">

<p align="center"><input type="Submit" name="Ajouter" value="Ajouter" align="middle" size="15">
<input type="reset" value="Reset" align="middle" size="15"></p>
</td>
</tr>
<tr align="center" bgcolor="AAKJ00" >
<td width="40%">
<font color="blue" size="+2">Personnel ajouté avec succés</font>
</font>
</td>
</tr>

</table>
</form>
</body>
</html>



<%//@ page import="java.sql.*" %>

<%@ page import="java.io.File" %>
<%@ page import="java.io.BufferedWriter" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.io.*" %>
<%@ page import="java.*" %>
<%@ page import="java.util.GregorianCalendar" %>
<%@ page import="java.util.LinkedList" %>
<%
boolean Ajouter=false;
String IDTA="";
String Password="";
String Nom="";
String Prenom="";
String CIN="";
String ProfilTA="";
String ProfilAD="";
String ProfilSUP="";
boolean SaveFile=false;

DiskFileUpload upload = new DiskFileUpload();
List items = upload.parseRequest(request);
Iterator itr = items.iterator();
File fullFile=null;
File savedFile=null;
File Toren=null;
FileItem Fitm=null;
while(itr.hasNext()){
FileItem item = (FileItem) itr.next();
if(item.isFormField()) {
String fieldName = item.getFieldName();
if(fieldName.equals("IDTA")) IDTA=item.getString();
if(fieldName.equals("Password")) Password=item.getString();
if(fieldName.equals("Nom")) Nom=item.getString();
if(fieldName.equals("Prenom")) Prenom=item.getString();
if(fieldName.equals("CIN")) CIN=item.getString();
if(fieldName.equals("ProfilTA")) ProfilTA=item.getString();
if(fieldName.equals("ProfilSUP")) ProfilSUP=item.getString();
if(fieldName.equals("ProfilAD")) ProfilAD=item.getString();
if(fieldName.equals("Ajouter")) Ajouter=true;
}else{
if(!item.getName().equals("")){
fullFile = new File(item.getName());
savedFile = new File(getServletContext().getRealPath("/")+"\\Photo\\", fullFile.getName());//fullFile.getName()
System.out.print(getServletContext().getRealPath("/")+"/Photo/"+fullFile.getName());
SaveFile=true;
Fitm=item;
}
}}


if(Ajouter==true)
{
Connection con;
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection ("jdbc:mysql://localhost:3306/tunis", "root", "admin");
Statement Stmt = con.createStatement();
ResultSet rs=Stmt.executeQuery("select count(*) from personnel where ID='"+IDTA+"'");
rs.next();
if(rs.getInt(1)==1)
{
%>
<html>
<head>
<title>
paged'accueil
</title>

<script LANGUAGE="JavaScript" TYPE="text/javascript">
function isBlank(val){
if(val==null){return true;}
for(var i=0;i<val.length;i++) {
if ((val.charAt(i)==' ')||(val.charAt(i)=="\t")||(val.charAt(i)=="\n")||(val.charAt(i)=="\r")){return true;}
}
return false;
}

function isBeginBlank(val){
if(val==null){return true;}

if ((val.charAt(0)!=' ')&&(val.charAt(0)!="\t")&&(val.charAt(0)!="\n")&&(val.charAt(0)!="\r")){ return false;}

return true;
}

function isInteger(s)
{ var i;
for (i = 0; i < s.length; i++)
{
// Check that current character is number.
var c = s.charAt(i);
if (((c < "0") || (c > "9"))) return false;
}
// All characters are numbers.
return true;
}

function NoOnIsChecked()
{
if(document.F.ProfilTA.checked=="" && document.F.ProfilAD.checked=="" && document.F.ProfilSUP.checked=="" ){return true;}
return false;
}


function check() {
if (document.F.IDTA.value == "" || isBlank(document.F.IDTA.value) || document.F.IDTA.value.length >55 ) {
alert("Identifiant obligatoire et ne doit pas contenir des blancs.\n");
document.F.IDTA.focus();
return false;
}else{
if(document.F.Password.value == "" || isBlank(document.F.Password.value) || document.F.Password.value.length >55 ){
alert("Mot de passe obligatoire et ne doit pas contenir des blancs.\n");
document.F.Password.focus();
return false;
}else{
if(document.F.Nom.value == "" || isBeginBlank(document.F.Nom.value) || document.F.Nom.value.length >55){
alert("Nom obligatoire et ne doit pas commencer par des blancs.\n");
document.F.Nom.focus();
return false;
}else{
if(document.F.CIN.value.length < 8 || document.F.CIN.value.length >12 || ! isInteger(document.F.CIN.value)|| isBeginBlank(document.F.CIN.value) ){
alert("Numéro CIN est incorrecte ou trop long.\n");
document.F.CIN.focus();
return false;
}else{
if(NoOnIsChecked()){
alert("Un profil doit etre montionné.\n");
document.F.ProfilTA.focus();
document.F.ProfilAD.focus();
document.F.ProfilSUP.focus();
return false;
}
}
}
}
}
return true;
}
</script></head>

<body bgcolor="#248F9B">
<img src="file:///C|/access/image 2 int jpg.JPG" />
<form action="" name="form1" onSubmit="return check()" method="post" enctype="multipart/form-data" >

<table width="628" height="383" border="0" align="center" background="images/container-top-bg[1].gif">
<tr><td height="150">
</form>
</font>
<!--<table width="100%">



</td>
</tr>
</table>-->
<!--<form action="Personnel1.jsp" name="F" onSubmit="return check()" method="post" enctype="multipart/form-data" >
--> <center><br>
<font color="blue" size="+1"><A href="index.jsp"><font size="+6" color="#cc3366" ><em><strong>Page d'Accueil</strong></em></font></A></font></A></font>
</center>
<table align="center" border="2" width="60%">
<tr>
<td colspan="2"><p align="center"><font size="+3" color="BLUE"> Formulaire d'ajout de nouveaux personnels</font></p></td>
</td>
</tr>
<tr>
<td width="40%">

<p align="justify"><font size="+1"><em><strong>Entrer Identifiant *</strong></em></font></p>
</td>
<td>
<input type="text" name="IDTA" align="middle" size="30%" value="<%out.print(IDTA);%>">
</td>

</tr>
<tr>
<td width="40%">

<p align="justify"><font size="+1" ><em><strong>Entrer Mot de passe *</strong></em></font></p>
</td>
<td>
<input type="password" name="Password" align="middle" size="30%" value="">
</td>

</tr>
<tr>
<td>
<p align="justify"><font size="+1" ><em><strong>Entrer le Nom *</strong></em></font></p>
</td>
<td>
<input type="text" name="Nom" align="middle" size="30%" value="<%out.print(Nom);%>">
</td>
</tr>
<tr>
<td>
<p align="justify"><font size="+1"><em><strong>Entrer le Prénom *</strong></em></font></p>
</td>
<td>
<label for="Prenom"><input type="text" name="Prenom" align="middle" size="30%" value="<%out.print(Prenom);%>"></label>
</td>
</tr>
<tr>
<td>
<p align="justify"><font size="+1" ><em><strong>N° CIN </strong></em></font></p>
</td>
<td>
<label for="prenom"><input type="text" name="CIN" size="30%" value="<%out.print(CIN);%>"></label>
</td>
</tr>
<tr>
<td>
<p align="justify"><font size="+1" ><em><strong>Photo</strong></em></font></p>
</td>
<td>
<label for="prenom"><input type="file" name="PHOTO" size="30%"></label>
</td>
</tr>
<tr>

<td>
<p align="justify"><font size="+1"><em><strong>Profil TA </strong></em></font></p>
</td>
<td>

<input type="CheckBox" name="ProfilTA" value="1" align="middle">
</td>
</tr>
<tr>
<td>

<p align="justify"><font size="+1" ><em><strong>Profil Administrateur</strong></em></font></p>
</td>
<td>

<input type="CheckBox" name="ProfilAD" value="2" align="middle">
</td>
</tr>
<tr>
<td>
<p align="justify"><font size="+1"><em><strong>Profil Superviseur </strong></em></font></p>
</td>
<td>
<input type="CheckBox" name="ProfilSUP" value="3" align="middle"> </td>
</td>
</tr>
</table>
<table align="center" width="60%">

<tr align="center">
<td width="40%">

<p align="center"><input type="Submit" name="Ajouter" value="Ajouter" align="middle" size="15">
<input type="reset" value="Reset" align="middle" size="15"></p>
</td>
</tr>
<tr align="center">
<td bgcolor="blue">
<font color="red" size="+1"><b>Identifiant existe déjà: Veuillez choisir un autre</b></font>
</font>
</td>
</tr>
</table>
</form>
</body>
</html>

<%
}else{
Statement StmtI=con.createStatement();
String reqins="insert into personnel values('"+IDTA+"','"+Password+"','"+
Nom+"','"+Prenom+"',"+
CIN+"";

if(ProfilTA!=""){reqins+=",1,";}else reqins+=",0,";

if(ProfilAD!=""){reqins+="1,";}else reqins+="0,";

if(ProfilSUP!=""){reqins+="1,";}else reqins+="0,";


reqins+="0,";
reqins+="'00:00:00','00:00:00','Poste_101')";
System.out.print(reqins);
StmtI.executeUpdate(reqins);

if(SaveFile){
Fitm.write(savedFile);
Toren=new File(getServletContext().getRealPath("/")+"\\Photo\\"+IDTA+".jpg");
savedFile.renameTo(Toren);
savedFile.delete();

}


%>

<html>
<head>
<title>
AjoutTA
</title>

<script LANGUAGE="JavaScript" TYPE="text/javascript">
function isBlank(val){
if(val==null){return true;}
for(var i=0;i<val.length;i++) {
if ((val.charAt(i)==' ')||(val.charAt(i)=="\t")||(val.charAt(i)=="\n")||(val.charAt(i)=="\r")){return true;}
}
return false;
}

function isBeginBlank(val){
if(val==null){return true;}

if ((val.charAt(0)!=' ')&&(val.charAt(0)!="\t")&&(val.charAt(0)!="\n")&&(val.charAt(0)!="\r")){ return false;}

return true;
}

function isInteger(s)
{ var i;
for (i = 0; i < s.length; i++)
{
// Check that current character is number.
var c = s.charAt(i);
if (((c < "0") || (c > "9"))) return false;
}
// All characters are numbers.
return true;
}

function NoOnIsChecked()
{
if(document.F.ProfilTA.checked=="" && document.F.ProfilAD.checked=="" && document.F.ProfilSUP.checked=="" ){return true;}
return false;
}


function check() {
if (document.F.IDTA.value == "" || isBlank(document.F.IDTA.value) || document.F.IDTA.value.length >55 ) {
alert("Identifiant obligatoire et ne doit pas contenir des blancs.\n");
document.F.IDTA.focus();
return false;
}else{
if(document.F.Password.value == "" || isBlank(document.F.Password.value) || document.F.Password.value.length >55 ){
alert("Mot de passe obligatoire et ne doit pas contenir des blancs.\n");
document.F.Password.focus();
return false;
}else{
if(document.F.Nom.value == "" || isBeginBlank(document.F.Nom.value) || document.F.Nom.value.length >55){
alert("Nom obligatoire et ne doit pas commencer par des blancs.\n");
document.F.Nom.focus();
return false;
}else{
if(document.F.CIN.value.length < 8 || document.F.CIN.value.length >12 || ! isInteger(document.F.CIN.value)|| isBeginBlank(document.F.CIN.value) ){
alert("Numéro CIN est incorrecte ou trop long.\n");
document.F.CIN.focus();
return false;
}else{
if(NoOnIsChecked()){
alert("Un profil doit etre montionné.\n");
document.F.ProfilTA.focus();
document.F.ProfilAD.focus();
document.F.ProfilSUP.focus();
return false;
}
}
}
}
}
return true;
}
</script></head>


<body bgcolor="#ffAfff" background="Image1.jpg">
<table width="100%">
<tr>
<td height="150">




</td>
</tr>
</table>
<form action="" name="form1" onSubmit="return check()" method="post" enctype="multipart/form-data">
<table align="center" border="2" width="60%">
<tr>
<td colspan="2"><p align="center"><font size="+3" color="BLUE"> Formulaire d'ajout de nouveaux personnels</font></p></td>
</td>
</tr>
<tr>
<td width="40%">

<p align="justify"><font size="+1">Entrer Identifiant *</font></p>
</td>
<td>
<input type="text" name="IDTA" align="middle" size="30%">
</td>

</tr>
<tr>
<td width="40%">

<p align="justify"><font size="+1">Entrer Mot de passe * </font></p>
</td>
<td>
<input type="password" name="Password" align="middle" size="30%">
</td>

</tr>
<tr>
<td>
<p align="justify"><font size="+1">Entrer le Nom * </font></p>
</td>
<td>
<input type="text" name="Nom" align="middle" size="30%">
</td>
</tr>
<tr>
<td>
<p align="justify"><font size="+1">Entrer le Prénom * </font></p>
</td>
<td>
<label for="Prenom"><input type="text" name="Prenom" align="middle" size="30%"></label>
</td>
</tr>
<tr>
<td>
<p align="justify">N° CIN </p>
</td>
<td>
<label for="prenom"><input type="text" name="CIN" size="30%"></label>
</td>
</tr>
<tr>
<td>
<p align="justify"><font size="+1" color="#666699"><em><strong>Photo</strong></em></font></p>
</td>
<td>
<label for="prenom"><input type="file" name="PHOTO" size="30%"></label>
</td>
</tr>
<tr>

<td>
<p align="justify">Profil TA </p>
</td>
<td>

<input type="CheckBox" name="ProfilTA" value="1" align="middle">
</td>
</tr>
<tr>
<td>

<p align="justify">Profil Administrateur </p>
</td>
<td>

<input type="CheckBox" name="ProfilAD" value="2" align="middle">
</td>
</tr>
<tr>
<td>
<p align="justify">Profil Superviseur </p>
</td>
<td>
<input type="CheckBox" name="ProfilSUP" value="3" align="middle"> </td>
</td>
</tr>
</table>
<table align="center" width="60%">

<tr align="center">
<td align="center">

<p align="center"><input type="Submit" name="Ajouter" value="Ajouter" align="middle" size="15">
<input type="reset" value="Reset" align="middle" size="15"></p>
</td>
</tr>
<tr align="center" bgcolor="AAKJ00" >
<td width="40%">
<font color="blue" size="+2">Personnel ajouté avec succés</font>
</font>
</td>
</tr>

</table>
</form>
</body>
</html>
mais ce code affiche des erreurs:
'catch' sans 'try'
'try' sans 'catch' ou 'finally'
'}' attendu
svp aide moi pour correger ces erreurs
samedi 7 juin 2008 à 14:28:13 | Re : ajout

DARKSIDIOUS

Membre Club Administrateur CodeS-SourceS
Salut,

Bah c'est cool, mais c'est quoi le problème au juste ???

Tu veux faire la jsp la plus longue au monde ?

Tu veux faire la jsp qui respecte le moins possible les standards préconisés par sun ?
______________________________________
DarK Sidious
lundi 9 juin 2008 à 09:57:37 | Re : ajout

Twinuts

Membre Club Administrateur CodeS-SourceS


Salut,

tu n'es pas chez mémé ici alors calmos avec les pavés de codes !


------------------------------------
"On n'est pas au resto : ici on ne fait pas dans les plats tout cuits ..."

OoWORAoO


Cette discussion est classée dans : document, return, false, value, if


Répondre à ce message

Sujets en rapport avec ce message

validation de deux formulaire [ par jfkill ] J'ai deux formulaire sur une meme page et je veux valider c'est deux formulaire de facon indépendanteParce que j'en ai un francais et un autre anglais password [ par procef ] salut a tous, je bloque sur un pass a cracké, je vous demande pas de galerer dessus mais juste de jeter un ptit coup d'oeil! merci function right(e) Probleme PDFBox [ par tof008 ] Bonjour, J'utilise la librairie PDFBox pour ouvrir un document PDF. Ce document s'ouvre avec un mot de passe. J'utilise le code suivant pour ouvrir Saisie semi automatique [ par keket ] Bien le bonjour. Je viens vous voir aujourd'hui car j'ai un petit soucis de compréhension avec un code que je n'arrive pas très bien a cerner. Le but java [ par limalima ] Bonjour,j'ai un code dont je ne comprends pas le résultat:public<font color="#7f0055 convertir les tableaux html en XML [ par asle ] salut, j'ai le code suivant qui permet d'extraire un tableau html et le transformer en xml: import org.htmlparser.*; import org.htmlparser.util.*; i Player multi format sécuriter java & php [ par c2bomb ] bonjour a tous,je cherche a afficher mon player,dans une fenetre style popup,mais hélas je suis vraiment nulle en javascript...si quelq'un peut m'aide erreur sur le code huffman [ par lekludo ] bonjour a vousj'ai un probleme je suis débutant en java et j'ai un petit proget qui m'a été donné sur le code de huffman seulement lorsque j'exécute, polygones convexes [ par beatriz42 ] Bonjour à tous Est ce quelqu'un pourrait m'aider. Je n'arrive pas à trouver une fonction qui est-convexe qui me permet de créer un polygone convexe à communiquer avec l'utilisateur [ par dmfdmf ] Bonjour à tous, je cherche à [b]communiquer avec l'utilisateur[/b] pour tracer une ligne droite. j'ai essayer ceci, mais cela ne fonctionne pas. [co


Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Février 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

Consulter la suite du CalendriCode

Photothèque

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 1,217 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales