纽威
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 lines
4.0 KiB

5 months ago
  1. using Newtonsoft.Json;
  2. using Newtonsoft.Json.Linq;
  3. using NFine.Code;
  4. using NFine.Data.Extensions;
  5. using NFine.Domain._03_Entity.SRM;
  6. using NFine.Repository;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Data;
  10. using System.Data.Common;
  11. namespace NFine.Application.WMS
  12. {
  13. public class ExpressageApp : RepositoryFactory<ICSVendor>
  14. {
  15. /// <summary>
  16. /// 扫描快递
  17. /// </summary>
  18. /// <param name="queryJson"></param>
  19. /// <returns></returns>
  20. public string InsertExpressage(string Code, string Expressage,string ExpressageCode)
  21. {
  22. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  23. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  24. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  25. string msg = "";
  26. string StackSql = @"select * from ICSExpressage where Code='{0}' and WorkPoint='{1}'";
  27. StackSql = string.Format(StackSql, Code, WorkPoint);
  28. DataTable dt = SqlHelper.GetDataTableBySql(StackSql);
  29. if (dt != null && dt.Rows.Count > 0)
  30. {
  31. msg = "快递单号已经录入";
  32. //throw new Exception("快递单号已经录入");
  33. return msg;
  34. }
  35. string sql = string.Empty;
  36. sql = @"INSERT INTO dbo.ICSExpressage
  37. ( ID ,Code ,Expressage ,ExpressageCode,ISNew ,MUSER , MUSERName ,MTIME ,WorkPoint )
  38. Values(NEWID(),'{0}','{1}','{2}','0','{3}','{4}',GETDATE(),'{5}')";
  39. sql = string.Format(sql, Code, Expressage, ExpressageCode, MUSER, MUSERNAME, WorkPoint);
  40. try
  41. {
  42. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  43. {
  44. }
  45. else
  46. {
  47. msg = "保存失败";
  48. }
  49. }
  50. catch (Exception ex)
  51. {
  52. throw new Exception(ex.Message);
  53. }
  54. return msg;
  55. }
  56. /// <summary>
  57. /// 获取快递公司列表
  58. /// </summary>
  59. /// <returns></returns>
  60. public DataTable GetExpressageList()
  61. {
  62. string sql = @"select b.F_ItemCode as Code ,b.F_ItemName as Name from Sys_SRM_Items a left join Sys_SRM_ItemsDetail b on a.F_Id=b.F_ItemId
  63. where a.F_EnCode='Expressage' order by cast(b.F_SortCode as int) asc";
  64. DataTable ListData = SqlHelper.GetDataTableBySql(sql);
  65. return ListData;
  66. }
  67. /// <summary>
  68. /// 查询快递录入信息
  69. /// </summary>
  70. /// <param name="jqgridparam"></param>
  71. /// <returns></returns>
  72. public DataTable GetExpressage(ref Pagination jqgridparam, string queryJson)
  73. {
  74. DataTable dt = new DataTable();
  75. var queryParam = queryJson.ToJObject();
  76. List<DbParameter> parameter = new List<DbParameter>();
  77. string sql = @" select ID, Code, Expressage, ExpressageCode,
  78. case when ISNew='0' then '否' else '是' end ISNew,
  79. UnpackMUSER, UnpackMUSERName, UnpackMTIME, MUSER, MUSERName, MTIME
  80. FROM ICSExpressage
  81. where ISDelete is null {0}
  82. ";
  83. string wheresql = "";
  84. if (!string.IsNullOrWhiteSpace(queryJson))
  85. {
  86. if (!string.IsNullOrWhiteSpace(queryParam["ExpressageCode"].ToString()))
  87. {
  88. wheresql += " and ExpressageCode like '%" + queryParam["ExpressageCode"].ToString() + "%' ";
  89. }
  90. if (!string.IsNullOrWhiteSpace(queryParam["Code"].ToString()))
  91. {
  92. wheresql += " and Code like '%" + queryParam["Code"].ToString() + "%' ";
  93. }
  94. }
  95. sql = string.Format(sql, wheresql);
  96. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  97. }
  98. }
  99. }