<% ' ' Filename: relclicontact.asp ' Generated with CodeCharge 2.0.5 ' ASP 2.0.ccp build 01/22/2002 ' '------------------------------- ' relclicontact CustomIncludes begin %> <% ' relclicontact CustomIncludes end '------------------------------- '=============================== ' Save Page and File Name available into variables '------------------------------- sFileName = "relclicontact.asp" '=============================== '=============================== ' relclicontact PageSecurity begin CheckSecurity(1) ' relclicontact PageSecurity end '=============================== '=============================== ' relclicontact Open Event start ' relclicontact Open Event end '=============================== '=============================== ' relclicontact OpenAnyPage Event start ' relclicontact OpenAnyPage Event end '=============================== '=============================== ' Save the name of the form and type of action into the variables '------------------------------- sAction = GetParam("FormAction") sForm = GetParam("FormName") '=============================== ' relclicontact Show begin '=============================== ' Page execution '------------------------------- 'Initialize error variables '------------------------------- srelclicontact1Err = "" '------------------------------- ' Select the FormAction '------------------------------- Select Case sForm Case "relclicontact1" relclicontact1Action(sAction) end select '=============================== '=============================== ' HTML Page layout '------------------------------- %> EB Customers 1.09
<% MenuGeneral2_Show %>
<% MenuGeneral_Show %>
<% relclicontact_Show %>
<% relclicontact1_Show %>
<% ' relclicontact Show end ' relclicontact Close Event start ' relclicontact Close Event end '------------------------------- ' Destroy connection object '------------------------------- cn.close Set cn = nothing '=============================== '******************************************************************************** '=============================== ' Display Grid Form '------------------------------- Sub relclicontact_Show() '------------------------------- ' Initialize variables '------------------------------- Dim rs Dim sWhere : sWhere = "" Dim sOrder : sOrder = "" Dim sSQL : sSQL = "" Dim sFormTitle: sFormTitle = "Contacts" Dim HasParam : HasParam = false Dim bReq : bReq = true 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 = 50 Dim iCounter : iCounter = 0 Dim iPage : iPage = 0 Dim bEof : bEof = False Dim sActionFileName : sActionFileName = "relclicontact.asp" Dim transit_params : transit_params = "idCli=" & ToURL(GetParam("idCli")) & "&" Dim form_params : form_params = "idCli=" & ToURL(GetParam("idCli")) & "&" '------------------------------- ' Build ORDER BY statement '------------------------------- sOrder = " order by r.LastName Asc" iSort = GetParam("Formrelclicontact_Sorting") iSorted = GetParam("Formrelclicontact_Sorted") sDirection = "" if IsEmpty(iSort) then form_sorting = "" else if iSort = iSorted then form_sorting = "" sDirection = " DESC" sSortParams = "Formrelclicontact_Sorting=" & iSort & "&Formrelclicontact_Sorted=" & iSort & "&" else form_sorting = iSort sDirection = " ASC" sSortParams = "Formrelclicontact_Sorting=" & iSort & "&Formrelclicontact_Sorted=" & "&" end if if iSort = 1 then sOrder = " order by r.LastName" & sDirection if iSort = 2 then sOrder = " order by r.FisrtName" & sDirection if iSort = 3 then sOrder = " order by r.Service" & sDirection if iSort = 4 then sOrder = " order by r.Function" & sDirection if iSort = 5 then sOrder = " order by r.Tel1" & sDirection if iSort = 6 then sOrder = " order by r.Tel2" & sDirection if iSort = 7 then sOrder = " order by r.Mail1" & sDirection if iSort = 8 then sOrder = " order by r.Mail2" & sDirection if iSort = 9 then sOrder = " order by r.Note" & sDirection end if '------------------------------- ' HTML column headers '------------------------------- %> <% '------------------------------- ' Build WHERE statement '------------------------------- pidCli = GetParam("idCli") if IsNumeric(pidCli) and not isEmpty(pidCli) then pidCli = ToSQL(pidCli, "Number") else pidCli = Empty if not isEmpty(pidCli) then HasParam = true sWhere = sWhere & "r.idCli=" & pidCli else bReq = false end if if HasParam then sWhere = " WHERE (" & sWhere & ")" end if '------------------------------- ' Build base SQL statement '------------------------------- sSQL = "select r.FisrtName as r_FisrtName, " & _ "r.Function as r_Function, " & _ "r.LastName as r_LastName, " & _ "r.Mail1 as r_Mail1, " & _ "r.Mail2 as r_Mail2, " & _ "r.Note as r_Note, " & _ "r.Service as r_Service, " & _ "r.Tel1 as r_Tel1, " & _ "r.Tel2 as r_Tel2, " & _ "r.id as r_id, " & _ "r.idCli as r_idCli " & _ " from relclicontact r " '------------------------------- '------------------------------- ' relclicontact Open Event start ' relclicontact Open Event end '------------------------------- '------------------------------- ' Assemble full SQL statement '------------------------------- sSQL = sSQL & sWhere & sOrder '------------------------------- '------------------------------- ' Process the link to the record page '------------------------------- form_action = sActionFileName '------------------------------- '------------------------------- ' Process if form has all required parameter '------------------------------- if not bReq then %>
<%=sFormTitle%>
LastName FisrtName Service Function Tel1 Tel2 Mail1 Mail2 Note
No records
<% exit sub end if '------------------------------- '------------------------------- ' Open the recordset '------------------------------- openrs rs, sSQL '------------------------------- '------------------------------- ' Process empty recordset '------------------------------- if rs.eof then %> No records <% end if '------------------------------- '------------------------------- 'Initialize page counter and records per page '------------------------------- iRecordsPerPage = 50 iCounter = 0 '------------------------------- ' Process page scroller '------------------------------- iPage = GetParam("Formrelclicontact_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 '------------------------------- fldFisrtName = GetValue(rs, "r_FisrtName") fldFunction = GetValue(rs, "r_Function") fldid = GetValue(rs, "r_id") fldidCli = GetValue(rs, "r_idCli") fldLastName_URLLink = "relclicontact.asp" fldLastName_id = GetValue(rs, "r_id") fldLastName = GetValue(rs, "r_LastName") fldMail1 = GetValue(rs, "r_Mail1") fldMail2 = GetValue(rs, "r_Mail2") fldNote = GetValue(rs, "r_Note") fldService = GetValue(rs, "r_Service") fldTel1 = GetValue(rs, "r_Tel1") fldTel2 = GetValue(rs, "r_Tel2") '------------------------------- ' relclicontact Show begin '------------------------------- '------------------------------- ' relclicontact Show Event start ' relclicontact Show Event end '------------------------------- '------------------------------- ' Process the HTML controls '------------------------------- %> <%=fldLastName%>  <%=ToHTML(fldFisrtName)%>  <%=ToHTML(fldService)%>  <%=ToHTML(fldFunction)%>  <%=ToHTML(fldTel1)%>  <%=ToHTML(fldTel2)%>  <%=ToHTML(fldMail1)%>  <%=ToHTML(fldMail2)%>  <%=ToHTML(fldNote)%>  <% '------------------------------- ' relclicontact 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. '------------------------------- %> Insert       <% '------------------------------- ' relclicontact 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 '------------------------------- ' relclicontact Navigation end '------------------------------- '------------------------------- ' Finish form processing '------------------------------- set rs = nothing %> <% '------------------------------- ' relclicontact Close Event start ' relclicontact Close Event end '------------------------------- end sub '=============================== '=============================== ' Action of the Record Form '------------------------------- Sub relclicontact1Action(sAction) '------------------------------- ' Initialize variables '------------------------------- Dim bExecSQL: bExecSQL = true Dim sActionFileName : sActionFileName = "" Dim sParams : sParams = "?" Dim sWhere : sWhere = "" Dim bErr : bErr = False Dim pPKid : pPKid = "" Dim fldLastName : fldLastName = "" Dim fldFisrtName : fldFisrtName = "" Dim fldService : fldService = "" Dim fldFunction : fldFunction = "" Dim fldTel1 : fldTel1 = "" Dim fldTel2 : fldTel2 = "" Dim fldMail1 : fldMail1 = "" Dim fldMail2 : fldMail2 = "" Dim fldNote : fldNote = "" '------------------------------- '------------------------------- ' relclicontact1 Action begin '------------------------------- sActionFileName = "relclicontact.asp" sParams = sParams & "idCli=" & ToURL(GetParam("Trn_idCli")) '------------------------------- ' CANCEL action '------------------------------- if sAction = "cancel" then '------------------------------- ' relclicontact1 BeforeCancel Event start ' relclicontact1 BeforeCancel Event end '------------------------------- cn.Close Set cn = Nothing response.redirect sActionFileName & sParams 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 '------------------------------- fldidCli = GetParam("Rqd_idCli") fldLastName = GetParam("LastName") fldFisrtName = GetParam("FisrtName") fldService = GetParam("Service") fldFunction = GetParam("Function") fldTel1 = GetParam("Tel1") fldTel2 = GetParam("Tel2") fldMail1 = GetParam("Mail1") fldMail2 = GetParam("Mail2") fldNote = GetParam("Note") '------------------------------- ' Validate fields '------------------------------- if sAction = "insert" or sAction = "update" then if IsEmpty(fldLastName) then srelclicontact1Err = srelclicontact1Err & "The value in field LastName is required.
" end if '------------------------------- ' relclicontact1 Check Event start ' relclicontact1 Check Event end '------------------------------- If len(srelclicontact1Err) > 0 then exit sub end if end if '------------------------------- '------------------------------- ' Create SQL statement '------------------------------- select case sAction case "insert" '------------------------------- ' relclicontact1 Insert Event start ' relclicontact1 Insert Event end '------------------------------- sSQL = "insert into relclicontact (" & _ "idCli," & _ "LastName," & _ "FisrtName," & _ "Service," & _ "Function," & _ "Tel1," & _ "Tel2," & _ "Mail1," & _ "Mail2," & _ "Note)" & _ " values (" & _ ToSQL(fldidCli, "Number") & "," & _ ToSQL(fldLastName, "Text") & "," & _ ToSQL(fldFisrtName, "Text") & "," & _ ToSQL(fldService, "Text") & "," & _ ToSQL(fldFunction, "Text") & "," & _ ToSQL(fldTel1, "Text") & "," & _ ToSQL(fldTel2, "Text") & "," & _ ToSQL(fldMail1, "Text") & "," & _ ToSQL(fldMail2, "Text") & "," & _ ToSQL(fldNote, "Text") & _ ")" case "update" '------------------------------- ' relclicontact1 Update Event start ' relclicontact1 Update Event end '------------------------------- sSQL = "update relclicontact set " & _ "LastName=" & ToSQL(fldLastName, "Text") & _ ",FisrtName=" & ToSQL(fldFisrtName, "Text") & _ ",Service=" & ToSQL(fldService, "Text") & _ ",Function=" & ToSQL(fldFunction, "Text") & _ ",Tel1=" & ToSQL(fldTel1, "Text") & _ ",Tel2=" & ToSQL(fldTel2, "Text") & _ ",Mail1=" & ToSQL(fldMail1, "Text") & _ ",Mail2=" & ToSQL(fldMail2, "Text") & _ ",Note=" & ToSQL(fldNote, "Text") sSQL = sSQL & " where " & sWhere case "delete" '------------------------------- ' relclicontact1 Delete Event start ' relclicontact1 Delete Event end '------------------------------- sSQL = "delete from relclicontact where " & sWhere end select '------------------------------- '------------------------------- ' relclicontact1 BeforeExecute Event start ' relclicontact1 BeforeExecute Event end '------------------------------- '------------------------------- ' Execute SQL statement '------------------------------- if len(srelclicontact1Err) > 0 then Exit Sub on error resume next if bExecSQL then cn.execute sSQL end if srelclicontact1Err = ProcessError on error goto 0 if len(srelclicontact1Err) > 0 then Exit Sub cn.Close Set cn = Nothing response.redirect sActionFileName & sParams '------------------------------- ' relclicontact1 Action end '------------------------------- end sub '=============================== '=============================== ' Display Record Form '------------------------------- Sub relclicontact1_Show() '------------------------------- ' relclicontact1 Show begin '------------------------------- sWhere = "" Dim sFormTitle: sFormTitle = "relclicontact" bPK = true %> <% if not (srelclicontact1Err = "") then %> <% end if %> <% '------------------------------- ' Load primary key and form parameters '------------------------------- if srelclicontact1Err = "" then fldid = GetParam("id") fldidCli = GetParam("idCli") Trn_idCli = GetParam("idCli") Rqd_idCli = GetParam("idCli") pid = GetParam("id") else fldid = GetParam("id") fldLastName = GetParam("LastName") fldFisrtName = GetParam("FisrtName") fldService = GetParam("Service") fldFunction = GetParam("Function") fldTel1 = GetParam("Tel1") fldTel2 = GetParam("Tel2") fldMail1 = GetParam("Mail1") fldMail2 = GetParam("Mail2") fldNote = GetParam("Note") Rqd_idCli = GetParam("Rqd_idCli") fldidCli = GetParam("Trn_idCli") Trn_idCli = GetParam("Trn_idCli") 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 '------------------------------- '------------------------------- ' relclicontact1 Open Event start ' relclicontact1 Open Event end '------------------------------- '------------------------------- ' Build SQL statement and open recordset '------------------------------- sSQL = "select * from relclicontact where " & sWhere openrs rs, sSQL bIsUpdateMode = (bPK and not(sAction = "insert" and sForm = "relclicontact1") and not rs.eof) '------------------------------- '------------------------------- ' Load all fields into variables from recordset or input parameters '------------------------------- if bIsUpdateMode then fldid = GetValue(rs, "id") fldidCli = GetValue(rs, "idCli") '------------------------------- ' Load data from recordset when form displayed first time '------------------------------- if srelclicontact1Err = "" then fldLastName = GetValue(rs, "LastName") fldFisrtName = GetValue(rs, "FisrtName") fldService = GetValue(rs, "Service") fldFunction = GetValue(rs, "Function") fldTel1 = GetValue(rs, "Tel1") fldTel2 = GetValue(rs, "Tel2") fldMail1 = GetValue(rs, "Mail1") fldMail2 = GetValue(rs, "Mail2") fldNote = GetValue(rs, "Note") end if '------------------------------- ' relclicontact1 ShowEdit Event start ' relclicontact1 ShowEdit Event end '------------------------------- else if srelclicontact1Err = "" then fldid = ToHTML(GetParam("id")) fldidCli = ToHTML(GetParam("idCli")) end if '------------------------------- ' relclicontact1 ShowInsert Event start ' relclicontact1 ShowInsert Event end '------------------------------- end if '------------------------------- ' Set lookup fields '------------------------------- fldidCli = DLookUp("eb_clients", "FriendName", "id=" & ToSQL(fldidCli, "Number")) '------------------------------- ' relclicontact1 Show Event start ' relclicontact1 Show Event end '------------------------------- '------------------------------- ' Show form fields '------------------------------- %>
<%=sFormTitle%>
<%= srelclicontact1Err %>
Client <%=ToHTML(fldidCli)%> 
LastName
FisrtName
Service
Function
Tel1
Tel2
Mail1
Mail2
Note
<% if not bIsUpdateMode then %> <% end if %> <% if bIsUpdateMode then %> <% end if %>
<% '------------------------------- ' relclicontact1 Close Event start ' relclicontact1 Close Event end '------------------------------- Set rs = Nothing '------------------------------- ' relclicontact1 Show end '------------------------------- End Sub '=============================== %>