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