Beispiel #1
0
        /// <summary>
        /// 将DataTable转换为Hashtable列表
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        public static List <Hashtable> DataTableToHash(DataTable table)
        {
            var list = new List <Hashtable>();
            DataRowCollection    rows    = table.Rows;
            DataColumnCollection columns = table.Columns;
            int conCount = table.Columns.Count;

            for (var j = 0; j < rows.Count; j++)
            {
                var item = new Hashtable();
                for (var i = 0; i < conCount; i++)
                {
                    var name  = columns[i].ColumnName;
                    var value = ValidatorHelper.ToStr(rows[j][i], "");
                    item[name] = value;
                }
                list.Add(item);
            }
            return(list);
        }
Beispiel #2
0
 /// <summary>
 /// 检查一个字符串是否是纯字母和数字构成的,一般用于查询字符串参数的有效性验证。
 /// </summary>
 /// <param name="_value">需验证的字符串。</param>
 /// <returns>是否合法的bool值。</returns>
 public static bool IsLetterOrNumber(string _value)
 {
     return(ValidatorHelper.QuickValidate("^[a-zA-Z0-9_]*$", _value));
 }
Beispiel #3
0
 /// <summary>
 /// 判断是否是数字,包括小数和整数。
 /// </summary>
 /// <param name="_value">需验证的字符串。</param>
 /// <returns>是否合法的bool值。</returns>
 public static bool IsNumber(string _value)
 {
     return(ValidatorHelper.QuickValidate("^(0|([1-9]+[0-9]*))(.[0-9]+)?$", _value));
 }
Beispiel #4
0
 /// <summary>
 /// 检查一个字符串是否是纯数字构成的,一般用于查询字符串参数的有效性验证。
 /// </summary>
 /// <param name="_value">需验证的字符串。</param>
 /// <returns>是否合法的bool值。</returns>
 public static bool IsNumeric(string _value)
 {
     return(ValidatorHelper.QuickValidate("^[1-9]*[0-9]*$", _value));
 }