private void ComputeSoldColumn(OperationsBaseData.SalesRow row)
        {
            SalesRow previousDaysRow = this.Sales.FindByDateFlavor(row.Date.AddDays(-1), row.Flavor);

            if (previousDaysRow == null)
            {
                row.SetSoldNull();
            }
            else
            {
                int lastInventory = previousDaysRow.Inventory;
                int received;

                OperationsBaseData.InventoryRow[] inventoryRows = row.GetInventoryRows();

                if (inventoryRows == null || inventoryRows.Length == 0)
                {
                    received = 0;
                }
                else
                {
                    received = inventoryRows[0].Received;
                }

                row.Sold = lastInventory - row.Inventory + received;
            }
        }
Beispiel #2
0
            public SalesRow AddSalesRow(decimal Amount, System.DateTime PurchaseDate)
            {
                SalesRow rowSalesRow = ((SalesRow)(this.NewRow()));

                object[] columnValuesArray = new object[] {
                    Amount,
                    null,
                    PurchaseDate
                };
                rowSalesRow.ItemArray = columnValuesArray;
                this.Rows.Add(rowSalesRow);
                return(rowSalesRow);
            }
        protected override void OnSalesInventoryChanged(DataColumnChangeEventArgs e)
        {
            SalesRow row = (SalesRow)e.Row;

            // Changing the inventory means changes in sales for the current day and the next day.
            if (row.RowState == DataRowState.Modified || row.RowState == DataRowState.Added)
            {
                ComputeSoldColumn(row);
                double sellingSpeed = ComputeAverageSellingSpeed(row.Flavor);

                SalesRow nextDay = this.Sales.FindByDateFlavor(row.Date.AddDays(1), row.Flavor);

                if (nextDay != null)
                {
                    ComputeSoldColumn(nextDay);
                    EstimateInventory(nextDay, sellingSpeed);
                }

                // Now that all relevant sold columns are computed,
                // we can estimate the inventory.
                EstimateInventory(row, sellingSpeed);
            }
        }
Beispiel #4
0
        protected override void OnSalesInventoryChanged(DataColumnChangeEventArgs e)
        {
            SalesRow row = (SalesRow)e.Row;

            // 更改库存意味着更改当日和次日的销售额。
            if (row.RowState == DataRowState.Modified || row.RowState == DataRowState.Added)
            {
                ComputeSoldColumn(row);
                double sellingSpeed = ComputeAverageSellingSpeed(row.Flavor);

                SalesRow nextDay = this.Sales.FindByDateFlavor(row.Date.AddDays(1), row.Flavor);

                if (nextDay != null)
                {
                    ComputeSoldColumn(nextDay);
                    EstimateInventory(nextDay, sellingSpeed);
                }

                // 所有相关销售额所在列计算完毕后,
                // 便可以估计库存。
                EstimateInventory(row, sellingSpeed);
            }
        }
 public SalesRowChangeEvent(SalesRow row, global::System.Data.DataRowAction action) {
     this.eventRow = row;
     this.eventAction = action;
 }
 public void RemoveSalesRow(SalesRow row) {
     this.Rows.Remove(row);
 }
 public void AddSalesRow(SalesRow row) {
     this.Rows.Add(row);
 }
Beispiel #8
0
 public SalesRowChangeEvent(SalesRow row, global::System.Data.DataRowAction action)
 {
     this.eventRow    = row;
     this.eventAction = action;
 }
Beispiel #9
0
 public void RemoveSalesRow(SalesRow row)
 {
     this.Rows.Remove(row);
 }
Beispiel #10
0
 public void AddSalesRow(SalesRow row)
 {
     this.Rows.Add(row);
 }