<% ' ' Filename: eb_clients.asp ' Generated with CodeCharge 2.0.5 ' ASP 2.0.ccp build 01/22/2002 ' '------------------------------- ' eb_clients CustomIncludes begin %> <% ' eb_clients CustomIncludes end '------------------------------- '=============================== ' Save Page and File Name available into variables '------------------------------- sFileName = "eb_clients.asp" '=============================== '=============================== ' eb_clients PageSecurity begin CheckSecurity(1) ' eb_clients PageSecurity end '=============================== '=============================== ' eb_clients Open Event start ' eb_clients Open Event end '=============================== '=============================== ' eb_clients OpenAnyPage Event start ' eb_clients OpenAnyPage Event end '=============================== '=============================== ' Save the name of the form and type of action into the variables '------------------------------- sAction = GetParam("FormAction") sForm = GetParam("FormName") '=============================== ' eb_clients Show begin '=============================== ' Page execution '------------------------------- 'Initialize error variables '------------------------------- seb_clients1Err = "" '------------------------------- ' Select the FormAction '------------------------------- Select Case sForm Case "eb_clients1" eb_clients1Action(sAction) end select '=============================== '=============================== ' HTML Page layout '------------------------------- %> EB Customers 1.09
<% MenuGeneral_Show %>
<% Search_Show %>
<% 'eb_clients1_Show %>
<% eb_clients_Show %>
<% ' eb_clients Show end ' eb_clients Close Event start ' eb_clients Close Event end '------------------------------- ' Destroy connection object '------------------------------- cn.close Set cn = nothing '=============================== '******************************************************************************** '=============================== ' Display Search Form '------------------------------- Sub Search_Show() Dim sFormTitle: sFormTitle = "Search" Dim action_page: action_page = "eb_clients.asp" '------------------------------- ' Search Open Event start ' Search Open Event end '------------------------------- '------------------------------- ' Set variables with search parameters '------------------------------- flds_FriendName = GetParam("s_FriendName") '------------------------------- ' Search Show begin '------------------------------- '------------------------------- ' Search Show Event start ' Search Show Event end '------------------------------- %>
<%=sFormTitle%>
Name or City
<% '------------------------------- ' Search Show end '------------------------------- '------------------------------- ' Search Close Event start ' Search Close Event end '------------------------------- end sub '=============================== '=============================== ' Display Grid Form '------------------------------- Sub eb_clients_Show() '------------------------------- ' Initialize variables '------------------------------- Dim rs Dim sWhere : sWhere = "" Dim sOrder : sOrder = "" Dim sSQL : sSQL = "" Dim sFormTitle: sFormTitle = "List" 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 = 200 Dim iCounter : iCounter = 0 Dim iPage : iPage = 0 Dim bEof : bEof = False Dim sActionFileName : sActionFileName = "eb_clients.asp" Dim transit_params : transit_params = "s_FriendName=" & ToURL(GetParam("s_FriendName")) & "&" Dim form_params : form_params = "s_FriendName=" & ToURL(GetParam("s_FriendName")) & "&" '------------------------------- ' Build ORDER BY statement '------------------------------- sOrder = " order by e.FriendName Asc" iSort = GetParam("Formeb_clients_Sorting") iSorted = GetParam("Formeb_clients_Sorted") sDirection = "" if IsEmpty(iSort) then form_sorting = "" else if iSort = iSorted then form_sorting = "" sDirection = " DESC" sSortParams = "Formeb_clients_Sorting=" & iSort & "&Formeb_clients_Sorted=" & iSort & "&" else form_sorting = iSort sDirection = " ASC" sSortParams = "Formeb_clients_Sorting=" & iSort & "&Formeb_clients_Sorted=" & "&" end if if iSort = 1 then sOrder = " order by e.FriendName" & sDirection if iSort = 2 then sOrder = " order by e.Name" & sDirection if iSort = 3 then sOrder = " order by e.Street" & sDirection if iSort = 4 then sOrder = " order by e.City" & sDirection if iSort = 5 then sOrder = " order by e.PostCode" & sDirection if iSort = 6 then sOrder = " order by e.Country" & sDirection if iSort = 7 then sOrder = " order by e.TelGeneral" & sDirection if iSort = 8 then sOrder = " order by t.Name" & sDirection end if '------------------------------- ' HTML column headers '------------------------------- %> <% '------------------------------- ' Build WHERE statement '------------------------------- ps_FriendName = GetParam("s_FriendName") if not isEmpty(ps_FriendName) then HasParam = true sWhere = "e.FriendName like '%" & replace(ps_FriendName, "'", "''") & "%'" & " or " & "e.City like '%" & replace(ps_FriendName, "'", "''") & "%'" & " or " & "e.Name like '%" & replace(ps_FriendName, "'", "''") & "%'" end if if HasParam then sWhere = " AND (" & sWhere & ")" end if '------------------------------- ' Build base SQL statement '------------------------------- sSQL = "select e.City as e_City, " & _ "e.Country as e_Country, " & _ "e.FriendName as e_FriendName, " & _ "e.Name as e_Name, " & _ "e.PostCode as e_PostCode, " & _ "e.Street as e_Street, " & _ "e.TelGeneral as e_TelGeneral, " & _ "e.id as e_id, " & _ "e.idTypeClient as e_idTypeClient, " & _ "t.id as t_id, " & _ "t.Name as t_Name " & _ " from eb_clients e, typeclient t" & _ " where t.id=e.idTypeClient " '------------------------------- '------------------------------- ' eb_clients Open Event start ' eb_clients 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 = 200 iCounter = 0 '------------------------------- ' Process page scroller '------------------------------- iPage = GetParam("Formeb_clients_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 '------------------------------- fldField1_URLLink = "relclicontact.asp" fldField1_idCli = GetValue(rs, "e_id") fldField2_URLLink = "relcliinstall.asp" fldField2_idCli = GetValue(rs, "e_id") fldCity = GetValue(rs, "e_City") fldCountry = GetValue(rs, "e_Country") fldFriendName_URLLink = "eb_clients.asp" fldFriendName_id = GetValue(rs, "e_id") fldFriendName = GetValue(rs, "e_FriendName") fldid = GetValue(rs, "e_id") fldidTypeClient = GetValue(rs, "t_Name") fldName = GetValue(rs, "e_Name") fldPostCode = GetValue(rs, "e_PostCode") fldStreet = GetValue(rs, "e_Street") fldTelGeneral = GetValue(rs, "e_TelGeneral") fldField1= "Contact" fldField2= "Install" '------------------------------- ' eb_clients Show begin '------------------------------- '------------------------------- ' eb_clients Show Event start ' eb_clients Show Event end '------------------------------- '------------------------------- ' Process the HTML controls '------------------------------- %> <% '------------------------------- ' eb_clients 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%>
FriendName Name Street City PostCode Country TelGeneral TypeClient
No records
<%=fldFriendName%>  <%=ToHTML(fldName)%>  <%=ToHTML(fldStreet)%>  <%=ToHTML(fldCity)%>  <%=ToHTML(fldPostCode)%>  <%=ToHTML(fldCountry)%>  <%=ToHTML(fldTelGeneral)%>  <%=ToHTML(fldidTypeClient)%> 
Insert       <% '------------------------------- ' eb_clients 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 '------------------------------- ' eb_clients Navigation end '------------------------------- '------------------------------- ' Finish form processing '------------------------------- set rs = nothing %>
<% '------------------------------- ' eb_clients Close Event start ' eb_clients Close Event end '------------------------------- end sub '=============================== '=============================== ' Action of the Record Form '------------------------------- Sub eb_clients1Action(sAction) '------------------------------- ' Initialize variables '------------------------------- Dim bExecSQL: bExecSQL = true Dim sActionFileName : sActionFileName = "" Dim sWhere : sWhere = "" Dim bErr : bErr = False Dim pPKid : pPKid = "" Dim fldName : fldName = "" Dim fldFriendName : fldFriendName = "" Dim fldStreet : fldStreet = "" Dim fldCity : fldCity = "" Dim fldPostCode : fldPostCode = "" Dim fldCountry : fldCountry = "" Dim fldTelGeneral : fldTelGeneral = "" Dim fldidTypeClient : fldidTypeClient = "" '------------------------------- '------------------------------- ' eb_clients1 Action begin '------------------------------- sActionFileName = "eb_clients.asp" '------------------------------- ' CANCEL action '------------------------------- if sAction = "cancel" then '------------------------------- ' eb_clients1 BeforeCancel Event start ' eb_clients1 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") fldFriendName = GetParam("FriendName") fldStreet = GetParam("Street") fldCity = GetParam("City") fldPostCode = GetParam("PostCode") fldCountry = GetParam("Country") fldTelGeneral = GetParam("TelGeneral") fldidTypeClient = GetParam("idTypeClient") '------------------------------- ' Validate fields '------------------------------- if sAction = "insert" or sAction = "update" then if IsEmpty(fldidTypeClient) then seb_clients1Err = seb_clients1Err & "The value in field TypeClient is required.
" end if if not isNumeric(fldidTypeClient) then seb_clients1Err = seb_clients1Err & "The value in field TypeClient is incorrect.
" end if '------------------------------- ' eb_clients1 Check Event start ' eb_clients1 Check Event end '------------------------------- If len(seb_clients1Err) > 0 then exit sub end if end if '------------------------------- '------------------------------- ' Create SQL statement '------------------------------- select case sAction case "insert" '------------------------------- ' eb_clients1 Insert Event start ' eb_clients1 Insert Event end '------------------------------- sSQL = "insert into eb_clients (" & _ "Name," & _ "FriendName," & _ "Street," & _ "City," & _ "PostCode," & _ "Country," & _ "TelGeneral," & _ "idTypeClient)" & _ " values (" & _ ToSQL(fldName, "Text") & "," & _ ToSQL(fldFriendName, "Text") & "," & _ ToSQL(fldStreet, "Text") & "," & _ ToSQL(fldCity, "Text") & "," & _ ToSQL(fldPostCode, "Text") & "," & _ ToSQL(fldCountry, "Text") & "," & _ ToSQL(fldTelGeneral, "Text") & "," & _ ToSQL(fldidTypeClient, "Number") & _ ")" case "update" '------------------------------- ' eb_clients1 Update Event start ' eb_clients1 Update Event end '------------------------------- sSQL = "update eb_clients set " & _ "Name=" & ToSQL(fldName, "Text") & _ ",FriendName=" & ToSQL(fldFriendName, "Text") & _ ",Street=" & ToSQL(fldStreet, "Text") & _ ",City=" & ToSQL(fldCity, "Text") & _ ",PostCode=" & ToSQL(fldPostCode, "Text") & _ ",Country=" & ToSQL(fldCountry, "Text") & _ ",TelGeneral=" & ToSQL(fldTelGeneral, "Text") & _ ",idTypeClient=" & ToSQL(fldidTypeClient, "Number") sSQL = sSQL & " where " & sWhere case "delete" '------------------------------- ' eb_clients1 Delete Event start ' eb_clients1 Delete Event end '------------------------------- sSQL = "delete from eb_clients where " & sWhere end select '------------------------------- '------------------------------- ' eb_clients1 BeforeExecute Event start ' eb_clients1 BeforeExecute Event end '------------------------------- '------------------------------- ' Execute SQL statement '------------------------------- if len(seb_clients1Err) > 0 then Exit Sub on error resume next if bExecSQL then cn.execute sSQL end if seb_clients1Err = ProcessError on error goto 0 if len(seb_clients1Err) > 0 then Exit Sub cn.Close Set cn = Nothing response.redirect sActionFileName '------------------------------- ' eb_clients1 Action end '------------------------------- end sub '=============================== '=============================== ' Display Record Form '------------------------------- Sub eb_clients1_Show() '------------------------------- ' eb_clients1 Show begin '------------------------------- sWhere = "" Dim sFormTitle: sFormTitle = "Insert / Modify" bPK = true %> <% if not (seb_clients1Err = "") then %> <% end if %> <% '------------------------------- ' Load primary key and form parameters '------------------------------- if seb_clients1Err = "" then fldid = GetParam("id") pid = GetParam("id") else fldid = GetParam("id") fldName = GetParam("Name") fldFriendName = GetParam("FriendName") fldStreet = GetParam("Street") fldCity = GetParam("City") fldPostCode = GetParam("PostCode") fldCountry = GetParam("Country") fldTelGeneral = GetParam("TelGeneral") fldidTypeClient = GetParam("idTypeClient") 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 '------------------------------- '------------------------------- ' eb_clients1 Open Event start ' eb_clients1 Open Event end '------------------------------- '------------------------------- ' Build SQL statement and open recordset '------------------------------- sSQL = "select * from eb_clients where " & sWhere openrs rs, sSQL bIsUpdateMode = (bPK and not(sAction = "insert" and sForm = "eb_clients1") 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 seb_clients1Err = "" then fldName = GetValue(rs, "Name") fldFriendName = GetValue(rs, "FriendName") fldStreet = GetValue(rs, "Street") fldCity = GetValue(rs, "City") fldPostCode = GetValue(rs, "PostCode") fldCountry = GetValue(rs, "Country") fldTelGeneral = GetValue(rs, "TelGeneral") fldidTypeClient = GetValue(rs, "idTypeClient") end if '------------------------------- ' eb_clients1 ShowEdit Event start ' eb_clients1 ShowEdit Event end '------------------------------- else if seb_clients1Err = "" then fldid = ToHTML(GetParam("id")) end if '------------------------------- ' eb_clients1 ShowInsert Event start ' eb_clients1 ShowInsert Event end '------------------------------- end if '------------------------------- ' eb_clients1 Show Event start ' eb_clients1 Show Event end '------------------------------- '------------------------------- ' Show form fields '------------------------------- %>
<%=sFormTitle%>
<%= seb_clients1Err %>
Name
FriendName
Street
City
PostCode
Country
TelGeneral
TypeClient
<% if not bIsUpdateMode then %> <% end if %> <% if bIsUpdateMode then %> <% end if %>
<% '------------------------------- ' eb_clients1 Close Event start ' eb_clients1 Close Event end '------------------------------- Set rs = Nothing '------------------------------- ' eb_clients1 Show end '------------------------------- End Sub '=============================== %>