private void LoanAdvancedCustomizableFields()
        {
            // fields
            List <CustomizableField> advancedCustomizableFields = ServicesProvider.GetInstance().
                                                                  GetCustomizableFieldsServices().
                                                                  SelectCustomizableFields(
                (int)Enum.Parse(typeof(OCustomizableFieldEntities), _entity.ToString()));

            // values
            List <CustomizableFieldValue> values =
                GetCustomizableFieldsServices().SelectCustomizableFieldValues(_linkId, _entityType);

            if (advancedCustomizableFields != null && advancedCustomizableFields.Count > 0)
            {
                foreach (CustomizableField field in advancedCustomizableFields)
                {
                    CustomProperty         myField          = null;
                    string                 fieldName        = field.Name;
                    CustomizableFieldValue value            = GetValueForField(values, fieldName);
                    string                 fieldDescription = field.Description;
                    switch (field.Type)
                    {
                    case OCustomizableFieldTypes.Boolean:
                        bool boolValue = value != null && bool.Parse(value.Value);
                        myField = new CustomProperty(fieldName, fieldDescription, boolValue, typeof(bool), false, true);
                        break;

                    case OCustomizableFieldTypes.Number:
                        object numberValue = value == null ? string.Empty : value.Value;
                        myField = new CustomProperty(fieldName, fieldDescription, numberValue, typeof(string), false, true);
                        break;

                    case OCustomizableFieldTypes.String:
                        string stringValue = value == null ? string.Empty : value.Value;
                        myField = new CustomProperty(fieldName, fieldDescription, stringValue, typeof(string), false, true);
                        break;

                    case OCustomizableFieldTypes.Date:
                        DateTime dateTime = value == null ? DateTime.Today : Converter.CustomFieldValueToDate(value.Value);
                        myField = new CustomProperty(fieldName, fieldDescription, dateTime, typeof(DateTime), false, true);
                        break;

                    case OCustomizableFieldTypes.Collection:
                        if (value == null)
                        {
                            _advancedFieldsCollections.Add(fieldName, field.Collection);
                            myField = new CustomProperty(fieldName, fieldDescription, string.Empty, typeof(CollectionType), false, true);
                        }
                        else
                        {
                            Collection.Items = value.Field.Collection;
                            if (value.Value != null)
                            {
                                _advancedFieldsCollections.Add(value.Field.Name, value.Field.Collection);
                                myField = new CustomProperty(value.Field.Name, value.Field.Description, Collection.Items[int.Parse(value.Value)],
                                                             typeof(CollectionType), false, true);
                            }
                            else
                            {
                                _advancedFieldsCollections.Add(value.Field.Name, value.Field.Collection);
                                myField = new CustomProperty(value.Field.Name, value.Field.Description, string.Empty, typeof(CollectionType), false, true);
                            }
                        }
                        break;

                    case OCustomizableFieldTypes.Client:
                        CustomClientField clientField;
                        if (value == null || value.Value == string.Empty)
                        {
                            clientField = CustomClientField.Empty;
                        }
                        else
                        {
                            int personId;
                            if (!int.TryParse(value.Value, out personId))
                            {
                                clientField = CustomClientField.Empty;
                            }
                            else
                            {
                                var clientService = ServiceProvider.GetClientServices();
                                var person        = clientService.FindPersonById(personId);
                                clientField = new CustomClientField(person);
                            }
                        }
                        myField = new CustomProperty(fieldName, fieldDescription, clientField, typeof(CustomClientField), false, true);
                        break;
                    }

                    _advancedFields.Add(myField);
                }
            }

            fieldGrid.Refresh();
        }
Ejemplo n.º 2
0
        private void LoanAdvancedCustomizableFields()
        {
            // fields
            List<CustomizableField> advancedCustomizableFields = ServicesProvider.GetInstance().
                GetCustomizableFieldsServices().
                SelectCustomizableFields(
                    (int) Enum.Parse(typeof (OCustomizableFieldEntities), _entity.ToString()));

            // values
            List<CustomizableFieldValue> values =
                GetCustomizableFieldsServices().SelectCustomizableFieldValues(_linkId, _entityType);

            if (advancedCustomizableFields != null && advancedCustomizableFields.Count > 0)
            {
                foreach (CustomizableField field in advancedCustomizableFields)
                {
                    CustomProperty myField = null;
                    string fieldName = field.Name;
                    CustomizableFieldValue value = GetValueForField(values, fieldName);
                    string fieldDescription = field.Description;
                    switch (field.Type)
                    {
                        case OCustomizableFieldTypes.Boolean:
                            bool boolValue = value != null && bool.Parse(value.Value);
                            myField = new CustomProperty(fieldName, fieldDescription, boolValue, typeof (bool), false, true);
                            break;
                        case OCustomizableFieldTypes.Number:
                            object numberValue = value == null ? string.Empty : value.Value;
                            myField = new CustomProperty(fieldName, fieldDescription, numberValue, typeof (string), false, true);
                            break;
                        case OCustomizableFieldTypes.String:
                            string stringValue = value == null ? string.Empty : value.Value;
                            myField = new CustomProperty(fieldName, fieldDescription, stringValue, typeof(string), false, true);
                            break;
                        case OCustomizableFieldTypes.Date:
                            DateTime dateTime = value == null ? DateTime.Today : Converter.CustomFieldValueToDate(value.Value);
                            myField = new CustomProperty(fieldName, fieldDescription, dateTime, typeof(DateTime), false, true);
                            break;
                        case OCustomizableFieldTypes.Collection:
                            if (value == null)
                            {
                                _advancedFieldsCollections.Add(fieldName, field.Collection);
                                myField = new CustomProperty(fieldName, fieldDescription, string.Empty, typeof(CollectionType), false, true);
                            }
                            else
                            {
                                Collection.Items = value.Field.Collection;
                                if (value.Value != null)
                                {
                                    _advancedFieldsCollections.Add(value.Field.Name, value.Field.Collection);
                                    myField = new CustomProperty(value.Field.Name, value.Field.Description, Collection.Items[int.Parse(value.Value)],
                                        typeof(CollectionType), false, true);
                                }
                                else
                                {
                                    _advancedFieldsCollections.Add(value.Field.Name, value.Field.Collection);
                                    myField = new CustomProperty(value.Field.Name, value.Field.Description, string.Empty, typeof(CollectionType), false, true);
                                }
                            }
                            break;
                        case OCustomizableFieldTypes.Client:
                            CustomClientField clientField;
                            if (value == null || value.Value == string.Empty)
                                clientField = CustomClientField.Empty;
                            else
                            {
                                int personId;
                                if (!int.TryParse(value.Value, out personId)) clientField = CustomClientField.Empty;
                                else
                                {
                                    var clientService = ServiceProvider.GetClientServices();
                                    var person = clientService.FindPersonById(personId);
                                    clientField = new CustomClientField(person);
                                }
                            }
                            myField = new CustomProperty(fieldName, fieldDescription, clientField, typeof(CustomClientField), false, true);
                            break;
                    }

                    _advancedFields.Add(myField);
                }
            }

            fieldGrid.Refresh();
        }
Ejemplo n.º 3
0
 protected override void HandleTierSelect(ClientSearchResult pClient)
 {
     var clientServices = ServicesProvider.GetInstance().GetClientServices();
     var person = clientServices.FindPersonById(pClient.Id);
     Value = new CustomClientField(person);
 }