<% ' ' Filename: comcliopenrec.asp ' Generated with CodeCharge 2.0.5 ' ASP 2.0.ccp build 01/22/2002 ' '------------------------------- ' comcliopenrec CustomIncludes begin %> <% ' comcliopenrec CustomIncludes end '------------------------------- '=============================== ' Save Page and File Name available into variables '------------------------------- sFileName = "comcliopenrec.asp" '=============================== '=============================== ' comcliopenrec PageSecurity begin ' comcliopenrec PageSecurity end '=============================== '=============================== ' comcliopenrec Open Event start ' comcliopenrec Open Event end '=============================== '=============================== ' comcliopenrec OpenAnyPage Event start ' comcliopenrec OpenAnyPage Event end '=============================== '=============================== ' Save the name of the form and type of action into the variables '------------------------------- sAction = GetParam("FormAction") sForm = GetParam("FormName") '=============================== ' comcliopenrec Show begin '=============================== ' Page execution '------------------------------- 'Initialize error variables '------------------------------- scommandescliErr = "" '------------------------------- ' Select the FormAction '------------------------------- Select Case sForm Case "commandescli" commandescliAction(sAction) end select '=============================== '=============================== ' HTML Page layout '------------------------------- %> Commandes clients
<% commandescli_Show %>
<% ' comcliopenrec Show end ' comcliopenrec Close Event start ' comcliopenrec Close Event end '------------------------------- ' Destroy connection object '------------------------------- cn.close Set cn = nothing '=============================== '******************************************************************************** '=============================== ' Action of the Record Form '------------------------------- Sub commandescliAction(sAction) '------------------------------- ' Initialize variables '------------------------------- Dim bExecSQL: bExecSQL = true Dim sActionFileName : sActionFileName = "" Dim sWhere : sWhere = "" Dim bErr : bErr = False Dim pPKidCommande : pPKidCommande = "" Dim fldidCli : fldidCli = "" Dim fldDateCommande : fldDateCommande = "" Dim fldDescCommande : fldDescCommande = "" Dim fldidStatut : fldidStatut = "" '------------------------------- '------------------------------- ' commandescli Action begin '------------------------------- sActionFileName = "comcliopen.asp" '------------------------------- ' CANCEL action '------------------------------- if sAction = "cancel" then '------------------------------- ' commandescli BeforeCancel Event start ' commandescli BeforeCancel Event end '------------------------------- cn.Close Set cn = Nothing response.redirect sActionFileName end if '------------------------------- '------------------------------- ' Build WHERE statement '------------------------------- if sAction = "update" or sAction = "delete" then pPKidCommande = GetParam("PK_idCommande") if IsEmpty(pPKidCommande) then exit sub sWhere = "idCommande=" & ToSQL(pPKidCommande, "Number") end if '------------------------------- '------------------------------- ' Load all form fields into variables '------------------------------- fldidCli = GetParam("idCli") fldDateCommande = GetParam("DateCommande") fldDescCommande = GetParam("DescCommande") fldidStatut = GetParam("idStatut") '------------------------------- ' Validate fields '------------------------------- if sAction = "insert" or sAction = "update" then if IsEmpty(fldidCli) then scommandescliErr = scommandescliErr & "The value in field Client : is required.
" end if if IsEmpty(fldidStatut) then scommandescliErr = scommandescliErr & "The value in field Statut : is required.
" end if if not isNumeric(fldidCli) then scommandescliErr = scommandescliErr & "The value in field Client : is incorrect.
" end if if not isNumeric(fldidStatut) then scommandescliErr = scommandescliErr & "The value in field Statut : is incorrect.
" end if '------------------------------- ' commandescli Check Event start ' commandescli Check Event end '------------------------------- If len(scommandescliErr) > 0 then exit sub end if end if '------------------------------- '------------------------------- ' Create SQL statement '------------------------------- select case sAction case "insert" '------------------------------- ' commandescli Insert Event start ' commandescli Insert Event end '------------------------------- sSQL = "insert into commandescli (" & _ "idCli," & _ "DateCommande," & _ "DescCommande," & _ "idStatut)" & _ " values (" & _ ToSQL(fldidCli, "Number") & "," & _ ToSQL(fldDateCommande, "Text") & "," & _ ToSQL(fldDescCommande, "Memo") & "," & _ ToSQL(fldidStatut, "Number") & _ ")" case "update" '------------------------------- ' commandescli Update Event start ' commandescli Update Event end '------------------------------- sSQL = "update commandescli set " & _ "idCli=" & ToSQL(fldidCli, "Number") & _ ",DateCommande=" & ToSQL(fldDateCommande, "Text") & _ ",DescCommande=" & ToSQL(fldDescCommande, "Memo") & _ ",idStatut=" & ToSQL(fldidStatut, "Number") sSQL = sSQL & " where " & sWhere case "delete" '------------------------------- ' commandescli Delete Event start ' commandescli Delete Event end '------------------------------- sSQL = "delete from commandescli where " & sWhere end select '------------------------------- '------------------------------- ' commandescli BeforeExecute Event start ' commandescli BeforeExecute Event end '------------------------------- '------------------------------- ' Execute SQL statement '------------------------------- if len(scommandescliErr) > 0 then Exit Sub on error resume next if bExecSQL then cn.execute sSQL end if scommandescliErr = ProcessError on error goto 0 if len(scommandescliErr) > 0 then Exit Sub cn.Close Set cn = Nothing response.redirect sActionFileName '------------------------------- ' commandescli Action end '------------------------------- end sub '=============================== '=============================== ' Display Record Form '------------------------------- Sub commandescli_Show() '------------------------------- ' commandescli Show begin '------------------------------- sWhere = "" Dim sFormTitle: sFormTitle = "Insérer / Modifier" bPK = true %> <% if not (scommandescliErr = "") then %> <% end if %> <% '------------------------------- ' Load primary key and form parameters '------------------------------- if scommandescliErr = "" then fldidCommande = GetParam("idCommande") pidCommande = GetParam("idCommande") else fldidCommande = GetParam("idCommande") fldidCli = GetParam("idCli") fldDateCommande = GetParam("DateCommande") fldDescCommande = GetParam("DescCommande") fldidStatut = GetParam("idStatut") pidCommande = GetParam("PK_idCommande") end if '------------------------------- ' Load all form fields '------------------------------- '------------------------------- ' Build WHERE statement if IsEmpty(pidCommande) then bPK = False sWhere = sWhere & "idCommande=" & ToSQL(pidCommande, "Number") PK_idCommande = pidCommande '------------------------------- '------------------------------- ' commandescli Open Event start ' commandescli Open Event end '------------------------------- '------------------------------- ' Build SQL statement and open recordset '------------------------------- sSQL = "select * from commandescli where " & sWhere openStaticRS rs, sSQL bIsUpdateMode = (bPK and not(sAction = "insert" and sForm = "commandescli") and not rs.eof) '------------------------------- '------------------------------- ' Load all fields into variables from recordset or input parameters '------------------------------- if bIsUpdateMode then fldidCommande = GetValue(rs, "idCommande") '------------------------------- ' Load data from recordset when form displayed first time '------------------------------- if scommandescliErr = "" then fldidCli = GetValue(rs, "idCli") fldDateCommande = GetValue(rs, "DateCommande") fldDescCommande = GetValue(rs, "DescCommande") fldidStatut = GetValue(rs, "idStatut") end if '------------------------------- ' commandescli ShowEdit Event start ' commandescli ShowEdit Event end '------------------------------- else if scommandescliErr = "" then fldidCommande = ToHTML(GetParam("idCommande")) fldidStatut= "1" end if '------------------------------- ' commandescli ShowInsert Event start ' commandescli ShowInsert Event end '------------------------------- end if '------------------------------- ' commandescli Show Event start ' commandescli Show Event end '------------------------------- '------------------------------- ' Show form fields '------------------------------- %>
<%=sFormTitle%>
<%= scommandescliErr %>
Client :
Date :
Description :
Statut :
<% if not bIsUpdateMode then %> <% end if %> <% if bIsUpdateMode then %> <% end if %>
<% '------------------------------- ' commandescli Close Event start ' commandescli Close Event end '------------------------------- Set rs = Nothing '------------------------------- ' commandescli Show end '------------------------------- End Sub '=============================== %>