コード例 #1
0
        //============================================================================*
        // SupplyTotals()
        //============================================================================*

        public cCostAnalysisSupplyTotals SupplyTotals(cSupply Supply)
        {
            cCostAnalysisSupplyTotals SupplyTotals = new cCostAnalysisSupplyTotals();

            SupplyTotals.InStockQty   += m_DataFiles.SupplyQuantity(Supply);
            SupplyTotals.InStockTotal += m_DataFiles.SupplyCost(Supply);

            //----------------------------------------------------------------------------*
            // Loop through the supply transactions
            //----------------------------------------------------------------------------*

            foreach (cTransaction Transaction in Supply.TransactionList)
            {
                //----------------------------------------------------------------------------*
                // See if this transaction meets the filter criteria
                //----------------------------------------------------------------------------*

                if (IncludeTransaction(Transaction))
                {
                    //----------------------------------------------------------------------------*
                    // Add to the overall totals
                    //----------------------------------------------------------------------------*

                    SupplyTotals.NumTransactions++;

                    //----------------------------------------------------------------------------*
                    // Determine the Transaction type
                    //----------------------------------------------------------------------------*

                    switch (Transaction.TransactionType)
                    {
                    //----------------------------------------------------------------------------*
                    // Purchase
                    //----------------------------------------------------------------------------*

                    case cTransaction.eTransactionType.Purchase:
                        SupplyTotals.NumPurchases++;
                        SupplyTotals.PurchaseQty   += Transaction.Quantity;
                        SupplyTotals.PurchaseTotal += Transaction.Cost;

                        if (m_DataFiles.Preferences.IncludeTaxShipping)
                        {
                            SupplyTotals.PurchaseTotal += (Transaction.Tax + Transaction.Shipping);
                        }

                        break;

                    //----------------------------------------------------------------------------*
                    // SetStockLevel
                    //----------------------------------------------------------------------------*

                    case cTransaction.eTransactionType.SetStockLevel:
                        if (Supply.SupplyType != cSupply.eSupplyTypes.Ammo || Transaction.BatchID == 0)
                        {
                            SupplyTotals.NumInitialStock++;
                            SupplyTotals.InitialStockQty   += Transaction.Quantity;
                            SupplyTotals.InitialStockTotal += Transaction.Cost;

                            if (m_DataFiles.Preferences.IncludeTaxShipping)
                            {
                                SupplyTotals.InitialStockTotal += (Transaction.Tax + Transaction.Shipping);
                            }
                        }
                        else
                        {
                            SupplyTotals.NumInitialStock++;
                            SupplyTotals.InitialStockQty   += Transaction.Quantity;
                            SupplyTotals.InitialStockTotal += m_DataFiles.BatchCost(Transaction.BatchID);
                        }

                        break;

                    //----------------------------------------------------------------------------*
                    // AddStock
                    //----------------------------------------------------------------------------*

                    case cTransaction.eTransactionType.AddStock:
                        SupplyTotals.NumAdjustments++;
                        SupplyTotals.AdjustmentsQty   += Transaction.Quantity;
                        SupplyTotals.AdjustmentsTotal += Transaction.Cost;

                        if (m_DataFiles.Preferences.IncludeTaxShipping)
                        {
                            SupplyTotals.AdjustmentsTotal += (Transaction.Tax + Transaction.Shipping);
                        }

                        break;

                    //----------------------------------------------------------------------------*
                    // ReduceStock
                    //----------------------------------------------------------------------------*

                    case cTransaction.eTransactionType.ReduceStock:
                        if (Supply.SupplyType == cSupply.eSupplyTypes.Ammo)
                        {
                            SupplyTotals.NumAdjustments++;
                            SupplyTotals.AdjustmentsQty   -= Transaction.Quantity;
                            SupplyTotals.AdjustmentsTotal -= Transaction.Cost;
                        }
                        else
                        {
                            if (Transaction.BatchID == 0)
                            {
                                SupplyTotals.NumAdjustments++;
                                SupplyTotals.AdjustmentsQty   -= Transaction.Quantity;
                                SupplyTotals.AdjustmentsTotal -= Transaction.Cost;
                            }
                            else
                            {
                                SupplyTotals.NumUsed++;

                                switch (Supply.SupplyType)
                                {
                                case cSupply.eSupplyTypes.Bullets:
                                    SupplyTotals.UsedQty   -= Transaction.Quantity;
                                    SupplyTotals.UsedTotal -= m_DataFiles.BatchBulletCost(Transaction.BatchID);
                                    break;

                                case cSupply.eSupplyTypes.Cases:
                                    SupplyTotals.UsedQty   -= Transaction.Quantity;
                                    SupplyTotals.UsedTotal -= m_DataFiles.BatchCaseCost(Transaction.BatchID);
                                    break;

                                case cSupply.eSupplyTypes.Powder:
                                    SupplyTotals.UsedQty   -= Transaction.Quantity;
                                    SupplyTotals.UsedTotal -= m_DataFiles.BatchPowderCost(Transaction.BatchID);
                                    break;

                                case cSupply.eSupplyTypes.Primers:
                                    SupplyTotals.UsedQty   -= Transaction.Quantity;
                                    SupplyTotals.UsedTotal -= m_DataFiles.BatchPrimerCost(Transaction.BatchID);
                                    break;
                                }
                            }
                        }

                        break;

                    //----------------------------------------------------------------------------*
                    // Fired
                    //----------------------------------------------------------------------------*

                    case cTransaction.eTransactionType.Fired:
                        SupplyTotals.NumFired++;

                        SupplyTotals.FiredQty   += Transaction.Quantity;
                        SupplyTotals.FiredTotal += Transaction.Cost;

                        break;
                    }
                }
            }

            if (Supply.SupplyType == cSupply.eSupplyTypes.Powder)
            {
                SupplyTotals.AdjustmentsQty  /= 7000.0;
                SupplyTotals.FiredQty        /= 7000.0;
                SupplyTotals.InitialStockQty /= 7000.0;
                SupplyTotals.InStockQty      /= 7000.0;
                SupplyTotals.PurchaseQty     /= 7000.0;
                SupplyTotals.UsedQty         /= 7000.0;

                SupplyTotals.AdjustmentsQty  = cDataFiles.StandardToMetric(SupplyTotals.AdjustmentsQty, cDataFiles.eDataType.CanWeight);
                SupplyTotals.FiredQty        = cDataFiles.StandardToMetric(SupplyTotals.FiredQty, cDataFiles.eDataType.CanWeight);
                SupplyTotals.InitialStockQty = cDataFiles.StandardToMetric(SupplyTotals.InitialStockQty, cDataFiles.eDataType.CanWeight);
                SupplyTotals.InStockQty      = cDataFiles.StandardToMetric(SupplyTotals.InStockQty, cDataFiles.eDataType.CanWeight);
                SupplyTotals.PurchaseQty     = cDataFiles.StandardToMetric(SupplyTotals.PurchaseQty, cDataFiles.eDataType.CanWeight);
                SupplyTotals.UsedQty         = cDataFiles.StandardToMetric(SupplyTotals.UsedQty, cDataFiles.eDataType.CanWeight);
            }

            return(SupplyTotals);
        }