public static DataSet1.dtIngSupplierDataTable SortSupplierIngDataTable(DataSet1.dtIngSupplierDataTable dtIngredsIn) { var sDict = new SortedDictionary <string, DataSet1.dtIngSupplierRow>(); foreach (DataSet1.dtIngSupplierRow row in dtIngredsIn.Rows) { sDict.Add(row.IngredientName, row); } var dtIngredsOut = new DataSet1.dtIngSupplierDataTable(); foreach (DataSet1.dtIngSupplierRow row in sDict.Values) { DataSet1.dtIngSupplierRow newRow = dtIngredsOut.NewdtIngSupplierRow(); newRow.Quantity = row.Quantity; newRow.IngredientName = row.IngredientName; newRow.SupplierType = row.SupplierType; newRow.Price = row.Price; dtIngredsOut.AdddtIngSupplierRow(newRow); } return(dtIngredsOut); }
private void AddSimpleToOutput(Ingredient ing, ref long supplierTotal, ref DataSet1.dtIngGatheredDataTable dtIngGathered, ref DataSet1.dtIngSupplierDataTable dtIngSupplier) { bool bFound = false; if ((ing is SupplierIngredients) || (ing is TraderIngredients)) { long cost = 0; if (ing is SupplierIngredients) { var supIng = (SupplierIngredients)ing; cost = supIng.EstimatedCost; } foreach (DataSet1.dtIngSupplierRow row in dtIngSupplier.Rows) { if (row.IngredientName == ing.Name) { int oldQuantity = Convert.ToInt32(row.Quantity); row.Quantity = Convert.ToString(oldQuantity + ing.QuantityRequested); supplierTotal += (cost * ing.QuantityRequested); bFound = true; break; } } if (!bFound) { DataSet1.dtIngSupplierRow dtRow = dtIngSupplier.NewdtIngSupplierRow(); dtRow.Quantity = ing.QuantityRequested.ToString(); dtRow.IngredientName = ing.Name; dtRow.SupplierType = ing.FormatIngredientType(); if (cost > 0) { dtRow.Price = cost.ToString(); supplierTotal += (cost * ing.QuantityRequested); } else { dtRow.Price = "0"; } dtIngSupplier.AdddtIngSupplierRow(dtRow); } } else // gathered { var simpIng = (SimpleIngredients)ing; foreach (DataSet1.dtIngGatheredRow row in dtIngGathered.Rows) { if (row.IngredientName == ing.Name) { row.Quantity = Convert.ToString(Convert.ToInt32(row.Quantity) + Convert.ToInt32(ing.QuantityRequested)); bFound = true; break; } } if (!bFound) { DataSet1.dtIngGatheredRow dtRow = dtIngGathered.NewdtIngGatheredRow(); dtRow.Quantity = ing.QuantityRequested.ToString(); dtRow.IngredientName = ing.Name; dtRow.Tier = ProfessionTier.FormatTier(simpIng.Tier); if (ing is FarmedIngredients) { dtRow.Profession = "Farming"; } else if (ing is ForesterIngredients) { dtRow.Profession = "Forester"; } else if (ing is PickedIngredients) { dtRow.Profession = "Picked"; } else if (ing is FishingIngredients) { dtRow.Profession = "Fishing"; } else if (ing is MobDropIngredients) { dtRow.Profession = "Mob Drop"; } else if (ing is ProspectorIngredients) { dtRow.Profession = "Prospector"; } else if (ing is ScholarIngredients) { dtRow.Profession = "Scholar"; } dtIngGathered.AdddtIngGatheredRow(dtRow); } } }