Exemplo n.º 1
0
        /// <summary>
        /// 单击 newDateButton 的事件处理程序。在 Sales 表中
        /// 针对新日期插入新行,并为新数据项设置列表对象。
        /// </summary>
        /// <param name="sender">事件的发送者。</param>
        /// <param name="e">事件参数。</param>
        private void newDateButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (!Globals.DataSet.IsLastDayComplete())
                {
                    MessageBox.Show(Globals.ThisWorkbook.IncompleteDataMessage);
                    return;
                }

                DateTime nextDate = Globals.DataSet.MaxDate.AddDays(1);

                foreach (OperationsBaseData.PricingRow row in Globals.DataSet.Pricing)
                {
                    OperationsBaseData.SalesRow newRow = (OperationsBaseData.SalesRow) this.dayView.Table.NewRow();
                    newRow.Flavor = row.Flavor;
                    newRow.Date   = nextDate;
                    this.dayView.Table.AddSalesRow(newRow);
                }

                this.DateSelector.MaxDate = nextDate;
                this.DateSelector.Value   = nextDate;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
                MessageBox.Show(ex.Message);
            }
        }
        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;
            }
        }
        private void EstimateInventory(OperationsBaseData.SalesRow row, double sellingSpeed)
        {
            double estimatedInventory = row.Inventory - sellingSpeed * (NextWeeklyDeliveryDate - row.Date).Days;

            row.Estimated_Inventory = estimatedInventory;

            if (estimatedInventory < 0)
            {
                row.Recommendation = Properties.Resources.CreateUnscheduledOrderRecommendation;
            }
            else
            {
                row.SetRecommendationNull();
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Calculates potential profit from ordering ice cream.
        /// </summary>
        /// <returns>Potential profit.</returns>
        private double CalculatePotentialProfit()
        {
            double profit = 0 - unscheduledDeliveryCost;

            foreach (DataRowView rowView in this.view)
            {
                OperationsBaseData.SalesRow row = (OperationsBaseData.SalesRow)rowView.Row;

                if (!row.IsEstimated_InventoryNull() && row.Estimated_Inventory < 0)
                {
                    OperationsBaseData.PricingRow pricing = (OperationsBaseData.PricingRow)row.GetParentRow("Pricing_Sales");
                    double flavorProfit = (pricing.Price - pricing.Cost) * (0 - row.Estimated_Inventory);

                    profit += flavorProfit;
                }
            }

            return(profit);
        }