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
|
<% ' Date de création: 10/01/2006 %>
<html>
<body>
<!--#include file="fonctions.asp"-->
<%
On Error Resume Next
err=0
'Test les champs obligatoires
'----------------------------
if trim(request("nom_inter"))="" OR trim(request("pnom_inter"))="" OR trim(request("tel_inter"))="" OR trim(request("nom_invit"))="" OR trim(request("date_rep"))="" OR trim(request("nb_couv_prev"))="" OR trim(request("salon"))="selectionnez" OR trim(request("type_rep"))="selectionnez" then
call AfficheMessage("Erreur utilisateur","Attention les champs en rouges sont obligatoires !","","")
response.end
end if
'Chargement des objets ADO
'-------------------------
set conn=Server.createObject("ADODB.Connection")
set res=Server.createObject("ADODB.Recordset")
set invit=Server.createObject("ADODB.Recordset")
set inter=Server.createObject("ADODB.Recordset")
set typrep=Server.createObject("ADODB.Recordset")
set effectuer=Server.createObject("ADODB.Recordset")
set organisme=Server.createObject("ADODB.Recordset")
set Lesalon=Server.createObject("ADODB.Recordset")
'Ouverture de la connexion
'-------------------------
conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; " & "DBQ=" & Server.mappath(".") & "/RepasMutuel.mdb"
if err<>0 then
Call AfficheMessage("Erreur Open Connection",err.description,"creer_reservation","")
response.end
end if
'Initialisation de la requête
'----------------------------
res.Open "SELECT * FROM _RESERVATION",conn,adOpenKeyset,adLockOptimistic
invit.Open "SELECT * FROM _INVITANT",conn,adOpenKeyset,adLockOptimistic
inter.Open "SELECT * FROM _INTERMEDIAIRE",conn,adOpenKeyset,adLockOptimistic
typrep.Open "SELECT * FROM _TYPE_REPAS",conn,adOpenKeyset,adLockOptimistic
effectuer.Open "SELECT * FROM _EFFECTUER",conn,adOpenKeyset,adLockOptimistic
organisme.Open "SELECT * FROM _ORGANISME",conn,adOpenKeyset,adLockOptimistic
Lesalon.Open "SELECT * FROM _SALON",conn,adOpenKeyset,adLockOptimistic
Lesalon.movefirst
numsal=0
do while Lesalon.eof<>false and trim(request("salon"))<>"Autre"
if Lesalon.Fields("LIB")=trim(request("salon")) then
numsal=Lesalon.Fields("ID_SALON")
Lesalon.movelast
Else
Lesalon.movenext
End if
loop
nom_sal=trim(request("salon"))
If trim(request("salon"))="Autre" then
SQL="INSERT INTO _SALON(LIB) VALUES (nom_sal)"
conn.Execute(SQL)
Lesalon.movelast
numsal=Lesalon.Fields("ID_SALON")
End if
organisme.movefirst
numorg=0
nom_org=trim(request("org"))
if trim(request("org"))="" then
numorg=""
Else
do While not organisme.eof
if organisme.Fields("LIB")=trim(request("org")) then
numorg=organisme.Fields("ID_SALON")
organisme.movelast
Else
organisme.movenext
End if
loop
if numorg=0 then
SQL="INSERT INTO _ORGANISME(LIB) VALUES(nom_org)"
conn.Execute(SQL)
organisme.movelast
numorg=organisme.Fields("ID_ORGANISME")
End if
end if
typrep.movefirst
numrep=0
do While not typrep.eof
if typrep.Fields("LIB")=trim(request("type_rep")) then
numrep=typrep.Fields("ID_TYPE_REPAS")
typrep.movelast
Else
typrep.movenext
End if
loop
invit.movefirst
numinvit=0
nom_invit=trim(request("nom_invit"))
code_budgetaire=trim(request("code_budg"))
do While not invit.eof
if invit.Fields("NOM")=trim(request("nom_invit")) then
numinvit=invit.Fields("ID_INVITANT")
invit.movelast
Else
invit.movenext
End if
loop
If numinvit=0 then
SQL="INSERT INTO _INVITANT(NOM,REF_ORGANISME,CODE_BUDGETAIRE) VALUES(nom_invit,numorg,code_budgetaire)"
conn.Execute(SQL)
invit.movelast
numinvit=invit.Fields("ID_INVITANT")
End if
inter.movefirst
numinter=0
nom_intermed=trim(request("nom_inter"))
pnom_intermed=trim(request("pnom_inter"))
tel_intermed=trim(request("tel_inter"))
do While not inter.eof
if inter.Fields("NOM")=trim(request("nom_inter")) and inter.Fields("PNOM")=trim(request("pnom_inter")) and inter.Fields("TEL")=trim(request("tel_inter")) then
numinter=inter.Fields("ID_INTERMEDIAIRE")
inter.movelast
Else
inter.movenext
End if
loop
If numinter=0 then
SQL="INSERT INTO _INTERMEDIAIRE(NOM,PNOM,TEL,REF_INVITANT) VALUES(nom_inter,pnom_inter,tel_inter,numinvit)"
conn.Execute(SQL)
inter.movelast
numinter=inter.Fields("ID_INTERMEDAIRE")
End if
'res.Addnew
numres=0
date_repas=trim(request("date_rep"))
heure_repas=trim(request("heure_rep"))
nb_couverts_prevus=trim(request("nb_couv_prev"))
date_reservation=Date()
SQL="INSERT INTO _RESERVATION(REF_TYPE_REP,REF_SALON,DATE_RES,DATE_REP,HEURE_REP,NB_COUVERTS_PREV) VALUES (numrep,numsal,date_reservation,date_repas,heure_repas,nb_couverts_prevus)"
conn.Execute(SQL)
res.movelast
numres=res("ID_RESERVATION")
SQL="INSERT INTO _EFFECTUER(REF_RESERVATION,REF_INTERMEDIAIRE) VALUES(numres,numinter)"
conn.Execute(SQL)
res.Update
res.close
set res=nothing
effectuer.Update
effectuer.close
set effectuer=nothing
typrep.Update
typrep.close
set typrep=nothing
Lesalon.Update
Lesalon.close
set Lesalon=nothing
invit.Update
invit.close
set invit=nothing
inter.Update
inter.close
set inter=nothing
org.Update
org.close
set org=nothing
conn.close
set conn=nothing
' Message de bon déroulement
'---------------------------
Call AfficheMessage("Enregistrement réservation","La réservation a bien été enregistrer.","","N'oubliez pas de confirmer votre réservation au maximum un jour avant la date du repas. Votre numéro de réservation est " & numres & ". Veillez à garder ce numéro il vous sera demandé lors de votre confirmation.")
%>
</body>
</html> |
Partager