Esempio n. 1
0
        //============================================================================*
        // PopulateInventoryData()
        //============================================================================*

        private void PopulateInventoryData()
        {
            QuantityTextBox.Value = (int)m_DataFiles.SupplyQuantity(m_Case);

            CostTextBox.Value = m_DataFiles.SupplyCost(m_Case);

            if (m_DataFiles.Preferences.TrackInventory)
            {
                CostTextBox.Text = String.Format("{0}{1:F2}", m_DataFiles.Preferences.Currency, m_DataFiles.SupplyCost(m_Case));
            }

            SetCostEach();
        }
Esempio n. 2
0
        //============================================================================*
        // PopulateInventoryData()
        //============================================================================*

        private void PopulateInventoryData()
        {
            double dQuantity = cDataFiles.StandardToMetric(m_DataFiles.SupplyQuantity(m_Powder) / 7000.0, cDataFiles.eDataType.CanWeight);

            QuantityTextBox.Value = dQuantity;

            CostTextBox.Value = m_DataFiles.SupplyCost(m_Powder);

            if (m_DataFiles.Preferences.TrackInventory)
            {
                CostTextBox.Text = String.Format("{0}{1:F2}", m_DataFiles.Preferences.Currency, CostTextBox.Value);
            }

            SetCostEach();
        }
Esempio n. 3
0
        //============================================================================*
        // PopulateInventoryData()
        //============================================================================*

        private void PopulateInventoryData()
        {
            m_fPopulating = true;

            QuantityTextBox.Value = (int)m_DataFiles.SupplyQuantity(m_Primer);

            CostTextBox.Value = m_DataFiles.SupplyCost(m_Primer);

            if (m_DataFiles.Preferences.TrackInventory)
            {
                CostTextBox.Text = String.Format("{0}{1:F2}", m_DataFiles.Preferences.Currency, m_DataFiles.SupplyCost(m_Primer));
            }

            m_fPopulating = false;

            SetCostEach();
        }
Esempio n. 4
0
        //============================================================================*
        // PopulateInventoryData()
        //============================================================================*

        private void PopulateInventoryData()
        {
            ComponentLabel.Text = String.Format("{0} {1}", m_Supply.ToString(), cSupply.SupplyTypeString(m_Supply));

            double dQuantityOnHand   = m_Supply.QuantityOnHand;
            double dValue            = m_DataFiles.SupplyCost(m_Supply);
            double dCostEach         = m_DataFiles.SupplyCostEach(m_Supply);
            double dLastPurchaseQty  = m_Supply.LastPurchaseQty;
            double dTotalPurchaseQty = m_Supply.TotalPurchaseQty;
            double dTotalAdjustQty   = m_Supply.TotalAdjustQty;
            double dTotalUsedQty     = m_Supply.TotalUsedQty;

            if (m_Supply.SupplyType == cSupply.eSupplyTypes.Powder)
            {
                dQuantityOnHand   = cDataFiles.StandardToMetric(m_Supply.QuantityOnHand / 7000.0, cDataFiles.eDataType.CanWeight);
                dCostEach         = cDataFiles.StandardToMetric(m_DataFiles.SupplyCostEach(m_Supply) * 7000.0, cDataFiles.eDataType.CanWeight);
                dLastPurchaseQty  = cDataFiles.StandardToMetric(m_Supply.LastPurchaseQty / 7000.0, cDataFiles.eDataType.CanWeight);
                dTotalPurchaseQty = cDataFiles.StandardToMetric(m_Supply.TotalPurchaseQty / 7000.0, cDataFiles.eDataType.CanWeight);
                dTotalAdjustQty   = cDataFiles.StandardToMetric(m_Supply.TotalAdjustQty / 7000.0, cDataFiles.eDataType.CanWeight);
                dTotalUsedQty     = cDataFiles.StandardToMetric(m_Supply.TotalUsedQty / 7000.0, cDataFiles.eDataType.CanWeight);

                string strQtyformat = "{0:F3} {1}{2}";

                QuantityLabel.Text        = String.Format(strQtyformat, dQuantityOnHand, (m_DataFiles.Preferences.MetricCanWeights ? "kilo" : "lb"), (dQuantityOnHand != 1.0 ? "s" : ""));
                LastPurchaseQtyLabel.Text = String.Format(strQtyformat, dLastPurchaseQty, (m_DataFiles.Preferences.MetricCanWeights ? "kilo" : "lb"), (dLastPurchaseQty != 1.0 ? "s" : ""));
                TotalPurchasedLabel.Text  = String.Format(strQtyformat, dTotalPurchaseQty, (m_DataFiles.Preferences.MetricCanWeights ? "kilo" : "lb"), (dTotalPurchaseQty != 1.0 ? "s" : ""));

                TotalAdjustLabel.Text = String.Format(strQtyformat, dTotalAdjustQty, (m_DataFiles.Preferences.MetricCanWeights ? "kilo" : "lb"), (dTotalAdjustQty != 1.0 ? "s" : ""));
                TotalUsedLabel.Text   = String.Format(strQtyformat, dTotalUsedQty, (m_DataFiles.Preferences.MetricCanWeights ? "kilo" : "lb"), (dTotalUsedQty != 1.0 ? "s" : ""));
            }
            else
            {
                string strQtyformat = "{0:G0}";

                QuantityLabel.Text        = String.Format(strQtyformat, dQuantityOnHand);
                LastPurchaseQtyLabel.Text = String.Format(strQtyformat, dLastPurchaseQty);
                TotalPurchasedLabel.Text  = String.Format(strQtyformat, dTotalPurchaseQty);

                TotalAdjustLabel.Text = String.Format(strQtyformat, dTotalAdjustQty);
                TotalUsedLabel.Text   = String.Format(strQtyformat, dTotalUsedQty);
            }

            ValueLabel.Text    = String.Format("{0}{1:F2} *", m_DataFiles.Preferences.Currency, dValue);
            CostEachLabel.Text = String.Format("{0}{1:F2} *", m_DataFiles.Preferences.Currency, dCostEach);

            LastPurchaseDateLabel.Text = (m_Supply.LastPurchaseDate.Year > 2009 ? m_Supply.LastPurchaseDate.ToShortDateString() : "N/A");
            LastPurchaseCostLabel.Text = String.Format("{0}{1:F2}", m_DataFiles.Preferences.Currency, m_Supply.LastPurchaseCost);

            TotalCostLabel.Text = String.Format("{0}{1:F2}", m_DataFiles.Preferences.Currency, m_Supply.TotalPurchaseCost);

            if (m_Supply.SupplyType == cSupply.eSupplyTypes.Powder)
            {
                MinimumStockLevelTextBox.Value            = cDataFiles.StandardToMetric(m_Supply.MinimumStockLevel, cDataFiles.eDataType.CanWeight) / (m_DataFiles.Preferences.MetricCanWeights ? 1000.0 :  7000.0);
                MinimumStockLevelMeasurementLabel.Visible = true;
                cDataFiles.SetMetricLabel(MinimumStockLevelMeasurementLabel, cDataFiles.eDataType.CanWeight);
            }
            else
            {
                MinimumStockLevelTextBox.Value            = m_Supply.MinimumStockLevel;
                MinimumStockLevelMeasurementLabel.Visible = false;
            }

            MinimumStockLevelTextBox.NumDecimals = m_Supply.SupplyType == cSupply.eSupplyTypes.Powder ? 3 : 0;

            if (m_DataFiles.Preferences.AverageCosts)
            {
                MethodLabel.Text = "* - Values based on avg of all purchases";
            }
            else
            {
                MethodLabel.Text = "* - Values based on last purchase only";
            }

            if (m_DataFiles.Preferences.IncludeTaxShipping)
            {
                MethodLabel.Text += " including tax && shipping";
            }
        }
        //============================================================================*
        // 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);
        }