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.

565 lines
24 KiB

  1. using NFine.Data.Extensions;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using NFine.Code;
  9. using NFine.Repository;
  10. using System.Data.Common;
  11. using NFine.Domain._03_Entity.SRM;
  12. using ICS.Application.Entity;
  13. using Newtonsoft.Json;
  14. using System.Configuration;
  15. using System.Data.SqlClient;
  16. using ICS.Data;
  17. using Newtonsoft.Json.Linq;
  18. using NFine.Domain._03_Entity.WMS;
  19. using System.Net;
  20. using System.IO;
  21. namespace NFine.Application.WMS
  22. {
  23. public class PurOrderApp : RepositoryFactory<ICSVendor>
  24. {
  25. public static DataTable Invmes = new DataTable();
  26. // public static DataTable Supplier = new DataTable();
  27. /// <summary>
  28. /// 退料
  29. /// </summary>
  30. /// <param name="jqgridparam"></param>
  31. /// <returns></returns>
  32. public DataTable GetICSMOApplyNeg(ref Pagination jqgridparam)
  33. {
  34. DataTable dt = new DataTable();
  35. List<DbParameter> parameter = new List<DbParameter>();
  36. string sql = @" select distinct a.POCode,a.VenCode,a.DepCode,a.PersonCode,a.Status,a.POType,a.CreatePerson,a.CreateDateTime,a.MUSER,a.MUSERName
  37. from ICSPurchaseOrder a
  38. where a.POType='1'";
  39. sql = string.Format(sql);
  40. DataTable dttest = Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  41. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  42. }
  43. //子表查询
  44. public DataTable GetICSMOApplyNegDetail(string POCode, ref Pagination jqgridparam)
  45. {
  46. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  47. DataTable dt = new DataTable();
  48. //var queryParam = queryJson.ToJObject();
  49. List<DbParameter> parameter = new List<DbParameter>();
  50. string sql = @"select a.ID,a.POCode,a.Sequence,a.InvCode,a.Quantity,a.Amount,a.InQuantity,a.ExtensionID,a.MUSER
  51. ,a.MUSERName,a.MTIME
  52. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  53. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  54. from ICSPurchaseOrder a
  55. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  56. WHERE a.POCode='" + POCode + "' ";
  57. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  58. }
  59. public DataTable GetINV(string invcode, ref Pagination jqgridparam)
  60. {
  61. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  62. List<DbParameter> parameter = new List<DbParameter>();
  63. DataTable table = new DataTable();
  64. string wherestr = "";
  65. if (!string.IsNullOrEmpty(invcode))
  66. {
  67. //wherestr += " and a.InvCode like '%" + invcode + "%'";
  68. wherestr += " and InvCode like '%" + invcode + "%'";
  69. }
  70. // string sql = @"SELECT DISTINCT a.ID,a.PoCode,a.Sequence,a.InvCode,a.Quantity,a.InQuantity,a.Amount,b.InvName,b.InvStd,b.InvUnit,a.ExtensionID
  71. //,f.Colspan,isnull(f.ProjectCode,'') AS ProjectCode ,isnull(f.BatchCode,'') AS BatchCode ,isnull(f.Version,'') AS Version ,isnull(f.Brand,'') AS Brand ,isnull(f.cFree1,'') AS cFree1,isnull(f.cFree2,'') AS cFree2,isnull(f.cFree3,'') AS cFree3 ,isnull(f.cFree4,'') AS cFree4
  72. //,isnull(f.cFree5,'') AS cFree5 ,isnull(f.cFree6,'') AS cFree6 ,isnull(f.cFree7,'') AS cFree7 ,isnull(f.cFree8,'') AS cFree8 ,isnull(f.cFree9,'') AS cFree9 ,isnull(f.cFree10,'') AS cFree10
  73. //FROM ICSPurchaseOrder a
  74. //left JOIN ICSInventory b ON a.InvCode = b.InvCode and a.WorkPoint=b.WorkPoint
  75. // left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  76. //where a.WorkPoint = '" + WorkPoint + "'" + wherestr;
  77. string sql = @"select ID, InvCode ,InvName ,InvStd ,InvUnit ,ClassCode ,ClassName from ICSInventory where WorkPoint = '" + WorkPoint + "'" + wherestr;
  78. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  79. }
  80. public DataTable GetICSMOPickLog(string invcode, ref Pagination jqgridparam)
  81. {
  82. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  83. List<DbParameter> parameter = new List<DbParameter>();
  84. DataTable table = new DataTable();
  85. //string wherestr = "";
  86. //if (!string.IsNullOrEmpty(invcode))
  87. //{
  88. // wherestr += " and a.InvCode like '%" + invcode + "'%";
  89. //}
  90. string sql = @" select distinct a.POCode,a.Sequence,a.Quantity,a.Amount,a.ID,a.InvCode
  91. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  92. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  93. from ICSPurchaseOrder a
  94. left join ICSExtension f on a.ExtensionID=f.ID
  95. where a.InvCode='{0}' and a.WorkPoint='{1}'
  96. ";
  97. sql = string.Format(sql, invcode, WorkPoint);
  98. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  99. }
  100. /// <summary>
  101. /// 获取仓库列表
  102. /// </summary>
  103. /// <returns></returns>
  104. public DataTable GetInvCode()
  105. {
  106. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  107. string sql = @"
  108. select '' as InvCode,
  109. union all
  110. select InvCode from ICSInventory where WorkPoint='{0}'
  111. ";
  112. //string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
  113. //if (role != "admin")
  114. //{
  115. // sql += " and b.WorkPoint=" + WorkPoint.TrimEnd(',') + "";
  116. //}
  117. sql = string.Format(sql, WorkPoint);
  118. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  119. return dt;
  120. }
  121. public DataTable GetICSReturnTemporary(string rfqno)
  122. {
  123. string sql = @"SELECT
  124. a.POCode,
  125. a.InvCode,
  126. a.Quantity,
  127. a.Amount,
  128. b.InvName,
  129. b.InvStd,
  130. b.InvUnit
  131. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  132. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  133. FROM
  134. ICSPurchaseOrder a
  135. LEFT JOIN ICSInventory b ON a.InvCode = b.InvCode
  136. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  137. where a.POCode='" + rfqno + "'";
  138. DataTable table = Repository().FindDataSetBySql(sql).Tables[0];
  139. DataTable dtCloned = table.Clone();
  140. foreach (DataColumn col in dtCloned.Columns)
  141. {
  142. col.DataType = typeof(string);
  143. }
  144. foreach (DataRow row in table.Rows)
  145. {
  146. DataRow newrow = dtCloned.NewRow();
  147. foreach (DataColumn column in dtCloned.Columns)
  148. {
  149. newrow[column.ColumnName] = row[column.ColumnName].ToString();
  150. }
  151. dtCloned.Rows.Add(newrow);
  152. }
  153. if (Invmes.Rows.Count > 0)
  154. {
  155. dtCloned.Merge(Invmes, false);
  156. }
  157. return dtCloned;
  158. }
  159. public string GetNewid()
  160. {
  161. string sql = "select newid() AS ID";
  162. return Repository().FindTableBySql(sql, null).Rows[0]["ID"].ToString();
  163. }
  164. public void AddPurOrderTemp(string json)
  165. {
  166. var data = json.ToJObject();
  167. if (Invmes.Columns.Count <= 0)
  168. {
  169. //Invmes.Columns.Add("ID", typeof(string));
  170. //Invmes.Columns.Add("PoCode", typeof(string));
  171. Invmes.Columns.Add("InvCode", typeof(string));
  172. Invmes.Columns.Add("InvName", typeof(string));
  173. Invmes.Columns.Add("InvStd", typeof(string));
  174. Invmes.Columns.Add("InvUnit", typeof(string));
  175. Invmes.Columns.Add("Quantity", typeof(string));
  176. Invmes.Columns.Add("IssueQuantity", typeof(string));
  177. Invmes.Columns.Add("ExtensionID", typeof(string));
  178. Invmes.Columns.Add("Amount", typeof(string));
  179. Invmes.Columns.Add("ID", typeof(string));
  180. Invmes.Columns.Add("ProjectCode", typeof(string));
  181. Invmes.Columns.Add("BatchCode", typeof(string));
  182. Invmes.Columns.Add("Version", typeof(string));
  183. Invmes.Columns.Add("Brand", typeof(string));
  184. Invmes.Columns.Add("cFree1", typeof(string));
  185. Invmes.Columns.Add("cFree2", typeof(string));
  186. Invmes.Columns.Add("cFree3", typeof(string));
  187. Invmes.Columns.Add("cFree4", typeof(string));
  188. Invmes.Columns.Add("cFree5", typeof(string));
  189. Invmes.Columns.Add("cFree6", typeof(string));
  190. Invmes.Columns.Add("cFree7", typeof(string));
  191. Invmes.Columns.Add("cFree8", typeof(string));
  192. Invmes.Columns.Add("cFree9", typeof(string));
  193. Invmes.Columns.Add("cFree10", typeof(string));
  194. }
  195. string usercode = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  196. DataRow newrow = Invmes.NewRow();
  197. //newrow["ID"] = data["ID"];
  198. //newrow["PoCode"] = data["PoCode"];
  199. newrow["InvName"] = data["InvName"];
  200. newrow["InvCode"] = data["InvCode"];
  201. newrow["InvStd"] = data["InvStd"];
  202. newrow["InvUnit"] = data["InvUnit"];
  203. newrow["Amount"] = data["Amount"];
  204. newrow["IssueQuantity"] = data["IssueQuantity"];
  205. newrow["ExtensionID"] = data["ExtensionID"];
  206. newrow["Quantity"] = "";
  207. newrow["ID"] = data["ID"];
  208. newrow["ProjectCode"] = data["ProjectCode"];
  209. newrow["BatchCode"] = data["BatchCode"];
  210. newrow["Version"] = data["Version"];
  211. newrow["Brand"] = data["Brand"];
  212. newrow["cFree1"] = data["cFree1"];
  213. newrow["cFree2"] = data["cFree2"];
  214. newrow["cFree3"] = data["cFree3"];
  215. newrow["cFree4"] = data["cFree4"];
  216. newrow["cFree5"] = data["cFree5"];
  217. newrow["cFree6"] = data["cFree6"];
  218. newrow["cFree7"] = data["cFree7"];
  219. newrow["cFree8"] = data["cFree8"];
  220. newrow["cFree9"] = data["cFree9"];
  221. newrow["cFree10"] = data["cFree10"];
  222. Invmes.Rows.Add(newrow);
  223. }
  224. public string DeleteMopick(string json)
  225. {
  226. try
  227. {
  228. string wheresql = "(";
  229. string[] id = json.Split(',');
  230. for (int i = 0; i < id.Length; i++)
  231. {
  232. wheresql += "'" + id[i].Replace(']', ' ').Replace('[', ' ').Replace('"', ' ').Trim() + "',";
  233. }
  234. wheresql = wheresql.Trim(',') + ")";
  235. string sql = "delete from ICSMOApplyNeg where id in" + wheresql;
  236. int count = DbHelper.ExecuteNonQuery(CommandType.Text, sql);
  237. DataRow[] row = Invmes.Select("ID in " + wheresql + "");
  238. foreach (DataRow a in row)
  239. {
  240. Invmes.Rows.Remove(a);
  241. }
  242. return "删除成功!";
  243. }
  244. catch (Exception ex)
  245. {
  246. return ex.Message + " 删除失败!";
  247. }
  248. }
  249. public void ClearTemp()
  250. {
  251. Invmes.Rows.Clear();
  252. }
  253. public string SaveICSPurOrder(string ICSASN)
  254. {
  255. string msg = "";
  256. string APIURL = ConfigurationManager.ConnectionStrings["APIURL"].ConnectionString + "PurOrderCreate/Create";
  257. string result = HttpPost(APIURL, ICSASN);
  258. JObject Obj = (JObject)JsonConvert.DeserializeObject(result);//或者JObject jo = JObject.Parse(jsonText);
  259. string MessAge = Obj["Message"].ToString();
  260. string Success = Obj["Success"].ToString();
  261. if (Success.ToUpper() == "FALSE")
  262. {
  263. msg = MessAge;
  264. }
  265. return msg;
  266. }
  267. public string UpdateICSPurOrder(string ICSASN)
  268. {
  269. string msg = "";
  270. string APIURL = ConfigurationManager.ConnectionStrings["APIURL"].ConnectionString + "PurOrderCreate/Update";
  271. string result = HttpPost(APIURL, ICSASN);
  272. JObject Obj = (JObject)JsonConvert.DeserializeObject(result);//或者JObject jo = JObject.Parse(jsonText);
  273. string MessAge = Obj["Message"].ToString();
  274. string Success = Obj["Success"].ToString();
  275. if (Success.ToUpper() == "FALSE")
  276. {
  277. msg = MessAge;
  278. }
  279. return msg;
  280. }
  281. //接口api解析
  282. public static string HttpPost(string url, string body)
  283. {
  284. try
  285. {
  286. Encoding encoding = Encoding.UTF8;
  287. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
  288. request.Method = "POST";
  289. request.Accept = "application/json, text/javascript, */*"; //"text/html, application/xhtml+xml, */*";
  290. request.ContentType = "application/json; charset=utf-8";
  291. byte[] buffer = encoding.GetBytes(body);
  292. request.ContentLength = buffer.Length;
  293. request.GetRequestStream().Write(buffer, 0, buffer.Length);
  294. HttpWebResponse response = (HttpWebResponse)request.GetResponse();
  295. using (StreamReader reader = new StreamReader(response.GetResponseStream(), encoding))
  296. {
  297. return reader.ReadToEnd();
  298. }
  299. }
  300. catch (WebException ex)
  301. {
  302. throw new Exception(ex.Message);
  303. }
  304. }
  305. /// <summary>
  306. /// 获取料品属性修改文本框值
  307. /// </summary>
  308. /// <param name="POCode"></param>
  309. /// <param name="PORow"></param>
  310. /// <returns></returns>
  311. public DataTable GetInputValue(string ID)
  312. {
  313. try
  314. {
  315. DataTable dt = new DataTable();
  316. //var queryParam = queryJson.ToJObject();
  317. List<DbParameter> parameter = new List<DbParameter>();
  318. string sql = @"select InvCode,InvName,InvDesc,InvStd,InvUnit,AmountUnit, ClassCode,ClassName,InvRate,InvVersion,InvBrand,InvIQC,
  319. InvFQC,EffectiveEnable,EffectiveDays,BatchEnable,LotEnable,PrintEnable,WHUser
  320. from ICSInventory
  321. WHERE 1=1 AND ID='{0}' ";
  322. sql = string.Format(sql, ID);
  323. return Repository().FindTableBySql(sql.ToString());
  324. }
  325. catch (Exception ex)
  326. {
  327. throw new Exception(ex.Message.ToString());
  328. }
  329. }
  330. public DataTable GetICSMOApplyNegDetailTemp(string PoCode)
  331. {
  332. string sql = @"SELECT DISTINCT
  333. a.ID,
  334. a.ID as TLZID,
  335. a.PoCode,
  336. a.InvCode,
  337. a.Quantity,
  338. a.Amount,
  339. b.InvName,
  340. b.InvStd,
  341. b.InvUnit,a.VenCode,a.DepCode,
  342. a.ExtensionID
  343. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  344. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  345. FROM
  346. ICSPurchaseOrder a
  347. LEFT JOIN ICSInventory b ON a.InvCode = b.InvCode
  348. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  349. where a.PoCode='" + PoCode + "'";
  350. DataTable table = Repository().FindDataSetBySql(sql).Tables[0];
  351. if(Invmes==null || Invmes.Columns.Count<=0)
  352. Invmes = table.Clone();
  353. DataTable dtCloned = table.Clone();
  354. foreach (DataColumn col in dtCloned.Columns)
  355. {
  356. col.DataType = typeof(string);
  357. }
  358. foreach (DataRow row in table.Rows)
  359. {
  360. DataRow newrow = dtCloned.NewRow();
  361. foreach (DataColumn column in dtCloned.Columns)
  362. {
  363. newrow[column.ColumnName] = row[column.ColumnName].ToString();
  364. }
  365. dtCloned.Rows.Add(newrow);
  366. }
  367. if (Invmes.Rows.Count > 0)
  368. {
  369. //dtCloned.Merge(Invmes, false);
  370. foreach (DataRow data in Invmes.Rows)
  371. {
  372. var info = dtCloned.Select(string.Format("TLZID='{0}'", data["TLZID"]));
  373. if (info != null && info.Length > 0)
  374. {
  375. info[0]["ZJID"] = data["ZJID"];
  376. info[0]["InvName"] = data["InvName"];
  377. info[0]["InvCode"] = data["InvCode"];
  378. info[0]["InvStd"] = data["InvStd"];
  379. info[0]["InvUnit"] = data["InvUnit"];
  380. info[0]["Amount"] = data["Amount"];
  381. info[0]["IssueNegQuantity"] = data["IssueNegQuantity"];
  382. info[0]["ExtensionID"] = data["ExtensionID"];
  383. info[0]["Quantity"] = 0;
  384. info[0]["ProjectCode"] = data["ProjectCode"];
  385. info[0]["BatchCode"] = data["BatchCode"];
  386. info[0]["Version"] = data["Version"];
  387. info[0]["Brand"] = data["Brand"];
  388. info[0]["cFree1"] = data["cFree1"];
  389. info[0]["cFree2"] = data["cFree2"];
  390. info[0]["cFree3"] = data["cFree3"];
  391. info[0]["cFree4"] = data["cFree4"];
  392. info[0]["cFree5"] = data["cFree5"];
  393. info[0]["cFree6"] = data["cFree6"];
  394. info[0]["cFree7"] = data["cFree7"];
  395. info[0]["cFree8"] = data["cFree8"];
  396. info[0]["cFree9"] = data["cFree9"];
  397. info[0]["cFree10"] = data["cFree10"];
  398. }
  399. else
  400. {
  401. DataRow newrow = dtCloned.NewRow();
  402. newrow["ZJID"] = data["ZJID"];
  403. newrow["InvName"] = data["InvName"];
  404. newrow["InvCode"] = data["InvCode"];
  405. newrow["InvStd"] = data["InvStd"];
  406. newrow["InvUnit"] = data["InvUnit"];
  407. newrow["Amount"] = data["Amount"];
  408. newrow["Quantity"] = 0;
  409. newrow["ID"] = data["ID"];
  410. newrow["TLZID"] = data["TLZID"];
  411. newrow["IssueNegQuantity"] = data["IssueNegQuantity"];
  412. newrow["ExtensionID"] = data["ExtensionID"];
  413. newrow["ProjectCode"] = data["ProjectCode"];
  414. newrow["BatchCode"] = data["BatchCode"];
  415. newrow["Version"] = data["Version"];
  416. newrow["Brand"] = data["Brand"];
  417. newrow["cFree1"] = data["cFree1"];
  418. newrow["cFree2"] = data["cFree2"];
  419. newrow["cFree3"] = data["cFree3"];
  420. newrow["cFree4"] = data["cFree4"];
  421. newrow["cFree5"] = data["cFree5"];
  422. newrow["cFree6"] = data["cFree6"];
  423. newrow["cFree7"] = data["cFree7"];
  424. newrow["cFree8"] = data["cFree8"];
  425. newrow["cFree9"] = data["cFree9"];
  426. newrow["cFree10"] = data["cFree10"];
  427. dtCloned.Rows.Add(newrow);
  428. }
  429. }
  430. }
  431. return dtCloned;
  432. }
  433. public void UpdateMOApplyNegTemp(string json)
  434. {
  435. var data = json.ToJObject();
  436. string usercode = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  437. var info = Invmes.Select(string.Format("TLZID='{0}'", data["TLZID"]));
  438. if (info != null && info.Length > 0)
  439. {
  440. info[0]["ZJID"] = data["ZJID"];
  441. info[0]["InvName"] = data["InvName"];
  442. info[0]["InvCode"] = data["InvCode"];
  443. info[0]["InvStd"] = data["InvStd"];
  444. info[0]["InvUnit"] = data["InvUnit"];
  445. info[0]["Amount"] = data["Amount"];
  446. info[0]["IssueNegQuantity"] = data["IssueNegQuantity"];
  447. info[0]["ExtensionID"] = data["ExtensionID"];
  448. info[0]["Quantity"] = 0;
  449. }
  450. else
  451. {
  452. DataRow newrow = Invmes.NewRow();
  453. newrow["ZJID"] = data["ZJID"];
  454. newrow["InvName"] = data["InvName"];
  455. newrow["InvCode"] = data["InvCode"];
  456. newrow["InvStd"] = data["InvStd"];
  457. newrow["InvUnit"] = data["InvUnit"];
  458. newrow["Amount"] = data["Amount"];
  459. newrow["IssueNegQuantity"] = data["IssueNegQuantity"];
  460. newrow["ExtensionID"] = data["ExtensionID"];
  461. newrow["Quantity"] = 0;
  462. newrow["ID"] = data["ID"];
  463. newrow["TLZID"] = data["TLZID"];
  464. Invmes.Rows.Add(newrow);
  465. }
  466. }
  467. public string AuditICSPurOrder(string ICSASN)
  468. {
  469. string msg = "";
  470. string APIURL = ConfigurationManager.ConnectionStrings["APIURL"].ConnectionString + "PurOrder/Approve";
  471. string result = HttpPost(APIURL, ICSASN);
  472. JObject Obj = (JObject)JsonConvert.DeserializeObject(result);//或者JObject jo = JObject.Parse(jsonText);
  473. string MessAge = Obj["Message"].ToString();
  474. string Success = Obj["Success"].ToString();
  475. if (Success.ToUpper() == "FALSE")
  476. {
  477. msg = MessAge;
  478. }
  479. return msg;
  480. }
  481. public string DeleteICSPurchaseOrder(string keyValue)
  482. {
  483. //站点信息
  484. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  485. string msg = "";
  486. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  487. string sql = string.Empty;
  488. sql += string.Format(@"IF EXISTS(SELECT 1 FROM ICSPurchaseOrder WHERE POCode IN ({0}) and WorkPoint ='{1}' and InQuantity>0)
  489. BEGIN
  490. RAISERROR('',16,1);
  491. RETURN
  492. END
  493. ELSE
  494. BEGIN
  495. DELETE FROM dbo.ICSPurchaseOrder WHERE POCode IN ({0}) and WorkPoint ='{1}'
  496. END", keyValue.TrimEnd(','), WorkPoint);
  497. try
  498. {
  499. SqlHelper.ExecuteNonQuery(sql);
  500. }
  501. catch (Exception ex)
  502. {
  503. msg = ex.Message;
  504. }
  505. //try
  506. //{
  507. // if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  508. // {
  509. // }
  510. //}
  511. //catch (Exception ex)
  512. //{
  513. // throw new Exception(ex.Message);
  514. //}
  515. return msg;
  516. }
  517. }
  518. }