Exercise - Accumulating Statistic result

The CalcOrderTotalForShipper class should look like :

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using Firefly.Box;
using ENV;
using ENV.Data;
using System.Diagnostics;

namespace Northwind.Exercises
{
    public class CalcOrderTotalForShipper : BusinessProcessBase
    {
        public readonly Models.Orders Orders = new Models.Orders();
        Number _numberOfOrders = 0;
        Number _totalValue = 0;

        public CalcOrderTotalForShipper()
        {
            From = Orders;
        }
        public void Run(Number pShipperID)
        {
            Where.Add(Orders.ShipVia.IsEqualTo(pShipperID));
            Execute();
        }
        protected override void OnLeaveRow()
        {
            _numberOfOrders++;
            _totalValue += Orders.Freight;
            Debug.WriteLine("OrderID :" + Orders.OrderID + " Shipper ID :" + Orders.ShipVia);
            Debug.WriteLine("\t\tNumber of orders : " + _numberOfOrders + " Total value :" + _totalValue);
        }
    }
} 

The Output panel results should look like :

2017-04-20_14h27_23


Help us improve, Edit this page on GitHub
or email us at info@fireflymigration.com