protected virtual void OnPostInsert(esDataSourceInsertEventArgs e)
 {
     esDataSource.esDataSourceInsertEventHandler handler = base.Events[evPostInsert]
                                                           as esDataSource.esDataSourceInsertEventHandler;
     if (handler != null)
     {
         handler(this, e);
     }
 }
        public override void Insert(System.Collections.IDictionary values, DataSourceViewOperationCallback callback)
        {
            esDataSourceInsertEventArgs e = null;

            try
            {
                e        = new esDataSourceInsertEventArgs();
                e.Values = values;

                this.OnPreInsert(e);
                if (e.Cancel)
                {
                    return;
                }

                esDataSourceCreateEntityEventArgs ce = new esDataSourceCreateEntityEventArgs();
                this.OnCreateEntity(ce);

                esEntity entity = ce.Entity;
                e.Entity = entity;

                if (entity != null)
                {
                    entity.SetProperties(values);
                }

                //this.OnPreInsert(e);

                e.EventWasHandled = false;
                this.OnInsert(e);

                if (!e.EventWasHandled)
                {
                    entity.Save();
                    this.OnDataSourceViewChanged(EventArgs.Empty);
                }

                e.EventWasHandled = false;
                this.OnPostInsert(e);
            }
            catch (Exception ex)
            {
                esDataSourceExceptionEventArgs exArgs = new esDataSourceExceptionEventArgs(ex);
                exArgs.EventType  = esDataSourceEventType.Insert;
                exArgs.InsertArgs = e;

                try
                {
                    this.OnException(exArgs);
                }
                catch { }

                if (!exArgs.ExceptionWasHandled)
                {
                    throw;
                }
            }
            finally
            {
                callback(1, null);
            }
        }
        public override void Insert(System.Collections.IDictionary values, DataSourceViewOperationCallback callback)
        {
            esDataSourceInsertEventArgs e = null;

            try
            {
                e = new esDataSourceInsertEventArgs();
                e.Values = values;

                this.OnPreInsert(e);
                if (e.Cancel)
                    return;

                esDataSourceCreateEntityEventArgs ce = new esDataSourceCreateEntityEventArgs();
                this.OnCreateEntity(ce);

                esEntity entity = ce.Entity;
                e.Entity = entity;

                if (entity != null)
                {
                    entity.SetProperties(values);
                }

                //this.OnPreInsert(e);

                e.EventWasHandled = false;
                this.OnInsert(e);

                if (!e.EventWasHandled)
                {
                    entity.Save();
                    this.OnDataSourceViewChanged(EventArgs.Empty);
                }

                e.EventWasHandled = false;
                this.OnPostInsert(e);
            }
            catch (Exception ex)
            {
                esDataSourceExceptionEventArgs exArgs = new esDataSourceExceptionEventArgs(ex);
                exArgs.EventType = esDataSourceEventType.Insert;
                exArgs.InsertArgs = e;

                try
                {
                    this.OnException(exArgs);
                }
                catch { }

                if (!exArgs.ExceptionWasHandled)
                {
                    throw;
                }
            }
            finally
            {
                callback(1, null);
            }
        }
 protected virtual void OnPostInsert(esDataSourceInsertEventArgs e)
 {
     esDataSource.esDataSourceInsertEventHandler handler = base.Events[evPostInsert]
         as esDataSource.esDataSourceInsertEventHandler;
     if (handler != null)
     {
         handler(this, e);
     }
 }