应用场景:
当组织为达市工厂时其他出库单领料类型,限制只能使用“备品备件”、“工程领料”和“水泥粉磨”。
技术分析
技术点一:通过“DataChanged”事件触发
//继承AbstractBillPlugIn
public override void DataChanged(DataChangedEventArgs e)
{
}
技术点二:下拉框赋值取值
var fieldkey = "F_lylx";//下拉框BOS标识
var pikType = this.View.Model.GetValue(fieldkey).ToString();//取值
var field = (ComboField)this.View.BillBusinessInfo.GetField(fieldkey);
this.Model.DataObject[field.PropertyName] = "1";//赋值
this.View.UpdateView(fieldkey);//刷新界面
技术点三:下拉框赋值取BOS“枚举项值”
最终实现
[Description("其他出库单领料类型限制")]
[Kingdee.BOS.Util.HotUpdate]
public class OtherOutStockChange : AbstractBillPlugIn
{
public override void DataChanged(DataChangedEventArgs e)
{
var fieldkey = "F_lylx";
List<string> pickTypeList = new List<string>()
{
"2",
"7",
"8"
};
/*
其他出库单当前组织是达市工厂时,领用类型只能使用“备品备件”、“工程领料”、“水泥/粉磨”
*/
var field = (ComboField)this.View.BillBusinessInfo.GetField(fieldkey);
var orgId = this.Context.CurrentOrganizationInfo.ID.ToString();//当前组织ID
var pikType = this.View.Model.GetValue(fieldkey).ToString();//领用类型
if (orgId == "915400")
{
if (!pickTypeList.Contains(pikType))
{
//this.View.Model.SetValue("F_lylx", "1");
this.Model.DataObject[field.PropertyName] = "1";
this.View.UpdateView(fieldkey);
if (!string.IsNullOrWhiteSpace(pikType))
{
this.View.ShowMessage("达市工厂时,领用类型只能使用“备品备件”、“工程领料”、“水泥/粉磨”", MessageBoxType.Error);
}
}
}
}
}