Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("ID: ");
            int id = Int32.Parse(Console.ReadLine());

            // Take a Category ID and name
            CategoryClient client = new CategoryClient();

            client.Open();
            Console.WriteLine(client.GetCategoryID(id));
            Console.WriteLine("\r\n");
            Console.WriteLine(client.GetCategoryName(id));
            client.Close();

            ProductsClient productClient = new ProductsClient();

            productClient.Open();
            Console.WriteLine(productClient.GetCategoryName(id));
            Console.WriteLine("\r\n");
            Console.WriteLine(productClient.GetProductName(id));
            Console.WriteLine("\r\n");
            Console.WriteLine(productClient.GetProductQty(id));
            Console.WriteLine("\r\n");
            Console.WriteLine(productClient.GetCategoryID(id));
            productClient.Close();

            Console.ReadKey();
        }
Ejemplo n.º 2
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..");
            }
        }
Ejemplo n.º 3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            int            id     = 1;
            CategoryClient client = new CategoryClient();

            client.Open();
            txtCategoryID.Text   = client.GetCategoryID(id).ToString();
            txtCategoryName.Text = client.GetCategoryName(id);
            client.Close();

            ProductsClient productClient = new ProductsClient();

            productClient.Open();
            txtProductID.Text           = id.ToString();
            txtProductName.Text         = productClient.GetProductName(id).ToString();
            txtProductCategoryID.Text   = productClient.GetCategoryID(id).ToString();
            txtProductCategoryName.Text = productClient.GetCategoryName(id).ToString();
            txtProductQty.Text          = productClient.GetProductQty(id).ToString();
            productClient.Close();
        }