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.

151 lines
5.5 KiB

  1. using NFine.Data.Extensions;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using NFine.Code;
  9. using NFine.Repository;
  10. using System.Data.Common;
  11. using NFine.Domain._03_Entity.SRM;
  12. using ICS.Application.Entity;
  13. using Newtonsoft.Json;
  14. using System.Configuration;
  15. using System.Data.SqlClient;
  16. using ICS.Data;
  17. using Newtonsoft.Json.Linq;
  18. namespace NFine.Application.WMS
  19. {
  20. public class PrintApp : RepositoryFactory<ICSVendor>
  21. {
  22. public DataTable GetLableType()
  23. {
  24. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  25. string sql = @"
  26. select '' as F_ItemCode,'' as F_ItemName
  27. union all
  28. SELECT DISTINCT a.F_ItemCode,isnull(a.F_ItemName,'') as F_ItemName FROM dbo.Sys_SRM_ItemsDetail a left join Sys_SRM_Items b on a.F_ItemId=b.F_Id where b.F_EnCode='BQ001'";
  29. string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
  30. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  31. return dt;
  32. }
  33. public DataTable GetLableSourceID()
  34. {
  35. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  36. string sql = @"
  37. select '' as ID,'' as SourceName
  38. union all
  39. select distinct ID,SourceName from Sys_LableDataSource";
  40. string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
  41. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  42. return dt;
  43. }
  44. public DataTable GetSys_LablesID(string LableType)
  45. {
  46. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  47. string sql = @"
  48. select '' as ID,'' as LableName
  49. union all
  50. select distinct ID,LableName from Sys_Lables where LableType='{0}'";
  51. sql = string.Format(sql, LableType);
  52. string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
  53. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  54. return dt;
  55. }
  56. public DataTable SelectColumnName(string BeginTime, string EndTime)
  57. {
  58. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  59. string sql = @"select ColCode, ColName from ICSExtensionEnable
  60. where Enable=1 and workPoint='{0}'
  61. order by cast(EATTRIBUTE1 as int)";
  62. sql = string.Format(sql, WorkPoint);
  63. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  64. return dt;
  65. }
  66. public DataTable SelectTableColumnName(string BeginTime, string EndTime)
  67. {
  68. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  69. string sql = @"select TableCode, ColumnCode AS Code,Name from ICSColumnEnable
  70. where Enable=1 and workPoint='{0}' order by MTIME";
  71. sql = string.Format(sql, WorkPoint);
  72. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  73. return dt;
  74. }
  75. public string GetCnValue(string Code)
  76. {
  77. try
  78. {
  79. object MultipleLanguageSetting = GetMultipleLanguageSetting();
  80. string content = "";
  81. string sql = string.Format(@"select {1} from Sys_Language where Code='{0}'", Code, MultipleLanguageSetting);
  82. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  83. if (dt != null && dt.Rows.Count > 0)
  84. {
  85. content = dt.Rows[0]["" + MultipleLanguageSetting + ""].ToString().ToUpper();
  86. }
  87. else
  88. {
  89. content = "";
  90. }
  91. return content;
  92. }
  93. catch (Exception ex)
  94. {
  95. throw new Exception(ex.Message.ToString());
  96. }
  97. }
  98. public object GetMultipleLanguageSetting()
  99. {
  100. try
  101. {
  102. string sql = string.Format(@"select top 1 b.F_Define1
  103. from Sys_SRM_Items a left join Sys_SRM_ItemsDetail b on a.F_Id=b.F_ItemId
  104. where a.F_EnCode='LGG0001' and b.F_EnabledMark='1' order by b.F_ItemCode");
  105. object MultipleLanguageSetting = SqlHelper.ExecuteScalar(sql);
  106. return MultipleLanguageSetting;
  107. }
  108. catch (Exception ex)
  109. {
  110. throw new Exception(ex.Message.ToString());
  111. }
  112. }
  113. public string updatePrintStatus(string LotNo)
  114. {
  115. try
  116. {
  117. string User = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  118. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  119. string msg = "";
  120. string sql = @"UPDATE ICSInventoryLot SET PrintTimes=(
  121. CASE WHEN PrintTimes IS NULL THEN 1
  122. ELSE PrintTimes+1
  123. END),LastPrintUser='{0}',LastPrintTime=GETDATE() WHERE LotNo='{1}' AND WorkPoint='{2}'";
  124. sql = string.Format(sql, User, LotNo, WorkPoint);
  125. if (!(SqlHelper.ExecuteNonQuery(sql) > 0))
  126. {
  127. msg = "条码 " + LotNo + " 更新打印人、打印时间与打印次数失败!";
  128. }
  129. return msg;
  130. }
  131. catch (Exception ex)
  132. {
  133. return "更新打印人出错:" + ex.Message;
  134. }
  135. }
  136. }
  137. }