%
'
' Filename: contacts.asp
' Generated with CodeCharge 2.0.5
' ASP 2.0.ccp build 01/22/2002
'
'-------------------------------
' contacts CustomIncludes begin
%>
<%
' contacts CustomIncludes end
'-------------------------------
'===============================
' Save Page and File Name available into variables
'-------------------------------
sFileName = "contacts.asp"
'===============================
'===============================
' contacts PageSecurity begin
CheckSecurity(1)
' contacts PageSecurity end
'===============================
'===============================
' contacts Open Event start
' contacts Open Event end
'===============================
'===============================
' contacts OpenAnyPage Event start
' contacts OpenAnyPage Event end
'===============================
'===============================
' Save the name of the form and type of action into the variables
'-------------------------------
sAction = GetParam("FormAction")
sForm = GetParam("FormName")
'===============================
' contacts 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
|
<% relclicontact1_Show %>
|
<%
' contacts Show end
' contacts Close Event start
' contacts 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 = "contacts.asp"
'-------------------------------
' Search Open Event start
' Search Open Event end
'-------------------------------
'-------------------------------
' Set variables with search parameters
'-------------------------------
flds_LastName = GetParam("s_LastName")
'-------------------------------
' Search Show begin
'-------------------------------
'-------------------------------
' Search Show Event start
' Search Show Event end
'-------------------------------
%>
<%
'-------------------------------
' Search Show end
'-------------------------------
'-------------------------------
' Search Close Event start
' Search Close Event end
'-------------------------------
end sub
'===============================
'===============================
' 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 iSort : iSort = ""
Dim iSorted : iSorted = ""
Dim sDirection : sDirection = ""
Dim form_sorting : form_sorting = ""
Dim sSortParams : sSortParams = ""
Dim form_action : form_action = ""
Dim iRecordsPerPage : iRecordsPerPage = 100
Dim iCounter : iCounter = 0
Dim iPage : iPage = 0
Dim bEof : bEof = False
Dim sActionFileName : sActionFileName = "contacts.asp"
Dim transit_params : transit_params = "s_LastName=" & ToURL(GetParam("s_LastName")) & "&"
Dim form_params : form_params = "s_LastName=" & ToURL(GetParam("s_LastName")) & "&"
'-------------------------------
' 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 e.FriendName" & sDirection
if iSort = 2 then sOrder = " order by r.LastName" & sDirection
if iSort = 3 then sOrder = " order by r.FisrtName" & sDirection
if iSort = 4 then sOrder = " order by r.Service" & sDirection
if iSort = 5 then sOrder = " order by r.Function" & sDirection
if iSort = 6 then sOrder = " order by r.Tel1" & sDirection
if iSort = 7 then sOrder = " order by r.Tel2" & sDirection
if iSort = 8 then sOrder = " order by r.Mail1" & sDirection
if iSort = 9 then sOrder = " order by r.Mail2" & sDirection
if iSort = 10 then sOrder = " order by r.Note" & sDirection
end if
'-------------------------------
' HTML column headers
'-------------------------------
%>
| <%=sFormTitle%> |
| Client |
LastName |
FisrtName |
Service |
Function |
Tel1 |
Tel2 |
Mail1 |
Mail2 |
Note |
<%
'-------------------------------
' Build WHERE statement
'-------------------------------
ps_LastName = GetParam("s_LastName")
if not isEmpty(ps_LastName) then
HasParam = true
sWhere = "r.LastName like '%" & replace(ps_LastName, "'", "''") & "%'" & " or " & "r.FisrtName like '%" & replace(ps_LastName, "'", "''") & "%'" & " or " & "r.Mail1 like '%" & replace(ps_LastName, "'", "''") & "%'" & " or " & "r.Mail2 like '%" & replace(ps_LastName, "'", "''") & "%'"
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, " & _
"e.id as e_id, " & _
"e.FriendName as e_FriendName " & _
" from (relclicontact r left join eb_clients e on e.id=r.idCli) "
'-------------------------------
'-------------------------------
' 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
'-------------------------------
'-------------------------------
' 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 = 100
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, "e_FriendName")
fldLastName_URLLink = "contacts.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
'-------------------------------
%>
| <%=ToHTML(fldidCli)%> |
<%=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 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 = "contacts.asp"
'-------------------------------
' CANCEL action
'-------------------------------
if sAction = "cancel" then
'-------------------------------
' relclicontact1 BeforeCancel Event start
' relclicontact1 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
'-------------------------------
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 "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
'-------------------------------
' relclicontact1 Action end
'-------------------------------
end sub
'===============================
'===============================
' Display Record Form
'-------------------------------
Sub relclicontact1_Show()
'-------------------------------
' relclicontact1 Show begin
'-------------------------------
sWhere = ""
Dim sFormTitle: sFormTitle = "Modifiy"
bPK = true
%>
<%
'-------------------------------
' relclicontact1 Close Event start
' relclicontact1 Close Event end
'-------------------------------
Set rs = Nothing
'-------------------------------
' relclicontact1 Show end
'-------------------------------
End Sub
'===============================
%>