banner literature about projects tools meetings search links BBS GAP home GAP home
home
<% cNumberOfPages = 4 Public ErrorCount, ErrorMessage, NewPage, NewSection PageAction = Request.Form("Action") PreviousPage = Request.Form("Page") SectionAction = Request.Form("SectionAction") PreviousSection = Request.Form("Section") Select Case PageAction Case "Next >" Call StoreVariables(PreviousPage, PreviousSection) Call CheckVariables(PreviousPage, PreviousSection) If ErrorCount > 0 Then NewPage = PreviousPage NewSection = PreviousSection Else Call SaveVariables(PreviousPage, PreviousSection) If ErrorCount > 0 Then NewPage = PreviousPage NewSection = PreviousSection Else NewPage = PreviousPage + 1 NewSection = "Top" End If End If Case "< Previous" Call StoreVariables(PreviousPage, PreviousSection) Call CheckVariables(PreviousPage, PreviousSection) If ErrorCount > 0 Then NewPage = PreviousPage NewSection = PreviousSection Else Call SaveVariables(PreviousPage, PreviousSection) NewPage = PreviousPage - 1 NewSection = "Top" End If Case "Finish" Call StoreVariables(PreviousPage, PreviousSection) Call CheckVariables(PreviousPage, PreviousSection) If ErrorCount > 0 Then NewPage = PreviousPage NewSection = PreviousSection Else Call SaveVariables(PreviousPage, PreviousSection) Session.Abandon NewPage = 0 NewSection = "Saved" End If Case "Cancel" NewPage = 0 NewSection = "Cancel" Case "Yes" NewPage = 0 NewSection = "CancelYes" Session.Abandon Call DeleteProject Case "No" NewPage = 1 NewSection = "Top" Case Else Select Case SectionAction Case "Add" NewPage = PreviousPage NewSection = "Add" Case "Edit" Call StoreVariables(PreviousPage, PreviousSection) Call CheckVariables(PreviousPage, PreviousSection) If ErrorCount > 0 Then NewPage = PreviousPage NewSection = PreviousSection Else NewPage = PreviousPage NewSection = "Edit" End If Case "Remove" PreviousSection = "Remove" Call StoreVariables(PreviousPage, PreviousSection) Call CheckVariables(PreviousPage, PreviousSection) Call SaveVariables(PreviousPage, PreviousSection) If ErrorCount > 0 Then NewPage = PreviousPage NewSection = "Top" Else NewPage = PreviousPage NewSection = "Top" End If Case "Ok" Select Case PreviousSection Case "Add" Call StoreVariables(PreviousPage, PreviousSection) Call CheckVariables(PreviousPage, PreviousSection) If ErrorCount > 0 Then NewPage = PreviousPage NewSection = PreviousSection Else Call SaveVariables(PreviousPage, PreviousSection) NewPage = PreviousPage NewSection = "Top" End If Case "Edit" Call StoreVariables(PreviousPage, PreviousSection) Call CheckVariables(PreviousPage, PreviousSection) If ErrorCount > 0 Then NewPage = PreviousPage NewSection = PreviousSection Else Call SaveVariables(PreviousPage, PreviousSection) NewPage = PreviousPage NewSection = "Top" End If Case Else Response.Write("Else! - PreviousSection") End Select Case "Cancel" NewPage = PreviousPage NewSection = "Top" Case "" NewPage = 1 'Start NewSection = "Top" Case Else Response.Write("Else! - SectionAction") End Select End Select Call DrawPage(NewPage, NewSection) Private Sub SaveVariables(Page, Section) Set Conn = Server.CreateObject("ADODB.Connection") Conn.Open Application("DSN_International") Select Case Page Case 1 If Session("ProjectID") = "" Then Set RS = Conn.Execute("EXEC spStartProject") Session("ProjectID") = RS("ProjectID") End If Set RS = Conn.Execute("EXEC spSaveName " & Session("ProjectID") & ",'" & SQLEncode(Session("FirstName")) & "','" & SQLEncode(Session("LastName")) & "'") Set RS = Conn.Execute("EXEC spSaveAddress " & Session("ProjectID") & ",'" & SQLEncode(Session("Address")) & "'") Set RS = Conn.Execute("EXEC spSavePhone " & Session("ProjectID") & ",'" & SQLEncode(Session("Phone")) & "','" & SQLEncode(Session("PhoneExtension")) & "'") Set RS = Conn.Execute("EXEC spSaveFax " & Session("ProjectID") & ",'" & SQLEncode(Session("Fax")) & "'") Set RS = Conn.Execute("EXEC spSaveEMail " & Session("ProjectID") & ",'" & SQLEncode(Session("EMail")) & "'") Set RS = Conn.Execute("EXEC spRemoveInstitutions " & Session("ProjectID")) For Each Institution In OnePerLine(Session("Institutions")) If Trim(Institution) <> "" Then Set RS = Conn.Execute("EXEC spSaveInstitution " & Session("ProjectID") & ",'" & SQLEncode(Trim(Institution)) & "'") End If Next Case 2 If Session("ProjectID") = "" Then ErrorCount = ErrorCount + 1 ErrorMessage = ErrorMessage & "A Fatal error has occured. Ignore all other error messages and contact the Web master about this problem.
" Else Set RS = Conn.Execute("EXEC spSaveTitle " & Session("ProjectID") & ",'" & SQLEncode(Session("Title")) & "'") Set RS = Conn.Execute("EXEC spSaveDescription " & Session("ProjectID") & ",'" & SQLEncode(Session("Description")) & "'") Set RS = Conn.Execute("EXEC spSaveStatus " & Session("ProjectID") & ",'" & SQLEncode(Session("Status")) & "'") Set RS = Conn.Execute("EXEC spRemoveKeywords " & Session("ProjectID")) Keywords = Session("Keywords") For Each Keyword In Split(Keywords, CHR(13) & CHR(10)) If Trim(Keyword) <> "" Then Set RS = Conn.Execute("EXEC spSaveKeyword " & Session("ProjectID") & ",'" & SQLEncode(Trim(Keyword)) & "'") End If Next Set RS = Conn.Execute("EXEC spSaveWebSiteURL " & Session("ProjectID") & ",'" & SQLEncode(Session("WebSiteURL")) & "'") Set RS = Conn.Execute("EXEC spSaveProducts " & Session("ProjectID") & ",'" & SQLEncode(Session("Products")) & "'") End If Case 3 If Session("ProjectID") = "" Then ErrorCount = ErrorCount + 1 ErrorMessage = ErrorMessage & "A Fatal error has occured. Ignore all other error messages and contact the Web master about this problem.
" Else Select Case Section Case "Add" For Each Province In OnePerLine(Session("Provinces")) If Trim(Province) <> "" Then ExistsProvince = TRUE Set RS = Conn.Execute("EXEC spSaveLocation " & Session("ProjectID") & ",'" & SQLEncode(Session("Country")) & "','" & SQLEncode(Trim(Province)) & "'") End If Next If ExistsProvince <> TRUE Then Set RS = Conn.Execute("EXEC spSaveLocation " & Session("ProjectID") & ",'" & SQLEncode(Session("Country")) & "','-ALL-'") End If Case "Edit" Set RS = Conn.Execute("EXEC spRemoveCountry " & Session("ProjectID") & ",'" & Session("Country") & "'") For Each Province In OnePerLine(Session("Provinces")) If Trim(Province) <> "" Then ExistsProvince = TRUE Set RS = Conn.Execute("EXEC spSaveLocation " & Session("ProjectID") & ",'" & SQLEncode(Session("Country")) & "','" & SQLEncode(Trim(Province)) & "'") End If Next If ExistsProvince <> TRUE Then Set RS = Conn.Execute("EXEC spSaveLocation " & Session("ProjectID") & ",'" & SQLEncode(Session("Country")) & "','-ALL-'") End If Case "Remove" If Session("Country") <> "" Then Set RS = Conn.Execute("EXEC spRemoveCountry " & Session("ProjectID") & ",'" & Session("Country") & "'") End If End Select Set RSCountries = Conn.Execute("EXEC spGetCountries " & Session("ProjectID")) While Not RSCountries.EOF Set RSProvinces = Conn.Execute("EXEC spGetProvinces " & Session("ProjectID") & ",'" & RSCountries("Country") & "'") While Not RSProvinces.EOF If Len(Provinces) <= 0 Then Provinces = RSProvinces("Province") Else Provinces = Provinces & ", " & RSProvinces("Province") End If RSProvinces.MoveNext WEnd If Len(Provinces) > 0 Then Provinces = "(" & Provinces & ")" End If If Len(Locations) <= 0 Then Locations = RSCountries("Country") & Provinces Else Locations = Locations & CHR(13) & CHR(10) & RSCountries("Country") & Provinces End If Provinces = "" RSCountries.MoveNext WEnd Session("Locations") = Locations End if Case 4 If Session("ProjectID") = "" Then ErrorCount = ErrorCount + 1 ErrorMessage = ErrorMessage & "A Fatal error has occured. Ignore all other error messages and contact the Web master about this problem.
" Else If Session("Request") <> "" Then Set RS = Conn.Execute("EXEC spSaveRequest " & Session("ProjectID") & ",'" & SQLEncode(Session("Request")) & "'") End If If Session("Notes") <> "" Then Set RS = Conn.Execute("EXEC spSaveNotes " & Session("ProjectID") & ",'" & SQLEncode(Session("Notes")) & "'") End If End If Set RS = Conn.Execute("EXEC spStopProject " & Session("ProjectID")) Set Mail = Server.CreateObject("Persits.MailSender") Mail.Host = Application("SMTPServer") Mail.From = "gap@uidaho.edu" Mail.FromName = "GAP Web Site" Mail.Subject = "New International Entry" Mail.Body = "A new international project has been entered. The browsing map may need updating." Mail.AddAddress("mattw@uidaho.edu") Mail.AddAddress("pcrist@uidaho.edu") Mail.Send Case Else Response.Write("Not a page to save!") End Select End Sub Sub StoreVariables(Page, Section) Select Case Page Case 1 Session("FirstName") = Trim(Request.Form("FirstName")) Session("LastName") = Trim(Request.Form("LastName")) Session("Institutions") = Trim(Request.Form("Institutions")) Session("Address") = Trim(Request.Form("Address")) Session("Phone") = Trim(Request.Form("Phone")) Session("PhoneExtension") = Trim(Request.Form("PhoneExtension")) Session("Fax") = Trim(Request.Form("Fax")) Session("EMail") = Trim(Request.Form("EMail")) Case 2 Session("Title") = Trim(Request.Form("Title")) Session("Description") = Trim(Request.Form("Description")) Session("Status") = Trim(Request.Form("Status")) Session("Keywords") = Trim(Request.Form("Keywords")) Session("WebSiteURL") = Trim(Request.Form("WebSiteURL")) Session("Products") = Trim(Request.Form("Products")) Case 3 Select Case Section Case "Add" Session("Country") = Trim(Request.Form("Country")) Session("Provinces") = Trim(Request.Form("Provinces")) Case "Edit" Session("Country") = Trim(Request.Form("Country")) Session("Provinces") = Trim(Request.Form("Provinces")) Case "Remove" Session("Location") = Trim(Request.Form("Location")) If (Session("Location") <> "") Then If Instr(Session("Location"), "(") Then Session("Country") = Left(Session("Location"), Instr(Session("Location"), "(") - 1) Else Session("Country") = Session("Location") End If Else Session("Country") = "" End If Case "Top" Session("Location") = Trim(Request.Form("Location")) If (Session("Location") <> "") Then If Instr(Session("Location"), "(") Then Session("Country") = Left(Session("Location"), Instr(Session("Location"), "(") - 1) Else Session("Country") = Session("Location") End If Else Session("Country") = "" End If End Select Case 4 Session("Request") = Trim(Request.Form("Request")) Session("Notes") = Trim(Request.Form("Notes")) End Select End Sub Private Sub CheckVariables(Page, Section) Select Case Page Case 1 Call ValidateNull("First/Given Name", Session("FirstName")) Call ValidateNull("Last/Family Name", Session("LastName")) Call ValidateNull("Institution(s)", Session("Institutions")) Call ValidateNull("Address", Session("Address")) Call ValidateNull("Phone", Session("Phone")) Call ValidateNull("E-mail Address", Session("EMail")) Call ValidatePhone("Phone", Session("Phone")) If Session("Fax") <> "" Then Call ValidatePhone("Fax", Session("Fax")) End If Call ValidateEMail("E-mail Address", Session("EMail")) Call ValidateMaxLength("First/Given Name", Session("FirstName"), 64) Call ValidateMaxLength("Last/Family Name", Session("LastName"), 64) Call ValidateMaxLength("Phone", Session("Phone"), 64) Call ValidateMaxLength("Phone Extension", Session("PhoneExtension"), 8) Call ValidateMaxLength("Fax", Session("Fax"), 64) Call ValidateMaxLength("E-mail", Session("EMail"), 64) Case 2 Call ValidateNull("Project Title", Session("Title")) Call ValidateNull("Description of Project", Session("Description")) Call ValidateNull("Status", Session("Status")) Call ValidateNull("Keywords", Session("Keywords")) If Session("WebSiteURL") <> "" Then Call ValidateURL("Web Site Address", Session("WebSiteURL")) Call ValidateMaxLength("Web Site Address", Session("WebSiteURL"), 128) End If Case 3 Select Case Section Case "Add" Call ValidateNull("Country", Session("Country")) Call ValidateMaxLength("Country", Session("Country"), 64) Case "Remove" Call ValidateSelected("Location", Session("Country")) Case "Edit" Call ValidateNull("Country", Session("Country")) Call ValidateMaxLength("Country", Session("Country"), 64) Case "Top" Call ValidateNull("Location(s)", Session("Locations")) Case Else Response.Write("Else! - CheckVariables Sub") End Select End Select End Sub Private Sub DrawPage(Page, Section) If ErrorCount > 0 Then Call Error() End If Select Case Page Case 0 Select Case Section Case "Saved" Response.Write("Your entry has been saved. Click here to continue.") Case "Cancel" Response.Write("Are you sure you want to cancel?") Response.Write("
") Response.Write("
") Response.Write("") Response.Write("

") Response.Write("
") Case "CancelYes" Response.Write("Your entry has been canceled. Click here to continue.") Case Else Response.Write("Else! - DrawForm - Case Section") End Select Case 1 Response.Write("All fields are required unless otherwise stated. Do not use the ""Back"" and ""Forward"" buttons on your browser.") Response.Write("
") Response.Write("
" & "First/Given Name:" & "
") Response.Write("
" & "Last/Family Name:" & "
") Response.Write("
" & "Institution(s):" & " " & "One per line." & "
") Response.Write("
" & "Address:" & " " & "Include city, state/provice, and postal code." & "
") Response.Write("
" & "Phone:" & " " & "Starting with country code, then a ""-"" (dash)." & "
" & "Extension:" & "
") Response.Write("
" & "Fax:" & " " & "Optional. Starting with country code, then a ""-"" (dash)." & "
") Response.Write("
" & "E-mail Address:" & "
") Response.Write("
") Response.Write("") Response.Write("

") Response.Write("
") Response.Write("Page " & Page & " of " & cNumberOfPages) Case 2 Response.Write("
") Response.Write("
" & "Project Title:" & "
") Response.Write("
" & "Description of Project:" & "
") Response.Write("
" & "Status:" & "
") Response.Write("
" & "Keywords:" & " " & "One per line." & "
") Response.Write("
" & "Web Site Address:" & " " & "Optional. Include the prefix. ie. ""http://""." & "
") Response.Write("
" & "Products:" & " " & "Optional. Any information about products that your project may have produced." & "
") Response.Write("
") Response.Write("") Response.Write("

") Response.Write("
") Response.Write("Page " & Page & " of " & cNumberOfPages) Case 3 Select Case Section Case "Add" Response.Write("
") Response.Write("
" & "Country:" & " " & "List only one country. No abbreviations." & "
") Response.Write("
" & "State(s)/Province(s):" & " " & "Leave blank if project covers the whole country. Otherwise list one per line. No abbreviations." & "
") Response.Write("
") Response.Write("") Response.Write("

") Response.Write("
") Response.Write("Page " & Page & "(" & Section & ") of " & cNumberOfPages) Case "Edit" Session("Provinces") = "" Set Conn = Server.CreateObject("ADODB.Connection") Conn.Open Application("DSN_International") Set RS = Conn.Execute("EXEC spGetProvinces " & Session("ProjectID") & ",'" & SQLEncode(Session("Country")) & "'") While Not RS.EOF If Session("Provinces") = "" Then Session("Provinces") = RS("Province") Else Session("Provinces") = Session("Provinces") & CHR(13) & CHR(10) & RS("Province") End If RS.MoveNext WEnd Response.Write("
") Response.Write("
" & "Country:" & " " & "List only one country. No abbreviations." & "
") Response.Write("
" & "State(s)/Province(s):" & " " & "Leave blank if project covers the whole country. Otherwise list one per line. No abbreviations." & "
") Response.Write("
") Response.Write("") Response.Write("

") Response.Write("
") Response.Write("Page " & Page & "(" & Section & ") of " & cNumberOfPages) Case Else Response.Write("
") If Session("Locations") <> "" Then Response.Write("
" & "Location(s):" & " " & "Use the ""Add"" button below to add a location. Select a location and use the ""Edit"" or ""Remove"" button to make changes." & "
") Response.Write("
") Else Response.Write("
" & "Location(s):" & " " & "Use the ""Add"" button below to add a location." & "
") End If Response.Write("") Response.Write("

") If Session("Locations") = "" Then Response.Write("

") Else Response.Write("

") End If Response.Write("
") Response.Write("

") Response.Write("
") Response.Write("Page " & Page & " of " & cNumberOfPages) End Select Case 4 Response.Write("
") Response.Write("
" & "Request for collaboration or assistance:" & " " & "Optional. No more than 600 words." & "
") Response.Write("
" & "Additonal information:" & " " & "Optional. No more than 600 words." & "
") Response.Write("") Response.Write("
") Response.Write("

") Response.Write("
") Response.Write("Page " & Page & " of " & cNumberOfPages) Case Else Response.Write("Else! - DrawForm") End Select End Sub Private Function AddBreaks(Value) AddBreaks = Replace(Value, CHR(13) & CHR(10), "
") End Function Private Sub Error() If ErrorCount > 1 Then Response.Write("The following " & ErrorCount & " errors occurred:
") Response.Write(ErrorMessage) Else Response.Write("The following error occurred:
") Response.Write(ErrorMessage) End If Response.Write("Please fix the problem, then continue.") End Sub Private Sub ValidateMaxLength(Name,Value,MaxLength) If Len(Value) > MaxLength Then ErrorCount = ErrorCount + 1 ErrorMessage = ErrorMessage & "" & Name & " can not be longer than " & MaxLength & " characters.
" End If End Sub Private Sub ValidateNull(Name,Value) If Len(Value) = 0 Then ErrorCount = ErrorCount + 1 ErrorMessage = ErrorMessage & "" & Name & " must be provided.
" End If End Sub Private Sub ValidatePhone(Name,Value) ' If contains anything other than 0-9 or "-" then fail. End Sub Private Sub ValidateEMail(Name,Value) If (Instr(Value,"@") = 0) OR (Instr(Value,".") = 0) Then ErrorCount = ErrorCount + 1 ErrorMessage = ErrorMessage & "" & Name & " must be an e-mail address of the form username@domain.ext.
" End If End Sub Private Sub ValidateURL(Name,Value) If (Instr(Value,":") = 0) OR (Instr(Value,".") = 0) OR (Instr(Value,"//") = 0) Then ErrorCount = ErrorCount + 1 ErrorMessage = ErrorMessage & "" & Name & " must be a properly formated URL. ie. http://www.gap.uidaho.edu/.
" End If End Sub Private Sub ValidateSelected(Name,Value) If Len(Value) = 0 Then ErrorCount = ErrorCount + 1 ErrorMessage = ErrorMessage & "A " & Name & " must be selected.
" End If End Sub Private Sub DeleteProject() Set Conn = Server.CreateObject("ADODB.Connection") Conn.Open Application("DSN_International") If Session("ProjectID") <> "" Then Set RS = Conn.Execute("EXEC spDeleteProject " & Session("ProjectID")) End If End Sub Private Function OnePerLine(Value) OnePerLine = Split(Value, CHR(13) & CHR(10)) End Function Function SQLEncode(SQLEncodeValue) SQLEncode = Replace(SQLEncodeValue, "'", "''") End Function %>

 

Literature  | About GAP | Projects and Products | Tools | Meetings | SearchLinks | Bulletin Boards  |  Site Map

 

USGS  ||Gap Analysis Program || NBII ||
Disclaimer
|| Privacy || Accessibility||
GAP Webmaster ||