using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebServices
{
public partial class CalculatorSvcExample :
System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnAdd_Click(object sender, EventArgs e)
{
double val1,
val2, result;
if (double.TryParse(txtValue1.Text, out val1) &&
double.TryParse(txtValue2.Text,
out val2))
{
//
Create a web service proxy object
CalculatorSvc.Calculator pxy = new CalculatorSvc.Calculator();
//
Call the Add method via proxy object
result = pxy.Add(val1, val2);
lblDisplay.Text
= "The result is
" + result;
}
else
{
lblDisplay.Text
= "You must enter numerical values for
both X and Y!";
}
}
protected void btnSubtract_Click(object sender, EventArgs e)
{
double val1,
val2, result;
if (double.TryParse(txtValue1.Text, out val1) &&
double.TryParse(txtValue2.Text,
out val2))
{
//
Create a web service proxy object
CalculatorSvc.Calculator pxy = new CalculatorSvc.Calculator();
//
Call the Add method via proxy object
result = pxy.Subtract(val1, val2);
lblDisplay.Text
= "The result is
" + result;
}
else
{
lblDisplay.Text
= "You must enter numerical values for
both X and Y!";
}
}
protected void btnMultiply_Click(object sender, EventArgs e)
{
double val1,
val2, result;
if (double.TryParse(txtValue1.Text, out val1) &&
double.TryParse(txtValue2.Text,
out val2))
{
//
Create a web service proxy object
CalculatorSvc.Calculator pxy = new CalculatorSvc.Calculator();
//
Call the Add method via proxy object
result = pxy.Multiply(val1, val2);
lblDisplay.Text
= "The result is
" + result;
}
else
{
lblDisplay.Text
= "You must enter numerical values for
both X and Y!";
}
}
protected void btnDivide_Click(object sender, EventArgs e)
{
double val1,
val2, result;
if (double.TryParse(txtValue1.Text, out val1) &&
double.TryParse(txtValue2.Text,
out val2))
{
//
Create a web service proxy object
CalculatorSvc.Calculator pxy = new CalculatorSvc.Calculator();
//
Call the Add method via proxy object
result = pxy.Divide(val1, val2);
lblDisplay.Text
= "The result is
" + result;
}
else
{
lblDisplay.Text = "You must enter numerical values for both X and Y!";
}
}
}
}