0

我正在尝试从 XAF 中的订单创建发票。我按照devexpress 网站上的添加显示弹出窗口的操作

使用视图控制器和操作我有一个订单类和 order_Details 类作为带有发票类的订单集合和 Invoice_Data 类作为发票的集合

  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​

我喜欢从带有 OrderDetailsCollection 视图的 Order detailView 中添加一个操作

  1. 创建新发票并将更改提交到数据库
  2. 获取 Oder.OrderDetail 集合当前视图项并将它们传递给新创建的 Invoice.InvoiceData 集合
  3. 将订单设置为已开票

感谢您提供的任何帮助。

4

1 回答 1

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​
于 2015-06-16T19:47:07.707 回答