Epicor客制化 - RowRule使用示例


RowRule示例

1.根据行字段值对字段进行样式设置

//高亮显示
RowRule rr1 = new RowRule("UD103.ShortChar02", RuleCondition.Equals, "");//如果UD103.ShortChar02=""
//高亮显示该行的UD103.ShortChar02字段
rr1.AddAction(RuleAction.AddControlSettings(this.oTrans, "UD103.ShortChar02", SettingStyle.Highlight));
((EpiDataView)(this.oTrans.EpiDataViews["UD103"])).AddRowRule(rr1);//将RowRule添加到EpiDataView实例化对象中

//自定义背景颜色
RowRule rr1 = new RowRule("UD103.ShortChar02", RuleCondition.Equals, "");//如果UD103.ShortChar02=""
ControlSettings controlSettings = new ControlSettings();
controlSettings.BackColor = Color.Red;//设置自定义背景颜色
controlSettings.StyleSetName = "MyStyle001";//设置该样式的名称,样式名称不能为空,也不能使用已有样式名,否则背景颜色将优先从该样式名对应的样式中获取,导致自定义背景色无效
rr1.AddAction(RuleAction.AddControlSettings(this.oTrans, "UD103.ShortChar02", controlSettings));
((EpiDataView)(this.oTrans.EpiDataViews["UD103"])).AddRowRule(rr1);

2.根据自定义方法返回值控制字段只读

private bool IsApproved(RowRuleDelegateArgs args)
{
    string shortChar01= Convert.ToString(args.Row["ShortChar01"]);
    if (shortChar01== "Approved") return true;
    else return false;
}
RowRule rr1 = new RowRule(null, new RowRuleConditionDelegate2(this.IsApproved), null);//如果IsApproved方法返回true
//该行的UD103.ShortChar02字段设置为只读,控制数据输入
rr1.AddAction(RuleAction.AddControlSettings(this.oTrans, "UD103.ShortChar02", SettingStyle.ReadOnly));
((EpiDataView)(this.oTrans.EpiDataViews["UD103"])).AddRowRule(rr1);//将RowRule添加到EpiDataView实例化对象中

3.根据自定义方法返回值控制整行只读

private bool IsApproved(RowRuleDelegateArgs args)
{
    string shortChar01= Convert.ToString(args.Row["ShortChar01"]);
    if (shortChar01== "Approved") return true;
    else return false;
}
RowRule rr1 = new RowRule(null, new RowRuleConditionDelegate2(this.IsApproved), null);//如果IsApproved方法返回true
rr1.AddAction(RuleAction.DisableRow(this.oTrans, "UD103A"));//控制整行数据输入
((EpiDataView)(this.oTrans.EpiDataViews["UD103"])).AddRowRule(rr1);//将RowRule添加到EpiDataView实例化对象中

4.SettingStyle

除了高亮显示和只读样式,还可以设置加粗,强制输入等,具体可以查看SettingStyle枚举:

public enum SettingStyle
{
    Bold = 0,
    Error = 1,
    Warning = 2,
    OK = 3,
    Highlight = 4,
    Disabled = 5,
    Mandatory = 6,
    Invisible = 7,
    ReadOnly = 8
}

5.根据自定义方法返回值执行自定义行为

除SettingStyle枚举中的行为外,我们也可以自定义行为:

private bool IsApproved(RowRuleDelegateArgs args)
{
    string shortChar01= Convert.ToString(args.Row["ShortChar01"]);
    if (shortChar01== "Approved") return true;
    else return false;
}
private void DoSomeThings(RowRuleDelegateArgs args){
	 epiBt1.ReadOnly = true;
}
//根据IsApproved方法返回值,执行DoSomeThings方法
RowRule rr1 = new RowRule(null, new RowRuleConditionDelegate2(this.IsApproved), null, new RowRuleActionDelegate2(this.DoSomeThings),null);
((EpiDataView)(this.oTrans.EpiDataViews["UD103"])).AddRowRule(rr1);

6.RowRule失效情况

暂时发现调用了oTrans.Clear()时RowRule会失效,需改为调用oTrans.ClearDataSets()。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值