<% ' ' Filename: typechargement.asp ' Generated with CodeCharge 2.0.5 ' ASP 2.0.ccp build 01/22/2002 ' '------------------------------- ' typechargement CustomIncludes begin %> <% ' typechargement CustomIncludes end '------------------------------- '=============================== ' Save Page and File Name available into variables '------------------------------- sFileName = "typechargement.asp" '=============================== '=============================== ' typechargement PageSecurity begin CheckSecurity(1) ' typechargement PageSecurity end '=============================== '=============================== ' typechargement Open Event start ' typechargement Open Event end '=============================== '=============================== ' typechargement OpenAnyPage Event start ' typechargement OpenAnyPage Event end '=============================== '=============================== ' Save the name of the form and type of action into the variables '------------------------------- sAction = GetParam("FormAction") sForm = GetParam("FormName") '=============================== ' typechargement Show begin '=============================== ' Page execution '------------------------------- 'Initialize error variables '------------------------------- stypechargement1Err = "" '------------------------------- ' Select the FormAction '------------------------------- Select Case sForm Case "typechargement1" typechargement1Action(sAction) end select '=============================== '=============================== ' HTML Page layout '------------------------------- %> EB Customers 1.09
<% MenuGeneral2_Show %>
<% MenuGeneral_Show %>
<% typechargement_Show %>
<% typechargement1_Show %>
<% ' typechargement Show end ' typechargement Close Event start ' typechargement Close Event end '------------------------------- ' Destroy connection object '------------------------------- cn.close Set cn = nothing '=============================== '******************************************************************************** '=============================== ' Display Grid Form '------------------------------- Sub typechargement_Show() '------------------------------- ' Initialize variables '------------------------------- Dim rs Dim sWhere : sWhere = "" Dim sOrder : sOrder = "" Dim sSQL : sSQL = "" Dim sFormTitle: sFormTitle = "type chargements" Dim HasParam : HasParam = false Dim iSort : iSort = "" Dim iSorted : iSorted = "" Dim sDirection : sDirection = "" Dim form_sorting : form_sorting = "" Dim sSortParams : sSortParams = "" Dim form_action : form_action = "" Dim iRecordsPerPage : iRecordsPerPage = 20 Dim iCounter : iCounter = 0 Dim iPage : iPage = 0 Dim bEof : bEof = False Dim sActionFileName : sActionFileName = "typechargement.asp" Dim transit_params : transit_params = "" Dim form_params : form_params = "" '------------------------------- ' Build ORDER BY statement '------------------------------- sOrder = " order by t.Name Asc" iSort = GetParam("Formtypechargement_Sorting") iSorted = GetParam("Formtypechargement_Sorted") sDirection = "" if IsEmpty(iSort) then form_sorting = "" else if iSort = iSorted then form_sorting = "" sDirection = " DESC" sSortParams = "Formtypechargement_Sorting=" & iSort & "&Formtypechargement_Sorted=" & iSort & "&" else form_sorting = iSort sDirection = " ASC" sSortParams = "Formtypechargement_Sorting=" & iSort & "&Formtypechargement_Sorted=" & "&" end if if iSort = 1 then sOrder = " order by t.Name" & sDirection if iSort = 2 then sOrder = " order by t.Description" & sDirection end if '------------------------------- ' HTML column headers '------------------------------- %> <% '------------------------------- ' Build base SQL statement '------------------------------- sSQL = "select t.Description as t_Description, " & _ "t.Name as t_Name, " & _ "t.id as t_id " & _ " from typechargement t " '------------------------------- '------------------------------- ' typechargement Open Event start ' typechargement Open Event end '------------------------------- '------------------------------- ' Assemble full SQL statement '------------------------------- sSQL = sSQL & sWhere & sOrder '------------------------------- '------------------------------- ' Process the link to the record page '------------------------------- form_action = sActionFileName '------------------------------- '------------------------------- ' Open the recordset '------------------------------- openrs rs, sSQL '------------------------------- '------------------------------- ' Process empty recordset '------------------------------- if rs.eof then %> <% end if '------------------------------- '------------------------------- 'Initialize page counter and records per page '------------------------------- iRecordsPerPage = 20 iCounter = 0 '------------------------------- ' Process page scroller '------------------------------- iPage = GetParam("Formtypechargement_Page") if IsEmpty(iPage) then iPage = 1 else iPage = CLng(iPage) while not rs.eof and iCounter < (iPage-1)*iRecordsPerPage rs.movenext iCounter = iCounter + 1 wend iCounter = 0 '------------------------------- '------------------------------- ' Display grid based on recordset '------------------------------- while not rs.EOF and iCounter < iRecordsPerPage '------------------------------- ' Create field variables based on database fields '------------------------------- fldDescription = GetValue(rs, "t_Description") fldid = GetValue(rs, "t_id") fldName_URLLink = "typechargement.asp" fldName_id = GetValue(rs, "t_id") fldName = GetValue(rs, "t_Name") '------------------------------- ' typechargement Show begin '------------------------------- '------------------------------- ' typechargement Show Event start ' typechargement Show Event end '------------------------------- '------------------------------- ' Process the HTML controls '------------------------------- %> <% '------------------------------- ' typechargement Show end '------------------------------- '------------------------------- ' Move to the next record and increase record counter '------------------------------- rs.MoveNext iCounter = iCounter + 1 wend '------------------------------- '------------------------------- ' Process the bottom on the Grid. The insert link and record navigator. '------------------------------- %>
<%=sFormTitle%>
Name Description
No records
<%=fldName%>  <%=ToHTML(fldDescription)%> 
Insert       <% '------------------------------- ' typechargement Navigation begin '------------------------------- bEof = rs.eof if not(rs.EOF and iPage=1) then if iPage = 1 then %> Previous <% else %> Previous <% end if response.write " [ " & iPage & " ] " if bEof then %> Next <% else %> Next <% end if end if '------------------------------- ' typechargement Navigation end '------------------------------- '------------------------------- ' Finish form processing '------------------------------- set rs = nothing %>
<% '------------------------------- ' typechargement Close Event start ' typechargement Close Event end '------------------------------- end sub '=============================== '=============================== ' Action of the Record Form '------------------------------- Sub typechargement1Action(sAction) '------------------------------- ' Initialize variables '------------------------------- Dim bExecSQL: bExecSQL = true Dim sActionFileName : sActionFileName = "" Dim sWhere : sWhere = "" Dim bErr : bErr = False Dim pPKid : pPKid = "" Dim fldName : fldName = "" Dim fldDescription : fldDescription = "" '------------------------------- '------------------------------- ' typechargement1 Action begin '------------------------------- sActionFileName = "typechargement.asp" '------------------------------- ' CANCEL action '------------------------------- if sAction = "cancel" then '------------------------------- ' typechargement1 BeforeCancel Event start ' typechargement1 BeforeCancel Event end '------------------------------- cn.Close Set cn = Nothing response.redirect sActionFileName end if '------------------------------- '------------------------------- ' Build WHERE statement '------------------------------- if sAction = "update" or sAction = "delete" then pPKid = GetParam("PK_id") if IsEmpty(pPKid) then exit sub sWhere = "id=" & ToSQL(pPKid, "Number") end if '------------------------------- '------------------------------- ' Load all form fields into variables '------------------------------- fldName = GetParam("Name") fldDescription = GetParam("Description") '------------------------------- ' Validate fields '------------------------------- if sAction = "insert" or sAction = "update" then if IsEmpty(fldName) then stypechargement1Err = stypechargement1Err & "The value in field Name is required.
" end if '------------------------------- ' typechargement1 Check Event start ' typechargement1 Check Event end '------------------------------- If len(stypechargement1Err) > 0 then exit sub end if end if '------------------------------- '------------------------------- ' Create SQL statement '------------------------------- select case sAction case "insert" '------------------------------- ' typechargement1 Insert Event start ' typechargement1 Insert Event end '------------------------------- sSQL = "insert into typechargement (" & _ "Name," & _ "Description)" & _ " values (" & _ ToSQL(fldName, "Text") & "," & _ ToSQL(fldDescription, "Text") & _ ")" case "update" '------------------------------- ' typechargement1 Update Event start ' typechargement1 Update Event end '------------------------------- sSQL = "update typechargement set " & _ "Name=" & ToSQL(fldName, "Text") & _ ",Description=" & ToSQL(fldDescription, "Text") sSQL = sSQL & " where " & sWhere case "delete" '------------------------------- ' typechargement1 Delete Event start ' typechargement1 Delete Event end '------------------------------- sSQL = "delete from typechargement where " & sWhere end select '------------------------------- '------------------------------- ' typechargement1 BeforeExecute Event start ' typechargement1 BeforeExecute Event end '------------------------------- '------------------------------- ' Execute SQL statement '------------------------------- if len(stypechargement1Err) > 0 then Exit Sub on error resume next if bExecSQL then cn.execute sSQL end if stypechargement1Err = ProcessError on error goto 0 if len(stypechargement1Err) > 0 then Exit Sub cn.Close Set cn = Nothing response.redirect sActionFileName '------------------------------- ' typechargement1 Action end '------------------------------- end sub '=============================== '=============================== ' Display Record Form '------------------------------- Sub typechargement1_Show() '------------------------------- ' typechargement1 Show begin '------------------------------- sWhere = "" Dim sFormTitle: sFormTitle = "Modifier" bPK = true %> <% if not (stypechargement1Err = "") then %> <% end if %> <% '------------------------------- ' Load primary key and form parameters '------------------------------- if stypechargement1Err = "" then fldid = GetParam("id") pid = GetParam("id") else fldid = GetParam("id") fldName = GetParam("Name") fldDescription = GetParam("Description") pid = GetParam("PK_id") end if '------------------------------- ' Load all form fields '------------------------------- '------------------------------- ' Build WHERE statement if IsEmpty(pid) then bPK = False sWhere = sWhere & "id=" & ToSQL(pid, "Number") PK_id = pid '------------------------------- '------------------------------- ' typechargement1 Open Event start ' typechargement1 Open Event end '------------------------------- '------------------------------- ' Build SQL statement and open recordset '------------------------------- sSQL = "select * from typechargement where " & sWhere openrs rs, sSQL bIsUpdateMode = (bPK and not(sAction = "insert" and sForm = "typechargement1") and not rs.eof) '------------------------------- '------------------------------- ' Load all fields into variables from recordset or input parameters '------------------------------- if bIsUpdateMode then fldid = GetValue(rs, "id") '------------------------------- ' Load data from recordset when form displayed first time '------------------------------- if stypechargement1Err = "" then fldName = GetValue(rs, "Name") fldDescription = GetValue(rs, "Description") end if '------------------------------- ' typechargement1 ShowEdit Event start ' typechargement1 ShowEdit Event end '------------------------------- else if stypechargement1Err = "" then fldid = ToHTML(GetParam("id")) end if '------------------------------- ' typechargement1 ShowInsert Event start ' typechargement1 ShowInsert Event end '------------------------------- end if '------------------------------- ' typechargement1 Show Event start ' typechargement1 Show Event end '------------------------------- '------------------------------- ' Show form fields '------------------------------- %>
<%=sFormTitle%>
<%= stypechargement1Err %>
Name
Description
<% if not bIsUpdateMode then %> <% end if %> <% if bIsUpdateMode then %> <% end if %>
<% '------------------------------- ' typechargement1 Close Event start ' typechargement1 Close Event end '------------------------------- Set rs = Nothing '------------------------------- ' typechargement1 Show end '------------------------------- End Sub '=============================== %>