public static void UpdateDataTable <T>(DataTable dt, List <T> list)
        {
            if (list.Count == 0)
            {
                dt.Rows.Clear();
            }
            else if (dt.Rows.Count > list.Count)
            {
                int num = dt.Rows.Count - list.Count;
                for (int i = 0; i < num; i++)
                {
                    dt.Rows.RemoveAt(list.Count - 1);
                }
            }

            if (list.Count > dt.Rows.Count)
            {
                int num = list.Count - dt.Rows.Count;
                for (int i = 0; i < num; i++)
                {
                    T _obj = (T)System.Activator.CreateInstance(typeof(T));
                    dt.Rows.Add(ConvertDataExtend.ToDataRow(_obj).ItemArray);
                }
            }

            for (int i = 0; i < list.Count; i++)
            {
                UpdateDataTable(dt, i, list[i]);
            }
        }
        public static void ToObject(DataRow dr, object obj)
        {
            //列名
            string columnName;
            //列数量
            int column = dr.Table.Columns.Count;

            //遍历所有列
            for (int i = 0; i < column; i++)
            {
                columnName = dr.Table.Columns[i].ColumnName;
                object objectValue = dr[i];
                objectValue = objectValue == DBNull.Value ? null : objectValue;
                if (obj.GetType().GetProperty(columnName) != null)
                {
                    if (obj.GetType().GetProperty(columnName).PropertyType == typeof(Int32))
                    {
                        objectValue = ConvertDataExtend.ToInt32(objectValue, 0);
                    }
                    if (obj.GetType().GetProperty(columnName).PropertyType == typeof(Decimal))
                    {
                        objectValue = ConvertDataExtend.ToDecimal(objectValue, 0);
                    }
                    if (obj.GetType().GetProperty(columnName).PropertyType == typeof(DateTime))
                    {
                        objectValue = Convert.ToDateTime(objectValue);
                    }
                    obj.GetType().GetProperty(columnName).SetValue(obj, objectValue, null);
                }
            }
        }
        public static void UpdateDataTableForSort <T>(DataTable dt, List <T> list)
        {
            dt.Rows.Clear();
            int num = list.Count;

            for (int i = 0; i < num; i++)
            {
                T _obj = (T)System.Activator.CreateInstance(typeof(T));
                dt.Rows.Add(ConvertDataExtend.ToDataRow(_obj).ItemArray);
            }
            for (int i = 0; i < list.Count; i++)
            {
                UpdateDataTable(dt, i, list[i]);
            }
        }