Exemplo n.º 1
0
        private void SetAddNewProductMode(bool state)
        {
            isAddMode = state;

            buttonDeleteProperty.Visible = state;
            buttonDeleteListItem.Visible = state;

            if (state)
            {
                Text = GetString("titleAdd");

                // Adding default properties
                CustomProperty propertyAmount = new CustomProperty(GetString("propertyAmount"), GetString("propertyAmountDescription"),
                    GetString("typeNumber"), typeof(int), true, true);
                myProperties.Add(propertyAmount);

                CustomProperty propertyDesc = new CustomProperty(GetString("propertyDescription"), GetString("propertyDescriptionDescription"),
                    GetString("typeString"), typeof(string), true, true);
                myProperties.Add(propertyDesc);
            }
            else
            {
                Text = GetString("titleEdit");
            }
        }
Exemplo n.º 2
0
        private void buttonAddProperty_Click(object sender, EventArgs e)
        {
            if (myProperties.Contains(textBoxPropertyName.Text))
            {
                MessageBox.Show("Property name must be unique!");
            }
            else
            {
                CustomProperty myProp = null;
                List<string> list = new List<string>();
                var type = (OCollateralPropertyTypes) Enum.Parse(typeof(OCollateralPropertyTypes), GetString(comboBoxPropertyTypes.Text), true);

                if (type == OCollateralPropertyTypes.Collection)
                {
                    if (listBox.Items.Count < 1)
                    {
                        MessageBox.Show("Please add at least one item to the collection!");
                        return;
                    }

                    foreach (string item in listBox.Items) list.Add(item);
                    myProp = new CustomProperty(textBoxPropertyName.Text, textBoxPropertyDesc.Text, list, typeof(List<string>), true, true);
                }
                else
                {
                    myProp = new CustomProperty(textBoxPropertyName.Text, textBoxPropertyDesc.Text, GetString("type"+type), typeof(string), true, true);
                }

                myProperties.Add(myProp);
                propertyGrid.Refresh();

                if (!isAddMode)
                {
                    CollateralProperty property = new CollateralProperty();
                    property.Name = textBoxPropertyName.Text;
                    property.Description = textBoxPropertyDesc.Text;

                    if (type == OCollateralPropertyTypes.Collection)
                    {
                        property.Type = OCollateralPropertyTypes.Collection;
                        property.Collection = list;
                    }
                    else
                    {
                        property.Type = (OCollateralPropertyTypes)Enum.Parse(typeof(OCollateralPropertyTypes), GetString(comboBoxPropertyTypes.Text), true);
                    }

                    editPropertyList.Add(property);
                }

                textBoxPropertyName.Text = string.Empty;
                textBoxPropertyDesc.Text = string.Empty;
                listBox.Items.Clear();
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Add CustomProperty to Collectionbase List
 /// </summary>
 /// <param name="value"></param>
 public void Add(CustomProperty value)
 {
     List.Add(value);
 }
Exemplo n.º 4
0
        private void InitializeProductValues()
        {
            textBoxProductName.Text = collateralProduct.Name;
            textBoxProductDesc.Text = collateralProduct.Description;

            CustomProperty myProp = null;
            foreach (CollateralProperty property in collateralProduct.Properties)
            {
                if (property.Type == OCollateralPropertyTypes.Collection)
                {
                    myProp = new CustomProperty(property.Name, property.Description, property.Collection, typeof(List<string>), true, true);
                }
                else
                {
                    myProp = new CustomProperty(property.Name, property.Description, GetString("type"+property.Type), typeof(string), true, true);
                }
                myProperties.Add(myProp);
            }
            propertyGrid.Refresh();
        }
Exemplo n.º 5
0
        private void buttonAddProperty_Click(object sender, EventArgs e)
        {
            try
            {
                if (_myFields.Contains(textBoxFieldName.Text) || _myFields.Contains(textBoxFieldName.Text + "*"))
                {
                    MessageBox.Show(GetString("textUniqueField"));

                }

                string fieldName = textBoxFieldName.Text;
                if (checkBoxNewMandatory.Checked) fieldName += "*";

                CustomProperty myField;
                List<string> list = new List<string>();
                var type = (OCustomizableFieldTypes)Enum.Parse(typeof(OCustomizableFieldTypes), GetString(comboBoxFieldTypes.Text), true);

                if (type == OCustomizableFieldTypes.Collection)
                {
                    if (listBox.Items.Count < 1)
                    {
                        MessageBox.Show(GetString("textAddOneItem"));
                        return;
                    }

                    foreach (string item in listBox.Items) list.Add(item);
                    {
                        myField = new CustomProperty(fieldName, textBoxFieldDesc.Text, list, typeof(CustomCollection), true,
                                                     true);
                    }
                }
                else
                {
                    myField = new CustomProperty(fieldName, textBoxFieldDesc.Text, GetString("type" + type),
                                                 typeof(string), true, true);
                }

                _myFields.Add(myField);
                fieldGrid.Refresh();

                CustomizableField field = new CustomizableField
                {
                    Name = fieldName,
                    Description = textBoxFieldDesc.Text,
                    Entity =
                        (OCustomizableFieldEntities)
                        Enum.Parse(typeof(OCustomizableFieldEntities),
                                   GetString(comboBoxEntities.Text), true),
                    IsMandatory = checkBoxNewMandatory.Checked,
                    IsUnique = checkBoxNewUnique.Checked
                };

                if (type == OCustomizableFieldTypes.Collection)
                {
                    field.Type = OCustomizableFieldTypes.Collection;
                    field.Collection = list;
                }
                else
                {
                    field.Type = (OCustomizableFieldTypes)Enum.Parse(typeof(OCustomizableFieldTypes), GetString(comboBoxFieldTypes.Text), true);
                }

                if (_isAddMode)
                    _fieldList.Add(field);
                else
                    _editFieldList.Add(field);

                textBoxFieldName.Text = string.Empty;
                textBoxFieldDesc.Text = string.Empty;
                listBox.Items.Clear();
            }
            catch (Exception ex)
            {
                new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
            }
        }
Exemplo n.º 6
0
 public CustomPropertyDescriptor(ref CustomProperty customProperty, Attribute [] attrs) : base(customProperty.Name, attrs)
 {
     _customProperty = customProperty;
 }
Exemplo n.º 7
0
        private void FillCollateralPropertyValues(ContractCollateral contractCollateral)
        {
            foreach (CollateralPropertyValue propertyValue in contractCollateral.PropertyValues)
            {
                CustomProperty myProp = null;
                if (propertyValue.Property.Type == OCollateralPropertyTypes.Number)
                {
                    myProp = new CustomProperty(propertyValue.Property.Name, propertyValue.Property.Description,
                        Converter.CustomFieldValueToDecimal(propertyValue.Value), typeof(decimal), false, true);
                }
                else if (propertyValue.Property.Type == OCollateralPropertyTypes.String)
                {
                    myProp = new CustomProperty(propertyValue.Property.Name, propertyValue.Property.Description,
                        propertyValue.Value, typeof(string), false, true);
                }
                else if (propertyValue.Property.Type == OCollateralPropertyTypes.Date)
                {
                    myProp = new CustomProperty(propertyValue.Property.Name, propertyValue.Property.Description,
                        Converter.CustomFieldValueToDate(propertyValue.Value), typeof(DateTime), false, true);
                }
                else if (propertyValue.Property.Type == OCollateralPropertyTypes.Collection)
                {
                    if (propertyValue.Value != null)
                    {
                        Collection.Items = propertyValue.Property.Collection;
                        collections.Add(propertyValue.Property.Name, propertyValue.Property.Collection);
                        myProp = new CustomProperty(propertyValue.Property.Name, propertyValue.Property.Description,
                            Collection.Items[int.Parse(propertyValue.Value)], typeof(CollectionType), false, true);
                    }
                    else
                    {
                        Collection.Items = propertyValue.Property.Collection;
                        collections.Add(propertyValue.Property.Name, propertyValue.Property.Collection);
                        myProp = new CustomProperty(propertyValue.Property.Name, propertyValue.Property.Description,
                            string.Empty, typeof(CollectionType), false, true);
                    }
                }
                else if (propertyValue.Property.Type == OCollateralPropertyTypes.Owner)
                {
                    if (propertyValue.Value != null)
                    {
                        Person client = (Person)ServicesProvider.GetInstance().GetClientServices().FindTiers(int.Parse(propertyValue.Value), OClientTypes.Person);
                        myProp = new CustomProperty(propertyValue.Property.Name, propertyValue.Property.Description, client, typeof(Person), false, true);
                    }
                    else
                    {
                        myProp = new CustomProperty(propertyValue.Property.Name, propertyValue.Property.Description, string.Empty, typeof(Person), false, true);
                    }
                }

                myProperties.Add(myProp);
            }
            propertyGrid.Refresh();
        }
Exemplo n.º 8
0
        private void FillCollateralProperties()
        {
            foreach(CollateralProperty property in product.Properties)
            {
                CustomProperty myProp = null;
                if (property.Type == OCollateralPropertyTypes.Number)
                {
                    myProp = new CustomProperty(property.Name, property.Description, new decimal(), typeof(decimal), false, true);
                }
                else if (property.Type == OCollateralPropertyTypes.String)
                {
                    myProp = new CustomProperty(property.Name, property.Description, string.Empty, typeof(string), false, true);
                }
                else if (property.Type == OCollateralPropertyTypes.Date)
                {
                    myProp = new CustomProperty(property.Name, property.Description, new DateTime(), typeof(DateTime), false, true);
                }
                else if (property.Type == OCollateralPropertyTypes.Collection)
                {
                    collections.Add(property.Name, property.Collection);
                    myProp = new CustomProperty(property.Name, property.Description, string.Empty, typeof(CollectionType), false, true);
                }
                else if (property.Type == OCollateralPropertyTypes.Owner)
                {
                    myProp = new CustomProperty(property.Name, property.Description, string.Empty, typeof(Person), false, true);
                }

                myProperties.Add(myProp);
            }

            propertyGrid.Refresh();

            /*
            // guarantor
            IClient client = SelectGuarantor();
            if (client != null)
                AddCollateralProperty("Guarantor", client);
            */

            /*CustomProperty myProp = new CustomProperty(propName, client, typeof(IClient), true, true);
            myProperties.Add(myProp);
            propertyGrid.Refresh();*/

            /*private void toolStripMenuItemString_Click(object sender, EventArgs e)
            {
                var myclient = (IClient)propertyGrid.SelectedGridItem.Value;
                MessageBox.Show(((Person)myclient).FirstName + " " + ((Person)myclient).LastName);
            }*/
        }
Exemplo n.º 9
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();
        }
Exemplo n.º 10
0
 public CustomPropertyDescriptor(ref CustomProperty customProperty, Attribute [] attrs)
     : base(customProperty.Name, attrs)
 {
     _customProperty = customProperty;
 }
Exemplo n.º 11
0
 /// <summary>
 /// Add CustomProperty to Collectionbase List
 /// </summary>
 /// <param name="value"></param>
 public void Add(CustomProperty value)
 {
     List.Add(value);
 }