Exemple #1
0
        private List <string> CreatePropertySource(BankImportFormatClient bankImportFormatClient)
        {
            var propertyInfos = UtilFunctions.GetDisplayAttributeNonReadOnlyPropertiesFromType(bankImportFormatClient.GetType(), true);

            List <string> propertySource = new List <string>(propertyInfos.Count);

            foreach (var propInfo in propertyInfos)
            {
                if (propInfo.PropertyType == typeof(byte))
                {
                    if (propInfo.Name == "SkipLines")
                    {
                        continue;
                    }

                    propertySource.Add(string.Format("{0} ({1})", propInfo.Name, UtilFunctions.GetDisplayNameFromPropertyInfo(propInfo)));
                }
            }
            return(propertySource);
        }
Exemple #2
0
        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            if (customDataColumnSource == null || customDataColumnSource.Count == 0 || bankImportFormat == null)
            {
                DialogResult = true;
                return;
            }
            var bankformatPositionProps = UtilFunctions.GetDisplayAttributeNonReadOnlyPropertiesFromType(bankImportFormat.GetType(), true);

            var strSplit = new StringSplit('(');

            foreach (var propInfo in bankformatPositionProps)
            {
                if (propInfo.PropertyType == typeof(byte))
                {
                    var propName = propInfo.Name;

                    if (propName == "SkipLines")
                    {
                        continue;
                    }

                    CustomDataColumn selectedCustomCol = null;
                    foreach (var col in customDataColumnSource)
                    {
                        if (col.ActualDataColumnName != null && col.ActualDataColumnName.Contains(propName))
                        {
                            selectedCustomCol = col;
                            break;
                        }
                    }

                    if (selectedCustomCol != null)
                    {
                        var selectedItem = selectedCustomCol.ActualDataColumnName;
                        var propertyName = strSplit.Split(selectedItem).First();

                        var prop = bankImportFormat.GetType().GetProperty(propertyName);
                        if (prop != null)
                        {
                            prop.SetValue(bankImportFormat, (byte)selectedCustomCol.DataColumnIndex, null);
                        }
                    }
                    else
                    {
                        propInfo.SetValue(bankImportFormat, (byte)0, null); // reset the value
                    }
                }
            }

            //Setting the delimiter value from the file to the bankformat
            if (updateDelimiter)
            {
                var seperatorProp = bankImportFormat.GetType().GetProperty("Seperator");
                if (seperatorProp != null)
                {
                    var sepValue = (char)seperatorProp.GetValue(bankImportFormat);
                    if (sepValue.CompareTo(fileDelimiter) != 0)
                    {
                        seperatorProp.SetValue(bankImportFormat, fileDelimiter, null);
                    }
                }
            }

            DialogResult = true;
        }