private void UpdateMDItemGroupItemCategoryMapEntity() { if (IsValid) { try { IList <MDItemGroupItemCategoryMapEntity> newMappedItems = new List <MDItemGroupItemCategoryMapEntity>(); foreach (ListItem chbxItem in chbxItemCategroy.Items) { if (chbxItem.Selected) { MDItemGroupItemCategoryMapEntity mDItemGroupItemCategoryMapEntity = new MDItemGroupItemCategoryMapEntity(); mDItemGroupItemCategoryMapEntity.ItemGroupID = Int64.Parse(lstBxItemGroup.SelectedValue.ToString()); mDItemGroupItemCategoryMapEntity.ItemCategoryID = Int64.Parse(chbxItem.Value.ToString()); newMappedItems.Add(mDItemGroupItemCategoryMapEntity); } } IList <MDItemGroupItemCategoryMapEntity> deleteList = _CurrentItemGroupItemCategoryMapList.Except(newMappedItems, new CustomerComparer()).ToList(); IList <MDItemGroupItemCategoryMapEntity> addNewList = newMappedItems.Except(_CurrentItemGroupItemCategoryMapList, new CustomerComparer()).ToList(); if (deleteList != null && deleteList.Count > 0) { foreach (MDItemGroupItemCategoryMapEntity ent in deleteList) { String fe1 = SqlExpressionBuilder.PrepareFilterExpression(MDItemGroupItemCategoryMapEntity.FLD_NAME_ItemCategoryID, ent.ItemCategoryID.ToString(), SQLMatchType.Equal); String fe2 = SqlExpressionBuilder.PrepareFilterExpression(MDItemGroupItemCategoryMapEntity.FLD_NAME_ItemGroupID, ent.ItemGroupID.ToString(), SQLMatchType.Equal); String fe = SqlExpressionBuilder.PrepareFilterExpression(fe1, SQLJoinType.AND, fe2); FCCMDItemGroupItemCategoryMap.GetFacadeCreate().Delete(ent, fe, DatabaseOperationType.Delete, TransactionRequired.No); } } if (addNewList != null && addNewList.Count > 0) { foreach (MDItemGroupItemCategoryMapEntity ent in addNewList) { FCCMDItemGroupItemCategoryMap.GetFacadeCreate().Add(ent, DatabaseOperationType.Add, TransactionRequired.No); } } MiscUtil.ShowMessage(lblMessage, "Item Group Item Category Map Information has been updated successfully.", false); _CurrentItemGroupItemCategoryMapList = new List <MDItemGroupItemCategoryMapEntity>(); } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } }