コード例 #1
0
ファイル: OrderList.cs プロジェクト: gvhung/dp2
        public SumInfo GetSumInfo(List <RateItem> rate_table)
        {
            List <string> totalprices = new List <string>();

            SumInfo info = new SumInfo();

            info.Seller = this.Seller;
            foreach (OrderListItem item in _items)
            {
                info.BiblioCount++;
                info.CopyCount += item.Copy;
                totalprices.Add(item.TotalPrice);
            }

            if (totalprices.Count > 1)
            {
                string        strError   = "";
                List <string> sum_prices = null;
                int           nRet       = PriceUtil.TotalPrice(totalprices,
                                                                out sum_prices,
                                                                out strError);
                if (nRet == -1)
                {
                    info.TotalPrice = strError;
                }
                else
                {
                    // Debug.Assert(sum_prices.Count == 1, "");
                    // info.TotalPrice = sum_prices[0];
                    info.TotalPrice = PriceUtil.JoinPriceString(sum_prices);
                }
            }
            else if (totalprices.Count == 1)
            {
                info.TotalPrice = totalprices[0];
            }

            // 计算汇率
            if (rate_table != null && string.IsNullOrEmpty(info.TotalPrice) == false)
            {
                try
                {
                    string strRatePrice = RateItem.RatePrices(
                        rate_table,
                        info.TotalPrice);
                    info.TotalPrice1 = strRatePrice;
                    if (info.TotalPrice == info.TotalPrice1)
                    {
                        info.TotalPrice1 = "";
                    }
                }
                catch (Exception ex)
                {
                    info.TotalPrice1 = ex.Message;
                }
            }

            return(info);
        }