コード例 #1
0
        private double getPrice(Elm elm, DPar.DPar csDP, string priceStr)
        {
            double price = Lib.ToDouble(priceStr);

            foreach (var sec in csDP.dpar)
            {
                if (!sec.Key.ToString().Contains("UNIT_"))
                {
                    continue;
                }
                switch (sec.Key)
                {
                case SType.UNIT_Weight:     // kg -> tonn
                    return(elm.weight / 1000 * price);

                case SType.UNIT_Vol:        // mm3 -> m3
                    return(elm.volume / 1000 / 1000 / 1000 * price);

                case SType.UNIT_Length:
                    return(elm.length * price);

                case SType.UNIT_Qty:
                    return(price);
                }
            }
            return(0);
        }
コード例 #2
0
ファイル: Matcher.cs プロジェクト: PavelKhrapkin/TSmatch
 /// <summary>
 /// getPrice(gr, csDP, priceStr) - return price made from priceStr in price-list as set in csDP price type 
 /// </summary>
 /// <param name="group">element group to be priced</param>
 /// <param name="csDP">CompSet Dictionary of Parameters</param>
 /// <param name="priceStr">price string in price-list</param>
 /// <returns>double price value, converted from priceStr, group of elemetsa, and pricing type</returns>
 private double getPrice(Group.Group group, DPar.DPar csDP, string priceStr)
 {
     double price = Lib.ToDouble(priceStr);
     foreach (var sec in csDP.dpar)
     {
         if (!sec.Key.ToString().Contains("UNIT_")) continue;
         switch (sec.Key)
         {
             case SType.UNIT_Weight: // kg -> tonn
                 if (group.totalWeight == 0) return group.totalVolume * 7850;
                 return group.totalWeight / 1000 * price;
             case SType.UNIT_Vol:    // NO mm3 -> m3
                 return group.totalVolume * price;
            //     return group.totalVolume / 1000 / 1000 / 1000 * price;
             case SType.UNIT_Length:
                 return group.totalLength * price;
             case SType.UNIT_Qty:
                 return price;
         }
     }
     return 0;
 }