Пример #1
0
 public static void AddSubPrice2ToStocks(this SubPrice2Stock baseStat, SubPrice1 subprice)
 {
     //make sure that each subprice has a corresponding stock
     if (baseStat.SubPrice2Stocks == null)
     {
         SubPrice2Stock ind1 = new SubPrice2Stock();
         baseStat.SubPrice2Stocks.Add(ind1);
     }
     if (!baseStat.SubPrice2Stocks
         .Any(s => s.TotalSubP2Label == subprice.SubPLabel))
     {
         if (subprice.SubPLabel != string.Empty)
         {
             SubPrice2Stock stock = new SubPrice2Stock();
             stock.TotalSubP2Label       = subprice.SubPLabel;
             stock.TotalSubP2Name        = subprice.SubPName;
             stock.TotalSubP2Unit        = subprice.SubPUnit;
             stock.TotalSubP2Description = subprice.SubPDescription;
             baseStat.SubPrice2Stocks.Add(stock);
         }
     }
     else
     {
         //update the identifiers in case they have changed
         SubPrice2Stock stock = baseStat.SubPrice2Stocks
                                .FirstOrDefault(s => s.TotalSubP2Label == subprice.SubPLabel);
         if (stock != null)
         {
             stock.TotalSubP2Label       = subprice.SubPLabel;
             stock.TotalSubP2Name        = subprice.SubPName;
             stock.TotalSubP2Unit        = subprice.SubPUnit;
             stock.TotalSubP2Description = subprice.SubPDescription;
         }
     }
 }
Пример #2
0
        public virtual void SetSubPrice1sProperties(XElement calculator)
        {
            //remember that the calculator inheriting from this class must set id and name
            //this.SetCalculatorProperties(calculator);
            if (this.SubPrice1s == null)
            {
                this.SubPrice1s = new List <SubPrice1>();
            }
            int i = 1;
            //standard attname used throughout DevTreks
            string sAttNameExtension = string.Empty;
            //don't make unnecessary collection members
            string sHasAttribute = string.Empty;

            for (i = 1; i < this.MaximumNumberOfSubPrice1s; i++)
            {
                sAttNameExtension = i.ToString();
                sHasAttribute     = CalculatorHelpers.GetAttribute(calculator,
                                                                   string.Concat(cSubPName, sAttNameExtension));
                if (!string.IsNullOrEmpty(sHasAttribute))
                {
                    SubPrice1 subP1 = new SubPrice1();
                    SetSubPrice1Properties(subP1, sAttNameExtension, calculator);
                    this.SubPrice1s.Add(subP1);
                }
                sHasAttribute = string.Empty;
            }
        }
Пример #3
0
        public virtual string GetSubPrice1sProperty(string attName, int colIndex)
        {
            string sPropertyValue = string.Empty;

            if (this.SubPrice1s.Count >= (colIndex + 1))
            {
                SubPrice1 subP = this.SubPrice1s.ElementAt(colIndex);
                if (subP != null)
                {
                    sPropertyValue = GetSubPrice1Property(subP, attName);
                }
            }
            return(sPropertyValue);
        }
Пример #4
0
 private void AddSubCost(LCA1Total1 totStock, SubPrice1 subprice, LCC1Calculator lccInput)
 {
     //make sure that each subprice has a corresponding stock
     totStock.SubP1Stock.AddSubPrice1ToStocks(subprice);
     //add cumulative totals (material, equipment, labor)
     foreach (SubPrice1Stock stock in totStock.SubP1Stock.SubPrice1Stocks)
     {
         if ((stock.TotalSubP1Label == subprice.SubPLabel &&
              subprice.SubPLabel != string.Empty))
         {
             stock.TotalSubP1Total       += subprice.SubPTotal;
             stock.TotalSubP1Price       += subprice.SubPPrice;
             stock.TotalSubP1Amount      += subprice.SubPAmount;
             stock.TotalSubP1TotalPerUnit = stock.TotalSubP1Total / lccInput.PerUnitAmount;
         }
     }
 }
Пример #5
0
 public virtual void CopySubPrice1sProperties(
     SubPrice1 calculator)
 {
     if (calculator.SubPrice1s != null)
     {
         if (this.SubPrice1s == null)
         {
             this.SubPrice1s = new List <SubPrice1>();
         }
         foreach (SubPrice1 calculatorInd in calculator.SubPrice1s)
         {
             SubPrice1 subP = new SubPrice1();
             CopySubPrice1Properties(subP, calculatorInd);
             this.SubPrice1s.Add(subP);
         }
     }
 }
Пример #6
0
 private void AddSubBenefit(LCA1Total1 totStock, SubPrice1 subprice, LCB1Calculator lcbOutput)
 {
     //make sure that each subprice has a corresponding stock2
     //stock2 distinguishes benefits from costs in budget elements
     totStock.SubP2Stock.AddSubPrice2ToStocks(subprice);
     //add cumulative totals (rentals, commodities, sales)
     foreach (SubPrice2Stock stock in totStock.SubP2Stock.SubPrice2Stocks)
     {
         if ((stock.TotalSubP2Label == subprice.SubPLabel &&
              subprice.SubPLabel != string.Empty))
         {
             stock.TotalSubP2Total       += subprice.SubPTotal;
             stock.TotalSubP2Price       += subprice.SubPPrice;
             stock.TotalSubP2Amount      += subprice.SubPAmount;
             stock.TotalSubP2TotalPerUnit = stock.TotalSubP2Total / lcbOutput.PerUnitAmount;
         }
     }
 }
Пример #7
0
        public virtual void SetSubPrice1sProperty(string attName,
                                                  string attValue, int colIndex)
        {
            if (this.SubPrice1s == null)
            {
                this.SubPrice1s = new List <SubPrice1>();
            }
            if (this.SubPrice1s.Count < (colIndex + 1))
            {
                SubPrice1 subP1 = new SubPrice1();
                this.SubPrice1s.Insert(colIndex, subP1);
            }
            SubPrice1 subP = this.SubPrice1s.ElementAt(colIndex);

            if (subP != null)
            {
                SetSubPrice1Property(subP, attName, attValue);
            }
        }
Пример #8
0
 public virtual void CopyLCC1Properties(
     LCC1Input calculator)
 {
     this.CopyCalculatorProperties(calculator);
     this.CopySharedObjectProperties(calculator);
     //this.CopySubPrice1sProperties(calculator);
     this.ServiceLifeYears          = calculator.ServiceLifeYears;
     this.YearsFromBaseDate         = calculator.YearsFromBaseDate;
     this.PlanningConstructionYears = calculator.PlanningConstructionYears;
     this.PerUnitAmount             = calculator.PerUnitAmount;
     this.PerUnitUnit   = calculator.PerUnitUnit;
     this.SubPrice1     = new SubPrice1(calculator.SubPrice1);
     this.OCTotalCost   = calculator.OCTotalCost;
     this.AOHTotalCost  = calculator.AOHTotalCost;
     this.CAPTotalCost  = calculator.CAPTotalCost;
     this.LCCTotalCost  = calculator.LCCTotalCost;
     this.EAATotalCost  = calculator.EAATotalCost;
     this.UnitTotalCost = calculator.UnitTotalCost;
 }
Пример #9
0
 public void SetSubPrice1Attributes(SubPrice1 subP, string attNameExtension,
                                    ref XElement calculator)
 {
     //don't needlessly add these to linkedviews if they are not being used
     if (subP.SubPName != string.Empty && subP.SubPName != Constants.NONE)
     {
         //remember that the calculator inheriting from this class must set id and name atts
         //and remove unwanted old atts i.e. this.SetCalculatorAttributes(calculator);
         CalculatorHelpers.SetAttribute(calculator,
                                        string.Concat(cSubPName, attNameExtension), subP.SubPName);
         CalculatorHelpers.SetAttribute(calculator,
                                        string.Concat(cSubPDescription, attNameExtension), subP.SubPDescription);
         CalculatorHelpers.SetAttribute(calculator,
                                        string.Concat(cSubPLabel, attNameExtension), subP.SubPLabel);
         CalculatorHelpers.SetAttribute(calculator,
                                        string.Concat(cSubPType, attNameExtension), subP.SubPType);
         CalculatorHelpers.SetAttributeDoubleF4(calculator,
                                                string.Concat(cSubPFactor, attNameExtension), subP.SubPFactor);
         CalculatorHelpers.SetAttributeDoubleF2(calculator,
                                                string.Concat(cSubPYears, attNameExtension), subP.SubPYears);
         CalculatorHelpers.SetAttributeDoubleF2(calculator,
                                                string.Concat(cSubPYearTimes, attNameExtension), subP.SubPYearTimes);
         CalculatorHelpers.SetAttributeDoubleF2(calculator,
                                                string.Concat(cSubPSalvValue, attNameExtension), subP.SubPSalvValue);
         CalculatorHelpers.SetAttributeDoubleF3(calculator,
                                                string.Concat(cSubPAmount, attNameExtension), subP.SubPAmount);
         CalculatorHelpers.SetAttribute(calculator,
                                        string.Concat(cSubPUnit, attNameExtension), subP.SubPUnit);
         CalculatorHelpers.SetAttributeDoubleF3(calculator,
                                                string.Concat(cSubPPrice, attNameExtension), subP.SubPPrice);
         CalculatorHelpers.SetAttributeDoubleF3(calculator,
                                                string.Concat(cSubPEscRate, attNameExtension), subP.SubPEscRate);
         CalculatorHelpers.SetAttribute(calculator,
                                        string.Concat(cSubPEscType, attNameExtension), subP.SubPEscType);
         CalculatorHelpers.SetAttributeDoubleF2(calculator,
                                                string.Concat(cSubPTotal, attNameExtension), subP.SubPTotal);
         CalculatorHelpers.SetAttributeDoubleF2(calculator,
                                                string.Concat(cSubPTotalPerUnit, attNameExtension), subP.SubPTotalPerUnit);
         CalculatorHelpers.SetAttribute(calculator,
                                        string.Concat(cSubPOtherType, attNameExtension), subP.SubPOtherType);
     }
 }
Пример #10
0
 public void InitSubPrice1Properties(SubPrice1 subP)
 {
     subP.SubPName         = string.Empty;
     subP.SubPDescription  = string.Empty;
     subP.SubPLabel        = string.Empty;
     subP.SubPType         = PRICE_TYPE.none.ToString();
     subP.SubPFactor       = 0;
     subP.SubPYears        = 0;
     subP.SubPYearTimes    = 0;
     subP.SubPSalvValue    = 0;
     subP.SubPAmount       = 0;
     subP.SubPUnit         = string.Empty;
     subP.SubPPrice        = 0;
     subP.SubPEscRate      = 0;
     subP.SubPEscType      = string.Empty;
     subP.SubPTotal        = 0;
     subP.SubPTotalPerUnit = 0;
     subP.SubPFactor       = 0;
     subP.SubPOtherType    = OTHERPRICE_TYPE.none.ToString();
 }
Пример #11
0
 private void CopySubPrice1Properties(
     SubPrice1 subP, SubPrice1 calculator)
 {
     subP.SubPName         = calculator.SubPName;
     subP.SubPDescription  = calculator.SubPDescription;
     subP.SubPLabel        = calculator.SubPLabel;
     subP.SubPType         = calculator.SubPType;
     subP.SubPFactor       = calculator.SubPFactor;
     subP.SubPYears        = calculator.SubPYears;
     subP.SubPYearTimes    = calculator.SubPYearTimes;
     subP.SubPSalvValue    = calculator.SubPSalvValue;
     subP.SubPAmount       = calculator.SubPAmount;
     subP.SubPUnit         = calculator.SubPUnit;
     subP.SubPPrice        = calculator.SubPPrice;
     subP.SubPEscRate      = calculator.SubPEscRate;
     subP.SubPEscType      = calculator.SubPEscType;
     subP.SubPTotal        = calculator.SubPTotal;
     subP.SubPTotalPerUnit = calculator.SubPTotalPerUnit;
     subP.SubPOtherType    = calculator.SubPOtherType;
 }
Пример #12
0
        public virtual void InitLCC1Properties()
        {
            //avoid null references to properties
            this.InitCalculatorProperties();
            this.InitSharedObjectProperties();
            this.SubPrice1 = new SubPrice1();
            this.SubPrice1.InitSubPrice1Properties(this.SubPrice1);

            this.ServiceLifeYears          = 0;
            this.YearsFromBaseDate         = 0;
            this.PlanningConstructionYears = 0;
            //avoid divide by zero when left out
            this.PerUnitAmount = 1;
            this.PerUnitUnit   = string.Empty;
            this.OCTotalCost   = 0;
            this.AOHTotalCost  = 0;
            this.CAPTotalCost  = 0;
            this.LCCTotalCost  = 0;
            this.EAATotalCost  = 0;
            this.UnitTotalCost = 0;
        }
Пример #13
0
 public virtual void SetSubPrice1Attributes(SubPrice1 subP, string attNameExtension,
                                            ref XmlWriter writer)
 {
     //don't needlessly add these to linkedviews if they are not being used
     if (subP.SubPName != string.Empty && subP.SubPName != Constants.NONE)
     {
         writer.WriteAttributeString(
             string.Concat(cSubPName, attNameExtension), subP.SubPName);
         writer.WriteAttributeString(
             string.Concat(cSubPDescription, attNameExtension), subP.SubPDescription);
         writer.WriteAttributeString(
             string.Concat(cSubPLabel, attNameExtension), subP.SubPLabel);
         writer.WriteAttributeString(
             string.Concat(cSubPType, attNameExtension), subP.SubPType);
         writer.WriteAttributeString(
             string.Concat(cSubPFactor, attNameExtension), subP.SubPFactor.ToString());
         writer.WriteAttributeString(
             string.Concat(cSubPYears, attNameExtension), subP.SubPYears.ToString());
         writer.WriteAttributeString(
             string.Concat(cSubPYearTimes, attNameExtension), subP.SubPYearTimes.ToString("N2", CultureInfo.InvariantCulture));
         writer.WriteAttributeString(
             string.Concat(cSubPSalvValue, attNameExtension), subP.SubPSalvValue.ToString("N2", CultureInfo.InvariantCulture));
         writer.WriteAttributeString(
             string.Concat(cSubPAmount, attNameExtension), subP.SubPAmount.ToString("N3", CultureInfo.InvariantCulture));
         writer.WriteAttributeString(
             string.Concat(cSubPUnit, attNameExtension), subP.SubPUnit);
         writer.WriteAttributeString(
             string.Concat(cSubPPrice, attNameExtension), subP.SubPPrice.ToString("N2", CultureInfo.InvariantCulture));
         writer.WriteAttributeString(
             string.Concat(cSubPEscRate, attNameExtension), subP.SubPEscRate.ToString());
         writer.WriteAttributeString(
             string.Concat(cSubPEscType, attNameExtension), subP.SubPEscType);
         writer.WriteAttributeString(
             string.Concat(cSubPTotal, attNameExtension), subP.SubPTotal.ToString("N2", CultureInfo.InvariantCulture));
         writer.WriteAttributeString(
             string.Concat(cSubPTotalPerUnit, attNameExtension), subP.SubPTotalPerUnit.ToString("N2", CultureInfo.InvariantCulture));
         writer.WriteAttributeString(
             string.Concat(cSubPOtherType, attNameExtension), subP.SubPOtherType);
     }
 }
Пример #14
0
 public void SetSubPrice1Properties(SubPrice1 subP, string attNameExtension,
                                    XElement calculator)
 {
     //set this object's properties
     subP.SubPName = CalculatorHelpers.GetAttribute(calculator,
                                                    string.Concat(cSubPName, attNameExtension));
     subP.SubPDescription = CalculatorHelpers.GetAttribute(calculator,
                                                           string.Concat(cSubPDescription, attNameExtension));
     subP.SubPLabel = CalculatorHelpers.GetAttribute(calculator,
                                                     string.Concat(cSubPLabel, attNameExtension));
     subP.SubPType = CalculatorHelpers.GetAttribute(calculator,
                                                    string.Concat(cSubPType, attNameExtension));
     subP.SubPAmount = CalculatorHelpers.GetAttributeDouble(calculator,
                                                            string.Concat(cSubPAmount, attNameExtension));
     subP.SubPUnit = CalculatorHelpers.GetAttribute(calculator,
                                                    string.Concat(cSubPUnit, attNameExtension));
     subP.SubPPrice = CalculatorHelpers.GetAttributeDouble(calculator,
                                                           string.Concat(cSubPPrice, attNameExtension));
     subP.SubPFactor = CalculatorHelpers.GetAttributeDouble(calculator,
                                                            string.Concat(cSubPFactor, attNameExtension));
     subP.SubPYears = CalculatorHelpers.GetAttributeDouble(calculator,
                                                           string.Concat(cSubPYears, attNameExtension));
     subP.SubPYearTimes = CalculatorHelpers.GetAttributeDouble(calculator,
                                                               string.Concat(cSubPYearTimes, attNameExtension));
     subP.SubPSalvValue = CalculatorHelpers.GetAttributeDouble(calculator,
                                                               string.Concat(cSubPSalvValue, attNameExtension));
     subP.SubPEscRate = CalculatorHelpers.GetAttributeDouble(calculator,
                                                             string.Concat(cSubPEscRate, attNameExtension));
     subP.SubPEscType = CalculatorHelpers.GetAttribute(calculator,
                                                       string.Concat(cSubPEscType, attNameExtension));
     subP.SubPTotal = CalculatorHelpers.GetAttributeDouble(calculator,
                                                           string.Concat(cSubPTotal, attNameExtension));
     subP.SubPTotalPerUnit = CalculatorHelpers.GetAttributeDouble(calculator,
                                                                  string.Concat(cSubPTotalPerUnit, attNameExtension));
     subP.SubPOtherType = CalculatorHelpers.GetAttribute(calculator,
                                                         string.Concat(cSubPOtherType, attNameExtension));
 }
Пример #15
0
        private string GetSubPrice1Property(SubPrice1 subP, string attName)
        {
            string sPropertyValue = string.Empty;

            switch (attName)
            {
            case cSubPName:
                sPropertyValue = subP.SubPName;
                break;

            case cSubPDescription:
                sPropertyValue = subP.SubPDescription;
                break;

            case cSubPLabel:
                sPropertyValue = subP.SubPLabel;
                break;

            case cSubPType:
                sPropertyValue = subP.SubPType;
                break;

            case cSubPFactor:
                sPropertyValue = subP.SubPFactor.ToString();
                break;

            case cSubPYears:
                sPropertyValue = subP.SubPYears.ToString();
                break;

            case cSubPYearTimes:
                sPropertyValue = subP.SubPYearTimes.ToString();
                break;

            case cSubPSalvValue:
                sPropertyValue = subP.SubPSalvValue.ToString();
                break;

            case cSubPAmount:
                sPropertyValue = subP.SubPAmount.ToString();
                break;

            case cSubPUnit:
                sPropertyValue = subP.SubPUnit.ToString();
                break;

            case cSubPPrice:
                sPropertyValue = subP.SubPPrice.ToString();
                break;

            case cSubPEscRate:
                sPropertyValue = subP.SubPEscRate.ToString();
                break;

            case cSubPEscType:
                sPropertyValue = subP.SubPEscType;
                break;

            case cSubPTotal:
                sPropertyValue = subP.SubPTotal.ToString();
                break;

            case cSubPTotalPerUnit:
                sPropertyValue = subP.SubPTotalPerUnit.ToString();
                break;

            case cSubPOtherType:
                sPropertyValue = subP.SubPOtherType.ToString();
                break;

            default:
                break;
            }
            return(sPropertyValue);
        }
Пример #16
0
 //copy constructors
 public SubPrice1(SubPrice1 calculator)
 {
     CopySubPrice1sProperties(calculator);
 }
Пример #17
0
        public void SetSubPrice1Property(SubPrice1 subP,
                                         string attName, string attValue)
        {
            switch (attName)
            {
            case cSubPName:
                subP.SubPName = attValue;
                break;

            case cSubPDescription:
                subP.SubPDescription = attValue;
                break;

            case cSubPLabel:
                subP.SubPLabel = attValue;
                break;

            case cSubPType:
                subP.SubPType = attValue;
                break;

            case cSubPFactor:
                subP.SubPFactor = CalculatorHelpers.ConvertStringToDouble(attValue);
                break;

            case cSubPYears:
                subP.SubPYears = CalculatorHelpers.ConvertStringToDouble(attValue);
                break;

            case cSubPYearTimes:
                subP.SubPYearTimes = CalculatorHelpers.ConvertStringToDouble(attValue);
                break;

            case cSubPSalvValue:
                subP.SubPSalvValue = CalculatorHelpers.ConvertStringToDouble(attValue);
                break;

            case cSubPAmount:
                subP.SubPAmount = CalculatorHelpers.ConvertStringToDouble(attValue);
                break;

            case cSubPUnit:
                subP.SubPUnit = attValue;
                break;

            case cSubPPrice:
                subP.SubPPrice = CalculatorHelpers.ConvertStringToDouble(attValue);
                break;

            case cSubPEscRate:
                subP.SubPEscRate = CalculatorHelpers.ConvertStringToDouble(attValue);
                break;

            case cSubPEscType:
                subP.SubPEscType = attValue;
                break;

            case cSubPTotal:
                subP.SubPTotal = CalculatorHelpers.ConvertStringToDouble(attValue);
                break;

            case cSubPTotalPerUnit:
                subP.SubPTotalPerUnit = CalculatorHelpers.ConvertStringToDouble(attValue);
                break;

            case cSubPOtherType:
                subP.SubPOtherType = attValue;
                break;

            default:
                break;
            }
        }