0 then
GroupId = gGrpID
else
GroupId = 0
end if

Set RstObj = Server.CreateObject(“ADODB.RecordSet”)
RstObj.CursorType = adOpenForwardOnly
Set ConnObj = Server.CreateObject(“ADODB.Connection”)
ConnObj.Mode = adModeReadWrite
ConnObj.Open ecom

Set StudentConn = Server.CreateObject(“ADODB.Connection”)
StudentConn.Open ecom

Dim StudentId
StudentId = 0

if len(request.QueryString(“RecId”) & “”) > 0 then
StudentId = request.QueryString(“RecId”)
action = “update”
end if

if len(request.QueryString(“StudentId”) & “”) > 0 then
StudentId = request.QueryString(“StudentId”)
action = “update”
end if

If Request.ServerVariables(“REQUEST_METHOD”) = “POST” Then
set rsStudent = Server.CreateObject(“ADODB.Recordset”)
rsStudent.Open “Select * from Students where recId = ” & StudentId, StudentConn, 3, 3

if StudentId = 0 then
rsStudent.addnew
end if

rsStudent(“fname”) = Trim(Request(“fname”))
rsStudent(“lname”) = Trim(Request(“lname”))
rsStudent(“username”) = Trim(Request(“username”))
rsStudent(“pword”) = Trim(Request(“pword”))
rsStudent(“email”) = Trim(Request(“email”))
rsStudent(“homephone”) = Trim(Request(“phone”))
rsStudent(“address1”) = Trim(Request(“address1”))
rsStudent(“address2”) = Trim(Request(“address2”))
rsStudent(“city”) = Trim(Request(“city”))
rsStudent(“state”) = Trim(Request(“state”))
rsStudent(“zip”) = Trim(Request(“zip”))
rsStudent(“CDL”) = Trim(Request(“CDL”))
rsStudent(“CDLExpDate”) = Trim(Request(“CDLExpDate”))
rsStudent(“DLState”) = Trim(Request(“DLState”))
rsStudent(“DLCountry”) = Trim(Request(“DLCountry”))

if len(Request(“BirthDate”) & “”) > 0 then
if isDate(Request(“BirthDate”)) then
rsStudent(“BirthDate”) = Trim(Request(“BirthDate”))
end if
end if

‘rsStudent(“sendemail”) = Request(“sendemail”)

if len(Request(“GroupID”) & “”) > 0 then
rsStudent(“classID”) = Request(“GroupID”)
end if

‘rsStudent(“payment”) = Request(“payment”)

if len(Trim(Request(“amount”)) & “”) > 0 then
rsStudent(“total”) = Trim(Request(“amount”))
end if

‘rsStudent(“needstopay”) = Trim(Request(“needstopay”))
rsStudent(“rostercomments”) = Trim(Request(“rostercomments”))
rsStudent(“Reschedule”) = Request(“Reschedule”)
rsStudent(“TimeExpired”) = Request(“TimeExpired”)
rsStudent(“rangestatus”) = Request(“rangestatus”)
rsStudent(“classBstatus”) = Request(“classBstatus”)
rsStudent(“classAstatus”) = Request(“classAstatus”)
rsStudent(“Gender”) = Request(“Gender”)

rsStudent(“CertificateNum”) = Request(“CertificateNum”)
rsStudent(“HowHear”) = Request(“HearAbout”) & “”
rsStudent(“Dealer”) = Request(“Dealer”) & “”
rsStudent(“OtherReferral”) = Request(“Referral”) & “”

If IsDate(Birthdate) Then
rsStudent(“Birthdate”) = BirthDate
End If

rsStudent(“comments”) = Replace(Request(“staffcomments”) & “”, VbCrLf, “
“)

randomize
rsStudent(“ordernum”) = Right(Year(Date),1) & Month(Date) & Day(Date) & int(rnd*9999999)+1

If amount = “” Then amount = “0”
If Reschedule = “” Then Reschedule = “0”
If TimeExpired = “” Then TimeExpired = “0”
If SkillsScore = “” then SkillsScore=”0″
If KnowledgeScore = “” then KnowledgeScore=”0″

If payment = “Credit Card” Then
ordstatus = “Pending Credit Card”
ElseIf payment = “Check” Then
ordstatus = “Waiting for Check”
ElseIf payment = “Money Order” Then
ordstatus = “Waiting for Check”
ElseIf payment = “PayPal” Then
ordstatus = “Pending”
ElseIf payment = “Cash” Then
ordstatus = “Waiting for Cash”
End If

‘ rsStudent(“amount”) = amount
rsStudent(“Reschedule”) = Reschedule
rsStudent(“TimeExpired”) = TimeExpired

if len(Request(“SkillsScore”) & “”) > 0 then
rsStudent(“SkillsScore”) = Request(“SkillsScore”)
else
rsStudent(“SkillsScore”) = 0
end if

if len(Request(“KnowledgeScore”) & “”) > 0 then
rsStudent(“KnowledgeScore”) = Request(“KnowledgeScore”)
else
rsStudent(“KnowledgeScore”) = 0
end if

‘rsStudent(“ordstatus”) = ordstatus

rsStudent.update

rsStudent.close
Set rsStudent = nothing

if StudentId = 0 then
Set RstObj = ConnObj.Execute (“SELECT Max(RecID) FROM Students WHERE LName = ‘” & tidySql(Request(“lname”)) & “‘ AND FName = ‘” & tidySql(Request(“fname”)) & “‘”, RecordsAffected, adCmdText)
If RstObj.EOF True Then
StudentId = RstObj(0)
End If
end if

classAstatus = Request(“classAstatus”)
classBstatus = Request(“classBstatus”)
rangestatus = Request(“rangestatus”)
rangeBstatus = Request(“rangeBstatus”)

If studentId > 0 AND Request(“GroupID”) “” Then

If classAstatus = “” Then classAstatus = “Enrolled”
If classBstatus = “” Then classBstatus = “Enrolled”
If rangestatus = “” Then rangestatus = “Enrolled”
If rangebstatus = “” Then rangebstatus = “Enrolled”

studentConn.Execute “DELETE Enrollments WHERE StudentID = ” & studentId

set rsEnrollment = Server.CreateObject(“ADODB.Recordset”)
rsEnrollment.Open “Select * from Enrollments where ClassID = ” & Request(“GroupID”) & ” AND StudentID = ” & StudentId, StudentConn, 3, 3

if rsEnrollment.RecordCount = 0 then
rsEnrollment.AddNew
rsEnrollment(“ClassId”) = Request(“GroupID”)
rsEnrollment(“StudentId”) = StudentId
rsEnrollment.Update
end if

rsEnrollment.Close
Set rsEnrollment = nothing

set rsStudent = Server.CreateObject(“ADODB.Recordset”)
rsStudent.Open “Select * from Students where recId = ” & StudentId, StudentConn, 3, 3

if not rsStudent.eof then
rsStudent(“ClassAStatus”) = classAstatus
rsStudent(“ClassBStatus”) = classBstatus
rsStudent(“RangeStatus”) = rangestatus
rsStudent(“RangeBStatus”) = rangeBstatus
rsStudent.update
end if

rsStudent.close
Set rsStudent = nothing

‘If sendemail = “Yes” And email “” Then Call emailClient()

If payment = “Credit Card” Then
StudentConn.Close
Set StudentConn = nothing
Response.redirect SecureUrl & “Paypal.asp?ord=” & ordernum
End If

End If

end if

If StudentId > 0 then
set rsStudent = Server.CreateObject(“ADODB.Recordset”)
rsStudent.Open “Select * from Students where recId = ” & StudentId, StudentConn, 3, 3

if rsStudent.RecordCount > 0 then
lname = rsStudent(“Lname”)
fname = rsStudent(“Fname”)
email = rsStudent(“Email”)
phone = rsStudent(“HomePhone”)
address1 = rsStudent(“Address1”)
address2 = rsStudent(“Address2”)
city = rsStudent(“City”)
state = rsStudent(“State”)
zip = rsStudent(“Zip”)
CDL = rsStudent(“CDL”)
CDLExpDate = rsStudent(“CDLExpDate”)
DLState = rsStudent(“DLState”)
DLCountry = rsStudent(“DLCountry”)
BirthDate = rsStudent(“BirthDate”)
username = rsStudent(“Username”)
pword = rsStudent(“Pword”)
needstopay = rsStudent(“RosterNeedsToPay”)
rostercomments = rsStudent(“RosterComments”)
staffcomments = rsStudent(“Comments”)
Reschedule = rsStudent(“Reschedule”)
TimeExpired = rsStudent(“TimeExpired”)
amount = rsStudent(“Total”)
payment = rsStudent(“Status”)
Paid = rsStudent(“Paid”)
classAstatus = rsStudent(“ClassAStatus”)
classBstatus = rsStudent(“ClassBStatus”)
rangestatus = rsStudent(“RangeStatus”)
rangebstatus = rsStudent(“RangeBStatus”)
Gender = rsStudent(“Gender”)
SkillsScore = rsStudent(“SkillsScore”)
KnowledgeScore = rsStudent(“KnowledgeScore”)
CertificateNum = rsStudent(“CertificateNum”)
HearAbout = rsStudent(“HowHear”) & “”
Dealer = rsStudent(“Dealer”) & “”
Referal = rsStudent(“OtherReferral”) & “”
GroupId = rsStudent(“ClassId”)
amount = rsStudent(“total”)
Reschedule = rsStudent(“Reschedule”)
TimeExpired = rsStudent(“TimeExpired”)
SkillsScore = rsStudent(“SkillsScore”)
KnowledgeScore = rsStudent(“KnowledgeScore”)

staffcomments = rsStudent(“comments”)

If amount = “” Then amount = “0”
If Reschedule = “” Then Reschedule = “0”
If TimeExpired = “” Then TimeExpired = “0”
If SkillsScore = “” then SkillsScore=”0″
If KnowledgeScore = “” then KnowledgeScore=”0″

If payment = “Credit Card” Then
ordstatus = “Pending Credit Card”
ElseIf payment = “Check” Then
ordstatus = “Waiting for Check”
ElseIf payment = “Money Order” Then
ordstatus = “Waiting for Check”
ElseIf payment = “PayPal” Then
ordstatus = “Pending”
ElseIf payment = “Cash” Then
ordstatus = “Waiting for Cash”
End If

ordernum = rsStudent(“ordernum”)

end if

rsStudent.close
Set rsStudent = nothing

end if

StudentConn.Close
Set StudentConn = nothing

Sub emailClient()
msg = “We would like to welcome you to the ” & CompanyName & “‘s website.” & VbCrLf & VbCrLf
msg = msg & “Here is your login information.” & VbCrLf & VbCrLf
msg = msg & “Username: ” & username & VbCrLf
msg = msg & “Password: ” & pword & VbCrLf & VbCrLf

msg = msg & “You can check your class assignments by going to:” & VbCrLf
msg = msg & “http://www.” & DomainName & “/student-home.asp” & VbCrLf
msg = msg & “If you have further questions, please call ” & busphone & VbCrLf

call SendMail(email, msg, CompanyName & ” Account”)
End Sub
%>

– Add Student

.error {
background-color: #c77272;
}

TD.rdd { color: ;
font-size: medium;
font-family: helvetica,arial;
font-weight: bold;
}
TD.wht { color: #FFFFFF; font-size: 14pt; font-family: helvetica,arial; font-weight: bold;}
.style2 {font-size: x-large}
.style3 {
font-family: Arial, Helvetica, sans-serif;
font-size: medium;
}
.style4 {font-size: medium}

0 then
pageHeader = “Edit ” & fName & ” ” & lName
else
pageHeader = “Add Student”
end if

response.write “

” & pageHeader & “

%>

<hr color="”>
Personal Info

<form action="students-add.asp?recId=” method=”post” id=”studentForm”>
<input type="hidden" name="ordernum" value="”>

<input type="hidden" name="payment" value="”>

First Name: <input type="text" name="fname" size="30" maxlength="30" style="font-size:medium" value="” class=”required”>
Last Name: <input type="text" name="lname" size="30" maxlength="30" style="font-size:medium" value="” class=”required”>
E-mail Address: <input type="text" name="email" size="30" maxlength="50" style="font-size:medium" value="” class=”required”>
Home Phone: <input type="text" name="phone" size="20" maxlength="25" style="font-size:medium" value="” class=”required”>
Address 1: <input type="text" name="address1" size="30" maxlength="30" style="font-size:medium" value="”>
Address 2: <input type="text" name="address2" size="30" maxlength="30" style="font-size:medium" value="”>
City: <input type="text" name="city" size="30" maxlength="30" style="font-size:medium" value="”>
State: <input type="text" name="state" size="2" maxlength="2" style="font-size:medium" value="”>
Zip: <input type="text" name="zip" size="5" maxlength="12" style="font-size:medium" value="”>
CDL: <input type="text" name="CDL" id="CDL" size="10" maxlength="20" style="font-size:medium" value="”>

CDL State: <input type="text" name="DLState" size="2" maxlength="2" style="font-size:medium" value="”>
CDL Country: <select name="DLCountry" size="2" class="style3" style="background-color: ;”>
<option selected>United States
<option>Other
CDL Expiration: <input type="text" name="CDLExpDate" size="5" maxlength="5" style="font-size:medium" value="” class=”required”> enter in format (mm/yy)
Birth Date: <input type="text" name="BirthDate" size="7" maxlength="12" style="font-size:medium" value="” class=”required”>
Gender: <select name="Gender" size="2" class="style4" style="background-color: ;”>
<option>M
<option>F
<hr color="”>
Referal
How Did You Hear About Us?

<%
if HearAbout = "Search Engine" then
response.write "Search Engine”
else
response.write “Search Engine”
end if

if HearAbout = “Referral” then
response.write “Referral”
else
response.write “Referral”
end if

if HearAbout = “DMV” then
response.write “DMV”
else
response.write “DMV”
end if

if HearAbout = “Motorcycle Dealers” then
response.write “Motorcycle Dealers”
else
response.write “Motorcycle Dealers”
end if

if HearAbout = “Other” then
response.write “Other”
else
response.write “Other”
end if

%>

If Dealer, Which One? <input style="font-size:medium" type="text" name="Dealer" size="35" tabindex="23" maxlength="40" value='’>
If Other or Referral, Who? <input style="font-size:medium" type="text" name="Referral" size="35" tabindex="24" maxlength="40" value='’>
<hr color="”>
Class Enrollments (optional)
Class Group Number:

= ‘” & startDate & “‘ AND ClassADate 0 then
classSql = classSql & “Union ”
classSql = classSql & “Select recId, GroupNo from Classes where recId = ” & GroupId
end if

Set ClassConn = Server.CreateObject(“ADODB.Connection”)
ClassConn.Open ecom

set rsClass = Server.CreateObject(“ADODB.Recordset”)
rsClass.Open classSql, ClassConn, 3, 3
%>

<select name="GroupID" size="1" class="style3" style="background-color: ;”>

0 then
if GroupId > 0 then
SelectedGroupId = groupId
end if
end if

Do while not rsClass.EOF

if Clng(SelectedGroupId) = Clng(rsClass(“recId”)) then
response.write “” & rsClass(“GroupNo”) & “”
else
response.write “” & rsClass(“GroupNo”) & “”
end if

rsClass.MoveNext
Loop

rsClass.Close
set rsClass = nothing

ClassConn.Close
Set ClassConn = nothing
%>

Class A Status: <select name="classAstatus" size="1" class="style3" style="background-color: ;”>

<option>Pass
<option>Fail
<option>Enrolled

Paid? Yes
Payment by: <select name="payment" size="1" class="style3" style="background-color: ;”>

<option>Credit Card
<option>Check/M.O.
<option>Cash
<option>CC Approved
<option>CC Declined



Range A Status: <select name="rangestatus" size="1" class="style3" style="background-color: ;”>

<option>Pass
<option>Fail
<option>Enrolled

    Class B Status <select name="classbstatus" size="1" class="style3" style="background-color: ;”>

<option>Pass
<option>Fail
<option>Enrolled

Amount: $<input type="text" name="amount" size="5" maxlength="12" style="font-size:medium" value="”> Range B Status: <select name="rangeBstatus" size="1" class="style3" style="background-color: ;”>

<option>Pass
<option>Fail
<option>Enrolled

Knowledge Score <input type="text" name="KnowledgeScore" size="10" maxlength="10" style="font-size:medium" value="”> Skills Score <input type="text" name="SkillsScore" size="10" maxlength="10" style="font-size:medium" value="”>
Certificate Number <input type="text" name="CertificateNum" size="20" maxlength="20" style="font-size:medium" value="”>
<hr color="”>
Roster Notes (optional – appears on the printable roster)
Needs to Pay: <input type="text" name="needstopay" size="30" maxlength="100" style="font-size:medium" value="”>
Roster Comments: <input type="text" name="rostercomments" size="30" maxlength="255" style="font-size:medium" value="”>
<hr color="”>
Need Rescheduling? <input type="radio" name="Reschedule" value="1">
Yes   <input type="radio" name="Reschedule" value="0">
No  
(will show up on the “Needs Rescheduling” page)
Time Expired? <input type="radio" name="TimeExpired" value="1">
Yes   <input type="radio" name="TimeExpired" value="0">
No  
(will show up on the “Time Expired” page)
<hr color="”>
Staff Comments:
These notes are confidential and only displayed here.
<hr color="”>

0 Then
submitMessage = “Update”
else
submitMessage = “Add”
end if
%>

<input type="button" value="” id=”button_submit”>

Student has been updated.


Student Search

Student has been added.

Add More

$(function() {

$(“#button_submit”).click( function()
{

var errCount = 0;

$( “.required” ).each(function( index )
{
if ($( this ).val().length == 0)
{

//alert($(this).name);

errCount = (errCount + 1);
$(this).addClass(“error”);
}
else
{
$(this).removeClass(“error”);
}
});

if (errCount == 0)
{
$(“form#studentForm”).submit();
}
else
{
alert(“Error – some required fields have not been completed”);
}
}
);

$(“#CDL”).change(function()
{
var licenceNo = $(“#CDL”).val();

if(licenceNo != “”)
{
var url = ‘../codeBehind/ajax.asp?ajaxAction=validateDuplicateLicence&licenceNo=’ + encodeURIComponent(licenceNo);

$(“#licenceDuplicate”).load(url, function (response, status, xhr) {
if(status==”success”) {
if (response != “”)
{
$(“#button_submit”).hide();
}
else
{
$(“#button_submit”).show();
}

}
}
);
}
else
{
$(“#licenceDuplicate”).html(“”);
$(“#button_submit”).show();
}

});

});