Ejemplo n.º 1
0
        private void generateFieldList()
        {
            // add fields from primary type
            fieldComboBox.Items.Clear();
            foreach (DBField currField in DBField.GetFieldList(Table))
            {
                if (currField.Filterable && currField.AllowDynamicFiltering)
                {
                    ComboFieldWrapper wrapper = new ComboFieldWrapper(currField);
                    wrapperLookup[currField] = wrapper;
                    fieldComboBox.Items.Add(wrapper);
                }
            }

            // add fields from secondary types
            foreach (DBRelation currRelation in DBRelation.GetRelations(Table))
            {
                if (!currRelation.Filterable)
                {
                    continue;
                }

                foreach (DBField currField in DBField.GetFieldList(currRelation.SecondaryType))
                {
                    if (currField.Filterable && currField.AllowDynamicFiltering)
                    {
                        ComboFieldWrapper wrapper = new ComboFieldWrapper(currField, currRelation);
                        wrapperLookup[currField] = wrapper;
                        fieldComboBox.Items.Add(wrapper);
                    }
                }
            }

            fieldComboBox.SelectedIndex = 0;
        }
Ejemplo n.º 2
0
        // initialize all values of the given object. essentially makes the object a new refernece
        // and a new row will be created if commited
        public void Clear()
        {
            id                 = null;
            commitNeeded       = true;
            RetrievalInProcess = true;

            ReadOnlyCollection <DBField> fieldList = DBField.GetFieldList(this.GetType());

            foreach (DBField currField in fieldList)
            {
                object defaultVal = currField.Default;
                currField.SetValue(this, defaultVal);

                // if this is a dynamic (internally changable) object, setup a listener
                if (defaultVal != null && defaultVal.GetType() == typeof(IDynamic))
                {
                    ((IDynamic)defaultVal).Changed += new ChangedEventHandler(commitNeededEventHandler);
                }
            }

            ReadOnlyCollection <DBRelation> relationList = DBRelation.GetRelations(this.GetType());

            foreach (DBRelation currRelation in relationList)
            {
                try {
                    currRelation.GetRelationList(this).Changed += new ChangedEventHandler(commitNeededEventHandler);
                }
                catch (NullReferenceException) {
                    throw new System.InvalidOperationException("RelationLists must be initialized in the get{} property method.");
                }
            }

            RetrievalInProcess = false;
        }
Ejemplo n.º 3
0
        private void populateFieldCombo()
        {
            fieldChanging = true;

            // add fields from primary type
            fieldComboBox.Items.Clear();
            foreach (DBField currField in DBField.GetFieldList(typeof(T)))
            {
                if (currField.Filterable)
                {
                    ComboFieldWrapper wrapper = new ComboFieldWrapper(currField);
                    wrapperLookup[currField] = wrapper;
                    fieldComboBox.Items.Add(wrapper);
                }
            }

            // add fields from secondary types
            foreach (DBRelation currRelation in DBRelation.GetRelations(typeof(T)))
            {
                if (!currRelation.Filterable)
                {
                    continue;
                }

                foreach (DBField currField in DBField.GetFieldList(currRelation.SecondaryType))
                {
                    if (currField.Filterable)
                    {
                        ComboFieldWrapper wrapper = new ComboFieldWrapper(currField, currRelation);
                        wrapperLookup[currField] = wrapper;
                        fieldComboBox.Items.Add(wrapper);
                    }
                }
            }

            if (Criteria != null && Criteria.Field != null && wrapperLookup.ContainsKey(Criteria.Field))
            {
                fieldComboBox.SelectedItem = wrapperLookup[Criteria.Field];
            }
            else
            {
                fieldComboBox.SelectedIndex = 0;
            }

            fieldChanging = false;
        }
Ejemplo n.º 4
0
        // create the dictionary to map variables to the correct values for this movie
        public static Dictionary <string, string> getVariableMapping(DatabaseTable obj)
        {
            // add fields from primary object
            Dictionary <string, string> replacementStrings = new Dictionary <string, string>();

            foreach (DBField currField in DBField.GetFieldList(obj.GetType()))
            {
                if (currField.Filterable && currField.GetValue(obj) != null)
                {
                    replacementStrings[currField.FieldName] = currField.GetValue(obj).ToString().Trim();
                }
            }

            // add fields from secondary types
            foreach (DBRelation currRelation in DBRelation.GetRelations(obj.GetType()))
            {
                if (!currRelation.Filterable)
                {
                    continue;
                }

                if (currRelation.GetRelationList(obj).Count > 0)
                {
                    DatabaseTable subObj = (DatabaseTable)currRelation.GetRelationList(obj)[0];

                    foreach (DBField currField in DBField.GetFieldList(currRelation.SecondaryType))
                    {
                        if (currField.Filterable && currField.GetValue(subObj) != null)
                        {
                            replacementStrings[currField.FieldName] = currField.GetValue(subObj).ToString().Trim();
                        }
                    }
                }
            }

            return(replacementStrings);
        }