You are on page 1of 3

‘Web Service implementation

Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the
following line.
' <System.Web.Script.Services.ScriptService()> _
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class WebService
Inherits System.Web.Services.WebService

<WebMethod()> _
Public Function reserve(ByVal roomtype1 As String, ByVal roomtype2 As String, ByVal
sdate As Date, ByVal edate As Date) As Boolean
Dim r As Boolean
If roomtype1 = "delux" Or roomtype2 = "ordinary" Then
If sdate.Date.Day.ToString = "30" Or edate.Date.Day.ToString = "30" Then
r = False
Else
r = True
End If
End If
Return r
End Function
<WebMethod()> _
Public Function price(ByVal roomtype1 As String) As Double
Dim pr As Double
If roomtype1 = "delux" Then
pr = 5000
ElseIf roomtype1 = "A" Then
pr = 3000
ElseIf roomtype1 = "ordinary" Then
pr = 1000
End If
Return pr
End Function
<WebMethod()> _
Public Function desc() As String
Return " No one vegitarian hotel"
End Function
<WebMethod()> _
Public Function room() As String
Return "300 delux rooms,200 A class rooms and 100 ordinary rooms"
End Function
<WebMethod()> _
Public Function food() As String
Return "Both chinece,fast food varities are available"
End Function
End Class
‘Web Service Application
Imports localhost
Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)


Handles Button1.Click
Dim s As String
Dim ws As New localhost.WebService

s = ws.reserve("delux", "ordinary", "9/28/2010", "10/1/2010")


If s = True Then
TextBox1.Text = "Available"
TextBox2.Text = ws.price("delux")
TextBox3.Text = ws.desc()
TextBox4.Text = ws.room()
TextBox5.Text = ws.food()
Else
TextBox1.Text = "Not available"
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
End If
End Sub
End Class

You might also like