Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            int CategoryID = 0;
            int Counter    = 0;

            try
            {
                using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
                {
                    ProductsClient proxy = new ProductsClient();
                    //CategoryID = proxy.AddCategory("Electronic Products");

                    proxy.AddCategory("Electronic Products");

                    //Counter = proxy.AddProducts(CategoryID);
                    Counter = proxy.AddProducts();

                    MessageBox.Show("Number of Products inserted are : " + Counter.ToString());

                    proxy.Close();
                    ts.Complete();
                }
            }
            catch (FaultException fex)
            {
                MessageBox.Show(fex.Message + "\n\n" +
                                "Products could not be added..");
            }
        }
Пример #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                for (int i = 1; i <= 5; i++)
                {
                    proxy.AddCategory("Electronic Products " + i.ToString());

                    System.Threading.Thread.Sleep(new TimeSpan(0, 0, 2));
                }
            }
            catch (FaultException fex)
            {
                MessageBox.Show(fex.Message + "\n\n" +
                                "Categories could not be added..");
            }
        }