K3Cloud动态表单模拟新增按钮功能

    xiaoxiao2021-04-13  45

    使用动态表单插件,模拟K3cloud新增按钮的功能,代码如下:

    public override void AfterBarItemClick(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.AfterBarItemClickEventArgs e) { base.AfterBarItemClick(e); //获取Save按钮点击事件 if (e.BarItemKey == "SaveButton") { //获取分录对象 Entity et = this.View.BillBusinessInfo.GetEntity("FEntity"); DynamicObjectCollection dc = this.View.Model.GetEntityDataObject(et); //循环判断是否存在空行,如果有空行,则变量i在删除完一行后,持续定位在分录对象的这一行,因为dc.count会 //随着deleteentryrow的每一次执行而-1;如果获取的行不是空行,则向下获取一行 for (int i = 0; i < dc.Count; ) { if (Convert.ToInt32(dc[i]["MATERIALID_Id"]) == 0) { this.View.Model.DeleteEntryRow("FEntity", i); } else { i++; } } //这里因为View的DataObject中不包含FFormId数据,所以手工将单据类型赋值 this.View.Model.DataObject["FFormId"] = "T_STK_MISCELLANEOUS"; IOperationResult ior = BusinessDataServiceHelper.Save(this.Context, this.View.BusinessInfo, this.View.Model.DataObject,null,"SAVE"); if (ior.InteractionContext == null) { if (ior.IsSuccess != true && ior.IsShowMessage) { List<ValidationErrorInfo> ros = ior.ValidationErrors; String info = "报错信息为:"; foreach (ValidationErrorInfo roinfo in ros) { info = info + roinfo.Message + ";\n"; } this.View.ShowMessage(info, MessageBoxType.Advise); } else { this.View.ShowMessage("单据已保存,单据编号为" + this.View.Model.DataObject["BillNo"] + "", MessageBoxOptions.OK, ret => { if (ret == MessageBoxResult.OK) { this.View.Refresh(); } }); } } } }

    转载请注明原文地址: https://ju.6miu.com/read-669368.html

    最新回复(0)