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.

4950 lines
305 KiB

  1. using NFine.Data.Extensions;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using NFine.Code;
  6. using NFine.Repository;
  7. using System.Data.Common;
  8. using NFine.Domain._03_Entity.SRM;
  9. using System.Configuration;
  10. using System.Text;
  11. using System.Net;
  12. using Newtonsoft.Json.Linq;
  13. using Newtonsoft.Json;
  14. using System.IO;
  15. using System.Data.SqlClient;
  16. namespace NFine.Application.WMS
  17. {
  18. public class WMSCreateItemLotApp : RepositoryFactory<ICSVendor>
  19. {
  20. public DataTable GetGridJson(string queryJson, ref Pagination jqgridparam)
  21. {
  22. DataTable dt = new DataTable();
  23. var queryParam = queryJson.ToJObject();
  24. List<DbParameter> parameter = new List<DbParameter>();
  25. object Figure = GetDecimalDigits();
  26. #region [SQL]
  27. string sql = @"select a.ID,y.MOCode,a.ApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit, CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity
  28. ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount , CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as IssueNegQuantity ,a.ExtensionID,a.MUSERName,a.MTIME , CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  29. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  30. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  31. a.EATTRIBUTE9,a.EATTRIBUTE10
  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 and ee.type='1'
  38. where isnull(ee.EATTRIBUTE1,'')=''
  39. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  40. )c
  41. on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  42. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  43. inner JOIN ICSMOPick x ON a.SourceDetailID=x.PickID AND a.WorkPoint=x.WorkPoint
  44. left JOIN ICSMO y ON x.MODetailID=y.MODetailID AND x.WorkPoint=y.WorkPoint
  45. where d.Type='1'";
  46. sql = string.Format(sql, Figure);
  47. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  48. #endregion
  49. if (!string.IsNullOrWhiteSpace(queryJson))
  50. {
  51. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  52. {
  53. sql += " and a.ApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  54. }
  55. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  56. {
  57. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  58. }
  59. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  60. {
  61. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  62. }
  63. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  64. {
  65. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  66. }
  67. if (!string.IsNullOrWhiteSpace(queryParam["POStatus"].ToString()))
  68. {
  69. string POStatus = queryParam["POStatus"].ToString();
  70. if (POStatus == "0")
  71. {
  72. //sql += " and a.Quantity=ISNULL(c.LotQty,0)";
  73. }
  74. else if (POStatus == "1")
  75. {
  76. sql += " and a.Quantity-ISNULL(c.LOTQTY,0)=0";
  77. }
  78. else
  79. {
  80. sql += " and a.Quantity-ISNULL(c.LOTQTY,0)<>0";
  81. }
  82. }
  83. }
  84. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  85. {
  86. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  87. }
  88. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  89. {
  90. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  91. }
  92. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  93. }
  94. /// <summary>
  95. /// 领料子件信息
  96. /// </summary>
  97. /// <param name="MODetailID"></param>
  98. /// <param name="workpoint"></param>
  99. /// <param name="jqgridparam"></param>
  100. /// <returns></returns>
  101. public DataTable GetICSMOPick(string MODetailID,string workpoint, ref Pagination jqgridparam)
  102. {
  103. DataTable dt = new DataTable();
  104. List<DbParameter> parameter = new List<DbParameter>();
  105. object Figure = GetDecimalDigits();
  106. #region [SQL]
  107. string sql = @"SELECT b.InvCode,c.InvName,c.InvStd,InvUnit,b.ID,b.Quantity,b.IssueQuantity FROM dbo.ICSMO a
  108. LEFT JOIN dbo.ICSMOPick b ON a.MODetailID=b.MODetailID AND a.WorkPoint=b.WorkPoint
  109. LEFT JOIN dbo.ICSInventory c ON b.InvCode=c.InvCode AND b.WorkPoint=c.WorkPoint
  110. WHERE a.MODetailID='{0}'
  111. ";
  112. sql = string.Format(sql, MODetailID);
  113. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  114. #endregion
  115. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  116. }
  117. public DataTable GetSubGridJson(string ApplyNegCode, string Sequence, string Type, ref Pagination jqgridparam)
  118. {
  119. DataTable dt = new DataTable();
  120. object Figure = GetDecimalDigits();
  121. List<DbParameter> parameter = new List<DbParameter>();
  122. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  123. string sql = @" select c.TransCode,c.TransSequence ,a.ID,a.LotNo, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity ,a.MUSERName,a.MTIME
  124. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  125. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,
  126. case when isnull(d.ID,'')='' then '' else '' end as isStorage,
  127. case when g.InvIQC='1'and isnull(e.ID,'')='' then '' else '' end as isInspection,
  128. case when g.InvIQC='1' then '是' else '否' end as isExemption,a.Amount,
  129. convert(varchar(20),a.ProductDate,23) as ProductDate,convert(varchar(20),a.ExpirationDate,23) as ExpirationDate ,g.EffectiveDays
  130. from ICSInventoryLot a
  131. left join (select count(LotNo) LotNoCount,LotNo,WorkPoint from ICSWareHouseLotInfo
  132. group by LotNo,WorkPoint)b on a.LotNo=b.LotNo and a.WorkPoint=b.WorkPoint
  133. left join ICSInventoryLotDetail c on a.LotNo=c.LotNo and a.WorkPoint=c.WorkPoint
  134. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  135. left join dbo.ICSWareHouseLotInfo d on a.LotNo=d.LotNo and a.WorkPoint=d.WorkPoint
  136. left join ICSInspection e on a.LotNo=e.LotNo and e.Enable='1' and a.WorkPoint=e.WorkPoint
  137. left join ICSInventory g on a.InvCode=g.InvCode and a.WorkPoint=g.WorkPoint
  138. WHERE isnull(a.EATTRIBUTE1,'')='' and a.Type='" + Type + "' and c.TransCode='" + ApplyNegCode + "' and c.TransSequence='" + Sequence + "' and a.WorkPoint in ('" + WorkPoint + "')";
  139. sql = string.Format(sql, Figure);
  140. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  141. }
  142. /// <summary>
  143. /// 点击生成条码
  144. /// </summary>
  145. public DataTable GetSubGridJsonByCreate(string ApplyNegCode, string Sequence, string WorkPoint)
  146. {
  147. DataTable dt = new DataTable();
  148. object Figure = GetDecimalDigits();
  149. List<DbParameter> parameter = new List<DbParameter>();
  150. string sql = @"select a.InvCode,b.InvName,b.ClassCode,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,4)) as Quantity, CAST( a.Amount as DECIMAL(18,4)) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,4)) as CreatedQty ,
  151. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,4)) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,4)) as EffectiveDays,
  152. d.ProjectCode,d.BatchCode,d.Version,d.Brand,d.cFree1,d.cFree2,d.cFree3,d.cFree4,d.cFree5,d.cFree6,d.cFree7,d.cFree8,d.cFree9,d.cFree10
  153. from ICSMOApplyNegDetail a
  154. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  155. left join (
  156. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  157. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo and a.Type='1'
  158. where isnull(a.EATTRIBUTE1,'')=''
  159. group by b.TransCode,b.TransSequence
  160. ) c on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  161. left join ICSExtension d on a.ExtensionID=d.ID and a.WorkPoint=d.WorkPoint
  162. WHERE 1 =1
  163. and a.ApplyNegCode='" + ApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  164. sql += " and a.WorkPoint='" + WorkPoint + "'";
  165. sql = string.Format(sql, Figure);
  166. return Repository().FindTableBySql(sql.ToString());
  167. }
  168. public DataTable GetVendorLotNo(string VenCode, string WorkPoint)
  169. {
  170. DataTable dt = new DataTable();
  171. //var queryParam = queryJson.ToJObject();
  172. List<DbParameter> parameter = new List<DbParameter>();
  173. string dtPre = DateTime.Now.ToString("yyyyMMdd");
  174. string sql = @"EXEC Addins_GetSerialCode '" + WorkPoint + "','ICSITEMLotNo','VendorLotNo','" + VenCode + dtPre + "',2";
  175. return Repository().FindTableBySql(sql.ToString());
  176. }
  177. /// <summary>
  178. /// 生产退料生成条码
  179. /// </summary>
  180. /// <param name="POCode"></param>
  181. /// <param name="PORow"></param>
  182. /// <param name="keyValue"></param>
  183. /// 已改
  184. /// <returns></returns>
  185. public int CreateItemLotNo(string ApplyNegCode, string Sequence, string keyValue, string WorkPoint,string AMEnable)
  186. {
  187. var queryParam = keyValue.ToJObject();
  188. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  189. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  190. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  191. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  192. decimal LOTQTY = minPackQty;
  193. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  194. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  195. string Pre = "MDN" + ApplyNegCode + (Convert.ToInt32(Sequence)).ToString("D4");
  196. string sql = string.Empty;
  197. //string VendorLot = queryParam["VendorLot"].ToString();
  198. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  199. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  200. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  201. string InvCode = queryParam["ClassCode"].ToString();
  202. string Colspan = "";
  203. string sqls = string.Empty;
  204. string LotNo = string.Empty;
  205. string str1 = "";
  206. List<string> ExtensionIDList = new List<string>();
  207. for (int i = 0; i < createPageCount; i++)
  208. {
  209. if (i + 1 == createPageCount)
  210. {
  211. if (minPackQty * createPageCount > thisCreateQty)
  212. {
  213. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  214. }
  215. }
  216. 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();
  217. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
  218. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  219. bool flag = true;
  220. foreach (var item in ExtensionIDList)
  221. {
  222. if (item == Colspan + WorkPoint)
  223. {
  224. flag = false;
  225. }
  226. }
  227. if (ExtensionID == null && flag == true)
  228. {
  229. str1 = Guid.NewGuid().ToString();
  230. 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)
  231. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  232. str1, 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(),
  233. MUSER, MUSERNAME, WorkPoints);
  234. }
  235. else if (ExtensionID != null)
  236. {
  237. str1 = ExtensionID.ToString();
  238. }
  239. ExtensionIDList.Add(Colspan + WorkPoint);
  240. //传过来的参数判断是否是奥美的项目奥美项目执行独有生成条码规则
  241. if (AMEnable == "true")
  242. {
  243. LotNo = SqlHelper.GetLOTNumber(InvCode,WorkPoint);
  244. }
  245. else
  246. {
  247. LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  248. }
  249. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  250. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  251. LotNo, ApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  252. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  253. //{
  254. sql += string.Format(@"insert into ICSInventoryLot
  255. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount
  256. ,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,EATTRIBUTE9,EATTRIBUTE10)
  257. select
  258. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','1','{3}','{4}', getdate(),'{5}','{9}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}'
  259. from ICSMOApplyNegDetail where ApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  260. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ApplyNegCode, Sequence, str1, Convert.ToDecimal( Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY)/ minPackQty* LOTQTY, queryParam["ExpirationDate"].ToString()
  261. , queryParam["EATTRIBUTE1"].ToString(), queryParam["EATTRIBUTE2"].ToString(), queryParam["EATTRIBUTE3"].ToString(), queryParam["EATTRIBUTE4"].ToString(), queryParam["EATTRIBUTE5"].ToString(),
  262. queryParam["EATTRIBUTE6"].ToString(), queryParam["EATTRIBUTE7"].ToString(), queryParam["EATTRIBUTE8"].ToString(), queryParam["EATTRIBUTE9"].ToString(), queryParam["EATTRIBUTE10"].ToString());
  263. sql += "\r\n";
  264. //}
  265. }
  266. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  267. return count;
  268. }
  269. public string GetSerialCode(string workPointCode, string tbName, string colName, string Pre, int numLen)
  270. {
  271. string sql = "EXEC Addins_GetSerialCode '{0}','{1}','{2}','{3}',{4}";
  272. sql = string.Format(sql, new object[] { workPointCode, tbName, colName, Pre, numLen });
  273. //return Repository().FindTableBySql(sql.ToString());
  274. return SqlHelper.ExecuteScalar(sql).ToString();
  275. //return DbHelper.ExecuteScalar(CommandType.Text, sql).ToString();
  276. }
  277. /// <summary>
  278. /// 删除条码
  279. /// </summary>
  280. /// <param name="keyValue"></param>
  281. /// <returns></returns>
  282. public string DeleteItemLot(string keyValue)
  283. {
  284. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  285. string msg = string.Empty;
  286. string sql = string.Format(@"SELECT * FROM dbo.ICSInspection
  287. WHERE LotNo IN (SELECT LotNO FROM dbo.ICSInventoryLot WHERE ID IN ({0})) and WorkPoint in ('{1}')", keyValue.TrimEnd(','), WorkPoint);
  288. DataTable dtASN = SqlHelper.GetDataTableBySql(sql);
  289. if (dtASN != null && dtASN.Rows.Count > 0)
  290. {
  291. msg = "所选条码已生成检验单,无法删除!";
  292. }
  293. sql = string.Format(@"SELECT * FROM dbo.ICSWareHouseLotInfo WHERE LotNO IN
  294. (SELECT LotNO FROM dbo.ICSInventoryLot WHERE ID IN ({0})) and WorkPoint in ('{1}')", keyValue.TrimEnd(','), WorkPoint);
  295. DataTable dtCarton = SqlHelper.GetDataTableBySql(sql);
  296. if (dtCarton != null && dtCarton.Rows.Count > 0)
  297. {
  298. msg += "所选条码已入库,无法删除!";
  299. }
  300. if (string.IsNullOrEmpty(msg))
  301. {
  302. 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);
  303. sqls += string.Format("DELETE FROM dbo.ICSInventoryLot WHERE ID IN ({0}) and WorkPoint in ('{1}')", keyValue.TrimEnd(','), WorkPoint);
  304. SqlHelper.CmdExecuteNonQueryLi(sqls);
  305. }
  306. return msg;
  307. }
  308. public DataTable GetGridJsonWeiWai(string queryJson, ref Pagination jqgridparam)
  309. {
  310. DataTable dt = new DataTable();
  311. var queryParam = queryJson.ToJObject();
  312. List<DbParameter> parameter = new List<DbParameter>();
  313. object Figure = GetDecimalDigits();
  314. #region [SQL]
  315. string sql = @"select a.ID,a.OApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit, CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity
  316. ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount , CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as IssueNegQuantity,a.ExtensionID,a.MUSERName,a.MTIME ,
  317. CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  318. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  319. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  320. a.EATTRIBUTE9,a.EATTRIBUTE10
  321. from ICSOApplyNegDetail a
  322. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  323. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  324. left join (
  325. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  326. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='2'
  327. where isnull(ee.EATTRIBUTE1,'')=''
  328. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  329. )c
  330. on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  331. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  332. WHERE d.Type='1' ";
  333. sql = string.Format(sql, Figure);
  334. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  335. #endregion
  336. if (!string.IsNullOrWhiteSpace(queryJson))
  337. {
  338. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  339. {
  340. sql += " and a.OApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  341. }
  342. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  343. {
  344. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  345. }
  346. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  347. {
  348. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  349. }
  350. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  351. {
  352. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  353. }
  354. if (!string.IsNullOrWhiteSpace(queryParam["POStatus"].ToString()))
  355. {
  356. string POStatus = queryParam["POStatus"].ToString();
  357. if (POStatus == "0")
  358. {
  359. //sql += " and a.Quantity=ISNULL(c.LotQty,0)";
  360. }
  361. else if (POStatus == "1")
  362. {
  363. sql += " and a.Quantity-ISNULL(c.LOTQTY,0)=0";
  364. }
  365. else
  366. {
  367. sql += " and a.Quantity-ISNULL(c.LOTQTY,0)<>0";
  368. }
  369. }
  370. }
  371. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  372. {
  373. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  374. }
  375. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  376. {
  377. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  378. }
  379. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  380. }
  381. public DataTable GetSubGridJsonWeiWai(string OApplyNegCode, string Sequence, ref Pagination jqgridparam)
  382. {
  383. DataTable dt = new DataTable();
  384. object Figure = GetDecimalDigits();
  385. //var queryParam = queryJson.ToJObject();
  386. List<DbParameter> parameter = new List<DbParameter>();
  387. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  388. string sql = @" select c.TransCode,c.TransSequence ,a.ID,a.LotNo,CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity from ICSInventoryLot a
  389. left join (select count(LotNo) LotNoCount,LotNo,WorkPoint from ICSWareHouseLotInfo
  390. group by LotNo,WorkPoint)b on a.LotNo=b.LotNo and a.WorkPoint=b.WorkPoint
  391. left join ICSInventoryLotDetail c on a.LotNo=c.LotNo
  392. WHERE c.TransCode='" + OApplyNegCode + "' and c.TransSequence='" + Sequence + "' and a.WorkPoint in (" + WorkPoint + ")";
  393. sql = string.Format(sql, Figure);
  394. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  395. }
  396. /// <summary>
  397. /// 点击委外退料生成条码
  398. /// </summary>
  399. public DataTable GetSubGridJsonWeiWaiByCreate(string OApplyNegCode, string Sequence, string WorkPoint)
  400. {
  401. DataTable dt = new DataTable();
  402. object Figure = GetDecimalDigits();
  403. List<DbParameter> parameter = new List<DbParameter>();
  404. string sql = @"select a.InvCode,b.InvName,b.ClassCode,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  405. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  406. ,e.ProjectCode,e.BatchCode,e.Version,e.Brand,e.cFree1,e.cFree2,e.cFree3,e.cFree4,e.cFree5,e.cFree6,e.cFree7,e.cFree8,e.cFree9,e.cFree10
  407. from ICSOApplyNegDetail a
  408. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  409. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  410. left join (
  411. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  412. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo and a.Type='2'
  413. where isnull(a.EATTRIBUTE1,'')=''
  414. group by b.TransCode,b.TransSequence
  415. ) c on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  416. left join ICSExtension e on a.ExtensionID=e.ID and a.WorkPoint=e.WorkPoint
  417. WHERE d.Type='1'
  418. and a.OApplyNegCode='" + OApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  419. sql += " and a.WorkPoint='" + WorkPoint + "'";
  420. sql = string.Format(sql, Figure);
  421. return Repository().FindTableBySql(sql.ToString());
  422. }
  423. /// <summary>
  424. /// 委外退料生成条码
  425. /// </summary>
  426. /// <param name="POCode"></param>
  427. /// <param name="PORow"></param>
  428. /// <param name="keyValue"></param>
  429. /// 已改
  430. /// <returns></returns>
  431. public int SubmitFormWeiWai(string OApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  432. {
  433. var queryParam = keyValue.ToJObject();
  434. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  435. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  436. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  437. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  438. decimal LOTQTY = minPackQty;
  439. string Pre = "OI" + OApplyNegCode + (Convert.ToInt32(Sequence)).ToString("D4");
  440. string sql = string.Empty;
  441. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  442. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  443. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  444. string sqls = string.Empty;
  445. string Colspan = "";
  446. List<string> ExtensionIDList = new List<string>();
  447. string str1 = "";
  448. for (int i = 0; i < createPageCount; i++)
  449. {
  450. if (i + 1 == createPageCount)
  451. {
  452. if (minPackQty * createPageCount > thisCreateQty)
  453. {
  454. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  455. }
  456. }
  457. 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();
  458. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
  459. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  460. bool flag = true;
  461. foreach (var item in ExtensionIDList)
  462. {
  463. if (item == Colspan + WorkPoint)
  464. {
  465. flag = false;
  466. }
  467. }
  468. if (ExtensionID == null && flag == true)
  469. {
  470. str1 = Guid.NewGuid().ToString();
  471. 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)
  472. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  473. str1, 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. MUSER, MUSERNAME, WorkPoints);
  475. }
  476. else if (ExtensionID != null)
  477. {
  478. str1 = ExtensionID.ToString();
  479. }
  480. ExtensionIDList.Add(Colspan + WorkPoint);
  481. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  482. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  483. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  484. LotNo, OApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  485. sql += string.Format(@"insert into ICSInventoryLot
  486. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount
  487. ,EATTRIBUTE1,EATTRIBUTE2,,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,EATTRIBUTE9,EATTRIBUTE10)
  488. select
  489. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','2','{3}','{4}', getdate(),'{5}','{9}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}'
  490. from ICSOApplyNegDetail where OApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  491. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, OApplyNegCode, Sequence, str1, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString()
  492. , queryParam["EATTRIBUTE1"].ToString(), queryParam["EATTRIBUTE2"].ToString(), queryParam["EATTRIBUTE3"].ToString(), queryParam["EATTRIBUTE4"].ToString(), queryParam["EATTRIBUTE5"].ToString(),
  493. queryParam["EATTRIBUTE6"].ToString(), queryParam["EATTRIBUTE7"].ToString(), queryParam["EATTRIBUTE8"].ToString(), queryParam["EATTRIBUTE9"].ToString(), queryParam["EATTRIBUTE10"].ToString() );
  494. sql += "\r\n";
  495. }
  496. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  497. return count;
  498. }
  499. public DataTable GetGridJsonChengPing(string queryJson, ref Pagination jqgridparam)
  500. {
  501. DataTable dt = new DataTable();
  502. var queryParam = queryJson.ToJObject();
  503. List<DbParameter> parameter = new List<DbParameter>();
  504. object Figure = GetDecimalDigits();
  505. #region [SQL]
  506. string sql = @" select distinct a.ID, a.MODetailID,a.MOCode,a.Sequence, CAST(a.RCVQuantity AS DECIMAL(18,{0})) as RCVQuantity ,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount,a.StartDate
  507. ,a.DueDate,a.MOStatus,a.ExtensionID,a.MUSERName,a.MTIME ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY ,CAST( a.Quantity AS DECIMAL(18,{0})) -CAST(a.RCVQuantity AS DECIMAL(18,{0})) as ERPNum,a.MOMemo
  508. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  509. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  510. a.EATTRIBUTE9,a.EATTRIBUTE10
  511. from ICSMO a
  512. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  513. left join (
  514. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  515. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='3'
  516. where isnull(ee.EATTRIBUTE1,'')=''
  517. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  518. )c
  519. on a.MOCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  520. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint ";
  521. sql += " WHERE 1=1 and a.MOStatus<>'3' ";
  522. sql = string.Format(sql, Figure);
  523. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  524. #endregion
  525. if (!string.IsNullOrWhiteSpace(queryJson))
  526. {
  527. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  528. {
  529. sql += " and a.MOCode like '%" + queryParam["POCode"].ToString() + "%' ";
  530. }
  531. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  532. {
  533. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  534. }
  535. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  536. {
  537. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  538. }
  539. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  540. {
  541. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  542. }
  543. if (!string.IsNullOrWhiteSpace(queryParam["SelGDLX"].ToString()))
  544. {
  545. sql += " and a.MOType like '%" + queryParam["SelGDLX"].ToString() + "%' ";
  546. }
  547. if (!string.IsNullOrWhiteSpace(queryParam["POStatus"].ToString()))
  548. {
  549. string POStatus = queryParam["POStatus"].ToString();
  550. if (POStatus == "0")
  551. {
  552. //sql += " and a.Quantity=ISNULL(c.LotQty,0)";
  553. }
  554. else if (POStatus == "1")
  555. {
  556. sql += " and a.Quantity-ISNULL(c.LOTQTY,0)=0";
  557. }
  558. else
  559. {
  560. sql += " and a.Quantity-ISNULL(c.LOTQTY,0)>0";
  561. }
  562. }
  563. }
  564. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  565. {
  566. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  567. }
  568. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  569. {
  570. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  571. }
  572. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  573. }
  574. /// <summary>
  575. /// 点击成品生成条码(成品)
  576. /// </summary>
  577. public DataTable GetSubGridJsonChengPingByCreate(string MOCode, string Sequence, string WorkPoint)
  578. {
  579. DataTable dt = new DataTable();
  580. object Figure = GetDecimalDigits();
  581. List<DbParameter> parameter = new List<DbParameter>();
  582. string sql = @"select d.Enable, a.InvCode,b.ClassCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  583. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  584. ,e.ProjectCode,e.BatchCode,e.Version,e.Brand,e.cFree1,e.cFree2,e.cFree3,e.cFree4,e.cFree5,e.cFree6,e.cFree7,e.cFree8,e.cFree9,e.cFree10
  585. from ICSMO a
  586. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  587. left join (
  588. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  589. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo and a.Type='3'
  590. where isnull(a.EATTRIBUTE1,'')=''
  591. group by b.TransCode,b.TransSequence
  592. ) c on a.MOCode=c.TransCode and a.Sequence=c.TransSequence
  593. left join ICSConfiguration d on d.Code='CompleteVerification001' and a.WorkPoint =d.WorkPoint
  594. left join ICSExtension e on a.ExtensionID=e.ID and a.WorkPoint=e.WorkPoint
  595. WHERE 1 =1 and a.MOStatus<>'3'
  596. and a.MOCode='" + MOCode + "' and a.Sequence='" + Sequence + "'";
  597. sql += " and a.WorkPoint='" + WorkPoint + "'";
  598. sql = string.Format(sql, Figure);
  599. return Repository().FindTableBySql(sql.ToString());
  600. }
  601. /// <summary>
  602. /// 成品生成条码
  603. /// </summary>
  604. /// <param name="POCode"></param>
  605. /// <param name="PORow"></param>
  606. /// <param name="keyValue"></param>
  607. /// 已改
  608. /// <returns></returns>
  609. ///传过来的参数判断是否是奥美的项目奥美项目执行独有生成条码规则
  610. public int SubmitFormChengPing(string MOCode, string Sequence, string keyValue, string WorkPoint)
  611. {
  612. var queryParam = keyValue.ToJObject();
  613. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  614. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  615. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  616. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  617. decimal LOTQTY = minPackQty;
  618. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  619. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  620. string Pre = "CP" + MOCode + (Convert.ToInt32(Sequence)).ToString("D4");
  621. string sql = string.Empty;
  622. //string VendorLot = queryParam["VendorLot"].ToString();
  623. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  624. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  625. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  626. string InvCode = queryParam["ClassCode"].ToString();
  627. string sqls = string.Empty;
  628. string Colspan = "";
  629. string str1 = "";
  630. string LotNo = string.Empty;
  631. List<string> ExtensionIDList = new List<string>();
  632. for (int i = 0; i < createPageCount; i++)
  633. {
  634. if (i + 1 == createPageCount)
  635. {
  636. if (minPackQty * createPageCount > thisCreateQty)
  637. {
  638. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  639. }
  640. }
  641. 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();
  642. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
  643. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  644. bool flag = true;
  645. foreach (var item in ExtensionIDList)
  646. {
  647. if (item == Colspan + WorkPoint)
  648. {
  649. flag = false;
  650. }
  651. }
  652. if (ExtensionID == null && flag == true)
  653. {
  654. str1 = Guid.NewGuid().ToString();
  655. 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)
  656. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  657. str1, 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(),
  658. MUSER, MUSERNAME, WorkPoints);
  659. }
  660. else if (ExtensionID != null)
  661. {
  662. str1 = ExtensionID.ToString();
  663. }
  664. ExtensionIDList.Add(Colspan + WorkPoint);
  665. //传过来的参数判断是否是奥美的项目奥美项目执行独有生成条码规则
  666. //if (AMEnable == "true")
  667. //{
  668. // LotNo = SqlHelper.GetLOTNumber(InvCode, WorkPoint);
  669. //}vvv
  670. //else
  671. //{
  672. LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  673. //}
  674. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  675. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  676. LotNo, MOCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  677. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  678. //{
  679. sql += string.Format(@"insert into ICSInventoryLot
  680. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount
  681. ,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,EATTRIBUTE9,EATTRIBUTE10)
  682. select
  683. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','3','{3}','{4}', getdate(),'{5}','{9}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}'
  684. from ICSMO where MOCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  685. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, MOCode, Sequence, str1, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString()
  686. , queryParam["EATTRIBUTE1"].ToString(), queryParam["EATTRIBUTE2"].ToString(), queryParam["EATTRIBUTE3"].ToString(), queryParam["EATTRIBUTE4"].ToString(), queryParam["EATTRIBUTE5"].ToString(),
  687. queryParam["EATTRIBUTE6"].ToString(), queryParam["EATTRIBUTE7"].ToString(), queryParam["EATTRIBUTE8"].ToString(), queryParam["EATTRIBUTE9"].ToString(), queryParam["EATTRIBUTE10"].ToString());
  688. sql += "\r\n";
  689. //}
  690. }
  691. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  692. return count;
  693. }
  694. public DataTable GetGridJsonXiaoShou(string queryJson, ref Pagination jqgridparam)
  695. {
  696. DataTable dt = new DataTable();
  697. var queryParam = queryJson.ToJObject();
  698. List<DbParameter> parameter = new List<DbParameter>();
  699. object Figure = GetDecimalDigits();
  700. #region [SQL]
  701. string sql = @" select a.ID,a.SDNCode,a.Sequence,a.SOCode,a.SOSequence,a.CusCode,a.CusName,a.Type,a.ArriveDate,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity
  702. ,cast(a.Amount as decimal(18,{0})) as Amount, CAST(a.SDNQuantity AS DECIMAL(18,{0})) as SDNQuantity ,a.Status,a.ExtensionID,a.CreatePerson,a.CreateDateTime ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  703. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  704. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  705. a.EATTRIBUTE9,a.EATTRIBUTE10
  706. from ICSSDN a
  707. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  708. left join (
  709. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  710. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='4'
  711. where isnull(ee.EATTRIBUTE1,'')=''
  712. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  713. )c
  714. on a.SDNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  715. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  716. where a.Type='2'";
  717. sql = string.Format(sql, Figure);
  718. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  719. #endregion
  720. if (!string.IsNullOrWhiteSpace(queryJson))
  721. {
  722. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  723. {
  724. sql += " and a.SDNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  725. }
  726. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  727. {
  728. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  729. }
  730. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  731. {
  732. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  733. }
  734. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  735. {
  736. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  737. }
  738. if (!string.IsNullOrWhiteSpace(queryParam["POStatus"].ToString()))
  739. {
  740. string POStatus = queryParam["POStatus"].ToString();
  741. if (POStatus == "0")
  742. {
  743. //sql += " and a.Quantity=ISNULL(c.LotQty,0)";
  744. }
  745. else if (POStatus == "1")
  746. {
  747. sql += " and a.Quantity-ISNULL(c.LOTQTY,0)=0";
  748. }
  749. else
  750. {
  751. sql += " and a.Quantity-ISNULL(c.LOTQTY,0)<>0";
  752. }
  753. }
  754. }
  755. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  756. {
  757. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  758. }
  759. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  760. {
  761. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  762. }
  763. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  764. }
  765. /// <summary>
  766. /// 点击销售退货生成条码(销售退货)
  767. /// </summary>
  768. public DataTable GetSubGridJsonXiaoShouByCreate(string SDNCode, string Sequence, string WorkPoint)
  769. {
  770. DataTable dt = new DataTable();
  771. object Figure = GetDecimalDigits();
  772. List<DbParameter> parameter = new List<DbParameter>();
  773. string sql = @"select a.InvCode,b.InvName,b.ClassCode,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  774. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  775. ,d.ProjectCode,d.BatchCode,d.Version,d.Brand,d.cFree1,d.cFree2,d.cFree3,d.cFree4,d.cFree5,d.cFree6,d.cFree7,d.cFree8,d.cFree9,d.cFree10
  776. from ICSSDN a
  777. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  778. left join (
  779. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  780. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo and a.Type='4'
  781. where isnull(a.EATTRIBUTE1,'')=''
  782. group by b.TransCode,b.TransSequence
  783. ) c on a.SDNCode=c.TransCode and a.Sequence=c.TransSequence
  784. left join ICSExtension d on a.ExtensionID=d.ID and a.WorkPoint=d.WorkPoint
  785. WHERE 1 =1
  786. and a.Type='2' and a.SDNCode='" + SDNCode + "' and a.Sequence='" + Sequence + "'";
  787. sql += " and a.WorkPoint='" + WorkPoint + "'";
  788. sql = string.Format(sql, Figure);
  789. return Repository().FindTableBySql(sql.ToString());
  790. }
  791. /// <summary>
  792. /// 销售退货生成条码
  793. /// </summary>
  794. /// <param name="POCode"></param>
  795. /// <param name="PORow"></param>
  796. /// <param name="keyValue"></param>
  797. /// 已改
  798. /// <returns></returns>
  799. public int SubmitFormXiaoShou(string SDNCode, string Sequence, string keyValue, string WorkPoint,string AMEnable)
  800. {
  801. var queryParam = keyValue.ToJObject();
  802. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  803. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  804. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  805. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  806. decimal LOTQTY = minPackQty;
  807. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  808. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  809. string Pre = "SR" + SDNCode + (Convert.ToInt32(Sequence)).ToString("D4");
  810. string sql = string.Empty;
  811. //string VendorLot = queryParam["VendorLot"].ToString();
  812. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  813. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  814. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  815. string InvCode = queryParam["ClassCode"].ToString();
  816. string sqls = string.Empty;
  817. string Colspan = "";
  818. string str1 = "";
  819. string LotNo = string.Empty;
  820. List<string> ExtensionIDList = new List<string>();
  821. for (int i = 0; i < createPageCount; i++)
  822. {
  823. if (i + 1 == createPageCount)
  824. {
  825. if (minPackQty * createPageCount > thisCreateQty)
  826. {
  827. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  828. }
  829. }
  830. 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();
  831. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
  832. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  833. bool flag = true;
  834. foreach (var item in ExtensionIDList)
  835. {
  836. if (item == Colspan + WorkPoint)
  837. {
  838. flag = false;
  839. }
  840. }
  841. if (ExtensionID == null && flag == true)
  842. {
  843. str1 = Guid.NewGuid().ToString();
  844. 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)
  845. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  846. str1, 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(),
  847. MUSER, MUSERNAME, WorkPoints);
  848. }
  849. else if (ExtensionID != null)
  850. {
  851. str1 = ExtensionID.ToString();
  852. }
  853. ExtensionIDList.Add(Colspan + WorkPoint);
  854. //传过来的参数判断是否是奥美的项目奥美项目执行独有生成条码规则
  855. if (AMEnable == "true")
  856. {
  857. LotNo = SqlHelper.GetLOTNumber(InvCode, WorkPoint);
  858. }
  859. else
  860. {
  861. LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  862. }
  863. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  864. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}')",
  865. LotNo, SDNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  866. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  867. //{
  868. sql += string.Format(@"
  869. insert into ICSInventoryLot
  870. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount ,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,EATTRIBUTE9,EATTRIBUTE10)
  871. select
  872. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','4','{3}','{4}', getdate(),'{5}','{9}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}'
  873. from ICSSDN where Type='2' and SDNCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  874. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, SDNCode, Sequence, str1, Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY, queryParam["ExpirationDate"].ToString()
  875. , queryParam["EATTRIBUTE1"].ToString(), queryParam["EATTRIBUTE2"].ToString(), queryParam["EATTRIBUTE3"].ToString(), queryParam["EATTRIBUTE4"].ToString(), queryParam["EATTRIBUTE5"].ToString(),
  876. queryParam["EATTRIBUTE6"].ToString(), queryParam["EATTRIBUTE7"].ToString(), queryParam["EATTRIBUTE8"].ToString(), queryParam["EATTRIBUTE9"].ToString(), queryParam["EATTRIBUTE10"].ToString());
  877. sql += "\r\n";
  878. //}
  879. }
  880. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  881. return count;
  882. }
  883. public DataTable GetGridJsonQiTa(string queryJson, ref Pagination jqgridparam)
  884. {
  885. DataTable dt = new DataTable();
  886. var queryParam = queryJson.ToJObject();
  887. List<DbParameter> parameter = new List<DbParameter>();
  888. object Figure = GetDecimalDigits();
  889. #region [SQL]
  890. string sql = @" select a.ID,a.InCode,a.Sequence,a.WHCode,a.InvCode, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,
  891. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST(a.Amount AS DECIMAL(18,{0})) as Amount, CAST(a.InQuantity AS DECIMAL(18,{0})) as InQuantity,a.CreatePerson,a.CreateDateTime,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  892. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  893. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  894. a.EATTRIBUTE9,a.EATTRIBUTE10
  895. from ICSOtherIn a
  896. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  897. left join (
  898. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  899. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='5'
  900. where isnull(ee.EATTRIBUTE1,'')=''
  901. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  902. )c
  903. on a.InCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  904. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  905. where a.Status='1'";
  906. sql = string.Format(sql, Figure);
  907. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  908. #endregion
  909. if (!string.IsNullOrWhiteSpace(queryJson))
  910. {
  911. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  912. {
  913. sql += " and a.InCode like '%" + queryParam["POCode"].ToString() + "%' ";
  914. }
  915. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  916. {
  917. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  918. }
  919. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  920. {
  921. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  922. }
  923. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  924. {
  925. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  926. }
  927. if (!string.IsNullOrWhiteSpace(queryParam["POStatus"].ToString()))
  928. {
  929. string POStatus = queryParam["POStatus"].ToString();
  930. if (POStatus == "0")
  931. {
  932. //sql += " and a.Quantity=ISNULL(c.LotQty,0)";
  933. }
  934. else if (POStatus == "1")
  935. {
  936. sql += " and a.Quantity-ISNULL(c.LOTQTY,0)=0";
  937. }
  938. else
  939. {
  940. sql += " and a.Quantity-ISNULL(c.LOTQTY,0)<>0";
  941. }
  942. }
  943. }
  944. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  945. {
  946. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  947. }
  948. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  949. {
  950. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  951. }
  952. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  953. }
  954. /// <summary>
  955. /// 点击销售退货生成条码(其他入库)
  956. /// </summary>
  957. public DataTable GetSubGridJsonQiTaByCreate(string InCode, string Sequence, string WorkPoint)
  958. {
  959. DataTable dt = new DataTable();
  960. object Figure = GetDecimalDigits();
  961. List<DbParameter> parameter = new List<DbParameter>();
  962. string sql = @"select a.InvCode,b.InvName,b.ClassCode,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  963. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  964. ,d.ProjectCode,d.BatchCode,d.Version,d.Brand,d.cFree1,d.cFree2,d.cFree3,d.cFree4,d.cFree5,d.cFree6,d.cFree7,d.cFree8,d.cFree9,d.cFree10
  965. from ICSOtherIn a
  966. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  967. left join (
  968. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  969. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo and a.Type='5'
  970. where isnull(a.EATTRIBUTE1,'')=''
  971. group by b.TransCode,b.TransSequence
  972. ) c on a.InCode=c.TransCode and a.Sequence=c.TransSequence
  973. left join ICSExtension d on a.ExtensionID=d.ID and a.WorkPoint=d.WorkPoint
  974. WHERE 1 =1
  975. and a.InCode='" + InCode + "' and a.Sequence='" + Sequence + "'";
  976. sql += " and a.WorkPoint='" + WorkPoint + "'";
  977. sql = string.Format(sql, Figure);
  978. return Repository().FindTableBySql(sql.ToString());
  979. }
  980. /// <summary>
  981. /// 其他入库生成条码
  982. /// </summary>
  983. /// <param name="POCode"></param>
  984. /// <param name="PORow"></param>
  985. /// <param name="keyValue"></param>
  986. /// 已改
  987. /// <returns></returns>
  988. public int SubmitFormQiTa(string InCode, string Sequence, string keyValue, string WorkPoint,string AMEnable)
  989. {
  990. var queryParam = keyValue.ToJObject();
  991. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  992. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  993. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  994. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  995. decimal LOTQTY = minPackQty;
  996. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  997. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  998. string Pre = "QT" + InCode + (Convert.ToInt32(Sequence)).ToString("D4");
  999. string sql = string.Empty;
  1000. //string VendorLot = queryParam["VendorLot"].ToString();
  1001. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1002. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1003. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1004. string InvCode = queryParam["ClassCode"].ToString();
  1005. string sqls = string.Empty;
  1006. string Colspan = "";
  1007. string str1 = "";
  1008. string LotNo = string.Empty;
  1009. List<string> ExtensionIDList = new List<string>();
  1010. for (int i = 0; i < createPageCount; i++)
  1011. {
  1012. if (i + 1 == createPageCount)
  1013. {
  1014. if (minPackQty * createPageCount > thisCreateQty)
  1015. {
  1016. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1017. }
  1018. }
  1019. 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();
  1020. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
  1021. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1022. bool flag = true;
  1023. foreach (var item in ExtensionIDList)
  1024. {
  1025. if (item == Colspan + WorkPoint)
  1026. {
  1027. flag = false;
  1028. }
  1029. }
  1030. if (ExtensionID == null && flag == true)
  1031. {
  1032. str1 = Guid.NewGuid().ToString();
  1033. 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)
  1034. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1035. str1, 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(),
  1036. MUSER, MUSERNAME, WorkPoints);
  1037. }
  1038. else if (ExtensionID != null)
  1039. {
  1040. str1 = ExtensionID.ToString();
  1041. }
  1042. ExtensionIDList.Add(Colspan + WorkPoint);
  1043. //传过来的参数判断是否是奥美的项目奥美项目执行独有生成条码规则
  1044. if (AMEnable == "true")
  1045. {
  1046. LotNo = SqlHelper.GetLOTNumber(InvCode, WorkPoint);
  1047. }
  1048. else
  1049. {
  1050. LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1051. }
  1052. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1053. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1054. LotNo, InCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1055. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  1056. //{
  1057. sql += string.Format(@"
  1058. insert into ICSInventoryLot
  1059. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount
  1060. ,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,EATTRIBUTE9,EATTRIBUTE10)
  1061. select
  1062. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','5','{3}','{4}', getdate(),'{5}','{9}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}'
  1063. from ICSOtherIn where InCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  1064. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, InCode, Sequence, str1, Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY, queryParam["ExpirationDate"].ToString()
  1065. , queryParam["EATTRIBUTE1"].ToString(), queryParam["EATTRIBUTE2"].ToString(), queryParam["EATTRIBUTE3"].ToString(), queryParam["EATTRIBUTE4"].ToString(), queryParam["EATTRIBUTE5"].ToString(),
  1066. queryParam["EATTRIBUTE6"].ToString(), queryParam["EATTRIBUTE7"].ToString(), queryParam["EATTRIBUTE8"].ToString(), queryParam["EATTRIBUTE9"].ToString(), queryParam["EATTRIBUTE10"].ToString());
  1067. sql += "\r\n";
  1068. //}
  1069. }
  1070. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1071. return count;
  1072. }
  1073. //归还
  1074. public DataTable GetGridJsonGuiHuan(string queryJson, ref Pagination jqgridparam)
  1075. {
  1076. DataTable dt = new DataTable();
  1077. var queryParam = queryJson.ToJObject();
  1078. List<DbParameter> parameter = new List<DbParameter>();
  1079. object Figure = GetDecimalDigits();
  1080. #region [SQL]
  1081. string sql = @"select a.ID,a.ReturnCode,a.Sequence,a.WHCode,a.InvCode, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount, CAST(a.ReturnQuantity AS DECIMAL(18,{0})) as ReturnQuantity,a.CreatePerson,a.CreateDateTime,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  1082. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  1083. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  1084. a.EATTRIBUTE9,a.EATTRIBUTE10
  1085. from ICSReturn a
  1086. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1087. left join (
  1088. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1089. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='6'
  1090. where isnull(ee.EATTRIBUTE1,'')=''
  1091. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1092. ) c on a.ReturnCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  1093. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1094. where a.Status='2'";
  1095. sql = string.Format(sql, Figure);
  1096. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  1097. #endregion
  1098. if (!string.IsNullOrWhiteSpace(queryJson))
  1099. {
  1100. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1101. {
  1102. sql += " and a.ReturnCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1103. }
  1104. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1105. {
  1106. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1107. }
  1108. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1109. {
  1110. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1111. }
  1112. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1113. {
  1114. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1115. }
  1116. if (!string.IsNullOrWhiteSpace(queryParam["POStatus"].ToString()))
  1117. {
  1118. string POStatus = queryParam["POStatus"].ToString();
  1119. if (POStatus == "0")
  1120. {
  1121. //sql += " and a.Quantity=ISNULL(c.LotQty,0)";
  1122. }
  1123. else if (POStatus == "1")
  1124. {
  1125. sql += " and a.Quantity-ISNULL(c.LOTQTY,0)=0";
  1126. }
  1127. else
  1128. {
  1129. sql += " and a.Quantity-ISNULL(c.LOTQTY,0)<>0";
  1130. }
  1131. }
  1132. }
  1133. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1134. {
  1135. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  1136. }
  1137. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1138. {
  1139. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1140. }
  1141. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1142. }
  1143. //审核到货单(采购订单需与审核到货单一起同步)
  1144. public DataTable GetGridJsonSHDH(string queryJson, ref Pagination jqgridparam)
  1145. {
  1146. DataTable dt = new DataTable();
  1147. var queryParam = queryJson.ToJObject();
  1148. List<DbParameter> parameter = new List<DbParameter>();
  1149. object Figure = GetDecimalDigits();
  1150. #region [SQL]
  1151. string sql = @"select distinct 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,
  1152. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.RCVQuantity AS DECIMAL(18,{0})) as RCVQuantity,CAST(a.UnitPrice AS DECIMAL(18,{0})) as UnitPrice,a.Currency,a.CreatePerson,a.CreateDateTime,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  1153. ,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  1154. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  1155. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  1156. a.EATTRIBUTE9,a.EATTRIBUTE10
  1157. from ICSDeliveryNotice a
  1158. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1159. left join (
  1160. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1161. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='7'
  1162. where isnull(ee.EATTRIBUTE1,'')=''
  1163. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1164. ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  1165. inner join ICSPurchaseOrder d on a.POID=d.POID and a.PODetailID=d.PODetailID and a.WorkPoint=d.WorkPoint
  1166. left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
  1167. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1168. where a.DNType='1' and a.Status='2' and a.ASNCode is null
  1169. ";
  1170. sql = string.Format(sql, Figure);
  1171. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  1172. #endregion
  1173. if (!string.IsNullOrWhiteSpace(queryJson))
  1174. {
  1175. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1176. {
  1177. sql += " and a.DNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1178. }
  1179. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  1180. {
  1181. sql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  1182. }
  1183. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  1184. {
  1185. sql += " and e.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  1186. }
  1187. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1188. {
  1189. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1190. }
  1191. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1192. {
  1193. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1194. }
  1195. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1196. {
  1197. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1198. }
  1199. if (!string.IsNullOrWhiteSpace(queryParam["POStatus"].ToString()))
  1200. {
  1201. string POStatus = queryParam["POStatus"].ToString();
  1202. if (POStatus == "0")
  1203. {
  1204. //sql += " and a.Quantity=ISNULL(c.LotQty,0)";
  1205. }
  1206. else if (POStatus == "1")
  1207. {
  1208. sql += " and a.Quantity-ISNULL(c.LOTQTY,0)=0";
  1209. }
  1210. else
  1211. {
  1212. sql += " and a.Quantity-ISNULL(c.LOTQTY,0)<>0";
  1213. }
  1214. }
  1215. }
  1216. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1217. {
  1218. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  1219. }
  1220. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1221. {
  1222. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1223. }
  1224. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1225. }
  1226. //审核委外到货单
  1227. public DataTable GetGridJsonWWSHDH(string queryJson, ref Pagination jqgridparam)
  1228. {
  1229. DataTable dt = new DataTable();
  1230. var queryParam = queryJson.ToJObject();
  1231. List<DbParameter> parameter = new List<DbParameter>();
  1232. object Figure = GetDecimalDigits();
  1233. #region [SQL]
  1234. string sql = @"select a.ID, d.OOCode,d.Sequence as OOSequence,a.ODNCode,a.Sequence,a.VenCode,e.VenName,a.InvCode, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.RCVQuantity AS DECIMAL(18,{0})) as RCVQuantity,CAST(a.UnitPrice AS DECIMAL(18,{0})) as UnitPrice,a.Currency,a.CreatePerson,a.CreateDateTime,
  1235. CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY ,d.OODetailID ,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  1236. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  1237. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10 ,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  1238. a.EATTRIBUTE9,a.EATTRIBUTE10
  1239. from ICSODeliveryNotice a
  1240. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1241. left join (
  1242. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1243. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='8'
  1244. where isnull(ee.EATTRIBUTE1,'')=''
  1245. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1246. ) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  1247. inner join ICSOutsourcingOrder d on a.OOID=d.OOID and a.OODetailID=d.OODetailID and a.WorkPoint=d.WorkPoint
  1248. left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
  1249. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1250. where a.ODNType='1' and a.Status='2' and a.OASNCode is null";
  1251. sql = string.Format(sql, Figure);
  1252. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  1253. #endregion
  1254. if (!string.IsNullOrWhiteSpace(queryJson))
  1255. {
  1256. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1257. {
  1258. sql += " and a.ODNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1259. }
  1260. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  1261. {
  1262. sql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  1263. }
  1264. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  1265. {
  1266. sql += " and e.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  1267. }
  1268. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1269. {
  1270. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1271. }
  1272. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1273. {
  1274. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1275. }
  1276. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1277. {
  1278. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1279. }
  1280. if (!string.IsNullOrWhiteSpace(queryParam["POStatus"].ToString()))
  1281. {
  1282. string POStatus = queryParam["POStatus"].ToString();
  1283. if (POStatus == "0")
  1284. {
  1285. //sql += " and a.Quantity=ISNULL(c.LotQty,0)";
  1286. }
  1287. else if (POStatus == "1")
  1288. {
  1289. sql += " and a.Quantity-ISNULL(c.LOTQTY,0)=0";
  1290. }
  1291. else
  1292. {
  1293. sql += " and a.Quantity-ISNULL(c.LOTQTY,0)<>0";
  1294. }
  1295. }
  1296. }
  1297. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1298. {
  1299. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  1300. }
  1301. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1302. {
  1303. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1304. }
  1305. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1306. }
  1307. //开立得成品入库单
  1308. public DataTable GetGridJsonKLCPRK(string queryJson, ref Pagination jqgridparam)
  1309. {
  1310. DataTable dt = new DataTable();
  1311. var queryParam = queryJson.ToJObject();
  1312. List<DbParameter> parameter = new List<DbParameter>();
  1313. object Figure = GetDecimalDigits();
  1314. #region [SQL]
  1315. string sql = @"
  1316. select a.ID,a.RCVCode,a.Sequence,a.WHCode,a.InvCode, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,
  1317. CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.RCVQuantity AS DECIMAL(18,{0})) as RCVQuantity ,a.CreatePerson,a.CreateDateTime,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  1318. ,b.EffectiveEnable,b.EffectiveDays
  1319. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  1320. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  1321. a.EATTRIBUTE9,a.EATTRIBUTE10
  1322. from ICSManufactureReceive a
  1323. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1324. left join (
  1325. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1326. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='9'
  1327. where isnull(ee.EATTRIBUTE1,'')=''
  1328. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1329. ) c on a.RCVCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  1330. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1331. where a.Status='1' and a.Type='1'";
  1332. sql = string.Format(sql, Figure);
  1333. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  1334. #endregion
  1335. if (!string.IsNullOrWhiteSpace(queryJson))
  1336. {
  1337. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1338. {
  1339. sql += " and a.RCVCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1340. }
  1341. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1342. {
  1343. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1344. }
  1345. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1346. {
  1347. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1348. }
  1349. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1350. {
  1351. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1352. }
  1353. if (!string.IsNullOrWhiteSpace(queryParam["POStatus"].ToString()))
  1354. {
  1355. string POStatus = queryParam["POStatus"].ToString();
  1356. if (POStatus == "0")
  1357. {
  1358. //sql += " and a.Quantity=ISNULL(c.LotQty,0)";
  1359. }
  1360. else if (POStatus == "1")
  1361. {
  1362. sql += " and a.Quantity-ISNULL(c.LOTQTY,0)=0";
  1363. }
  1364. else
  1365. {
  1366. sql += " and a.Quantity-ISNULL(c.LOTQTY,0)<>0";
  1367. }
  1368. }
  1369. }
  1370. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1371. {
  1372. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  1373. }
  1374. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1375. {
  1376. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1377. }
  1378. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1379. }
  1380. /// <summary>
  1381. /// 点击审核委外到货单生成条码(审核委外到货单)
  1382. /// </summary>
  1383. public DataTable GetSubGridJsonWWSHDHByCreate(string ODNCode, string Sequence, string WorkPoint)
  1384. {
  1385. DataTable dt = new DataTable();
  1386. object Figure = GetDecimalDigits();
  1387. List<DbParameter> parameter = new List<DbParameter>();
  1388. string sql = @"select e.Enable, a.InvCode,b.InvName,b.ClassCode,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  1389. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  1390. ,d.ProjectCode,d.BatchCode,d.Version,d.Brand,d.cFree1,d.cFree2,d.cFree3,d.cFree4,d.cFree5,d.cFree6,d.cFree7,d.cFree8,d.cFree9,d.cFree10
  1391. from ICSODeliveryNotice a
  1392. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1393. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1394. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo and a.Type='8'
  1395. where isnull(a.EATTRIBUTE1,'')=''
  1396. group by b.TransCode,b.TransSequence
  1397. ) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence
  1398. left join ICSConfiguration e on e.Code='CompleteVerification002' and a.WorkPoint =e.WorkPoint
  1399. left join ICSExtension d on a.ExtensionID=d.ID and a.WorkPoint=d.WorkPoint
  1400. WHERE 1 =1
  1401. and a.ODNCode='" + ODNCode + "' and a.Sequence='" + Sequence + "'";
  1402. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1403. sql = string.Format(sql, Figure);
  1404. return Repository().FindTableBySql(sql.ToString());
  1405. }
  1406. /// <summary>
  1407. /// 点击开立成品入库生成条码(开立成品入库单)
  1408. /// </summary>
  1409. /// //--
  1410. public DataTable GetSubGridJsonKLCPRKByCreate(string RCVCode, string Sequence, string WorkPoint)
  1411. {
  1412. DataTable dt = new DataTable();
  1413. object Figure = GetDecimalDigits();
  1414. List<DbParameter> parameter = new List<DbParameter>();
  1415. string sql = @"select a.InvCode,b.InvName,b.ClassCode,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  1416. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  1417. ,d.ProjectCode,d.BatchCode,d.Version,d.Brand,d.cFree1,d.cFree2,d.cFree3,d.cFree4,d.cFree5,d.cFree6,d.cFree7,d.cFree8,d.cFree9,d.cFree10
  1418. from ICSManufactureReceive a
  1419. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1420. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1421. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo and a.Type='9'
  1422. where isnull(a.EATTRIBUTE1,'')=''
  1423. group by b.TransCode,b.TransSequence
  1424. ) c on a.RCVCode=c.TransCode and a.Sequence=c.TransSequence
  1425. left join ICSExtension d on a.ExtensionID=d.ID and a.WorkPoint=d.WorkPoint
  1426. WHERE 1 =1
  1427. and a.RCVCode='" + RCVCode + "' and a.Sequence='" + Sequence + "'";
  1428. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1429. sql = string.Format(sql, Figure);
  1430. return Repository().FindTableBySql(sql.ToString());
  1431. }
  1432. /// <summary>
  1433. /// 点击审核到货单生成条码(审核到货单)
  1434. /// </summary>
  1435. public DataTable GetSubGridJsonSHDHByCreate(string DNCode, string Sequence, string WorkPoint)
  1436. {
  1437. DataTable dt = new DataTable();
  1438. object Figure = GetDecimalDigits();
  1439. List<DbParameter> parameter = new List<DbParameter>();
  1440. string sql = @"select a.InvCode,b.InvName,b.ClassCode,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  1441. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  1442. ,d.ProjectCode,d.BatchCode,d.Version,d.Brand,d.cFree1,d.cFree2,d.cFree3,d.cFree4,d.cFree5,d.cFree6,d.cFree7,d.cFree8,d.cFree9,d.cFree10
  1443. from ICSDeliveryNotice a
  1444. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1445. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1446. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo and a.Type='7'
  1447. where isnull(a.EATTRIBUTE1,'')=''
  1448. group by b.TransCode,b.TransSequence
  1449. ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence
  1450. left join ICSExtension d on a.ExtensionID=d.ID and a.WorkPoint=d.WorkPoint
  1451. WHERE 1 =1
  1452. and a.DNCode='" + DNCode + "' and a.Sequence='" + Sequence + "'";
  1453. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1454. sql = string.Format(sql, Figure);
  1455. return Repository().FindTableBySql(sql.ToString());
  1456. }
  1457. /// <summary>
  1458. /// 点击归还生成条码(归还)
  1459. /// </summary>
  1460. public DataTable GetSubGridJsonGuiHuanByCreate(string ReturnCode, string Sequence, string WorkPoint)
  1461. {
  1462. DataTable dt = new DataTable();
  1463. object Figure = GetDecimalDigits();
  1464. List<DbParameter> parameter = new List<DbParameter>();
  1465. string sql = @"select a.InvCode,b.InvName,b.ClassCode,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  1466. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  1467. ,d.ProjectCode,d.BatchCode,d.Version,d.Brand,d.cFree1,d.cFree2,d.cFree3,d.cFree4,d.cFree5,d.cFree6,d.cFree7,d.cFree8,d.cFree9,d.cFree10
  1468. from ICSReturn a
  1469. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1470. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1471. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo and a.Type='6'
  1472. where isnull(a.EATTRIBUTE1,'')=''
  1473. group by b.TransCode,b.TransSequence
  1474. ) c on a.ReturnCode=c.TransCode and a.Sequence=c.TransSequence
  1475. left join ICSExtension d on a.ExtensionID=d.ID and a.WorkPoint=d.WorkPoint
  1476. WHERE 1 =1
  1477. and a.ReturnCode='" + ReturnCode + "' and a.Sequence='" + Sequence + "'";
  1478. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1479. sql = string.Format(sql, Figure);
  1480. return Repository().FindTableBySql(sql.ToString());
  1481. }
  1482. /// <summary>
  1483. /// 归还单生成条码
  1484. /// </summary>
  1485. /// <param name="POCode"></param>
  1486. /// <param name="PORow"></param>
  1487. /// <param name="keyValue"></param>
  1488. /// 已改
  1489. /// <returns></returns>
  1490. public int SubmitFormGuiHuan(string ReturnCode, string Sequence, string keyValue, string WorkPoint)
  1491. {
  1492. var queryParam = keyValue.ToJObject();
  1493. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1494. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1495. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1496. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1497. decimal LOTQTY = minPackQty;
  1498. string Pre = "GH" + ReturnCode + (Convert.ToInt32(Sequence)).ToString("D4");
  1499. string sql = string.Empty;
  1500. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1501. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1502. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1503. string sqls = string.Empty;
  1504. string Colspan = "";
  1505. string str1="";
  1506. List<string> ExtensionIDList = new List<string>();
  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}' and WorkPoint='{1}'", Colspan, WorkPoint);
  1518. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1519. bool flag = true;
  1520. foreach (var item in ExtensionIDList)
  1521. {
  1522. if (item == Colspan + WorkPoint)
  1523. {
  1524. flag = false;
  1525. }
  1526. }
  1527. if (ExtensionID == null && flag == true)
  1528. {
  1529. str1 = Guid.NewGuid().ToString();
  1530. 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)
  1531. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1532. str1, 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(),
  1533. MUSER, MUSERNAME, WorkPoints);
  1534. }
  1535. else if (ExtensionID != null)
  1536. {
  1537. str1 = ExtensionID.ToString();
  1538. }
  1539. ExtensionIDList.Add(Colspan + WorkPoint);
  1540. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1541. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1542. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1543. LotNo, ReturnCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1544. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  1545. //{
  1546. sql += string.Format(@"
  1547. insert into ICSInventoryLot
  1548. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount ,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,EATTRIBUTE9,EATTRIBUTE10)
  1549. select
  1550. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','6','{3}','{4}', getdate(),'{5}','{9}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}'
  1551. from ICSReturn where ReturnCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  1552. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ReturnCode, Sequence, str1, Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY, queryParam["ExpirationDate"].ToString()
  1553. , queryParam["EATTRIBUTE1"].ToString(), queryParam["EATTRIBUTE2"].ToString(), queryParam["EATTRIBUTE3"].ToString(), queryParam["EATTRIBUTE4"].ToString(), queryParam["EATTRIBUTE5"].ToString(),
  1554. queryParam["EATTRIBUTE6"].ToString(), queryParam["EATTRIBUTE7"].ToString(), queryParam["EATTRIBUTE8"].ToString(), queryParam["EATTRIBUTE9"].ToString(), queryParam["EATTRIBUTE10"].ToString());
  1555. sql += "\r\n";
  1556. //}
  1557. }
  1558. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1559. return count;
  1560. }
  1561. /// <summary>
  1562. /// 审核到货单生成条码
  1563. /// </summary>
  1564. /// <param name="POCode"></param>
  1565. /// <param name="PORow"></param>
  1566. /// <param name="keyValue"></param>
  1567. /// 2023 1117 传过来的参数判断是否是奥美的项目奥美项目执行独有生成条码规则 lacy.xu
  1568. /// <returns></returns>
  1569. public int SubmitFormSHDH(string DNCode, string Sequence, string keyValue, string WorkPoint,string AMEnable)
  1570. {
  1571. var queryParam = keyValue.ToJObject();
  1572. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1573. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1574. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1575. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1576. decimal LOTQTY = minPackQty;
  1577. string Pre = "DN" + DNCode + (Convert.ToInt32(Sequence)).ToString("D4");
  1578. string sql = string.Empty;
  1579. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1580. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1581. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1582. string InvCode = queryParam["ClassCode"].ToString();
  1583. string sqls = string.Empty;
  1584. string Colspan = "";
  1585. string str1 = "";
  1586. string LotNo = string.Empty;
  1587. List<string> ExtensionIDList = new List<string>();
  1588. for (int i = 0; i < createPageCount; i++)
  1589. {
  1590. if (i + 1 == createPageCount)
  1591. {
  1592. if (minPackQty * createPageCount > thisCreateQty)
  1593. {
  1594. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1595. }
  1596. }
  1597. 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();
  1598. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
  1599. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1600. bool flag = true;
  1601. foreach (var item in ExtensionIDList)
  1602. {
  1603. if (item == Colspan + WorkPoint)
  1604. {
  1605. flag = false;
  1606. }
  1607. }
  1608. if (ExtensionID == null && flag == true)
  1609. {
  1610. str1 = Guid.NewGuid().ToString();
  1611. 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)
  1612. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1613. str1, 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(),
  1614. MUSER, MUSERNAME, WorkPoints);
  1615. }
  1616. else if (ExtensionID != null)
  1617. {
  1618. str1 = ExtensionID.ToString();
  1619. }
  1620. ExtensionIDList.Add(Colspan + WorkPoint);
  1621. //传过来的参数判断是否是奥美的项目奥美项目执行独有生成条码规则
  1622. if (AMEnable == "true")
  1623. {
  1624. LotNo = SqlHelper.GetLOTNumber(InvCode, WorkPoint);
  1625. }
  1626. else
  1627. {
  1628. LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1629. }
  1630. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1631. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1632. LotNo, DNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1633. sql += string.Format(@"
  1634. insert into ICSInventoryLot
  1635. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount ,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,EATTRIBUTE9,EATTRIBUTE10)
  1636. select
  1637. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','7','{3}','{4}', getdate(),'{5}','{9}'
  1638. ,'{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}'
  1639. from ICSDeliveryNotice where DNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  1640. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, DNCode, Sequence, str1, Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY, queryParam["ExpirationDate"].ToString()
  1641. , queryParam["EATTRIBUTE1"].ToString(), queryParam["EATTRIBUTE2"].ToString(), queryParam["EATTRIBUTE3"].ToString(), queryParam["EATTRIBUTE4"].ToString(), queryParam["EATTRIBUTE5"].ToString(),
  1642. queryParam["EATTRIBUTE6"].ToString(), queryParam["EATTRIBUTE7"].ToString(), queryParam["EATTRIBUTE8"].ToString(), queryParam["EATTRIBUTE9"].ToString(), queryParam["EATTRIBUTE10"].ToString());
  1643. sql += "\r\n";
  1644. }
  1645. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1646. return count;
  1647. }
  1648. /// <summary>
  1649. /// 审核委外到货单生成条码
  1650. /// </summary>
  1651. /// <param name="POCode"></param>
  1652. /// <param name="PORow"></param>
  1653. /// <param name="keyValue"></param>
  1654. /// 已改
  1655. /// <returns></returns>
  1656. /// 2023 1117 传过来的参数判断是否是奥美的项目奥美项目执行独有生成条码规则 lacy.xu
  1657. public int SubmitFormWWSHDH(string ODNCode, string Sequence, string keyValue, string WorkPoint,string AMEnable)
  1658. {
  1659. var queryParam = keyValue.ToJObject();
  1660. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1661. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1662. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1663. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1664. decimal LOTQTY = minPackQty;
  1665. string Pre = "ODN" + ODNCode + (Convert.ToInt32(Sequence)).ToString("D4");
  1666. string sql = string.Empty;
  1667. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1668. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1669. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1670. string InvCode = queryParam["ClassCode"].ToString();
  1671. string sqls = string.Empty;
  1672. string Colspan = "";
  1673. string str1 = "";
  1674. string LotNo = string.Empty;
  1675. List<string> ExtensionIDList = new List<string>();
  1676. for (int i = 0; i < createPageCount; i++)
  1677. {
  1678. if (i + 1 == createPageCount)
  1679. {
  1680. if (minPackQty * createPageCount > thisCreateQty)
  1681. {
  1682. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1683. }
  1684. }
  1685. 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();
  1686. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
  1687. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1688. bool flag = true;
  1689. foreach (var item in ExtensionIDList)
  1690. {
  1691. if (item == Colspan + WorkPoint)
  1692. {
  1693. flag = false;
  1694. }
  1695. }
  1696. if (ExtensionID == null && flag == true)
  1697. {
  1698. str1 = Guid.NewGuid().ToString();
  1699. 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)
  1700. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1701. str1, 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(),
  1702. MUSER, MUSERNAME, WorkPoints);
  1703. }
  1704. else if (ExtensionID != null)
  1705. {
  1706. str1 = ExtensionID.ToString();
  1707. }
  1708. ExtensionIDList.Add(Colspan + WorkPoint);
  1709. //传过来的参数判断是否是奥美的项目奥美项目执行独有生成条码规则
  1710. if (AMEnable == "true")
  1711. {
  1712. LotNo = SqlHelper.GetLOTNumber(InvCode, WorkPoint);
  1713. }
  1714. else
  1715. {
  1716. LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1717. }
  1718. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1719. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1720. LotNo, ODNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1721. sql += string.Format(@"
  1722. insert into ICSInventoryLot
  1723. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount ,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,EATTRIBUTE9,EATTRIBUTE10)
  1724. select
  1725. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','8','{3}','{4}', getdate(),'{5}','{9}'
  1726. ,'{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}'
  1727. from ICSODeliveryNotice where ODNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  1728. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ODNCode, Sequence, str1, Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY, queryParam["ExpirationDate"].ToString()
  1729. , queryParam["EATTRIBUTE1"].ToString(), queryParam["EATTRIBUTE2"].ToString(), queryParam["EATTRIBUTE3"].ToString(), queryParam["EATTRIBUTE4"].ToString(), queryParam["EATTRIBUTE5"].ToString(),
  1730. queryParam["EATTRIBUTE6"].ToString(), queryParam["EATTRIBUTE7"].ToString(), queryParam["EATTRIBUTE8"].ToString(), queryParam["EATTRIBUTE9"].ToString(), queryParam["EATTRIBUTE10"].ToString());
  1731. sql += "\r\n";
  1732. }
  1733. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1734. return count;
  1735. }
  1736. /// <summary>
  1737. /// 开立成品入库单
  1738. /// </summary>
  1739. /// <param name="POCode"></param>
  1740. /// <param name="PORow"></param>
  1741. /// <param name="keyValue"></param>
  1742. /// 已改
  1743. /// <returns></returns>
  1744. public int SubmitFormKLCPRK(string RCVCode, string Sequence, string keyValue, string WorkPoint)
  1745. {
  1746. var queryParam = keyValue.ToJObject();
  1747. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1748. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1749. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1750. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1751. decimal LOTQTY = minPackQty;
  1752. string Pre = "KCP" + RCVCode + (Convert.ToInt32(Sequence)).ToString("D4");
  1753. string sql = string.Empty;
  1754. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1755. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1756. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1757. string sqls = string.Empty;
  1758. string Colspan = "";
  1759. string str1 = "";
  1760. List<string> ExtensionIDList = new List<string>();
  1761. for (int i = 0; i < createPageCount; i++)
  1762. {
  1763. if (i + 1 == createPageCount)
  1764. {
  1765. if (minPackQty * createPageCount > thisCreateQty)
  1766. {
  1767. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1768. }
  1769. }
  1770. 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();
  1771. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
  1772. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1773. bool flag = true;
  1774. foreach (var item in ExtensionIDList)
  1775. {
  1776. if (item == Colspan + WorkPoint)
  1777. {
  1778. flag = false;
  1779. }
  1780. }
  1781. if (ExtensionID == null && flag == true)
  1782. {
  1783. str1 = Guid.NewGuid().ToString();
  1784. 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)
  1785. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1786. str1, 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(),
  1787. MUSER, MUSERNAME, WorkPoints);
  1788. }
  1789. else if (ExtensionID != null)
  1790. {
  1791. str1 = ExtensionID.ToString();
  1792. }
  1793. ExtensionIDList.Add(Colspan + WorkPoint);
  1794. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1795. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1796. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1797. LotNo, RCVCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1798. sql += string.Format(@"
  1799. insert into ICSInventoryLot
  1800. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount ,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,EATTRIBUTE9,EATTRIBUTE10)
  1801. select
  1802. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','9','{3}','{4}', getdate(),'{5}','{9}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}'
  1803. from ICSManufactureReceive where RCVCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  1804. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, RCVCode, Sequence, str1, Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY, queryParam["ExpirationDate"].ToString()
  1805. , queryParam["EATTRIBUTE1"].ToString(), queryParam["EATTRIBUTE2"].ToString(), queryParam["EATTRIBUTE3"].ToString(), queryParam["EATTRIBUTE4"].ToString(), queryParam["EATTRIBUTE5"].ToString(),
  1806. queryParam["EATTRIBUTE6"].ToString(), queryParam["EATTRIBUTE7"].ToString(), queryParam["EATTRIBUTE8"].ToString(), queryParam["EATTRIBUTE9"].ToString(), queryParam["EATTRIBUTE10"].ToString());
  1807. sql += "\r\n";
  1808. }
  1809. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1810. return count;
  1811. }
  1812. //委外拒收单
  1813. public DataTable GetGridJsonWWJSD(string queryJson, ref Pagination jqgridparam)
  1814. {
  1815. DataTable dt = new DataTable();
  1816. var queryParam = queryJson.ToJObject();
  1817. List<DbParameter> parameter = new List<DbParameter>();
  1818. object Figure = GetDecimalDigits();
  1819. #region [SQL]
  1820. 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,
  1821. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.RCVQuantity AS DECIMAL(18,{0})) as RCVQuantity,CAST(a.UnitPrice AS DECIMAL(18,{0})) as UnitPrice,a.Currency,a.CreatePerson,a.CreateDateTime,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  1822. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  1823. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10 ,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  1824. a.EATTRIBUTE9,a.EATTRIBUTE10
  1825. from ICSODeliveryNotice a
  1826. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1827. left join (
  1828. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1829. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='11'
  1830. where isnull(ee.EATTRIBUTE1,'')=''
  1831. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1832. ) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  1833. --inner join ICSOutsourcingOrder d on a.OOID=d.OOID and a.OODetailID=d.OODetailID and a.WorkPoint=d.WorkPoint
  1834. left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
  1835. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1836. where a.ODNType='3' and a.Status='2' and a.EATTRIBUTE1 is NOT null
  1837. ";
  1838. sql = string.Format(sql, Figure);
  1839. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  1840. #endregion
  1841. if (!string.IsNullOrWhiteSpace(queryJson))
  1842. {
  1843. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1844. {
  1845. sql += " and a.ODNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1846. }
  1847. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  1848. {
  1849. sql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  1850. }
  1851. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  1852. {
  1853. sql += " and e.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  1854. }
  1855. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1856. {
  1857. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1858. }
  1859. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1860. {
  1861. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1862. }
  1863. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1864. {
  1865. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1866. }
  1867. if (!string.IsNullOrWhiteSpace(queryParam["POStatus"].ToString()))
  1868. {
  1869. string POStatus = queryParam["POStatus"].ToString();
  1870. if (POStatus == "0")
  1871. {
  1872. //sql += " and a.Quantity=ISNULL(c.LotQty,0)";
  1873. }
  1874. else if (POStatus == "1")
  1875. {
  1876. sql += " and a.Quantity-ISNULL(c.LOTQTY,0)=0";
  1877. }
  1878. else
  1879. {
  1880. sql += " and a.Quantity-ISNULL(c.LOTQTY,0)<>0";
  1881. }
  1882. }
  1883. }
  1884. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1885. {
  1886. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  1887. }
  1888. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1889. {
  1890. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1891. }
  1892. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1893. }
  1894. //拒收单
  1895. public DataTable GetGridJsonJSD(string queryJson, ref Pagination jqgridparam)
  1896. {
  1897. DataTable dt = new DataTable();
  1898. var queryParam = queryJson.ToJObject();
  1899. List<DbParameter> parameter = new List<DbParameter>();
  1900. object Figure = GetDecimalDigits();
  1901. #region [SQL]
  1902. string sql = @"select a.ID,a.DNCode ,a.Sequence ,a.VenCode,e.VenName,a.InvCode, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,
  1903. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.RCVQuantity AS DECIMAL(18,{0})) as RCVQuantity,CAST( a.UnitPrice AS DECIMAL(18,{0})) as UnitPrice,a.Currency,a.CreatePerson,a.CreateDateTime,
  1904. CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  1905. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  1906. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  1907. a.EATTRIBUTE9,a.EATTRIBUTE10
  1908. from ICSDeliveryNotice a
  1909. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1910. left join (
  1911. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1912. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='10'
  1913. where isnull(ee.EATTRIBUTE1,'')=''
  1914. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1915. ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  1916. --inner join ICSPurchaseOrder d on a.POID=d.POID and a.PODetailID=d.PODetailID and a.WorkPoint=d.WorkPoint
  1917. left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
  1918. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1919. where a.DNType='3' and a.Status='2' and a.EATTRIBUTE1 is NOT null
  1920. ";
  1921. sql = string.Format(sql, Figure);
  1922. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  1923. #endregion
  1924. if (!string.IsNullOrWhiteSpace(queryJson))
  1925. {
  1926. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1927. {
  1928. sql += " and a.DNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1929. }
  1930. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  1931. {
  1932. sql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  1933. }
  1934. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  1935. {
  1936. sql += " and e.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  1937. }
  1938. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1939. {
  1940. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1941. }
  1942. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1943. {
  1944. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1945. }
  1946. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1947. {
  1948. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1949. }
  1950. if (!string.IsNullOrWhiteSpace(queryParam["POStatus"].ToString()))
  1951. {
  1952. string POStatus = queryParam["POStatus"].ToString();
  1953. if (POStatus == "0")
  1954. {
  1955. //sql += " and a.Quantity=ISNULL(c.LotQty,0)";
  1956. }
  1957. else if (POStatus == "1")
  1958. {
  1959. sql += " and a.Quantity-ISNULL(c.LOTQTY,0)=0";
  1960. }
  1961. else
  1962. {
  1963. sql += " and a.Quantity-ISNULL(c.LOTQTY,0)<>0";
  1964. }
  1965. }
  1966. }
  1967. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1968. {
  1969. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  1970. }
  1971. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1972. {
  1973. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1974. }
  1975. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1976. }
  1977. //领料申请退料
  1978. public DataTable GetGridJsonLLSQTL(string queryJson, ref Pagination jqgridparam)
  1979. {
  1980. DataTable dt = new DataTable();
  1981. var queryParam = queryJson.ToJObject();
  1982. List<DbParameter> parameter = new List<DbParameter>();
  1983. object Figure = GetDecimalDigits();
  1984. #region [SQL]
  1985. string sql = @"select a.ID,a.ApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
  1986. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as IssueNegQuantity ,a.ExtensionID,a.MUSERName,a.MTIME ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  1987. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  1988. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  1989. a.EATTRIBUTE9,a.EATTRIBUTE10
  1990. from ICSMOApplyNegDetail a
  1991. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  1992. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1993. left join (
  1994. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1995. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='12'
  1996. where isnull(ee.EATTRIBUTE1,'')=''
  1997. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1998. )c
  1999. on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  2000. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  2001. WHERE d.Type='2'";
  2002. sql = string.Format(sql, Figure);
  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.ApplyNegCode 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. if (!string.IsNullOrWhiteSpace(queryParam["POStatus"].ToString()))
  2024. {
  2025. string POStatus = queryParam["POStatus"].ToString();
  2026. if (POStatus == "0")
  2027. {
  2028. //sql += " and a.Quantity=ISNULL(c.LotQty,0)";
  2029. }
  2030. else if (POStatus == "1")
  2031. {
  2032. sql += " and a.Quantity-ISNULL(c.LOTQTY,0)=0";
  2033. }
  2034. else
  2035. {
  2036. sql += " and a.Quantity-ISNULL(c.LOTQTY,0)<>0";
  2037. }
  2038. }
  2039. }
  2040. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  2041. {
  2042. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  2043. }
  2044. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  2045. {
  2046. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  2047. }
  2048. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2049. }
  2050. /// <summary>
  2051. /// 拒收生成条码
  2052. /// </summary>
  2053. /// <param name="POCode"></param>
  2054. /// <param name="PORow"></param>
  2055. /// <param name="keyValue"></param>
  2056. /// <returns></returns>
  2057. public int SubmitFormJSD(string DNCode, string Sequence, string keyValue, string WorkPoint)
  2058. {
  2059. var queryParam = keyValue.ToJObject();
  2060. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2061. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  2062. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  2063. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  2064. decimal LOTQTY = minPackQty;
  2065. string Pre = "JS" + DNCode + (Convert.ToInt32(Sequence)).ToString("D4");
  2066. string sql = string.Empty;
  2067. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2068. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2069. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  2070. string sqls = string.Empty;
  2071. string Colspan = "";
  2072. string str1 = "";
  2073. List<string> ExtensionIDList = new List<string>();
  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}' and WorkPoint='{1}'", Colspan, WorkPoint);
  2085. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  2086. bool flag = true;
  2087. foreach (var item in ExtensionIDList)
  2088. {
  2089. if (item == Colspan + WorkPoint)
  2090. {
  2091. flag = false;
  2092. }
  2093. }
  2094. if (ExtensionID == null && flag == true)
  2095. {
  2096. str1 = Guid.NewGuid().ToString();
  2097. 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)
  2098. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  2099. str1, 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(),
  2100. MUSER, MUSERNAME, WorkPoints);
  2101. }
  2102. else if (ExtensionID != null)
  2103. {
  2104. str1 = ExtensionID.ToString();
  2105. }
  2106. ExtensionIDList.Add(Colspan + WorkPoint);
  2107. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  2108. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  2109. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  2110. LotNo, DNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  2111. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  2112. //{
  2113. sql += string.Format(@"
  2114. insert into ICSInventoryLot
  2115. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount ,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,EATTRIBUTE9,EATTRIBUTE10)
  2116. select
  2117. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','10','{3}','{4}', getdate(),'{5}','{9}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}'
  2118. from ICSDeliveryNotice where DNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  2119. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, DNCode, Sequence, str1, Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY, queryParam["ExpirationDate"].ToString()
  2120. , queryParam["EATTRIBUTE1"].ToString(), queryParam["EATTRIBUTE2"].ToString(), queryParam["EATTRIBUTE3"].ToString(), queryParam["EATTRIBUTE4"].ToString(), queryParam["EATTRIBUTE5"].ToString(),
  2121. queryParam["EATTRIBUTE6"].ToString(), queryParam["EATTRIBUTE7"].ToString(), queryParam["EATTRIBUTE8"].ToString(), queryParam["EATTRIBUTE9"].ToString(), queryParam["EATTRIBUTE10"].ToString());
  2122. sql += "\r\n";
  2123. //}
  2124. }
  2125. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  2126. return count;
  2127. }
  2128. /// <summary>
  2129. /// 委外拒收生成条码
  2130. /// </summary>
  2131. /// <param name="POCode"></param>
  2132. /// <param name="PORow"></param>
  2133. /// <param name="keyValue"></param>
  2134. /// <returns></returns>
  2135. public int SubmitFormWWJSD(string ODNCode, string Sequence, string keyValue, string WorkPoint)
  2136. {
  2137. var queryParam = keyValue.ToJObject();
  2138. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2139. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  2140. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  2141. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  2142. decimal LOTQTY = minPackQty;
  2143. string Pre = "OJS" + ODNCode + (Convert.ToInt32(Sequence)).ToString("D4");
  2144. string sql = string.Empty;
  2145. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2146. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2147. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  2148. string sqls = string.Empty;
  2149. string Colspan = "";
  2150. string str1 = "";
  2151. List<string> ExtensionIDList = new List<string>();
  2152. for (int i = 0; i < createPageCount; i++)
  2153. {
  2154. if (i + 1 == createPageCount)
  2155. {
  2156. if (minPackQty * createPageCount > thisCreateQty)
  2157. {
  2158. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  2159. }
  2160. }
  2161. 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();
  2162. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
  2163. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  2164. bool flag = true;
  2165. foreach (var item in ExtensionIDList)
  2166. {
  2167. if (item == Colspan + WorkPoint)
  2168. {
  2169. flag = false;
  2170. }
  2171. }
  2172. if (ExtensionID == null && flag == true)
  2173. {
  2174. str1 = Guid.NewGuid().ToString();
  2175. 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)
  2176. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  2177. str1, 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(),
  2178. MUSER, MUSERNAME, WorkPoints);
  2179. }
  2180. else if (ExtensionID != null)
  2181. {
  2182. str1 = ExtensionID.ToString();
  2183. }
  2184. ExtensionIDList.Add(Colspan + WorkPoint);
  2185. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  2186. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  2187. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  2188. LotNo, ODNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  2189. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  2190. //{
  2191. sql += string.Format(@"
  2192. insert into ICSInventoryLot
  2193. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount ,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,EATTRIBUTE9,EATTRIBUTE10)
  2194. select
  2195. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','11','{3}','{4}', getdate(),'{5}','{9}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}'
  2196. from ICSODeliveryNotice where ODNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  2197. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ODNCode, Sequence, str1, Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY, queryParam["ExpirationDate"].ToString()
  2198. , queryParam["EATTRIBUTE1"].ToString(), queryParam["EATTRIBUTE2"].ToString(), queryParam["EATTRIBUTE3"].ToString(), queryParam["EATTRIBUTE4"].ToString(), queryParam["EATTRIBUTE5"].ToString(),
  2199. queryParam["EATTRIBUTE6"].ToString(), queryParam["EATTRIBUTE7"].ToString(), queryParam["EATTRIBUTE8"].ToString(), queryParam["EATTRIBUTE9"].ToString(), queryParam["EATTRIBUTE10"].ToString());
  2200. sql += "\r\n";
  2201. //}
  2202. }
  2203. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  2204. return count;
  2205. }
  2206. /// <summary>
  2207. /// 点击审核到货单生成条码(审核到货单)
  2208. /// </summary>
  2209. public DataTable GetSubGridJsonJSDByCreate(string DNCode, string Sequence, string WorkPoint)
  2210. {
  2211. DataTable dt = new DataTable();
  2212. object Figure = GetDecimalDigits();
  2213. List<DbParameter> parameter = new List<DbParameter>();
  2214. string sql = @"select a.InvCode,b.InvName,b.ClassCode,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  2215. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  2216. ,d.ProjectCode,d.BatchCode,d.Version,d.Brand,d.cFree1,d.cFree2,d.cFree3,d.cFree4,d.cFree5,d.cFree6,d.cFree7,d.cFree8,d.cFree9,d.cFree10
  2217. from ICSDeliveryNotice a
  2218. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2219. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  2220. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo and a.Type='10'
  2221. where isnull(a.EATTRIBUTE1,'')=''
  2222. group by b.TransCode,b.TransSequence
  2223. ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence
  2224. left join ICSExtension d on a.ExtensionID=d.ID and a.WorkPoint=d.WorkPoint
  2225. WHERE a.DNType='3'
  2226. and a.DNCode='" + DNCode + "' and a.Sequence='" + Sequence + "'";
  2227. sql += " and a.WorkPoint='" + WorkPoint + "'";
  2228. sql = string.Format(sql, Figure);
  2229. return Repository().FindTableBySql(sql.ToString());
  2230. }
  2231. /// <summary>
  2232. /// 点击审核委外到货单生成条码(审核委外到货单)
  2233. /// </summary>
  2234. public DataTable GetSubGridJsonWWJSDByCreate(string ODNCode, string Sequence, string WorkPoint)
  2235. {
  2236. DataTable dt = new DataTable();
  2237. object Figure = GetDecimalDigits();
  2238. List<DbParameter> parameter = new List<DbParameter>();
  2239. string sql = @"select a.InvCode,b.InvName,b.ClassCode,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  2240. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  2241. ,d.ProjectCode,d.BatchCode,d.Version,d.Brand,d.cFree1,d.cFree2,d.cFree3,d.cFree4,d.cFree5,d.cFree6,d.cFree7,d.cFree8,d.cFree9,d.cFree10
  2242. from ICSODeliveryNotice a
  2243. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2244. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  2245. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo and a.Type='11'
  2246. where isnull(a.EATTRIBUTE1,'')=''
  2247. group by b.TransCode,b.TransSequence
  2248. ) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence
  2249. left join ICSExtension d on a.ExtensionID=d.ID and a.WorkPoint=d.WorkPoint
  2250. WHERE a.ODNType='3'
  2251. and a.ODNCode='" + ODNCode + "' and a.Sequence='" + Sequence + "'";
  2252. sql += " and a.WorkPoint='" + WorkPoint + "'";
  2253. sql = string.Format(sql, Figure);
  2254. return Repository().FindTableBySql(sql.ToString());
  2255. }
  2256. public DataTable GetSubGridJsonLLSQDByCreate(string ApplyNegCode, string Sequence, string WorkPoint)
  2257. {
  2258. DataTable dt = new DataTable();
  2259. object Figure = GetDecimalDigits();
  2260. List<DbParameter> parameter = new List<DbParameter>();
  2261. string sql = @"select a.InvCode,b.InvName,b.ClassCode,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  2262. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  2263. ,e.ProjectCode,e.BatchCode,e.Version,e.Brand,e.cFree1,e.cFree2,e.cFree3,e.cFree4,e.cFree5,e.cFree6,e.cFree7,e.cFree8,e.cFree9,e.cFree10
  2264. from ICSMOApplyNegDetail a
  2265. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  2266. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2267. left join (
  2268. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  2269. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo and a.Type='12'
  2270. where isnull(a.EATTRIBUTE1,'')=''
  2271. group by b.TransCode,b.TransSequence
  2272. ) c on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  2273. left join ICSExtension e on a.ExtensionID=e.ID and a.WorkPoint=e.WorkPoint
  2274. WHERE d.Type='2'
  2275. and a.ApplyNegCode='" + ApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  2276. sql += " and a.WorkPoint='" + WorkPoint + "'";
  2277. sql = string.Format(sql, Figure);
  2278. return Repository().FindTableBySql(sql.ToString());
  2279. }
  2280. //领料申请退料生成条码
  2281. public int SubmitFormLLSQTL(string ApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  2282. {
  2283. var queryParam = keyValue.ToJObject();
  2284. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2285. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  2286. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  2287. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  2288. decimal LOTQTY = minPackQty;
  2289. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2290. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  2291. string Pre = "MA" + ApplyNegCode + (Convert.ToInt32(Sequence)).ToString("D4");
  2292. string sql = string.Empty;
  2293. //string VendorLot = queryParam["VendorLot"].ToString();
  2294. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2295. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2296. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  2297. string sqls = string.Empty;
  2298. string Colspan = "";
  2299. string str1 = "";
  2300. List<string> ExtensionIDList = new List<string>();
  2301. for (int i = 0; i < createPageCount; i++)
  2302. {
  2303. if (i + 1 == createPageCount)
  2304. {
  2305. if (minPackQty * createPageCount > thisCreateQty)
  2306. {
  2307. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  2308. }
  2309. }
  2310. 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();
  2311. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
  2312. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  2313. bool flag = true;
  2314. foreach (var item in ExtensionIDList)
  2315. {
  2316. if (item == Colspan + WorkPoint)
  2317. {
  2318. flag = false;
  2319. }
  2320. }
  2321. if (ExtensionID == null && flag == true)
  2322. {
  2323. str1 = Guid.NewGuid().ToString();
  2324. 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)
  2325. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  2326. str1, 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(),
  2327. MUSER, MUSERNAME, WorkPoints);
  2328. }
  2329. else if (ExtensionID != null)
  2330. {
  2331. str1 = ExtensionID.ToString();
  2332. }
  2333. ExtensionIDList.Add(Colspan + WorkPoint);
  2334. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  2335. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  2336. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  2337. LotNo, ApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  2338. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  2339. //{
  2340. sql += string.Format(@"insert into ICSInventoryLot
  2341. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount ,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,EATTRIBUTE9,EATTRIBUTE10)
  2342. select
  2343. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','12','{3}','{4}', getdate(),'{5}','{9}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}'
  2344. from ICSMOApplyNegDetail where ApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  2345. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ApplyNegCode, Sequence, str1, Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY, queryParam["ExpirationDate"].ToString()
  2346. , queryParam["EATTRIBUTE1"].ToString(), queryParam["EATTRIBUTE2"].ToString(), queryParam["EATTRIBUTE3"].ToString(), queryParam["EATTRIBUTE4"].ToString(), queryParam["EATTRIBUTE5"].ToString(),
  2347. queryParam["EATTRIBUTE6"].ToString(), queryParam["EATTRIBUTE7"].ToString(), queryParam["EATTRIBUTE8"].ToString(), queryParam["EATTRIBUTE9"].ToString(), queryParam["EATTRIBUTE10"].ToString());
  2348. sql += "\r\n";
  2349. //}
  2350. }
  2351. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  2352. return count;
  2353. }
  2354. //材料出库退料
  2355. public DataTable GetGridJsonCLCK(string queryJson, ref Pagination jqgridparam)
  2356. {
  2357. DataTable dt = new DataTable();
  2358. var queryParam = queryJson.ToJObject();
  2359. List<DbParameter> parameter = new List<DbParameter>();
  2360. object Figure = GetDecimalDigits();
  2361. #region [SQL]
  2362. string sql = @"
  2363. select a.ID,a.ApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
  2364. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,
  2365. CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as IssueNegQuantity ,a.ExtensionID,a.MUSERName,a.MTIME ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  2366. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  2367. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  2368. from ICSMOApplyNegDetail a
  2369. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  2370. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2371. left join (
  2372. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  2373. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='13'
  2374. where isnull(ee.EATTRIBUTE1,'')=''
  2375. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  2376. )c
  2377. on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  2378. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  2379. WHERE d.Type='3'";
  2380. sql = string.Format(sql, Figure);
  2381. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  2382. #endregion
  2383. if (!string.IsNullOrWhiteSpace(queryJson))
  2384. {
  2385. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  2386. {
  2387. sql += " and a.ApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  2388. }
  2389. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  2390. {
  2391. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  2392. }
  2393. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  2394. {
  2395. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  2396. }
  2397. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  2398. {
  2399. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  2400. }
  2401. if (!string.IsNullOrWhiteSpace(queryParam["POStatus"].ToString()))
  2402. {
  2403. string POStatus = queryParam["POStatus"].ToString();
  2404. if (POStatus == "0")
  2405. {
  2406. //sql += " and a.Quantity=ISNULL(c.LotQty,0)";
  2407. }
  2408. else if (POStatus == "1")
  2409. {
  2410. sql += " and a.Quantity-ISNULL(c.LOTQTY,0)=0";
  2411. }
  2412. else
  2413. {
  2414. sql += " and a.Quantity-ISNULL(c.LOTQTY,0)<>0";
  2415. }
  2416. }
  2417. }
  2418. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  2419. {
  2420. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  2421. }
  2422. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  2423. {
  2424. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  2425. }
  2426. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2427. }
  2428. //材料出库退料
  2429. public DataTable GetSubGridJsonCLCKByCreate(string ApplyNegCode, string Sequence, string WorkPoint)
  2430. {
  2431. DataTable dt = new DataTable();
  2432. object Figure = GetDecimalDigits();
  2433. List<DbParameter> parameter = new List<DbParameter>();
  2434. string sql = @"select a.InvCode,b.InvName,b.ClassCode,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  2435. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  2436. ,f.ProjectCode,f.BatchCode,f.Version,f.Brand,f.cFree1,f.cFree2,f.cFree3,f.cFree4,f.cFree5,f.cFree6,f.cFree7,f.cFree8,f.cFree9,f.cFree10
  2437. from ICSMOApplyNegDetail a
  2438. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  2439. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2440. left join (
  2441. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  2442. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo and a.Type='13'
  2443. where isnull(a.EATTRIBUTE1,'')=''
  2444. group by b.TransCode,b.TransSequence
  2445. ) c on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  2446. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  2447. WHERE d.Type='3'
  2448. and a.ApplyNegCode='" + ApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  2449. sql += " and a.WorkPoint='" + WorkPoint + "'";
  2450. sql = string.Format(sql, Figure);
  2451. return Repository().FindTableBySql(sql.ToString());
  2452. }
  2453. //材料出库退料生成条码
  2454. public int SubmitFormCLCKT(string ApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  2455. {
  2456. var queryParam = keyValue.ToJObject();
  2457. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2458. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  2459. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  2460. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  2461. decimal LOTQTY = minPackQty;
  2462. string Pre = "MD" + ApplyNegCode + (Convert.ToInt32(Sequence)).ToString("D4");
  2463. string sql = string.Empty;
  2464. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2465. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2466. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  2467. string sqls = string.Empty;
  2468. string Colspan = "";
  2469. string str1 = "";
  2470. List<string> ExtensionIDList = new List<string>();
  2471. for (int i = 0; i < createPageCount; i++)
  2472. {
  2473. if (i + 1 == createPageCount)
  2474. {
  2475. if (minPackQty * createPageCount > thisCreateQty)
  2476. {
  2477. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  2478. }
  2479. }
  2480. 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();
  2481. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
  2482. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  2483. bool flag = true;
  2484. foreach (var item in ExtensionIDList)
  2485. {
  2486. if (item == Colspan + WorkPoint)
  2487. {
  2488. flag = false;
  2489. }
  2490. }
  2491. if (ExtensionID == null && flag == true)
  2492. {
  2493. str1 = Guid.NewGuid().ToString();
  2494. 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)
  2495. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  2496. str1, 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(),
  2497. MUSER, MUSERNAME, WorkPoints);
  2498. }
  2499. else if (ExtensionID != null)
  2500. {
  2501. str1 = ExtensionID.ToString();
  2502. }
  2503. ExtensionIDList.Add(Colspan + WorkPoint);
  2504. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  2505. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  2506. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  2507. LotNo, ApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  2508. sql += string.Format(@"insert into ICSInventoryLot
  2509. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount ,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,EATTRIBUTE9,EATTRIBUTE10)
  2510. select
  2511. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','13','{3}','{4}', getdate(),'{5}','{9}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}'
  2512. from ICSMOApplyNegDetail where ApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  2513. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ApplyNegCode, Sequence, str1, Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY, queryParam["ExpirationDate"].ToString()
  2514. , queryParam["EATTRIBUTE1"].ToString(), queryParam["EATTRIBUTE2"].ToString(), queryParam["EATTRIBUTE3"].ToString(), queryParam["EATTRIBUTE4"].ToString(), queryParam["EATTRIBUTE5"].ToString(),
  2515. queryParam["EATTRIBUTE6"].ToString(), queryParam["EATTRIBUTE7"].ToString(), queryParam["EATTRIBUTE8"].ToString(), queryParam["EATTRIBUTE9"].ToString(), queryParam["EATTRIBUTE10"].ToString());
  2516. sql += "\r\n";
  2517. }
  2518. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  2519. return count;
  2520. }
  2521. public DataTable GetGridJsonWWLLTL(string queryJson, ref Pagination jqgridparam)
  2522. {
  2523. DataTable dt = new DataTable();
  2524. var queryParam = queryJson.ToJObject();
  2525. List<DbParameter> parameter = new List<DbParameter>();
  2526. object Figure = GetDecimalDigits();
  2527. #region [SQL]
  2528. string sql = @"select a.ID,a.OApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
  2529. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as IssueNegQuantity ,a.ExtensionID,a.MUSERName,a.MTIME ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  2530. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  2531. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  2532. a.EATTRIBUTE9,a.EATTRIBUTE10
  2533. from ICSOApplyNegDetail a
  2534. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  2535. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2536. left join (
  2537. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  2538. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='14'
  2539. where isnull(ee.EATTRIBUTE1,'')=''
  2540. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  2541. )c
  2542. on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  2543. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  2544. WHERE d.Type='2'";
  2545. sql = string.Format(sql, Figure);
  2546. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  2547. #endregion
  2548. if (!string.IsNullOrWhiteSpace(queryJson))
  2549. {
  2550. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  2551. {
  2552. sql += " and a.OApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  2553. }
  2554. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  2555. {
  2556. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  2557. }
  2558. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  2559. {
  2560. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  2561. }
  2562. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  2563. {
  2564. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  2565. }
  2566. if (!string.IsNullOrWhiteSpace(queryParam["POStatus"].ToString()))
  2567. {
  2568. string POStatus = queryParam["POStatus"].ToString();
  2569. if (POStatus == "0")
  2570. {
  2571. //sql += " and a.Quantity=ISNULL(c.LotQty,0)";
  2572. }
  2573. else if (POStatus == "1")
  2574. {
  2575. sql += " and a.Quantity-ISNULL(c.LOTQTY,0)=0";
  2576. }
  2577. else
  2578. {
  2579. sql += " and a.Quantity-ISNULL(c.LOTQTY,0)<>0";
  2580. }
  2581. }
  2582. }
  2583. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  2584. {
  2585. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  2586. }
  2587. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  2588. {
  2589. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  2590. }
  2591. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2592. }
  2593. /// <summary>
  2594. /// 点击委外领料退料生成条码
  2595. /// </summary>
  2596. public DataTable GetSubGridJsonWWLLByCreate(string OApplyNegCode, string Sequence, string WorkPoint)
  2597. {
  2598. DataTable dt = new DataTable();
  2599. object Figure = GetDecimalDigits();
  2600. List<DbParameter> parameter = new List<DbParameter>();
  2601. string sql = @"
  2602. select a.InvCode,b.InvName,b.ClassCode,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  2603. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  2604. ,e.ProjectCode,e.BatchCode,e.Version,e.Brand,e.cFree1,e.cFree2,e.cFree3,e.cFree4,e.cFree5,e.cFree6,e.cFree7,e.cFree8,e.cFree9,e.cFree10
  2605. from ICSOApplyNegDetail a
  2606. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  2607. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2608. left join (
  2609. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  2610. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo and a.Type='14'
  2611. where isnull(a.EATTRIBUTE1,'')=''
  2612. group by b.TransCode,b.TransSequence
  2613. ) c on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  2614. left join ICSExtension e on a.ExtensionID=e.ID and a.WorkPoint=e.WorkPoint
  2615. WHERE d.Type='2'
  2616. and a.OApplyNegCode='" + OApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  2617. sql += " and a.WorkPoint='" + WorkPoint + "'";
  2618. sql = string.Format(sql, Figure);
  2619. return Repository().FindTableBySql(sql.ToString());
  2620. }
  2621. //委外领料申请退料
  2622. public int SubmitFormWWLL(string OApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  2623. {
  2624. var queryParam = keyValue.ToJObject();
  2625. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2626. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  2627. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  2628. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  2629. decimal LOTQTY = minPackQty;
  2630. string Pre = "OMA" + OApplyNegCode + (Convert.ToInt32(Sequence)).ToString("D4");
  2631. string sql = string.Empty;
  2632. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2633. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2634. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  2635. string sqls = string.Empty;
  2636. string Colspan = "";
  2637. string str1 = "";
  2638. List<string> ExtensionIDList = new List<string>();
  2639. for (int i = 0; i < createPageCount; i++)
  2640. {
  2641. if (i + 1 == createPageCount)
  2642. {
  2643. if (minPackQty * createPageCount > thisCreateQty)
  2644. {
  2645. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  2646. }
  2647. }
  2648. 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();
  2649. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
  2650. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  2651. bool flag = true;
  2652. foreach (var item in ExtensionIDList)
  2653. {
  2654. if (item == Colspan + WorkPoint)
  2655. {
  2656. flag = false;
  2657. }
  2658. }
  2659. if (ExtensionID == null && flag == true)
  2660. {
  2661. str1 = Guid.NewGuid().ToString();
  2662. 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)
  2663. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  2664. str1, 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(),
  2665. MUSER, MUSERNAME, WorkPoints);
  2666. }
  2667. else if (ExtensionID != null)
  2668. {
  2669. str1 = ExtensionID.ToString();
  2670. }
  2671. ExtensionIDList.Add(Colspan + WorkPoint);
  2672. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  2673. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  2674. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  2675. LotNo, OApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  2676. sql += string.Format(@"insert into ICSInventoryLot
  2677. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount ,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,EATTRIBUTE9,EATTRIBUTE10)
  2678. select
  2679. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','14','{3}','{4}', getdate(),'{5}','{9}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}'
  2680. from ICSOApplyNegDetail where OApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  2681. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, OApplyNegCode, Sequence, str1, Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY, queryParam["ExpirationDate"].ToString()
  2682. , queryParam["EATTRIBUTE1"].ToString(), queryParam["EATTRIBUTE2"].ToString(), queryParam["EATTRIBUTE3"].ToString(), queryParam["EATTRIBUTE4"].ToString(), queryParam["EATTRIBUTE5"].ToString(),
  2683. queryParam["EATTRIBUTE6"].ToString(), queryParam["EATTRIBUTE7"].ToString(), queryParam["EATTRIBUTE8"].ToString(), queryParam["EATTRIBUTE9"].ToString(), queryParam["EATTRIBUTE10"].ToString());
  2684. sql += "\r\n";
  2685. }
  2686. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  2687. return count;
  2688. }
  2689. //委外材料出库
  2690. public DataTable GetGridJsonWWCLCK(string queryJson, ref Pagination jqgridparam)
  2691. {
  2692. DataTable dt = new DataTable();
  2693. var queryParam = queryJson.ToJObject();
  2694. List<DbParameter> parameter = new List<DbParameter>();
  2695. object Figure = GetDecimalDigits();
  2696. #region [SQL]
  2697. string sql = @"select a.ID,a.OApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
  2698. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as IssueNegQuantity ,a.ExtensionID,a.MUSERName,a.MTIME ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  2699. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  2700. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  2701. a.EATTRIBUTE9,a.EATTRIBUTE10
  2702. from ICSOApplyNegDetail a
  2703. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  2704. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2705. left join (
  2706. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  2707. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='15'
  2708. where isnull(ee.EATTRIBUTE1,'')=''
  2709. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  2710. )c
  2711. on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  2712. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  2713. WHERE d.Type='3'";
  2714. sql = string.Format(sql, Figure);
  2715. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  2716. #endregion
  2717. if (!string.IsNullOrWhiteSpace(queryJson))
  2718. {
  2719. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  2720. {
  2721. sql += " and a.OApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  2722. }
  2723. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  2724. {
  2725. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  2726. }
  2727. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  2728. {
  2729. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  2730. }
  2731. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  2732. {
  2733. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  2734. }
  2735. if (!string.IsNullOrWhiteSpace(queryParam["POStatus"].ToString()))
  2736. {
  2737. string POStatus = queryParam["POStatus"].ToString();
  2738. if (POStatus == "0")
  2739. {
  2740. //sql += " and a.Quantity=ISNULL(c.LotQty,0)";
  2741. }
  2742. else if (POStatus == "1")
  2743. {
  2744. sql += " and a.Quantity-ISNULL(c.LOTQTY,0)=0";
  2745. }
  2746. else
  2747. {
  2748. sql += " and a.Quantity-ISNULL(c.LOTQTY,0)<>0";
  2749. }
  2750. }
  2751. }
  2752. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  2753. {
  2754. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  2755. }
  2756. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  2757. {
  2758. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  2759. }
  2760. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2761. }
  2762. //委外材料出库
  2763. public DataTable GetSubGridJsonWWCLByCreate(string OApplyNegCode, string Sequence, string WorkPoint)
  2764. {
  2765. DataTable dt = new DataTable();
  2766. object Figure = GetDecimalDigits();
  2767. List<DbParameter> parameter = new List<DbParameter>();
  2768. string sql = @"
  2769. select a.InvCode,b.InvName,b.ClassCode,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  2770. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  2771. ,f.ProjectCode,f.BatchCode,f.Version,f.Brand,f.cFree1,f.cFree2,f.cFree3,f.cFree4,f.cFree5,f.cFree6,f.cFree7,f.cFree8,f.cFree9,f.cFree10
  2772. from ICSOApplyNegDetail a
  2773. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  2774. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2775. left join (
  2776. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  2777. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo and a.Type='15'
  2778. where isnull(a.EATTRIBUTE1,'')=''
  2779. group by b.TransCode,b.TransSequence
  2780. ) c on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  2781. left join ICSExtension f on a.ExtensionID=d.ID and a.WorkPoint=d.WorkPoint
  2782. WHERE d.Type='3'
  2783. and a.OApplyNegCode='" + OApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  2784. sql += " and a.WorkPoint='" + WorkPoint + "'";
  2785. sql = string.Format(sql, Figure);
  2786. return Repository().FindTableBySql(sql.ToString());
  2787. }
  2788. //委外材料出库
  2789. public int SubmitFormWWCL(string OApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  2790. {
  2791. var queryParam = keyValue.ToJObject();
  2792. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2793. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  2794. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  2795. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  2796. decimal LOTQTY = minPackQty;
  2797. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2798. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  2799. string Pre = "OMD" + OApplyNegCode + (Convert.ToInt32(Sequence)).ToString("D4");
  2800. string sql = string.Empty;
  2801. //string VendorLot = queryParam["VendorLot"].ToString();
  2802. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2803. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2804. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  2805. string sqls = string.Empty;
  2806. string Colspan = "";
  2807. string str1 = "";
  2808. List<string> ExtensionIDList = new List<string>();
  2809. for (int i = 0; i < createPageCount; i++)
  2810. {
  2811. if (i + 1 == createPageCount)
  2812. {
  2813. if (minPackQty * createPageCount > thisCreateQty)
  2814. {
  2815. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  2816. }
  2817. }
  2818. 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();
  2819. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
  2820. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  2821. bool flag = true;
  2822. foreach (var item in ExtensionIDList)
  2823. {
  2824. if (item == Colspan + WorkPoint)
  2825. {
  2826. flag = false;
  2827. }
  2828. }
  2829. if (ExtensionID == null && flag == true)
  2830. {
  2831. str1 = Guid.NewGuid().ToString();
  2832. 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)
  2833. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  2834. str1, 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(),
  2835. MUSER, MUSERNAME, WorkPoints);
  2836. }
  2837. else if (ExtensionID != null)
  2838. {
  2839. str1 = ExtensionID.ToString();
  2840. }
  2841. ExtensionIDList.Add(Colspan + WorkPoint);
  2842. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  2843. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  2844. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  2845. LotNo, OApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  2846. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  2847. //{
  2848. sql += string.Format(@"insert into ICSInventoryLot
  2849. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount ,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,EATTRIBUTE9,EATTRIBUTE10)
  2850. select
  2851. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','15','{3}','{4}', getdate(),'{5}','{9}'
  2852. ,'{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}'
  2853. from ICSOApplyNegDetail where OApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  2854. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, OApplyNegCode, Sequence, str1, Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY, queryParam["ExpirationDate"].ToString()
  2855. , queryParam["EATTRIBUTE1"].ToString(), queryParam["EATTRIBUTE2"].ToString(), queryParam["EATTRIBUTE3"].ToString(), queryParam["EATTRIBUTE4"].ToString(), queryParam["EATTRIBUTE5"].ToString(),
  2856. queryParam["EATTRIBUTE6"].ToString(), queryParam["EATTRIBUTE7"].ToString(), queryParam["EATTRIBUTE8"].ToString(), queryParam["EATTRIBUTE9"].ToString(), queryParam["EATTRIBUTE10"].ToString());
  2857. sql += "\r\n";
  2858. //}
  2859. }
  2860. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  2861. return count;
  2862. }
  2863. public DataTable SelectICSExtensionEnable()
  2864. {
  2865. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2866. string sql = @"select ColCode from ICSExtensionEnable
  2867. where Enable=0 and WorkPoint='"+ WorkPoints + "' order by cast(EATTRIBUTE1 as int)";
  2868. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  2869. return dt;
  2870. }
  2871. public DataTable GetComplete()
  2872. {
  2873. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2874. string sql = @"select Enable from ICSConfiguration where Code='CompleteVerification001' and WorkPoint='" + WorkPoints + "'";
  2875. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  2876. return dt;
  2877. }
  2878. public DataTable GetWWComplete()
  2879. {
  2880. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2881. string sql = @"select Enable from ICSConfiguration where Code='CompleteVerification002' and WorkPoint='" + WorkPoints + "'";
  2882. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  2883. return dt;
  2884. }
  2885. //返工工单
  2886. public DataTable GetGridJsonFGGD(string queryJson, ref Pagination jqgridparam)
  2887. {
  2888. DataTable dt = new DataTable();
  2889. var queryParam = queryJson.ToJObject();
  2890. List<DbParameter> parameter = new List<DbParameter>();
  2891. object Figure = GetDecimalDigits();
  2892. #region [SQL]
  2893. string sql = @"select a.ID,d.MOCode,d.Sequence+'~'+ a.Sequence as Sequence,a.PickID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
  2894. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,
  2895. CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.IssueQuantity AS DECIMAL(18,{0})) as IssueQuantity ,a.ExtensionID,a.MUSERName,a.MTIME ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  2896. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  2897. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  2898. a.EATTRIBUTE9,a.EATTRIBUTE10
  2899. from ICSMOPick a
  2900. left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint and d.MOStatus<>'3'
  2901. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2902. left join (
  2903. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  2904. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='16'
  2905. where isnull(ee.EATTRIBUTE1,'')=''
  2906. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  2907. )c
  2908. on d.MOCode=c.TransCode and d.Sequence+'~'+a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  2909. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  2910. where a.EATTRIBUTE1='1' and d.EATTRIBUTE1='1'";
  2911. sql = string.Format(sql, Figure);
  2912. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  2913. #endregion
  2914. if (!string.IsNullOrWhiteSpace(queryJson))
  2915. {
  2916. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  2917. {
  2918. sql += " and d.MOCode like '%" + queryParam["POCode"].ToString() + "%' ";
  2919. }
  2920. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  2921. {
  2922. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  2923. }
  2924. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  2925. {
  2926. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  2927. }
  2928. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  2929. {
  2930. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  2931. }
  2932. if (!string.IsNullOrWhiteSpace(queryParam["POStatus"].ToString()))
  2933. {
  2934. string POStatus = queryParam["POStatus"].ToString();
  2935. if (POStatus == "0")
  2936. {
  2937. //sql += " and a.Quantity=ISNULL(c.LotQty,0)";
  2938. }
  2939. else if (POStatus == "1")
  2940. {
  2941. sql += " and a.Quantity-ISNULL(c.LOTQTY,0)=0";
  2942. }
  2943. else
  2944. {
  2945. sql += " and a.Quantity-ISNULL(c.LOTQTY,0)<>0";
  2946. }
  2947. }
  2948. }
  2949. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  2950. {
  2951. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  2952. }
  2953. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  2954. {
  2955. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  2956. }
  2957. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2958. }
  2959. public DataTable GetSubGridJsonFGGDCreate(string FGGDMOCode, string Sequence, string WorkPoint)
  2960. {
  2961. DataTable dt = new DataTable();
  2962. object Figure = GetDecimalDigits();
  2963. List<DbParameter> parameter = new List<DbParameter>();
  2964. string sql = @"
  2965. select a.InvCode,b.InvName,b.ClassCode,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  2966. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  2967. ,e.ProjectCode,e.BatchCode,e.Version,e.Brand,e.cFree1,e.cFree2,e.cFree3,e.cFree4,e.cFree5,e.cFree6,e.cFree7,e.cFree8,e.cFree9,e.cFree10
  2968. from ICSMOPick a
  2969. left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint and d.MOStatus<>'3'
  2970. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2971. left join (
  2972. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  2973. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo and a.Type='16'
  2974. where isnull(a.EATTRIBUTE1,'')=''
  2975. group by b.TransCode,b.TransSequence
  2976. ) c on d.MOCode=c.TransCode and d.Sequence+'~'+a.Sequence=c.TransSequence
  2977. left join ICSExtension e on d.ExtensionID=e.ID and a.WorkPoint=e.WorkPoint
  2978. WHERE 1=1
  2979. and d.MOCode='" + FGGDMOCode + "' and d.Sequence+'~'+a.Sequence='" + Sequence + "'";
  2980. sql += " and a.WorkPoint='" + WorkPoint + "'";
  2981. sql = string.Format(sql, Figure);
  2982. return Repository().FindTableBySql(sql.ToString());
  2983. }
  2984. //返工工单
  2985. public int SubmitFormFGGD(string FGGDMOCode, string Sequence, string keyValue, string WorkPoint)
  2986. {
  2987. var queryParam = keyValue.ToJObject();
  2988. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2989. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  2990. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  2991. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  2992. decimal LOTQTY = minPackQty;
  2993. Sequence = Sequence.Replace("~", "");
  2994. string Pre = "FG" + FGGDMOCode + (Convert.ToInt32(Sequence)).ToString("D4");
  2995. string sql = string.Empty;
  2996. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2997. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2998. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  2999. string sqls = string.Empty;
  3000. string Colspan = "";
  3001. string str1 = "";
  3002. List<string> ExtensionIDList = new List<string>();
  3003. for (int i = 0; i < createPageCount; i++)
  3004. {
  3005. if (i + 1 == createPageCount)
  3006. {
  3007. if (minPackQty * createPageCount > thisCreateQty)
  3008. {
  3009. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  3010. }
  3011. }
  3012. 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();
  3013. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
  3014. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  3015. bool flag = true;
  3016. foreach (var item in ExtensionIDList)
  3017. {
  3018. if (item == Colspan + WorkPoint)
  3019. {
  3020. flag = false;
  3021. }
  3022. }
  3023. if (ExtensionID == null && flag == true)
  3024. {
  3025. str1 = Guid.NewGuid().ToString();
  3026. 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)
  3027. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  3028. str1, 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(),
  3029. MUSER, MUSERNAME, WorkPoints);
  3030. }
  3031. else if (ExtensionID != null)
  3032. {
  3033. str1 = ExtensionID.ToString();
  3034. }
  3035. ExtensionIDList.Add(Colspan + WorkPoint);
  3036. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  3037. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  3038. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  3039. LotNo, FGGDMOCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  3040. sql += string.Format(@"insert into ICSInventoryLot
  3041. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount ,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,EATTRIBUTE9,EATTRIBUTE10)
  3042. select
  3043. newid(),'{0}',a.InvCode,'{1}','{10}','{2}','{8}','16','{3}','{4}', getdate(),'{5}','{9}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}'
  3044. from ICSMOPick a left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint where d.MOCode='{6}' and d.Sequence+'~'+a.Sequence='{7}' and a.WorkPoint='{5}' ",
  3045. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, FGGDMOCode, Sequence, str1, Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY, queryParam["ExpirationDate"].ToString()
  3046. , queryParam["EATTRIBUTE1"].ToString(), queryParam["EATTRIBUTE2"].ToString(), queryParam["EATTRIBUTE3"].ToString(), queryParam["EATTRIBUTE4"].ToString(), queryParam["EATTRIBUTE5"].ToString(),
  3047. queryParam["EATTRIBUTE6"].ToString(), queryParam["EATTRIBUTE7"].ToString(), queryParam["EATTRIBUTE8"].ToString(), queryParam["EATTRIBUTE9"].ToString(), queryParam["EATTRIBUTE10"].ToString());
  3048. sql += "\r\n";
  3049. }
  3050. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  3051. return count;
  3052. }
  3053. public object GetDecimalDigits()
  3054. {
  3055. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  3056. try
  3057. {
  3058. string sql = string.Empty;
  3059. sql = @"select Figure from ICSConfiguration where Code='Figure001' and Enable='1' and WorkPoint='" + WorkPoint + "'";
  3060. object Figure = SqlHelper.ExecuteScalar(sql);
  3061. return Figure;
  3062. }
  3063. catch (Exception ex)
  3064. {
  3065. throw new Exception(ex.Message.ToString());
  3066. }
  3067. }
  3068. /// <summary>
  3069. /// 生成条码导出
  3070. /// </summary>
  3071. /// <param name="ProductBrand"></param>
  3072. /// <param name="cCusName"></param>
  3073. /// <param name="DesignAddRate"></param>
  3074. /// <returns></returns>
  3075. public DataTable StatementExportAll(string Type,string ID)
  3076. {
  3077. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  3078. string sql = string.Empty;
  3079. object Figure = GetDecimalDigits();
  3080. string TableCode = string.Empty;
  3081. #region sql语句
  3082. if (Type == "1") //生产退料
  3083. {
  3084. sql = @"select a.ApplyNegCode as 退料单号,a.Sequence as 退料单行号,a.InvCode as 料品编码,b.InvName as 料品名称,b.InvStd as 规格型号,b.InvUnit as 单位, CAST(a.Quantity AS DECIMAL(18,{0})) as 数量
  3085. ,CAST(a.Amount AS DECIMAL(18,{0})) as , CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as 退 ,a.MUSERName as ,a.MTIME as , CAST(c.LOTQTY AS DECIMAL(18,{0})) as
  3086. ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  3087. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  3088. a.EATTRIBUTE9,a.EATTRIBUTE10
  3089. from ICSMOApplyNegDetail a
  3090. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  3091. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  3092. left join (
  3093. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  3094. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='1'
  3095. where isnull(ee.EATTRIBUTE1,'')=''
  3096. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  3097. )c
  3098. on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  3099. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  3100. where d.Type='1' and a.ID in (" + ID.TrimEnd(',') + ")";
  3101. TableCode = "ICSMOApplyNegDetail";
  3102. }
  3103. if (Type == "2") //委外退料
  3104. {
  3105. sql = @"select a.OApplyNegCode as 退料单号,a.Sequence as 退料单行号,a.InvCode as 料品编码,b.InvName as 料品名称,b.InvStd as 规格型号,b.InvUnit as 单位, CAST(a.Quantity AS DECIMAL(18,{0})) as 数量
  3106. ,CAST(a.Amount AS DECIMAL(18,{0})) as , CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as 退 ,a.MUSERName as ,a.MTIME as , CAST(c.LOTQTY AS DECIMAL(18,{0})) as
  3107. ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  3108. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  3109. a.EATTRIBUTE9,a.EATTRIBUTE10
  3110. from ICSOApplyNegDetail a
  3111. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  3112. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  3113. left join (
  3114. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  3115. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='2'
  3116. where isnull(ee.EATTRIBUTE1,'')=''
  3117. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  3118. )c
  3119. on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  3120. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  3121. WHERE d.Type='1' and a.ID in (" + ID.TrimEnd(',') + ")";
  3122. TableCode = "ICSOApplyNegDetail";
  3123. }
  3124. if (Type == "3")//工单成品生成条码
  3125. {
  3126. sql = @"select a.MOCode as 工单号,a.Sequence as 工单行号 ,a.InvCode as 料品编码,b.InvName as 料品名称,b.InvStd as 规格型号,b.InvUnit as 单位
  3127. ,CAST( a.Quantity AS DECIMAL(18,{0})) as ,CAST( a.Amount as DECIMAL(18,{0})) as
  3128. ,a.MUSERName as ,a.MTIME as ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as
  3129. ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  3130. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,
  3131. a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  3132. a.EATTRIBUTE9,a.EATTRIBUTE10
  3133. from ICSMO a
  3134. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  3135. left join (
  3136. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  3137. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='3'
  3138. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  3139. )c
  3140. on a.MOCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  3141. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  3142. WHERE 1=1 and a.MOStatus<>'3' and a.Quantity-ISNULL(c.LOTQTY,0)<>0 and a.ID in (" + ID.TrimEnd(',') + ")";
  3143. TableCode = "ICSMO";
  3144. }
  3145. if (Type == "4")//销售退货
  3146. {
  3147. sql = @"select a.SDNCode as 单据号,a.Sequence as 行号,a.SOCode as 销售订单号,a.SOSequence as 销售订单行号,a.CusCode as 客户代码 ,a.CusName as 客户名称 ,a.ArriveDate as 发货日期,a.InvCode as 料品编码,b.InvName as 料品名称,b.InvStd as 规格型号,b.InvUnit as 单位,CAST(a.Quantity AS DECIMAL(18,{0})) as 数量
  3148. ,cast(a.Amount as decimal(18,{0})) as , CAST(a.SDNQuantity AS DECIMAL(18,{0})) as ,a.CreatePerson as ,a.CreateDateTime as ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as
  3149. ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  3150. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  3151. a.EATTRIBUTE9,a.EATTRIBUTE10
  3152. from ICSSDN a
  3153. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  3154. left join (
  3155. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  3156. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='4'
  3157. where isnull(ee.EATTRIBUTE1,'')=''
  3158. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  3159. )c
  3160. on a.SDNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  3161. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  3162. where a.Type='2'and a.ID in (" + ID.TrimEnd(',') + ")";
  3163. TableCode = "ICSSDN";
  3164. }
  3165. if (Type == "5")//其它入库生成条码
  3166. {
  3167. sql = @"select a.InCode as 单据号,a.Sequence as 行号,a.WHCode as 仓库编码,a.InvCode as 料品编码, b.InvName as 料品名称,b.InvStd as 料品型号 ,b.InvDesc as 料品描述,b.InvUnit as 料品单位,
  3168. CAST(a.Quantity AS DECIMAL(18,{0})) as ,CAST(a.Amount AS DECIMAL(18,{0})) as , CAST(a.InQuantity AS DECIMAL(18,{0})) as ,a.CreatePerson as ,a.CreateDateTime as ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as
  3169. ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  3170. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  3171. a.EATTRIBUTE9,a.EATTRIBUTE10
  3172. from ICSOtherIn a
  3173. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  3174. left join (
  3175. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  3176. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='5'
  3177. where isnull(ee.EATTRIBUTE1,'')=''
  3178. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  3179. )c
  3180. on a.InCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  3181. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  3182. where a.Status='1' and a.ID in (" + ID.TrimEnd(',') + ")";
  3183. TableCode = "ICSOtherIn";
  3184. }
  3185. if (Type == "6")//归还单生成条码
  3186. {
  3187. sql = @" select a.ReturnCode as 单据号,a.Sequence as 行号,a.WHCode as 仓库编码,a.InvCode as 料品编码, b.InvName as 料品名称,b.InvStd as 料品型号,b.InvDesc as 料品描述,b.InvUnit as 料品单位
  3188. ,CAST(a.Quantity AS DECIMAL(18,{0})) as ,CAST(a.Amount AS DECIMAL(18,{0})) as , CAST(a.ReturnQuantity AS DECIMAL(18,{0})) as ,a.CreatePerson as ,a.CreateDateTime as ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as
  3189. ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  3190. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  3191. a.EATTRIBUTE9,a.EATTRIBUTE10
  3192. from ICSReturn a
  3193. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  3194. left join (
  3195. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  3196. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='6'
  3197. where isnull(ee.EATTRIBUTE1,'')=''
  3198. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  3199. ) c on a.ReturnCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  3200. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  3201. where a.Status='2' and a.ID in (" + ID.TrimEnd(',') + ")";
  3202. TableCode = "ICSReturn";
  3203. }
  3204. if (Type == "7")//*审核到货单生成条码
  3205. {
  3206. sql = @"select d.POCode as 采购订单号,d.Sequence as 采购订单行号,a.DNCode as 单据号,a.Sequence as 行号,a.VenCode as 供应商代码,e.VenName as 供应商名称,a.InvCode as 料品编码, b.InvName as 料品名称,b.InvStd as 料品型号,b.InvDesc as 料品描述,b.InvUnit as 料品单位,
  3207. CAST(a.Quantity AS DECIMAL(18,{0})) as ,CAST(a.Amount AS DECIMAL(18,{0})) as ,CAST(a.RCVQuantity AS DECIMAL(18,{0})) as ,a.Currency as ,a.CreatePerson as ,a.CreateDateTime as ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as
  3208. ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  3209. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  3210. a.EATTRIBUTE9,a.EATTRIBUTE10
  3211. from ICSDeliveryNotice a
  3212. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  3213. left join (
  3214. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  3215. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='7'
  3216. where isnull(ee.EATTRIBUTE1,'')=''
  3217. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  3218. ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  3219. inner join ICSPurchaseOrder d on a.POID=d.POID and a.PODetailID=d.PODetailID and a.WorkPoint=d.WorkPoint
  3220. left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
  3221. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  3222. where a.DNType='1' and a.Status='2' and a.ASNCode is null and a.ID in (" + ID.TrimEnd(',') + ")";
  3223. TableCode = "ICSDeliveryNotice";
  3224. }
  3225. if (Type == "8")//审核委外到货单生成条码
  3226. {
  3227. sql = @"select d.OOCode as 委外采购订单号,d.Sequence as 委外采购订单行号,a.ODNCode as 单据号,a.Sequence as 行号,a.VenCode as 供应商代码,e.VenName as 供应商名称,a.InvCode as 料品编码, b.InvName as ,b.InvStd as 料品型号,b.InvDesc as 料品描述,b.InvUnit as 料品单位,CAST(a.Quantity AS DECIMAL(18,{0})) as 数量 ,CAST(a.Amount AS DECIMAL(18,{0})) as 辅计量数量,CAST(a.RCVQuantity AS DECIMAL(18,{0})) as 入库数量,a.Currency as 币种,a.CreatePerson as 创建人,a.CreateDateTime as 创建时间,
  3228. CAST(c.LOTQTY AS DECIMAL(18,{0})) as
  3229. ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  3230. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10 ,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  3231. a.EATTRIBUTE9,a.EATTRIBUTE10
  3232. from ICSODeliveryNotice a
  3233. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  3234. left join (
  3235. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  3236. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='8'
  3237. where isnull(ee.EATTRIBUTE1,'')=''
  3238. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  3239. ) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  3240. inner join ICSOutsourcingOrder d on a.OOID=d.OOID and a.OODetailID=d.OODetailID and a.WorkPoint=d.WorkPoint
  3241. left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
  3242. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  3243. where a.ODNType='1' and a.Status='2' and a.OASNCode is null and a.ID in (" + ID.TrimEnd(',') + ")";
  3244. TableCode = "ICSODeliveryNotice";
  3245. }
  3246. if (Type == "9")//开立得成品入库单 生成条码
  3247. {
  3248. sql = @"select a.RCVCode as 单据号,a.Sequence as 行号,a.WHCode as 仓库号,a.InvCode as 料品编码, b.InvName as 料品名称,b.InvStd as 料品型号,b.InvDesc as 料品描述,b.InvUnit as 料品单位,CAST(a.Quantity AS DECIMAL(18,{0})) as 数量 ,
  3249. CAST(a.Amount AS DECIMAL(18,{0})) as ,CAST(a.RCVQuantity AS DECIMAL(18,{0})) as ,a.CreatePerson as ,a.CreateDateTime as ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as
  3250. ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  3251. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  3252. a.EATTRIBUTE9,a.EATTRIBUTE10
  3253. from ICSManufactureReceive a
  3254. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  3255. left join (
  3256. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  3257. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='9'
  3258. where isnull(ee.EATTRIBUTE1,'')=''
  3259. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  3260. ) c on a.RCVCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  3261. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  3262. where a.Status='1' and a.Type='1' and a.ID in (" + ID.TrimEnd(',') + ")";
  3263. TableCode = "ICSManufactureReceive";
  3264. }
  3265. if (Type == "10")//采购拒收单
  3266. {
  3267. sql = @"select a.DNCode as 拒收单号 ,a.Sequence as 拒收单行号 ,a.VenCode as 供应商代码,e.VenName as 供应商名称,a.InvCode as 料品编码, b.InvName as 料品名称,b.InvStd as 料品型号,b.InvDesc as 料品描述,b.InvUnit as 料品单位,
  3268. CAST(a.Quantity AS DECIMAL(18,{0})) as ,CAST(a.Amount AS DECIMAL(18,{0})) as ,CAST(a.RCVQuantity AS DECIMAL(18,{0})) as ,a.Currency as ,a.CreatePerson as ,a.CreateDateTime as ,
  3269. CAST(c.LOTQTY AS DECIMAL(18,{0})) as
  3270. ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  3271. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  3272. a.EATTRIBUTE9,a.EATTRIBUTE10
  3273. from ICSDeliveryNotice a
  3274. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  3275. left join (
  3276. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  3277. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='10'
  3278. where isnull(ee.EATTRIBUTE1,'')=''
  3279. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  3280. ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  3281. --inner join ICSPurchaseOrder d on a.POID=d.POID and a.PODetailID=d.PODetailID and a.WorkPoint=d.WorkPoint
  3282. left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
  3283. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  3284. where a.DNType='3' and a.Status='2' and a.EATTRIBUTE1 is NOT null and a.ID in (" + ID.TrimEnd(',') + ")";
  3285. TableCode = "ICSDeliveryNotice";
  3286. }
  3287. if (Type == "11") //委外拒收单生成条码
  3288. {
  3289. sql = @"select a.ODNCode as 委外拒收单号,a.Sequence as 委外拒收单行号,a.VenCode as 供应商代码,e.VenName as 供应商名称,a.InvCode as 料品编码, b.InvName as 料品名称,b.InvStd as 料品型号,b.InvDesc as 料品描述,b.InvUnit as 料品单位,
  3290. CAST(a.Quantity AS DECIMAL(18,{0})) as ,CAST(a.Amount AS DECIMAL(18,{0})) as ,CAST(a.RCVQuantity AS DECIMAL(18,{0})) as ,a.Currency as ,a.CreatePerson as ,a.CreateDateTime as ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as
  3291. ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  3292. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10 ,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  3293. a.EATTRIBUTE9,a.EATTRIBUTE10
  3294. from ICSODeliveryNotice a
  3295. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  3296. left join (
  3297. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  3298. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='11'
  3299. where isnull(ee.EATTRIBUTE1,'')=''
  3300. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  3301. ) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  3302. --inner join ICSOutsourcingOrder d on a.OOID=d.OOID and a.OODetailID=d.OODetailID and a.WorkPoint=d.WorkPoint
  3303. left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
  3304. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  3305. where a.ODNType='3' and a.Status='2' and a.EATTRIBUTE1 is NOT null and a.ID in (" + ID.TrimEnd(',') + ")";
  3306. TableCode = "ICSODeliveryNotice";
  3307. }
  3308. if (Type == "12")//领料申请退料生成条码
  3309. {
  3310. sql = @"select a.ApplyNegCode as 退料单号,a.Sequence as 退料单行号,a.InvCode as 料品编码,b.InvName as 料品编码,b.InvDesc as 料品描述,b.InvStd as 规格型号,b.InvUnit as 单位,
  3311. CAST(a.Quantity AS DECIMAL(18,{0})) as ,CAST(a.Amount AS DECIMAL(18,{0})) as ,CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as 退 ,a.MUSERName as ,a.MTIME as ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as
  3312. ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  3313. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  3314. a.EATTRIBUTE9,a.EATTRIBUTE10
  3315. from ICSMOApplyNegDetail a
  3316. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  3317. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  3318. left join (
  3319. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  3320. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='12'
  3321. where isnull(ee.EATTRIBUTE1,'')=''
  3322. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  3323. )c
  3324. on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  3325. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  3326. WHERE d.Type='2' and a.ID in (" + ID.TrimEnd(',') + ")";
  3327. TableCode = "ICSMOApplyNegDetail";
  3328. }
  3329. if (Type == "13")//材料出库退料
  3330. {
  3331. sql = @" select a.ApplyNegCode as 退料单号,a.Sequence as 退料单行号,a.InvCode as 料品编码,b.InvName as 料品名称,b.InvDesc as 料品描述,b.InvStd as 规格型号,b.InvUnit as 单位,
  3332. CAST(a.Quantity AS DECIMAL(18,{0})) as ,
  3333. CAST(a.Amount AS DECIMAL(18,{0})) as ,CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as 退 ,a.MUSERName as ,a.MTIME as ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as
  3334. ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  3335. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  3336. from ICSMOApplyNegDetail a
  3337. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  3338. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  3339. left join (
  3340. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  3341. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='13'
  3342. where isnull(ee.EATTRIBUTE1,'')=''
  3343. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  3344. )c
  3345. on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  3346. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  3347. WHERE d.Type='3' and a.ID in (" + ID.TrimEnd(',') + ")";
  3348. TableCode = "ICSMOApplyNegDetail";
  3349. }
  3350. if (Type == "14")//委外领料申请退料
  3351. {
  3352. sql = @" select a.OApplyNegCode as 退料单号,a.Sequence as 退料单行号,a.InvCode as 料品编码,b.InvName as 料品名称,b.InvDesc as 料品描述,b.InvStd as 规格型号,b.InvUnit as 单位,
  3353. CAST(a.Quantity AS DECIMAL(18,{0})) as ,CAST(a.Amount AS DECIMAL(18,{0})) as ,CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as 退 ,a.MUSERName as ,a.MTIME as ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as
  3354. ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  3355. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  3356. a.EATTRIBUTE9,a.EATTRIBUTE10
  3357. from ICSOApplyNegDetail a
  3358. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  3359. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  3360. left join (
  3361. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  3362. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='14'
  3363. where isnull(ee.EATTRIBUTE1,'')=''
  3364. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  3365. )c
  3366. on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  3367. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  3368. WHERE d.Type='2' and a.ID in (" + ID.TrimEnd(',') + ")";
  3369. TableCode = "ICSOApplyNegDetail";
  3370. }
  3371. if (Type == "15")//委外材料出库退料
  3372. {
  3373. sql = @" select a.OApplyNegCode as 退料单号,a.Sequence as 退料单行号,a.InvCode as 料品编码,b.InvName as 料品名称,b.InvDesc as 料品描述,b.InvStd as 规格型号,b.InvUnit as 单位,
  3374. CAST(a.Quantity AS DECIMAL(18,{0})) as ,CAST(a.Amount AS DECIMAL(18,{0})) as ,CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as 退 ,a.MUSERName as ,a.MTIME as ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as
  3375. ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  3376. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  3377. a.EATTRIBUTE9,a.EATTRIBUTE10
  3378. from ICSOApplyNegDetail a
  3379. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  3380. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  3381. left join (
  3382. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  3383. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='15'
  3384. where isnull(ee.EATTRIBUTE1,'')=''
  3385. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  3386. )c
  3387. on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  3388. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  3389. WHERE d.Type='3' and a.ID in (" + ID.TrimEnd(',') + ")";
  3390. TableCode = "ICSOApplyNegDetail";
  3391. }
  3392. if (Type == "16") //返工工单
  3393. {
  3394. sql = @"select d.MOCode as 工单号,d.Sequence+'~'+ a.Sequence as 工单子件行号,a.InvCode as 料品编码,b.InvName as 料品名称,b.InvDesc as 料品描述,b.InvStd as 规格型号,b.InvUnit as 单位,
  3395. CAST(a.Quantity AS DECIMAL(18,{0})) as ,
  3396. CAST(a.Amount AS DECIMAL(18,{0})) as ,CAST(a.IssueQuantity AS DECIMAL(18,{0})) as ,a.MUSERName as ,a.MTIME as ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as
  3397. ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  3398. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  3399. a.EATTRIBUTE9,a.EATTRIBUTE10
  3400. from ICSMOPick a
  3401. left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint and d.MOStatus<>'3'
  3402. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  3403. left join (
  3404. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  3405. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='16'
  3406. where isnull(ee.EATTRIBUTE1,'')=''
  3407. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  3408. )c
  3409. on d.MOCode=c.TransCode and d.Sequence+'~'+a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  3410. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  3411. where a.EATTRIBUTE1='1' and d.EATTRIBUTE1='1' and a.ID in (" + ID.TrimEnd(',') + ")";
  3412. TableCode = "ICSMOPick";
  3413. }
  3414. if (Type == "17")//检验不合格条码重新生成
  3415. {
  3416. sql = @"select a.LotNo as 不合格条码, a.InvCode as 料品编码,b.InvName as 料品名称,b.InvDesc as 料品描述,b.InvStd as 规格型号,b.InvUnit as 单位,
  3417. CAST(a.Quantity AS DECIMAL(18,{0})) as ,
  3418. CAST(c.Amount AS DECIMAL(18,{0})) as ,a.MUSERName,a.MUSERName as ,a.MTIME as ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as
  3419. ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  3420. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,
  3421. a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  3422. a.EATTRIBUTE9,a.EATTRIBUTE10
  3423. from ICSInspection a
  3424. left join dbo.ICSInventoryLot d on a.LotNo=d.LotNo and a.WorkPoint=d.WorkPoint
  3425. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  3426. left join (
  3427. select ee.LotNo,ee.EATTRIBUTE1,ee.Amount,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  3428. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='17'
  3429. group by ee.LotNo,ee.EATTRIBUTE1,ee.Amount,ee.WorkPoint
  3430. )c
  3431. on c.EATTRIBUTE1=d.LotNo and a.WorkPoint=c.WorkPoint
  3432. left join ICSExtension f on d.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  3433. where a.UnqualifiedQuantity>0 and a.Enable='1' and a.ID in (" + ID.TrimEnd(',') + ")";
  3434. TableCode = "ICSInspection";
  3435. }
  3436. #endregion
  3437. sql = sql + " and a.WorkPoint='{1}'";
  3438. sql = string.Format(sql, Figure, WorkPoint);
  3439. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  3440. string sqls = @"SELECT ColCode,ColName,Enable
  3441. from ICSExtensionEnable where WorkPoint='" + WorkPoint + "'";
  3442. DataTable dtExtension = SqlHelper.GetDataTableBySql(sqls);
  3443. foreach (DataRow drE in dtExtension.Rows)
  3444. {
  3445. if (dt.Columns.Contains(drE["ColCode"].ToString()) )
  3446. {
  3447. if (!Convert.ToBoolean(drE["Enable"]))
  3448. {
  3449. dt.Columns.Remove(drE["ColCode"].ToString());
  3450. }
  3451. else if (Convert.ToBoolean(drE["Enable"]))
  3452. {
  3453. dt.Columns[drE["ColCode"].ToString()].ColumnName = drE["ColName"].ToString();
  3454. }
  3455. }
  3456. }
  3457. DataTable dtColumn = ColumnEnable(TableCode);
  3458. foreach (DataRow drC in dtColumn.Rows)
  3459. {
  3460. if (dt.Columns.Contains(drC["ColumnCode"].ToString()))
  3461. {
  3462. if (!Convert.ToBoolean(drC["Enable"]))
  3463. {
  3464. dt.Columns.Remove(drC["ColumnCode"].ToString());
  3465. }
  3466. else if (Convert.ToBoolean(drC["Enable"]))
  3467. {
  3468. dt.Columns[drC["ColumnCode"].ToString()].ColumnName = drC["Name"].ToString();
  3469. }
  3470. }
  3471. }
  3472. return dt;
  3473. }
  3474. public DataTable ColumnEnable(string TableCode)
  3475. {
  3476. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  3477. string sql = string.Empty;
  3478. sql = @"select ColumnCode,Name,Enable from ICSColumnEnable where TableCode='{0}' and WorkPoint='{1}'";
  3479. sql = string.Format(sql, TableCode, WorkPoint);
  3480. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  3481. return dt;
  3482. }
  3483. public object GetQiSetNum(string keyValue)
  3484. {
  3485. decimal Num = 0;
  3486. string msg = "";
  3487. string APIURL = ConfigurationManager.ConnectionStrings["ERPAPIURL"].ConnectionString + "Complete/Approve";
  3488. string result = HttpPost(APIURL, keyValue);
  3489. JObject Obj = (JObject)JsonConvert.DeserializeObject(result);//或者JObject jo = JObject.Parse(jsonText);
  3490. string MessAge = Obj["Message"].ToString();
  3491. string Success = Obj["Success"].ToString();
  3492. if (Success.ToUpper() == "FALSE")
  3493. {
  3494. msg = MessAge;
  3495. }
  3496. else
  3497. {
  3498. if (MessAge == "U9")
  3499. {
  3500. decimal Date = Convert.ToDecimal(Obj["Data"].ToString());
  3501. int date = Convert.ToInt32(Date);
  3502. Num = date;
  3503. }
  3504. else
  3505. {
  3506. if (msg == "")
  3507. {
  3508. JArray res = (JArray)JsonConvert.DeserializeObject(Obj["Data"].ToString());
  3509. foreach (var item in res)
  3510. {
  3511. JObject jo = (JObject)item;
  3512. //var aa= jo["min_lotqty"].ToString();
  3513. Num = Convert.ToDecimal(jo["min_lotqty"].ToString());
  3514. }
  3515. }
  3516. }
  3517. }
  3518. var Header = new
  3519. {
  3520. msg = msg,
  3521. Num = Num,
  3522. };
  3523. return Header;
  3524. }
  3525. //接口api解析
  3526. public static string HttpPost(string url, string body)
  3527. {
  3528. try
  3529. {
  3530. Encoding encoding = Encoding.UTF8;
  3531. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
  3532. request.Method = "POST";
  3533. request.Accept = "application/json, text/javascript, */*"; //"text/html, application/xhtml+xml, */*";
  3534. request.ContentType = "application/json; charset=utf-8";
  3535. byte[] buffer = encoding.GetBytes(body);
  3536. request.ContentLength = buffer.Length;
  3537. request.GetRequestStream().Write(buffer, 0, buffer.Length);
  3538. HttpWebResponse response = (HttpWebResponse)request.GetResponse();
  3539. using (StreamReader reader = new StreamReader(response.GetResponseStream(), encoding))
  3540. {
  3541. return reader.ReadToEnd();
  3542. }
  3543. }
  3544. catch (WebException ex)
  3545. {
  3546. throw new Exception(ex.Message);
  3547. }
  3548. }
  3549. public DataTable GetLoadShow()
  3550. {
  3551. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  3552. string sql = @"
  3553. select * from ICSExtensionEnable where WorkPoint='" + WorkPoints + "' order by cast(EATTRIBUTE1 as int) ";
  3554. return Repository().FindTableBySql(sql.ToString());
  3555. }
  3556. //不合格条码重新生成入库
  3557. public DataTable GetGridJsonBHGTM(string queryJson, ref Pagination jqgridparam)
  3558. {
  3559. DataTable dt = new DataTable();
  3560. var queryParam = queryJson.ToJObject();
  3561. List<DbParameter> parameter = new List<DbParameter>();
  3562. object Figure = GetDecimalDigits();
  3563. #region [SQL]
  3564. string sql = @"select a.ID,a.LotNo, a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
  3565. CAST(a.UnqualifiedQuantity AS DECIMAL(18,{0})) as Quantity ,
  3566. CAST(c.Amount AS DECIMAL(18,{0})) as Amount,a.MUSERName,a.MTIME,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY,d.ExtensionID
  3567. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  3568. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  3569. a.EATTRIBUTE9,a.EATTRIBUTE10
  3570. from ICSInspection a
  3571. left join dbo.ICSInventoryLot d on a.LotNo=d.LotNo and a.WorkPoint=d.WorkPoint
  3572. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  3573. left join (
  3574. select ee.LotNo,ee.EATTRIBUTE1,ee.Amount,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  3575. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='17'
  3576. group by ee.LotNo,ee.EATTRIBUTE1,ee.Amount,ee.WorkPoint
  3577. )c
  3578. on c.EATTRIBUTE1=d.LotNo and a.WorkPoint=c.WorkPoint
  3579. left join ICSExtension f on d.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  3580. where a.UnqualifiedQuantity>0 and a.Enable='1'";
  3581. sql = string.Format(sql, Figure);
  3582. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  3583. #endregion
  3584. if (!string.IsNullOrWhiteSpace(queryJson))
  3585. {
  3586. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  3587. {
  3588. sql += " and a.LotNo like '%" + queryParam["POCode"].ToString() + "%' ";
  3589. }
  3590. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  3591. {
  3592. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  3593. }
  3594. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  3595. {
  3596. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  3597. }
  3598. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  3599. {
  3600. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  3601. }
  3602. if (!string.IsNullOrWhiteSpace(queryParam["POStatus"].ToString()))
  3603. {
  3604. string POStatus = queryParam["POStatus"].ToString();
  3605. if (POStatus == "0")
  3606. {
  3607. //sql += " and a.Quantity=ISNULL(c.LotQty,0)";
  3608. }
  3609. else if (POStatus == "1")
  3610. {
  3611. sql += " and a.UnqualifiedQuantity-ISNULL(c.LOTQTY,0)=0";
  3612. }
  3613. else
  3614. {
  3615. sql += " and a.UnqualifiedQuantity-ISNULL(c.LOTQTY,0)<>0";
  3616. }
  3617. }
  3618. }
  3619. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  3620. {
  3621. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  3622. }
  3623. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  3624. }
  3625. public DataTable GetSubGridJsonBHGTM(string LotNo, string Type, ref Pagination jqgridparam)
  3626. {
  3627. DataTable dt = new DataTable();
  3628. object Figure = GetDecimalDigits();
  3629. List<DbParameter> parameter = new List<DbParameter>();
  3630. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  3631. string sql = @" select c.TransCode,c.TransSequence ,a.ID,a.LotNo, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity ,a.MUSERName,a.MTIME
  3632. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  3633. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,
  3634. case when isnull(d.ID,'')='' then '' else '' end as isStorage,
  3635. case when isnull(e.ID,'')='' then '' else '' end as isInspection,
  3636. case when g.InvIQC='1' then '是' else '否' end as isExemption
  3637. from ICSInventoryLot a
  3638. left join (select count(LotNo) LotNoCount,LotNo,WorkPoint from ICSWareHouseLotInfo
  3639. group by LotNo,WorkPoint)b on a.LotNo=b.LotNo and a.WorkPoint=b.WorkPoint
  3640. left join ICSInventoryLotDetail c on a.LotNo=c.LotNo and a.WorkPoint=c.WorkPoint
  3641. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  3642. left join dbo.ICSWareHouseLotInfo d on a.LotNo=d.LotNo and a.WorkPoint=d.WorkPoint
  3643. left join ICSInspection e on a.LotNo=e.LotNo and e.Enable='1' and a.WorkPoint=e.WorkPoint
  3644. left join ICSInventory g on a.InvCode=g.InvCode and a.WorkPoint=g.WorkPoint
  3645. WHERE isnull(a.EATTRIBUTE1,'')='" + LotNo+"' and a.Type='" + Type + "' and a.WorkPoint in ('" + WorkPoint + "')";
  3646. sql = string.Format(sql, Figure);
  3647. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  3648. }
  3649. public int SubmitFormBHGTM(string OldLotNo, string keyValue, string WorkPoint)
  3650. {
  3651. var queryParam = keyValue.ToJObject();
  3652. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  3653. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  3654. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  3655. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  3656. decimal LOTQTY = minPackQty;
  3657. // string Pre = "DN" + DNCode + (Convert.ToInt32(Sequence)).ToString("D4");
  3658. string sql = string.Empty;
  3659. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  3660. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  3661. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  3662. string sqls = string.Empty;
  3663. string Colspan = "";
  3664. string str1 = "";
  3665. List<string> ExtensionIDList = new List<string>();
  3666. for (int i = 0; i < createPageCount; i++)
  3667. {
  3668. if (i + 1 == createPageCount)
  3669. {
  3670. if (minPackQty * createPageCount > thisCreateQty)
  3671. {
  3672. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  3673. }
  3674. }
  3675. string LotNo = GetNewLotNo(OldLotNo);
  3676. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  3677. select '{0}',TransCode,TransSequence,'{1}','{2}',getdate(),'{3}' from ICSInventoryLotDetail where LotNo='{4}'",
  3678. LotNo, MUSER, MUSERNAME, WorkPoints, OldLotNo);
  3679. sql += string.Format(@"
  3680. insert into ICSInventoryLot
  3681. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount,EATTRIBUTE1)
  3682. select
  3683. newid(),'{0}',a.InvCode,a.ProductDate,a.ExpirationDate,b.UnqualifiedQuantity,a.ExtensionID,'17','{1}','{2}',getdate(),'{3}',a.Amount,'{4}'
  3684. from ICSInventoryLot a
  3685. inner join ICSInspection b on a.LotNo=b.LotNo and a.WorkPoint=b.WorkPoint and b.Enable='1'
  3686. where a.LotNo='{4}' and a.WorkPoint='{3}'",
  3687. LotNo, MUSER, MUSERNAME, WorkPoints, OldLotNo);
  3688. sql += "\r\n";
  3689. }
  3690. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  3691. return count;
  3692. }
  3693. public string GetNewLotNo(string LotNO)
  3694. {
  3695. DataTable dt = new DataTable();
  3696. List<DbParameter> parameter = new List<DbParameter>();
  3697. //string sql = @"select max(LotNo) as NewLotNo from ICSInventoryLot where EATTRIBUTE1='{0}' ";
  3698. string sql = @"SELECT TOP 1 LotNO as NewLotNo FROM ICSInventoryLot WHERE EATTRIBUTE1='{0}'
  3699. ORDER BY CAST(SUBSTRING(LotNO, (LEN(LotNO)-CHARINDEX('-',REVERSE(LotNO))+1)+1,CHARINDEX('-',REVERSE(LotNO))-1) AS INT) DESC";
  3700. sql = string.Format(sql, LotNO);
  3701. dt = Repository().FindTableBySql(sql.ToString());
  3702. if (dt == null || dt.Rows.Count == 0 || dt.Rows[0]["NewLotNo"].ToString() == "")
  3703. {
  3704. return LotNO + "-1";
  3705. }
  3706. else
  3707. {
  3708. string newLotNO = dt.Rows[0]["NewLotNo"].ToString();
  3709. int COUNT = Convert.ToInt32(newLotNO.Substring(newLotNO.LastIndexOf('-') + 1)) + 1;
  3710. return LotNO + "-" + COUNT.ToString();
  3711. }
  3712. }
  3713. public DataTable SelGDLX()
  3714. {
  3715. string sql = string.Empty;
  3716. DataTable dt = null;
  3717. sql = string.Format(@"select distinct isnull(MOType,'') as Code ,isnull(MOType,'') as Name from dbo.ICSMO where isnull(MOType,'')<>''");
  3718. dt = SqlHelper.GetDataTableBySql(sql);
  3719. return dt;
  3720. }
  3721. public DataTable GetFreeEnble()
  3722. {
  3723. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  3724. string sql = @"
  3725. select * from ICSExtensionEnable where WorkPoint='" + WorkPoints + "' order by cast(EATTRIBUTE1 as int) ";
  3726. return Repository().FindTableBySql(sql.ToString());
  3727. }
  3728. public DataTable GetInvBatchEnable(string InvCode)
  3729. {
  3730. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  3731. string sql = @"select distinct BatchEnable from ICSInventory where InvCode='{0}' and WorkPoint='{1}'";
  3732. sql = string.Format(sql,InvCode, WorkPoints);
  3733. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  3734. return dt;
  3735. }
  3736. //副产品
  3737. public DataTable GetGridJsonFCP(string queryJson, ref Pagination jqgridparam)
  3738. {
  3739. DataTable dt = new DataTable();
  3740. var queryParam = queryJson.ToJObject();
  3741. List<DbParameter> parameter = new List<DbParameter>();
  3742. object Figure = GetDecimalDigits();
  3743. #region [SQL]
  3744. string sql = @"select a.ID,d.MOCode,d.Sequence+'~'+ a.Sequence as Sequence,a.PickID,a.InvCode as ZInvCode,d.InvCode as MInvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
  3745. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,
  3746. CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.IssueQuantity AS DECIMAL(18,{0})) as IssueQuantity ,a.ExtensionID,a.MUSERName,a.MTIME ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  3747. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  3748. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  3749. a.EATTRIBUTE9,a.EATTRIBUTE10
  3750. from ICSMOPick a
  3751. left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint and d.MOStatus<>'3'
  3752. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  3753. left join (
  3754. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  3755. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='18'
  3756. where isnull(ee.EATTRIBUTE1,'')=''
  3757. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  3758. )c
  3759. on d.MOCode=c.TransCode and d.Sequence+'~'+a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  3760. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  3761. where a.EATTRIBUTE1='1' ";
  3762. sql = string.Format(sql, Figure);
  3763. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  3764. #endregion
  3765. if (!string.IsNullOrWhiteSpace(queryJson))
  3766. {
  3767. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  3768. {
  3769. sql += " and d.MOCode like '%" + queryParam["POCode"].ToString() + "%' ";
  3770. }
  3771. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  3772. {
  3773. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  3774. }
  3775. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  3776. {
  3777. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  3778. }
  3779. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  3780. {
  3781. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  3782. }
  3783. if (!string.IsNullOrWhiteSpace(queryParam["POStatus"].ToString()))
  3784. {
  3785. string POStatus = queryParam["POStatus"].ToString();
  3786. if (POStatus == "0")
  3787. {
  3788. //sql += " and a.Quantity=ISNULL(c.LotQty,0)";
  3789. }
  3790. else if (POStatus == "1")
  3791. {
  3792. sql += " and a.Quantity-ISNULL(c.LOTQTY,0)=0";
  3793. }
  3794. else
  3795. {
  3796. sql += " and a.Quantity-ISNULL(c.LOTQTY,0)<>0";
  3797. }
  3798. }
  3799. }
  3800. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  3801. {
  3802. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  3803. }
  3804. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  3805. {
  3806. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  3807. }
  3808. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  3809. }
  3810. public DataTable GetSubGridJsonFCPCreate(string FCPMOCode, string Sequence, string WorkPoint)
  3811. {
  3812. DataTable dt = new DataTable();
  3813. object Figure = GetDecimalDigits();
  3814. List<DbParameter> parameter = new List<DbParameter>();
  3815. string sql = @"
  3816. select a.InvCode,b.InvName,b.ClassCode,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  3817. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  3818. ,e.ProjectCode,e.BatchCode,e.Version,e.Brand,e.cFree1,e.cFree2,e.cFree3,e.cFree4,e.cFree5,e.cFree6,e.cFree7,e.cFree8,e.cFree9,e.cFree10
  3819. from ICSMOPick a
  3820. left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint and d.MOStatus<>'3'
  3821. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  3822. left join (
  3823. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  3824. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo and a.Type='18'
  3825. where isnull(a.EATTRIBUTE1,'')=''
  3826. group by b.TransCode,b.TransSequence
  3827. ) c on d.MOCode=c.TransCode and d.Sequence+'~'+a.Sequence=c.TransSequence
  3828. left join ICSExtension e on d.ExtensionID=e.ID and a.WorkPoint=e.WorkPoint
  3829. WHERE 1=1
  3830. and d.MOCode='" + FCPMOCode + "' and d.Sequence+'~'+a.Sequence='" + Sequence + "'";
  3831. sql += " and a.WorkPoint='" + WorkPoint + "'";
  3832. sql = string.Format(sql, Figure);
  3833. return Repository().FindTableBySql(sql.ToString());
  3834. }
  3835. //副产品
  3836. public int SubmitFormFCP(string FCPMOCode, string Sequence, string keyValue, string WorkPoint)
  3837. {
  3838. var queryParam = keyValue.ToJObject();
  3839. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  3840. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  3841. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  3842. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  3843. decimal LOTQTY = minPackQty;
  3844. string Sequences = Sequence.Replace("~", "");
  3845. string Pre = "FCP" + FCPMOCode + (Convert.ToInt32(Sequences)).ToString("D4");
  3846. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  3847. string sql = string.Empty;
  3848. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  3849. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  3850. string sqls = string.Empty;
  3851. string Colspan = "";
  3852. string str1 = "";
  3853. List<string> ExtensionIDList = new List<string>();
  3854. for (int i = 0; i < createPageCount; i++)
  3855. {
  3856. if (i + 1 == createPageCount)
  3857. {
  3858. if (minPackQty * createPageCount > thisCreateQty)
  3859. {
  3860. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  3861. }
  3862. }
  3863. 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();
  3864. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
  3865. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  3866. bool flag = true;
  3867. foreach (var item in ExtensionIDList)
  3868. {
  3869. if (item == Colspan + WorkPoint)
  3870. {
  3871. flag = false;
  3872. }
  3873. }
  3874. if (ExtensionID == null && flag == true)
  3875. {
  3876. str1 = Guid.NewGuid().ToString();
  3877. 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)
  3878. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  3879. str1, 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(),
  3880. MUSER, MUSERNAME, WorkPoints);
  3881. }
  3882. else if (ExtensionID != null)
  3883. {
  3884. str1 = ExtensionID.ToString();
  3885. }
  3886. ExtensionIDList.Add(Colspan + WorkPoint);
  3887. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  3888. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  3889. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  3890. LotNo, FCPMOCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  3891. sql += string.Format(@"insert into ICSInventoryLot
  3892. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount ,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,EATTRIBUTE9,EATTRIBUTE10)
  3893. select
  3894. newid(),'{0}',a.InvCode,'{1}','{10}','{2}','{8}','18','{3}','{4}', getdate(),'{5}','{9}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}'
  3895. from ICSMOPick a left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint and d.MOStatus<>'3' where d.MOCode='{6}' and d.Sequence+'~'+a.Sequence='{7}' and a.WorkPoint='{5}' ",
  3896. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, FCPMOCode, Sequence, str1, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString()
  3897. , queryParam["EATTRIBUTE1"].ToString(), queryParam["EATTRIBUTE2"].ToString(), queryParam["EATTRIBUTE3"].ToString(), queryParam["EATTRIBUTE4"].ToString(), queryParam["EATTRIBUTE5"].ToString(),
  3898. queryParam["EATTRIBUTE6"].ToString(), queryParam["EATTRIBUTE7"].ToString(), queryParam["EATTRIBUTE8"].ToString(), queryParam["EATTRIBUTE9"].ToString(), queryParam["EATTRIBUTE10"].ToString());
  3899. sql += "\r\n";
  3900. }
  3901. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  3902. return count;
  3903. }
  3904. public bool GetGeneratedNum(string Code, string Sequence, string Type, string thisCreateQty)
  3905. {
  3906. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  3907. DataTable dt = new DataTable();
  3908. List<DbParameter> parameter = new List<DbParameter>();
  3909. string sql = string.Empty;
  3910. bool flag = true;
  3911. if (Type=="1")
  3912. {
  3913. sql = @" select distinct CAST(isnull(a.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
  3914. CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
  3915. from ICSMOApplyNegDetail a
  3916. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  3917. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  3918. left join (
  3919. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  3920. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='1'
  3921. where isnull(ee.EATTRIBUTE1,'')=''
  3922. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  3923. )c
  3924. on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  3925. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  3926. where d.Type='1'
  3927. and a.ApplyNegCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
  3928. }
  3929. if (Type=="2")
  3930. {
  3931. sql = @" select distinct CAST(isnull(a.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
  3932. CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
  3933. from ICSOApplyNegDetail a
  3934. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  3935. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  3936. left join (
  3937. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  3938. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='2'
  3939. where isnull(ee.EATTRIBUTE1,'')=''
  3940. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  3941. )c
  3942. on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  3943. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  3944. WHERE d.Type='1' and a.OApplyNegCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
  3945. }
  3946. if (Type == "3")
  3947. {
  3948. sql = @" select distinct CAST(isnull(a.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
  3949. CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
  3950. from ICSMO a
  3951. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  3952. left join (
  3953. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  3954. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='3'
  3955. where isnull(ee.EATTRIBUTE1,'')=''
  3956. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  3957. )c
  3958. on a.MOCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  3959. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  3960. WHERE 1=1 and a.MOStatus<>'3' and a.MOCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
  3961. }
  3962. if (Type == "4")
  3963. {
  3964. sql = @" select distinct CAST(isnull(a.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
  3965. CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
  3966. from ICSSDN a
  3967. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  3968. left join (
  3969. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  3970. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='4'
  3971. where isnull(ee.EATTRIBUTE1,'')=''
  3972. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  3973. )c
  3974. on a.SDNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  3975. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  3976. where a.Type='2'
  3977. and a.SDNCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
  3978. }
  3979. if (Type == "5")
  3980. {
  3981. sql = @" select distinct CAST(isnull(a.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
  3982. CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
  3983. from ICSOtherIn a
  3984. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  3985. left join (
  3986. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  3987. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='5'
  3988. where isnull(ee.EATTRIBUTE1,'')=''
  3989. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  3990. )c
  3991. on a.InCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  3992. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  3993. where a.Status='1'
  3994. and a.InCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
  3995. }
  3996. if (Type == "6")
  3997. {
  3998. sql = @" select distinct CAST(isnull(a.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
  3999. CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
  4000. from ICSReturn a
  4001. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  4002. left join (
  4003. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  4004. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='6'
  4005. where isnull(ee.EATTRIBUTE1,'')=''
  4006. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  4007. ) c on a.ReturnCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  4008. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  4009. where a.Status='2'
  4010. and a.ReturnCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
  4011. }
  4012. if (Type == "7")
  4013. {
  4014. sql = @" select distinct CAST(isnull(a.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
  4015. CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
  4016. from ICSDeliveryNotice a
  4017. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  4018. left join (
  4019. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  4020. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='7'
  4021. where isnull(ee.EATTRIBUTE1,'')=''
  4022. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  4023. ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  4024. inner join ICSPurchaseOrder d on a.POID=d.POID and a.PODetailID=d.PODetailID and a.WorkPoint=d.WorkPoint
  4025. left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
  4026. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  4027. where a.DNType='1' and a.Status='2' and a.ASNCode is null
  4028. and a.DNCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
  4029. }
  4030. if (Type == "8")
  4031. {
  4032. sql = @" select distinct CAST(isnull(a.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
  4033. CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
  4034. from ICSODeliveryNotice a
  4035. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  4036. left join (
  4037. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  4038. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='8'
  4039. where isnull(ee.EATTRIBUTE1,'')=''
  4040. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  4041. ) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  4042. inner join ICSOutsourcingOrder d on a.OOID=d.OOID and a.OODetailID=d.OODetailID and a.WorkPoint=d.WorkPoint
  4043. left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
  4044. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  4045. where a.ODNType='1' and a.Status='2' and a.OASNCode is null
  4046. and a.ODNCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
  4047. }
  4048. if (Type == "9")
  4049. {
  4050. sql = @" select distinct CAST(isnull(a.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
  4051. CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
  4052. from ICSManufactureReceive a
  4053. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  4054. left join (
  4055. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  4056. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='9'
  4057. where isnull(ee.EATTRIBUTE1,'')=''
  4058. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  4059. ) c on a.RCVCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  4060. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  4061. where a.Status='1' and a.Type='1'
  4062. and a.RCVCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
  4063. }
  4064. if (Type == "10")
  4065. {
  4066. sql = @" select distinct CAST(isnull(a.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
  4067. CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
  4068. from ICSDeliveryNotice a
  4069. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  4070. left join (
  4071. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  4072. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='10'
  4073. where isnull(ee.EATTRIBUTE1,'')=''
  4074. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  4075. ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  4076. --inner join ICSPurchaseOrder d on a.POID=d.POID and a.PODetailID=d.PODetailID and a.WorkPoint=d.WorkPoint
  4077. left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
  4078. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  4079. where a.DNType='3' and a.Status='2' and a.EATTRIBUTE1 is NOT null
  4080. and a.DNCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
  4081. }
  4082. if (Type == "11")
  4083. {
  4084. sql = @" select distinct CAST(isnull(a.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
  4085. CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
  4086. from ICSODeliveryNotice a
  4087. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  4088. left join (
  4089. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  4090. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='11'
  4091. where isnull(ee.EATTRIBUTE1,'')=''
  4092. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  4093. ) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  4094. --inner join ICSOutsourcingOrder d on a.OOID=d.OOID and a.OODetailID=d.OODetailID and a.WorkPoint=d.WorkPoint
  4095. left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
  4096. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  4097. where a.ODNType='3' and a.Status='2' and a.EATTRIBUTE1 is NOT null
  4098. and a.ODNCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
  4099. }
  4100. if (Type == "12")
  4101. {
  4102. sql = @" select distinct CAST(isnull(a.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
  4103. CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
  4104. from ICSMOApplyNegDetail a
  4105. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  4106. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  4107. left join (
  4108. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  4109. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='12'
  4110. where isnull(ee.EATTRIBUTE1,'')=''
  4111. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  4112. )c
  4113. on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  4114. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  4115. WHERE d.Type='2'
  4116. and a.ApplyNegCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
  4117. }
  4118. if (Type == "13")
  4119. {
  4120. sql = @" select distinct CAST(isnull(a.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
  4121. CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
  4122. from ICSMOApplyNegDetail a
  4123. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  4124. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  4125. left join (
  4126. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  4127. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='13'
  4128. where isnull(ee.EATTRIBUTE1,'')=''
  4129. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  4130. )c
  4131. on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  4132. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  4133. WHERE d.Type='3'
  4134. and a.ApplyNegCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
  4135. }
  4136. if (Type == "14")
  4137. {
  4138. sql = @" select distinct CAST(isnull(a.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
  4139. CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
  4140. from ICSOApplyNegDetail a
  4141. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  4142. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  4143. left join (
  4144. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  4145. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='14'
  4146. where isnull(ee.EATTRIBUTE1,'')=''
  4147. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  4148. )c
  4149. on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  4150. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  4151. WHERE d.Type='2'
  4152. and a.OApplyNegCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
  4153. }
  4154. if (Type == "15")
  4155. {
  4156. sql = @" select distinct CAST(isnull(a.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
  4157. CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
  4158. from ICSOApplyNegDetail a
  4159. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  4160. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  4161. left join (
  4162. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  4163. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='15'
  4164. where isnull(ee.EATTRIBUTE1,'')=''
  4165. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  4166. )c
  4167. on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  4168. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  4169. WHERE d.Type='3'
  4170. and a.OApplyNegCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
  4171. }
  4172. if (Type == "16")
  4173. {
  4174. sql = @" select distinct CAST(isnull(a.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
  4175. CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
  4176. from ICSMOPick a
  4177. left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint and d.MOStatus<>'3'
  4178. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  4179. left join (
  4180. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  4181. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='16'
  4182. where isnull(ee.EATTRIBUTE1,'')=''
  4183. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  4184. )c
  4185. on d.MOCode=c.TransCode and d.Sequence+'~'+a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  4186. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  4187. where a.EATTRIBUTE1='1' and d.EATTRIBUTE1='1'
  4188. and d.MOCode='" + Code + "' and d.Sequence+'~'+a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
  4189. }
  4190. if (Type == "18")
  4191. {
  4192. sql = @" select distinct CAST(isnull(a.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
  4193. CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
  4194. from ICSMOPick a
  4195. left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint and d.MOStatus<>'3'
  4196. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  4197. left join (
  4198. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  4199. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='18'
  4200. where isnull(ee.EATTRIBUTE1,'')=''
  4201. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  4202. )c
  4203. on d.MOCode=c.TransCode and d.Sequence+'~'+a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  4204. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  4205. where a.EATTRIBUTE1='1'
  4206. and d.MOCode='" + Code + "' and d.Sequence+'~'+a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
  4207. }
  4208. dt = SqlHelper.GetDataTableBySql(sql);
  4209. decimal Quantity= Convert.ToDecimal(dt.Rows[0]["Quantity"].ToString());
  4210. decimal LOTQTY = Convert.ToDecimal(dt.Rows[0]["LOTQTY"].ToString());
  4211. decimal thisQty = Convert.ToDecimal(thisCreateQty);
  4212. if (LOTQTY+ thisQty> Quantity)
  4213. {
  4214. flag = false;
  4215. }
  4216. return flag;
  4217. }
  4218. /// <summary>
  4219. /// 开立成品入库单(一键生成)
  4220. /// </summary>
  4221. public int SubmitFormKLCPRKALL (string keyValue)
  4222. {
  4223. string sql = string.Empty;
  4224. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  4225. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  4226. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  4227. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  4228. foreach (var item in res)
  4229. {
  4230. JObject jo = (JObject)item;
  4231. int createPageCount = Convert.ToInt32(jo["createPageCount"].ToString());
  4232. decimal minPackQty = Convert.ToDecimal(jo["minPackQty"].ToString());
  4233. decimal thisCreateQty = Convert.ToDecimal(jo["thisCreateQty"].ToString());
  4234. decimal LOTQTY = minPackQty;
  4235. string Pre = "KCP" + jo["Code"].ToString() + (Convert.ToInt32(jo["Sequence"].ToString())).ToString("D4");
  4236. string PRODUCTDATE = jo["PRODUCTDATE"].ToString();
  4237. string sqls = string.Empty;
  4238. string Colspan = "";
  4239. string str1 = "";
  4240. List<string> ExtensionIDList = new List<string>();
  4241. for (int i = 0; i < createPageCount; i++)
  4242. {
  4243. if (i + 1 == createPageCount)
  4244. {
  4245. if (minPackQty * createPageCount > thisCreateQty)
  4246. {
  4247. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  4248. }
  4249. }
  4250. Colspan = jo["ProjectCode"].ToString() + "~" + jo["BatchCode"].ToString() + "~" + jo["Version"].ToString() + "~" + jo["Brand"].ToString() + "~" + jo["cFree1"].ToString() + "~" + jo["cFree2"].ToString() + "~" + jo["cFree3"].ToString() + "~" + jo["cFree4"].ToString() + "~" + jo["cFree5"].ToString() + "~" + jo["cFree6"].ToString() + "~" + jo["cFree7"].ToString() + "~" + jo["cFree8"].ToString() + "~" + jo["cFree9"].ToString() + "~" + jo["cFree10"].ToString();
  4251. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
  4252. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  4253. bool flag = true;
  4254. foreach (var items in ExtensionIDList)
  4255. {
  4256. if (items == Colspan + WorkPoint)
  4257. {
  4258. flag = false;
  4259. }
  4260. }
  4261. if (ExtensionID == null && flag == true)
  4262. {
  4263. str1 = Guid.NewGuid().ToString();
  4264. 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)
  4265. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  4266. str1, Colspan, jo["ProjectCode"].ToString(), jo["BatchCode"].ToString(), jo["Version"].ToString(), jo["Brand"].ToString(), jo["cFree1"].ToString(), jo["cFree2"].ToString(), jo["cFree3"].ToString(), jo["cFree4"].ToString(), jo["cFree5"].ToString(), jo["cFree6"].ToString(), jo["cFree7"].ToString(), jo["cFree8"].ToString(), jo["cFree9"].ToString(), jo["cFree10"].ToString(),
  4267. MUSER, MUSERNAME, WorkPoint);
  4268. }
  4269. else if (ExtensionID != null)
  4270. {
  4271. str1 = ExtensionID.ToString();
  4272. }
  4273. ExtensionIDList.Add(Colspan + WorkPoint);
  4274. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  4275. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  4276. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  4277. LotNo, jo["Code"].ToString(), jo["Sequence"].ToString(), MUSER, MUSERNAME, WorkPoint);
  4278. sql += string.Format(@"
  4279. insert into ICSInventoryLot
  4280. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  4281. select
  4282. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','9','{3}','{4}', getdate(),'{5}','{9}'
  4283. from ICSManufactureReceive where RCVCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  4284. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoint, jo["Code"].ToString(), jo["Sequence"].ToString(), str1, Convert.ToDecimal(jo["Amount"].ToString()) / minPackQty * LOTQTY, jo["ExpirationDate"].ToString());
  4285. sql += "\r\n";
  4286. }
  4287. }
  4288. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  4289. return count;
  4290. }
  4291. /// <summary>
  4292. /// 审核到货单生成条码(一键生成)
  4293. /// </summary>
  4294. /// <param name="POCode"></param>
  4295. /// <param name="PORow"></param>
  4296. /// <param name="keyValue"></param>
  4297. /// 已改
  4298. /// <returns></returns>
  4299. public int SubmitFormSHDHALL(string keyValue)
  4300. {
  4301. string sql = string.Empty;
  4302. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  4303. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  4304. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  4305. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  4306. foreach (var resItem in res)
  4307. {
  4308. JObject jo = (JObject)resItem;
  4309. int createPageCount = Convert.ToInt32(jo["createPageCount"].ToString());
  4310. decimal minPackQty = Convert.ToDecimal(jo["minPackQty"].ToString());
  4311. decimal thisCreateQty = Convert.ToDecimal(jo["thisCreateQty"].ToString());
  4312. decimal LOTQTY = minPackQty;
  4313. string Pre = "DN" + jo["Code"].ToString() + (Convert.ToInt32(jo["Sequence"])).ToString("D4");
  4314. string PRODUCTDATE = jo["PRODUCTDATE"].ToString();
  4315. string sqls = string.Empty;
  4316. string Colspan = "";
  4317. string str1 = "";
  4318. List<string> ExtensionIDList = new List<string>();
  4319. for (int i = 0; i < createPageCount; i++)
  4320. {
  4321. if (i + 1 == createPageCount)
  4322. {
  4323. if (minPackQty * createPageCount > thisCreateQty)
  4324. {
  4325. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  4326. }
  4327. }
  4328. Colspan = jo["ProjectCode"].ToString() + "~" + jo["BatchCode"].ToString() + "~" + jo["Version"].ToString() + "~" + jo["Brand"].ToString() + "~" + jo["cFree1"].ToString() + "~" + jo["cFree2"].ToString() + "~" + jo["cFree3"].ToString() + "~" + jo["cFree4"].ToString() + "~" + jo["cFree5"].ToString() + "~" + jo["cFree6"].ToString() + "~" + jo["cFree7"].ToString() + "~" + jo["cFree8"].ToString() + "~" + jo["cFree9"].ToString() + "~" + jo["cFree10"].ToString();
  4329. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
  4330. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  4331. bool flag = true;
  4332. foreach (var item in ExtensionIDList)
  4333. {
  4334. if (item == Colspan + WorkPoint)
  4335. {
  4336. flag = false;
  4337. }
  4338. }
  4339. if (ExtensionID == null && flag == true)
  4340. {
  4341. str1 = Guid.NewGuid().ToString();
  4342. 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)
  4343. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  4344. str1, Colspan, jo["ProjectCode"].ToString(), jo["BatchCode"].ToString(), jo["Version"].ToString(), jo["Brand"].ToString(), jo["cFree1"].ToString(), jo["cFree2"].ToString(), jo["cFree3"].ToString(), jo["cFree4"].ToString(), jo["cFree5"].ToString(), jo["cFree6"].ToString(), jo["cFree7"].ToString(), jo["cFree8"].ToString(), jo["cFree9"].ToString(), jo["cFree10"].ToString(),
  4345. MUSER, MUSERNAME, WorkPoint);
  4346. }
  4347. else if (ExtensionID != null)
  4348. {
  4349. str1 = ExtensionID.ToString();
  4350. }
  4351. ExtensionIDList.Add(Colspan + WorkPoint);
  4352. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  4353. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  4354. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  4355. LotNo, jo["Code"].ToString(), jo["Sequence"].ToString(), MUSER, MUSERNAME, WorkPoint);
  4356. sql += string.Format(@"
  4357. insert into ICSInventoryLot
  4358. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  4359. select
  4360. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','7','{3}','{4}', getdate(),'{5}','{9}'
  4361. from ICSDeliveryNotice where DNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  4362. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoint, jo["Code"].ToString(), jo["Sequence"], str1, Convert.ToDecimal(jo["Amount"].ToString()) / minPackQty * LOTQTY, jo["ExpirationDate"].ToString());
  4363. sql += "\r\n";
  4364. }
  4365. }
  4366. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  4367. return count;
  4368. }
  4369. /// <summary>
  4370. /// 审核委外到货单生成条码(一键生成)
  4371. /// </summary>
  4372. /// <param name="POCode"></param>
  4373. /// <param name="PORow"></param>
  4374. /// <param name="keyValue"></param>
  4375. /// 已改
  4376. /// <returns></returns>
  4377. public int SubmitFormWWSHDHALL(string keyValue)
  4378. {
  4379. string sql = string.Empty;
  4380. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  4381. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  4382. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  4383. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  4384. foreach (var resItem in res)
  4385. {
  4386. JObject jo = (JObject)resItem;
  4387. int createPageCount = Convert.ToInt32(jo["createPageCount"].ToString());
  4388. decimal minPackQty = Convert.ToDecimal(jo["minPackQty"].ToString());
  4389. decimal thisCreateQty = Convert.ToDecimal(jo["thisCreateQty"].ToString());
  4390. decimal LOTQTY = minPackQty;
  4391. string Pre = "ODN" + jo["Code"] + (Convert.ToInt32(jo["Sequence"])).ToString("D4");
  4392. string PRODUCTDATE = jo["PRODUCTDATE"].ToString();
  4393. string sqls = string.Empty;
  4394. string Colspan = "";
  4395. string str1 = "";
  4396. List<string> ExtensionIDList = new List<string>();
  4397. for (int i = 0; i < createPageCount; i++)
  4398. {
  4399. if (i + 1 == createPageCount)
  4400. {
  4401. if (minPackQty * createPageCount > thisCreateQty)
  4402. {
  4403. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  4404. }
  4405. }
  4406. Colspan = jo["ProjectCode"].ToString() + "~" + jo["BatchCode"].ToString() + "~" + jo["Version"].ToString() + "~" + jo["Brand"].ToString() + "~" + jo["cFree1"].ToString() + "~" + jo["cFree2"].ToString() + "~" + jo["cFree3"].ToString() + "~" + jo["cFree4"].ToString() + "~" + jo["cFree5"].ToString() + "~" + jo["cFree6"].ToString() + "~" + jo["cFree7"].ToString() + "~" + jo["cFree8"].ToString() + "~" + jo["cFree9"].ToString() + "~" + jo["cFree10"].ToString();
  4407. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
  4408. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  4409. bool flag = true;
  4410. foreach (var item in ExtensionIDList)
  4411. {
  4412. if (item == Colspan + WorkPoint)
  4413. {
  4414. flag = false;
  4415. }
  4416. }
  4417. if (ExtensionID == null && flag == true)
  4418. {
  4419. str1 = Guid.NewGuid().ToString();
  4420. 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)
  4421. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  4422. str1, Colspan, jo["ProjectCode"].ToString(), jo["BatchCode"].ToString(), jo["Version"].ToString(), jo["Brand"].ToString(), jo["cFree1"].ToString(), jo["cFree2"].ToString(), jo["cFree3"].ToString(), jo["cFree4"].ToString(), jo["cFree5"].ToString(), jo["cFree6"].ToString(), jo["cFree7"].ToString(), jo["cFree8"].ToString(), jo["cFree9"].ToString(), jo["cFree10"].ToString(),
  4423. MUSER, MUSERNAME, WorkPoint);
  4424. }
  4425. else if (ExtensionID != null)
  4426. {
  4427. str1 = ExtensionID.ToString();
  4428. }
  4429. ExtensionIDList.Add(Colspan + WorkPoint);
  4430. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  4431. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  4432. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  4433. LotNo, jo["Code"], jo["Sequence"], MUSER, MUSERNAME, WorkPoint);
  4434. sql += string.Format(@"
  4435. insert into ICSInventoryLot
  4436. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  4437. select
  4438. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','8','{3}','{4}', getdate(),'{5}','{9}'
  4439. from ICSODeliveryNotice where ODNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  4440. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoint, jo["Code"], jo["Sequence"], str1, Convert.ToDecimal(jo["Amount"].ToString()) / minPackQty * LOTQTY, jo["ExpirationDate"].ToString());
  4441. sql += "\r\n";
  4442. }
  4443. }
  4444. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  4445. return count;
  4446. }
  4447. public DataTable SelectICSColumnEnableForLotEnable()
  4448. {
  4449. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  4450. string sql = @" select ColumnCode from ICSColumnEnable
  4451. where Enable='0' and TableCode='ICSInventoryLot' and WorkPoint='" + WorkPoints + "' order by cast(Code as int)";
  4452. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  4453. return dt;
  4454. }
  4455. public DataTable GetLoadShowForColumn()
  4456. {
  4457. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  4458. string sql = @"
  4459. select * from ICSColumnEnable where TableCode='ICSInventoryLot' and WorkPoint='" + WorkPoints + "' order by cast(code as int) ";
  4460. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  4461. return dt;
  4462. }
  4463. public string GetAMEnable()
  4464. {
  4465. string Code = SqlHelper.GetItemsDetailEnabledMark("LotNoMaintenance");
  4466. return Code;
  4467. }
  4468. public DataTable SeachMeasure()
  4469. {
  4470. DataTable dt = new DataTable();
  4471. List<DbParameter> parameter = new List<DbParameter>();
  4472. string sql = @" SELECT Top 1 a.F_ItemCode as Code
  4473. FROM [dbo].[Sys_SRM_ItemsDetail] a
  4474. LEFT JOIN [dbo].[Sys_SRM_Items] b ON a.F_ItemId=b.F_Id
  4475. WHERE b.F_EnCode='CrtLot001' AND a.F_EnabledMark='1' ORDER BY a.F_ItemCode";
  4476. return Repository().FindTableBySql(sql.ToString());
  4477. }
  4478. public DataTable SeachLableofDisable()
  4479. {
  4480. DataTable dt = new DataTable();
  4481. List<DbParameter> parameter = new List<DbParameter>();
  4482. string sql = @"
  4483. SELECT a.F_ItemCode as Code,a.F_EnabledMark as Enable
  4484. FROM [dbo].[Sys_SRM_ItemsDetail] a
  4485. LEFT JOIN [dbo].[Sys_SRM_Items] b ON a.F_ItemId=b.F_Id
  4486. WHERE b.F_EnCode='Lot0001' ORDER BY a.F_SortCode";
  4487. return Repository().FindTableBySql(sql.ToString());
  4488. }
  4489. public DataTable SeachAmountEnablebyInvCode(string InvCode)
  4490. {
  4491. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  4492. DataTable dt = new DataTable();
  4493. List<DbParameter> parameter = new List<DbParameter>();
  4494. string sql = @"
  4495. select isnull(AmountEnable,0) as AmountEnable from dbo.ICSInventory where InvCode='"+ InvCode + "' and WorkPoint='"+ WorkPoint + "'";
  4496. return Repository().FindTableBySql(sql.ToString());
  4497. }
  4498. public string LotBindCode(String savePath)
  4499. {
  4500. //数据获取
  4501. try
  4502. {
  4503. int index = 1;
  4504. string msg = "";
  4505. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  4506. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  4507. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  4508. SqlConnection conn = SqlHelper.GetDataCenterConn();
  4509. string sql = "";
  4510. int count = 0;
  4511. DataTable data = FileToExcel.ExcelToTable(savePath);
  4512. foreach (DataRow dr in data.Rows)
  4513. {
  4514. index++;
  4515. //string GUID = Guid.NewGuid().ToString();
  4516. string Code = dr["单据号"].ToString().Trim().ToUpper();
  4517. string Sequence = dr["单据行号"].ToString().Trim().ToUpper();
  4518. string LotNo = dr["条码"].ToString().Trim().ToUpper();
  4519. string Quantity = dr["条码数量"].ToString().Trim().ToUpper();
  4520. if (Code == "" || Code == null)
  4521. {
  4522. throw new Exception("第 " + index + " 行单据号不能为空!");
  4523. }
  4524. if (Sequence == "" || Sequence == null)
  4525. {
  4526. throw new Exception("第 " + index + " 行单据行号不能为空!");
  4527. }
  4528. if (LotNo == "" || LotNo == null)
  4529. {
  4530. throw new Exception("第 " + index + " 行条码不能为空!");
  4531. }
  4532. if (Quantity == "" || Quantity == null)
  4533. {
  4534. throw new Exception("第 " + index + " 行条码数量不能为空!");
  4535. }
  4536. string sqlCode = @" select a.MOCode,a.Sequence, a.Quantity,a.Amount,a.InvCode,isnull(c.LOTQTY,0) as LOTQTY,
  4537. case when b.EffectiveEnable='1' then getdate()+b.EffectiveDays else '2999-12-31 00:00:00.000' end as ExpirationDate,
  4538. a.ExtensionID
  4539. from ICSMO a
  4540. left join (
  4541. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  4542. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo and a.Type='3'
  4543. where isnull(a.EATTRIBUTE1,'')=''
  4544. group by b.TransCode,b.TransSequence
  4545. ) c on a.MOCode=c.TransCode and a.Sequence=c.TransSequence
  4546. inner join dbo.ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint where a.MOCode='{0}' and a.Sequence='{1}' and a.WorkPoint='{2}'";
  4547. sqlCode = string.Format(sqlCode, Code, Sequence, WorkPoint);
  4548. DataTable dd = SqlHelper.CmdExecuteDataTable(sqlCode);
  4549. if (dd == null || dd.Rows.Count <= 0)
  4550. {
  4551. throw new Exception("第 " + index + "行单号: " + Code + "行号" + Sequence + " 单据不存在!");
  4552. }
  4553. string ExtensionID = dd.Rows[0]["ExtensionID"].ToString();
  4554. string ExpirationDate= dd.Rows[0]["ExpirationDate"].ToString();
  4555. string InvCode = dd.Rows[0]["InvCode"].ToString();
  4556. decimal CQuantity = Convert.ToDecimal(dd.Rows[0]["Quantity"].ToString());
  4557. decimal CAmount = Convert.ToDecimal(dd.Rows[0]["Amount"].ToString());
  4558. decimal CLOTQTY = Convert.ToDecimal(dd.Rows[0]["LOTQTY"].ToString());
  4559. if (Convert.ToDecimal(Quantity) > (CQuantity- CLOTQTY))
  4560. {
  4561. throw new Exception("第 " + index + "行单号: " + Code + "行号" + Sequence + " 所输入条码数量超出该单据可生成数量!");
  4562. }
  4563. var Amount = CAmount / CQuantity * Convert.ToDecimal(Quantity);
  4564. sql += @"Insert INto ICSInventoryLot
  4565. ( ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,Amount,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint)
  4566. Values (newid(),'{0}','{1}',getdate(),'{2}','{3}','{4}','{5}','3','{6}','{7}',getdate(),'{8}')
  4567. ";
  4568. sql += @" Insert INto ICSInventoryLotDetail
  4569. ( LotNo,TransID,TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  4570. Values ('{0}','','{9}','{10}','{6}','{7}',getdate(),'{8}')";
  4571. sql = string.Format(sql, LotNo, InvCode, ExpirationDate, Quantity, Amount, ExtensionID, MUSER, MUSERNAME, WorkPoint, Code, Sequence);
  4572. }
  4573. count = SqlHelper.CmdExecuteNonQueryLi(sql);
  4574. if (count > 0)
  4575. {
  4576. msg = "导入成功";
  4577. }
  4578. else
  4579. {
  4580. return "无有效的导入数据。";
  4581. }
  4582. return msg;
  4583. }
  4584. catch (Exception ex)
  4585. {
  4586. return ex.Message;
  4587. }
  4588. }
  4589. }
  4590. }