Example #1
0
        /// <summary>
        /// 根据当日充值B-ROI计算评级
        /// </summary>
        /// <param name="payamountb">充值B</param>
        /// <param name="dtake">当日投入金额</param>
        /// <returns></returns>
        public static string GetSubLevel(decimal payamountb, decimal dtake)
        {
            if (dtake <= 0)
            {
                return("");
            }

            decimal levelValue = (payamountb / dtake) * ConvertKit.ToDecimal(100);

            if (levelValue < 33)
            {
                return("C");
            }
            else if (levelValue <= 65)
            {
                return("B");
            }
            else if (levelValue <= 99)
            {
                return("A");
            }
            else
            {
                return("S");
            }
        }
Example #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="value"></param>
 /// <returns></returns>
 public static String ToBaifen2(object value)
 {
     if (ConvertKit.ToDecimal(value) > 0)
     {
         return((ConvertKit.ToDecimal(value) * 100).ToString("f0") + "%");
     }
     else
     {
         return("-");
     }
 }
Example #3
0
        /// <summary>
        ///  读取From表单中的某一组值
        /// </summary>
        /// <typeparam name="TValue"></typeparam>
        /// <param name="name"></param>
        /// <returns></returns>
        public static List <TValue> GetFormValues <TValue>(string name)
        {
            List <TValue> list = new List <TValue>();

            string[] values = HttpContext.Current.Request.Form.GetValues(name);
            if (values != null)
            {
                foreach (string value in values)
                {
                    list.Add(ConvertKit.Convert(value, default(TValue)));
                }
            }
            return(list);
        }
        public static IDictionary <TKey, string> ToDescriptionDictionary <TKey>(Type enumType)
        {
            string cacheKey = "CACHE_ENUM_KEYVALUE_" + enumType.FullName.ToUpper() + "_" + typeof(TKey).ToString().ToUpper();

            var dictionary = HttpContext.Current.Cache[cacheKey] as Dictionary <TKey, string>;

            if (dictionary == null)
            {
                dictionary = new Dictionary <TKey, string>();
                object      enumInstance = enumType.Assembly.CreateInstance(enumType.FullName);
                FieldInfo[] fieldInfos   = enumType.GetFields();

                foreach (FieldInfo fieldInfo in fieldInfos)
                {
                    var descriptionAttributes = (DescriptionAttribute[])fieldInfo.GetCustomAttributes(typeof(DescriptionAttribute), true);

                    if (descriptionAttributes.Length > 0)
                    {
                        TKey   key   = ConvertKit.Convert(fieldInfo.GetValue(enumInstance), default(TKey));
                        string value = descriptionAttributes[0].Description;

                        if (!dictionary.ContainsKey(key))
                        {
                            dictionary.Add(key, value);
                        }
                    }
                }
                HttpContext.Current.Cache.Insert(cacheKey, dictionary);
            }
            var result = new OptimizedDictionary <TKey, string>();

            foreach (var kvp in dictionary)
            {
                result.Add(kvp.Key, kvp.Value);
            }
            return(result);
        }
Example #5
0
 /// <summary>
 /// ROI=充值/投入
 /// </summary>
 /// <param name="payamount">充值</param>
 /// <param name="dtake">投入</param>
 /// <returns></returns>
 public static string GetRoI(decimal payamount, decimal dtake)
 {
     return(dtake <= 0 ? "" : ConvertKit.ToBaifen2x(payamount / dtake).ToString());
 }
Example #6
0
 public static string TodecimalInt(object value)
 {
     return(ConvertKit.ToDecimal(value).ToString("f0"));
 }
Example #7
0
 public static String ToBaifen(object value, object value2)
 {
     return(((ConvertKit.ToDecimal(value) / ConvertKit.ToDecimal(value2)) * 100).ToString("f2") + "%");
 }