1:插件继承体系
领域类型 基类
动态表单 – 维护 AbstractDynamicFormPlugIn
业务单据 – 维护 AbstractBillPlugIn
业务单据 – 列表 AbstractListPlugIn
基础资料 – 维护 AbstractBasePlugIn
基础资料 – 列表 AbstractListPlugIn
2:获取单据相关信息
(1)获取当前行号
int rowIndex = this.Model.GetEntryCurrentRowIndex("FEntity"); FEntity为单据体标识
(2)获取单据体集合 Entity entity = this.View.BillBusinessInfo.GetEntity("FSaleOrderEntry"); FSaleOrderEntry为单据体标识
DynamicObjectCollection entrys = this.Model.GetEntityDataObject(entity);
(3)操作插件获取选中行
// 扩展方法,需要
using Kingdee.BOS.Core.DynamicForm
var selectedRows = this.Option.GetBillOperationSelectedRows();
(4)获取选中行
int[] selectedIndexsR = this.View.GetControl("FSaleOrderEntry").GetSelectedRows();
(5)获取选中行数据
//当前选中行行号
int[] selectedIndexsR = this.View.GetControl("FSaleOrderEntry").GetSelectedRows();
//单据体数据
DynamicObjectCollection selectedRowsDy = this.Model.DataObject["SaleOrderEntry"] as DynamicObjectCollection;
//选中行数据
DynamicObject selectedRow = selectedRowsDy[selectedIndexsR[0]];
(6)获取单据内码
long billNo = Convert.ToInt64(this.View.Model.GetPKValue());//获取当前单据编号内码
(7)获取单据分录内码
int row = this.Model.GetEntryCurrentRowIndex("FSubEntity");
Entity entiry = this.View.Model.BillBusinessInfo.GetEntity("FSubEntity");
object pkValue = this.View.Model.GetEntryPKValue(entiry.Key, row);
(8)在单据列表界面,使用如下语句获取当前选择行的单据内码
this.ListView.CurrentSelectedRowInfo.PrimaryKeyValue
3:当前界面的数据保存,直接调用保存操作
Kingdee.BOS.ServiceHelper.BusinessDataServiceHelper.Save(this.Context, this.View.BusinessInfo, this.View.Model.DataObject);
4:检验字符串函数
ObjectUtils.IsNullOrEmptyOrWhiteSpace
IsNullOrWhiteSpace
5:利用代码弹出提示框
this.View.ShowMessage("详细信息", MessageBoxOptions.YesNo, ret =>
{
if (ret == MessageBoxResult.No)
{
e.Cancel = true;
return;
}
}, string.Format("物料编码为:{0}的物料存在不同的报关项号,是否继续?", string.Join(",", list)), MessageBoxType.Notice);
6:通过主键获取对象
FormMetadata formMetadata = MetaDataServiceHelper.Load(this.Context, "BD_MATERIAL") as FormMetadata;
DynamicObject dynamicObject = BusinessDataServiceHelper.LoadSingle(this.Context,id,formMetadata .BusinessInfo.GetDynamicObjectType());
7:获取表单字段的值
DynamicObject FMaterial = (DynamicObject)this.View.Model.GetValue("FMaterialId");FMaterialId为字段标识,本字段是一个基础资料字段
DynamicObject FMaterial = (DynamicObject)this.View.Model.GetValue("FMaterialId",e.Row);e.ROW为单据体行号
8:设置表单字段的值
1:给分录赋值 this.View.Model.SetValue("FEntryNote", FNOTE,rowIndex);
2:给单据头赋值 this.View.Model.SetValue("FEntryNote",FNOTE);
3:数据库执行语句 DBUtils.Execute(this.Context, updateSql);
var mas = DBUtils.ExecuteDynamicObject(this.Context, sql);
4:新增、删除单据体行 this.View.Model.DeleteEntryRow("FSONEntity", i);
this.View.Model.CreateNewEntryRow("FSONEntity");
5:刷新操作this.View.UpdateView("FieldKey")
刷新某个字段this.View.InvokeFormOperation(Kingdee.BOS.Core.DynamicForm.FormOperationEnum.Refresh)//刷新整单
6:代码锁定单元格this.View.GetFieldEditor("FBaseUnitId", 0).SetEnabled("", false);
this.View.GetFieldEditor("FBarCodeAmount", 0).Enabled = false;