Example #1
0
        private void btnTransaction_Click(object sender, EventArgs e)
        {
            int categoryID = 0;
            int counter    = 0;

            try
            {
                using (var ts = new TransactionScope(TransactionScopeOption.Required))
                {
                    var proxy = new wref.ProductClient();
                    categoryID = proxy.AddCategory("Electronic Products");
                    counter    = proxy.AddProduct(categoryID);

                    MessageBox.Show($"Num products inserted: {counter.ToString()}");

                    proxy.Close();
                    ts.Complete();
                }
            }
            catch (FaultException fex)
            {
                MessageBox.Show(fex.Message);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #2
0
        private void btnProdCateg_Click(object sender, EventArgs e)
        {
            try
            {
                for (int i = 1; i < 6; i++)
                {
                    _proxy.AddCategory($"Prod_{i.ToString()}");

                    Thread.Sleep(2000);
                }
            }
            catch (FaultException fex)
            {
                MessageBox.Show(fex.Message);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }