Пример #1
0
        public virtual void SetTotalSubPrice2StocksProperties(XElement calculator)
        {
            //remember that the analyzer inheriting from this must .SetAnalyzerProps
            if (this.SubPrice2Stocks == null)
            {
                this.SubPrice2Stocks = new List <SubPrice2Stock>();
            }
            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.MaximumNumberOfSubPrice2Stocks; i++)
            {
                sAttNameExtension = i.ToString();
                sHasAttribute     = CalculatorHelpers.GetAttribute(calculator,
                                                                   string.Concat(SubPrice1.cSubPName, sAttNameExtension));
                if (!string.IsNullOrEmpty(sHasAttribute))
                {
                    SubPrice2Stock ind1 = new SubPrice2Stock();
                    SetTotalSubPrice2StockProperties(ind1, sAttNameExtension, calculator);
                    this.SubPrice2Stocks.Add(ind1);
                }
                sHasAttribute = string.Empty;
            }
        }
Пример #2
0
 public static void AddSubStock2ToTotalStocks(this LCA1Total1 baseStat, SubPrice2Stock substock)
 {
     //make sure that each subprice has a corresponding stock
     if (baseStat.SubP2Stock.SubPrice2Stocks == null)
     {
         baseStat.SubP2Stock.SubPrice2Stocks = new List <SubPrice2Stock>();
     }
     if (!baseStat.SubP2Stock.SubPrice2Stocks
         .Any(s => s.TotalSubP2Label == substock.TotalSubP2Label))
     {
         if (substock.TotalSubP2Label != string.Empty)
         {
             SubPrice2Stock stock = new SubPrice2Stock();
             stock.TotalSubP2Label       = substock.TotalSubP2Label;
             stock.TotalSubP2Name        = substock.TotalSubP2Name;
             stock.TotalSubP2Unit        = substock.TotalSubP2Unit;
             stock.TotalSubP2Description = substock.TotalSubP2Description;
             baseStat.SubP2Stock.SubPrice2Stocks.Add(stock);
         }
     }
     else
     {
         //update the identifiers in case they have changed
         SubPrice2Stock stock = baseStat.SubP2Stock.SubPrice2Stocks
                                .FirstOrDefault(s => s.TotalSubP2Label == substock.TotalSubP2Label);
         if (stock != null)
         {
             stock.TotalSubP2Label       = substock.TotalSubP2Label;
             stock.TotalSubP2Name        = substock.TotalSubP2Name;
             stock.TotalSubP2Unit        = substock.TotalSubP2Unit;
             stock.TotalSubP2Description = substock.TotalSubP2Description;
         }
     }
 }
Пример #3
0
 private void InitTotalSubPrice2StockProperties(SubPrice2Stock ind)
 {
     ind.ErrorMessage           = string.Empty;
     ind.TotalSubP2Description  = string.Empty;
     ind.TotalSubP2Name         = string.Empty;
     ind.TotalSubP2Label        = string.Empty;
     ind.TotalSubP2Total        = 0;
     ind.TotalSubP2TotalPerUnit = 0;
     ind.TotalSubP2Price        = 0;
     ind.TotalSubP2Unit         = string.Empty;
     ind.TotalSubP2Amount       = 0;
 }
Пример #4
0
 private void CopyTotalSubPrice2StockProperties(SubPrice2Stock ind,
                                                SubPrice2Stock calculator)
 {
     ind.ErrorMessage           = calculator.ErrorMessage;
     ind.TotalSubP2Description  = calculator.TotalSubP2Description;
     ind.TotalSubP2Name         = calculator.TotalSubP2Name;
     ind.TotalSubP2Label        = calculator.TotalSubP2Label;
     ind.TotalSubP2Total        = calculator.TotalSubP2Total;
     ind.TotalSubP2TotalPerUnit = calculator.TotalSubP2TotalPerUnit;
     ind.TotalSubP2Price        = calculator.TotalSubP2Price;
     ind.TotalSubP2Unit         = calculator.TotalSubP2Unit;
     ind.TotalSubP2Amount       = calculator.TotalSubP2Amount;
 }
Пример #5
0
        public virtual string GetTotalSubPrice2StocksProperty(string attName, int colIndex)
        {
            string sPropertyValue = string.Empty;

            if (this.SubPrice2Stocks.Count >= (colIndex + 1))
            {
                SubPrice2Stock ind = this.SubPrice2Stocks.ElementAt(colIndex);
                if (ind != null)
                {
                    sPropertyValue = GetTotalSubPrice2StockProperty(ind, attName);
                }
            }
            return(sPropertyValue);
        }
Пример #6
0
 public virtual void CopyTotalSubPrice2StocksProperties(
     SubPrice2Stock calculator)
 {
     if (calculator.SubPrice2Stocks != null)
     {
         if (this.SubPrice2Stocks == null)
         {
             this.SubPrice2Stocks = new List <SubPrice2Stock>();
         }
         foreach (SubPrice2Stock calculatorInd in calculator.SubPrice2Stocks)
         {
             SubPrice2Stock indstock = new SubPrice2Stock();
             CopyTotalSubPrice2StockProperties(indstock, calculatorInd);
             this.SubPrice2Stocks.Add(indstock);
         }
     }
 }
Пример #7
0
        private string GetTotalSubPrice2StockProperty(SubPrice2Stock ind, string attName)
        {
            string sPropertyValue = string.Empty;

            switch (attName)
            {
            case cTotalSubP2Description:
                sPropertyValue = ind.TotalSubP2Description;
                break;

            case cTotalSubP2Name:
                sPropertyValue = ind.TotalSubP2Name.ToString();
                break;

            case cTotalSubP2Label:
                sPropertyValue = ind.TotalSubP2Label.ToString();
                break;

            case cTotalSubP2Total:
                sPropertyValue = ind.TotalSubP2Total.ToString();
                break;

            case cTotalSubP2TotalPerUnit:
                sPropertyValue = ind.TotalSubP2TotalPerUnit.ToString();
                break;

            case cTotalSubP2Price:
                sPropertyValue = ind.TotalSubP2Price.ToString();
                break;

            case cTotalSubP2Unit:
                sPropertyValue = ind.TotalSubP2Unit;
                break;

            case cTotalSubP2Amount:
                sPropertyValue = ind.TotalSubP2Amount.ToString();
                break;

            default:
                break;
            }
            return(sPropertyValue);
        }
Пример #8
0
        public virtual void SetTotalSubPrice2StocksProperty(string attName,
                                                            string attValue, int colIndex)
        {
            if (this.SubPrice2Stocks == null)
            {
                this.SubPrice2Stocks = new List <SubPrice2Stock>();
            }
            if (this.SubPrice2Stocks.Count < (colIndex + 1))
            {
                SubPrice2Stock ind1 = new SubPrice2Stock();
                this.SubPrice2Stocks.Insert(colIndex, ind1);
            }
            SubPrice2Stock ind = this.SubPrice2Stocks.ElementAt(colIndex);

            if (ind != null)
            {
                SetTotalSubPrice2StockProperty(ind, attName, attValue);
            }
        }
Пример #9
0
 private void SetTotalSubPrice2StockAttributes(SubPrice2Stock ind,
                                               string attNameExtension, ref XmlWriter writer)
 {
     writer.WriteAttributeString(
         string.Concat(cTotalSubP2Description, attNameExtension), ind.TotalSubP2Description);
     writer.WriteAttributeString(
         string.Concat(cTotalSubP2Name, attNameExtension), ind.TotalSubP2Name.ToString());
     writer.WriteAttributeString(
         string.Concat(cTotalSubP2Label, attNameExtension), ind.TotalSubP2Label.ToString());
     writer.WriteAttributeString(
         string.Concat(cTotalSubP2Total, attNameExtension), ind.TotalSubP2Total.ToString("N2", CultureInfo.InvariantCulture));
     writer.WriteAttributeString(
         string.Concat(cTotalSubP2TotalPerUnit, attNameExtension), ind.TotalSubP2TotalPerUnit.ToString("N2", CultureInfo.InvariantCulture));
     writer.WriteAttributeString(
         string.Concat(cTotalSubP2Price, attNameExtension), ind.TotalSubP2Price.ToString("N2", CultureInfo.InvariantCulture));
     writer.WriteAttributeString(
         string.Concat(cTotalSubP2Unit, attNameExtension), ind.TotalSubP2Unit);
     writer.WriteAttributeString(
         string.Concat(cTotalSubP2Amount, attNameExtension), ind.TotalSubP2Amount.ToString("N3", CultureInfo.InvariantCulture));
 }
Пример #10
0
 public virtual void SetTotalSubPrice2StockAttributes(SubPrice2Stock ind,
                                                      string attNameExtension, ref XElement calculator)
 {
     CalculatorHelpers.SetAttribute(calculator,
                                    string.Concat(cTotalSubP2Description, attNameExtension), ind.TotalSubP2Description);
     CalculatorHelpers.SetAttribute(calculator,
                                    string.Concat(cTotalSubP2Name, attNameExtension), ind.TotalSubP2Name);
     CalculatorHelpers.SetAttribute(calculator,
                                    string.Concat(cTotalSubP2Label, attNameExtension), ind.TotalSubP2Label);
     CalculatorHelpers.SetAttributeDoubleF2(calculator,
                                            string.Concat(cTotalSubP2Total, attNameExtension), ind.TotalSubP2Total);
     CalculatorHelpers.SetAttributeDoubleF2(calculator,
                                            string.Concat(cTotalSubP2TotalPerUnit, attNameExtension), ind.TotalSubP2TotalPerUnit);
     CalculatorHelpers.SetAttributeDoubleF2(calculator,
                                            string.Concat(cTotalSubP2Price, attNameExtension), ind.TotalSubP2Price);
     CalculatorHelpers.SetAttribute(calculator,
                                    string.Concat(cTotalSubP2Unit, attNameExtension), ind.TotalSubP2Unit);
     CalculatorHelpers.SetAttributeDoubleF2(calculator,
                                            string.Concat(cTotalSubP2Amount, attNameExtension), ind.TotalSubP2Amount);
 }
Пример #11
0
 private void SetTotalSubPrice2StockProperties(SubPrice2Stock ind,
                                               string attNameExtension, XElement calculator)
 {
     ind.TotalSubP2Description = CalculatorHelpers.GetAttribute(calculator,
                                                                string.Concat(cTotalSubP2Description, attNameExtension));
     ind.TotalSubP2Name = CalculatorHelpers.GetAttribute(calculator,
                                                         string.Concat(cTotalSubP2Name, attNameExtension));
     ind.TotalSubP2Label = CalculatorHelpers.GetAttribute(calculator,
                                                          string.Concat(cTotalSubP2Label, attNameExtension));
     ind.TotalSubP2Total = CalculatorHelpers.GetAttributeDouble(calculator,
                                                                string.Concat(cTotalSubP2Total, attNameExtension));
     ind.TotalSubP2TotalPerUnit = CalculatorHelpers.GetAttributeDouble(calculator,
                                                                       string.Concat(cTotalSubP2TotalPerUnit, attNameExtension));
     ind.TotalSubP2Price = CalculatorHelpers.GetAttributeDouble(calculator,
                                                                string.Concat(cTotalSubP2Price, attNameExtension));
     ind.TotalSubP2Unit = CalculatorHelpers.GetAttribute(calculator,
                                                         string.Concat(cTotalSubP2Unit, attNameExtension));
     ind.TotalSubP2Amount = CalculatorHelpers.GetAttributeDouble(calculator,
                                                                 string.Concat(cTotalSubP2Amount, attNameExtension));
 }
Пример #12
0
        private void SetTotalSubPrice2StockProperty(SubPrice2Stock ind,
                                                    string attName, string attValue)
        {
            switch (attName)
            {
            case cTotalSubP2Description:
                ind.TotalSubP2Description = attValue;
                break;

            case cTotalSubP2Name:
                ind.TotalSubP2Name = attValue;
                break;

            case cTotalSubP2Label:
                ind.TotalSubP2Label = attValue;
                break;

            case cTotalSubP2Total:
                ind.TotalSubP2Total = CalculatorHelpers.ConvertStringToDouble(attValue);
                break;

            case cTotalSubP2TotalPerUnit:
                ind.TotalSubP2TotalPerUnit = CalculatorHelpers.ConvertStringToDouble(attValue);
                break;

            case cTotalSubP2Price:
                ind.TotalSubP2Price = CalculatorHelpers.ConvertStringToDouble(attValue);
                break;

            case cTotalSubP2Unit:
                ind.TotalSubP2Unit = attValue;
                break;

            case cTotalSubP2Amount:
                ind.TotalSubP2Amount = CalculatorHelpers.ConvertStringToDouble(attValue);
                break;

            default:
                break;
            }
        }
Пример #13
0
 //copy constructor
 public SubPrice2Stock(SubPrice2Stock calculator)
 {
     CopyTotalSubPrice2StocksProperties(calculator);
 }