WMCalculateUnitService.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 WMCalculateUnitService
  12. {
  13. SqlHelper sqlHelper = new SqlHelper("InstallDB");
  14. public String getInstallUnitList(Pagination pagination)
  15. {
  16. String sql = "SELECT [UnitId],[Code],[CalculateUnit],[CreateDt] FROM WM_CalculateUnit";
  17. DataTable dt;
  18. StringBuilder sb = new StringBuilder();
  19. String json = "";
  20. Char c = ',';
  21. int total = pagination.records;
  22. dt = sqlHelper.ExecuteDataTable(sql, "", false, pagination.rows, pagination.page, out total, null);
  23. pagination.records = total;
  24. if (dt.Rows.Count > 0)
  25. {
  26. for (int i = 0; i < dt.Rows.Count; i++)
  27. {
  28. DataRow r = dt.Rows[i];
  29. #region 拼接sql
  30. sb.Append("{");
  31. sb.Append("\"UnitId\":\"").Append(r["UnitId"].ToString()).Append("\",");
  32. sb.Append("\"Code\":\"").Append(r["Code"].ToString()).Append("\",");
  33. sb.Append("\"CalculateUnit\":\"").Append(r["CalculateUnit"] != System.DBNull.Value ? r["CalculateUnit"].ToString() : "").Append("\",");
  34. sb.Append("\"CreateDt\":\"").Append(r["CreateDt"] != System.DBNull.Value ? Convert.ToDateTime(r["CreateDt"]).ToString("yyyy-MM-dd HH:mm:ss") : "").Append("\"");
  35. sb.Append("},");
  36. #endregion
  37. json = "[" + sb.ToString().TrimEnd(c) + "]";
  38. }
  39. }
  40. return json;
  41. }
  42. public void SaveCulcalateUnit(String Code, String CalculateUnit)
  43. {
  44. String sql = "Insert into WM_CalculateUnit([Code],[CalculateUnit],[CreateDt]) Values ('" + Code.Trim() + "','" + CalculateUnit + "',GETDATE())";
  45. try
  46. {
  47. sqlHelper.ExecuteNoParams(sql, CommandType.Text);
  48. //sql = "update INS_Budget SET PaymentName = '" + op + "' ,PaymentTime = GETDATE() where Apply_ID =" + applyId;
  49. //sqlHelper.ExecuteNoParams(sql, CommandType.Text);
  50. }
  51. catch (Exception ex)
  52. {
  53. throw;
  54. }
  55. }
  56. }
  57. }