Example #1
0
        void Tabulate(Dictionary <string, ProductSalesInfo> dct, string product, string quarter, string thisQuarter, double qty)
        {
            // get information for this product
            ProductSalesInfo psi = null;

            if (!dct.TryGetValue(product, out psi))
            {
                psi          = new ProductSalesInfo(product);
                dct[product] = psi;
            }

            // pro-rate current quarter
            double prorate = 1;

            if (quarter == thisQuarter)
            {
                var monthInQuarter = (DateTime.Today.Month - 1) % 3;
                var dayInQuarter   = monthInQuarter * 30 + DateTime.Today.Day;
                prorate = 91.0 / dayInQuarter;
            }

            // update quantity for this product/period
            psi.UpdateQuantity(quarter, (int)(qty * prorate + .5));
        }
Example #2
0
        void Tabulate(Dictionary<string, ProductSalesInfo> dct, string product, string quarter, string thisQuarter, double qty)
        {
            // get information for this product
            ProductSalesInfo psi = null;
            if (!dct.TryGetValue(product, out psi))
            {
                psi = new ProductSalesInfo(product);
                dct[product] = psi;
            }

            // pro-rate current quarter
            double prorate = 1;
            if (quarter == thisQuarter)
            {
                var monthInQuarter = (DateTime.Today.Month - 1) % 3;
                var dayInQuarter = monthInQuarter * 30 + DateTime.Today.Day;
                prorate = 91.0 / dayInQuarter;
            }

            // update quantity for this product/period
            psi.UpdateQuantity(quarter, (int)(qty * prorate + .5));
        }