Example #1
0
 static void SetPropertyValue(PrintOrderForm.LineInfo info,
                              string strKeyName,
                              object value)
 {
     try
     {
         info.GetType().GetProperty(strKeyName).SetValue(info, value);
     }
     catch (Exception ex)
     {
         throw new Exception($"SetProperty() 时发生异常(strKeyName={strKeyName} value={value}): " + ex.Message);
     }
 }
Example #2
0
        static string ConcatLinePrice(
            IGrouping <string, PrintOrderForm.LineInfo> cl,
            string strFieldName)
        {
            // PrintOrderForm.RemoveChangedChar()
            string strList = (string)GetPropertyValue(cl.Aggregate((current, next) =>
            {
                // TODO:单价应该乘以套数。或者还有期数也要乘上
                string s1 = (string)GetPropertyValue(current, strFieldName);
                string s2 = (string)GetPropertyValue(next, strFieldName);
                var r     = new PrintOrderForm.LineInfo();
                SetPropertyValue(r, strFieldName, s1 + "," + s2);
                return(r);
            }), strFieldName);

            return(PriceUtil.TotalPrice(StringUtil.SplitList(strList)));
        }
Example #3
0
        static object GetPropertyValue(PrintOrderForm.LineInfo info,
                                       string strKeyName)
        {
            object result = info.GetType().GetProperty(strKeyName).GetValue(info);

            return(result);

#if NO
            if (strKeyName == "seller")
            {
                return(info.Seller);
            }
            else if (strKeyName == "source")
            {
                return(info.Source);
            }
            throw new ArgumentException($"未知的 strKeyName '{strKeyName}'");
#endif
        }