{
public partial
class WebForm1 : System.Web.UI.Page
{
protected void
Page_Load(object sender,
EventArgs e)
{
TextBox4.Focus();
}
protected void
Button1_Click(object sender,
EventArgs e)
{
if (string.IsNullOrEmpty(TextBox4.Text)
|| string.IsNullOrEmpty(TextBox1.Text))
{
Label5.Text =
"Please Enter Some Values"; Label5.ForeColor
= System.Drawing.Color.Red;
}
else
{
Arthmetic
objArithmetic = Arthmetic.Addition; DoArithmetic(objArithmetic);
}
}
protected void
Button2_Click(object sender,
EventArgs e)
{
if (string.IsNullOrEmpty(TextBox4.Text)
|| string.IsNullOrEmpty(TextBox1.Text))
{
Label5.Text =
"Please Enter Some Values";
Label5.ForeColor = System.Drawing.Color.Red;
}
else
{
Arthmetic
objArithmetic = Arthmetic.Substraction; DoArithmetic(objArithmetic);
}
}
protected void
Button3_Click(object sender,
EventArgs e)
{
if (string.IsNullOrEmpty(TextBox4.Text)
|| string.IsNullOrEmpty(TextBox1.Text))
{
Label5.Text =
"Please Enter Some Values";
Label5.ForeColor = System.Drawing.Color.Red;
}
else
{
Arthmetic
objArithmetic = Arthmetic.Multiplication; DoArithmetic(objArithmetic);
}
}
protected void
Button4_Click(object sender,
EventArgs e)
{
if (string.IsNullOrEmpty(TextBox4.Text)
|| string.IsNullOrEmpty(TextBox1.Text))
{
Label5.Text =
"Please Enter Some Values";
Label5.ForeColor = System.Drawing.Color.Red;
}
else
{
Arthmetic
objArithmetic = Arthmetic.Division; DoArithmetic(objArithmetic);
}
}
protected void
DoArithmetic(Arthmetic objArthmetic)
{
switch (objArthmetic)
{
case Arthmetic.Addition:
Label5.Text =
"Addition Result is " + (double.Parse(TextBox4.Text)
+ double.Parse(TextBox1.Text)).ToString();
Label5.ForeColor = System.Drawing.Color.Green;
TextBox1.Text
= string.Empty;
TextBox4.Text
= string.Empty;
break;
case Arthmetic.Substraction:
Label5.Text = "Substraction Result is " + (double.Parse(TextBox4.Text)
- double.Parse(TextBox1.Text));
Label5.ForeColor = System.Drawing.Color.Green;
TextBox1.Text = string.Empty;
TextBox4.Text = string.Empty;
break;
case
Arthmetic.Multiplication:
Label5.Text = "Multiplication Result is " + (double.Parse(TextBox4.Text)
* double.Parse(TextBox1.Text));
Label5.ForeColor = System.Drawing.Color.Green;
TextBox1.Text = string.Empty;
TextBox4.Text = string.Empty;
break;
case Arthmetic.Division:
Label5.Text = "Division Result is " + (double.Parse(TextBox4.Text)
/ double.Parse(TextBox1.Text));
Label5.ForeColor = System.Drawing.Color.Green;
TextBox1.Text = string.Empty;
TextBox4.Text = string.Empty;
break;
}
}
}
}