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

2327 lines
142 KiB

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