<% ' ' Filename: typedb.asp ' Generated with CodeCharge 2.0.5 ' ASP 2.0.ccp build 01/22/2002 ' '------------------------------- ' typedb CustomIncludes begin %> <% ' typedb CustomIncludes end '------------------------------- '=============================== ' Save Page and File Name available into variables '------------------------------- sFileName = "typedb.asp" '=============================== '=============================== ' typedb PageSecurity begin CheckSecurity(1) ' typedb PageSecurity end '=============================== '=============================== ' typedb Open Event start ' typedb Open Event end '=============================== '=============================== ' typedb OpenAnyPage Event start ' typedb OpenAnyPage Event end '=============================== '=============================== ' Save the name of the form and type of action into the variables '------------------------------- sAction = GetParam("FormAction") sForm = GetParam("FormName") '=============================== ' typedb Show begin '=============================== ' Page execution '------------------------------- 'Initialize error variables '------------------------------- stypedb1Err = "" '------------------------------- ' Select the FormAction '------------------------------- Select Case sForm Case "typedb1" typedb1Action(sAction) end select '=============================== '=============================== ' HTML Page layout '------------------------------- %> EB Customers 1.09
<% MenuGeneral2_Show %>
<% MenuGeneral_Show %>
<% typedb_Show %>
<% typedb1_Show %>
<% ' typedb Show end ' typedb Close Event start ' typedb Close Event end '------------------------------- ' Destroy connection object '------------------------------- cn.close Set cn = nothing '=============================== '******************************************************************************** '=============================== ' Display Grid Form '------------------------------- Sub typedb_Show() '------------------------------- ' Initialize variables '------------------------------- Dim rs Dim sWhere : sWhere = "" Dim sOrder : sOrder = "" Dim sSQL : sSQL = "" Dim sFormTitle: sFormTitle = "Type DB" 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 = "typedb.asp" Dim transit_params : transit_params = "" Dim form_params : form_params = "" '------------------------------- ' Build ORDER BY statement '------------------------------- sOrder = " order by t.Name Asc" iSort = GetParam("Formtypedb_Sorting") iSorted = GetParam("Formtypedb_Sorted") sDirection = "" if IsEmpty(iSort) then form_sorting = "" else if iSort = iSorted then form_sorting = "" sDirection = " DESC" sSortParams = "Formtypedb_Sorting=" & iSort & "&Formtypedb_Sorted=" & iSort & "&" else form_sorting = iSort sDirection = " ASC" sSortParams = "Formtypedb_Sorting=" & iSort & "&Formtypedb_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 typedb t " '------------------------------- '------------------------------- ' typedb Open Event start ' typedb 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("Formtypedb_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 = "typedb.asp" fldName_id = GetValue(rs, "t_id") fldName = GetValue(rs, "t_Name") '------------------------------- ' typedb Show begin '------------------------------- '------------------------------- ' typedb Show Event start ' typedb Show Event end '------------------------------- '------------------------------- ' Process the HTML controls '------------------------------- %> <% '------------------------------- ' typedb 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       <% '------------------------------- ' typedb 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 '------------------------------- ' typedb Navigation end '------------------------------- '------------------------------- ' Finish form processing '------------------------------- set rs = nothing %>
<% '------------------------------- ' typedb Close Event start ' typedb Close Event end '------------------------------- end sub '=============================== '=============================== ' Action of the Record Form '------------------------------- Sub typedb1Action(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 = "" '------------------------------- '------------------------------- ' typedb1 Action begin '------------------------------- sActionFileName = "typedb.asp" '------------------------------- ' CANCEL action '------------------------------- if sAction = "cancel" then '------------------------------- ' typedb1 BeforeCancel Event start ' typedb1 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 stypedb1Err = stypedb1Err & "The value in field Name is required.
" end if '------------------------------- ' typedb1 Check Event start ' typedb1 Check Event end '------------------------------- If len(stypedb1Err) > 0 then exit sub end if end if '------------------------------- '------------------------------- ' Create SQL statement '------------------------------- select case sAction case "insert" '------------------------------- ' typedb1 Insert Event start ' typedb1 Insert Event end '------------------------------- sSQL = "insert into typedb (" & _ "Name," & _ "Description)" & _ " values (" & _ ToSQL(fldName, "Text") & "," & _ ToSQL(fldDescription, "Text") & _ ")" case "update" '------------------------------- ' typedb1 Update Event start ' typedb1 Update Event end '------------------------------- sSQL = "update typedb set " & _ "Name=" & ToSQL(fldName, "Text") & _ ",Description=" & ToSQL(fldDescription, "Text") sSQL = sSQL & " where " & sWhere case "delete" '------------------------------- ' typedb1 Delete Event start ' typedb1 Delete Event end '------------------------------- sSQL = "delete from typedb where " & sWhere end select '------------------------------- '------------------------------- ' typedb1 BeforeExecute Event start ' typedb1 BeforeExecute Event end '------------------------------- '------------------------------- ' Execute SQL statement '------------------------------- if len(stypedb1Err) > 0 then Exit Sub on error resume next if bExecSQL then cn.execute sSQL end if stypedb1Err = ProcessError on error goto 0 if len(stypedb1Err) > 0 then Exit Sub cn.Close Set cn = Nothing response.redirect sActionFileName '------------------------------- ' typedb1 Action end '------------------------------- end sub '=============================== '=============================== ' Display Record Form '------------------------------- Sub typedb1_Show() '------------------------------- ' typedb1 Show begin '------------------------------- sWhere = "" Dim sFormTitle: sFormTitle = "Modifier" bPK = true %> <% if not (stypedb1Err = "") then %> <% end if %> <% '------------------------------- ' Load primary key and form parameters '------------------------------- if stypedb1Err = "" 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 '------------------------------- '------------------------------- ' typedb1 Open Event start ' typedb1 Open Event end '------------------------------- '------------------------------- ' Build SQL statement and open recordset '------------------------------- sSQL = "select * from typedb where " & sWhere openrs rs, sSQL bIsUpdateMode = (bPK and not(sAction = "insert" and sForm = "typedb1") 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 stypedb1Err = "" then fldName = GetValue(rs, "Name") fldDescription = GetValue(rs, "Description") end if '------------------------------- ' typedb1 ShowEdit Event start ' typedb1 ShowEdit Event end '------------------------------- else if stypedb1Err = "" then fldid = ToHTML(GetParam("id")) end if '------------------------------- ' typedb1 ShowInsert Event start ' typedb1 ShowInsert Event end '------------------------------- end if '------------------------------- ' typedb1 Show Event start ' typedb1 Show Event end '------------------------------- '------------------------------- ' Show form fields '------------------------------- %>
<%=sFormTitle%>
<%= stypedb1Err %>
Name
Description
<% if not bIsUpdateMode then %> <% end if %> <% if bIsUpdateMode then %> <% end if %>
<% '------------------------------- ' typedb1 Close Event start ' typedb1 Close Event end '------------------------------- Set rs = Nothing '------------------------------- ' typedb1 Show end '------------------------------- End Sub '=============================== %>