/// <summary>
/// 查询料品列表
/// </summary>
/// <param name="paramList"></param>
/// <returns></returns>
public static string GetItemMasterList(List<ParamDTOData> paramList)
{
RootD result = new RootD();
var jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
try
{
int RecordCount = 0;
if (paramList.Count > 0)
{
ItemMaster.EntityList item = ItemMaster.Finder.FindAll($"Org.id ={Context.LoginOrg.ID} and {paramList[0].DocNo} order by ID");
if (item != null && item.Count > 0)
{
RecordCount = item.Count;
int pagecount = ToInt(paramList[0].Prv1, 1);
int pagesize = ToInt(paramList[0].Prv2, 1000);
List<ItemMaster> listImMasters = item.Cast<ItemMaster>().Skip((pagecount - 1) * pagesize).Take(pagesize).ToList();
DataSet ds = new DataSet();
DataTable newTable = new DataTable();
newTable.Columns.Add("料号", typeof(string));
newTable.Columns.Add("品名", typeof(string));
newTable.Columns.Add("规格", typeof(string));
foreach (ItemMaster lm in listImMasters)
{
DataRow dr = newTable.NewRow();
dr["料号"] = lm.Code;//Code 料号
dr["品名"] = lm.Name;//Name 品名
dr["规格"] = lm.SPECS;//SPECS 规格
newTable.Rows.Add(dr);
}
ds.Tables.Add(newTable);
string json = JsonConvert.SerializeObject(ds, Formatting.None, jsonSetting);
result.state = "success";
result.msg = RecordCount + "";
result.data = json;
return JsonConvert.SerializeObject(result, Formatting.None, jsonSetting);
}
else
{
result.state = "fail";
result.msg = "没有查到数据";
result.data = "";
return JsonConvert.SerializeObject(result, Formatting.None, jsonSetting);
}
}
else
{
result.state = "fail";
result.msg = "查询条件不对";
result.data = "";
return JsonConvert.SerializeObject(result, Formatting.None, jsonSetting);
}
return JsonConvert.SerializeObject(result, Formatting.None, jsonSetting);
}
catch (Exception ex)
{
result.state = "fail";
result.msg = ex.Message;
result.data = "";
return JsonConvert.SerializeObject(result, Formatting.None, jsonSetting);
}
}