平台中 是当所有信息都录好保存的时候 提示下名称或者编码重复,这样 有时候 很麻烦 录好在提示 浪费时间,有的需要及时提醒,比如客户用在crm 系统中时 就需要,有需要的可以参考,其他类似,单据界面如图:
表单插件 继承 AbstractBillPlugIn 插件实现
/// <summary> /// 按钮点击提示。 /// </summary> /// <param name="e"></param> 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; } } }
/// <summary> /// 检查单据 名称是否重复 /// </summary> /// <param name="ctx"></param> /// <param name="formid"></param> /// <param name="name"></param> /// <returns></returns> public static string CheckName(Context ctx,string formid,string name) { string mesg = null; IQueryService ss = Kingdee.BOS.App.ServiceHelper.GetService<IQueryService>(); 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; }