实现的效果是:点击测试按钮,弹出子窗口,输入日期、金额返回数据到父窗口
取消按钮:
测试按钮插件代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using Kingdee.BOS.Core.Bill.PlugIn;
using Kingdee.BOS.Core.DynamicForm;
using Kingdee.BOS.Util;
namespace cux.button.test
{
[Description("按钮测试")]
[HotUpdate]
public class KdBosExecuteServicePlugIn : AbstractBillPlugIn
{
public override void BarItemClick(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.BarItemClickEventArgs e)
{
base.BarItemClick(e);
if (e.BarItemKey.Equals("PBQO_tbButton"))
{
//如果不返回数据可以这样调用
/* this.View.ShowForm(new DynamicFormShowParameter()
{
ParentPageId = this.View.PageId,
FormId = "kdddbaabfd7234eb98e8193efd1340729"
});*/
//返回数据这样调用
this.View.ShowForm(new DynamicFormShowParameter()
{
ParentPageId = this.View.PageId,
FormId = "kdddbaabfd7234eb98e8193efd1340729"
}, (Action<Kingdee.BOS.Core.DynamicForm.FormResult>)(result =>
{
if (result.ReturnData == null)
return;
Dictionary<string, object> dictionary = result.ReturnData as Dictionary<string, object>;
DateTime dateTime1 = Convert.ToDateTime(dictionary["FDate"]);
Decimal fAmount = Convert.ToDecimal(dictionary["FAmount"]);
// DateTime dateTime1 = Convert.ToDateTime(result.ReturnData);
}
));
}
}
}
}
点击OK插件代码
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm;
using System;
using System.Collections.Generic;
using Kingdee.BOS.Util;
using System.ComponentModel;
namespace cux.button.test
{
[Description("测试动态表单插件")]
[HotUpdate]
public class TestDynamicFormPlugin : AbstractDynamicFormPlugIn
{
public override void AfterButtonClick(AfterButtonClickEventArgs e)
{
base.AfterButtonClick(e);
if (!e.Key.Equals("FOkButton", StringComparison.OrdinalIgnoreCase))
return;
if (this.Model.GetValue("FDate") == null)
this.View.ShowWarnningMessage("追加日期未录入!", "", MessageBoxOptions.OK, (Action<MessageBoxResult>)null, MessageBoxType.Advise);
else if (this.Model.GetValue("FAmount") == null || Convert.ToDecimal(this.Model.GetValue("FAmount")) == new Decimal(0))
{
this.View.ShowWarnningMessage("金额未录入!", "", MessageBoxOptions.OK, (Action<MessageBoxResult>)null, MessageBoxType.Advise);
}
else
{
this.View.ReturnToParentWindow(new Kingdee.BOS.Core.DynamicForm.FormResult((object)new Dictionary<string, object>()
{
{
"FDate",
this.Model.GetValue("FDate")
},
{
"FAmount",
this.Model.GetValue("FAmount")
}/*,
{
"FRemark",
this.Model.GetValue("FRemark")
}*/
}));
this.View.Close();
}
}
}
}