private void LoadComponentsProperties(int rowIndex) { Table table = GetSelectedTable(); if (table == null) return; string columnName = gridViewDetails[COL_COLUMNNAME, rowIndex].Value.ToString(); KPMappingEntity mappingEntity = null; using (ISession session = ActiveRecordConfiguration.GetISession()) { IQueryable<KPMappingEntity> queryable = session.Query<KPMappingEntity>() .Where(x => x.OwnerSchema.Equals(table.OwnerSchema) && x.Database.Equals(table.DatabaseName) && x.Table.Equals(table.Name) && x.Column.Equals(columnName)); mappingEntity = queryable.FirstOrDefault(); if (mappingEntity == null) { mappingEntity = new KPMappingEntity() { OwnerSchema = table.OwnerSchema, Database = table.DatabaseName, Table = table.Name, Column = columnName }; mappingEntity.SaveAndFlush(); } } var entityColumn = gridViewDetails.Rows[rowIndex].DataBoundItem as Column; KPComponentsFormsEnum? componentFormEnum = gridViewDetails[COL_COLUMNTYPEFORM, rowIndex].Value as KPComponentsFormsEnum?; if (componentFormEnum.HasValue) { switch (componentFormEnum.Value) { case KPComponentsFormsEnum.KPFormItemButton: break; case KPComponentsFormsEnum.KPFormItemCheckBox: { var entityControl = new KPFormItemCheckBoxEntity().GetEntityByMapping(mappingEntity, entityColumn); if (!entityColumn.IsNullable) entityControl.IsRequired = true; propertyForm.SelectedObject = entityControl; } break; case KPComponentsFormsEnum.KPFormItemCombo: { var entityControl = new KPFormItemComboEntity().GetEntityByMapping(mappingEntity, entityColumn); if (!entityColumn.IsNullable) entityControl.IsRequired = true; propertyForm.SelectedObject = entityControl; } break; case KPComponentsFormsEnum.KPFormItemEntity: { var entityControl = new KPFormItemEntityEntity().GetEntityByMapping(mappingEntity, entityColumn); if (!entityColumn.IsNullable) entityControl.IsRequired = true; propertyForm.SelectedObject = entityControl; } break; case KPComponentsFormsEnum.KPFormItemGrid: { var entityControl = new KPFormItemGridEntity().GetEntityByMapping(mappingEntity, entityColumn); if (!entityColumn.IsNullable) entityControl.IsRequired = true; propertyForm.SelectedObject = entityControl; } break; case KPComponentsFormsEnum.KPFormItemPassword: { var entityControl = new KPFormItemPasswordEntity().GetEntityByMapping(mappingEntity, entityColumn); if (!entityColumn.IsNullable) entityControl.IsRequired = true; propertyForm.SelectedObject = entityControl; } break; case KPComponentsFormsEnum.KPFormItemText: { var entityControl = new KPFormItemTextEntity().GetEntityByMapping(mappingEntity, entityColumn); if (!entityColumn.IsNullable) entityControl.IsRequired = true; if (entityColumn.MappedDataType == typeof(DateTime) || entityColumn.MappedDataType == typeof(DateTime?)) entityControl.MaskType = KPMaskTypeClassEnum.DATETIME; propertyForm.SelectedObject = entityControl; } break; case KPComponentsFormsEnum.KPFormItemDateTime: { var entityControl = new KPFormItemDateTimeEntity().GetEntityByMapping(mappingEntity, entityColumn); if (!entityColumn.IsNullable) entityControl.IsRequired = true; propertyForm.SelectedObject = entityControl; } break; case KPComponentsFormsEnum.KPFormItemZoom: { var entityControl = new KPFormItemZoomEntity().GetEntityByMapping(mappingEntity, entityColumn); if (!entityColumn.IsNullable) entityControl.IsRequired = true; propertyForm.SelectedObject = entityControl; } break; default: propertyForm.SelectedObject = null; break; } } KPComponentsViewEnum? componentViewEnum = gridViewDetails[COL_COLUMNTYPEVIEW, rowIndex].Value as KPComponentsViewEnum?; if (componentViewEnum.HasValue) { switch (componentViewEnum.Value) { case KPComponentsViewEnum.KPColumnModel: { var entityControl = new KPColumnModelEntity().GetEntityByMapping(mappingEntity, entityColumn); if (entityColumn.IsPrimaryKey) entityControl.IsVisible = false; if (entityColumn.MappedDataType == typeof(DateTime) || entityColumn.MappedDataType == typeof(DateTime?)) entityControl.MaskType = KPMaskTypeClassEnum.DATETIME; propertyView.SelectedObject = entityControl; } break; case KPComponentsViewEnum.KPEnumModel: { var entityControl = new KPEnumModelEntity().GetEntityByMapping(mappingEntity, entityColumn); propertyView.SelectedObject = entityControl; } break; case KPComponentsViewEnum.KPEntityModel: { var entityControl = new KPEntityModelEntity().GetEntityByMapping(mappingEntity, entityColumn); propertyView.SelectedObject = entityControl; } break; case KPComponentsViewEnum.KPBooleanModel: { var entityControl = new KPBooleanModelEntity().GetEntityByMapping(mappingEntity, entityColumn); propertyView.SelectedObject = entityControl; } break; default: propertyView.SelectedObject = null; break; } } }
public static ActiveRecordBase GetEntityControlForm(Column column) { ActiveRecordBase entity = null; if (column == null) return null; Table selectedTable = column.Table; using (ISession session = ActiveRecordConfiguration.GetISession()) { IQueryable<KPMappingEntity> queryable = session.Query<KPMappingEntity>() .Where(x => x.OwnerSchema.Equals(selectedTable.OwnerSchema) && x.Database.Equals(selectedTable.DatabaseName) && x.Table.Equals(selectedTable.Name) && x.Column.Equals(column.Name)); KPMappingEntity mapEntity = queryable.FirstOrDefault(); if (mapEntity != null) { switch (column.ColumnTypeForm) { case KPComponentsFormsEnum.KPFormItemButton: entity = new KPFormItemButtonEntity().GetEntityByMapping(mapEntity, column); break; case KPComponentsFormsEnum.KPFormItemCheckBox: entity = new KPFormItemCheckBoxEntity().GetEntityByMapping(mapEntity, column); break; case KPComponentsFormsEnum.KPFormItemCombo: entity = new KPFormItemComboEntity().GetEntityByMapping(mapEntity, column); break; case KPComponentsFormsEnum.KPFormItemEntity: entity = new KPFormItemEntityEntity().GetEntityByMapping(mapEntity, column); break; case KPComponentsFormsEnum.KPFormItemGrid: entity = new KPFormItemGridEntity().GetEntityByMapping(mapEntity, column); break; case KPComponentsFormsEnum.KPFormItemPassword: entity = new KPFormItemPasswordEntity().GetEntityByMapping(mapEntity, column); break; case KPComponentsFormsEnum.KPFormItemText: entity = new KPFormItemTextEntity().GetEntityByMapping(mapEntity, column); break; case KPComponentsFormsEnum.KPFormItemDateTime: entity = new KPFormItemDateTimeEntity().GetEntityByMapping(mapEntity, column); break; case KPComponentsFormsEnum.KPFormItemZoom: entity = new KPFormItemZoomEntity().GetEntityByMapping(mapEntity, column); break; } } } return entity; }
private string GetControlKPFormItemGridEntity(Column column) { string propertyConcat = String.Empty; KPFormItemGridEntity entity = column.EntityComponentForm as KPFormItemGridEntity; if (entity == null) entity = new KPFormItemGridEntity(); var isRequired = entity.IsRequired; var height = entity.Height; var eventDeleteLine = entity.KPEventDeleteLine; if (height > 0) propertyConcat += String.Format(@" Height=""{0}""", height); if (isRequired) propertyConcat += String.Format(@" IsRequired=""{0}""", isRequired.ToString().ToLower()); if (eventDeleteLine) propertyConcat += String.Format(@" OnKPDeleteLine=""{0}_KPDeleteLine""", column.Name.GetFormattedText()); return propertyConcat; }