Esempio n. 1
0
        private void nameValueListToolStripMenuItem_Click(object sender, EventArgs e)
        {
            IColumnInfo pkColumn    = null;
            IColumnInfo valueColumn = null;

            foreach (IColumnInfo info in dbColumns1.ListColumns.SelectedItems)
            {
                if (info.IsPrimaryKey)
                {
                    pkColumn = info;
                }
                else
                {
                    valueColumn = info;
                }
            }
            if (pkColumn != null && valueColumn != null && dbColumns1.ListColumns.SelectedItems.Count == 2)
            {
                NewObjectDefaults frm = NewObjectDefaults.NewNVLProperties();

                if (frm.ShowDialog() == DialogResult.OK)
                {
                    string collectionName = frm.GetPropertyValue("CollectionName");
                    NewNVL(collectionName);
                    AddPropertiesForSelectedColumns();
                    _currentCslaObject.NameColumn  = valueColumn.ColumnName;
                    _currentCslaObject.ValueColumn = pkColumn.ColumnName;
                }
            }
            else
            {
                MessageBox.Show(@"You must select a PK column and a non PK column in order to automatically create a name value list. If you need to create a NVL and can't meet this requirement, create a new object manually through the toolbar.", "New NVL", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 2
0
        private void editableChildCollectionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            NewObjectDefaults frm = NewObjectDefaults.NewChildListProperties();

            if (frm.ShowDialog() == DialogResult.OK)
            {
                string         collectionName = frm.GetPropertyValue("CollectionName");
                string         itemName       = frm.GetPropertyValue("ItemName");
                string         parentName     = frm.GetPropertyValue("ParentType");
                string         propertyName   = frm.GetPropertyValue("PropertyNameInParentType");
                CslaObjectInfo parent         = _currentUnit.CslaObjects.Find(parentName);
                if (parent == null)
                {
                    MessageBox.Show(@"Parent type not found", @"CslaGenerator", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                NewCollection(CslaObjectType.EditableChildCollection, collectionName, itemName, parentName);
                NewObject(CslaObjectType.EditableChild, itemName, collectionName);
                AddPropertiesForSelectedColumns();
                ArrayList lst = new ArrayList();
                foreach (ValueProperty p in parent.ValueProperties)
                {
                    if (p.PrimaryKey != ValueProperty.UserDefinedKeyBehaviour.Default)
                    {
                        lst.Add(p);
                    }
                }
                foreach (Property p in lst)
                {
                    _currentCslaObject.ParentProperties.Add(p);
                }
                ChildProperty col = new ChildProperty();
                col.TypeName = collectionName;
                if (!string.IsNullOrEmpty(propertyName))
                {
                    col.Name = propertyName;
                }
                else
                {
                    col.Name = collectionName;
                }
                col.ReadOnly = true;
                foreach (var crit in parent.CriteriaObjects)
                {
                    if (crit.GetOptions.Factory || crit.GetOptions.AddRemove || crit.GetOptions.DataPortal)
                    {
                        foreach (var prop in crit.Properties)
                        {
                            col.LoadParameters.Add(new Parameter(crit, prop));
                        }
                    }
                }
                parent.ChildCollectionProperties.Add(col);
            }
        }
Esempio n. 3
0
        private void dynamicEditableRootCollectionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            NewObjectDefaults frm = NewObjectDefaults.NewReadOnlyListProperties();

            if (frm.ShowDialog() == DialogResult.OK)
            {
                string collectionName = frm.GetPropertyValue("CollectionName");
                string itemName       = frm.GetPropertyValue("ItemName");
                NewCollection(CslaObjectType.DynamicEditableRootCollection, collectionName, itemName);
                NewObject(CslaObjectType.DynamicEditableRoot, itemName, collectionName);
                AddPropertiesForSelectedColumns();
            }
        }