Esempio n. 1
0
        private void AddRecipeToOutput(CompositeIngredients rec, ref long supplierTotal,
                                       ref DataSet1.dtRecipeDataTable dtRecipes,
                                       ref DataSet1.dtIngCraftedDataTable dtIngCrafted,
                                       ref DataSet1.dtIngGatheredDataTable dtIngGathered,
                                       ref DataSet1.dtIngSupplierDataTable dtIngSupplier,
                                       ref DataSet1.dtCraftingXPDataTable dtCraftingXp)
        {
            bool bFound = false;

            // if already added, then sum, else create
            foreach (DataSet1.dtRecipeRow row in dtRecipes.Rows)
            {
                if (row.RecipeName == rec.Name)
                {
                    row.Quantity = Convert.ToString(Convert.ToInt32(row.Quantity) + rec.QuantityRequested);
                    bFound       = true;
                    break;
                }
            }
            if (!bFound)
            {
                DataSet1.dtRecipeRow dtRow = dtRecipes.NewdtRecipeRow();
                dtRow.Quantity   = rec.QuantityRequested.ToString();
                dtRow.Profession = GetProfession(rec);
                dtRow.RecipeName = rec.Name;
                dtRow.Tier       = ProfessionTier.FormatTier(rec.Tier);
                dtRow.Facility   = GetFacility(rec);
                dtRecipes.AdddtRecipeRow(dtRow);
            }
            addCraftingXp(rec, ref dtCraftingXp);

            // breakdown the ingredients
            foreach (Ingredient subIng in rec.GetRecipeIngredients().Values)
            {
                if (subIng is CompositeIngredients)
                {
                    var newIng = (CompositeIngredients)subIng;
                    AddComponentToOutput(newIng, ref supplierTotal, ref dtIngCrafted, ref dtIngGathered, ref dtIngSupplier, ref dtCraftingXp);
                }
                else
                {
                    AddSimpleToOutput(subIng, ref supplierTotal, ref dtIngGathered, ref dtIngSupplier);
                }
            }
        }
Esempio n. 2
0
        public static DataSet1.dtRecipeDataTable SortRecipeDataTable(DataSet1.dtRecipeDataTable dtRecipesIn)
        {
            var sDict = new SortedDictionary <string, DataSet1.dtRecipeRow>();

            foreach (DataSet1.dtRecipeRow row in dtRecipesIn.Rows)
            {
                sDict.Add(row.RecipeName, row);
            }

            var dtRecipesOut = new DataSet1.dtRecipeDataTable();

            foreach (DataSet1.dtRecipeRow row in sDict.Values)
            {
                DataSet1.dtRecipeRow newRow = dtRecipesOut.NewdtRecipeRow();
                newRow.Facility   = row.Facility;
                newRow.Profession = row.Profession;
                newRow.Quantity   = row.Quantity;
                newRow.RecipeName = row.RecipeName;
                newRow.Tier       = row.Tier;
                dtRecipesOut.AdddtRecipeRow(newRow);
            }

            return(dtRecipesOut);
        }
Esempio n. 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (null == Session["Cook"])
            {
                Response.Redirect("~/default.aspx");
                return;
            }

            if (Page.IsPostBack)
            {
                return;
            }

            var dtCart = (DataTable)Session["dtCart"];

            if (null == dtCart)
            {
                dtCart = new DataTable();
                dtCart.Columns.Add("Recipe", typeof(string));
                dtCart.Columns.Add("Tier", typeof(string));
                dtCart.Columns.Add("Quantity", typeof(string));
                Session.Add("dtCart", dtCart);
            }

            var recsAll = (SortedDictionary <string, Ingredient>)Application["Recipes"];
            //var ingsAll = (SortedDictionary<string, Ingredient>)Application["Ingredients"];
            //var ds = new DataSet1();

            //var dt = ds.dtRecipe;

            long supplierTotal = 0;

            var dtRecipesUnsorted     = new DataSet1.dtRecipeDataTable();
            var dtIngCraftedUnsorted  = new DataSet1.dtIngCraftedDataTable();
            var dtIngGatheredUnsorted = new DataSet1.dtIngGatheredDataTable();
            var dtIngSupplierUnsorted = new DataSet1.dtIngSupplierDataTable();
            var dtCraftingXp          = new DataSet1.dtCraftingXPDataTable();

            for (int i = 0; i < 9; i++)
            {
                // ProfessionTierEnum.Apprentice
                var dtCraftingXpRow = dtCraftingXp.NewdtCraftingXPRow();
                dtCraftingXpRow.Tier        = ProfessionTier.FormatTier((ProfessionTierEnum)i);
                dtCraftingXpRow.Cook        = 0;
                dtCraftingXpRow.Forester    = 0;
                dtCraftingXpRow.Jeweler     = 0;
                dtCraftingXpRow.Metalsmith  = 0;
                dtCraftingXpRow.Prospector  = 0;
                dtCraftingXpRow.Scholar     = 0;
                dtCraftingXpRow.Tailor      = 0;
                dtCraftingXpRow.Weaponsmith = 0;
                dtCraftingXpRow.Woodworker  = 0;
                dtCraftingXp.Rows.Add(dtCraftingXpRow);
            }

            foreach (DataRow dtRow in dtCart.Rows)
            {
                var recipeName = (string)dtRow["Recipe"];
                //string Tier = (string)dtRow["Tier"];
                var quantity       = (string)dtRow["Quantity"];
                int quantityToMake = 1;
                try { quantityToMake = Convert.ToInt16(quantity); }
// ReSharper disable EmptyGeneralCatchClause
                catch { }
// ReSharper restore EmptyGeneralCatchClause

                var rec = (CompositeIngredients)recsAll[recipeName];
                rec.QuantityRequested = quantityToMake;

                AddRecipeToOutput(rec, ref supplierTotal,
                                  ref dtRecipesUnsorted, ref dtIngCraftedUnsorted, ref dtIngGatheredUnsorted, ref dtIngSupplierUnsorted, ref dtCraftingXp);
            }

            DataSet1.dtRecipeDataTable      dtRecipes     = DataSetHelpers.SortRecipeDataTable(dtRecipesUnsorted);
            DataSet1.dtIngCraftedDataTable  dtIngCrafted  = DataSetHelpers.SortCraftedIngDataTable(dtIngCraftedUnsorted);
            DataSet1.dtIngGatheredDataTable dtIngGathered = DataSetHelpers.SortGatheredIngDataTable(dtIngGatheredUnsorted);
            DataSet1.dtIngSupplierDataTable dtIngSupplier = DataSetHelpers.SortSupplierIngDataTable(dtIngSupplierUnsorted);

            var dtSupplierCost = new DataSet1.dtSupplierTotalDataTable();
            var dtSupplierRow  = dtSupplierCost.NewdtSupplierTotalRow();

            dtSupplierRow.TotalCost = FormatCost(supplierTotal);
            dtSupplierCost.AdddtSupplierTotalRow(dtSupplierRow);

            ReportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1_dtRecipe", (DataTable)dtRecipes));
            ReportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1_dtIngCrafted", (DataTable)dtIngCrafted));
            ReportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1_dtIngGathered", (DataTable)dtIngGathered));
            ReportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1_dtIngSupplier", (DataTable)dtIngSupplier));
            ReportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1_dtSupplierCost", (DataTable)dtSupplierCost));
            ReportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1_dtCraftingXP", (DataTable)dtCraftingXp));

            ReportViewer1.LocalReport.ReportPath = "Report1.rdlc";
            ReportViewer1.LocalReport.Refresh();
        }