I am trying to create an invoice from an order in XAF. I follow the Add an Action that Displays a Pop-up Window from the devexpress web site
Using a View controller and an Action I have an order class and order_Details class as a Collection of orders with an Invoice class and Invoice_Data class as a collection of Invoice
Private Sub Create_Invoice_Action_CustomizePopupWindowParams(sender As Object, e As CustomizePopupWindowParamsEventArgs) Handles Create_Invoice_Action.CustomizePopupWindowParams
Dim objectSpace As IObjectSpace = Application.CreateObjectSpace()
e.View = Application.CreateListView(Application.FindListViewId(GetType(elmts.OrderDetail)), _
New CollectionSource(objectSpace, GetType(elmts.OrderDetail)), True)
End Sub
Private Sub ShowNotesAction_Execute(ByVal sender As Object, _
ByVal e As PopupWindowShowActionExecuteEventArgs) Handles Create_Invoice_Action.Execute
Dim _invoiceDetails As elmts.InvoiceData = CType(View.CurrentObject, elmts.InvoiceData)
View.ObjectSpace.SetModified(_invoiceDetails)
For Each _nv_Det As elmts.OrderDetail In e.PopupWindow.View.SelectedObjects
If (Not String.IsNullOrEmpty(_invoiceDetails.ProductName)) Then
_invoiceDetails.ProductName += Environment.NewLine
End If
_invoiceDetails.ProductName += _nv_Det.Division
Next _nv_Det
Dim item As ViewItem = (CType(View, DetailView)).FindItem("ProductName")
CType(item, PropertyEditor).ReadValue()
'Save changes to the database if the current Detail View is displayed in the View mode
If TypeOf View Is DetailView AndAlso (CType(View, DetailView)).ViewEditMode = _
ViewEditMode.View Then
View.ObjectSpace.CommitChanges()
End If
End Sub
Private Sub PopupNotesController_Activated(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Activated
Create_Invoice_Action.Active.SetItemValue("ObjectType", DirectCast(View, DetailView).ObjectTypeInfo.Type Is GetType(elmts.Order))
End Sub
Another words I like to from the Order detailView with an OrderDetailsCollection view add an action that will
Thanks for any help provided.
答案 0 :(得分:0)
我希望这会有所帮助:
Private Sub Create_Invoice_Action_CustomizePopupWindowParams(sender As Object, e As CustomizePopupWindowParamsEventArgs) Handles Create_Invoice_Action.CustomizePopupWindowParams
Dim objectSpace As IObjectSpace = Application.CreateObjectSpace()
e.View = Application.CreateListView(Application.FindListViewId(GetType(elmts.OrderDetail)), _
New CollectionSource(objectSpace, GetType(elmts.OrderDetail)), True)
End Sub
Private Sub ShowNotesAction_Execute(ByVal sender As Object, _ByVal e As PopupWindowShowActionExecuteEventArgs) Handles Create_Invoice_Action.Execute
'Dim _invoiceDetails As elmts.InvoiceData = CType(View.CurrentObject, elmts.InvoiceData) << Wrong, since View.CurrentObject is elmts.Order
Dim _order As elmts.Order = CType(View.CurrentObject, elmts.Order);
Dim _invoiceDetails As elmts.InvoiceData = _order.CreateInvoice(); 'creates a new InvoiceData
View.ObjectSpace.SetModified(_invoiceDetails)
For Each _nv_Det As elmts.OrderDetail In e.PopupWindow.View.SelectedObjects
If (Not String.IsNullOrEmpty(_invoiceDetails.ProductName)) Then
_invoiceDetails.ProductName += Environment.NewLine
End If
_invoiceDetails.ProductName += _nv_Det.Division
Next _nv_Det
Dim item As ViewItem = (CType(View, DetailView)).FindItem("ProductName")
CType(item, PropertyEditor).ReadValue()
'Save changes to the database if the current Detail View is displayed in the View mode
If TypeOf View Is DetailView AndAlso (CType(View, DetailView)).ViewEditMode = _
ViewEditMode.View Then
View.ObjectSpace.CommitChanges()
End If
End Sub
Private Sub PopupNotesController_Activated(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Activated
Create_Invoice_Action.Active.SetItemValue("ObjectType", DirectCast(View, DetailView).ObjectTypeInfo.Type Is GetType(elmts.Order))
End Sub