【分享】客户中增加按钮提前判断是否撞单 并提示
金蝶云社区-jiedong_kingdee
jiedong_kingdee
0人赞赏了该文章 1,696次浏览 未经作者许可,禁止转载编辑于2014年07月18日 09:58:27

平台中 是当所有信息都录好保存的时候 提示下名称或者编码重复,这样 有时候 很麻烦 录好在提示 浪费时间,有的需要及时提醒,比如客户用在crm 系统中时 就需要,有需要的可以参考,其他类似,单据界面如图:


表单插件 继承 AbstractBillPlugIn 插件实现[code]///
/// 按钮点击提示。
///

///
public override void ButtonClick(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.ButtonClickEventArgs e)
{
base.ButtonClick(e);
if (e.Key.ToUpper() == "FBUTTON")
{
//检查客户中是的已经存在
if (this.View.Model.GetValue("FName") != null)
{
LocaleValue value = this.View.Model.GetValue("FName") as LocaleValue;
var name = value[this.Context.UserLocale.LCID];
string mesg = CloudSJDUtils.CheckValidity.CheckName(this.Context, "BD_Customer", name);
if (mesg !=null )
{
this.View.ShowMessage(mesg);
e.Cancel = true;
return;
}
}
else
{
this.View.ShowMessage("请先填写名称。");
e.Cancel = true;
return;
}

}
}[/code]工具类中CheckName方法 参数 ctx 系统上下文,formid 单据或者基础资料标示,name 是校验字段录的值[code] ///


/// 检查单据 名称是否重复
///

///
///
///
///
public static string CheckName(Context ctx,string formid,string name)
{
string mesg = null;

IQueryService ss = Kingdee.BOS.App.ServiceHelper.GetService();
Kingdee.BOS.Core.SqlBuilder.QueryBuilderParemeter QueryParemeter = null;

if (formid == "BD_Customer")// k客户
{
QueryParemeter = new Kingdee.BOS.Core.SqlBuilder.QueryBuilderParemeter
{
FormId = formid,
SelectItems = SelectorItemInfo.CreateItems("FName"),
FilterClauseWihtKey = "FName like @nam"

};
var p = new[] {
new SqlParam("@nam",DbType.String,name+"%")
};
var rpt = ss.GetDynamicObjectCollection(ctx, QueryParemeter, p.ToList());
if (rpt != null && rpt.Count> 0)
{
mesg = "名称为 " + name + " 的客户信息在金蝶K3Cloud系统中已存在。";
}

}

return mesg;
}[/code]