WMSupplierTypeService.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using LeaRun.Data;
  2. using LeaRun.Util.WebControl;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace LeaRun.Application.Service.WarehouseManage
  10. {
  11. public class WMSupplierTypeService
  12. {
  13. SqlHelper sqlHelper = new SqlHelper("InstallDB");
  14. //获取计量单位
  15. public String getSupplierTypeList(Pagination pagination)
  16. {
  17. String sql = "SELECT SupplierTypeId,SupplierCode,SupplierTypeName,CreateDt FROM WM_CalculateUnit";
  18. DataTable dt;
  19. StringBuilder sb = new StringBuilder();
  20. String json = "";
  21. Char c = ',';
  22. int total = pagination.records;
  23. dt = sqlHelper.ExecuteDataTable(sql, "", false, pagination.rows, pagination.page, out total, null);
  24. pagination.records = total;
  25. if (dt.Rows.Count > 0)
  26. {
  27. for (int i = 0; i < dt.Rows.Count; i++)
  28. {
  29. DataRow r = dt.Rows[i];
  30. #region 拼接sql
  31. sb.Append("{");
  32. sb.Append("\"SupplierTypeId\":\"").Append(r["SupplierTypeId"].ToString()).Append("\",");
  33. sb.Append("\"SupplierCode\":\"").Append(r["SupplierCode"].ToString()).Append("\",");
  34. sb.Append("\"SupplierTypeName\":\"").Append(r["SupplierTypeName"] != System.DBNull.Value ? r["CalculateUnit"].ToString() : "").Append("\",");
  35. sb.Append("\"CreateDt\":\"").Append(r["CreateDt"] != System.DBNull.Value ? Convert.ToDateTime(r["CreateDt"]).ToString("yyyy-MM-dd HH:mm:ss") : "").Append("\"");
  36. sb.Append("},");
  37. #endregion
  38. json = "[" + sb.ToString().TrimEnd(c) + "]";
  39. }
  40. }
  41. return json;
  42. }
  43. }
  44. }