コード例 #1
0
        /// <summary>
        /// Deliberately adds BO to the grid's collection because current habanero model only
        /// adds BO to grid when it is saved.  This causes a problem when you call col.CreateBO(), since
        /// it adds the BO twice and throws a duplicate key exception.
        /// </summary>a
        private void NewButtonClicked(object sender, EventArgs e)
        {
            _newBO = null;
            IBusinessObject currentBO = CurrentBusinessObject;

            if (currentBO != null)
            {
                if (!currentBO.IsValid())
                {
                    _iboEditorControl.DisplayErrors();
                    return;
                }
                currentBO.Save();
            }

            IBusinessObjectCollection collection = _readOnlyGridControl.Grid.BusinessObjectCollection;

            _readOnlyGridControl.Grid.SelectionChanged -= GridSelectionChanged;
            _newBO = collection.CreateBusinessObject();
            // _readOnlyGridControl.Grid.GetBusinessObjectCollection().Add(businessObject);
            _readOnlyGridControl.SelectedBusinessObject = _newBO;
            CurrentBusinessObject = _newBO;
            UpdateControlEnabledState();
            //collection.Add(businessObject);
            _readOnlyGridControl.Grid.SelectionChanged += GridSelectionChanged;
            GridSelectionChanged(null, null);
            _iboEditorControl.Focus();
            _iboEditorControl.ClearErrors();
            _cancelButton.Enabled = true;
        }
コード例 #2
0
        public void TestColIsInstantiatedButNotLoaded()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            OrganisationTestBO.LoadDefaultClassDef();
            IClassDef contactPersonClassDef = ContactPersonTestBO.LoadClassDefOrganisationTestBORelationship_MultipleReverse();
            RelKeyDef keyDef = new RelKeyDef();

            keyDef.Add(new RelPropDef(contactPersonClassDef.PropDefcol["OrganisationID"], "OrganisationID"));
            MultipleRelationshipDef def = new MultipleRelationshipDef
                                              (TestUtil.GetRandomString(), typeof(ContactPersonTestBO),
                                              keyDef, false, "", DeleteParentAction.DoNothing);

            OrganisationTestBO organisation = new OrganisationTestBO();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            IMultipleRelationship rel = (IMultipleRelationship)def.CreateRelationship(organisation, organisation.Props);

            //---------------Test Result -----------------------

            IBusinessObjectCollection collection = rel.BusinessObjectCollection;

            Assert.IsNotNull(collection);
            Assert.AreEqual(0, collection.Count);
            Assert.AreSame(contactPersonClassDef, collection.ClassDef);
            Assert.IsNotNull(collection.SelectQuery.Criteria);
            Assert.IsNotNull(collection.SelectQuery.Criteria.Field);
            Assert.AreEqual("OrganisationID", collection.SelectQuery.Criteria.Field.PropertyName);
            Assert.IsNotNull(collection.SelectQuery.Criteria.Field.Source);
            Assert.AreEqual("ContactPersonTestBO", collection.SelectQuery.Criteria.Field.Source.Name);
            Assert.AreEqual(organisation.OrganisationID.Value, collection.SelectQuery.Criteria.FieldValue);
            Assert.IsInstanceOf(typeof(ContactPersonTestBO), collection.CreateBusinessObject());
        }
コード例 #3
0
        /// <summary>
        /// Deliberately adds BO to the grid's collection because current habanero model only
        /// adds BO to grid when it is saved.  This causes a problem when you call col.CreateBO(), since
        /// it adds the BO twice and throws a duplicate key exception.
        /// </summary>a
        private void NewButtonClicked(object sender, EventArgs e)
        {
            try
            {
                _newBO = null;
                IBusinessObject currentBO = CurrentBusinessObject;
                if (currentBO != null)
                {
                    if (!currentBO.Status.IsValid())
                    {
                        bool errors = _iboEditorControl.HasErrors;
                        return;
                    }
                    currentBO.Save();
                }

                IBusinessObjectCollection collection = _readOnlyGridControl.Grid.BusinessObjectCollection;
                _readOnlyGridControl.Grid.SelectionChanged -= GridSelectionChanged;
                _newBO = collection.CreateBusinessObject();
                // _readOnlyGridControl.Grid.GetBusinessObjectCollection().Add(businessObject);
                _readOnlyGridControl.SelectedBusinessObject = _newBO;
                CurrentBusinessObject = _newBO;
                UpdateControlEnabledState();
                //collection.Add(businessObject);
                _readOnlyGridControl.Grid.SelectionChanged += GridSelectionChanged;
                GridSelectionChanged(null, null);
                _iboEditorControl.Focus();
                //_iboEditorControl.ClearErrors();
                _cancelButton.Enabled = true;
            }
            catch (Exception ex)
            {
                GlobalRegistry.UIExceptionNotifier.Notify(ex, "", "Error ");
            }
        }
コード例 #4
0
        // What about giving a save (yes/no/cancel) option, if so, duplicate the code from CheckRowSelectionCanChange
        private void NewButtonClicked(object sender, EventArgs e)
        {
            IBusinessObject currentBO = CurrentBusinessObject;

            if (currentBO != null)
            {
                CallApplyChangesOnPanelInfo_IfStrategyAllows();

                if (!currentBO.Status.IsValid())
                {
                    CallApplyChangesOnPanelInfo();  // to flash the error providers
                    return;
                }
                NotifyUserOfDirtyStatus();
                if (currentBO.Status.IsDirty)
                {
                    return;
                }
            }

            IBusinessObjectCollection collection        = ReadOnlyGridControl.Grid.BusinessObjectCollection;
            IBusinessObject           newBusinessObject = collection.CreateBusinessObject();

            SelectBusinessObjectInGrid_NoEvents(newBusinessObject);

            GridSelectionChanged(null, null);
            UpdateControlEnabledState();
            _businessObjectControl.Focus();
            //_businessObjectControl.ClearErrors();
        }
コード例 #5
0
 /// <summary>
 /// Creates the object, without editing or saving it.
 /// </summary>
 /// <returns></returns>
 public IBusinessObject CreateBusinessObject()
 {
     return(_boCol != null?_boCol.CreateBusinessObject() : _classDef.CreateNewBusinessObject());
 }