public void BuildText(ExtensionItem extension) { Field propField = (Field)ObjectUtils.CreateCopy(modelTextField); propField.DynamicProperty = null; propField.ChildrenFields.Clear(); propField.EntityKey = currEntityKey; propField.Entity = currEntity; if (propField.UpdateActions != null) { propField.UpdateActions.Clear(); } // 必改属性,涉及到数据的加载 propField.Key = extension.Key; propField.FieldName = extension.Key.ToUpperInvariant(); propField.PropertyName = extension.Key; propField.Name = new LocaleValue(extension.Name); _currBusinessInfo.Add(propField); }
public override void OnSetBusinessInfo(SetBusinessInfoArgs e) { base.OnSetBusinessInfo(e); FormMetadata currmetadata = (FormMetadata)ObjectUtils.CreateCopy(this.View.OpenParameter.FormMetaData); _currBusinessInfo = currmetadata.BusinessInfo; _currLayoutInfo = currmetadata.GetLayoutInfo(); // 获取单据体表格的元数据及布局 string entityKey = "FEntity"; Entity entity = _currBusinessInfo.GetEntity(entityKey); //EntityAppearance entityApp = _currLayoutInfo.GetEntityAppearance(entityKey); string FSDate = this.View.OpenParameter.GetCustomParameter("FSDate") == null ? "" : this.View.OpenParameter.GetCustomParameter("FSDate").ToString(); string FEDate = this.View.OpenParameter.GetCustomParameter("FEDate") == null ? "" : this.View.OpenParameter.GetCustomParameter("FEDate").ToString(); string FOrgId = this.View.OpenParameter.GetCustomParameter("FOrgId") == null ? "0" : this.View.OpenParameter.GetCustomParameter("FOrgId").ToString(); string FDeptID = this.View.OpenParameter.GetCustomParameter("FDeptID") == null ? "0" : this.View.OpenParameter.GetCustomParameter("FDeptID").ToString(); string FAccountId = this.View.OpenParameter.GetCustomParameter("FAccountId") == null ? "0" : this.View.OpenParameter.GetCustomParameter("FAccountId").ToString(); string sql = string.Format(@"EXEC proc_czly_AccountDept @SDt='{0}', @EDt='{1}', @FOrgId='{2}', @FDeptId='{3}', @FAccountId='{4}'", FSDate, FEDate, FOrgId, FDeptID, FAccountId); Field textField = _currBusinessInfo.GetField("FField"); Field decimalField = _currBusinessInfo.GetField("FDecimal"); //var textApp = _currLayoutInfo.GetEntityAppearance("FField"); entityData = DBUtils.ExecuteDataSet(this.Context, sql).Tables[0]; // 获取生成的费用项目列 sql = string.Format(@"EXEC proc_czly_AccountOrg @SDt='{0}', @EDt='{1}', @FOrgId='{2}', @FDeptId='{3}', @FAccountId='{4}'", FSDate, FEDate, FOrgId, FDeptID, FAccountId); costItems = DBUtils.ExecuteDataSet(this.Context, sql).Tables[0]; for (int i = 0; i < entityData.Columns.Count; i++) { string name = "FField_" + (i + 1).ToString(); //Field field = new Field(); Field field; if (i == 0) { field = (Field)ObjectUtils.CreateCopy(textField); } else { field = (Field)ObjectUtils.CreateCopy(decimalField); // 增加合计列 GroupSumColumn sumColumn = new GroupSumColumn(); sumColumn.FieldKey = name; sumColumn.Precision = -1; sumColumn.SumType = 1; entity.GroupColumnInfo.AddGroupSumColumn(sumColumn); } field.DynamicProperty = null; //field.ElementType = ElementType.BarItemElementType_TextField; field.Entity = entity; field.EntityKey = entityKey; field.Key = name; field.FieldName = name; field.PropertyName = name; field.Name = new LocaleValue(name); _currBusinessInfo.Add(field); } _currBusinessInfo.Remove(textField); _currBusinessInfo.Remove(decimalField); // 强制要求重新构建单据的ORM模型 _currBusinessInfo.GetDynamicObjectType(true); // 输出动态调整后的单据逻辑元数据模型(BusinessInfo) e.BusinessInfo = _currBusinessInfo; e.BillBusinessInfo = _currBusinessInfo; }