Пример #1
0
        public EditRelationDialog(ActiveRecordDescriptor descriptor, Project project, ActiveRecordPropertyRelationDescriptor prop) : base(descriptor, project)
        {
            // This call is required by the Windows Form Designer.
            InitializeComponent();

            AssociationEnum assoc = AssociationEnum.Undefined;

            if (prop is ActiveRecordHasManyDescriptor)
            {
                hasManyButton.Checked = true;
                assoc = AssociationEnum.HasMany;
            }
            else if (prop is ActiveRecordBelongsToDescriptor)
            {
                belongsToButton.Checked = true;
                assoc = AssociationEnum.BelongsTo;
            }
            else if (prop is ActiveRecordHasAndBelongsToManyDescriptor)
            {
                hasAndBelongsToManyButton.Checked = true;
                assoc = AssociationEnum.HasAndBelongsToMany;
            }

            SelectedTarget = prop.TargetType;

            SwitchViewTo(assoc);
        }
Пример #2
0
		public RelationshipInfo(AssociationEnum association, ActiveRecordDescriptor descriptor, ActiveRecordDescriptor targetDescriptor)
		{
			if (association == AssociationEnum.Undefined) throw new ArgumentException("association");
			if (descriptor == null) throw new ArgumentNullException("descriptor");
			if (targetDescriptor == null) throw new ArgumentNullException("targetDescriptor");

			this.association = association;
			this.descriptor = descriptor;
			this.targetDescriptor = targetDescriptor;
		}
Пример #3
0
        protected void SwitchViewTo(AssociationEnum association)
        {
            // Nothing's changed?
            if (_oldDescSelection == SelectedTarget && association == _association)
            {
                // Aparently not
                return;
            }

            // Saves
            _oldDescSelection = SelectedTarget;
            _association      = association;

            // Disabling
            associationTable.Enabled = associationTableLabel.Enabled = false;
            parentCols.Enabled       = parentColsLabel.Enabled = false;
            relatedCols.Enabled      = relatedColsLabel.Enabled = false;

            if (association == AssociationEnum.BelongsTo)
            {
                parentCols.Enabled = parentColsLabel.Enabled = true;

                PopulateColumnsInListBox(parentCols, _descriptor.Table);
            }
            else if (association == AssociationEnum.HasAndBelongsToMany)
            {
                associationTable.Enabled = associationTableLabel.Enabled = true;
                parentCols.Enabled       = parentColsLabel.Enabled = true;
                relatedCols.Enabled      = relatedColsLabel.Enabled = true;

                associationTable.SelectedIndex = -1;

                parentCols.Items.Clear();
                relatedCols.Items.Clear();

                PopulateTablesInComboBox(associationTable, _descriptor.Table.DatabaseDefinition);
            }
            else if (association == AssociationEnum.HasMany)
            {
                relatedCols.Enabled = relatedColsLabel.Enabled = true;

                PopulateColumnsInListBox(relatedCols, SelectedTarget.Table);
            }
        }
        public RelationshipInfo(AssociationEnum association, ActiveRecordDescriptor descriptor, ActiveRecordDescriptor targetDescriptor)
        {
            if (association == AssociationEnum.Undefined)
            {
                throw new ArgumentException("association");
            }
            if (descriptor == null)
            {
                throw new ArgumentNullException("descriptor");
            }
            if (targetDescriptor == null)
            {
                throw new ArgumentNullException("targetDescriptor");
            }

            this.association      = association;
            this.descriptor       = descriptor;
            this.targetDescriptor = targetDescriptor;
        }
Пример #5
0
		protected void SwitchViewTo(AssociationEnum association)
		{
			// Nothing's changed?
			if (_oldDescSelection == SelectedTarget && association == _association)
			{
				// Aparently not
				return;
			}

			// Saves 
			_oldDescSelection = SelectedTarget;
			_association = association;

			// Disabling
			associationTable.Enabled = associationTableLabel.Enabled = false;
			parentCols.Enabled = parentColsLabel.Enabled = false;
			relatedCols.Enabled = relatedColsLabel.Enabled = false;

			if (association == AssociationEnum.BelongsTo)
			{
				parentCols.Enabled = parentColsLabel.Enabled = true;

				PopulateColumnsInListBox( parentCols, _descriptor.Table);
			}
			else if (association == AssociationEnum.HasAndBelongsToMany)
			{
				associationTable.Enabled = associationTableLabel.Enabled = true;
				parentCols.Enabled = parentColsLabel.Enabled = true;
				relatedCols.Enabled = relatedColsLabel.Enabled = true;

				associationTable.SelectedIndex = -1;

				parentCols.Items.Clear();
				relatedCols.Items.Clear();

				PopulateTablesInComboBox(associationTable, _descriptor.Table.DatabaseDefinition);
			}
			else if (association == AssociationEnum.HasMany)
			{
				relatedCols.Enabled = relatedColsLabel.Enabled = true;

				PopulateColumnsInListBox( relatedCols, SelectedTarget.Table);
			}
		}