Beispiel #1
0
        private void DeleteNode(int Dictionary_PKID, Wicresoft.Session.Session session)
        {
            // Delete the entry in Dictionary
            BusinessMapping.Dictionary owner = new BusinessMapping.Dictionary();
            owner.SessionInstance = session;
            owner.PKID.Value      = Dictionary_PKID;
            owner.IsValid.Value   = false;
            owner.Update();

            // Delete the entry in Dictionary_RegionDetail
            BusinessObjectCollection region = new BusinessObjectCollection("Dictionary_RegionDetail");

            region.SessionInstance = session;

            BusinessFilter regiondeletefilter = new BusinessFilter("Dictionary_RegionDetail");

            regiondeletefilter.AddFilterItem("FK_Dictionary", Dictionary_PKID.ToString(), Operation.Equal, FilterType.NumberType, AndOr.AND);
            region.AddFilter(regiondeletefilter);

            ((BusinessMapping.Dictionary_RegionDetail)region.Businessobject).IsValid.Value = false;
            region.UpdateFilter();


            // Delete any child entries
            BusinessObjectCollection child = new BusinessObjectCollection("Dictionary");

            child.SessionInstance = session;

            BusinessFilter filter = new BusinessFilter("Dictionary");

            filter.AddFilterItem("Parent", Dictionary_PKID.ToString(), Operation.Equal, FilterType.NumberType, AndOr.AND);
            filter.AddFilterItem("Type", ((int)SystemManage.DictionaryType.Region).ToString(), Operation.Equal, FilterType.NumberType, AndOr.AND);
            filter.AddFilterItem("IsValid", "1", Operation.Equal, FilterType.NumberType, AndOr.AND);
            child.AddFilter(filter);

            DataTable childtable = child.GetDataTable();

            for (int i = 0; i < childtable.Rows.Count; i++)
            {
                DeleteNode(int.Parse(childtable.Rows[i]["PKID"].ToString()), session);
            }
        }