コード例 #1
0
 /// <summary>
 /// Get an item from associated data source
 /// </summary>
 /// <param name="item">data source item</param>
 /// <returns>AccessContextItem instance or null</returns>
 internal AccessContextItem GetItemFromDataSource(RootItem item)
 {
     foreach (var listItem in Items)
     {
         if (listItem.Key.Item.DataSource == item)
         {
             return(listItem.Key.Item);
         }
     }
     return(null);
 }
コード例 #2
0
 /// <summary>
 /// Try to get an AccessContextItem instance from associated data source
 /// </summary>
 /// <param name="item">data source item</param>
 /// <returns>AccessContextItem instance or null</returns>
 private AccessContextItem GetItemFromDataSource(RootItem item)
 {
     foreach (var listItem in this)
     {
         if (listItem.DataSource == item)
         {
             return(listItem);
         }
     }
     return(null);
 }
コード例 #3
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();
        }
コード例 #4
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");
        }
コード例 #5
0
 /// <summary>
 /// Creates an instance of the class
 /// </summary>
 /// <param name="parent">parent list</param>
 /// <param name="dataSource">origin item</param>
 /// <param name="state">current state of the item</param>
 public AccessContextItem(AccessContextList parent, RootItem dataSource, AccessContextItemState state)
 {
     Parent     = parent;
     DataSource = dataSource;
     ItemState  = state;
 }
コード例 #6
0
 /// <summary>
 /// Get an item from associated data source
 /// </summary>
 /// <param name="item">data source item</param>
 /// <returns>AccessContextItem instance or null</returns>
 internal AccessContextItem GetItemFromDataSource(RootItem item)
 {
     foreach (var listItem in Items)
     {
         if (listItem.Key.Item.DataSource == item)
             return listItem.Key.Item;
     }
     return null;
 }
コード例 #7
0
 /// <summary>
 /// Creates an instance of the class
 /// </summary>
 /// <param name="parent">parent list</param>
 /// <param name="dataSource">origin item</param>
 /// <param name="state">current state of the item</param>
 public AccessContextItem(AccessContextList parent, RootItem dataSource, AccessContextItemState state)
 {
     Parent = parent;
     DataSource = dataSource;
     ItemState = state;
 }