示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            int Counter = 0;

            try
            {
                using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
                {
                    ProductsClient proxy = new ProductsClient();
                    proxy.AddCateogry("Electronic Products");
                    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..");
            }
        }