Exemple #1
0
        private void HandleInsert(CommandEventArgs args)
        {
            var dataSource = GetDataSource();

            if (dataSource == null)
            {
                throw new InvalidOperationException("Control must have a data source.");
            }

            // Expand the cell bindings to retrieve all form values.
            var values = CellBindings.ToDictionary(cell => cell.Key, cell => cell.Value.Get());

            var insertingEventArgs = new CrmEntityFormViewInsertingEventArgs(values);

            OnItemInserting(insertingEventArgs);

            if ((!Page.IsValid) || insertingEventArgs.Cancel)
            {
                return;
            }

            var dataSourceView = dataSource.GetView(DataMember) as CrmDataSourceView;

            if (dataSourceView == null)
            {
                return;
            }

            dataSourceView.Inserted += DataSourceViewInserted;

            dataSourceView.Insert(values, EntityName);
        }
Exemple #2
0
        protected virtual void OnItemInserting(CrmEntityFormViewInsertingEventArgs args)
        {
            var handler = (EventHandler <CrmEntityFormViewInsertingEventArgs>)Events[_eventItemInserting];

            if (handler != null)
            {
                handler(this, args);
            }
        }