using Kingdee.BOS.Core.Bill.PlugIn;
using Kingdee.BOS.Core.Metadata.EntityElement;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Util;
using System;
using System.ComponentModel;
using System.Text;
namespace cux.button.test
{
[Description("测试循环遍历单据行明细")]
[HotUpdate]
public class CuxTestBosExecuteServicePlugIn : AbstractBillPlugIn
{
public override void BarItemClick(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.BarItemClickEventArgs e)
{
base.BarItemClick(e);
if (e.BarItemKey.Equals("PBQO_tbButton"))
{
/*
var sql = string.Format("UPDATE T_SEC_USER SET FDESCRIPTION='测试DEMO!!!' WHERE FUSERID={0}", this.Context.UserId);
DBUtils.Execute(this.Context, sql);
this.View.ShowMessage("更新执行成功,SQL已执行,SQL脚本:" + sql);
*/
string FBillNo = "";
DynamicObject docSCDDIds1 = this.View.Model.DataObject;
FBillNo = docSCDDIds1["BillNo"].ToString();
EntryEntity entryEntity = this.View.BusinessInfo.GetEntryEntity("FEntity");
DynamicObjectCollection docCGSQIds = this.View.Model.GetEntityDataObject(entryEntity);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < docCGSQIds.Count; i++)
{
String qty = docCGSQIds[i]["F_PBQO_Decimal"].GetString().ToString();
DynamicObject Fitem = this.View.Model.GetEntityDataObject(entryEntity, i)["F_PBQO_Base"] as DynamicObject;
String itemCode = Fitem["Number"].ToString();
sb.AppendLine(string.Format("第{0}行的物料编码是{1},数量为:{2}", i + 1, itemCode, qty));
}
this.View.ShowMessage("单据编号:" + FBillNo + ",明细行数量" + sb);
}
}
}
}