纽威
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.

2525 lines
157 KiB

3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
  1. using NFine.Data.Extensions;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using NFine.Code;
  6. using NFine.Repository;
  7. using System.Data.Common;
  8. using NFine.Domain._03_Entity.SRM;
  9. namespace NFine.Application.WMS
  10. {
  11. public class WMSCreateItemLotApp : RepositoryFactory<ICSVendor>
  12. {
  13. public DataTable GetGridJson(string queryJson, ref Pagination jqgridparam)
  14. {
  15. DataTable dt = new DataTable();
  16. var queryParam = queryJson.ToJObject();
  17. List<DbParameter> parameter = new List<DbParameter>();
  18. object Figure = GetDecimalDigits();
  19. #region [SQL]
  20. string sql = @"select a.ID,a.ApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit, CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity
  21. ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount , CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as IssueNegQuantity ,a.ExtensionID,a.MUSERName,a.MTIME , CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  22. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  23. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  24. from ICSMOApplyNegDetail a
  25. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  26. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  27. left join (
  28. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  29. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
  30. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  31. )c
  32. on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  33. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  34. where d.Type='1'";
  35. sql = string.Format(sql, Figure);
  36. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  37. #endregion
  38. if (!string.IsNullOrWhiteSpace(queryJson))
  39. {
  40. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  41. {
  42. sql += " and a.ApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  43. }
  44. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  45. {
  46. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  47. }
  48. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  49. {
  50. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  51. }
  52. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  53. {
  54. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  55. }
  56. }
  57. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  58. {
  59. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  60. }
  61. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  62. {
  63. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  64. }
  65. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  66. }
  67. public DataTable GetSubGridJson(string ApplyNegCode, string Sequence, string Type, ref Pagination jqgridparam)
  68. {
  69. DataTable dt = new DataTable();
  70. object Figure = GetDecimalDigits();
  71. List<DbParameter> parameter = new List<DbParameter>();
  72. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  73. string sql = @" select c.TransCode,c.TransSequence ,a.ID,a.LotNo, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity ,a.MUSERName,a.MTIME
  74. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  75. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  76. from ICSInventoryLot a
  77. left join (select count(LotNo) LotNoCount,LotNo,WorkPoint from ICSWareHouseLotInfo
  78. group by LotNo,WorkPoint)b on a.LotNo=b.LotNo and a.WorkPoint=b.WorkPoint
  79. left join ICSInventoryLotDetail c on a.LotNo=c.LotNo and a.WorkPoint=c.WorkPoint
  80. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  81. WHERE a.Type='" + Type + "' and c.TransCode='" + ApplyNegCode + "' and c.TransSequence='" + Sequence + "' and a.WorkPoint in ('" + WorkPoint + "')";
  82. sql = string.Format(sql, Figure);
  83. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  84. }
  85. /// <summary>
  86. /// 点击生成条码
  87. /// </summary>
  88. public DataTable GetSubGridJsonByCreate(string ApplyNegCode, string Sequence, string WorkPoint)
  89. {
  90. DataTable dt = new DataTable();
  91. object Figure = GetDecimalDigits();
  92. List<DbParameter> parameter = new List<DbParameter>();
  93. string sql = @" select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity, CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty ,
  94. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  95. from ICSMOApplyNegDetail a
  96. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  97. left join (
  98. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  99. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  100. group by b.TransCode,b.TransSequence
  101. ) c on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  102. WHERE 1 =1
  103. and a.ApplyNegCode='" + ApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  104. sql += " and a.WorkPoint='" + WorkPoint + "'";
  105. sql = string.Format(sql, Figure);
  106. return Repository().FindTableBySql(sql.ToString());
  107. }
  108. public DataTable GetVendorLotNo(string VenCode, string WorkPoint)
  109. {
  110. DataTable dt = new DataTable();
  111. //var queryParam = queryJson.ToJObject();
  112. List<DbParameter> parameter = new List<DbParameter>();
  113. string dtPre = DateTime.Now.ToString("yyyyMMdd");
  114. string sql = @"EXEC Addins_GetSerialCode '" + WorkPoint + "','ICSITEMLotNo','VendorLotNo','" + VenCode + dtPre + "',2";
  115. return Repository().FindTableBySql(sql.ToString());
  116. }
  117. /// <summary>
  118. /// 生产退料生成条码
  119. /// </summary>
  120. /// <param name="POCode"></param>
  121. /// <param name="PORow"></param>
  122. /// <param name="keyValue"></param>
  123. /// 已改
  124. /// <returns></returns>
  125. public int CreateItemLotNo(string ApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  126. {
  127. var queryParam = keyValue.ToJObject();
  128. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  129. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  130. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  131. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  132. decimal LOTQTY = minPackQty;
  133. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  134. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  135. string Pre = "MDN" + ApplyNegCode + Sequence;
  136. string sql = string.Empty;
  137. //string VendorLot = queryParam["VendorLot"].ToString();
  138. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  139. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  140. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  141. string Colspan = "";
  142. string sqls = string.Empty;
  143. for (int i = 0; i < createPageCount; i++)
  144. {
  145. if (i + 1 == createPageCount)
  146. {
  147. if (minPackQty * createPageCount > thisCreateQty)
  148. {
  149. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  150. }
  151. }
  152. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  153. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  154. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  155. if (ExtensionID == null)
  156. {
  157. ExtensionID = Guid.NewGuid();
  158. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  159. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  160. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  161. MUSER, MUSERNAME, WorkPoints);
  162. }
  163. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  164. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  165. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  166. LotNo, ApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  167. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  168. //{
  169. sql += string.Format(@"insert into ICSInventoryLot
  170. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  171. select
  172. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','1','{3}','{4}', getdate(),'{5}','{9}'
  173. from ICSMOApplyNegDetail where ApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  174. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ApplyNegCode, Sequence, ExtensionID, queryParam["Amount"].ToString(), queryParam["ExpirationDate"].ToString());
  175. sql += "\r\n";
  176. //}
  177. }
  178. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  179. return count;
  180. }
  181. public string GetSerialCode(string workPointCode, string tbName, string colName, string Pre, int numLen)
  182. {
  183. string sql = "EXEC Addins_GetSerialCode '{0}','{1}','{2}','{3}',{4}";
  184. sql = string.Format(sql, new object[] { workPointCode, tbName, colName, Pre, numLen });
  185. return DbHelper.ExecuteScalar(CommandType.Text, sql).ToString();
  186. }
  187. /// <summary>
  188. /// 删除条码
  189. /// </summary>
  190. /// <param name="keyValue"></param>
  191. /// <returns></returns>
  192. public string DeleteItemLot(string keyValue)
  193. {
  194. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  195. string msg = string.Empty;
  196. string sql = string.Format(@"SELECT * FROM dbo.ICSInspection
  197. WHERE LotNo IN (SELECT LotNO FROM dbo.ICSInventoryLot WHERE ID IN ({0})) and WorkPoint in ('{1}')", keyValue.TrimEnd(','), WorkPoint);
  198. DataTable dtASN = SqlHelper.GetDataTableBySql(sql);
  199. if (dtASN != null && dtASN.Rows.Count > 0)
  200. {
  201. msg = "所选条码已生成检验单,无法删除!";
  202. }
  203. sql = string.Format(@"SELECT * FROM dbo.ICSWareHouseLotInfo WHERE LotNO IN
  204. (SELECT LotNO FROM dbo.ICSInventoryLot WHERE ID IN ({0})) and WorkPoint in ('{1}')", keyValue.TrimEnd(','), WorkPoint);
  205. DataTable dtCarton = SqlHelper.GetDataTableBySql(sql);
  206. if (dtCarton != null && dtCarton.Rows.Count > 0)
  207. {
  208. msg += "所选条码已入库,无法删除!";
  209. }
  210. if (string.IsNullOrEmpty(msg))
  211. {
  212. string sqls = string.Format("DELETE FROM ICSInventoryLotDetail WHERE LotNO IN (select LotNO from ICSInventoryLot where ID in ({0}) ) and WorkPoint in ('{1}')", keyValue.TrimEnd(','), WorkPoint);
  213. sqls += string.Format("DELETE FROM dbo.ICSInventoryLot WHERE ID IN ({0}) and WorkPoint in ('{1}')", keyValue.TrimEnd(','), WorkPoint);
  214. SqlHelper.CmdExecuteNonQueryLi(sqls);
  215. }
  216. return msg;
  217. }
  218. public DataTable GetGridJsonWeiWai(string queryJson, ref Pagination jqgridparam)
  219. {
  220. DataTable dt = new DataTable();
  221. var queryParam = queryJson.ToJObject();
  222. List<DbParameter> parameter = new List<DbParameter>();
  223. object Figure = GetDecimalDigits();
  224. #region [SQL]
  225. string sql = @"select a.ID,a.OApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit, CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity
  226. ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount , CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as IssueNegQuantity,a.ExtensionID,a.MUSERName,a.MTIME ,
  227. CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  228. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  229. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  230. from ICSOApplyNegDetail a
  231. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  232. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  233. left join (
  234. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  235. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
  236. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  237. )c
  238. on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  239. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  240. WHERE d.Type='1' ";
  241. sql = string.Format(sql, Figure);
  242. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  243. #endregion
  244. if (!string.IsNullOrWhiteSpace(queryJson))
  245. {
  246. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  247. {
  248. sql += " and a.OApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  249. }
  250. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  251. {
  252. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  253. }
  254. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  255. {
  256. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  257. }
  258. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  259. {
  260. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  261. }
  262. }
  263. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  264. {
  265. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  266. }
  267. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  268. {
  269. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  270. }
  271. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  272. }
  273. public DataTable GetSubGridJsonWeiWai(string OApplyNegCode, string Sequence, ref Pagination jqgridparam)
  274. {
  275. DataTable dt = new DataTable();
  276. object Figure = GetDecimalDigits();
  277. //var queryParam = queryJson.ToJObject();
  278. List<DbParameter> parameter = new List<DbParameter>();
  279. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  280. string sql = @" select c.TransCode,c.TransSequence ,a.ID,a.LotNo,CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity from ICSInventoryLot a
  281. left join (select count(LotNo) LotNoCount,LotNo,WorkPoint from ICSWareHouseLotInfo
  282. group by LotNo,WorkPoint)b on a.LotNo=b.LotNo and a.WorkPoint=b.WorkPoint
  283. left join ICSInventoryLotDetail c on a.LotNo=c.LotNo
  284. WHERE c.TransCode='" + OApplyNegCode + "' and c.TransSequence='" + Sequence + "' and a.WorkPoint in (" + WorkPoint + ")";
  285. sql = string.Format(sql, Figure);
  286. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  287. }
  288. /// <summary>
  289. /// 点击委外退料生成条码
  290. /// </summary>
  291. public DataTable GetSubGridJsonWeiWaiByCreate(string OApplyNegCode, string Sequence, string WorkPoint)
  292. {
  293. DataTable dt = new DataTable();
  294. object Figure = GetDecimalDigits();
  295. List<DbParameter> parameter = new List<DbParameter>();
  296. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount,CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  297. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  298. from ICSOApplyNegDetail a
  299. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  300. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  301. left join (
  302. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  303. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  304. group by b.TransCode,b.TransSequence
  305. ) c on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  306. WHERE d.Type='1'
  307. and a.OApplyNegCode='" + OApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  308. sql += " and a.WorkPoint='" + WorkPoint + "'";
  309. sql = string.Format(sql, Figure);
  310. return Repository().FindTableBySql(sql.ToString());
  311. }
  312. /// <summary>
  313. /// 委外退料生成条码
  314. /// </summary>
  315. /// <param name="POCode"></param>
  316. /// <param name="PORow"></param>
  317. /// <param name="keyValue"></param>
  318. /// 已改
  319. /// <returns></returns>
  320. public int SubmitFormWeiWai(string OApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  321. {
  322. var queryParam = keyValue.ToJObject();
  323. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  324. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  325. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  326. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  327. decimal LOTQTY = minPackQty;
  328. string Pre = "OI" + OApplyNegCode + Sequence;
  329. string sql = string.Empty;
  330. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  331. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  332. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  333. string sqls = string.Empty;
  334. string Colspan = "";
  335. for (int i = 0; i < createPageCount; i++)
  336. {
  337. if (i + 1 == createPageCount)
  338. {
  339. if (minPackQty * createPageCount > thisCreateQty)
  340. {
  341. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  342. }
  343. }
  344. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  345. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  346. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  347. if (ExtensionID == null)
  348. {
  349. ExtensionID = Guid.NewGuid();
  350. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  351. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  352. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  353. MUSER, MUSERNAME, WorkPoints);
  354. }
  355. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  356. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  357. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  358. LotNo, OApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  359. sql += string.Format(@"insert into ICSInventoryLot
  360. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  361. select
  362. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','2','{3}','{4}', getdate(),'{5}','{9}'
  363. from ICSOApplyNegDetail where OApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  364. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, OApplyNegCode, Sequence, ExtensionID, queryParam["Amount"].ToString(), queryParam["ExpirationDate"].ToString());
  365. sql += "\r\n";
  366. }
  367. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  368. return count;
  369. }
  370. public DataTable GetGridJsonChengPing(string queryJson, ref Pagination jqgridparam)
  371. {
  372. DataTable dt = new DataTable();
  373. var queryParam = queryJson.ToJObject();
  374. List<DbParameter> parameter = new List<DbParameter>();
  375. object Figure = GetDecimalDigits();
  376. #region [SQL]
  377. string sql = @" select a.ID,a.MOCode,a.Sequence, CAST(a.RCVQuantity AS DECIMAL(18,{0})) as RCVQuantity ,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount,a.StartDate
  378. ,a.DueDate,a.MOStatus,a.ExtensionID,a.MUSERName,a.MTIME ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  379. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  380. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  381. from ICSMO a
  382. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  383. left join (
  384. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  385. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
  386. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  387. )c
  388. on a.MOCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  389. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint ";
  390. sql += " WHERE 1=1";
  391. sql = string.Format(sql, Figure);
  392. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  393. #endregion
  394. if (!string.IsNullOrWhiteSpace(queryJson))
  395. {
  396. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  397. {
  398. sql += " and a.MOCode like '%" + queryParam["POCode"].ToString() + "%' ";
  399. }
  400. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  401. {
  402. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  403. }
  404. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  405. {
  406. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  407. }
  408. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  409. {
  410. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  411. }
  412. }
  413. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  414. {
  415. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  416. }
  417. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  418. {
  419. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  420. }
  421. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  422. }
  423. /// <summary>
  424. /// 点击成品生成条码(成品)
  425. /// </summary>
  426. public DataTable GetSubGridJsonChengPingByCreate(string MOCode, string Sequence, string WorkPoint)
  427. {
  428. DataTable dt = new DataTable();
  429. object Figure = GetDecimalDigits();
  430. List<DbParameter> parameter = new List<DbParameter>();
  431. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount,CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  432. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  433. from ICSMO a
  434. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  435. left join (
  436. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  437. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  438. group by b.TransCode,b.TransSequence
  439. ) c on a.MOCode=c.TransCode and a.Sequence=c.TransSequence
  440. WHERE 1 =1
  441. and a.MOCode='" + MOCode + "' and a.Sequence='" + Sequence + "'";
  442. sql += " and a.WorkPoint='" + WorkPoint + "'";
  443. sql = string.Format(sql, Figure);
  444. return Repository().FindTableBySql(sql.ToString());
  445. }
  446. /// <summary>
  447. /// 成品生成条码
  448. /// </summary>
  449. /// <param name="POCode"></param>
  450. /// <param name="PORow"></param>
  451. /// <param name="keyValue"></param>
  452. /// 已改
  453. /// <returns></returns>
  454. public int SubmitFormChengPing(string MOCode, string Sequence, string keyValue, string WorkPoint)
  455. {
  456. var queryParam = keyValue.ToJObject();
  457. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  458. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  459. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  460. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  461. decimal LOTQTY = minPackQty;
  462. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  463. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  464. string Pre = "CP" + MOCode + Sequence;
  465. string sql = string.Empty;
  466. //string VendorLot = queryParam["VendorLot"].ToString();
  467. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  468. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  469. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  470. string sqls = string.Empty;
  471. string Colspan = "";
  472. for (int i = 0; i < createPageCount; i++)
  473. {
  474. if (i + 1 == createPageCount)
  475. {
  476. if (minPackQty * createPageCount > thisCreateQty)
  477. {
  478. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  479. }
  480. }
  481. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  482. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  483. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  484. if (ExtensionID == null)
  485. {
  486. ExtensionID = Guid.NewGuid();
  487. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  488. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  489. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  490. MUSER, MUSERNAME, WorkPoints);
  491. }
  492. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  493. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  494. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  495. LotNo, MOCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  496. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  497. //{
  498. sql += string.Format(@"insert into ICSInventoryLot
  499. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  500. select
  501. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','3','{3}','{4}', getdate(),'{5}','{9}'
  502. from ICSMO where MOCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  503. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, MOCode, Sequence, ExtensionID, queryParam["Amount"].ToString(), queryParam["ExpirationDate"].ToString());
  504. sql += "\r\n";
  505. //}
  506. }
  507. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  508. return count;
  509. }
  510. public DataTable GetGridJsonXiaoShou(string queryJson, ref Pagination jqgridparam)
  511. {
  512. DataTable dt = new DataTable();
  513. var queryParam = queryJson.ToJObject();
  514. List<DbParameter> parameter = new List<DbParameter>();
  515. object Figure = GetDecimalDigits();
  516. #region [SQL]
  517. string sql = @" select a.ID,a.SDNCode,a.Sequence,a.SOCode,a.SOSequence,a.CusCode,a.CusName,a.Type,a.ArriveDate,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity
  518. ,cast(a.Amount as decimal(18,{0})) as Amount, CAST(a.SDNQuantity AS DECIMAL(18,{0})) as SDNQuantity ,a.Status,a.ExtensionID,a.CreatePerson,a.CreateDateTime ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  519. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  520. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  521. from ICSSDN a
  522. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  523. left join (
  524. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  525. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
  526. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  527. )c
  528. on a.SDNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  529. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  530. where a.Type='2'";
  531. sql = string.Format(sql, Figure);
  532. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  533. #endregion
  534. if (!string.IsNullOrWhiteSpace(queryJson))
  535. {
  536. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  537. {
  538. sql += " and a.SDNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  539. }
  540. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  541. {
  542. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  543. }
  544. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  545. {
  546. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  547. }
  548. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  549. {
  550. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  551. }
  552. }
  553. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  554. {
  555. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  556. }
  557. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  558. {
  559. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  560. }
  561. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  562. }
  563. /// <summary>
  564. /// 点击销售退货生成条码(销售退货)
  565. /// </summary>
  566. public DataTable GetSubGridJsonXiaoShouByCreate(string SDNCode, string Sequence, string WorkPoint)
  567. {
  568. DataTable dt = new DataTable();
  569. object Figure = GetDecimalDigits();
  570. List<DbParameter> parameter = new List<DbParameter>();
  571. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount,CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  572. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  573. from ICSSDN a
  574. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  575. left join (
  576. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  577. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  578. group by b.TransCode,b.TransSequence
  579. ) c on a.SDNCode=c.TransCode and a.Sequence=c.TransSequence
  580. WHERE 1 =1
  581. and a.Type='2' and a.SDNCode='" + SDNCode + "' and a.Sequence='" + Sequence + "'";
  582. sql += " and a.WorkPoint='" + WorkPoint + "'";
  583. sql = string.Format(sql, Figure);
  584. return Repository().FindTableBySql(sql.ToString());
  585. }
  586. /// <summary>
  587. /// 销售退货生成条码
  588. /// </summary>
  589. /// <param name="POCode"></param>
  590. /// <param name="PORow"></param>
  591. /// <param name="keyValue"></param>
  592. /// 已改
  593. /// <returns></returns>
  594. public int SubmitFormXiaoShou(string SDNCode, string Sequence, string keyValue, string WorkPoint)
  595. {
  596. var queryParam = keyValue.ToJObject();
  597. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  598. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  599. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  600. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  601. decimal LOTQTY = minPackQty;
  602. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  603. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  604. string Pre = "SR" + SDNCode + Sequence;
  605. string sql = string.Empty;
  606. //string VendorLot = queryParam["VendorLot"].ToString();
  607. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  608. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  609. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  610. string sqls = string.Empty;
  611. string Colspan = "";
  612. for (int i = 0; i < createPageCount; i++)
  613. {
  614. if (i + 1 == createPageCount)
  615. {
  616. if (minPackQty * createPageCount > thisCreateQty)
  617. {
  618. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  619. }
  620. }
  621. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  622. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  623. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  624. if (ExtensionID == null)
  625. {
  626. ExtensionID = Guid.NewGuid();
  627. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  628. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  629. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  630. MUSER, MUSERNAME, WorkPoints);
  631. }
  632. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  633. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  634. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}')",
  635. LotNo, SDNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  636. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  637. //{
  638. sql += string.Format(@"
  639. insert into ICSInventoryLot
  640. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  641. select
  642. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','4','{3}','{4}', getdate(),'{5}','{9}'
  643. from ICSSDN where Type='2' and SDNCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  644. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, SDNCode, Sequence, ExtensionID, queryParam["Amount"].ToString(), queryParam["ExpirationDate"].ToString());
  645. sql += "\r\n";
  646. //}
  647. }
  648. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  649. return count;
  650. }
  651. public DataTable GetGridJsonQiTa(string queryJson, ref Pagination jqgridparam)
  652. {
  653. DataTable dt = new DataTable();
  654. var queryParam = queryJson.ToJObject();
  655. List<DbParameter> parameter = new List<DbParameter>();
  656. object Figure = GetDecimalDigits();
  657. #region [SQL]
  658. string sql = @" select a.ID,a.InCode,a.Sequence,a.WHCode,a.InvCode, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,
  659. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST(a.Amount AS DECIMAL(18,{0})) as Amount, CAST(a.InQuantity AS DECIMAL(18,{0})) as InQuantity,a.CreatePerson,a.CreateDateTime,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  660. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  661. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  662. from ICSOtherIn a
  663. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  664. left join (
  665. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  666. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
  667. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  668. )c
  669. on a.InCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  670. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  671. where a.Status='1'";
  672. sql = string.Format(sql, Figure);
  673. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  674. #endregion
  675. if (!string.IsNullOrWhiteSpace(queryJson))
  676. {
  677. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  678. {
  679. sql += " and a.InCode like '%" + queryParam["POCode"].ToString() + "%' ";
  680. }
  681. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  682. {
  683. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  684. }
  685. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  686. {
  687. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  688. }
  689. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  690. {
  691. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  692. }
  693. }
  694. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  695. {
  696. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  697. }
  698. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  699. {
  700. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  701. }
  702. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  703. }
  704. /// <summary>
  705. /// 点击销售退货生成条码(其他入库)
  706. /// </summary>
  707. public DataTable GetSubGridJsonQiTaByCreate(string InCode, string Sequence, string WorkPoint)
  708. {
  709. DataTable dt = new DataTable();
  710. object Figure = GetDecimalDigits();
  711. List<DbParameter> parameter = new List<DbParameter>();
  712. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount,CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  713. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  714. from ICSOtherIn a
  715. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  716. left join (
  717. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  718. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  719. group by b.TransCode,b.TransSequence
  720. ) c on a.InCode=c.TransCode and a.Sequence=c.TransSequence
  721. WHERE 1 =1
  722. and a.InCode='" + InCode + "' and a.Sequence='" + Sequence + "'";
  723. sql += " and a.WorkPoint='" + WorkPoint + "'";
  724. sql = string.Format(sql, Figure);
  725. return Repository().FindTableBySql(sql.ToString());
  726. }
  727. /// <summary>
  728. /// 其他入库生成条码
  729. /// </summary>
  730. /// <param name="POCode"></param>
  731. /// <param name="PORow"></param>
  732. /// <param name="keyValue"></param>
  733. /// 已改
  734. /// <returns></returns>
  735. public int SubmitFormQiTa(string InCode, string Sequence, string keyValue, string WorkPoint)
  736. {
  737. var queryParam = keyValue.ToJObject();
  738. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  739. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  740. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  741. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  742. decimal LOTQTY = minPackQty;
  743. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  744. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  745. string Pre = "QT" + InCode + Sequence;
  746. string sql = string.Empty;
  747. //string VendorLot = queryParam["VendorLot"].ToString();
  748. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  749. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  750. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  751. string sqls = string.Empty;
  752. string Colspan = "";
  753. for (int i = 0; i < createPageCount; i++)
  754. {
  755. if (i + 1 == createPageCount)
  756. {
  757. if (minPackQty * createPageCount > thisCreateQty)
  758. {
  759. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  760. }
  761. }
  762. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  763. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  764. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  765. if (ExtensionID == null)
  766. {
  767. ExtensionID = Guid.NewGuid();
  768. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  769. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  770. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  771. MUSER, MUSERNAME, WorkPoints);
  772. }
  773. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  774. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  775. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  776. LotNo, InCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  777. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  778. //{
  779. sql += string.Format(@"
  780. insert into ICSInventoryLot
  781. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  782. select
  783. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','5','{3}','{4}', getdate(),'{5}','{9}'
  784. from ICSOtherIn where InCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  785. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, InCode, Sequence, ExtensionID, queryParam["Amount"].ToString(), queryParam["ExpirationDate"].ToString());
  786. sql += "\r\n";
  787. //}
  788. }
  789. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  790. return count;
  791. }
  792. //归还
  793. public DataTable GetGridJsonGuiHuan(string queryJson, ref Pagination jqgridparam)
  794. {
  795. DataTable dt = new DataTable();
  796. var queryParam = queryJson.ToJObject();
  797. List<DbParameter> parameter = new List<DbParameter>();
  798. object Figure = GetDecimalDigits();
  799. #region [SQL]
  800. string sql = @"select a.ID,a.ReturnCode,a.Sequence,a.WHCode,a.InvCode, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount, CAST(a.ReturnQuantity AS DECIMAL(18,{0})) as ReturnQuantity,a.CreatePerson,a.CreateDateTime,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  801. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  802. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10 from ICSReturn a
  803. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  804. left join (
  805. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  806. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
  807. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  808. ) c on a.ReturnCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  809. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  810. where a.Status='2'";
  811. sql = string.Format(sql, Figure);
  812. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  813. #endregion
  814. if (!string.IsNullOrWhiteSpace(queryJson))
  815. {
  816. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  817. {
  818. sql += " and a.ReturnCode like '%" + queryParam["POCode"].ToString() + "%' ";
  819. }
  820. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  821. {
  822. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  823. }
  824. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  825. {
  826. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  827. }
  828. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  829. {
  830. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  831. }
  832. }
  833. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  834. {
  835. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  836. }
  837. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  838. {
  839. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  840. }
  841. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  842. }
  843. //审核到货单(采购订单需与审核到货单一起同步)
  844. public DataTable GetGridJsonSHDH(string queryJson, ref Pagination jqgridparam)
  845. {
  846. DataTable dt = new DataTable();
  847. var queryParam = queryJson.ToJObject();
  848. List<DbParameter> parameter = new List<DbParameter>();
  849. object Figure = GetDecimalDigits();
  850. #region [SQL]
  851. string sql = @"select a.ID, d.POCode,d.Sequence as POSequence,a.DNCode,a.Sequence,a.VenCode,e.VenName,a.InvCode, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,
  852. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.RCVQuantity AS DECIMAL(18,{0})) as RCVQuantity,CAST(a.UnitPrice AS DECIMAL(18,{0})) as UnitPrice,a.Currency,a.CreatePerson,a.CreateDateTime,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  853. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  854. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  855. from ICSDeliveryNotice a
  856. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  857. left join (
  858. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  859. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
  860. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  861. ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  862. inner join ICSPurchaseOrder d on a.POID=d.POID and a.PODetailID=d.PODetailID and a.WorkPoint=d.WorkPoint
  863. left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
  864. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  865. where a.DNType='1' and a.Status='2' and a.ASNCode is null
  866. ";
  867. sql = string.Format(sql, Figure);
  868. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  869. #endregion
  870. if (!string.IsNullOrWhiteSpace(queryJson))
  871. {
  872. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  873. {
  874. sql += " and a.DNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  875. }
  876. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  877. {
  878. sql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  879. }
  880. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  881. {
  882. sql += " and e.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  883. }
  884. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  885. {
  886. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  887. }
  888. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  889. {
  890. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  891. }
  892. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  893. {
  894. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  895. }
  896. }
  897. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  898. {
  899. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  900. }
  901. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  902. {
  903. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  904. }
  905. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  906. }
  907. //审核委外到货单
  908. public DataTable GetGridJsonWWSHDH(string queryJson, ref Pagination jqgridparam)
  909. {
  910. DataTable dt = new DataTable();
  911. var queryParam = queryJson.ToJObject();
  912. List<DbParameter> parameter = new List<DbParameter>();
  913. object Figure = GetDecimalDigits();
  914. #region [SQL]
  915. string sql = @"select a.ID, d.OOCode,d.Sequence as OOSequence,a.ODNCode,a.Sequence,a.VenCode,e.VenName,a.InvCode, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.RCVQuantity AS DECIMAL(18,{0})) as RCVQuantity,CAST(a.UnitPrice AS DECIMAL(18,{0})) as UnitPrice,a.Currency,a.CreatePerson,a.CreateDateTime,
  916. CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  917. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  918. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  919. from ICSODeliveryNotice a
  920. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  921. left join (
  922. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  923. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
  924. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  925. ) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  926. inner join ICSOutsourcingOrder d on a.OOID=d.OOID and a.OODetailID=d.OODetailID and a.WorkPoint=d.WorkPoint
  927. left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
  928. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  929. where a.ODNType='1' and a.Status='2' and a.OASNCode is null";
  930. sql = string.Format(sql, Figure);
  931. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  932. #endregion
  933. if (!string.IsNullOrWhiteSpace(queryJson))
  934. {
  935. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  936. {
  937. sql += " and a.ODNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  938. }
  939. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  940. {
  941. sql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  942. }
  943. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  944. {
  945. sql += " and e.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  946. }
  947. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  948. {
  949. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  950. }
  951. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  952. {
  953. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  954. }
  955. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  956. {
  957. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  958. }
  959. }
  960. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  961. {
  962. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  963. }
  964. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  965. {
  966. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  967. }
  968. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  969. }
  970. //开立得成品入库单
  971. public DataTable GetGridJsonKLCPRK(string queryJson, ref Pagination jqgridparam)
  972. {
  973. DataTable dt = new DataTable();
  974. var queryParam = queryJson.ToJObject();
  975. List<DbParameter> parameter = new List<DbParameter>();
  976. object Figure = GetDecimalDigits();
  977. #region [SQL]
  978. string sql = @"
  979. select a.ID,a.RCVCode,a.Sequence,a.WHCode,a.InvCode, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,
  980. CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.RCVQuantity AS DECIMAL(18,{0})) as RCVQuantity ,a.CreatePerson,a.CreateDateTime,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  981. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  982. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  983. from ICSManufactureReceive a
  984. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  985. left join (
  986. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  987. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
  988. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  989. ) c on a.RCVCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  990. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  991. where a.Status='1' and a.Type='1'";
  992. sql = string.Format(sql, Figure);
  993. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  994. #endregion
  995. if (!string.IsNullOrWhiteSpace(queryJson))
  996. {
  997. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  998. {
  999. sql += " and a.RCVCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1000. }
  1001. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1002. {
  1003. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1004. }
  1005. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1006. {
  1007. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1008. }
  1009. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1010. {
  1011. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1012. }
  1013. }
  1014. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1015. {
  1016. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  1017. }
  1018. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1019. {
  1020. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1021. }
  1022. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1023. }
  1024. /// <summary>
  1025. /// 点击审核委外到货单生成条码(审核委外到货单)
  1026. /// </summary>
  1027. public DataTable GetSubGridJsonWWSHDHByCreate(string ODNCode, string Sequence, string WorkPoint)
  1028. {
  1029. DataTable dt = new DataTable();
  1030. object Figure = GetDecimalDigits();
  1031. List<DbParameter> parameter = new List<DbParameter>();
  1032. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount,CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  1033. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  1034. from ICSODeliveryNotice a
  1035. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1036. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1037. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1038. group by b.TransCode,b.TransSequence
  1039. ) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence
  1040. WHERE 1 =1
  1041. and a.ODNCode='" + ODNCode + "' and a.Sequence='" + Sequence + "'";
  1042. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1043. sql = string.Format(sql, Figure);
  1044. return Repository().FindTableBySql(sql.ToString());
  1045. }
  1046. /// <summary>
  1047. /// 点击开立成品入库生成条码(开立成品入库单)
  1048. /// </summary>
  1049. /// //--
  1050. public DataTable GetSubGridJsonKLCPRKByCreate(string RCVCode, string Sequence, string WorkPoint)
  1051. {
  1052. DataTable dt = new DataTable();
  1053. object Figure = GetDecimalDigits();
  1054. List<DbParameter> parameter = new List<DbParameter>();
  1055. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount,CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  1056. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  1057. from ICSManufactureReceive a
  1058. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1059. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1060. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1061. group by b.TransCode,b.TransSequence
  1062. ) c on a.RCVCode=c.TransCode and a.Sequence=c.TransSequence
  1063. WHERE 1 =1
  1064. and a.RCVCode='" + RCVCode + "' and a.Sequence='" + Sequence + "'";
  1065. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1066. sql = string.Format(sql, Figure);
  1067. return Repository().FindTableBySql(sql.ToString());
  1068. }
  1069. /// <summary>
  1070. /// 点击审核到货单生成条码(审核到货单)
  1071. /// </summary>
  1072. public DataTable GetSubGridJsonSHDHByCreate(string DNCode, string Sequence, string WorkPoint)
  1073. {
  1074. DataTable dt = new DataTable();
  1075. object Figure = GetDecimalDigits();
  1076. List<DbParameter> parameter = new List<DbParameter>();
  1077. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount,CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  1078. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  1079. from ICSDeliveryNotice a
  1080. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1081. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1082. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1083. group by b.TransCode,b.TransSequence
  1084. ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence
  1085. WHERE 1 =1
  1086. and a.DNCode='" + DNCode + "' and a.Sequence='" + Sequence + "'";
  1087. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1088. sql = string.Format(sql, Figure);
  1089. return Repository().FindTableBySql(sql.ToString());
  1090. }
  1091. /// <summary>
  1092. /// 点击归还生成条码(归还)
  1093. /// </summary>
  1094. public DataTable GetSubGridJsonGuiHuanByCreate(string ReturnCode, string Sequence, string WorkPoint)
  1095. {
  1096. DataTable dt = new DataTable();
  1097. object Figure = GetDecimalDigits();
  1098. List<DbParameter> parameter = new List<DbParameter>();
  1099. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount,CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  1100. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  1101. from ICSReturn a
  1102. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1103. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1104. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1105. group by b.TransCode,b.TransSequence
  1106. ) c on a.ReturnCode=c.TransCode and a.Sequence=c.TransSequence
  1107. WHERE 1 =1
  1108. and a.ReturnCode='" + ReturnCode + "' and a.Sequence='" + Sequence + "'";
  1109. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1110. sql = string.Format(sql, Figure);
  1111. return Repository().FindTableBySql(sql.ToString());
  1112. }
  1113. /// <summary>
  1114. /// 归还单生成条码
  1115. /// </summary>
  1116. /// <param name="POCode"></param>
  1117. /// <param name="PORow"></param>
  1118. /// <param name="keyValue"></param>
  1119. /// 已改
  1120. /// <returns></returns>
  1121. public int SubmitFormGuiHuan(string ReturnCode, string Sequence, string keyValue, string WorkPoint)
  1122. {
  1123. var queryParam = keyValue.ToJObject();
  1124. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1125. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1126. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1127. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1128. decimal LOTQTY = minPackQty;
  1129. string Pre = "GH" + ReturnCode + Sequence;
  1130. string sql = string.Empty;
  1131. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1132. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1133. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1134. string sqls = string.Empty;
  1135. string Colspan = "";
  1136. for (int i = 0; i < createPageCount; i++)
  1137. {
  1138. if (i + 1 == createPageCount)
  1139. {
  1140. if (minPackQty * createPageCount > thisCreateQty)
  1141. {
  1142. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1143. }
  1144. }
  1145. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  1146. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1147. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1148. if (ExtensionID == null)
  1149. {
  1150. ExtensionID = Guid.NewGuid();
  1151. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  1152. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1153. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  1154. MUSER, MUSERNAME, WorkPoints);
  1155. }
  1156. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1157. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1158. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1159. LotNo, ReturnCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1160. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  1161. //{
  1162. sql += string.Format(@"
  1163. insert into ICSInventoryLot
  1164. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1165. select
  1166. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','6','{3}','{4}', getdate(),'{5}','{9}'
  1167. from ICSReturn where ReturnCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  1168. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ReturnCode, Sequence, ExtensionID, queryParam["Amount"].ToString(), queryParam["ExpirationDate"].ToString());
  1169. sql += "\r\n";
  1170. //}
  1171. }
  1172. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1173. return count;
  1174. }
  1175. /// <summary>
  1176. /// 审核到货单生成条码
  1177. /// </summary>
  1178. /// <param name="POCode"></param>
  1179. /// <param name="PORow"></param>
  1180. /// <param name="keyValue"></param>
  1181. /// 已改
  1182. /// <returns></returns>
  1183. public int SubmitFormSHDH(string DNCode, string Sequence, string keyValue, string WorkPoint)
  1184. {
  1185. var queryParam = keyValue.ToJObject();
  1186. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1187. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1188. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1189. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1190. decimal LOTQTY = minPackQty;
  1191. string Pre = "DN" + DNCode + Sequence;
  1192. string sql = string.Empty;
  1193. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1194. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1195. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1196. string sqls = string.Empty;
  1197. string Colspan = "";
  1198. for (int i = 0; i < createPageCount; i++)
  1199. {
  1200. if (i + 1 == createPageCount)
  1201. {
  1202. if (minPackQty * createPageCount > thisCreateQty)
  1203. {
  1204. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1205. }
  1206. }
  1207. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  1208. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1209. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1210. if (ExtensionID == null)
  1211. {
  1212. ExtensionID = Guid.NewGuid();
  1213. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  1214. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1215. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  1216. MUSER, MUSERNAME, WorkPoints);
  1217. }
  1218. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1219. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1220. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1221. LotNo, DNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1222. sql += string.Format(@"
  1223. insert into ICSInventoryLot
  1224. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1225. select
  1226. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','7','{3}','{4}', getdate(),'{5}','{9}'
  1227. from ICSDeliveryNotice where DNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  1228. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, DNCode, Sequence, ExtensionID, queryParam["Amount"].ToString(), queryParam["ExpirationDate"].ToString());
  1229. sql += "\r\n";
  1230. }
  1231. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1232. return count;
  1233. }
  1234. /// <summary>
  1235. /// 审核委外到货单生成条码
  1236. /// </summary>
  1237. /// <param name="POCode"></param>
  1238. /// <param name="PORow"></param>
  1239. /// <param name="keyValue"></param>
  1240. /// 已改
  1241. /// <returns></returns>
  1242. public int SubmitFormWWSHDH(string ODNCode, string Sequence, string keyValue, string WorkPoint)
  1243. {
  1244. var queryParam = keyValue.ToJObject();
  1245. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1246. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1247. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1248. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1249. decimal LOTQTY = minPackQty;
  1250. string Pre = "ODN" + ODNCode + Sequence;
  1251. string sql = string.Empty;
  1252. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1253. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1254. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1255. string sqls = string.Empty;
  1256. string Colspan = "";
  1257. for (int i = 0; i < createPageCount; i++)
  1258. {
  1259. if (i + 1 == createPageCount)
  1260. {
  1261. if (minPackQty * createPageCount > thisCreateQty)
  1262. {
  1263. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1264. }
  1265. }
  1266. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  1267. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1268. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1269. if (ExtensionID == null)
  1270. {
  1271. ExtensionID = Guid.NewGuid();
  1272. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  1273. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1274. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  1275. MUSER, MUSERNAME, WorkPoints);
  1276. }
  1277. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1278. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1279. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1280. LotNo, ODNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1281. sql += string.Format(@"
  1282. insert into ICSInventoryLot
  1283. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1284. select
  1285. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','8','{3}','{4}', getdate(),'{5}','{9}'
  1286. from ICSODeliveryNotice where ODNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  1287. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ODNCode, Sequence, ExtensionID, queryParam["Amount"].ToString(), queryParam["ExpirationDate"].ToString());
  1288. sql += "\r\n";
  1289. }
  1290. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1291. return count;
  1292. }
  1293. /// <summary>
  1294. /// 开立成品入库单
  1295. /// </summary>
  1296. /// <param name="POCode"></param>
  1297. /// <param name="PORow"></param>
  1298. /// <param name="keyValue"></param>
  1299. /// 已改
  1300. /// <returns></returns>
  1301. public int SubmitFormKLCPRK(string RCVCode, string Sequence, string keyValue, string WorkPoint)
  1302. {
  1303. var queryParam = keyValue.ToJObject();
  1304. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1305. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1306. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1307. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1308. decimal LOTQTY = minPackQty;
  1309. string Pre = "KCP" + RCVCode + Sequence;
  1310. string sql = string.Empty;
  1311. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1312. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1313. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1314. string sqls = string.Empty;
  1315. string Colspan = "";
  1316. for (int i = 0; i < createPageCount; i++)
  1317. {
  1318. if (i + 1 == createPageCount)
  1319. {
  1320. if (minPackQty * createPageCount > thisCreateQty)
  1321. {
  1322. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1323. }
  1324. }
  1325. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  1326. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1327. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1328. if (ExtensionID == null)
  1329. {
  1330. ExtensionID = Guid.NewGuid();
  1331. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  1332. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1333. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  1334. MUSER, MUSERNAME, WorkPoints);
  1335. }
  1336. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1337. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1338. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1339. LotNo, RCVCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1340. sql += string.Format(@"
  1341. insert into ICSInventoryLot
  1342. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1343. select
  1344. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','9','{3}','{4}', getdate(),'{5}','{9}'
  1345. from ICSManufactureReceive where RCVCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  1346. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, RCVCode, Sequence, ExtensionID, queryParam["Amount"].ToString(), queryParam["ExpirationDate"].ToString());
  1347. sql += "\r\n";
  1348. }
  1349. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1350. return count;
  1351. }
  1352. //委外拒收单
  1353. public DataTable GetGridJsonWWJSD(string queryJson, ref Pagination jqgridparam)
  1354. {
  1355. DataTable dt = new DataTable();
  1356. var queryParam = queryJson.ToJObject();
  1357. List<DbParameter> parameter = new List<DbParameter>();
  1358. object Figure = GetDecimalDigits();
  1359. #region [SQL]
  1360. string sql = @"select a.ID, a.ODNCode OOCode,a.Sequence OOSequence,a.VenCode,e.VenName,a.InvCode, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,
  1361. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.RCVQuantity AS DECIMAL(18,{0})) as RCVQuantity,CAST(a.UnitPrice AS DECIMAL(18,{0})) as UnitPrice,a.Currency,a.CreatePerson,a.CreateDateTime,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  1362. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  1363. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  1364. from ICSODeliveryNotice a
  1365. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1366. left join (
  1367. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1368. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
  1369. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1370. ) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  1371. --inner join ICSOutsourcingOrder d on a.OOID=d.OOID and a.OODetailID=d.OODetailID and a.WorkPoint=d.WorkPoint
  1372. left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
  1373. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1374. where a.ODNType='3' and a.Status='2' and a.EATTRIBUTE1 is NOT null
  1375. ";
  1376. sql = string.Format(sql, Figure);
  1377. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  1378. #endregion
  1379. if (!string.IsNullOrWhiteSpace(queryJson))
  1380. {
  1381. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1382. {
  1383. sql += " and a.ODNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1384. }
  1385. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  1386. {
  1387. sql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  1388. }
  1389. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  1390. {
  1391. sql += " and e.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  1392. }
  1393. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1394. {
  1395. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1396. }
  1397. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1398. {
  1399. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1400. }
  1401. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1402. {
  1403. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1404. }
  1405. }
  1406. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1407. {
  1408. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  1409. }
  1410. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1411. {
  1412. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1413. }
  1414. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1415. }
  1416. //拒收单
  1417. public DataTable GetGridJsonJSD(string queryJson, ref Pagination jqgridparam)
  1418. {
  1419. DataTable dt = new DataTable();
  1420. var queryParam = queryJson.ToJObject();
  1421. List<DbParameter> parameter = new List<DbParameter>();
  1422. object Figure = GetDecimalDigits();
  1423. #region [SQL]
  1424. string sql = @"select a.ID,a.DNCode ,a.Sequence ,a.VenCode,e.VenName,a.InvCode, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,
  1425. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.RCVQuantity AS DECIMAL(18,{0})) as RCVQuantity,CAST( a.UnitPrice AS DECIMAL(18,{0})) as UnitPrice,a.Currency,a.CreatePerson,a.CreateDateTime,
  1426. CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  1427. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  1428. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  1429. from ICSDeliveryNotice a
  1430. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1431. left join (
  1432. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1433. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
  1434. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1435. ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  1436. --inner join ICSPurchaseOrder d on a.POID=d.POID and a.PODetailID=d.PODetailID and a.WorkPoint=d.WorkPoint
  1437. left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
  1438. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1439. where a.DNType='3' and a.Status='2' and a.EATTRIBUTE1 is NOT null
  1440. ";
  1441. sql = string.Format(sql, Figure);
  1442. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  1443. #endregion
  1444. if (!string.IsNullOrWhiteSpace(queryJson))
  1445. {
  1446. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1447. {
  1448. sql += " and a.DNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1449. }
  1450. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  1451. {
  1452. sql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  1453. }
  1454. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  1455. {
  1456. sql += " and e.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  1457. }
  1458. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1459. {
  1460. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1461. }
  1462. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1463. {
  1464. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1465. }
  1466. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1467. {
  1468. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1469. }
  1470. }
  1471. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1472. {
  1473. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  1474. }
  1475. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1476. {
  1477. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1478. }
  1479. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1480. }
  1481. //领料申请退料
  1482. public DataTable GetGridJsonLLSQTL(string queryJson, ref Pagination jqgridparam)
  1483. {
  1484. DataTable dt = new DataTable();
  1485. var queryParam = queryJson.ToJObject();
  1486. List<DbParameter> parameter = new List<DbParameter>();
  1487. object Figure = GetDecimalDigits();
  1488. #region [SQL]
  1489. string sql = @"select a.ID,a.ApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
  1490. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as IssueNegQuantity ,a.ExtensionID,a.MUSERName,a.MTIME ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  1491. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  1492. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  1493. from ICSMOApplyNegDetail a
  1494. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  1495. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1496. left join (
  1497. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1498. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
  1499. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1500. )c
  1501. on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  1502. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1503. WHERE d.Type='2'";
  1504. sql = string.Format(sql, Figure);
  1505. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  1506. #endregion
  1507. if (!string.IsNullOrWhiteSpace(queryJson))
  1508. {
  1509. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1510. {
  1511. sql += " and a.ApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1512. }
  1513. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1514. {
  1515. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1516. }
  1517. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1518. {
  1519. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1520. }
  1521. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1522. {
  1523. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1524. }
  1525. }
  1526. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1527. {
  1528. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  1529. }
  1530. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1531. {
  1532. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1533. }
  1534. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1535. }
  1536. /// <summary>
  1537. /// 拒收生成条码
  1538. /// </summary>
  1539. /// <param name="POCode"></param>
  1540. /// <param name="PORow"></param>
  1541. /// <param name="keyValue"></param>
  1542. /// <returns></returns>
  1543. public int SubmitFormJSD(string DNCode, string Sequence, string keyValue, string WorkPoint)
  1544. {
  1545. var queryParam = keyValue.ToJObject();
  1546. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1547. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1548. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1549. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1550. decimal LOTQTY = minPackQty;
  1551. string Pre = "JS" + DNCode + Sequence;
  1552. string sql = string.Empty;
  1553. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1554. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1555. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1556. string sqls = string.Empty;
  1557. string Colspan = "";
  1558. for (int i = 0; i < createPageCount; i++)
  1559. {
  1560. if (i + 1 == createPageCount)
  1561. {
  1562. if (minPackQty * createPageCount > thisCreateQty)
  1563. {
  1564. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1565. }
  1566. }
  1567. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  1568. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1569. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1570. if (ExtensionID == null)
  1571. {
  1572. ExtensionID = Guid.NewGuid();
  1573. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  1574. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1575. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  1576. MUSER, MUSERNAME, WorkPoints);
  1577. }
  1578. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1579. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1580. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1581. LotNo, DNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1582. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  1583. //{
  1584. sql += string.Format(@"
  1585. insert into ICSInventoryLot
  1586. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1587. select
  1588. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','10','{3}','{4}', getdate(),'{5}','{9}'
  1589. from ICSDeliveryNotice where DNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  1590. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, DNCode, Sequence, ExtensionID, queryParam["Amount"].ToString(), queryParam["ExpirationDate"].ToString());
  1591. sql += "\r\n";
  1592. //}
  1593. }
  1594. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1595. return count;
  1596. }
  1597. /// <summary>
  1598. /// 委外拒收生成条码
  1599. /// </summary>
  1600. /// <param name="POCode"></param>
  1601. /// <param name="PORow"></param>
  1602. /// <param name="keyValue"></param>
  1603. /// <returns></returns>
  1604. public int SubmitFormWWJSD(string ODNCode, string Sequence, string keyValue, string WorkPoint)
  1605. {
  1606. var queryParam = keyValue.ToJObject();
  1607. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1608. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1609. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1610. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1611. decimal LOTQTY = minPackQty;
  1612. string Pre = "OJS" + ODNCode + Sequence;
  1613. string sql = string.Empty;
  1614. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1615. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1616. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1617. string sqls = string.Empty;
  1618. string Colspan = "";
  1619. for (int i = 0; i < createPageCount; i++)
  1620. {
  1621. if (i + 1 == createPageCount)
  1622. {
  1623. if (minPackQty * createPageCount > thisCreateQty)
  1624. {
  1625. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1626. }
  1627. }
  1628. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  1629. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1630. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1631. if (ExtensionID == null)
  1632. {
  1633. ExtensionID = Guid.NewGuid();
  1634. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  1635. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1636. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  1637. MUSER, MUSERNAME, WorkPoints);
  1638. }
  1639. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1640. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1641. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1642. LotNo, ODNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1643. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  1644. //{
  1645. sql += string.Format(@"
  1646. insert into ICSInventoryLot
  1647. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1648. select
  1649. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','11','{3}','{4}', getdate(),'{5}','{9}'
  1650. from ICSODeliveryNotice where ODNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  1651. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ODNCode, Sequence, ExtensionID, queryParam["Amount"].ToString(), queryParam["ExpirationDate"].ToString());
  1652. sql += "\r\n";
  1653. //}
  1654. }
  1655. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1656. return count;
  1657. }
  1658. /// <summary>
  1659. /// 点击审核到货单生成条码(审核到货单)
  1660. /// </summary>
  1661. public DataTable GetSubGridJsonJSDByCreate(string DNCode, string Sequence, string WorkPoint)
  1662. {
  1663. DataTable dt = new DataTable();
  1664. object Figure = GetDecimalDigits();
  1665. List<DbParameter> parameter = new List<DbParameter>();
  1666. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount,CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  1667. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  1668. from ICSDeliveryNotice a
  1669. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1670. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1671. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1672. group by b.TransCode,b.TransSequence
  1673. ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence
  1674. WHERE a.DNType='3'
  1675. and a.DNCode='" + DNCode + "' and a.Sequence='" + Sequence + "'";
  1676. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1677. sql = string.Format(sql, Figure);
  1678. return Repository().FindTableBySql(sql.ToString());
  1679. }
  1680. /// <summary>
  1681. /// 点击审核委外到货单生成条码(审核委外到货单)
  1682. /// </summary>
  1683. public DataTable GetSubGridJsonWWJSDByCreate(string ODNCode, string Sequence, string WorkPoint)
  1684. {
  1685. DataTable dt = new DataTable();
  1686. object Figure = GetDecimalDigits();
  1687. List<DbParameter> parameter = new List<DbParameter>();
  1688. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount,CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  1689. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  1690. from ICSODeliveryNotice a
  1691. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1692. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1693. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1694. group by b.TransCode,b.TransSequence
  1695. ) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence
  1696. WHERE a.ODNType='3'
  1697. and a.ODNCode='" + ODNCode + "' and a.Sequence='" + Sequence + "'";
  1698. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1699. sql = string.Format(sql, Figure);
  1700. return Repository().FindTableBySql(sql.ToString());
  1701. }
  1702. public DataTable GetSubGridJsonLLSQDByCreate(string ApplyNegCode, string Sequence, string WorkPoint)
  1703. {
  1704. DataTable dt = new DataTable();
  1705. object Figure = GetDecimalDigits();
  1706. List<DbParameter> parameter = new List<DbParameter>();
  1707. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount,CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  1708. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  1709. from ICSMOApplyNegDetail a
  1710. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  1711. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1712. left join (
  1713. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1714. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1715. group by b.TransCode,b.TransSequence
  1716. ) c on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  1717. WHERE d.Type='2'
  1718. and a.ApplyNegCode='" + ApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  1719. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1720. sql = string.Format(sql, Figure);
  1721. return Repository().FindTableBySql(sql.ToString());
  1722. }
  1723. //领料申请退料生成条码
  1724. public int SubmitFormLLSQTL(string ApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  1725. {
  1726. var queryParam = keyValue.ToJObject();
  1727. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1728. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1729. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1730. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1731. decimal LOTQTY = minPackQty;
  1732. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1733. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  1734. string Pre = "MA" + ApplyNegCode + Sequence;
  1735. string sql = string.Empty;
  1736. //string VendorLot = queryParam["VendorLot"].ToString();
  1737. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1738. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1739. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1740. string sqls = string.Empty;
  1741. string Colspan = "";
  1742. for (int i = 0; i < createPageCount; i++)
  1743. {
  1744. if (i + 1 == createPageCount)
  1745. {
  1746. if (minPackQty * createPageCount > thisCreateQty)
  1747. {
  1748. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1749. }
  1750. }
  1751. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  1752. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1753. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1754. if (ExtensionID == null)
  1755. {
  1756. ExtensionID = Guid.NewGuid();
  1757. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  1758. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1759. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  1760. MUSER, MUSERNAME, WorkPoints);
  1761. }
  1762. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1763. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1764. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1765. LotNo, ApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1766. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  1767. //{
  1768. sql += string.Format(@"insert into ICSInventoryLot
  1769. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1770. select
  1771. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','12','{3}','{4}', getdate(),'{5}','{9}'
  1772. from ICSMOApplyNegDetail where ApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  1773. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ApplyNegCode, Sequence, ExtensionID, queryParam["Amount"].ToString(), queryParam["ExpirationDate"].ToString());
  1774. sql += "\r\n";
  1775. //}
  1776. }
  1777. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1778. return count;
  1779. }
  1780. //材料出库退料
  1781. public DataTable GetGridJsonCLCK(string queryJson, ref Pagination jqgridparam)
  1782. {
  1783. DataTable dt = new DataTable();
  1784. var queryParam = queryJson.ToJObject();
  1785. List<DbParameter> parameter = new List<DbParameter>();
  1786. object Figure = GetDecimalDigits();
  1787. #region [SQL]
  1788. string sql = @"
  1789. select a.ID,a.ApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
  1790. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity
  1791. CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as IssueNegQuantity ,a.ExtensionID,a.MUSERName,a.MTIME ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  1792. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  1793. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  1794. from ICSMOApplyNegDetail a
  1795. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  1796. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1797. left join (
  1798. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1799. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
  1800. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1801. )c
  1802. on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  1803. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1804. WHERE d.Type='3'";
  1805. sql = string.Format(sql, Figure);
  1806. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  1807. #endregion
  1808. if (!string.IsNullOrWhiteSpace(queryJson))
  1809. {
  1810. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1811. {
  1812. sql += " and a.ApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1813. }
  1814. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1815. {
  1816. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1817. }
  1818. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1819. {
  1820. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1821. }
  1822. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1823. {
  1824. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1825. }
  1826. }
  1827. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1828. {
  1829. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  1830. }
  1831. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1832. {
  1833. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1834. }
  1835. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1836. }
  1837. //材料出库退料
  1838. public DataTable GetSubGridJsonCLCKByCreate(string ApplyNegCode, string Sequence, string WorkPoint)
  1839. {
  1840. DataTable dt = new DataTable();
  1841. object Figure = GetDecimalDigits();
  1842. List<DbParameter> parameter = new List<DbParameter>();
  1843. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount,CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  1844. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  1845. from ICSMOApplyNegDetail a
  1846. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  1847. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1848. left join (
  1849. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1850. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1851. group by b.TransCode,b.TransSequence
  1852. ) c on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  1853. WHERE d.Type='3'
  1854. and a.ApplyNegCode='" + ApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  1855. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1856. sql = string.Format(sql, Figure);
  1857. return Repository().FindTableBySql(sql.ToString());
  1858. }
  1859. //材料出库退料生成条码
  1860. public int SubmitFormCLCKT(string ApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  1861. {
  1862. var queryParam = keyValue.ToJObject();
  1863. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1864. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1865. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1866. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1867. decimal LOTQTY = minPackQty;
  1868. string Pre = "MD" + ApplyNegCode + Sequence;
  1869. string sql = string.Empty;
  1870. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1871. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1872. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1873. string sqls = string.Empty;
  1874. string Colspan = "";
  1875. for (int i = 0; i < createPageCount; i++)
  1876. {
  1877. if (i + 1 == createPageCount)
  1878. {
  1879. if (minPackQty * createPageCount > thisCreateQty)
  1880. {
  1881. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1882. }
  1883. }
  1884. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  1885. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1886. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1887. if (ExtensionID == null)
  1888. {
  1889. ExtensionID = Guid.NewGuid();
  1890. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  1891. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1892. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  1893. MUSER, MUSERNAME, WorkPoints);
  1894. }
  1895. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1896. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1897. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1898. LotNo, ApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1899. sql += string.Format(@"insert into ICSInventoryLot
  1900. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1901. select
  1902. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','13','{3}','{4}', getdate(),'{5}','{9}'
  1903. from ICSMOApplyNegDetail where ApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  1904. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ApplyNegCode, Sequence, ExtensionID, queryParam["Amount"].ToString(), queryParam["ExpirationDate"].ToString());
  1905. sql += "\r\n";
  1906. }
  1907. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1908. return count;
  1909. }
  1910. public DataTable GetGridJsonWWLLTL(string queryJson, ref Pagination jqgridparam)
  1911. {
  1912. DataTable dt = new DataTable();
  1913. var queryParam = queryJson.ToJObject();
  1914. List<DbParameter> parameter = new List<DbParameter>();
  1915. object Figure = GetDecimalDigits();
  1916. #region [SQL]
  1917. string sql = @"select a.ID,a.OApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
  1918. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as IssueNegQuantity ,a.ExtensionID,a.MUSERName,a.MTIME ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  1919. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  1920. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  1921. from ICSOApplyNegDetail a
  1922. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  1923. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1924. left join (
  1925. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1926. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
  1927. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1928. )c
  1929. on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  1930. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1931. WHERE d.Type='2'";
  1932. sql = string.Format(sql, Figure);
  1933. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  1934. #endregion
  1935. if (!string.IsNullOrWhiteSpace(queryJson))
  1936. {
  1937. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1938. {
  1939. sql += " and a.OApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1940. }
  1941. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1942. {
  1943. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1944. }
  1945. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1946. {
  1947. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1948. }
  1949. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1950. {
  1951. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1952. }
  1953. }
  1954. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1955. {
  1956. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  1957. }
  1958. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1959. {
  1960. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1961. }
  1962. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1963. }
  1964. /// <summary>
  1965. /// 点击委外领料退料生成条码
  1966. /// </summary>
  1967. public DataTable GetSubGridJsonWWLLByCreate(string OApplyNegCode, string Sequence, string WorkPoint)
  1968. {
  1969. DataTable dt = new DataTable();
  1970. object Figure = GetDecimalDigits();
  1971. List<DbParameter> parameter = new List<DbParameter>();
  1972. string sql = @"
  1973. select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount,CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  1974. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  1975. from ICSOApplyNegDetail a
  1976. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  1977. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1978. left join (
  1979. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1980. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1981. group by b.TransCode,b.TransSequence
  1982. ) c on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  1983. WHERE d.Type='2'
  1984. and a.OApplyNegCode='" + OApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  1985. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1986. sql = string.Format(sql, Figure);
  1987. return Repository().FindTableBySql(sql.ToString());
  1988. }
  1989. //委外领料申请退料
  1990. public int SubmitFormWWLL(string OApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  1991. {
  1992. var queryParam = keyValue.ToJObject();
  1993. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1994. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1995. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1996. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1997. decimal LOTQTY = minPackQty;
  1998. string Pre = "OMA" + OApplyNegCode + Sequence;
  1999. string sql = string.Empty;
  2000. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2001. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2002. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  2003. string sqls = string.Empty;
  2004. string Colspan = "";
  2005. for (int i = 0; i < createPageCount; i++)
  2006. {
  2007. if (i + 1 == createPageCount)
  2008. {
  2009. if (minPackQty * createPageCount > thisCreateQty)
  2010. {
  2011. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  2012. }
  2013. }
  2014. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  2015. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  2016. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  2017. if (ExtensionID == null)
  2018. {
  2019. ExtensionID = Guid.NewGuid();
  2020. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  2021. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  2022. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  2023. MUSER, MUSERNAME, WorkPoints);
  2024. }
  2025. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  2026. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  2027. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  2028. LotNo, OApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  2029. sql += string.Format(@"insert into ICSInventoryLot
  2030. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  2031. select
  2032. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','14','{3}','{4}', getdate(),'{5}','{9}'
  2033. from ICSOApplyNegDetail where OApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  2034. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, OApplyNegCode, Sequence, ExtensionID, queryParam["Amount"].ToString(), queryParam["ExpirationDate"].ToString());
  2035. sql += "\r\n";
  2036. }
  2037. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  2038. return count;
  2039. }
  2040. //委外材料出库
  2041. public DataTable GetGridJsonWWCLCK(string queryJson, ref Pagination jqgridparam)
  2042. {
  2043. DataTable dt = new DataTable();
  2044. var queryParam = queryJson.ToJObject();
  2045. List<DbParameter> parameter = new List<DbParameter>();
  2046. object Figure = GetDecimalDigits();
  2047. #region [SQL]
  2048. string sql = @"select a.ID,a.OApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
  2049. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as IssueNegQuantity ,a.ExtensionID,a.MUSERName,a.MTIME ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  2050. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  2051. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  2052. from ICSOApplyNegDetail a
  2053. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  2054. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2055. left join (
  2056. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  2057. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
  2058. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  2059. )c
  2060. on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  2061. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  2062. WHERE d.Type='3'";
  2063. sql = string.Format(sql, Figure);
  2064. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  2065. #endregion
  2066. if (!string.IsNullOrWhiteSpace(queryJson))
  2067. {
  2068. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  2069. {
  2070. sql += " and a.OApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  2071. }
  2072. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  2073. {
  2074. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  2075. }
  2076. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  2077. {
  2078. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  2079. }
  2080. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  2081. {
  2082. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  2083. }
  2084. }
  2085. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  2086. {
  2087. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  2088. }
  2089. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  2090. {
  2091. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  2092. }
  2093. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2094. }
  2095. //委外材料出库
  2096. public DataTable GetSubGridJsonWWCLByCreate(string OApplyNegCode, string Sequence, string WorkPoint)
  2097. {
  2098. DataTable dt = new DataTable();
  2099. object Figure = GetDecimalDigits();
  2100. List<DbParameter> parameter = new List<DbParameter>();
  2101. string sql = @"
  2102. select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount,CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  2103. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  2104. from ICSOApplyNegDetail a
  2105. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  2106. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2107. left join (
  2108. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  2109. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  2110. group by b.TransCode,b.TransSequence
  2111. ) c on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  2112. WHERE d.Type='3'
  2113. and a.OApplyNegCode='" + OApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  2114. sql += " and a.WorkPoint='" + WorkPoint + "'";
  2115. sql = string.Format(sql, Figure);
  2116. return Repository().FindTableBySql(sql.ToString());
  2117. }
  2118. //委外材料出库
  2119. public int SubmitFormWWCL(string OApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  2120. {
  2121. var queryParam = keyValue.ToJObject();
  2122. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2123. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  2124. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  2125. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  2126. decimal LOTQTY = minPackQty;
  2127. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2128. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  2129. string Pre = "OMD" + OApplyNegCode + Sequence;
  2130. string sql = string.Empty;
  2131. //string VendorLot = queryParam["VendorLot"].ToString();
  2132. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2133. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2134. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  2135. string sqls = string.Empty;
  2136. string Colspan = "";
  2137. for (int i = 0; i < createPageCount; i++)
  2138. {
  2139. if (i + 1 == createPageCount)
  2140. {
  2141. if (minPackQty * createPageCount > thisCreateQty)
  2142. {
  2143. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  2144. }
  2145. }
  2146. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  2147. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  2148. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  2149. if (ExtensionID == null)
  2150. {
  2151. ExtensionID = Guid.NewGuid();
  2152. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  2153. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  2154. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  2155. MUSER, MUSERNAME, WorkPoints);
  2156. }
  2157. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  2158. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  2159. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  2160. LotNo, OApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  2161. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  2162. //{
  2163. sql += string.Format(@"insert into ICSInventoryLot
  2164. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  2165. select
  2166. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','15','{3}','{4}', getdate(),'{5}','{9}'
  2167. from ICSOApplyNegDetail where OApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  2168. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, OApplyNegCode, Sequence, ExtensionID, queryParam["Amount"].ToString(), queryParam["ExpirationDate"].ToString());
  2169. sql += "\r\n";
  2170. //}
  2171. }
  2172. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  2173. return count;
  2174. }
  2175. public DataTable SelectICSExtensionEnable(string BeginTime, string EndTime)
  2176. {
  2177. string sql = @"select ColCode from ICSExtensionEnable
  2178. where Enable=0
  2179. order by cast(EATTRIBUTE1 as int)";
  2180. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  2181. return dt;
  2182. }
  2183. //返工工单
  2184. public DataTable GetGridJsonFGGD(string queryJson, ref Pagination jqgridparam)
  2185. {
  2186. DataTable dt = new DataTable();
  2187. var queryParam = queryJson.ToJObject();
  2188. List<DbParameter> parameter = new List<DbParameter>();
  2189. object Figure = GetDecimalDigits();
  2190. #region [SQL]
  2191. string sql = @"select a.ID,d.MOCode,d.Sequence+'-'+ a.Sequence as Sequence,a.PickID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
  2192. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity
  2193. CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.IssueQuantity AS DECIMAL(18,{0})) as IssueQuantity ,a.ExtensionID,a.MUSERName,a.MTIME ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  2194. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  2195. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  2196. from ICSMOPick a
  2197. left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint
  2198. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2199. left join (
  2200. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  2201. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
  2202. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  2203. )c
  2204. on d.MOCode=c.TransCode and d.Sequence+'-'+a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  2205. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  2206. where a.EATTRIBUTE1='1' and d.EATTRIBUTE1='1'";
  2207. sql = string.Format(sql, Figure);
  2208. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  2209. #endregion
  2210. if (!string.IsNullOrWhiteSpace(queryJson))
  2211. {
  2212. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  2213. {
  2214. sql += " and d.MOCode like '%" + queryParam["POCode"].ToString() + "%' ";
  2215. }
  2216. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  2217. {
  2218. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  2219. }
  2220. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  2221. {
  2222. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  2223. }
  2224. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  2225. {
  2226. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  2227. }
  2228. }
  2229. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  2230. {
  2231. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  2232. }
  2233. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  2234. {
  2235. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  2236. }
  2237. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2238. }
  2239. public DataTable GetSubGridJsonFGGDCreate(string FGGDMOCode, string Sequence, string WorkPoint)
  2240. {
  2241. DataTable dt = new DataTable();
  2242. object Figure = GetDecimalDigits();
  2243. List<DbParameter> parameter = new List<DbParameter>();
  2244. string sql = @"
  2245. select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount,CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  2246. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  2247. from ICSMOPick a
  2248. left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint
  2249. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2250. left join (
  2251. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  2252. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  2253. group by b.TransCode,b.TransSequence
  2254. ) c on d.MOCode=c.TransCode and d.Sequence+'-'+a.Sequence=c.TransSequence
  2255. WHERE 1=1
  2256. and d.MOCode='" + FGGDMOCode + "' and d.Sequence+'-'+a.Sequence='" + Sequence + "'";
  2257. sql += " and a.WorkPoint='" + WorkPoint + "'";
  2258. sql = string.Format(sql, Figure);
  2259. return Repository().FindTableBySql(sql.ToString());
  2260. }
  2261. //返工工单
  2262. public int SubmitFormFGGD(string FGGDMOCode, string Sequence, string keyValue, string WorkPoint)
  2263. {
  2264. var queryParam = keyValue.ToJObject();
  2265. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2266. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  2267. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  2268. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  2269. decimal LOTQTY = minPackQty;
  2270. string Pre = "FG" + FGGDMOCode + Sequence;
  2271. string sql = string.Empty;
  2272. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2273. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2274. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  2275. string sqls = string.Empty;
  2276. string Colspan = "";
  2277. for (int i = 0; i < createPageCount; i++)
  2278. {
  2279. if (i + 1 == createPageCount)
  2280. {
  2281. if (minPackQty * createPageCount > thisCreateQty)
  2282. {
  2283. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  2284. }
  2285. }
  2286. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  2287. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  2288. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  2289. if (ExtensionID == null)
  2290. {
  2291. ExtensionID = Guid.NewGuid();
  2292. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  2293. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  2294. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  2295. MUSER, MUSERNAME, WorkPoints);
  2296. }
  2297. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  2298. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  2299. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  2300. LotNo, FGGDMOCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  2301. sql += string.Format(@"insert into ICSInventoryLot
  2302. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  2303. select
  2304. newid(),'{0}',a.InvCode,'{1}','{10}','{2}','{8}','16','{3}','{4}', getdate(),'{5}','{9}'
  2305. from ICSMOPick a left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint where d.MOCode='{6}' and d.Sequence+'-'+a.Sequence='{7}' and a.WorkPoint='{5}' ",
  2306. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, FGGDMOCode, Sequence, ExtensionID, queryParam["Amount"].ToString(), queryParam["ExpirationDate"].ToString());
  2307. sql += "\r\n";
  2308. }
  2309. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  2310. return count;
  2311. }
  2312. public object GetDecimalDigits()
  2313. {
  2314. try
  2315. {
  2316. string sql = string.Empty;
  2317. sql = @"select Figure from ICSConfiguration where Code='Figure001' and Enable='1'";
  2318. object Figure = SqlHelper.ExecuteScalar(sql);
  2319. return Figure;
  2320. }
  2321. catch (Exception ex)
  2322. {
  2323. throw new Exception(ex.Message.ToString());
  2324. }
  2325. }
  2326. }
  2327. }