Exemple #1
0
        /// <summary>
        /// 获取1,2,4 将其转 list
        /// </summary>
        /// <param name="strName"></param>
        /// <param name="splitChar">分割标识符</param>
        /// <param name="filtSame">是否过滤重复</param>
        /// <returns></returns>
        public static List <int> GetFormInts(string strName, string splitChar, bool filtSame)
        {
            List <int> list = new List <int>();

            if (HttpContext.Current.Request.Form[strName] == null)
            {
                return(list);
            }
            var arr  = StringTool.SplitString(GetFormString(strName), splitChar);
            int temp = 0;

            foreach (var i in arr)
            {
                temp = TypeParseHelper.StrToInt(i, int.MinValue);
                if (temp != int.MinValue)
                {
                    if (filtSame && list.Contains(temp))
                    {
                        continue;
                    }
                    list.Add(temp);
                }
            }
            return(list);
        }
Exemple #2
0
        /// <summary>
        /// 分割字符串
        /// </summary>
        public static List <int> SplitStringListInt(string strContent, string strSplit)
        {
            List <int> lists = new List <int>();

            int temp = int.MinValue;

            if (strContent.IndexOf(strSplit) < 0)
            {
                temp = TypeParseHelper.StrToInt(strContent, temp);
                if (int.MinValue != temp)
                {
                    lists.Add(temp);
                }
                return(lists);
            }
            foreach (string list in Regex.Split(strContent, @strSplit.Replace(".", @"\."), RegexOptions.IgnoreCase))
            {
                temp = TypeParseHelper.StrToInt(list, temp);
                if (int.MinValue != temp)
                {
                    lists.Add(temp);
                }
            }
            return(lists);
        }
Exemple #3
0
 public static long GetCookieLong(string str, long def)
 {
     if (HttpContext.Current.Request.Cookies[str] != null)
     {
         return(TypeParseHelper.StrToLong(HttpContext.Current.Request.Cookies[str].Value, def));
     }
     return(def);
 }
Exemple #4
0
 /// <summary>
 /// 获取日期
 /// </summary>
 /// <param name="strName"></param>
 /// <returns></returns>
 public static DateTime GetFormDataTime(string strName, DateTime defValue)
 {
     return(TypeParseHelper.StrToDateTime(HttpContext.Current.Request.Form[strName], defValue));
 }
Exemple #5
0
 public static float GetFormFloat(string strName, float defValue)
 {
     return(TypeParseHelper.StrToFloat(HttpContext.Current.Request.Form[strName], defValue));
 }
Exemple #6
0
 public static decimal GetFormDecimal(string strName, decimal defValue)
 {
     return(TypeParseHelper.StrToDecimal(HttpContext.Current.Request.Form[strName], defValue));
 }
Exemple #7
0
 public static long GetFormLong(string strName, long defValue)
 {
     return(TypeParseHelper.StrToLong(HttpContext.Current.Request.Form[strName], defValue));
 }
Exemple #8
0
 /// <summary>
 /// 获得指定表单参数的int类型值
 /// </summary>
 /// <param name="strName">表单参数</param>
 /// <param name="defValue">缺省值</param>
 /// <returns>表单参数的int类型值</returns>
 public static int GetFormInt(string strName, int defValue)
 {
     return(TypeParseHelper.StrToInt(HttpContext.Current.Request.Form[strName], defValue));
 }