/// <summary> /// /// This method will merge the contents of this Group with the one provided. /// /// NOTE: A true merge happens only between two instances of a group with one row. The functionality /// to merge other groups has not yet been truly implemented. /// /// <param name="ThatProductGroup">The Group that should merge with this one</param> /// <returns>None</returns> /// </summary> public void Merge(WonkaPrdGroup ThatProductGroup) { if (this.MasterGroup.GroupId == ThatProductGroup.MasterGroup.GroupId) { if ((this.GetRowCount() == 1) && (ThatProductGroup.GetRowCount() == 1)) { if (ThatProductGroup.GetRowCount() > 0) { if (this.GetRowCount() <= 0) { AppendRow(); } WonkaPrdGroupDataRow ThisRow = this.DataRowVector[0]; WonkaPrdGroupDataRow ThatRow = ThatProductGroup.DataRowVector[0]; ThisRow.Merge(ThatRow); } } else if (ThatProductGroup.GetRowCount() > 0) { this.SetData(ThatProductGroup); } } else { throw new Exception("ERROR! Attempting to merge two Groups of different sizes!"); } }
/// <summary> /// /// This method will assign the Attribute values specifically to the first DataRow /// of their respective Group. /// /// NOTE: This method will nullify Attributes only for the first DataRow of the Group. /// /// <param name="poProduct">The Product that we are assigning these Attribute values</param> /// <param name="poAttrValues">The Attribute values that we are going to set inside the provided Product</param> /// <returns>None</returns> /// </summary> public static void PopulateProduct(WonkaProduct poProduct, Dictionary <int, string> poAttrValues) { var iAttrValueEnum = poAttrValues.GetEnumerator(); while (iAttrValueEnum.MoveNext()) { int nAttrId = iAttrValueEnum.Current.Key; string sAttrValue = iAttrValueEnum.Current.Value; WonkaRefAttr TempAttribute = WonkaRefEnvironment.GetInstance().GetAttributeByAttrId(nAttrId); WonkaPrdGroup TempPrdGroup = poProduct.ProductGroups[TempAttribute.GroupId]; if (TempPrdGroup.GetRowCount() <= 0) { TempPrdGroup.AppendRow(); } WonkaPrdGroupDataRow GrpDataRow = TempPrdGroup.GetRow(0); GrpDataRow.SetData(nAttrId, sAttrValue); } }