Implementing custom tab in uCommerce admin and subscribe to save event.
I am trying to create a custom tab in the admin so that my client can
add tracking to an order. I have the new tab on an order however I am
unable to subscribe to the save event. Anyone got any ideas what I am doing wrong?
public partial class OrderTracking : UCommerce.Presentation.Web.Controls.ViewEnabledControl<IEditOrderView> {
Implementing custom tab in uCommerce admin and subscribe to save event.
I am trying to create a custom tab in the admin so that my client can add tracking to an order. I have the new tab on an order however I am unable to subscribe to the save event. Anyone got any ideas what I am doing wrong?
public partial class OrderTracking : UCommerce.Presentation.Web.Controls.ViewEnabledControl<IEditOrderView>
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
txtTrackAndTrace.Attributes.Add("style", "width: 500px");
PurchaseOrder purchaseOrder = PurchaseOrder.SingleOrDefault(x => x.OrderId == View.OrderId);
ICollection<Shipment> shipments = purchaseOrder.Shipments;
Shipment shipment = purchaseOrder.Shipments.FirstOrDefault();
txtTrackAndTrace.Text = shipment.TrackAndTrace;
View.Saved += new EventHandler<EntityCommandEventArgs<PurchaseOrder>>(this.HandleSaveOrderTracking);
}
}
private void HandleSaveOrderTracking(object sender, EventArgs e)
{
PurchaseOrder purchaseOrder = PurchaseOrder.SingleOrDefault(x => x.OrderId == View.OrderId);
ICollection<Shipment> shipments = purchaseOrder.Shipments;
Shipment shipment = purchaseOrder.Shipments.FirstOrDefault();
shipment.TrackAndTrace = Server.HtmlEncode(txtTrackAndTrace.Text);
shipment.Save();
}
}
You need to put this line outside your IsPostBack
View.Saved += new EventHandler<EntityCommandEventArgs<PurchaseOrder>>(this.HandleSaveOrderTracking);
Simple, thanks again Morten, you are a life saver..
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.