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

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