在工程项目中,一个业主给工厂多个制造合同,在生产制造环节就形成了一个业主多个制造任务同时进行的状态。
直接上干货。
业主库BO:
using DevExpress.Data.Filtering;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.DC;
using DevExpress.ExpressApp.Model;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl;
using DevExpress.Persistent.Validation;
using DevExpress.Xpo;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
namespace MyMOM.Module.BusinessObjects
{
[DefaultClassOptions]
//[ImageName("BO_Contact")]
//[DefaultProperty("DisplayMemberNameForLookupEditorsOfThisType")]
//[DefaultListViewOptions(MasterDetailMode.ListViewOnly, false, NewItemRowPosition.None)]
//[Persistent("DatabaseTableName")]
// Specify more UI options using a declarative approach (https://documentation.devexpress.com/#eXpressAppFramework/CustomDocument112701).
public class PF_CRM_业主库 : BaseObject
{ // Inherit from a different class to provide a custom primary key, concurrency and deletion behavior, etc. (https://documentation.devexpress.com/eXpressAppFramework/CustomDocument113146.aspx).
public PF_CRM_业主库(Session session)
: base(session)
{
}
public override void AfterConstruction()
{
base.AfterConstruction();
// Place your initialization code here (https://documentation.devexpress.com/eXpressAppFramework/CustomDocument112834.aspx).
}
//private string _PersistentProperty;
//[XafDisplayName("My display name"), ToolTip("My hint message")]
//[ModelDefault("EditMask", "(000) - 00"), Index(0), VisibleInListView(false)]
//[Persistent("DatabaseColumnName"), RuleRequiredField(DefaultContexts.Save)]
//public string PersistentProperty {
// get { return _PersistentProperty; }
// set { SetPropertyValue(nameof(PersistentProperty), ref _PersistentProperty, value); }
//}
//[Action(Caption = "My UI Action", ConfirmationMessage = "Are you sure ? ", ImageName = "Attention", AutoCommit = true)]
//public void ActionMethod() {
// // Trigger a custom business logic for the current record in the UI (https://documentation.devexpress.com/eXpressAppFramework/CustomDocument112619.aspx).
// this.PersistentProperty = "Paid";
//}
string f名称;
[Size(255)]
public string 名称
{
get { return f名称; }
set { SetPropertyValue<string>(nameof(名称), ref f名称, value); }
}
//MD_PUB_公司库 f公司信息;
//[Association(@"PF_CRM_业主库ReferencesMD_PUB_公司库")]
//public MD_PUB_公司库 公司信息
//{
// get { return f公司信息; }
// set { SetPropertyValue<MD_PUB_公司库>(nameof(公司信息), ref f公司信息, value); }
//}
string f备注;
[Size(512)]
public string 备注
{
get { return f备注; }
set { SetPropertyValue<string>(nameof(备注), ref f备注, value); }
}
//[Association(@"PF_CRM_经营合同ReferencesPF_CRM_业主库")]
//public XPCollection<PF_CRM_经营合同> PF_CRM_经营合同s { get { return GetCollection<PF_CRM_经营合同>(nameof(PF_CRM_经营合同s)); } }
//[Association(@"PF_CRM_业主信誉ReferencesPF_CRM_业主库")]
//public XPCollection<PF_CRM_业主信誉> PF_CRM_业主信誉s { get { return GetCollection<PF_CRM_业主信誉>(nameof(PF_CRM_业主信誉s)); } }
[Association(@"PF_CRM_制造任务单ReferencesPF_CRM_业主库")]
public XPCollection<PF_CRM_制造任务单> PF_CRM_制造任务单s { get { return GetCollection<PF_CRM_制造任务单>(nameof(PF_CRM_制造任务单s)); } }
//[Association(@"PF_CRM_制造项目ReferencesPF_CRM_业主库")]
//public XPCollection<PF_CRM_制造项目> PF_CRM_制造项目s { get { return GetCollection<PF_CRM_制造项目>(nameof(PF_CRM_制造项目s)); } }
}
}
制造任务单BO:
using DevExpress.Data.Filtering;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.DC;
using DevExpress.ExpressApp.Model;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl;
using DevExpress.Persistent.Validation;
using DevExpress.Xpo;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
namespace MyMOM.Module.BusinessObjects
{
[DefaultClassOptions]
//[ImageName("BO_Contact")]
//[DefaultProperty("DisplayMemberNameForLookupEditorsOfThisType")]
//[DefaultListViewOptions(MasterDetailMode.ListViewOnly, false, NewItemRowPosition.None)]
//[Persistent("DatabaseTableName")]
// Specify more UI options using a declarative approach (https://documentation.devexpress.com/#eXpressAppFramework/CustomDocument112701).
public class PF_CRM_制造任务单 : BaseObject
{ // Inherit from a different class to provide a custom primary key, concurrency and deletion behavior, etc. (https://documentation.devexpress.com/eXpressAppFramework/CustomDocument113146.aspx).
public PF_CRM_制造任务单(Session session)
: base(session)
{
}
public override void AfterConstruction()
{
base.AfterConstruction();
// Place your initialization code here (https://documentation.devexpress.com/eXpressAppFramework/CustomDocument112834.aspx).
}
//private string _PersistentProperty;
//[XafDisplayName("My display name"), ToolTip("My hint message")]
//[ModelDefault("EditMask", "(000) - 00"), Index(0), VisibleInListView(false)]
//[Persistent("DatabaseColumnName"), RuleRequiredField(DefaultContexts.Save)]
//public string PersistentProperty {
// get { return _PersistentProperty; }
// set { SetPropertyValue(nameof(PersistentProperty), ref _PersistentProperty, value); }
//}
//[Action(Caption = "My UI Action", ConfirmationMessage = "Are you sure ? ", ImageName = "Attention", AutoCommit = true)]
//public void ActionMethod() {
// // Trigger a custom business logic for the current record in the UI (https://documentation.devexpress.com/eXpressAppFramework/CustomDocument112619.aspx).
// this.PersistentProperty = "Paid";
//}
string f名称;
[Size(255)]
public string 名称
{
get { return f名称; }
set { SetPropertyValue<string>(nameof(名称), ref f名称, value); }
}
string f编码;
[Size(64)]
public string 编码
{
get { return f编码; }
set { SetPropertyValue<string>(nameof(编码), ref f编码, value); }
}
PF_HR_公司员工 f编制人;
[Association(@"PF_CRM_制造任务单ReferencesPF_HR_公司员工")]
public PF_HR_公司员工 编制人
{
get { return f编制人; }
set { SetPropertyValue<PF_HR_公司员工>(nameof(编制人), ref f编制人, value); }
}
DateTime f编制日期;
public DateTime 编制日期
{
get { return f编制日期; }
set { SetPropertyValue<DateTime>(nameof(编制日期), ref f编制日期, value); }
}
PF_CRM_业主库 f业主;
[Association(@"PF_CRM_制造任务单ReferencesPF_CRM_业主库")]
public PF_CRM_业主库 业主
{
get { return f业主; }
set { SetPropertyValue<PF_CRM_业主库>(nameof(业主), ref f业主, value); }
}
int f版本;
public int 版本
{
get { return f版本; }
set { SetPropertyValue<int>(nameof(版本), ref f版本, value); }
}
//PF_CRM_经营合同 f经营合同;
//[Association(@"PF_CRM_制造任务单ReferencesPF_CRM_经营合同")]
//public PF_CRM_经营合同 经营合同
//{
// get { return f经营合同; }
// set { SetPropertyValue<PF_CRM_经营合同>(nameof(经营合同), ref f经营合同, value); }
//}
string f备注;
[Size(255)]
public string 备注
{
get { return f备注; }
set { SetPropertyValue<string>(nameof(备注), ref f备注, value); }
}
}
}
同样的,业主和经营合同也是一对多的关系。
经营合同与制造任务也是一对多的关系。就是一个签订了一个经营合同,根据业务进度安排或工厂自身的生产制造状况安排一个或多个制造任务下达给工厂或车间。
鉴于XAF的整体架构,不建议在BO的名称和属性名称中使用中文。