// 计算价格乘积 // 从PrintOrderForm中转移过来 public static int MultiPrice(string strPrice, int nCopy, out string strResult, out string strError) { strError = ""; strResult = ""; string strPrefix = ""; string strValue = ""; string strPostfix = ""; int nRet = PriceUtil.ParsePriceUnit(strPrice, out strPrefix, out strValue, out strPostfix, out strError); if (nRet == -1) { return(-1); } decimal value = 0; try { value = Convert.ToDecimal(strValue); } catch { strError = "数字 '" + strValue + "' 格式不正确"; return(-1); } value *= (decimal)nCopy; strResult = strPrefix + value.ToString() + strPostfix; return(0); }
public static CurrencyItem Parse(string strText) { string strError = ""; string strPrefix = ""; string strValue = ""; string strPostfix = ""; int nRet = PriceUtil.ParsePriceUnit(strText, out strPrefix, out strValue, out strPostfix, out strError); if (nRet == -1) { throw new Exception(strError); } decimal value = 0; try { value = Convert.ToDecimal(strValue); } catch { strError = "数字 '" + strValue + "' 格式不正确"; throw new Exception(strError); } CurrencyItem item = new CurrencyItem(); item.Prefix = strPrefix; item.Postfix = strPostfix; item.Value = value; return(item); }
public static string Add(string strText1, string strText2) { PriceUtil currency = new PriceUtil(strText1); return(currency.Add(strText2).ToString()); }