Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- namespace WebApplication1
- {
- public partial class WebForm1 : System.Web.UI.Page
- {
- private double a, b;
- private bool isNumbers(ref double a, ref double b)
- {
- return Double.TryParse(tbLeft.Text, out a) && Double.TryParse(tbRight.Text, out b);
- }
- private void showErrorInput()
- {
- result.Text = "Ошибка ввода данных!";
- }
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- protected void addition_Click(object sender, EventArgs e)
- {
- if (isNumbers(ref a, ref b))
- {
- result.Text = (a + b).ToString();
- }
- else
- {
- showErrorInput();
- }
- }
- protected void multiplication_Click(object sender, EventArgs e)
- {
- if (isNumbers(ref a, ref b))
- {
- result.Text = (a * b).ToString();
- }
- else
- {
- showErrorInput();
- }
- }
- protected void division_Click(object sender, EventArgs e)
- {
- if (isNumbers(ref a, ref b) && b!=0)
- {
- result.Text = (a / b).ToString();
- }
- else
- {
- showErrorInput();
- }
- }
- protected void subtraction_Click(object sender, EventArgs e)
- {
- if (isNumbers(ref a, ref b))
- {
- result.Text = (a - b).ToString();
- }
- else
- {
- showErrorInput();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement