PX(DB) DateAttribute 属性

PXDBDate 属性和 PXDate 属性被设计成与 Nullable<DateTime>DateTime?)的 DAC 领域工作与单一字段内的可选的时间部分键入和存储日期值。除了 DAC 字段中的日期之外,Wheather PX(DB)DateAttribute 应该节省时间由 PreserveTime 属性定义 :当 PreserveTime 设置为 True 时,保留字段值的时间部分,否则只保存日期部分 DAC 领域:

#region UsrDateTime
public abstract class usrDateTime : IBqlField
{ }

[PXDBDate(PreserveTime = true, InputMask = "g")]
[PXUIField(DisplayName = "DateTime Value")]
public DateTime? UsrDateTime { get; set; }
#endregion

#region UsrDate
public abstract class usrDate : IBqlField
{ }

[PXDBDate]
[PXUIField(DisplayName = "Date Value")]
public DateTime? UsrDate { get; set; }
#endregion

在 UI 中,对于使用 PXDBDateAttributePXDateAttribute 修饰的字段,系统会创建一个输入控件,仅接受日期值或同时接受日期和时间值,具体取决于 PreserveTime 属性的值。这个概念在表单上完全相同:

StackOverflow 文档

<px:PXDateTimeEdit runat="server" ID="edUsrDateTime" DataField="UsrDateTime" Size="SM" />
<px:PXDateTimeEdit runat="server" ID="edUsrDate" DataField="UsrDate" />

并在网格单元格内:

StackOverflow 文档

<Columns>
    ...
    <px:PXGridColumn DataField="UsrDateTime" Width="130px" />
    <px:PXGridColumn DataField="UsrDate" Width="90px" />
    ...
</Columns>