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.

483 lines
25 KiB

3 weeks ago
  1. using Newtonsoft.Json;
  2. using NFine.Application.Entity;
  3. using NFine.Application.Models;
  4. using NFine.Code;
  5. using NFine.Data.Extensions;
  6. using NFine.Domain._03_Entity.SRM;
  7. using NFine.Repository;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Data.Common;
  11. using System.Data;
  12. using System.Linq;
  13. using System.Text;
  14. using System.Threading.Tasks;
  15. namespace NFine.Application.WMS
  16. {
  17. /// <summary>
  18. /// 调拨单
  19. /// </summary>
  20. public class ICSTransferApp : RepositoryFactory<ICSVendor>
  21. {
  22. public static DataTable Invmes = new DataTable();
  23. /// <summary>
  24. /// 删除
  25. /// </summary>
  26. /// <param name="keyValue"></param>
  27. /// <returns></returns>
  28. /// <exception cref="Exception"></exception>
  29. public string DeleteTransferApplyNeg(string keyValue)
  30. {
  31. //站点信息
  32. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  33. string msg = "";
  34. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  35. string sql = string.Empty;
  36. sql += string.Format(@"DELETE FROM dbo.ICSTransfer WHERE TransferNO IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  37. //sql += string.Format(@"DELETE FROM dbo.ICSMTransferNegDetail WHERE ApplyNegCode IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  38. try
  39. {
  40. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  41. {
  42. }
  43. }
  44. catch (Exception ex)
  45. {
  46. throw new Exception(ex.Message);
  47. }
  48. return msg;
  49. }
  50. /// <summary>
  51. /// 查询
  52. /// </summary>
  53. /// <param name="jqgridparam"></param>
  54. /// <returns></returns>
  55. public DataTable GetTransferApplyNeg(ref Pagination jqgridparam)
  56. {
  57. DataTable dt = new DataTable();
  58. List<DbParameter> parameter = new List<DbParameter>();
  59. string sql = @"select a.TransferNO, a.MUSERName,a.MTIME,a.Status,a.Type from ICSTransfer a
  60. group by a.TransferNO, a.MUSERName,a.MTIME,a.Status,a.Type";
  61. sql = string.Format(sql);
  62. DataTable dttest = Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  63. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  64. }
  65. /// <summary>
  66. /// 查询无条码物料相关调拨单(晶华)
  67. /// </summary>
  68. /// <param name="jqgridparam"></param>
  69. /// <returns></returns>
  70. public DataTable GetTransferInForJINH(ref Pagination jqgridparam)
  71. {
  72. DataTable dt = new DataTable();
  73. List<DbParameter> parameter = new List<DbParameter>();
  74. string sql = @" select a.TransferNO, a.MUSERName,a.MTIME,a.Status,a.Type from ICSTransfer a
  75. WHERE A.Type='1' AND A.InvCode IN
  76. (SELECT B.F_Define1 FROM Sys_SRM_Items A
  77. LEFT JOIN Sys_SRM_ItemsDetail B ON B.F_ItemId=A.F_Id
  78. WHERE A.F_EnCode='InventoryLotWareHouseFixed')
  79. group by a.TransferNO, a.MUSERName,a.MTIME,a.Status,a.Type";
  80. sql = string.Format(sql);
  81. DataTable dttest = Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  82. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  83. }
  84. /// <summary>
  85. /// 明细查询
  86. /// </summary>
  87. /// <param name="jqgridparam"></param>
  88. /// <returns></returns>
  89. public DataTable GetTransferApplyNegDetail(string TransferNO, ref Pagination jqgridparam)
  90. {
  91. DataTable dt = new DataTable();
  92. //object Figure = GetDecimalDigits();
  93. List<DbParameter> parameter = new List<DbParameter>();
  94. string sql = @"SELECT a.ID,a.TransferNO,a.Sequence,a.InvCode,a.Quantity,a.TransferQuantity,a.Amount,a.FromWarehouseCode as FromWHCode,e.WarehouseName as FromWHName,a.Memo
  95. ,a.ToWarehouseCode as ToWHCode,g.WarehouseName as ToWHName,a.FromLocationCode as FromLotCode,h.LocationName as FromLotName,a.ToLocationCode as ToLotCode,i.LocationName as ToLotName
  96. ,a.ExtensionID,a.MUSER,a.MUSERName,a.MTIME,a.WorkPoint,b.InvName,a.CreateDateTime,a.CreatePerson,a.TransferID,a.TransferDetailID
  97. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  98. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  99. ,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,a.EATTRIBUTE9,a.EATTRIBUTE10
  100. from ICSTransfer a
  101. left join ICSInventory b on a.InvCode = b.InvCode and a.WorkPoint = b.WorkPoint
  102. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  103. left join ICSWarehouse e on a.FromWarehouseCode = e.WarehouseCode and a.WorkPoint=e.WorkPoint
  104. left join ICSWarehouse g on a.ToWarehouseCode = g.WarehouseCode and g.WorkPoint=e.WorkPoint
  105. left join ICSLocation h on a.FromLocationCode = h.LocationCode and h.WorkPoint=e.WorkPoint
  106. left join ICSLocation i on a.ToLocationCode = i.LocationCode and i.WorkPoint=e.WorkPoint
  107. where a.TransferNO = '" + TransferNO + "' ";
  108. //sql = string.Format(sql, Figure);
  109. DataTable dttest = Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  110. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  111. }
  112. /// <summary>
  113. /// 无条码料调入单明细查询(晶华)
  114. /// </summary>
  115. /// <param name="TransferNO"></param>
  116. /// <param name="jqgridparam"></param>
  117. /// <returns></returns>
  118. public DataTable GetTransferInDetailJINH(string TransferNO, ref Pagination jqgridparam)
  119. {
  120. DataTable dt = new DataTable();
  121. //object Figure = GetDecimalDigits();
  122. List<DbParameter> parameter = new List<DbParameter>();
  123. string sql = @"SELECT a.ID,a.TransferNO,a.Sequence,a.InvCode,a.Quantity,a.TransferQuantity,a.Amount,a.FromWarehouseCode as FromWHCode,e.WarehouseName as FromWHName,a.Memo
  124. ,a.ToWarehouseCode as ToWHCode,g.WarehouseName as ToWHName,a.FromLocationCode as FromLotCode,h.LocationName as FromLotName,a.ToLocationCode as ToLotCode,i.LocationName as ToLotName
  125. ,a.ExtensionID,a.MUSER,a.MUSERName,a.MTIME,a.WorkPoint,b.InvName,a.CreateDateTime,a.CreatePerson,a.TransferID,a.TransferDetailID
  126. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  127. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  128. ,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7
  129. ,ISNULL(a.EATTRIBUTE8,'') AS OutWorkPoint,ISNULL(a.EATTRIBUTE9,'') AS INWorkPoint,a.EATTRIBUTE10
  130. from ICSTransfer a
  131. left join ICSInventory b on a.InvCode = b.InvCode and a.WorkPoint = b.WorkPoint
  132. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  133. left join ICSWarehouse e on a.FromWarehouseCode = e.WarehouseCode and a.WorkPoint=e.WorkPoint
  134. left join ICSWarehouse g on a.ToWarehouseCode = g.WarehouseCode and g.WorkPoint=e.WorkPoint
  135. left join ICSLocation h on a.FromLocationCode = h.LocationCode and h.WorkPoint=e.WorkPoint
  136. left join ICSLocation i on a.ToLocationCode = i.LocationCode and i.WorkPoint=e.WorkPoint
  137. where a.TransferNO = '" + TransferNO + "' ";
  138. //sql = string.Format(sql, Figure);
  139. DataTable dttest = Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  140. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  141. }
  142. public void ClearTemp()
  143. {
  144. Invmes.Rows.Clear();
  145. }
  146. /// <summary>
  147. /// 获取库位信息
  148. /// </summary>
  149. /// <param name="LocationCode"></param>
  150. /// <param name="jqgridparam"></param>
  151. /// <returns></returns>
  152. public DataTable GetLocationCode(string WHCode, ref Pagination jqgridparam)
  153. {
  154. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  155. List<DbParameter> parameter = new List<DbParameter>();
  156. DataTable table = new DataTable();
  157. string wherestr = "";
  158. if (!string.IsNullOrEmpty(WHCode))
  159. {
  160. wherestr += " and b.WarehouseCode = '" + WHCode + "'";
  161. }
  162. string sql = @"select a.LocationCode as LocationCode ,a.ID,a.LocationName,b.WarehouseCode, b.WarehouseName,a.Musername as 'MUSER',a.MTIME
  163. from ICSLocation a WITH (NOLOCK)
  164. inner join ICSWarehouse b WITH (NOLOCK) on a.WHID=b.ID
  165. where 1=1 and a.WorkPoint = '" + WorkPoint + "'" + wherestr;
  166. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  167. return dt;
  168. }
  169. /// <summary>
  170. /// 新增、修改
  171. /// </summary>
  172. /// <param name="ICSASN"></param>
  173. /// <returns></returns>
  174. public string SaveICSTransferApplyNeg(string keyValue, string deleteIDs)
  175. {
  176. string returnValue = string.Empty;
  177. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  178. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  179. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  180. var Dates = DateTime.Now;
  181. string Colspan = string.Empty;
  182. string IDD = string.Empty;
  183. var sql = string.Empty;
  184. try
  185. {
  186. var modelList = JsonConvert.DeserializeObject<List<ICSTransferEdit>>(keyValue);
  187. if (!string.IsNullOrEmpty(deleteIDs))
  188. {
  189. var deleteentityList = deleteIDs.Split(',');
  190. foreach (var item in deleteentityList)
  191. {
  192. if (!string.IsNullOrEmpty(item))
  193. {
  194. var deleteEntity = MsSqlData.Get<Entity.ICSTransfer>(item);
  195. sql += string.Format(@"DELETE FROM dbo.ICSTransfer WHERE ID IN ({0}) and WorkPoint ='{1}'", item, WorkPoint);
  196. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  197. {
  198. }
  199. }
  200. }
  201. }
  202. foreach (var model in modelList)
  203. {
  204. if (string.IsNullOrEmpty(model.ID))
  205. {
  206. if (string.IsNullOrEmpty(model.TransferNO))
  207. {
  208. throw new Exception("其他调拨单号错误!");
  209. }
  210. //新增
  211. var count = MsSqlData.ExecuteScalar(" select count(1) from ICSTransfer where TransferNO ='" + model.TransferNO + "' and Sequence ='" + model.Sequence + "'").ToInt();
  212. if (count > 0)
  213. {
  214. throw new Exception("当前调拨单号以及行号已存在");
  215. }
  216. //检验自由项
  217. Colspan = model.ProjectCode + "~" + model.BatchCode + "~" + model.Version
  218. + "~" + model.Brand + "~" + model.cFree1
  219. + "~" + model.cFree2 + "~" + model.cFree3 + "~" + model.cFree4
  220. + "~" + model.cFree5 + "~" + model.cFree6 + "~" + model.cFree7
  221. + "~" + model.cFree8 + "~" + model.cFree9 + "~" + model.cFree10;
  222. sql = @"select ID,Colspan from ICSExtension a
  223. where Colspan='{0}' and WorkPoint='{1}'";
  224. sql = string.Format(sql, Colspan, model.WorkPoint);
  225. var dttt = SqlHelper.CmdExecuteDataTable(sql);
  226. if (dttt.Rows.Count == 0)
  227. {
  228. IDD = Guid.NewGuid().ToString();
  229. sql = @"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  230. select '{17}','{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}',GETDATE(),'{15}',f.F_RealName,'{16}'from Sys_SRM_User f where f.F_Account='{15}' and f.F_Location='{16}'";
  231. sql = string.Format(sql, Colspan, model.ProjectCode, model.BatchCode, model.Version, model.Brand, model.cFree1, model.cFree2, model.cFree3, model.cFree4, model.cFree5, model.cFree6, model.cFree7, model.cFree8, model.cFree9, model.cFree10, model.User, model.WorkPoint, IDD);
  232. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  233. {
  234. throw new Exception("自由项添加失败");
  235. }
  236. }
  237. else
  238. {
  239. IDD = dttt.Rows[0]["ID"].ToString();
  240. }
  241. var entity = new ICSTransfer();
  242. ConvertExt.Mapping(model, entity);
  243. entity.ID = Guid.NewGuid().ToString();
  244. entity.TransferID = "";
  245. entity.TransferDetailID = "";
  246. //entity.TransferID = "";
  247. //entity.TransferDetailID = "";
  248. entity.Status = "1";
  249. entity.CreatePerson = MUSER;
  250. entity.CreateDateTime = Dates;
  251. entity.MUSER = MUSER;
  252. entity.MUSERName = MUSERNAME;
  253. entity.MTIME = Dates;
  254. entity.WorkPoint = WorkPoint;
  255. entity.ExtensionID = IDD;
  256. var result = MsSqlData.Insert<ICSTransfer>(entity);
  257. if (!result)
  258. {
  259. returnValue = "调拨单新增失败";
  260. }
  261. }
  262. else
  263. {
  264. //修改
  265. var entity = MsSqlData.Get<ICSTransfer>(model.ID);
  266. if (entity == null)
  267. {
  268. //新增
  269. if (string.IsNullOrEmpty(model.TransferNO))
  270. {
  271. throw new Exception("调拨单单号错误!");
  272. }
  273. var count = MsSqlData.ExecuteScalar(" select count(1) from ICSTransfer where TransferNO ='" + model.TransferNO + "' and Sequence ='" + model.Sequence + "'").ToInt();
  274. if (count > 0)
  275. {
  276. throw new Exception("当前调拨单号以及行号已存在");
  277. }
  278. //检验自由项
  279. Colspan = model.ProjectCode + "~" + model.BatchCode + "~" + model.Version
  280. + "~" + model.Brand + "~" + model.cFree1
  281. + "~" + model.cFree2 + "~" + model.cFree3 + "~" + model.cFree4
  282. + "~" + model.cFree5 + "~" + model.cFree6 + "~" + model.cFree7
  283. + "~" + model.cFree8 + "~" + model.cFree9 + "~" + model.cFree10;
  284. sql = @"select ID,Colspan from ICSExtension a
  285. where Colspan='{0}' and WorkPoint='{1}'";
  286. sql = string.Format(sql, Colspan, model.WorkPoint);
  287. var dttt = SqlHelper.CmdExecuteDataTable(sql);
  288. if (dttt.Rows.Count == 0)
  289. {
  290. IDD = Guid.NewGuid().ToString();
  291. sql = @"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  292. select '{17}','{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}',GETDATE(),'{15}',f.F_RealName,'{16}'from Sys_SRM_User f where f.F_Account='{15}' and f.F_Location='{16}'";
  293. sql = string.Format(sql, Colspan, model.ProjectCode, model.BatchCode, model.Version, model.Brand, model.cFree1, model.cFree2, model.cFree3, model.cFree4, model.cFree5, model.cFree6, model.cFree7, model.cFree8, model.cFree9, model.cFree10, model.User, model.WorkPoint, IDD);
  294. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  295. {
  296. throw new Exception("自由项添加失败");
  297. }
  298. }
  299. else
  300. {
  301. IDD = dttt.Rows[0]["ID"].ToString();
  302. }
  303. entity = new ICSTransfer();
  304. ConvertExt.Mapping<ICSTransferEdit, ICSTransfer>(model, entity);
  305. entity.ID = Guid.NewGuid().ToString();
  306. entity.TransferID = "";
  307. entity.TransferDetailID = "";
  308. //entity.TransferID = "";
  309. //entity.TransferDetailID = "";
  310. entity.CreatePerson = MUSER;
  311. entity.CreateDateTime = Dates;
  312. entity.Status = "1";
  313. entity.MUSER = MUSER;
  314. entity.MUSERName = MUSERNAME;
  315. entity.MTIME = Dates;
  316. entity.WorkPoint = WorkPoint;
  317. entity.ExtensionID = IDD;
  318. var result = MsSqlData.Insert<ICSTransfer>(entity);
  319. if (!result)
  320. {
  321. returnValue = "新增失败";
  322. }
  323. }
  324. else
  325. {
  326. //检验自由项
  327. Colspan = model.ProjectCode + "~" + model.BatchCode + "~" + model.Version
  328. + "~" + model.Brand + "~" + model.cFree1
  329. + "~" + model.cFree2 + "~" + model.cFree3 + "~" + model.cFree4
  330. + "~" + model.cFree5 + "~" + model.cFree6 + "~" + model.cFree7
  331. + "~" + model.cFree8 + "~" + model.cFree9 + "~" + model.cFree10;
  332. sql = @"select ID,Colspan from ICSExtension a
  333. where Colspan='{0}' and WorkPoint='{1}'";
  334. sql = string.Format(sql, Colspan, model.WorkPoint);
  335. var dtt = SqlHelper.CmdExecuteDataTable(sql);
  336. if (dtt.Rows.Count == 0)
  337. {
  338. IDD = Guid.NewGuid().ToString();
  339. sql = @"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  340. select '{17}','{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}',GETDATE(),'{15}',f.F_RealName,'{16}'from Sys_SRM_User f where f.F_Account='{15}' and f.F_Location='{16}'";
  341. sql = string.Format(sql, Colspan, model.ProjectCode, model.BatchCode, model.Version, model.Brand, model.cFree1, model.cFree2, model.cFree3, model.cFree4, model.cFree5, model.cFree6, model.cFree7, model.cFree8, model.cFree9, model.cFree10, model.User, model.WorkPoint, IDD);
  342. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  343. {
  344. throw new Exception("自由项添加失败");
  345. }
  346. }
  347. else
  348. {
  349. IDD = dtt.Rows[0]["ID"].ToString();
  350. }
  351. ConvertExt.Mapping<ICSTransferEdit, ICSTransfer>(model, entity);
  352. entity.TransferID = "";
  353. entity.TransferDetailID = "";
  354. //entity.TransferID = "";
  355. //entity.TransferDetailID = "";
  356. entity.CreatePerson = MUSER;
  357. entity.CreateDateTime = Dates;
  358. entity.MUSER = MUSER;
  359. entity.MUSERName = MUSERNAME;
  360. entity.MTIME = Dates;
  361. entity.ExtensionID = IDD;
  362. var result = MsSqlData.Update<ICSTransfer>(entity);
  363. if (!result)
  364. {
  365. returnValue = "修改失败";
  366. }
  367. }
  368. }
  369. }
  370. }
  371. catch (Exception ex)
  372. {
  373. returnValue = ex.Message;
  374. }
  375. return returnValue;
  376. }
  377. /// <summary>
  378. /// 创建自增单号
  379. /// </summary>
  380. /// <param name="WorkPoint"></param>
  381. /// <returns></returns>
  382. public string GetOOCode(string WorkPoint)
  383. {
  384. WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  385. string OOCode = string.Empty;
  386. if (!string.IsNullOrEmpty(WorkPoint))
  387. {
  388. OOCode = GetSerialCode(WorkPoint, "ICSTransfer", "TransferNO", "00", 8);
  389. }
  390. if (!string.IsNullOrWhiteSpace(OOCode))
  391. {
  392. string sqlISHave = @"SELECT TransferNO FROM ICSTransfer a
  393. WHERE a.TransferNO = '{0}'";
  394. sqlISHave = string.Format(sqlISHave, OOCode);
  395. DataTable dtIsHave = SqlHelper.GetDataTableBySql(sqlISHave);
  396. if (dtIsHave.Rows.Count > 0)
  397. {
  398. throw new Exception("单号已存在!");
  399. }
  400. }
  401. return OOCode;
  402. }
  403. public string GetSerialCode(string workPointCode, string tbName, string colName, string Pre, int numLen)
  404. {
  405. string sql = "EXEC Addins_GetSerialCode '{0}','{1}','{2}','{3}',{4}";
  406. sql = string.Format(sql, new object[] { workPointCode, tbName, colName, Pre, numLen });
  407. return SqlHelper.ExecuteScalar(sql).ToString();
  408. }
  409. public void UpdateOutsourcingOrderApplyNegTemp(string json)
  410. {
  411. var data = json.ToJObject();
  412. string usercode = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  413. var info = Invmes.Select(string.Format("TLZID='{0}'", data["TLZID"]));
  414. if (info != null && info.Length > 0)
  415. {
  416. info[0]["ZJID"] = data["ZJID"];
  417. info[0]["InvName"] = data["InvName"];
  418. }
  419. else
  420. {
  421. DataRow newrow = Invmes.NewRow();
  422. newrow["ZJID"] = data["ZJID"];
  423. Invmes.Rows.Add(newrow);
  424. }
  425. }
  426. public DataTable GetICSTransferReturnTemporary(string TransferNO)
  427. {
  428. string sql = @"SELECT a.ID,a.TransferNO,a.Sequence,a.InvCode,a.Quantity,a.Amount,a.TransferQuantity,a.FromWarehouseCode as FromWHCode,a.FromLocationCode as FromLotCode,a.Type,a.Memo
  429. ,a.ToWarehouseCode as ToWHCode,a.ToLocationCode as ToLotCode,b.InvName,a.ExtensionID,a.MUSER,a.MUSERName,a.MTIME,a.WorkPoint
  430. from ICSTransfer a
  431. left join ICSInventory b on a.InvCode = b.InvCode and a.WorkPoint = b.WorkPoint
  432. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  433. where a.TransferNO ='" + TransferNO + "' ";
  434. DataTable table = Repository().FindDataSetBySql(sql).Tables[0];
  435. DataTable dtCloned = table.Clone();
  436. foreach (DataColumn col in dtCloned.Columns)
  437. {
  438. col.DataType = typeof(string);
  439. }
  440. foreach (DataRow row in table.Rows)
  441. {
  442. DataRow newrow = dtCloned.NewRow();
  443. foreach (DataColumn column in dtCloned.Columns)
  444. {
  445. newrow[column.ColumnName] = row[column.ColumnName].ToString();
  446. }
  447. dtCloned.Rows.Add(newrow);
  448. }
  449. if (Invmes.Rows.Count > 0)
  450. {
  451. dtCloned.Merge(Invmes, false);
  452. }
  453. return dtCloned;
  454. }
  455. }
  456. }