private static List<MTL_WAREHOUSE_DETAIL> ListSort(List<MTL_WAREHOUSE_DETAIL> infoList, string field, string rule)
{
if (!string.IsNullOrEmpty(rule) && (rule.ToLower().Equals("desc") || rule.ToLower().Equals("asc")))
{
try
{
//List<Info> infoList = GetList();
infoList.Sort(
delegate (MTL_WAREHOUSE_DETAIL info1, MTL_WAREHOUSE_DETAIL info2)
{
Type t = typeof(MTL_WAREHOUSE_DETAIL);
PropertyInfo pro = t.GetProperty(field);
return rule.ToLower().Equals("asc") ?
pro.GetValue(info1, null).ToString().CompareTo(pro.GetValue(info2, null).ToString()) :
pro.GetValue(info2, null).ToString().CompareTo(pro.GetValue(info1, null).ToString());
});
return infoList;
}
catch (Exception ex)
{
return infoList;
}
}
else
{
return infoList;
}
}