fishbone34
02-08-2005, 09:00 PM
Hello, I have a Asp page that inputs data from a Form into a table. It will Also Email the Person the Forms' data is for.
MY problem:
From the Form data, there is a WIP entry " wip=request.form("wip") ". This WIP entry can either be YES or NO. If the WIP from the form is YES I do not want to email the agent. If it is NO, then I would want to email the Agent.
How can I add a IF/THEN process in the below Code?
NOTE: I have noted where the Email process Begins and Ends
Here is MY CODE:
<html>
<head>
<meta name="keywords" content="DoNotBrowse">
<title>EDIT Ticket Documentation- Form Processing</title>
</head>
<body bgcolor="#ffffff">
<%
'Declare all form variables
DATED=request.form("DATED")
TIMED=request.form("TIMED")
AGENT=request.form("AGENT")
MONITOR=request.form("MONITOR")
HotelCode=UCase(request.form("HotelCode"))
ticket=request.form("ticket")
Q1=request.form("Q1")
C1=request.form("C1")
Q2=request.form("Q2")
C2=request.form("C2")
Q3=request.form("Q3")
C3=request.form("C3")
Q4=request.form("Q4")
C4=request.form("C4")
Q5=request.form("Q5")
C5=request.form("C5")
Q6=request.form("Q6")
C6=request.form("C6")
Q7=request.form("Q7")
C7=request.form("C7")
Q8=request.form("Q8")
C8=request.form("C8")
Q9=request.form("Q9")
C9=request.form("C9")
Q10=request.form("Q10")
C10=request.form("C10")
Q11=request.form("Q11")
C11=request.form("C11")
Q12=request.form("Q12")
C12=request.form("C12")
Q13=request.form("Q13")
C13=request.form("C13")
wip=request.form("wip")
'Must replace any apostrophe's in the problem description with 2 apostrophe's for SQL
C1 = request.form("C1")
C1 = replace (C1, "'", "''")
C2 = request.form("C2")
C2 = replace (C2, "'", "''")
C3 = request.form("C3")
C3 = replace (C3, "'", "''")
C4 = request.form("C4")
C4 = replace (C4, "'", "''")
C5 = request.form("C5")
C5 = replace (C5, "'", "''")
C6 = request.form("C6")
C6 = replace (C6, "'", "''")
C7 = request.form("C7")
C7 = replace (C7, "'", "''")
C8 = request.form("C8")
C8 = replace (C8, "'", "''")
C9 = request.form("C9")
C9 = replace (C9, "'", "''")
C10 = request.form("C10")
C10 = replace (C10, "'", "''")
C11 = request.form("C11")
C11 = replace (C11, "'", "''")
C12 = request.form("C12")
C12 = replace (C12, "'", "''")
C13 = request.form("C13")
C13 = replace (C13, "'", "''")
'Connect to database to upload all form data.
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Provider=SQLOLEDB;Data Source=xx.xxx.xxx.xx;database=TESTDB;uid=xx;pwd=xxxxxxx;"
'Get Phone_ID of the Agent from their name
nameArray = split(Agent,",")
lname = nameArray(0)
fname = nameArray(1)
query1 = "Select first_name, Last_name, Phone_Id, email from tb_Employee where last_name = '"&lname&"' and first_name = '"&fname&"'"
set objRS=Conn.execute(query1)
Phone_Id = objRS("Phone_ID")
t1 = objRS("first_name")
t2 = objRS("Last_Name")
t3 = objRS("email")
update1 = "UPDATE TICKETDOC SET HOTELCODE = '"&HotelCode&"', TICKET = '"&Ticket&"', Q1 = '"&Q1&"',C1 = '"&C1&"',"
update1 = update1 & "Q2 = '"&Q2&"', C2 = '"&C2&"',Q3 = '"&Q3&"', C3 = '"&C3&"',Q4 = '"&Q4&"', C4 = '"&C4&"',"
update1 = update1 & "Q5 = '"&Q5&"', C5 = '"&C5&"',Q6 = '"&Q6&"', C6 = '"&C6&"',Q7 = '"&Q7&"', C7 = '"&C7&"',"
update1 = update1 & "Q8 = '"&Q8&"', C8 = '"&C8&"',Q9 = '"&Q9&"', C9 = '"&C9&"',Q10 = '"&Q10&"', C10 = '"&C10&"',"
update1 = update1 & "Q11 = '"&Q11&"', C11 = '"&C11&"', Q12 = '"&Q12&"', C12 = '"&C12&"', Q13 = '"&Q13&"', C13 = '"&C13&"', wip = '"&wip&"' WHERE "
update1 = update1 & "AGENT = '"&Agent&"' AND DATED = '"&DATED&"' AND TIMED = '"&TIMED&"'"
set objRS=Conn.execute(update1)
' NOTE NOTE NOTE This Part EMAILS the Agent
Dim t1name,t1,t2name,t2,t3name,t3
t2name = "Your Service Observation is ready to view: "
Dim ObjMail
Set ObjMail = Server.CreateObject("CDONTS.NewMail")
ObjMail.To = t3
ObjMail.From = "*schamergccweb@6c.com"
ObjMail.Subject = "Your Service Observation is ready to view"
ObjMail.Body = t2name & t2
ObjMail.Send
Set ObjMail = Nothing
Response.Write"An Email Has been Sent to the Agent."
' NOTE NOTE NOTE End of Email Section.
%>
<CENTER>
<img src="serviceOps.gif" alt="" height="112" width="561" border="0" livesrc="serviceOps.gif"><BR>
<font size="3" face="Arial"><BR><BR><BR><BR>
Ticket Documentation Results Successfully Updated!.<BR>
</center>
</body>
</html>
MY problem:
From the Form data, there is a WIP entry " wip=request.form("wip") ". This WIP entry can either be YES or NO. If the WIP from the form is YES I do not want to email the agent. If it is NO, then I would want to email the Agent.
How can I add a IF/THEN process in the below Code?
NOTE: I have noted where the Email process Begins and Ends
Here is MY CODE:
<html>
<head>
<meta name="keywords" content="DoNotBrowse">
<title>EDIT Ticket Documentation- Form Processing</title>
</head>
<body bgcolor="#ffffff">
<%
'Declare all form variables
DATED=request.form("DATED")
TIMED=request.form("TIMED")
AGENT=request.form("AGENT")
MONITOR=request.form("MONITOR")
HotelCode=UCase(request.form("HotelCode"))
ticket=request.form("ticket")
Q1=request.form("Q1")
C1=request.form("C1")
Q2=request.form("Q2")
C2=request.form("C2")
Q3=request.form("Q3")
C3=request.form("C3")
Q4=request.form("Q4")
C4=request.form("C4")
Q5=request.form("Q5")
C5=request.form("C5")
Q6=request.form("Q6")
C6=request.form("C6")
Q7=request.form("Q7")
C7=request.form("C7")
Q8=request.form("Q8")
C8=request.form("C8")
Q9=request.form("Q9")
C9=request.form("C9")
Q10=request.form("Q10")
C10=request.form("C10")
Q11=request.form("Q11")
C11=request.form("C11")
Q12=request.form("Q12")
C12=request.form("C12")
Q13=request.form("Q13")
C13=request.form("C13")
wip=request.form("wip")
'Must replace any apostrophe's in the problem description with 2 apostrophe's for SQL
C1 = request.form("C1")
C1 = replace (C1, "'", "''")
C2 = request.form("C2")
C2 = replace (C2, "'", "''")
C3 = request.form("C3")
C3 = replace (C3, "'", "''")
C4 = request.form("C4")
C4 = replace (C4, "'", "''")
C5 = request.form("C5")
C5 = replace (C5, "'", "''")
C6 = request.form("C6")
C6 = replace (C6, "'", "''")
C7 = request.form("C7")
C7 = replace (C7, "'", "''")
C8 = request.form("C8")
C8 = replace (C8, "'", "''")
C9 = request.form("C9")
C9 = replace (C9, "'", "''")
C10 = request.form("C10")
C10 = replace (C10, "'", "''")
C11 = request.form("C11")
C11 = replace (C11, "'", "''")
C12 = request.form("C12")
C12 = replace (C12, "'", "''")
C13 = request.form("C13")
C13 = replace (C13, "'", "''")
'Connect to database to upload all form data.
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Provider=SQLOLEDB;Data Source=xx.xxx.xxx.xx;database=TESTDB;uid=xx;pwd=xxxxxxx;"
'Get Phone_ID of the Agent from their name
nameArray = split(Agent,",")
lname = nameArray(0)
fname = nameArray(1)
query1 = "Select first_name, Last_name, Phone_Id, email from tb_Employee where last_name = '"&lname&"' and first_name = '"&fname&"'"
set objRS=Conn.execute(query1)
Phone_Id = objRS("Phone_ID")
t1 = objRS("first_name")
t2 = objRS("Last_Name")
t3 = objRS("email")
update1 = "UPDATE TICKETDOC SET HOTELCODE = '"&HotelCode&"', TICKET = '"&Ticket&"', Q1 = '"&Q1&"',C1 = '"&C1&"',"
update1 = update1 & "Q2 = '"&Q2&"', C2 = '"&C2&"',Q3 = '"&Q3&"', C3 = '"&C3&"',Q4 = '"&Q4&"', C4 = '"&C4&"',"
update1 = update1 & "Q5 = '"&Q5&"', C5 = '"&C5&"',Q6 = '"&Q6&"', C6 = '"&C6&"',Q7 = '"&Q7&"', C7 = '"&C7&"',"
update1 = update1 & "Q8 = '"&Q8&"', C8 = '"&C8&"',Q9 = '"&Q9&"', C9 = '"&C9&"',Q10 = '"&Q10&"', C10 = '"&C10&"',"
update1 = update1 & "Q11 = '"&Q11&"', C11 = '"&C11&"', Q12 = '"&Q12&"', C12 = '"&C12&"', Q13 = '"&Q13&"', C13 = '"&C13&"', wip = '"&wip&"' WHERE "
update1 = update1 & "AGENT = '"&Agent&"' AND DATED = '"&DATED&"' AND TIMED = '"&TIMED&"'"
set objRS=Conn.execute(update1)
' NOTE NOTE NOTE This Part EMAILS the Agent
Dim t1name,t1,t2name,t2,t3name,t3
t2name = "Your Service Observation is ready to view: "
Dim ObjMail
Set ObjMail = Server.CreateObject("CDONTS.NewMail")
ObjMail.To = t3
ObjMail.From = "*schamergccweb@6c.com"
ObjMail.Subject = "Your Service Observation is ready to view"
ObjMail.Body = t2name & t2
ObjMail.Send
Set ObjMail = Nothing
Response.Write"An Email Has been Sent to the Agent."
' NOTE NOTE NOTE End of Email Section.
%>
<CENTER>
<img src="serviceOps.gif" alt="" height="112" width="561" border="0" livesrc="serviceOps.gif"><BR>
<font size="3" face="Arial"><BR><BR><BR><BR>
Ticket Documentation Results Successfully Updated!.<BR>
</center>
</body>
</html>