Wrox Home  
 
Search P2P Archive for  go

More Wrox Resources

  Return to Index  

asp_web_howto thread: Final price calcuation for a resort


Message #1 by "Ricardo Hernandez" <richhern35@h...> on Wed, 23 Jan 2002 13:04:03
Hi my name is Ricardo Hernandez. And I am working at a resort place in 

italy. I want to impress my boss with a page in which the users can enter 

the start date and end date they plan to stay in the resort. The system 

should calculate the final price. However there are some complications 

because we divided the year in three different seasons. And each season 

has a different set of prices.Which means the customer may want to get the 

final price for days that correspond to the winter and the spring season 

which have different rates. 



If you have some ideas or some code I can modify can be greatly 

appreciated. 

Message #2 by "O'Hara, Elliott M" <EMOHARA@k...> on Wed, 23 Jan 2002 09:04:29 -0500
well ricardo,

	From scratch?????



Well....



Your lucky I'm bored....

this is just a start...

hasn't been dubugged and there is a lot more needed,

but you should get the idea

write now it will work as long as they start in the first season, and don't

stay for more than a year, but you need to think about things like that...





Elliott

PS - I do consulting work (just don't tell NASA)

:~)



<%option explicit

dim monPrice1,monPrice2,monPrice3

dim dtSeason1,dtSeason2,dtSeason3 ' these are your season dates

dim NumDays,NumDays1,NumDays2,NumDays3 ' the Number of days theyll stay

dim dtStart,dtEnd ' day they come and leave

dim monPrice ' what they pay

monPrice1 = 100 ' price per day for 1st Season

monPrice2 = 125 ' get the idea?

monPrice3 = 150 ' you know???

%>

<html><head><title>Elliott Gets to stay for Free</title></head>

<body>

<!-- make the form -->

<form method="post">

Start Date

<input type="text" name="dtStart">

<br />

End Date

<input type="text" name="dtEnd">

<br />

<input type = "submit" value="Calculate Price">

</form>

<% 

' have they submitted the form???

if Request.Form("dtStart")<>"" and Request.Form("dtEnd")<>"" then



dtStart = cdate(Request.form("dtStart"))

dtEnd = cdate(Request.form("dtEnd"))



dtSeason1 = dateserial(year(dtStart),1,1) ' Jan 1, the year they selected

dtSeason2 = dateserial(year(dtStart),4,1) ' April FOOLS!!!

dtSeason3 = dateserial(year(dtStart),7,1) ' thats umm i think July 1st...



NumDays = dateDiff("d",dtStart,dtEnd)



if  dtStart<dtSeason2 and dtStart<dtSeason3 then

if NumDays<datediff("d",dtSeason1,dtSeason2) then ' then its only 1st season

	monPrice = NumDays*MonPrice1

else ' go to the second season

	monPrice = dateDiff("d",dtStart,dtSeason2)*monPrice1 ' first season

	if dtEnd<dtSeason3 then ' the rest is second season

	monPrice = monPrice + dateDiff("d",dtSeason2,dtEnd)*monPrice2

	else ' they stayed the WHOLE SECOND SEASON!!!

	monPrice=monPrice + dateDiff("d",dtSeason2,dtSeason3)*monPrice2

	monPrice = monPrice + dateDiff("d",dtSeason3,dtEnd)*monPrice3

	end if

end if



elseif dtStart<dtSeason3 and dtStart>dtSeason2 then

	' they started in season 2

	' I don't want to write any more....

else 

	' they must be starting in the 3rd season

	' I don't wanna do this eather.....

	

end if



Response.Write "FROM " & dtStart & " TO " & dtEnd & "<br />"

Response.Write "PRICE IS "&monPrice 





end if

%>



-----Original Message-----

From: Ricardo Hernandez [mailto:richhern35@h...]

Sent: Wednesday, January 23, 2002 8:04 AM

To: ASP Web HowTo

Subject: [asp_web_howto] Final price calcuation for a resort





Hi my name is Ricardo Hernandez. And I am working at a resort place in 

italy. I want to impress my boss with a page in which the users can enter 

the start date and end date they plan to stay in the resort. The system 

should calculate the final price. However there are some complications 

because we divided the year in three different seasons. And each season 

has a different set of prices.Which means the customer may want to get the 

final price for days that correspond to the winter and the spring season 

which have different rates. 



If you have some ideas or some code I can modify can be greatly 

appreciated. 






$subst('Email.Unsub').

Message #3 by "ricardo hernandez" <richhern35@h...> on Thu, 24 Jan 2002 02:23:21 -0700
Thank you for your prompt response. I am going to try it to utilize your 

logic and start programing this thing.



Sincerely,



Ricardo Hernandez





>From: "O'Hara, Elliott M" <EMOHARA@k...>

>Reply-To: "ASP Web HowTo" <asp_web_howto@p...>

>To: "ASP Web HowTo" <asp_web_howto@p...>

>Subject: [asp_web_howto] RE: Final price calcuation for a resort

>Date: Wed, 23 Jan 2002 09:04:29 -0500

>

>well ricardo,

>	From scratch?????

>

>Well....

>

>Your lucky I'm bored....

>this is just a start...

>hasn't been dubugged and there is a lot more needed,

>but you should get the idea

>write now it will work as long as they start in the first season, and don't

>stay for more than a year, but you need to think about things like that...

>

>

>Elliott

>PS - I do consulting work (just don't tell NASA)

>:~)

>

><%option explicit

>dim monPrice1,monPrice2,monPrice3

>dim dtSeason1,dtSeason2,dtSeason3 ' these are your season dates

>dim NumDays,NumDays1,NumDays2,NumDays3 ' the Number of days theyll stay

>dim dtStart,dtEnd ' day they come and leave

>dim monPrice ' what they pay

>monPrice1 = 100 ' price per day for 1st Season

>monPrice2 = 125 ' get the idea?

>monPrice3 = 150 ' you know???

>%>

><html><head><title>Elliott Gets to stay for Free</title></head>

><body>

><!-- make the form -->

><form method="post">

>Start Date

><input type="text" name="dtStart">

><br />

>End Date

><input type="text" name="dtEnd">

><br />

><input type = "submit" value="Calculate Price">

></form>

><%

>' have they submitted the form???

>if Request.Form("dtStart")<>"" and Request.Form("dtEnd")<>"" then

>

>dtStart = cdate(Request.form("dtStart"))

>dtEnd = cdate(Request.form("dtEnd"))

>

>dtSeason1 = dateserial(year(dtStart),1,1) ' Jan 1, the year they selected

>dtSeason2 = dateserial(year(dtStart),4,1) ' April FOOLS!!!

>dtSeason3 = dateserial(year(dtStart),7,1) ' thats umm i think July 1st...

>

>NumDays = dateDiff("d",dtStart,dtEnd)

>

>if  dtStart<dtSeason2 and dtStart<dtSeason3 then

>if NumDays<datediff("d",dtSeason1,dtSeason2) then ' then its only 1st 

>season

>	monPrice = NumDays*MonPrice1

>else ' go to the second season

>	monPrice = dateDiff("d",dtStart,dtSeason2)*monPrice1 ' first season

>	if dtEnd<dtSeason3 then ' the rest is second season

>	monPrice = monPrice + dateDiff("d",dtSeason2,dtEnd)*monPrice2

>	else ' they stayed the WHOLE SECOND SEASON!!!

>	monPrice=monPrice + dateDiff("d",dtSeason2,dtSeason3)*monPrice2

>	monPrice = monPrice + dateDiff("d",dtSeason3,dtEnd)*monPrice3

>	end if

>end if

>

>elseif dtStart<dtSeason3 and dtStart>dtSeason2 then

>	' they started in season 2

>	' I don't want to write any more....

>else

>	' they must be starting in the 3rd season

>	' I don't wanna do this eather.....

>

>end if

>

>Response.Write "FROM " & dtStart & " TO " & dtEnd & "<br />"

>Response.Write "PRICE IS "&monPrice

>

>

>end if

>%>

>

>-----Original Message-----

>From: Ricardo Hernandez [mailto:richhern35@h...]

>Sent: Wednesday, January 23, 2002 8:04 AM

>To: ASP Web HowTo

>Subject: [asp_web_howto] Final price calcuation for a resort

>

>

>Hi my name is Ricardo Hernandez. And I am working at a resort place in

>italy. I want to impress my boss with a page in which the users can enter

>the start date and end date they plan to stay in the resort. The system

>should calculate the final price. However there are some complications

>because we divided the year in three different seasons. And each season

>has a different set of prices.Which means the customer may want to get the

>final price for days that correspond to the winter and the spring season

>which have different rates.

>

>If you have some ideas or some code I can modify can be greatly

>appreciated.

>




>$subst('Email.Unsub').

>




>$subst('Email.Unsub').









_________________________________________________________________

Join the world?s largest e-mail service with MSN Hotmail. 

http://www.hotmail.com




  Return to Index