Ejemplo n.º 1
0
 private void button2_Click(object sender, EventArgs e)
 {
     MathServiceReference.MyNumbers obj = new MathServiceReference.MyNumbers();
     obj.Number1   = Convert.ToInt32(textBox1.Text);
     obj.Number2   = Convert.ToInt32(textBox2.Text);
     textBox3.Text = proxy.Subtract(obj).ToString();
 }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            MathServiceReference.MyNumbers o1 = new MathServiceReference.MyNumbers();
            o1.Number1 = Convert.ToInt32(textBox1.Text);
            o1.Number2 = Convert.ToInt32(textBox2.Text);
            int c = obj.Add(o1);

            textBox3.Text = c.ToString();
        }
Ejemplo n.º 3
0
        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                MathServiceReference.MyNumbers obj = new MathServiceReference.MyNumbers();
                obj.Number1 = Convert.ToInt32(textBox1.Text);
                obj.Number2 = Convert.ToInt32(textBox2.Text);

                textBox3.Text = proxy.Divide(obj).ToString();
            }
            //catch(System.DivideByZeroException dbze)
            //{
            //    MessageBox.Show(dbze.Message);
            //}
            //catch(Exception ex)
            //{
            //    MessageBox.Show(ex.Message);
            //}
            //catch (FaultException faultException)
            //{
            //    MessageBox.Show(faultException.Message + "\n\n" + "Try again!.", "Division problem");
            //}

            //catch (FaultException fex)
            //{
            //    switch (fex.Code.Name)
            //    {
            //        case "BValueIsZero":
            //            MessageBox.Show(
            //              fex.Message + "\n\n" +
            //              "Try again!.", "Division problem");
            //            break;
            //        case "BValueIsAboveHundred":
            //            MessageBox.Show(
            //              fex.Message + "\n\n" +
            //              "Try again!.", "MaxValue problem");
            //            break;
            //        default:
            //            MessageBox.Show(
            //              fex.Message, "Error");
            //            break;
            //    }
            //}

            catch (FaultException <DivisionFault> fex)
            {
                MessageBox.Show(String.Format("{0}\n\n" +
                                              "The following error occurred in {1}:\n{2}",
                                              fex.Detail.Reason,
                                              fex.Detail.Method,
                                              fex.Detail.Message),
                                "Division problem");
            }
        }
Ejemplo n.º 4
0
        private void btnDivide_Click(object sender, EventArgs e)
        {
            try
            {
                int num1 = int.Parse(txtNumber1.Text);
                int num2 = int.Parse(txtNumber2.Text);

                var myNum = new wref.MyNumbers
                {
                    Number1 = num1,
                    Number2 = num2
                };

                var res = _client.Divide(myNum);
                txtResult.Text = res.ToString();
            }
            //catch (DivideByZeroException dex)
            //{
            //    MessageBox.Show(dex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //}
            //catch (FaultException fex)
            //{
            //    //MessageBox.Show(fex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //    // Show message according to fault code
            //    switch (fex.Code.Name)
            //    {
            //        case "DivisorAbove100":
            //            MessageBox.Show(fex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //            break;
            //        case "DivisorIsZero":
            //            MessageBox.Show(fex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //            break;
            //        default:
            //            MessageBox.Show(fex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //            break;
            //    }
            //}
            catch (FaultException <wref.DivisionFault> fex)
            {
                var msg =
                    $@"{fex.Detail.Reason}
The following error occurred in {fex.Detail.Method}:
{fex.Detail.Message}";
                MessageBox.Show(msg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 5
0
        private void btnSubtract_Click(object sender, EventArgs e)
        {
            int num1 = int.Parse(txtNumber1.Text);
            int num2 = int.Parse(txtNumber2.Text);

            var myNum = new MathServiceReference.MyNumbers
            {
                Number1 = num1,
                Number2 = num2
            };

            var res = _client.Subtract(myNum);

            txtResult.Text = res.ToString();
        }
Ejemplo n.º 6
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            int num1 = int.Parse(txtNumber1.Text);
            int num2 = int.Parse(txtNumber2.Text);

            var myNum = new wref.MyNumbers
            {
                Number1 = num1,
                Number2 = num2
            };

            var res = _client.Add(myNum);

            txtResult.Text = res.ToString();
        }
Ejemplo n.º 7
0
        private void button4_Click(object sender, EventArgs e)
        {
            try
            {
                MathServiceReference.MyNumbers obj = new MathServiceReference.MyNumbers();
                obj.Number1 = Convert.ToInt32(textBox1.Text);
                obj.Number2 = Convert.ToInt32(textBox2.Text);

                proxy.DivideInOneWay(obj);
            }
            catch (System.DivideByZeroException dbze)
            {
                MessageBox.Show(dbze.Message);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 8
0
        private void btnDivideOneWay_Click(object sender, EventArgs e)
        {
            try
            {
                int num1 = int.Parse(txtNumber1.Text);
                int num2 = int.Parse(txtNumber2.Text);

                var myNum = new wref.MyNumbers
                {
                    Number1 = num1,
                    Number2 = num2
                };

                _client.DivideOneWay(myNum);
            }
            catch (DivideByZeroException dex)
            {
                MessageBox.Show(dex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }