%
'
' Filename: EBemployees.asp
' Generated with CodeCharge 2.0.5
' ASP 2.0.ccp build 01/22/2002
'
'-------------------------------
' EBemployees CustomIncludes begin
%>
<%
' EBemployees CustomIncludes end
'-------------------------------
'===============================
' Save Page and File Name available into variables
'-------------------------------
sFileName = "EBemployees.asp"
'===============================
'===============================
' EBemployees PageSecurity begin
CheckSecurity(1)
' EBemployees PageSecurity end
'===============================
'===============================
' EBemployees Open Event start
' EBemployees Open Event end
'===============================
'===============================
' EBemployees OpenAnyPage Event start
' EBemployees OpenAnyPage Event end
'===============================
'===============================
' Save the name of the form and type of action into the variables
'-------------------------------
sAction = GetParam("FormAction")
sForm = GetParam("FormName")
'===============================
' EBemployees Show begin
'===============================
' Page execution
'-------------------------------
'Initialize error variables
'-------------------------------
semployees1Err = ""
'-------------------------------
' Select the FormAction
'-------------------------------
Select Case sForm
Case "employees1"
employees1Action(sAction)
end select
'===============================
'===============================
' HTML Page layout
'-------------------------------
%>
EB Agenda - Employés
|
<% employees_Show %>
|
<% employees1_Show %>
|
<%
' EBemployees Show end
' EBemployees Close Event start
' EBemployees Close Event end
'-------------------------------
' Destroy connection object
'-------------------------------
cn.close
Set cn = nothing
'===============================
'********************************************************************************
'===============================
' Display Grid Form
'-------------------------------
Sub employees_Show()
'-------------------------------
' Initialize variables
'-------------------------------
Dim rs
Dim sWhere : sWhere = ""
Dim sOrder : sOrder = ""
Dim sSQL : sSQL = ""
Dim sFormTitle: sFormTitle = "Employees' 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 = 50
Dim iCounter : iCounter = 0
Dim iPage : iPage = 0
Dim bEof : bEof = False
Dim sActionFileName : sActionFileName = "EBemployees.asp"
Dim transit_params : transit_params = ""
Dim form_params : form_params = ""
'-------------------------------
' Build ORDER BY statement
'-------------------------------
sOrder = " order by e.FullName Asc"
iSort = GetParam("Formemployees_Sorting")
iSorted = GetParam("Formemployees_Sorted")
sDirection = ""
if IsEmpty(iSort) then
form_sorting = ""
else
if iSort = iSorted then
form_sorting = ""
sDirection = " DESC"
sSortParams = "Formemployees_Sorting=" & iSort & "&Formemployees_Sorted=" & iSort & "&"
else
form_sorting = iSort
sDirection = " ASC"
sSortParams = "Formemployees_Sorting=" & iSort & "&Formemployees_Sorted=" & "&"
end if
if iSort = 1 then sOrder = " order by e.IdEmpl" & sDirection
if iSort = 2 then sOrder = " order by e.FullName" & sDirection
if iSort = 3 then sOrder = " order by e.Initiales" & sDirection
if iSort = 4 then sOrder = " order by e.Fonction" & sDirection
if iSort = 5 then sOrder = " order by e.Telephone" & sDirection
if iSort = 6 then sOrder = " order by e.Mail" & sDirection
if iSort = 7 then sOrder = " order by e.Skype" & sDirection
if iSort = 8 then sOrder = " order by e.DisableEmpl" & sDirection
end if
'-------------------------------
' HTML column headers
'-------------------------------
%>
| <%=sFormTitle%> |
| ID |
FullName |
Initiales |
Function |
Phone |
Mail |
Skype |
Disable |
<%
'-------------------------------
' Build base SQL statement
'-------------------------------
sSQL = "select e.DisableEmpl as e_DisableEmpl, " & _
"e.Fonction as e_Fonction, " & _
"e.FullName as e_FullName, " & _
"e.IdEmpl as e_IdEmpl, " & _
"e.Initiales as e_Initiales, " & _
"e.Mail as e_Mail, " & _
"e.Skype as e_Skype, " & _
"e.Telephone as e_Telephone, " & _
"e.id as e_id " & _
" from employees e "
'-------------------------------
'-------------------------------
' employees Open Event start
' employees 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
%>
| Aucuns enregistrements |
<%
end if
'-------------------------------
'-------------------------------
'Initialize page counter and records per page
'-------------------------------
iRecordsPerPage = 50
iCounter = 0
'-------------------------------
' Process page scroller
'-------------------------------
iPage = GetParam("Formemployees_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
'-------------------------------
fldDisableEmpl = GetValue(rs, "e_DisableEmpl")
fldFonction = GetValue(rs, "e_Fonction")
fldFullName = GetValue(rs, "e_FullName")
fldid = GetValue(rs, "e_id")
fldIdEmpl_URLLink = "EBemployees.asp"
fldIdEmpl_id = GetValue(rs, "e_id")
fldIdEmpl = GetValue(rs, "e_IdEmpl")
fldInitiales = GetValue(rs, "e_Initiales")
fldMail = GetValue(rs, "e_Mail")
fldSkype = GetValue(rs, "e_Skype")
fldTelephone = GetValue(rs, "e_Telephone")
'-------------------------------
' employees Show begin
'-------------------------------
'-------------------------------
' employees Show Event start
' employees Show Event end
'-------------------------------
'-------------------------------
' Process the HTML controls
'-------------------------------
%>
| <%=fldIdEmpl%> |
<%=ToHTML(fldFullName)%> |
<%=ToHTML(fldInitiales)%> |
<%=ToHTML(fldFonction)%> |
<%=ToHTML(fldTelephone)%> |
<%=ToHTML(fldMail)%> |
<%=ToHTML(fldSkype)%> |
<%=ToHTML(fldDisableEmpl)%> |
<%
'-------------------------------
' employees 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
<%
'-------------------------------
' employees 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
'-------------------------------
' employees Navigation end
'-------------------------------
'-------------------------------
' Finish form processing
'-------------------------------
set rs = nothing
%>
|
<%
'-------------------------------
' employees Close Event start
' employees Close Event end
'-------------------------------
end sub
'===============================
'===============================
' Action of the Record Form
'-------------------------------
Sub employees1Action(sAction)
'-------------------------------
' Initialize variables
'-------------------------------
Dim bExecSQL: bExecSQL = true
Dim sActionFileName : sActionFileName = ""
Dim sWhere : sWhere = ""
Dim bErr : bErr = False
Dim pPKid : pPKid = ""
Dim fldIdEmpl : fldIdEmpl = ""
Dim fldFullName : fldFullName = ""
Dim fldInitiales : fldInitiales = ""
Dim fldFonction : fldFonction = ""
Dim fldTelephone : fldTelephone = ""
Dim fldMail : fldMail = ""
Dim fldSkype : fldSkype = ""
Dim fldLogin : fldLogin = ""
Dim fldPass : fldPass = ""
Dim fldDisableEmpl : fldDisableEmpl = ""
'-------------------------------
'-------------------------------
' employees1 Action begin
'-------------------------------
sActionFileName = "EBemployees.asp"
'-------------------------------
' CANCEL action
'-------------------------------
if sAction = "cancel" then
'-------------------------------
' employees1 BeforeCancel Event start
' employees1 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
'-------------------------------
fldIdEmpl = GetParam("IdEmpl")
fldFullName = GetParam("FullName")
fldInitiales = GetParam("Initiales")
fldFonction = GetParam("Fonction")
fldTelephone = GetParam("Telephone")
fldMail = GetParam("Mail")
fldSkype = GetParam("Skype")
fldLogin = GetParam("Login")
fldPass = GetParam("Pass")
fldDisableEmpl = getCheckBoxValue(GetParam("DisableEmpl"), "1", "0", "Number")
'-------------------------------
' Validate fields
'-------------------------------
if sAction = "insert" or sAction = "update" then
if IsEmpty(fldIdEmpl) then
semployees1Err = semployees1Err & "La valeur dans le domaine ID : est exigée.
"
end if
if IsEmpty(fldFullName) then
semployees1Err = semployees1Err & "La valeur dans le domaine Full Name : est exigée.
"
end if
if IsEmpty(fldInitiales) then
semployees1Err = semployees1Err & "La valeur dans le domaine Initiales : est exigée.
"
end if
if IsEmpty(fldLogin) then
semployees1Err = semployees1Err & "La valeur dans le domaine Login : est exigée.
"
end if
if IsEmpty(fldPass) then
semployees1Err = semployees1Err & "La valeur dans le domaine Pass : est exigée.
"
end if
if not isNumeric(fldIdEmpl) then
semployees1Err = semployees1Err & "La valeur dans le domaine ID : est incorrecte.
"
end if
'-------------------------------
' employees1 Check Event start
' employees1 Check Event end
'-------------------------------
If len(semployees1Err) > 0 then
exit sub
end if
end if
'-------------------------------
'-------------------------------
' Create SQL statement
'-------------------------------
select case sAction
case "insert"
'-------------------------------
' employees1 Insert Event start
' employees1 Insert Event end
'-------------------------------
sSQL = "insert into employees (" & _
"IdEmpl," & _
"FullName," & _
"Initiales," & _
"Fonction," & _
"Telephone," & _
"Mail," & _
"Skype," & _
"Login," & _
"Pass," & _
"DisableEmpl)" & _
" values (" & _
ToSQL(fldIdEmpl, "Number") & "," & _
ToSQL(fldFullName, "Text") & "," & _
ToSQL(fldInitiales, "Text") & "," & _
ToSQL(fldFonction, "Text") & "," & _
ToSQL(fldTelephone, "Text") & "," & _
ToSQL(fldMail, "Text") & "," & _
ToSQL(fldSkype, "Text") & "," & _
ToSQL(fldLogin, "Text") & "," & _
ToSQL(fldPass, "Text") & "," & _
fldDisableEmpl & _
")"
case "update"
'-------------------------------
' employees1 Update Event start
' employees1 Update Event end
'-------------------------------
sSQL = "update employees set " & _
"IdEmpl=" & ToSQL(fldIdEmpl, "Number") & _
",FullName=" & ToSQL(fldFullName, "Text") & _
",Initiales=" & ToSQL(fldInitiales, "Text") & _
",Fonction=" & ToSQL(fldFonction, "Text") & _
",Telephone=" & ToSQL(fldTelephone, "Text") & _
",Mail=" & ToSQL(fldMail, "Text") & _
",Skype=" & ToSQL(fldSkype, "Text") & _
",Login=" & ToSQL(fldLogin, "Text") & _
",Pass=" & ToSQL(fldPass, "Text") & _
",DisableEmpl=" & fldDisableEmpl
sSQL = sSQL & " where " & sWhere
case "delete"
'-------------------------------
' employees1 Delete Event start
' employees1 Delete Event end
'-------------------------------
sSQL = "delete from employees where " & sWhere
end select
'-------------------------------
'-------------------------------
' employees1 BeforeExecute Event start
' employees1 BeforeExecute Event end
'-------------------------------
'-------------------------------
' Execute SQL statement
'-------------------------------
if len(semployees1Err) > 0 then Exit Sub
on error resume next
if bExecSQL then
cn.execute sSQL
end if
semployees1Err = ProcessError
on error goto 0
if len(semployees1Err) > 0 then Exit Sub
cn.Close
Set cn = Nothing
response.redirect sActionFileName
'-------------------------------
' employees1 Action end
'-------------------------------
end sub
'===============================
'===============================
' Display Record Form
'-------------------------------
Sub employees1_Show()
'-------------------------------
' employees1 Show begin
'-------------------------------
sWhere = ""
Dim sFormTitle: sFormTitle = "Modify Employee"
bPK = true
%>
<%
'-------------------------------
' employees1 Close Event start
' employees1 Close Event end
'-------------------------------
Set rs = Nothing
'-------------------------------
' employees1 Show end
'-------------------------------
End Sub
'===============================
%>