protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (!this.IsPostBack) { ClientDataSet.EntityFieldDataTable table = EntityFieldProvider.GetEntityField(this.EntityFieldId); if (table.Count > 0) { ClientDataSet.EntityFieldRow row = table[0]; if (row != null) { switch ((EntityFieldType)row.EntityFieldTypeId) { case EntityFieldType.SingleSelectList: case EntityFieldType.MultipleSelectList: this.MasterPage.CustomName = string.Format(CultureInfo.InvariantCulture, Resources.EntityFieldListValuesControl_CustomNameFormat, row.Name); return; } } } List.ShowAddLink = false; } }
protected void EntityDataSource_Selected(object sender, ObjectDataSourceStatusEventArgs e) { if (e == null) { return; } ClientDataSet.EntityFieldDataTable table = e.ReturnValue as ClientDataSet.EntityFieldDataTable; if (table != null) { if (table.Count > 0) { ClientDataSet.EntityFieldRow row = table[0]; EntityFieldType fieldType = (EntityFieldType)row.EntityFieldTypeId; SwitchDataTypeFields(fieldType, (EntityFieldDataType)row.DataTypeId); (EditForm.Fields[4] as TextBoxField).Required = (!row.AllowDBNull); if (fieldType != EntityFieldType.Value) { (EditForm.Fields[5] as CheckBoxField).AutoPostBack = false; } ConfigureRangeValidators((EntityFieldDataType)row.DataTypeId, row.DecimalDigits , (EditForm.Fields[4] as TextBoxField), (EditForm.Fields[9] as TextBoxField), (EditForm.Fields[10] as TextBoxField)); } } }
public static Guid InsertEntityField(int entityFieldTypeId, string name, string description, int dataTypeId, string defaultValue , bool allowDBNull, bool unique, int maxLength, string minValue, string maxValue, int decimalDigits, int orderNumber , Guid entityId, Guid organizationId, Guid?instanceId, bool active) { ClientDataSet.EntityFieldDataTable table = new ClientDataSet.EntityFieldDataTable(); ClientDataSet.EntityFieldRow row = table.NewEntityFieldRow(); row.EntityFieldId = Guid.NewGuid(); row.EntityFieldTypeId = entityFieldTypeId; row.Name = name; row.Description = description; row.DataTypeId = dataTypeId; if ((EntityFieldType)entityFieldTypeId == EntityFieldType.Value) { row.DefaultValue = defaultValue; } row.AllowDBNull = allowDBNull; row.Unique = unique; row.MaxLength = maxLength; if (minValue != null) { row.MinValue = minValue; } if (maxValue != null) { row.MaxValue = maxValue; } row.DecimalDigits = decimalDigits; row.OrderNumber = orderNumber; row.EntityId = entityId; row.OrganizationId = organizationId; if (instanceId.HasValue) { row.InstanceId = instanceId.Value; } row.Active = active; table.AddEntityFieldRow(row); using (EntityFieldTableAdapter adapter = new EntityFieldTableAdapter(OrganizationProvider.GetConnectionString(organizationId))) { adapter.Update(row); } RemoveFromCache(); return(row.EntityFieldId); }
internal static EntityField CreateEntityField(ClientDataSet.EntityFieldRow value) { EntityField entityField = null; if (value != null) { string name = value.Name; if (!string.IsNullOrEmpty(name)) { Type dataType = null; switch ((EntityFieldDataType)value.DataTypeId) { case EntityFieldDataType.Text: dataType = typeof(string); break; case EntityFieldDataType.YesNo: dataType = typeof(bool); break; case EntityFieldDataType.DateTime: dataType = typeof(DateTime); break; case EntityFieldDataType.Numeric: dataType = ((value.DecimalDigits > 0) ? typeof(decimal) : typeof(int)); break; } if (dataType != null) { entityField = new EntityField(); entityField.Id = value.EntityFieldId; entityField.EntityFieldTypeId = value.EntityFieldTypeId; entityField.Name = name; entityField.MappedHierarchyEntity = (value.EntityFieldTypeId == 4); entityField.Description = value.Description; entityField.EntityFieldDataType = (EntityFieldDataType)value.DataTypeId; entityField.DataType = dataType; if (!value.IsDefaultValueNull()) { entityField.DefaultValue = Support.ConvertStringToType(value.DefaultValue, dataType); } entityField.AllowDBNull = value.AllowDBNull; entityField.Unique = value.Unique; entityField.MaxLength = value.MaxLength; if (!value.IsMinValueNull()) { entityField.MinValue = Support.ConvertStringToType(value.MinValue, dataType); } if (!value.IsMaxValueNull()) { entityField.MaxValue = Support.ConvertStringToType(value.MaxValue, dataType); } entityField.DecimalDigits = value.DecimalDigits; entityField.OrderNumber = value.OrderNumber; entityField.OrganizationId = value.OrganizationId; if (!value.IsInstanceIdNull()) { entityField.InstanceId = value.InstanceId; } entityField.Active = value.Active; entityField.IsCustom = true; LoadEntityFieldValues(entityField); } } } return(entityField); }