/// <summary> /// Deletes the association items. /// </summary> /// <param name="catalogAssociation">The catalog association.</param> private void DeleteAssociationItems(CatalogAssociationDto.CatalogAssociationRow catalogAssociation) { if (catalogAssociation != null) { CatalogAssociationDto.CatalogEntryAssociationRow[] entryRows = catalogAssociation.GetCatalogEntryAssociationRows(); foreach (CatalogAssociationDto.CatalogEntryAssociationRow entryRow in entryRows) { entryRow.Delete(); } } }
/// <summary> /// Sets the association items grid data source. /// </summary> /// <param name="associationId">The association id.</param> private void SetAssociationItemsGridDataSource(int associationId) { CatalogAssociationDto dto = CurrentCatalogAssociationDto; CatalogAssociationDto.CatalogAssociationRow row = GetAssociationRow(associationId); if (row != null) { CatalogAssociationDto.CatalogEntryAssociationRow[] entryAssociationRows = row.GetCatalogEntryAssociationRows(); DataTable dt = new DataTable("CatalogEntryAssociation"); dt.Columns.AddRange(new DataColumn[5] { new DataColumn(_CatalogAssociationIdString, typeof(int)), new DataColumn(_CatalogEntryIdString, typeof(int)), new DataColumn("EntryName", typeof(string)), new DataColumn(_SortOrderString, typeof(int)), new DataColumn(_AssociationTypeIdString, typeof(string)) }); foreach (CatalogAssociationDto.CatalogEntryAssociationRow entryRow in entryAssociationRows) { DataRow dr = dt.NewRow(); dr[_CatalogAssociationIdString] = entryRow.CatalogAssociationId; dr[_CatalogEntryIdString] = entryRow.CatalogEntryId; dr["EntryName"] = GetEntryNameById(entryRow.CatalogEntryId); dr[_SortOrderString] = entryRow.SortOrder; dr[_AssociationTypeIdString] = entryRow.AssociationTypeId; dt.Rows.Add(dr); } CatalogAssociationDto.AssociationTypeDataTable associationTypeTable = new CatalogAssociationDto.AssociationTypeDataTable(); List <CatalogAssociationDto.AssociationTypeRow> associationTypeRows = new List <CatalogAssociationDto.AssociationTypeRow>(); foreach (CatalogAssociationDto.AssociationTypeRow associationTypeRow in dto.AssociationType.Rows) { associationTypeTable.ImportRow(associationTypeRow); } DataSet dsSrc = new DataSet(); dsSrc.Tables.Add(dt); dsSrc.Tables.Add(associationTypeTable); dsSrc.Relations.Add(dsSrc.Tables["AssociationType"].Columns["AssociationTypeId"], dsSrc.Tables["CatalogEntryAssociation"].Columns["AssociationTypeId"]); AssociationItemsGrid.DataSource = dsSrc; } else { AssociationItemsGrid.DataSource = null; } }