コード例 #1
0
        private void GetOrders(int prodId, ref SalesReportReportEntity orderTotals)
        {
            double ManufactorPrice  = GetManufactorPrice(prodId);
            string filterExpression = "iProductId = " + prodId;

            DataRow[] rows = _dataOrders.Tables[0].Select(filterExpression);
            foreach (var row in rows)
            {
                orderTotals.ManufactorPriceSummary += ManufactorPrice;
                orderTotals.SalesPricesSummary     += Convert.ToDouble(row["iOrderAmount"]);
                orderTotals.CountOfSales++;
            }
            orderTotals.OutcomeSummary = orderTotals.SalesPricesSummary - orderTotals.ManufactorPriceSummary;
        }
コード例 #2
0
        private void GetSalesAmounts(int prodId, ref SalesReportReportEntity yearAmounts,
                                     ref SalesReportReportEntity yearPrevAmounts, ref SalesReportReportEntity yearTotals,
                                     ref SalesReportReportEntity monthTotals, ref List <SalesReportReportEntity> prevMonthsTotals)
        {
            double ManufactorPrice  = GetManufactorPrice(prodId);
            string filterExpression = "iProductId = " + prodId;

            DataRow[] rows = _dataSales.Tables[0].Select(filterExpression);

            for (int i = 1; i <= _monthToReport - 1; i++)
            {
                prevMonthsTotals.Add(new SalesReportReportEntity());
            }

            foreach (var row in rows)
            {
                DateTime dtSalesDate = Convert.ToDateTime(row["iSalesDate"]);
                if (dtSalesDate.Year == _yearToReport)
                {
                    yearAmounts.ManufactorPriceSummary += ManufactorPrice;
                    yearAmounts.SalesPricesSummary     += Convert.ToDouble(row["iSalesAmount"]);
                    yearAmounts.CountOfSales++;
                }

                if ((dtSalesDate.Year == _yearToReport) && (dtSalesDate.Month == _monthToReport))
                {
                    monthTotals.ManufactorPriceSummary += ManufactorPrice;
                    monthTotals.SalesPricesSummary     += Convert.ToDouble(row["iSalesAmount"]);
                    monthTotals.CountOfSales++;
                }

                if ((dtSalesDate.Year == _yearToReport) && (dtSalesDate.Month < _monthToReport))
                {
                    prevMonthsTotals[dtSalesDate.Month - 1].ManufactorPriceSummary += ManufactorPrice;
                    prevMonthsTotals[dtSalesDate.Month - 1].SalesPricesSummary     += Convert.ToDouble(row["iSalesAmount"]);
                    prevMonthsTotals[dtSalesDate.Month - 1].CountOfSales++;
                }
                if ((dtSalesDate.Year == _yearToReport) && (dtSalesDate.Month > _monthToReport))
                {
                }

                if (dtSalesDate.Year == _yearToReport - 1)
                {
                    yearPrevAmounts.ManufactorPriceSummary += ManufactorPrice;
                    yearPrevAmounts.SalesPricesSummary     += Convert.ToDouble(row["iSalesAmount"]);
                    yearPrevAmounts.CountOfSales++;
                }

                yearTotals.ManufactorPriceSummary += ManufactorPrice;
                yearTotals.SalesPricesSummary     += Convert.ToDouble(row["iSalesAmount"]);
                yearTotals.CountOfSales++;
            }

            yearAmounts.OutcomeSummary     = yearAmounts.SalesPricesSummary - yearAmounts.ManufactorPriceSummary;
            yearPrevAmounts.OutcomeSummary = yearPrevAmounts.SalesPricesSummary - yearPrevAmounts.ManufactorPriceSummary;
            monthTotals.OutcomeSummary     = monthTotals.SalesPricesSummary - monthTotals.ManufactorPriceSummary;
            foreach (SalesReportReportEntity itemMonth in prevMonthsTotals)
            {
                itemMonth.OutcomeSummary = itemMonth.SalesPricesSummary - itemMonth.ManufactorPriceSummary;
            }
            yearTotals.OutcomeSummary = yearTotals.SalesPricesSummary - yearTotals.ManufactorPriceSummary;
        }