54 lines
1.8 KiB
C#
54 lines
1.8 KiB
C#
using Kingdee.BOS;
|
|
using Kingdee.BOS.Core.Metadata.FieldElement;
|
|
using Kingdee.BOS.Orm;
|
|
using Kingdee.BOS.Orm.DataEntity;
|
|
using Kingdee.BOS.Orm.Metadata.DataEntity;
|
|
using Kingdee.BOS.Util;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Pilot_KD_Parino.Common
|
|
{
|
|
public static class BOSCommon
|
|
{
|
|
/// <summary>
|
|
/// 给基础资料赋值
|
|
/// </summary>
|
|
/// <param name="ctx"></param>
|
|
/// <param name="field"></param>
|
|
/// <param name="data"></param>
|
|
/// <param name="value"></param>
|
|
public static void SetBaseDataFieldValue(Context ctx, BaseDataField field, DynamicObject data, object value)
|
|
{
|
|
long result = 0L;
|
|
long.TryParse(value.ToString(), out result);
|
|
if ((value.ToString().Length > 1) || (result > 0L))
|
|
{
|
|
DynamicObject newValue = LoadReferenceData(ctx, field.RefFormDynamicObjectType, value);
|
|
field.DynamicProperty.SetValue(data, newValue);
|
|
field.RefIDDynamicProperty.SetValue(data, value);
|
|
}
|
|
else
|
|
{
|
|
field.DynamicProperty.SetValue(data, null);
|
|
field.RefIDDynamicProperty.SetValue(data, 0);
|
|
}
|
|
}
|
|
|
|
public static DynamicObject LoadReferenceData(Context ctx, DynamicObjectType dt, object pkValue)
|
|
{
|
|
if (pkValue.IsEmptyPrimaryKey())
|
|
{
|
|
return null;
|
|
}
|
|
OperateOption option = OperateOption.Create();
|
|
option.SetThrowExceptionWhenNotFind(false);
|
|
return Kingdee.BOS.ServiceHelper.BusinessDataServiceHelper.LoadSingle(ctx, pkValue, dt, option);
|
|
|
|
}
|
|
}
|
|
}
|