XAF中如何实现Action创建一个可以编辑外连接对象的detail

本文详细介绍了如何使用Xaf框架通过主数据创建关联表的对象,以库存表为例,演示了如何创建出入库单对象并弹出窗体进行编辑。涉及到对象空间操作、视图参数配置以及控制器应用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在系统中有时候我们希望实现这样的创建操作,通过主数据创建一个关联表的对象,比如,通过库存表创建一个出入库单的对象并弹出一个窗体编辑给对象,在xaf中可以使用如下的代码实现:

using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;

using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.Persistent.Base;
using DevExpress.ExpressApp.SystemModule;
namespace Tes.Module.INVE.Controllers
{
   public partial class InveActionContriller : ViewController
    {
        private DetailView createdDetailView;
        //private InveActionContriller newController;
        public InveActionContriller()
        {
            InitializeComponent();
            RegisterActions(components);
            //this.TargetViewType = ViewType.ListView;
            
//this.TargetViewNesting = Nesting.Nested;
            
//this.TargetObjectType = typeof(Dy_Inventory);
            
        }
        private void actionCreateAdm_Execute(object sender, SimpleActionExecuteEventArgs e)
        {


            

            //Find an existing object.

            
//Contact obj = os.FindObject<Contact>(CriteriaOperator.Parse("FirstName=?", "My Contact"));

            
//Or create a new object.
            Contact obj = View.ObjectSpace.CreateObject<Contact>();

            obj.Dy_Materials = (Dy_Inventory)e.CurrentObject;

            //Save the changes if necessary.

            View.ObjectSpace.CommitChanges();
            IObjectSpace os = Application.CreateObjectSpace();

            e.ShowViewParameters.CreatedView = Application.CreateDetailView(os, os.GetObject(obj));
            //os = os.GetObject(obj);
            os.SetModified(os.GetObject(obj));
            //Specify various display settings.
            
            e.ShowViewParameters.TargetWindow = TargetWindow.NewModalWindow;

            e.ShowViewParameters.Context = TemplateContext.NestedFrame;
            
           
            e.ShowViewParameters.CreateAllControllers = true;

            //Provide standard dialog window functionality.

            DialogController dc = Application.CreateController<DialogController>();

            e.ShowViewParameters.Controllers.Add(dc);

     
            View.ObjectSpace.Refresh();
   
        }
    }
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值