コード例 #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();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            ProductsClient client   = new ProductsClient();
            string         cateName = client.GetCategoryName(1);

            Console.WriteLine(cateName);
            Console.Read();
        }
コード例 #3
0
 private static void GetCategoryName(int ProductID)
 {
     try
     {
         ProductsClient client       = new ProductsClient();
         string         CategoryName = client.GetCategoryName(ProductID);
         Console.WriteLine(string.Format("Category name {0} for Product ID {1}", CategoryName, ProductID));
     }
     catch (FaultException <ServiceException> ex)
     {
         Console.WriteLine(string.Format("Errors occured in service : {0} ", ex.Detail.Message));
     }
 }
コード例 #4
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();
        }