1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
| <%@ LANGUAGE="VBSCRIPT" %>
<%
OPTION EXPLICIT
%>
<!-- #include file="../Include/bloc_menu.asp" -->
<!-- #include file="../Utils/gConst.asp"-->
<!-- #include file="../Utils/Utils.asp"-->
<%
RESPONSE.BUFFER = TRUE
' Fonctions Internes
' Vérification des datas
Function CheckData()
Dim blnretour
blnretour= TRUE
libelle = Request("libelle")
If len(libelle) = 0 then
libelle = " une libelle ici !!"
blnretour = FALSE
End If
detail = Request("detail")
CheckData = blnretour
End Function
' Enregistre une nouvelle catégorie
Function Insert_Cat()
Dim oConnx
Dim StrSQL
If CheckData() then
StrSQL = "INSERT INTO Cat_form (libelle, detail)" & _
" VALUES ('" & Replace(libelle,"'","''") & "', '" & Replace(detail,"'","''") & "')"
'Response.write strSQL
Set oConnx = Server.CreateObject("ADODB.CONNECTION")
oConnx.Open CONNECTION_ACCESS
oConnx.Execute(StrSQL)
oConnx.Close
Set oConnx = nothing
Response.Redirect "formation.asp"
End If
End Function
' Modifie une categorie
Function Update_Cat()
Dim oConnx
Dim StrSQL
If CheckData() then
StrSQL = "UPDATE Cat_form SET" & _
" libelle='"& Replace(libelle,"'","''") & "'" & _
", detail='"& Replace(detail,"'","''") & "'" & _
" WHERE id=" & id
'Response.write StrSQL
Set oConnx = Server.CreateObject("ADODB.CONNECTION")
oConnx.Open CONNECTION_ACCESS
oConnx.Execute(StrSQL)
oConnx.Close
Set oConnx = nothing
Response.Redirect "formation.asp"
End If
End Function
' Ouvre l'enregistrement et initialise les variables
Function Get_Infos()
Dim oConnx
Dim oRsCatFrm
Dim StrSQL
StrSQL = "SELECT * FROM Cat_form WHERE ID=" & id
Set oConnx = Server.CreateObject("ADODB.CONNECTION")
oConnx.Open CONNECTION_ACCESS
Set oRsCatFrm = Server.CreateObject("ADODB.RECORDSET")
oRsCAtFrm.Open StrSQL, oConnx
If Not oRsCatFrm.EOF then
libelle = oRsCatFrm("libelle")
detail = oRsCatFrm("detail")
End If
oRsCatFrm.Close
Set oRsCatFrm = Nothing
oConnx.Close
Set oConnx = Nothing
End Function
' Affiche la catégorie dans un formulaire
Function Affiche_Cat()
With Response
.write "<TABLE WIDTH=""480px"" class=""cadre"" cellpadding=""0"" cellspacing=""0"" border=""0"">"
.write "<FORM METHOD=""POST"" ACTION=""Detail_cat.asp"">"
.write "<INPUT TYPE=""HIDDEN"" NAME=""action"" VALUE=""1"">"
.write "<INPUT TYPE=""HIDDEN"" NAME=""id_cat"" VALUE=""" & id & """>"
.write "<TR>"
.write "<TD COLSPAN=""2"" ALIGN=""CENTER"" class=""titre_tableau"">Catégorie de formation</TD>"
.write "</TR>"
.write "<TR>"
.write "<TD colspan=""2"" WIDTH=""480px"" class=""bloc""> ID : " & id & "</TD>"
'.write "<TD WIDTH=""300px"" class=""bloc"">" & id & "</TD>"
.write "</TR>"
.write "<TR>"
.write "<TD WIDTH=""100px"" class=""bloc""> <b>Libelle : </TD>"
.write "<TD WIDTH=""480px"" class=""bloc""><INPUT TYPE=""TEXTE"" SIZE=""40"" NAME=""LIBELLE"" VALUE=""" & libelle & """ class=""saisie""></TD>"
.write "</TR>"
.write "<TR>"
.write "<TD colspan=""2"" WIDTH=""480px"" class=""bloc""> <b>Détail : </TD>"
.write "</TR>"
.write "<TR>"
.write "<TD colspan=""2"" WIDTH=""480px"" class=""bloc"" align=""center""><TEXTAREA NAME=""DETAIL"" ROWS=""8"" COLS=""80"" class=""saisie"">" & detail & "</TEXTAREA></TD>"
.write "</TR>"
.write "<TR>"
.write "<TD COLSPAN=""2"" ALIGN=""RIGHT"" WIDTH=""480px"" class=""bloc"" align=""right""><INPUT TYPE=""SUBMIT"" SIZE=""20"" NAME=""SAVE"" VALUE=""Enregistre"" class=""valider""></TD>"
.write "</TR>"
.write "</FORM>"
.write "</TABLE>"
End With
End Function
'Déclaration des variables
Dim action
Dim id
Dim libelle
Dim detail
' test si session toujours valide
if clng(nz(session("id_user"),0))=0 then
response.redirect "default.asp"
end if
' Récupération des parametres
id = clng(nz(xrequest_numeric("id_Cat"),0))
action = clng(nz(xrequest_numeric("action"),0))
If id = 0 then
If action <> 0 then ' cas d'un nouvel enregistrement
Call Insert_Cat
End If
Else
If Action <> 0 then
Call Update_Cat() ' Cas d'une modification
Else
Call Get_Infos() ' cas d'une édition
End If
End If
%>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="../Style/bocmg.css" type="text/css">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<table width="700" border="0">
<tr VALIGN="TOP">
<td width="150" align="center" class="titre_tableau"><% Call Bloc_Session() %></td>
<td width="480" align="center" class="titre_tableau"></td>
<td rowspan="2" VALIGN="TOP" width="150"><!-- #include file="../Include/Menu_D.asp" --></td>
</tr>
<tr VALIGN="TOP">
<td width="150"><!-- #include file="../Include/Menu_G.asp" --></td>
<td width="480" align=""top""><div class=""contenu><% call Affiche_Cat() %></div></td>
</tr>
<tr>
<TD ALIGN="CENTER" COLSPAN="3"><!-- #include file="../Include/Footer.asp" --></TD>
</tr>
</table>
</body>
</html> |
Partager