Example #1
0
        /// <summary>
        /// Commit local changes to associated root table
        /// </summary>
        internal void ApplyLocalChanges()
        {
            foreach (var item in ItemManager.Items)
            {
                switch (item.Key.State)
                {
                case AccessContextListItemManager.ItemEntryState.New:

                    item.Key.Item.ItemState = AccessContextItemState.ItemIsNormal;
                    RootItem newItem = DataSource.AddNew();
                    foreach (var property in item.Key.Item.LocalChangedProperties)
                    {
                        newItem.SetValue(property.Key, property.Value);
                    }
                    item.Key.Item.DataSource = newItem;

                    // datenbank kommando
                    // dynmamischer code
                    break;

                case AccessContextListItemManager.ItemEntryState.Deleted:

                    item.Key.Item.ItemState = AccessContextItemState.ItemIsDeleted;
                    DataSource.Remove(item.Key.Item.DataSource);

                    // datenbank kommando
                    // dynmamischer code
                    break;

                case AccessContextListItemManager.ItemEntryState.Changed:

                    item.Key.Item.ItemState = AccessContextItemState.ItemIsNormal;
                    foreach (var property in item.Key.Item.LocalChangedProperties)
                    {
                        item.Key.Item.DataSource.SetValue(property.Key, property.Value);
                    }

                    // datenbank kommando
                    // dynmamischer code
                    break;

                default:
                    throw new IndexOutOfRangeException();
                }
            }
            Parent.Parent.UpdateNotifyOtherListInstances(this);
            ItemManager.Clear();
        }
Example #2
0
        private void buttonSimulateDatabaseAction_Click(object sender, EventArgs e)
        {
            DataLayer.RootList tableProducts = DataHost.Tables["Products"];

            tableProducts[0].SetValue("Name", "ChangedName");

            tableProducts.Remove(tableProducts[1]);
            tableProducts.Remove(tableProducts[1]);

            DataLayer.RootItem item1 = tableProducts.AddNew();
            item1.SetValue("Name", "NewProduct1");

            DataLayer.RootItem item2 = tableProducts.AddNew();
            item2.SetValue("Name", "NewProduct2");

            DataLayer.RootItem item3 = tableProducts.AddNew();
            item3.SetValue("Name", "NewProduct3");
        }