Exemple #1
0
 protected void btnGetShipper_Click(object sender, EventArgs e)
 {
     int number = 0;
     if (int.TryParse(txtShipperIdSearch.Text, out number))
     {
         try
         {
             var client = new NorthwindServiceClient();
             var shipper = client.GetShipperById(int.Parse(txtShipperIdSearch.Text));
             txtShipperIdRead.Text = shipper.ShipperId.ToString();
             txtCompanyName.Text = shipper.CompanyName;
             txtPhoneNumber.Text = shipper.Phone;
             lblError.ForeColor = Color.Green;
             lblError.Text = !string.IsNullOrEmpty(shipper.CompanyName) ? "Shipper found" : $"Shipper with id {shipper.ShipperId} not found";
         }
         catch (FaultException ex)
         {
             lblError.Text = ex.Message;
             lblError.ForeColor = Color.Red;
         }
         catch (Exception ex)
         {
             lblError.Text = ex.Message;
             lblError.ForeColor = Color.Red;
         }
     }
     else
     {
         lblError.Text = "Only numbers please";
         lblError.ForeColor = Color.Red;
     }
 }