Exemple #1
0
        private void add_Click(object sender, RoutedEventArgs e)
        {
            IEditableCollectionView editableCollectionView = itemsControl.Items as IEditableCollectionView;

            if (!editableCollectionView.CanAddNew)
            {
                MessageBox.Show("You cannot add items to the list.");
                return;
            }

            // Create a window that prompts the user to enter a new
            // item to sell.
            ChangeItemWindow win = new ChangeItemWindow();

            //Create a new item to be added to the collection.
            win.DataContext = editableCollectionView.AddNew();

            // If the user submits the new item, commit the new
            // object to the collection.  If the user cancels
            // adding the new item, discard the new item.
            if ((bool)win.ShowDialog())
            {
                editableCollectionView.CommitNew();
            }
            else
            {
                editableCollectionView.CancelNew();
            }
        }
        public void ICVF_Remove()
        {
            EntitySet <City>        entitySet;
            EntityCollection <City> entityCollection = this.CreateEntityCollection(out entitySet);
            IEditableCollectionView view             = this.GetIECV(entityCollection);

            City city = (City)view.AddNew();

            city.Name       = "Des Moines";
            city.CountyName = "King";
            city.StateName  = "WA";
            view.CommitNew();
            entityCollection.Add(this.CreateLocalCity("Normandy Park"));
            entityCollection.Add(this.CreateLocalCity("SeaTac"));

            // This one was added through the view and will be removed from both
            view.Remove(city);
            Assert.IsFalse(entityCollection.Contains(city),
                           "EntityCollection should no longer contain the first entity.");
            Assert.IsFalse(entitySet.Contains(city),
                           "EntitySet should no longer contain the first entity.");

            // This one was added directly and will only be removed for the collection
            city = entityCollection.ElementAt(1);
            view.Remove(city);
            Assert.IsFalse(entityCollection.Contains(city),
                           "EntityCollection should no longer contain the entity at index 1.");
            Assert.IsTrue(entitySet.Contains(city),
                          "EntitySet should still contain the entity at index 1.");
        }
        private void ItemsDataGrid_LoadingRow(object sender, DataGridRowEventArgs e)
        {
            IEditableCollectionView itemsView = ItemsDataGrid.Items;

            if (ItemsDataGrid.Items.Count == 31 && itemsView.IsAddingNew == true)
            {
                itemsView.CommitNew();
                ItemsDataGrid.CanUserAddRows = false;
            }
        }
        /// <summary>
        /// Ends the add transaction and saves the pending new item.
        /// </summary>
        void IEditableCollectionView.CommitNew()
        {
            IEditableCollectionView iEditableCollectionView = this.currentView as IEditableCollectionView;

            if (iEditableCollectionView == null)
            {
                throw new InvalidOperationException(ExceptionMessage.Format(ExceptionMessages.MemberNotAllowedForView, "CommitNew"));
            }
            iEditableCollectionView.CommitNew();
        }
Exemple #5
0
        /// <summary>
        /// Complete the transaction started by <seealso cref="IEditableCollectionView.AddNew"/>.  The new
        /// item remains in the collection, and the view's sort, filter, and grouping
        /// specifications (if any) are applied to the new item.
        /// </summary>
        void IEditableCollectionView.CommitNew()
        {
            IEditableCollectionView ecv = ProxiedView as IEditableCollectionView;

            if (ecv != null)
            {
                ecv.CommitNew();
            }
            else
            {
                throw new InvalidOperationException(SR.Get(SRID.MemberNotAllowedForView, "CommitNew"));
            }
        }
        private void CheckDataGrid(DataGrid grid)
        {
            IEditableCollectionView collection = grid.Items;

            if (collection.IsEditingItem)
            {
                collection.CommitEdit();
            }
            if (collection.IsAddingNew)
            {
                collection.CommitNew();
            }
        }
Exemple #7
0
        // Token: 0x06007409 RID: 29705 RVA: 0x00212E1C File Offset: 0x0021101C
        void IEditableCollectionView.CommitNew()
        {
            IEditableCollectionView editableCollectionView = this.ProxiedView as IEditableCollectionView;

            if (editableCollectionView != null)
            {
                editableCollectionView.CommitNew();
                return;
            }
            throw new InvalidOperationException(SR.Get("MemberNotAllowedForView", new object[]
            {
                "CommitNew"
            }));
        }
Exemple #8
0
        public void ICVF_AddNew()
        {
            EntitySet <City>        entitySet = this.CreateEntitySet <City>();
            IEditableCollectionView view      = this.GetIECV(entitySet);

            City city = (City)view.AddNew();

            Assert.IsTrue(entitySet.Contains(city),
                          "EntitySet should contain the first entity after AddNew.");
            city.Name       = "Tukwila";
            city.CountyName = "King";
            city.StateName  = "WA";
            view.CommitNew();
            Assert.IsTrue(entitySet.Contains(city),
                          "EntitySet should contain the first entity after CommitNew.");
        }
Exemple #9
0
        /// <summary>
        /// Zatwierdzenie zmian
        /// </summary>
        private void OnCommit(object sender, RoutedEventArgs e)
        {
            string errmsg = string.Empty;

            if (m_mode == eDbOperation.Insert)
            {
                var schedule = m_schedules.CurrentAddItem as FtpSchedule;
                if (!ValidateSchedule(schedule))
                {
                    return;
                }

                schedule.Endpoint = m_mainWnd.m_tbHarmonogramy.m_selectedEndpoint.XX;
                errmsg            = FtpDiligentDatabaseClient.ModifySchedule(schedule.GetModel(), m_mode);
                if (string.IsNullOrEmpty(errmsg))
                {
                    schedule.XX = IFtpDiligentDatabaseClient.m_lastInsertedKey;
                    m_schedules.CommitNew();
                }
            }
            else
            {
                var schedule = m_schedules.CurrentEditItem as FtpSchedule;
                if (!ValidateSchedule(schedule))
                {
                    return;
                }
                errmsg = FtpDiligentDatabaseClient.ModifySchedule(schedule.GetModel(), m_mode);
                if (string.IsNullOrEmpty(errmsg))
                {
                    m_schedules.CommitEdit();
                }
            }

            if (string.IsNullOrEmpty(errmsg))
            {
                RestoreTabControl();
            }
            else
            {
                m_mainWnd.ShowErrorInfo(eSeverityCode.Error, errmsg);
            }
        }
Exemple #10
0
 private void CollectionView_PagingTestCurrentChanging(object source, CurrentChangingEventArgs e)
 {
     if (this._cancelCurrencyMove == true)
     {
         e.Cancel = true;
     }
     else if (this._cancelCurrencyMove == false)
     {
         // Commit the edited/addition item before the page move occurs.
         IEditableCollectionView editableCollectionView = (IEditableCollectionView)source;
         if (editableCollectionView.IsAddingNew)
         {
             editableCollectionView.CommitNew();
         }
         else
         {
             editableCollectionView.CommitEdit();
         }
     }
 }
Exemple #11
0
        /// <summary>
        /// Commits the current entity editing and exits the editing mode.
        /// </summary>
        /// <param name="dataItem">The entity being edited</param>
        /// <returns>True if a commit operation was invoked.</returns>
        public bool EndEdit(object dataItem)
        {
#if FEATURE_IEDITABLECOLLECTIONVIEW
            IEditableCollectionView editableCollectionView = this.EditableCollectionView;
            if (editableCollectionView != null)
            {
                // IEditableCollectionView.CommitEdit can potentially change currency. If it does,
                // we don't want to attempt a second commit inside our CurrentChanging event handler.
                _owner.NoCurrentCellChangeCount++;
                this.EndingEdit = true;
                try
                {
                    if (editableCollectionView.IsAddingNew && dataItem == editableCollectionView.CurrentAddItem)
                    {
                        editableCollectionView.CommitNew();
                    }
                    else
                    {
                        editableCollectionView.CommitEdit();
                    }
                }
                finally
                {
                    _owner.NoCurrentCellChangeCount--;
                    this.EndingEdit = false;
                }

                return(true);
            }
#endif

            IEditableObject editableDataItem = dataItem as IEditableObject;
            if (editableDataItem != null)
            {
                editableDataItem.EndEdit();
            }

            return(true);
        }
            internal DisposeItemsDeferRefresh(FilterPresenter filterVm)
            {
                this.filterPr = filterVm;
                IEditableCollectionView cv = filterPr.CollectionView as IEditableCollectionView;

                if (cv != null)
                {
                    if (cv.IsAddingNew)
                    {
                        cv.CommitNew();
                    }
                    if (cv.IsEditingItem)
                    {
                        cv.CommitEdit();
                    }
                }
                if (filterPr.itemsDeferRefreshCount == 0)
                {
                    filterPr.itemsDeferRefresh = filterPr.CollectionView.DeferRefresh();
                }
                filterPr.itemsDeferRefreshCount++;
            }
        /// <summary>
        /// Zatwierdzenie zmian
        /// </summary>
        private void OnCommit(object sender, RoutedEventArgs e)
        {
            string errmsg = string.Empty;

            if (m_mode == eDbOperation.Insert)
            {
                var endpoint = m_endpoints.CurrentAddItem as FtpEndpoint;
                endpoint.Instance = m_mainWnd.m_instance;
                SanitizeDirectories(ref endpoint);
                errmsg = FtpDiligentDatabaseClient.ModifyEndpoint(endpoint.GetModel(), m_mode);
                if (string.IsNullOrEmpty(errmsg))
                {
                    endpoint.XX = IFtpDiligentDatabaseClient.m_lastInsertedKey;
                    m_endpoints.CommitNew();
                }
            }
            else
            {
                var endpoint = m_endpoints.CurrentEditItem as FtpEndpoint;
                SanitizeDirectories(ref endpoint);
                errmsg = FtpDiligentDatabaseClient.ModifyEndpoint(endpoint.GetModel(), m_mode);
                if (string.IsNullOrEmpty(errmsg))
                {
                    m_endpoints.CommitEdit();
                }
            }

            if (string.IsNullOrEmpty(errmsg))
            {
                RestoreTabControl();
            }
            else
            {
                m_mainWnd.ShowErrorInfo(eSeverityCode.Error, errmsg);
            }
        }
Exemple #14
0
 public void CommitNew()
 {
     _collectionView.CommitNew();
 }