private string GetRemoteProduct(TextBox txtProductID, ref RemoteProductServiceProxy.Product product) { string result = ""; try { int productID = Int32.Parse(txtProductID.Text); var client = new RemoteProductServiceProxy.ProductServiceClient(); product = client.GetProduct(productID); var sb = new StringBuilder(); sb.Append("ProductID:" + product.ProductID.ToString() + "\n"); sb.Append("ProductName:" + product.ProductName + "\n"); sb.Append("UnitPrice:" + product.UnitPrice.ToString() + "\n"); sb.Append("RowVersion:"); foreach (var x in product.RowVersion.AsEnumerable()) { sb.Append(x.ToString()); sb.Append(" "); } result = sb.ToString(); } catch (Exception ex) { result = "Exception: " + ex.Message.ToString(); } return(result); }
private string UpdateRemotePrice( TextBox txtNewPrice, ref RemoteProductServiceProxy.Product product, ref bool updateResult) { string result = ""; string message = ""; try { product.UnitPrice = Decimal.Parse(txtNewPrice.Text); var client = new RemoteProductServiceProxy.ProductServiceClient(); updateResult = client.UpdateProduct(ref product, ref message); var sb = new StringBuilder(); if (updateResult == true) { sb.Append("Price updated to "); sb.Append(txtNewPrice.Text.ToString()); sb.Append("\n"); sb.Append("Update result:"); sb.Append(updateResult.ToString()); sb.Append("\n"); sb.Append("Update message:"); sb.Append(message); sb.Append("\n"); sb.Append("New RowVersion:"); } else { sb.Append("Price not updated to "); sb.Append(txtNewPrice.Text.ToString()); sb.Append("\n"); sb.Append("Update result:"); sb.Append(updateResult.ToString()); sb.Append("\n"); sb.Append("Update message:"); sb.Append(message); sb.Append("\n"); sb.Append("Old RowVersion:"); } foreach (var x in product.RowVersion.AsEnumerable()) { sb.Append(x.ToString()); sb.Append(" "); } result = sb.ToString(); } catch (Exception ex) { result = "Exception: " + ex.Message; } return(result); }
private string GetRemoteProduct(TextBox txtProductID, ref RemoteProductServiceProxy.Product product) { string result = ""; try { int productID = Int32.Parse(txtProductID.Text); var client = new RemoteProductServiceProxy.ProductServiceClient(); product = client.GetProduct(productID); var sb = new StringBuilder(); sb.Append("ProductID:" + product.ProductID.ToString() + "\n"); sb.Append("ProductName:" + product.ProductName + "\n"); sb.Append("UnitPrice:" + product.UnitPrice.ToString() + "\n"); sb.Append("RowVersion:"); foreach (var x in product.RowVersion.AsEnumerable()) { sb.Append(x.ToString()); sb.Append(" "); } result = sb.ToString(); } catch (Exception ex) { result = "Exception: " + ex.Message.ToString(); } return result; }
private string UpdateRemotePrice( TextBox txtNewPrice, ref RemoteProductServiceProxy.Product product, ref bool updateResult) { string result = ""; string message = ""; try { product.UnitPrice = Decimal.Parse(txtNewPrice.Text); var client = new RemoteProductServiceProxy.ProductServiceClient(); updateResult = client.UpdateProduct(ref product, ref message); var sb = new StringBuilder(); if (updateResult == true) { sb.Append("Price updated to "); sb.Append(txtNewPrice.Text.ToString()); sb.Append("\n"); sb.Append("Update result:"); sb.Append(updateResult.ToString()); sb.Append("\n"); sb.Append("Update message:"); sb.Append(message); sb.Append("\n"); sb.Append("New RowVersion:"); } else { sb.Append("Price not updated to "); sb.Append(txtNewPrice.Text.ToString()); sb.Append("\n"); sb.Append("Update result:"); sb.Append(updateResult.ToString()); sb.Append("\n"); sb.Append("Update message:"); sb.Append(message); sb.Append("\n"); sb.Append("Old RowVersion:"); } foreach (var x in product.RowVersion.AsEnumerable()) { sb.Append(x.ToString()); sb.Append(" "); } result = sb.ToString(); } catch (Exception ex) { result = "Exception: " + ex.Message; } return result; }