0

XAF で注文から請求書を作成しようとしています。devexpress Web サイトから、ポップアップ ウィンドウを表示するアクションを追加します。

ビューコントローラーとアクションを使用して、注文クラスとorder_Detailsクラスを注文のコレクションとして、InvoiceクラスとInvoice_Dataクラスを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​

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 に答える