Esempio n. 1
0
        public virtual bool SaveOnly()
        {
            bool       saved = false;
            RowAdapter d     = GetPersistentRow();

            foreach (DataRow dataRow in dataTable.Rows)
            {
                if (dataRow.RowState != DataRowState.Deleted)
                {
                    d.UpdateColumnValue(dataRow);

                    if (DataRowChangedHandler != null)
                    {
                        d.RowChanged += DataRowChangedHandler;
                    }

                    if (ValueChangedHandler != null)
                    {
                        d.ValueChangedHandler = ValueChangedHandler;
                    }

                    if (dataRow.RowState != DataRowState.Unchanged)
                    {
                        saved = d.Save();
                    }
                }
                else
                {
                    dataRow.RejectChanges();
                    d.UpdateColumnValue(dataRow);

                    if (DataRowChangedHandler != null)
                    {
                        d.RowChanged += DataRowChangedHandler;
                    }

                    if (ValueChangedHandler != null)
                    {
                        d.ValueChangedHandler = ValueChangedHandler;
                    }

                    d.Delete();
                    dataRow.Delete();
                }
            }


            return(saved);
        }
Esempio n. 2
0
        public virtual bool Delete()
        {
            bool       deleted = false;
            RowAdapter d       = new RowAdapter(this.fields, this.columns, this.TableName, this.Locator);

            foreach (DataRow dataRow in dataTable.Rows)
            {
                if (dataRow.RowState == DataRowState.Deleted)
                {
                    dataRow.RejectChanges();
                    d.UpdateColumnValue(dataRow);

                    if (DataRowChangedHandler != null)
                    {
                        d.RowChanged += DataRowChangedHandler;
                    }

                    if (ValueChangedHandler != null)
                    {
                        d.ValueChangedHandler = ValueChangedHandler;
                    }

                    deleted = d.Delete();

                    if (deleted)
                    {
                        dataRow.Delete();
                    }
                }
            }

            dataTable.AcceptChanges();
            return(deleted);
        }
Esempio n. 3
0
        public virtual bool Load()
        {
            RowAdapter d = GetPersistentRow();

            foreach (DataRow dataRow in dataTable.Rows)
            {
                if (dataRow.RowState == DataRowState.Deleted)
                {
                    continue;
                }

                d.UpdateColumnValue(dataRow);
                d.Load();
                foreach (ColumnAdapter column in columns)
                {
                    dataRow[column.Field.Name] = d.Row[column.Field.Name];
                }
            }
            dataTable.AcceptChanges();

            return(true);
        }
Esempio n. 4
0
        public virtual bool Delete()
        {
            bool deleted = false;
            RowAdapter d = new RowAdapter(this.fields, this.columns, this.TableName, this.Locator);

            foreach (DataRow dataRow in dataTable.Rows)
            {
                if (dataRow.RowState == DataRowState.Deleted)
                {
                    dataRow.RejectChanges();
                    d.UpdateColumnValue(dataRow);

                    if (DataRowChangedHandler != null)
                        d.RowChanged += DataRowChangedHandler;

                    if (ValueChangedHandler != null)
                        d.ValueChangedHandler = ValueChangedHandler;

                    deleted = d.Delete();

                    if (deleted)
                        dataRow.Delete();
                }
            }

            dataTable.AcceptChanges();
            return deleted;
        }