Opening an Order

Discussions related to SoftPro Select Server development.

Moderator: Phil Barton

Shevy
Posts: 48
Joined: Tue Dec 23, 2008 12:21 pm

Re: Opening an Order

Post by Shevy »

Now I would like to go ahead and edit some of the order information from my application.
For example I want to be able to change the sales price.
Here's what I coded:

Code: Select all

       Dim server As New SoftPro.Select.Client.SelectServer("http://Localhost/SelectServer", credential)
        ' Create the order tracking client 
        Dim ot As SoftPro.OrderTracking.Client.OrderTracking = server.GetService(Of  SoftPro.OrderTracking.Client.OrderTracking)()
        ' Create the specification for the existing order. 
        Dim spec As New OrderQuerySpec()
        spec.BaseOrderNumber = TitleNumber 
        ' Open the order 
        Dim order As IOrder = ot.GetOrder(spec, True)
Response.Write(order.SalesContract.SalesPrice)

'until here it works 

        Dim os As SoftPro.OrderTracking.Client.ISalesContract = server.GetService(Of SoftPro.OrderTracking.Client.ISalesContract)()

            Dim salesContract As ISalesContract = ot.GetOrder(spec, True)
        salesContract.SalesPrice = 10000
The error i get is:
Unable to cast object of type 'SoftPro.OrderTracking.Client.OrderProxy' to type 'SoftPro.OrderTracking.Client.ISalesContract'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Unable to cast object of type 'SoftPro.OrderTracking.Client.OrderProxy' to type 'SoftPro.OrderTracking.Client.ISalesContract'.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[InvalidCastException: Unable to cast object of type 'SoftPro.OrderTracking.Client.OrderProxy' to type 'SoftPro.OrderTracking.Client.ISalesContract'.]
TransactionsList.OrderInformation.dtlVwOrderInfo_ItemUpdating(Object sender, DetailsViewUpdateEventArgs e) in K:\Inet\MTANewWebDev\Generic\TransactionsList\OrderInformation.aspx.vb:304
System.Web.UI.WebControls.DetailsView.OnItemUpdating(DetailsViewUpdateEventArgs e) +133
System.Web.UI.WebControls.DetailsView.HandleUpdate(String commandArg, Boolean causesValidation) +716
System.Web.UI.WebControls.DetailsView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +440
System.Web.UI.WebControls.DetailsView.OnBubbleEvent(Object source, EventArgs e) +95
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.DetailsViewRow.OnBubbleEvent(Object source, EventArgs e) +109
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +115
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +132
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +177
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746


Thanks
Shevy
Posts: 48
Joined: Tue Dec 23, 2008 12:21 pm

Re: Opening an Order

Post by Shevy »

I would like to get moving with this.
Can anyone help me? Basically I want to be able to edit order information such as "salesprice", "Loanamount" via the API in .NET.
Thanks in advance.
Mark McKenna

Re: Opening an Order

Post by Mark McKenna »

Hi Shevy,

I'd recommend you take a peek at the Select SDK Help documentation for a complete synopsis of these methods and interfaces, but as a quick summary to get you going:

1. The OrderTracking.GetOrder() service method returns an object of type IOrder. Your cast to ISalesContract is failing there since it is not assignable.
2. The ISalesContract interface does not represent a registered service, whereas OrderTracking does. Your GetService<ISalesContract>() call will return null and that, in turn, will result in your os variable being null. You don't need that line at all.

Instead, you'll want to use the IOrder reference that you successfully obtained, directly:

Code: Select all

Dim order As IOrder = ot.GetOrder(spec, True)
Dim sc As ISalesContract = order.SalesContract
sc.SalesPrice = 10000
The SDK Help documentation provides a wealth of great API information, including what types are returned by the various methods and properties. You'll also start to recognize the relationships between objects (orders have sales contracts, buyers have notes, etc.) and the pattern by which the API provides read/write access to the various objects. Hope that helps!
Post Reply