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

2081 lines
63 KiB

3 years ago
  1. using NFine.Application.WMS;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.IO;
  6. using System.Linq;
  7. using System.Web;
  8. using System.Web.Mvc;
  9. using NFine.Code;
  10. using System.Data.SqlClient;
  11. using NFine.Data.Extensions;
  12. using System.Data.OleDb;
  13. using System.Configuration;
  14. using ICS.Application.Entity;
  15. namespace NFine.Web.Areas.WMS.Controllers
  16. {
  17. public class BasicSettingsController : ControllerBase
  18. {
  19. BasicSettingsApp App = new BasicSettingsApp();
  20. /// <summary>
  21. /// 加载仓库
  22. /// </summary>
  23. /// <returns></returns>
  24. [HttpGet]
  25. public ActionResult Warehouse()
  26. {
  27. return View();
  28. }
  29. /// <summary>
  30. /// 加载库位
  31. /// </summary>
  32. /// <returns></returns>
  33. [HttpGet]
  34. public ActionResult ICSStackWMS()
  35. {
  36. return View();
  37. }
  38. /// <summary>
  39. /// 物料档案
  40. /// </summary>
  41. /// <returns></returns>
  42. [HttpGet]
  43. public ActionResult ICSINVENTORY()
  44. {
  45. return View();
  46. }
  47. /// <summary>
  48. /// 不良代码组
  49. /// </summary>
  50. /// <returns></returns>
  51. [HttpGet]
  52. public ActionResult ICSECG()
  53. {
  54. return View();
  55. }
  56. [HttpGet]
  57. public ActionResult ICSSDN()
  58. {
  59. return View();
  60. }
  61. /// <summary>
  62. /// 不良代码维护
  63. /// </summary>
  64. /// <returns></returns>
  65. [HttpGet]
  66. public ActionResult ICSBadCode()
  67. {
  68. return View();
  69. }
  70. /// <summary>
  71. /// 新增库位信息
  72. /// </summary>
  73. /// <returns></returns>
  74. [HttpGet]
  75. public ActionResult ICSStackWMSAdd()
  76. {
  77. return View();
  78. }
  79. [HttpGet]
  80. /// <summary>
  81. /// 标签模板维护
  82. /// </summary>
  83. /// <returns></returns>
  84. public ActionResult ICSLableManage()
  85. {
  86. return View();
  87. }
  88. public ActionResult ICSLableManageAdd()
  89. {
  90. return View();
  91. }
  92. /// <summary>
  93. /// 新增不良代码
  94. /// </summary>
  95. /// <returns></returns>
  96. public ActionResult ICSBadCodeAdd()
  97. {
  98. return View();
  99. }
  100. /// <summary>
  101. /// 类型维护
  102. /// </summary>
  103. /// <returns></returns>
  104. public ActionResult ICSTypeMaintain()
  105. {
  106. return View();
  107. }
  108. /// 新增类型
  109. /// </summary>
  110. /// <returns></returns>
  111. [HttpGet]
  112. public ActionResult ICSTypeMaintainAdd()
  113. {
  114. return View();
  115. }
  116. /// <summary>
  117. /// 配置参数维护
  118. /// </summary>
  119. /// <returns></returns>
  120. public ActionResult ICSConfiguration()
  121. {
  122. return View();
  123. }
  124. /// <summary>
  125. /// 启用配置
  126. /// </summary>
  127. /// <returns></returns>
  128. public ActionResult ICSExtensionEnable()
  129. {
  130. return View();
  131. }
  132. /// <summary>
  133. /// 新增启用配置
  134. /// </summary>
  135. /// <returns></returns>
  136. public ActionResult ICSExtensionEnableAdd()
  137. {
  138. return View();
  139. }
  140. /// 新增类型
  141. /// </summary>
  142. /// <returns></returns>
  143. [HttpGet]
  144. public ActionResult ICSConfigurationAdd()
  145. {
  146. return View();
  147. }
  148. /// 不良原因组
  149. /// </summary>
  150. /// <returns></returns>
  151. [HttpGet]
  152. public ActionResult ICSBadReasonGroup()
  153. {
  154. return View();
  155. }
  156. /// 新增不良原因组
  157. /// </summary>
  158. /// <returns></returns>
  159. [HttpGet]
  160. public ActionResult ICSBadReasonGroupAdd()
  161. {
  162. return View();
  163. }
  164. /// 新增不良原因组
  165. /// </summary>
  166. /// <returns></returns>
  167. [HttpGet]
  168. public ActionResult ICSInventoryBadGroupAdd()
  169. {
  170. return View();
  171. }
  172. [HttpGet]
  173. //不良代码
  174. public ActionResult GetICSBadCodeGroup(Pagination pagination,string queryJson)
  175. {
  176. DataTable ListData = App.GetICSBadCodeGroup(ref pagination, queryJson);
  177. var JsonData = new
  178. {
  179. total = pagination.total,
  180. page = pagination.page,
  181. records = pagination.records,
  182. rows = ListData,
  183. };
  184. return Content(JsonData.ToJson());
  185. }
  186. //不良原因()
  187. public ActionResult GetICSBadReasonGroup(Pagination pagination, string queryJson)
  188. {
  189. DataTable ListData = App.GetICSBadReasonGroup(ref pagination, queryJson);
  190. var JsonData = new
  191. {
  192. total = pagination.total,
  193. page = pagination.page,
  194. records = pagination.records,
  195. rows = ListData,
  196. };
  197. return Content(JsonData.ToJson());
  198. }
  199. //不良代码子表
  200. [HttpGet]
  201. [HandlerAjaxOnly]
  202. public ActionResult GetICSBadCodeGroupdetil(string ID, Pagination pagination)
  203. {
  204. DataTable ListData = App.GetICSBadCodeGroupdetil(ID, ref pagination);
  205. var JsonData = new
  206. {
  207. total = pagination.total,
  208. page = pagination.page,
  209. records = pagination.records,
  210. rows = ListData,
  211. };
  212. return Content(JsonData.ToJson());
  213. }
  214. [HttpGet]
  215. public ActionResult GetICSBadCodeGroupdetil2(string ID)
  216. {
  217. var data = App.GetICSBadCodeGroupdetil2(ID);
  218. return Content(data.ToJson());
  219. }
  220. //不良原因子表
  221. [HttpGet]
  222. [HandlerAjaxOnly]
  223. public ActionResult GetICSBadReason(string BRGCode, Pagination pagination)
  224. {
  225. DataTable ListData = App.GetICSBadReason(BRGCode, ref pagination);
  226. var JsonData = new
  227. {
  228. total = pagination.total,
  229. page = pagination.page,
  230. records = pagination.records,
  231. rows = ListData,
  232. };
  233. return Content(JsonData.ToJson());
  234. }
  235. [HttpGet]
  236. public ActionResult GetICSBadReason2(string BRGCode)
  237. {
  238. var data = App.GetICSBadReason2(BRGCode);
  239. return Content(data.ToJson());
  240. }
  241. [HttpGet]
  242. public ActionResult ICSInspectionGroup()
  243. {
  244. return View();
  245. }
  246. [HttpGet]
  247. public ActionResult ICSInspectionListAdd()
  248. {
  249. return View();
  250. }
  251. [HttpGet]
  252. public ActionResult ICSINVEBTORYAdd()
  253. {
  254. return View();
  255. }
  256. [HttpGet]
  257. public ActionResult ICSInventoryBatchEnable()
  258. {
  259. return View();
  260. }
  261. [HttpGet]
  262. public ActionResult ICSInventoryBatchEnableAdd()
  263. {
  264. return View();
  265. }
  266. [HttpGet]
  267. public ActionResult ICSInventoryBatchEnableUpadte()
  268. {
  269. return View();
  270. }
  271. [HttpGet]
  272. public ActionResult ICSInventoryLocation()
  273. {
  274. return View();
  275. }
  276. [HttpGet]
  277. public ActionResult ICSInventoryLocationAdd()
  278. {
  279. return View();
  280. }
  281. [HttpGet]
  282. public ActionResult ICSInventoryLocationUpdate()
  283. {
  284. return View();
  285. }
  286. [HttpGet]
  287. public ActionResult ICSContainer()
  288. {
  289. return View();
  290. }
  291. [HttpGet]
  292. public ActionResult ICSContainerAdd()
  293. {
  294. return View();
  295. }
  296. [HttpGet]
  297. public ActionResult ICSContainerLot()
  298. {
  299. return View();
  300. }
  301. [HttpGet]
  302. public ActionResult ICSContainerLotAdd()
  303. {
  304. return View();
  305. }
  306. [HttpGet]
  307. public ActionResult ICSInventoryBadGroup()
  308. {
  309. return View();
  310. }
  311. [HttpGet]
  312. public ActionResult ICSInventoryBadGroupUpdate()
  313. {
  314. return View();
  315. }
  316. [HttpGet]
  317. public ActionResult ICSLabelTemplate()
  318. {
  319. return View();
  320. }
  321. [HttpGet]
  322. public ActionResult ICSLabelTemplateAdd()
  323. {
  324. return View();
  325. }
  326. // public ActionResult DownloadExcl(int day)
  327. // {
  328. // try
  329. // {
  330. // //int showDay = NVelocityBLL.DAY_AGO * -1;
  331. // //var list = NVelocityBLL.Instance.DataList;
  332. // //NVelocityBLL.Instance.Refresh();
  333. // //if (day != 0)
  334. // //{
  335. // //showDay = day;
  336. // //list = NVelocityBLL.Instance.GetDataByTotalDay(day);
  337. // //}
  338. // string sWebRootFolder = _hostingEnvironment.WebRootPath;
  339. // string sFileName = $"Subscription/{Guid.NewGuid()}.xlsx";
  340. // DeleteDir($"{sWebRootFolder}\\Subscription");
  341. // FileInfo file = new FileInfo(Path.Combine(sWebRootFolder, sFileName));
  342. // using (ExcelPackage package = new ExcelPackage(file))
  343. // {
  344. // ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("aspnetcore");
  345. // worksheet.Cells[1, 1].Value = "date/Step";
  346. // worksheet.DefaultColWidth = 25;
  347. // for (int i = 1; i <= showDay; i++)
  348. // {
  349. // // The number of now days.Used as a column header.
  350. // int nowDay = -(i - 1);
  351. // //Col index
  352. // int colIndex = i + 1;
  353. // //DateTime nowTime = NVelocityBLL.Instance.GetChinaByUtcDate(DateTime.UtcNow).AddDays(nowDay);
  354. // string utcTime = DateTime.UtcNow.AddDays(nowDay).ToString("yyyy-MM-dd");
  355. // //Insert the column header
  356. // worksheet.Cells[1, colIndex].Value = nowTime.ToString("yyyy-MM-dd");
  357. // //Insert the row
  358. // InsertExeclRow(list, worksheet, colIndex, nowTime);
  359. // }
  360. // package.Save();
  361. // }
  362. // return File(sFileName, "applicationnd.openxmlformats-officedocument.spreadsheetml.sheet");
  363. // }
  364. // catch (Exception ex)
  365. // {
  366. // FxLogger.DEFAULT.Error($"DownloadExcl:", ex);
  367. // return SiteBLL.ErrorResponseData(-2, ex.Message);
  368. // }
  369. //}
  370. /// <summary>
  371. /// 删除库位
  372. /// </summary>
  373. /// <returns></returns>
  374. [HttpPost]
  375. [HandlerAjaxOnly]
  376. [ValidateAntiForgeryToken]
  377. public ActionResult DeleteStack(string keyValue)
  378. {
  379. string msg = App.DeleteStack(keyValue);
  380. if (string.IsNullOrEmpty(msg))
  381. {
  382. return Success("删除成功!");
  383. }
  384. else
  385. {
  386. return Error(msg);
  387. }
  388. }
  389. /// <summary>
  390. /// 删除不良原因
  391. /// </summary>
  392. /// <returns></returns>
  393. [HttpPost]
  394. [HandlerAjaxOnly]
  395. [ValidateAntiForgeryToken]
  396. public ActionResult DeleteBadCode(string keyValue)
  397. {
  398. string msg = App.DeleteBadCode(keyValue);
  399. if (string.IsNullOrEmpty(msg))
  400. {
  401. return Success("删除成功!");
  402. }
  403. else
  404. {
  405. return Error(msg);
  406. }
  407. }
  408. [HttpPost]
  409. [HandlerAjaxOnly]
  410. public ActionResult InsertStack(string keyValue)
  411. {
  412. string msg = App.InsertStack(keyValue);
  413. if (!string.IsNullOrEmpty(msg))
  414. {
  415. return Error(msg);
  416. }
  417. else
  418. {
  419. return Success("添加成功!");
  420. }
  421. }
  422. [HttpPost]
  423. [HandlerAjaxOnly]
  424. public ActionResult InsertBadCode(string keyValue)
  425. {
  426. string msg = App.InsertBadCode(keyValue);
  427. if (!string.IsNullOrEmpty(msg))
  428. {
  429. return Error(msg);
  430. }
  431. else
  432. {
  433. return Success("添加成功!");
  434. }
  435. }
  436. [HttpPost]
  437. [HandlerAjaxOnly]
  438. public ActionResult UpdateBadCode(string keyValue)
  439. {
  440. string msg = App.UpdateBadCode(keyValue);
  441. if (!string.IsNullOrEmpty(msg))
  442. {
  443. return Error(msg);
  444. }
  445. else
  446. {
  447. return Success("修改成功!");
  448. }
  449. }
  450. [HttpPost]
  451. [HandlerAjaxOnly]
  452. public ActionResult UpdateStack(string keyValue)
  453. {
  454. string msg = App.UpdateStack(keyValue);
  455. if (!string.IsNullOrEmpty(msg))
  456. {
  457. return Error(msg);
  458. }
  459. else
  460. {
  461. return Success("修改成功!");
  462. }
  463. }
  464. /// <summary>
  465. /// 获取库位信息
  466. /// </summary>
  467. /// <returns></returns>
  468. public ActionResult GetWarehouse()
  469. {
  470. DataTable dt = App.GetWarehouse();
  471. return Content(dt.ToJson());
  472. }
  473. /// <summary>
  474. /// 新增类型
  475. /// </summary>
  476. /// <param name="keyValue"></param>
  477. /// <returns></returns>
  478. [HttpPost]
  479. [HandlerAjaxOnly]
  480. public ActionResult InsertICSType(string keyValue)
  481. {
  482. string msg = App.InsertICSType(keyValue);
  483. if (!string.IsNullOrEmpty(msg))
  484. {
  485. return Error(msg);
  486. }
  487. else
  488. {
  489. return Success("添加成功!");
  490. }
  491. }
  492. /// <summary>
  493. /// 修改类型
  494. /// </summary>
  495. /// <param name="keyValue"></param>
  496. /// <returns></returns>
  497. [HttpPost]
  498. [HandlerAjaxOnly]
  499. public ActionResult UpdateICSType(string keyValue)
  500. {
  501. string msg = App.UpdateICSType(keyValue);
  502. if (!string.IsNullOrEmpty(msg))
  503. {
  504. return Error(msg);
  505. }
  506. else
  507. {
  508. return Success("修改成功!");
  509. }
  510. }
  511. /// <summary>
  512. /// 删除类型
  513. /// </summary>
  514. /// <returns></returns>
  515. [HttpPost]
  516. [HandlerAjaxOnly]
  517. [ValidateAntiForgeryToken]
  518. public ActionResult DeleteICSType(string keyValue)
  519. {
  520. string msg = App.DeleteICSType(keyValue);
  521. if (string.IsNullOrEmpty(msg))
  522. {
  523. return Success("删除成功!");
  524. }
  525. else
  526. {
  527. return Error(msg);
  528. }
  529. }
  530. /// <summary>
  531. /// 修改配置参数
  532. /// </summary>
  533. /// <param name="keyValue"></param>
  534. /// <returns></returns>
  535. [HttpPost]
  536. [HandlerAjaxOnly]
  537. public ActionResult UpdateICSConfiguration(string keyValue)
  538. {
  539. string msg = App.UpdateICSConfiguration(keyValue);
  540. if (!string.IsNullOrEmpty(msg))
  541. {
  542. return Error(msg);
  543. }
  544. else
  545. {
  546. return Success("修改成功!");
  547. }
  548. }
  549. /// <summary>
  550. /// 新增参数配置
  551. /// </summary>
  552. /// <param name="keyValue"></param>
  553. /// <returns></returns>
  554. [HttpPost]
  555. [HandlerAjaxOnly]
  556. public ActionResult InsertICSConfiguration(string keyValue)
  557. {
  558. string msg = App.InsertICSConfiguration(keyValue);
  559. if (!string.IsNullOrEmpty(msg))
  560. {
  561. return Error(msg);
  562. }
  563. else
  564. {
  565. return Success("添加成功!");
  566. }
  567. }
  568. /// <summary>
  569. /// 删除参数配置
  570. /// </summary>
  571. /// <returns></returns>
  572. [HttpPost]
  573. [HandlerAjaxOnly]
  574. [ValidateAntiForgeryToken]
  575. public ActionResult DeleteICSConfiguration(string keyValue)
  576. {
  577. string msg = App.DeleteICSConfiguration(keyValue);
  578. if (string.IsNullOrEmpty(msg))
  579. {
  580. return Success("删除成功!");
  581. }
  582. else
  583. {
  584. return Error(msg);
  585. }
  586. }
  587. /// <summary>
  588. /// 修改启用配置
  589. /// </summary>
  590. /// <param name="keyValue"></param>
  591. /// <returns></returns>
  592. [HttpPost]
  593. [HandlerAjaxOnly]
  594. public ActionResult UpdateICSExtensionEnable(string keyValue)
  595. {
  596. string msg = App.UpdateICSExtensionEnable(keyValue);
  597. if (!string.IsNullOrEmpty(msg))
  598. {
  599. return Error(msg);
  600. }
  601. else
  602. {
  603. return Success("修改成功!");
  604. }
  605. }
  606. /// <summary>
  607. /// 新增启用配置
  608. /// </summary>
  609. /// <param name="keyValue"></param>
  610. /// <returns></returns>
  611. [HttpPost]
  612. [HandlerAjaxOnly]
  613. public ActionResult InsertICSExtensionEnable(string keyValue)
  614. {
  615. string msg = App.InsertICSExtensionEnable(keyValue);
  616. if (!string.IsNullOrEmpty(msg))
  617. {
  618. return Error(msg);
  619. }
  620. else
  621. {
  622. return Success("添加成功!");
  623. }
  624. }
  625. /// <summary>
  626. /// 删除启用配置
  627. /// </summary>
  628. /// <returns></returns>
  629. [HttpPost]
  630. [HandlerAjaxOnly]
  631. [ValidateAntiForgeryToken]
  632. public ActionResult DeleteICSExtensionEnable(string keyValue)
  633. {
  634. string msg = App.DeleteICSExtensionEnable(keyValue);
  635. if (string.IsNullOrEmpty(msg))
  636. {
  637. return Success("删除成功!");
  638. }
  639. else
  640. {
  641. return Error(msg);
  642. }
  643. }
  644. [HttpGet]
  645. public ActionResult DeleteBCItem(string ID)
  646. {
  647. try
  648. {
  649. App.DeleteBCItem(ID);
  650. return Success("删除成功!");
  651. }
  652. catch (Exception ex)
  653. {
  654. return Error(ex.Message);
  655. }
  656. }
  657. [HttpGet]
  658. public ActionResult DeleteItem(string ID)
  659. {
  660. try
  661. {
  662. App.DeleteItem(ID);
  663. return Success("删除成功!");
  664. }
  665. catch (Exception ex)
  666. {
  667. return Error(ex.Message);
  668. }
  669. }
  670. //不良代码组新增
  671. [HttpPost]
  672. public ActionResult SubICSBadCodeGroupAdd(ICSBadReason main, string BRGCode, string BRGDesc)
  673. {
  674. try
  675. {
  676. App.SubICSBadCodeGroupAdd(main, BRGCode, BRGDesc);
  677. return Success("保存成功!");
  678. }
  679. catch (Exception ex)
  680. {
  681. return Error(ex.Message);
  682. }
  683. }
  684. //不良原因组新增
  685. [HttpPost]
  686. public ActionResult SubICSBadReasonGroupAdd(ICSBadReason main,string BRGCode, string BRGDesc)
  687. {
  688. try
  689. {
  690. App.SubICSBadReasonGroupAdd(main, BRGCode, BRGDesc);
  691. return Success("保存成功!");
  692. }
  693. catch (Exception ex)
  694. {
  695. return Error(ex.Message);
  696. }
  697. }
  698. //不良代码组修改
  699. [HttpPost]
  700. public ActionResult UpdateICSBadCodeGroup(ICSBadReason main, string BID, string BRGCode, string BRGDesc)
  701. {
  702. try
  703. {
  704. App.UpdateICSBadCodeGroup(main, BID, BRGCode, BRGDesc);
  705. return Success("修改成功!");
  706. }
  707. catch (Exception ex)
  708. {
  709. return Error(ex.Message);
  710. }
  711. }
  712. //不良原因组修改
  713. [HttpPost]
  714. public ActionResult UpdateICSBadReasonGroup(ICSBadReason main,string BID ,string BRGCode, string BRGDesc)
  715. {
  716. try
  717. {
  718. App.UpdateICSBadReasonGroup(main, BID, BRGCode, BRGDesc);
  719. return Success("修改成功!");
  720. }
  721. catch (Exception ex)
  722. {
  723. return Error(ex.Message);
  724. }
  725. }
  726. /// <summary>
  727. /// 删除不良代码组
  728. /// </summary>
  729. /// <returns></returns>
  730. [HttpPost]
  731. [HandlerAjaxOnly]
  732. [ValidateAntiForgeryToken]
  733. public ActionResult DeleteICSBadCodeGroup(string keyValue)
  734. {
  735. string msg = App.DeleteICSBadCodeGroup(keyValue);
  736. if (string.IsNullOrEmpty(msg))
  737. {
  738. return Success("删除成功!");
  739. }
  740. else
  741. {
  742. return Error(msg);
  743. }
  744. }
  745. /// <summary>
  746. /// 删除不良原因组
  747. /// </summary>
  748. /// <returns></returns>
  749. [HttpPost]
  750. [HandlerAjaxOnly]
  751. [ValidateAntiForgeryToken]
  752. public ActionResult DeleteICSBadReasonGroup(string keyValue)
  753. {
  754. string msg = App.DeleteICSBadReasonGroup(keyValue);
  755. if (string.IsNullOrEmpty(msg))
  756. {
  757. return Success("删除成功!");
  758. }
  759. else
  760. {
  761. return Error(msg);
  762. }
  763. }
  764. [HttpGet]
  765. public ActionResult GetICSInspectionGroup(Pagination pagination, string queryJson)
  766. {
  767. DataTable ListData = App.GetICSInspectionGroup(ref pagination, queryJson);
  768. var JsonData = new
  769. {
  770. total = pagination.total,
  771. page = pagination.page,
  772. records = pagination.records,
  773. rows = ListData,
  774. };
  775. return Content(JsonData.ToJson());
  776. }
  777. [HttpGet]
  778. [HandlerAjaxOnly]
  779. public ActionResult ICSInspectionList(string GroupCode, Pagination pagination)
  780. {
  781. DataTable ListData = App.ICSInspectionList(GroupCode, ref pagination);
  782. var JsonData = new
  783. {
  784. total = pagination.total,
  785. page = pagination.page,
  786. records = pagination.records,
  787. rows = ListData,
  788. };
  789. return Content(JsonData.ToJson());
  790. }
  791. //删除自动表
  792. [HttpGet]
  793. public ActionResult DeleteList(string ID)
  794. {
  795. try
  796. {
  797. App.DeleteList(ID);
  798. return Success("删除成功!");
  799. }
  800. catch (Exception ex)
  801. {
  802. return Error(ex.Message);
  803. }
  804. }
  805. //检查项目组组修改
  806. [HttpPost]
  807. public ActionResult UpdateICSInspectionGroup(ICSInspectionList main, string BID, string GroupCode, string GroupName, string Enable)
  808. {
  809. try
  810. {
  811. App.UpdateICSInspectionGroup(main, BID, GroupCode, GroupName, Enable);
  812. return Success("修改成功!");
  813. }
  814. catch (Exception ex)
  815. {
  816. return Error(ex.Message);
  817. }
  818. }
  819. //检查项目组新增
  820. [HttpPost]
  821. public ActionResult ICSInspectionGroupAdd(ICSInspectionList main, string GroupCode, string GroupName,string Enable)
  822. {
  823. try
  824. {
  825. App.ICSInspectionGroupAdd(main, GroupCode, GroupName, Enable);
  826. return Success("保存成功!");
  827. }
  828. catch (Exception ex)
  829. {
  830. return Error(ex.Message);
  831. }
  832. }
  833. /// <summary>
  834. /// 动态子表修改加载页面
  835. /// </summary>
  836. /// <param name="GroupCode"></param>
  837. /// <returns></returns>
  838. [HttpGet]
  839. public ActionResult ICSInspectionList2(string GroupCode)
  840. {
  841. var data = App.ICSInspectionList2(GroupCode);
  842. return Content(data.ToJson());
  843. }
  844. /// <summary>
  845. /// 删除不良原因组
  846. /// </summary>
  847. /// <returns></returns>
  848. [HttpPost]
  849. [HandlerAjaxOnly]
  850. [ValidateAntiForgeryToken]
  851. public ActionResult DeleteICSInspectionGroup(string keyValue)
  852. {
  853. string msg = App.DeleteICSInspectionGroup(keyValue);
  854. if (string.IsNullOrEmpty(msg))
  855. {
  856. return Success("删除成功!");
  857. }
  858. else
  859. {
  860. return Error(msg);
  861. }
  862. }
  863. /// <summary>
  864. /// 新增料品属性
  865. /// </summary>
  866. /// <param name="keyValue"></param>
  867. /// <returns></returns>
  868. [HttpPost]
  869. [HandlerAjaxOnly]
  870. public ActionResult InsertICSInventory(string keyValue)
  871. {
  872. string msg = App.InsertICSInventory(keyValue);
  873. if (!string.IsNullOrEmpty(msg))
  874. {
  875. return Error(msg);
  876. }
  877. else
  878. {
  879. return Success("添加成功!");
  880. }
  881. }
  882. /// <summary>
  883. /// 修改料品属性
  884. /// </summary>
  885. /// <param name="keyValue"></param>
  886. /// <returns></returns>
  887. [HttpPost]
  888. [HandlerAjaxOnly]
  889. public ActionResult UpdateICSInventory(string keyValue)
  890. {
  891. string msg = App.UpdateICSInventory(keyValue);
  892. if (!string.IsNullOrEmpty(msg))
  893. {
  894. return Error(msg);
  895. }
  896. else
  897. {
  898. return Success("修改成功!");
  899. }
  900. }
  901. /// <summary>
  902. /// 获取料品属性修改文本框值
  903. /// </summary>
  904. /// <param name="POCode"></param>
  905. /// <param name="PORow"></param>
  906. /// <returns></returns>
  907. [HttpPost]
  908. [HandlerAjaxOnly]
  909. public ActionResult GetInputValue(string ID)
  910. {
  911. DataTable ListData = App.GetInputValue(ID);
  912. var JsonData = new
  913. {
  914. rows = ListData,
  915. };
  916. return Content(JsonData.ToJson());
  917. }
  918. /// <summary>
  919. /// 删除料品属性
  920. /// </summary>
  921. /// <returns></returns>
  922. [HttpPost]
  923. [HandlerAjaxOnly]
  924. [ValidateAntiForgeryToken]
  925. public ActionResult DeleteICSInventory(string keyValue)
  926. {
  927. string msg = App.DeleteICSInventory(keyValue);
  928. if (string.IsNullOrEmpty(msg))
  929. {
  930. return Success("删除成功!");
  931. }
  932. else
  933. {
  934. return Error(msg);
  935. }
  936. }
  937. /// <summary>
  938. /// 获取料品信息
  939. /// </summary>
  940. /// <param name="pagination"></param>
  941. /// <returns></returns>
  942. [HttpGet]
  943. public ActionResult GetICSInventoryInfo(string queryJson, Pagination pagination)
  944. {
  945. DataTable ListData = App.GetICSInventoryInfo(queryJson,ref pagination);
  946. var JsonData = new
  947. {
  948. total = pagination.total,
  949. page = pagination.page,
  950. records = pagination.records,
  951. rows = ListData,
  952. };
  953. return Content(JsonData.ToJson());
  954. }
  955. /// 获取仓库信息
  956. /// </summary>
  957. /// <param name="pagination"></param>
  958. /// <returns></returns>
  959. [HttpGet]
  960. public ActionResult GetICSWarehouseInfo(string queryJson, Pagination pagination)
  961. {
  962. DataTable ListData = App.GetICSWarehouseInfo(queryJson,ref pagination);
  963. var JsonData = new
  964. {
  965. total = pagination.total,
  966. page = pagination.page,
  967. records = pagination.records,
  968. rows = ListData,
  969. };
  970. return Content(JsonData.ToJson());
  971. }
  972. /// <summary>
  973. /// 新增料品仓库批次
  974. /// </summary>
  975. /// <param name="keyValue"></param>
  976. /// <returns></returns>
  977. [HttpPost]
  978. [HandlerAjaxOnly]
  979. public ActionResult InsertICSInventoryBatchEnable(string keyValue,string keyValue2)
  980. {
  981. string msg = App.InsertICSInventoryBatchEnable(keyValue, keyValue2);
  982. if (!string.IsNullOrEmpty(msg))
  983. {
  984. return Error(msg);
  985. }
  986. else
  987. {
  988. return Success("添加成功!");
  989. }
  990. }
  991. /// <summary>
  992. /// 修改料品仓库批次关系
  993. /// </summary>
  994. /// <param name="keyValue"></param>
  995. /// <returns></returns>
  996. [HttpPost]
  997. [HandlerAjaxOnly]
  998. public ActionResult UpdateICSInventoryBatchEnable(string keyValue)
  999. {
  1000. string msg = App.UpdateICSInventoryBatchEnable(keyValue);
  1001. if (!string.IsNullOrEmpty(msg))
  1002. {
  1003. return Error(msg);
  1004. }
  1005. else
  1006. {
  1007. return Success("修改成功!");
  1008. }
  1009. }
  1010. /// <summary>
  1011. /// 删除料品仓库批次关系
  1012. /// </summary>
  1013. /// <returns></returns>
  1014. [HttpPost]
  1015. [HandlerAjaxOnly]
  1016. [ValidateAntiForgeryToken]
  1017. public ActionResult DeleteICSInventoryBatchEnable(string keyValue)
  1018. {
  1019. string msg = App.DeleteICSInventoryBatchEnable(keyValue);
  1020. if (string.IsNullOrEmpty(msg))
  1021. {
  1022. return Success("删除成功!");
  1023. }
  1024. else
  1025. {
  1026. return Error(msg);
  1027. }
  1028. }
  1029. /// 获取库位信息
  1030. /// </summary>
  1031. /// <param name="pagination"></param>
  1032. /// <returns></returns>
  1033. [HttpGet]
  1034. public ActionResult GetICSLocation(string queryJson, Pagination pagination)
  1035. {
  1036. DataTable ListData = App.GetICSLocation(queryJson,ref pagination);
  1037. var JsonData = new
  1038. {
  1039. total = pagination.total,
  1040. page = pagination.page,
  1041. records = pagination.records,
  1042. rows = ListData,
  1043. };
  1044. return Content(JsonData.ToJson());
  1045. }
  1046. /// <summary>
  1047. /// 新增料品库位绑定关系
  1048. /// </summary>
  1049. /// <param name="keyValue"></param>
  1050. /// <returns></returns>
  1051. [HttpPost]
  1052. [HandlerAjaxOnly]
  1053. public ActionResult InsertICSInventoryLocation(string keyValue, string keyValue2)
  1054. {
  1055. string msg = App.InsertICSInventoryLocation(keyValue, keyValue2);
  1056. if (!string.IsNullOrEmpty(msg))
  1057. {
  1058. return Error(msg);
  1059. }
  1060. else
  1061. {
  1062. return Success("添加成功!");
  1063. }
  1064. }
  1065. /// <summary>
  1066. /// 修改料品库位绑定关系
  1067. /// </summary>
  1068. /// <param name="keyValue"></param>
  1069. /// <returns></returns>
  1070. [HttpPost]
  1071. [HandlerAjaxOnly]
  1072. public ActionResult UpdateICSInventoryLocation(string keyValue)
  1073. {
  1074. string msg = App.UpdateICSInventoryLocation(keyValue);
  1075. if (!string.IsNullOrEmpty(msg))
  1076. {
  1077. return Error(msg);
  1078. }
  1079. else
  1080. {
  1081. return Success("修改成功!");
  1082. }
  1083. }
  1084. /// <summary>
  1085. /// 删除料品仓库批次关系
  1086. /// </summary>
  1087. /// <returns></returns>
  1088. [HttpPost]
  1089. [HandlerAjaxOnly]
  1090. [ValidateAntiForgeryToken]
  1091. public ActionResult DeleteICSInventoryLocation(string keyValue)
  1092. {
  1093. string msg = App.DeleteICSInventoryLocation(keyValue);
  1094. if (string.IsNullOrEmpty(msg))
  1095. {
  1096. return Success("删除成功!");
  1097. }
  1098. else
  1099. {
  1100. return Error(msg);
  1101. }
  1102. }
  1103. /// <summary>
  1104. /// 新增包装、容器
  1105. /// </summary>
  1106. /// <param name="keyValue"></param>
  1107. /// <returns></returns>
  1108. [HttpPost]
  1109. [HandlerAjaxOnly]
  1110. public ActionResult InsertICSContainer(string keyValue)
  1111. {
  1112. string msg = App.InsertICSContainer(keyValue);
  1113. if (!string.IsNullOrEmpty(msg))
  1114. {
  1115. return Error(msg);
  1116. }
  1117. else
  1118. {
  1119. return Success("添加成功!");
  1120. }
  1121. }
  1122. /// <summary>
  1123. /// 修改包装、容器
  1124. /// </summary>
  1125. /// <param name="keyValue"></param>
  1126. /// <returns></returns>
  1127. [HttpPost]
  1128. [HandlerAjaxOnly]
  1129. public ActionResult UpdateICSContainer(string keyValue)
  1130. {
  1131. string msg = App.UpdateICSContainer(keyValue);
  1132. if (!string.IsNullOrEmpty(msg))
  1133. {
  1134. return Error(msg);
  1135. }
  1136. else
  1137. {
  1138. return Success("修改成功!");
  1139. }
  1140. }
  1141. /// <summary>
  1142. /// 删除包装、容器
  1143. /// </summary>
  1144. /// <returns></returns>
  1145. [HttpPost]
  1146. [HandlerAjaxOnly]
  1147. [ValidateAntiForgeryToken]
  1148. public ActionResult DeleteICSContainer(string keyValue)
  1149. {
  1150. string msg = App.DeleteICSContainer(keyValue);
  1151. if (string.IsNullOrEmpty(msg))
  1152. {
  1153. return Success("删除成功!");
  1154. }
  1155. else
  1156. {
  1157. return Error(msg);
  1158. }
  1159. }
  1160. /// <summary>
  1161. /// 新增包装、容器
  1162. /// </summary>
  1163. /// <param name="keyValue"></param>
  1164. /// <returns></returns>
  1165. [HttpPost]
  1166. [HandlerAjaxOnly]
  1167. public ActionResult InsertICSContainerLot(string keyValue)
  1168. {
  1169. string msg = App.InsertICSContainerLot(keyValue);
  1170. if (!string.IsNullOrEmpty(msg))
  1171. {
  1172. return Error(msg);
  1173. }
  1174. else
  1175. {
  1176. return Success("添加成功!");
  1177. }
  1178. }
  1179. /// <summary>
  1180. /// 修改包装、容器
  1181. /// </summary>
  1182. /// <param name="keyValue"></param>
  1183. /// <returns></returns>
  1184. [HttpPost]
  1185. [HandlerAjaxOnly]
  1186. public ActionResult UpdateICSContainerLot(string keyValue)
  1187. {
  1188. string msg = App.UpdateICSContainerLot(keyValue);
  1189. if (!string.IsNullOrEmpty(msg))
  1190. {
  1191. return Error(msg);
  1192. }
  1193. else
  1194. {
  1195. return Success("修改成功!");
  1196. }
  1197. }
  1198. /// <summary>
  1199. /// 删除包装、容器关联
  1200. /// </summary>
  1201. /// <returns></returns>
  1202. [HttpPost]
  1203. [HandlerAjaxOnly]
  1204. [ValidateAntiForgeryToken]
  1205. public ActionResult DeleteICSContainerLot(string keyValue)
  1206. {
  1207. string msg = App.DeleteICSContainerLot(keyValue);
  1208. if (string.IsNullOrEmpty(msg))
  1209. {
  1210. return Success("删除成功!");
  1211. }
  1212. else
  1213. {
  1214. return Error(msg);
  1215. }
  1216. }
  1217. /// <summary>
  1218. /// 获取物料信息
  1219. /// </summary>
  1220. /// <returns></returns>
  1221. public ActionResult GetInvCode()
  1222. {
  1223. DataTable dt = App.GetInvCode();
  1224. return Content(dt.ToJson());
  1225. }
  1226. /// <summary>
  1227. /// 获取不良代码信息
  1228. /// </summary>
  1229. /// <returns></returns>
  1230. public ActionResult GetBCGroup()
  1231. {
  1232. DataTable dt = App.GetBCGroup();
  1233. return Content(dt.ToJson());
  1234. }
  1235. /// <summary>
  1236. /// 获取不良原因信息
  1237. /// </summary>
  1238. /// <returns></returns>
  1239. public ActionResult BRGroupID()
  1240. {
  1241. DataTable dt = App.BRGroupID();
  1242. return Content(dt.ToJson());
  1243. }
  1244. [HttpPost]
  1245. [HandlerAjaxOnly]
  1246. public ActionResult InsertInventoryBadGroup(string keyValue)
  1247. {
  1248. string msg = App.InsertInventoryBadGroup(keyValue);
  1249. if (!string.IsNullOrEmpty(msg))
  1250. {
  1251. return Error(msg);
  1252. }
  1253. else
  1254. {
  1255. return Success("添加成功!");
  1256. }
  1257. }
  1258. [HttpPost]
  1259. [HandlerAjaxOnly]
  1260. public ActionResult UpdateInventoryBadGroup(string keyValue)
  1261. {
  1262. string msg = App.UpdateInventoryBadGroup(keyValue);
  1263. if (!string.IsNullOrEmpty(msg))
  1264. {
  1265. return Error(msg);
  1266. }
  1267. else
  1268. {
  1269. return Success("修改成功!");
  1270. }
  1271. }
  1272. /// <summary>
  1273. /// 删除料品不良信息
  1274. /// </summary>
  1275. /// <returns></returns>
  1276. [HttpPost]
  1277. [HandlerAjaxOnly]
  1278. [ValidateAntiForgeryToken]
  1279. public ActionResult DeleteInventoryBadGroup(string keyValue)
  1280. {
  1281. string msg = App.DeleteInventoryBadGroup(keyValue);
  1282. if (string.IsNullOrEmpty(msg))
  1283. {
  1284. return Success("删除成功!");
  1285. }
  1286. else
  1287. {
  1288. return Error(msg);
  1289. }
  1290. }
  1291. #region 打印
  1292. /// <summary>
  1293. /// 打印数据参数:服务器的URL+打印的文件名,转化为Base64编码
  1294. /// </summary>
  1295. protected string strPrintData;
  1296. /// <summary>
  1297. /// 标识是否安装了控件
  1298. /// </summary>
  1299. protected bool bIsInstallPrintControl = true;
  1300. /// <summary>
  1301. /// 打印控件的Cookie值
  1302. /// </summary>
  1303. protected string strPrintControlCookie = "";
  1304. /// <summary>
  1305. /// 获取Url中去掉文件名的路径
  1306. /// </summary>
  1307. /// <returns></returns>
  1308. private string GetUrlPath()
  1309. {
  1310. string strUrl = Request.Url.ToString();
  1311. int iEnd = strUrl.LastIndexOf("/");
  1312. strUrl = strUrl.Substring(0, iEnd + 1);
  1313. return strUrl;
  1314. }
  1315. /// <summary>
  1316. /// 设置控件调用的Cookie值,判断是否安装了打印控件
  1317. /// </summary>
  1318. /// <param name="pJson"></param>
  1319. private void SetCookieAndURL(PrintJson pJson)
  1320. {
  1321. bIsInstallPrintControl = false;
  1322. strPrintControlCookie = "";
  1323. HttpCookie pCookieInstall = Request.Cookies["InstallPrintControl"];
  1324. if (pCookieInstall != null)
  1325. { //Cookie存在
  1326. strPrintControlCookie = pCookieInstall.Value.ToString();
  1327. //以Cookie值查找在数据表中是否存在
  1328. string strSql = @"Select * From sys_SRM_CheckInstall Where Cookie = @Cookie";
  1329. SqlParameter[] pmcCookie = { new SqlParameter("Cookie", strPrintControlCookie) };
  1330. using (SqlDataReader drCookie = DbHelper.ExecuteReader(DbHelper.ConnectionString, CommandType.Text, strSql, pmcCookie))
  1331. {
  1332. if (drCookie.Read())
  1333. { //标识为已经安装
  1334. bIsInstallPrintControl = true;
  1335. }
  1336. drCookie.Close();
  1337. }
  1338. //更新Cookie的保存时间
  1339. pCookieInstall.Expires = DateTime.Now.AddYears(10);
  1340. Response.SetCookie(pCookieInstall);
  1341. }
  1342. else
  1343. {//Cookie不存在,则新建Cookie
  1344. strPrintControlCookie = System.Guid.NewGuid().ToString();
  1345. pCookieInstall = new HttpCookie("InstallPrintControl", strPrintControlCookie);
  1346. pCookieInstall.Expires = DateTime.Now.AddYears(10);
  1347. Response.Cookies.Add(pCookieInstall);
  1348. }
  1349. string strUrl = Server.MapPath("/PrintTemp/") + "IsCheckInstall";
  1350. pJson.SetCookieAndURL(strPrintControlCookie, strUrl);
  1351. }
  1352. [HttpPost]
  1353. [HandlerAjaxOnly]
  1354. public ActionResult PrintStack(string keyValue)
  1355. {
  1356. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  1357. string strPrintFileName = Server.MapPath("/ReportFile/") + "Stack.fr3";
  1358. PrintJson pJson = new PrintJson(Server.MapPath("./PrintTemp"), strPrintFileName);
  1359. pJson.CheckRegister("苏州智合诚信息科技有限公司", "56DD3B4C172D0D140841CAC98A58A819F4E28EDA5D6E45711DDD64F6A439F68B6A7870CD7DAFD69A919CB870207FE4BB206F92BE3D53C221B019E0797E739EBA4"); //注册信息
  1360. pJson.MasterOptions(1, "STNO", false); //主从关系
  1361. SetCookieAndURL(pJson);// 设置控件调用的Cookie值,判断是否安装了打印控件
  1362. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1363. string strSql = @"select a.LocationCode,
  1364. a.ID,
  1365. a.LocationName,
  1366. b.WarehouseCode,
  1367. b.WarehouseName,
  1368. a.Musername as 'MUSER',
  1369. a.MTIME
  1370. from ICSLocation a WITH (NOLOCK)
  1371. inner join ICSWarehouse b WITH (NOLOCK) on a.WHID=b.ID
  1372. where 1=1
  1373. and a.ID IN (" + keyValue.TrimEnd(',') + ")";
  1374. DataTable dtInInfo = DbHelper.ExecuteTable(DbHelper.ConnectionString, CommandType.Text, strSql, true, null);
  1375. // strSql = @"SELECT Row_Number() OVER (partition BY a.STNO ORDER BY a.CREATETIME DESC) AS rowno,c.STNO,
  1376. // c.PLANQTY,c.LotnoQTY,c.CartonNOQTY,c.ITEMCODE,b.INVNAME,b.INVSTD,b.INVPARSETYPE,d.StorageName,
  1377. // CONVERT(VARCHAR,CAST(ISNULL(c.Qty,0) AS money),1) AS Qty,
  1378. // CONVERT(VARCHAR,CAST(ISNULL(c.Meters,0) AS money),1) AS Meters,
  1379. // c.STNO AS QRSTNO,c.TransNO,c.TransLine,c.MEMO,c.VenderLotNO,CONVERT(varchar(10), c.PRODUCTDATE, 23) as PRODUCTDATE,a.remark
  1380. // FROM
  1381. // (SELECT aa.STNO,aa.ITEMCODE,aa.WorkPoint,SUM(aa.PLANQTY) PLANQTY,SUM(cc.LOTQTY) Qty,
  1382. // SUM(ISNULL(cc.Meters,0)) Meters,cc.TransNO,cc.TransLine,dd.MEMO,cc.VenderLotNO,cc.PRODUCTDATE,
  1383. // COUNT(aa.LOTNO) LotnoQTY,COUNT(bb.CartonNO) CartonNOQTY
  1384. // FROM ICSASNDETAIL aa
  1385. // LEFT JOIN ICSITEMLot2Carton bb ON aa.LOTNO = bb.LotNO AND aa.WorkPoint = bb.WorkPoint
  1386. // LEFT JOIN ICSITEMLot cc ON aa.LOTNO = cc.LotNO AND aa.WorkPoint = cc.WorkPoint
  1387. // LEFT JOIN ICSPO_PoMain dd on dd.POCode=cc.TransNO and dd.PORow=cc.TransLine
  1388. // GROUP BY aa.stno,aa.itemcode,aa.WorkPoint,cc.TransNO,cc.TransLine,dd.MEMO,cc.VenderLotNO,cc.PRODUCTDATE) c
  1389. // LEFT JOIN ICSASN a on c.stno=a.stno AND c.WorkPoint=a.WorkPoint
  1390. // LEFT JOIN dbo.ICSINVENTORY b ON c.ITEMCODE=b.INVCODE AND b.WorkPoint=c.WorkPoint
  1391. // LEFT JOIN dbo.icsstorage d ON b.INVMACHINETYPE=d.StorageCode
  1392. // WHERE c.STNO IN (" + keyValue.TrimEnd(',') + ") and c.WorkPoint='" + WorkPoint + "'";
  1393. // DataTable dtInMaterial = DbHelper.ExecuteTable(DbHelper.ConnectionString, CommandType.Text, strSql, true, null);
  1394. string strPrintTempFile = pJson.ShowReport(dtInInfo, null); //产生JSON文件内容
  1395. //把服务器的URL + 此文件名 传递给控件,由控件下载还原数据进行打印
  1396. string strServerURL = Server.MapPath("/PrintTemp/");
  1397. string strData = strServerURL + strPrintTempFile;
  1398. strPrintData = PrintFunction.EnBase64(strData);
  1399. var JsonData = new
  1400. {
  1401. strPrintData_1 = strPrintData,
  1402. bIsInstallPrintControl_1 = bIsInstallPrintControl,
  1403. strPrintControlCookie_1 = strPrintControlCookie
  1404. };
  1405. // string sql = @"UPDATE dbo.ICSASN
  1406. // SET ADDITION1=ISNULL(ADDITION1,0)+1,
  1407. // ADDITION2=CONVERT(varchar(100), GETDATE(), 21)
  1408. // WHERE STNO in (" + keyValue.TrimEnd(',') + ") and WorkPoint='" + WorkPoint + "'";
  1409. // SqlHelper.ExecuteNonQuery(sql);
  1410. return Content(JsonData.ToJson());
  1411. }
  1412. /// <summary>
  1413. /// 写日志(用于跟踪)
  1414. /// </summary>
  1415. private void WriteLog(string strMessage)
  1416. {
  1417. string strLogFile = Server.MapPath("./Cookie_Log.txt");
  1418. StreamWriter swLogFile = null;
  1419. try
  1420. {
  1421. if (!System.IO.File.Exists(strLogFile))
  1422. {
  1423. swLogFile = System.IO.File.CreateText(strLogFile);
  1424. }
  1425. else
  1426. {
  1427. swLogFile = System.IO.File.AppendText(strLogFile);
  1428. }
  1429. swLogFile.WriteLine(strMessage);
  1430. }
  1431. catch
  1432. {
  1433. }
  1434. finally
  1435. {
  1436. if (swLogFile != null)
  1437. swLogFile.Close();
  1438. }
  1439. }
  1440. /// <summary>
  1441. ///判断数据表中是否存在,若不存在则新建一条记录,若存在则更新最后访问的时间
  1442. /// </summary>
  1443. /// <param name="strCookie"></param>
  1444. private void UpdateCheckInstall(string strCookie)
  1445. {
  1446. bool bIsExist = false;
  1447. //判断记录是否存在
  1448. GetLastAccessTime(strCookie, ref bIsExist);
  1449. string strSql = "";
  1450. SqlParameter[] pmcCookie = { new SqlParameter("Cookie", strCookie) };
  1451. if (bIsExist)
  1452. { //存在则更新最后访问的时间
  1453. strSql = @"Update sys_SRM_CheckInstall
  1454. Set LastAccessTime = getDate()
  1455. Where Cookie = @Cookie";
  1456. }
  1457. else
  1458. { //不存在则新建一条记录
  1459. strSql = @"Insert into sys_SRM_CheckInstall(Cookie, LastAccessTime)
  1460. Values( @Cookie, getDate() )";
  1461. }
  1462. DbHelper.ExecuteNonQuery(DbHelper.ConnectionString, CommandType.Text, strSql, pmcCookie);
  1463. }
  1464. public DateTime ToDateTime(object SrcValue)
  1465. {
  1466. if (Convert.IsDBNull(SrcValue) == true)
  1467. return DateTime.MinValue;
  1468. else
  1469. {
  1470. try
  1471. {
  1472. return Convert.ToDateTime(SrcValue);
  1473. }
  1474. catch
  1475. {
  1476. return DateTime.MinValue;
  1477. }
  1478. }
  1479. }
  1480. /// <summary>
  1481. /// 获取此Cookie的最后访问时间
  1482. /// </summary>
  1483. /// <param name="strCookie"></param>
  1484. /// <returns></returns>
  1485. private DateTime GetLastAccessTime(string strCookie, ref bool bIsExist)
  1486. {
  1487. DateTime dtLastAccessTime = DateTime.MinValue;
  1488. bIsExist = false;
  1489. string strSql = @"Select * From sys_SRM_CheckInstall Where Cookie = @Cookie";
  1490. SqlParameter[] pmcCookie = { new SqlParameter("Cookie", strCookie) };
  1491. using (SqlDataReader drCookie = DbHelper.ExecuteReader(DbHelper.ConnectionString, CommandType.Text, strSql, pmcCookie))
  1492. {
  1493. if (drCookie.Read())
  1494. {
  1495. dtLastAccessTime = ToDateTime(drCookie["LastAccessTime"]);
  1496. bIsExist = true;
  1497. }
  1498. drCookie.Close();
  1499. }
  1500. return dtLastAccessTime;
  1501. }
  1502. [HttpGet]
  1503. [HandlerAjaxOnly]
  1504. public ActionResult IsCheckInstall(string checkInstall)
  1505. {
  1506. string strValue = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss 访问,");
  1507. if (Request.QueryString["cookie"] != null)
  1508. { //有控件上传的Cookie值
  1509. string strCookie = Request.QueryString["cookie"].ToString();
  1510. //判断数据表中是否存在,若不存在则新建一条记录,若存在则更新最后访问的时间
  1511. UpdateCheckInstall(strCookie);
  1512. strValue = strValue + "上传的cookie:" + strCookie;
  1513. }
  1514. else if (checkInstall != null)
  1515. {//Ajax检查控件是否安装了,防止那种客户把打印控件卸装了,打印时无法检测到的情况
  1516. string strCookie = checkInstall;
  1517. //读取最后访问的时间
  1518. string strResult = "PrintControlInstall";
  1519. bool bIsExist = false;
  1520. DateTime dtLastAccessTime = GetLastAccessTime(strCookie, ref bIsExist);
  1521. if (!bIsExist || dtLastAccessTime.AddSeconds(30) < DateTime.Now)
  1522. {
  1523. strResult = "NOT";
  1524. }
  1525. Response.Clear();
  1526. Response.Write(strResult);
  1527. strValue = strValue + "检测安装的值:" + strCookie;
  1528. }
  1529. WriteLog(strValue);
  1530. return null;
  1531. }
  1532. [HttpGet]
  1533. [HandlerAjaxOnly]
  1534. public ActionResult IsCheckInstall()
  1535. {
  1536. string strValue = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss 访问,");
  1537. if (Request.QueryString["cookie"] != null)
  1538. { //有控件上传的Cookie值
  1539. string strCookie = Request.QueryString["cookie"].ToString();
  1540. //判断数据表中是否存在,若不存在则新建一条记录,若存在则更新最后访问的时间
  1541. UpdateCheckInstall(strCookie);
  1542. strValue = strValue + "上传的cookie:" + strCookie;
  1543. }
  1544. else if (Request.QueryString["checkInstall"] != null)
  1545. {//Ajax检查控件是否安装了,防止那种客户把打印控件卸装了,打印时无法检测到的情况
  1546. string strCookie = Request.QueryString["checkInstall"];
  1547. //读取最后访问的时间
  1548. string strResult = "PrintControlInstall";
  1549. bool bIsExist = false;
  1550. DateTime dtLastAccessTime = GetLastAccessTime(strCookie, ref bIsExist);
  1551. if (!bIsExist || dtLastAccessTime.AddSeconds(30) < DateTime.Now)
  1552. {
  1553. strResult = "NOT";
  1554. }
  1555. Response.Clear();
  1556. Response.Write(strResult);
  1557. strValue = strValue + "检测安装的值:" + strCookie;
  1558. }
  1559. WriteLog(strValue);
  1560. return null;
  1561. }
  1562. #endregion
  1563. /// <summary>
  1564. /// 导入Excel
  1565. /// </summary>
  1566. /// <param name="fileURL"></param>
  1567. /// <returns></returns>
  1568. [HttpPost]
  1569. public ActionResult Import(string fileURL)
  1570. {
  1571. var fileName = "";
  1572. var filePath = fileURL;
  1573. string path = Path.Combine(filePath, fileName);
  1574. //file.SaveAs(path);
  1575. DataTable excelTable = new DataTable();
  1576. //excelTable =SqlHelper.GetExcelDataTable(path);
  1577. DataTable dbdata = new DataTable();
  1578. dbdata.Columns.Add("LocationCode");
  1579. dbdata.Columns.Add("LocationName");
  1580. dbdata.Columns.Add("Musername");
  1581. dbdata.Columns.Add("MUSER");
  1582. dbdata.Columns.Add("EATTRIBUTE1");
  1583. for (int i = 0; i < excelTable.Rows.Count; i++)
  1584. {
  1585. string LocationCode = "";
  1586. string LocationName = "";
  1587. DataRow dr = excelTable.Rows[i];
  1588. DataRow dr_ = dbdata.NewRow();
  1589. if (!string.IsNullOrWhiteSpace(dr["区"].ToString().ToUpper()))
  1590. {
  1591. LocationCode += "-" + dr["区"].ToString().ToUpper();
  1592. LocationName += dr["区"].ToString().ToUpper() + "区";
  1593. }
  1594. if (!string.IsNullOrWhiteSpace(dr["排"].ToString().ToUpper()))
  1595. {
  1596. LocationCode += "-" + dr["排"].ToString().ToUpper();
  1597. LocationName += dr["排"].ToString().ToUpper() + "排";
  1598. }
  1599. if (!string.IsNullOrWhiteSpace(dr["货架"].ToString().ToUpper()))
  1600. {
  1601. LocationCode += "-" + dr["货架"].ToString().ToUpper();
  1602. LocationName += dr["货架"].ToString().ToUpper() + "货架";
  1603. }
  1604. if (!string.IsNullOrWhiteSpace(dr["层"].ToString().ToUpper()))
  1605. {
  1606. LocationCode += "-" + dr["层"].ToString().ToUpper();
  1607. LocationName += dr["层"].ToString().ToUpper() + "层";
  1608. }
  1609. if (!string.IsNullOrWhiteSpace(dr["格"].ToString().ToUpper()))
  1610. {
  1611. LocationCode += "-" + dr["格"].ToString().ToUpper();
  1612. LocationName += dr["格"].ToString().ToUpper() + "格";
  1613. }
  1614. dr_["LocationCode"] = LocationCode;
  1615. dr_["LocationName"] = LocationName;
  1616. dr_["Musername"] = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1617. dr_["MUSER"] = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1618. dr_["Musername"] = "";
  1619. dbdata.Rows.Add(dr_);
  1620. }
  1621. SqlHelper.RemoveEmpty(dbdata);
  1622. SqlHelper.SqlBulkCopyByDatatable( "ICSLocation", dbdata);
  1623. return View();
  1624. }
  1625. //库位导入
  1626. [HttpPost]
  1627. /// <summary>
  1628. /// 文件上传到本地
  1629. /// </summary>
  1630. public string UploadFile()
  1631. {
  1632. try
  1633. {
  1634. HttpFileCollection hpFiles = System.Web.HttpContext.Current.Request.Files;
  1635. if (hpFiles != null && hpFiles.Count > 0)
  1636. {
  1637. string IsXls = System.IO.Path.GetExtension(hpFiles[0].FileName).ToString().ToLower();//System.IO.Path.GetExtension获得文件的扩展名
  1638. if (IsXls != ".xls" && IsXls != ".xlsx")
  1639. {
  1640. return "只可以选择Excel(.xls .xlsx)文件";//当选择的不是Excel文件时,返回
  1641. }
  1642. string filename = DateTime.Now.ToString("yyyyMMddhhmmss") + Guid.NewGuid() + IsXls; //获取Execle文件名 DateTime日期函数
  1643. string savePath = System.Web.HttpContext.Current.Server.MapPath("~\\File\\UPLoadFile\\" + filename);//Server.MapPath 获得虚拟服务器相对路径
  1644. int iLen = hpFiles[0].ContentLength;
  1645. if (Directory.Exists(savePath)) return "文件已存在";
  1646. byte[] bData = new byte[iLen];
  1647. hpFiles[0].InputStream.Read(bData, 0, iLen);
  1648. FileStream newFile = new FileStream(savePath, FileMode.OpenOrCreate);
  1649. newFile.Write(bData, 0, bData.Length);
  1650. newFile.Flush();
  1651. int _FileSizeTemp = hpFiles[0].ContentLength;
  1652. newFile.Close();
  1653. newFile.Dispose();
  1654. //bool del = false;
  1655. string mess = "";
  1656. mess = App.SetData_PR(savePath);
  1657. if (System.IO.File.Exists(savePath))//删除文件
  1658. {
  1659. System.IO.File.Delete(savePath);
  1660. }
  1661. return mess;
  1662. }
  1663. else
  1664. {
  1665. return "获取文件失败";
  1666. }
  1667. }
  1668. catch (Exception ex)
  1669. {
  1670. return ex.ToString();
  1671. }
  1672. }
  1673. /// <summary>
  1674. ///启用的料品库位绑定关系
  1675. /// </summary>
  1676. /// <returns></returns>
  1677. [HttpPost]
  1678. [HandlerAjaxOnly]
  1679. [ValidateAntiForgeryToken]
  1680. public ActionResult EnableInventoryLocation(string keyValue)
  1681. {
  1682. string msg = App.EnableInventoryLocation(keyValue);
  1683. if (string.IsNullOrEmpty(msg))
  1684. {
  1685. return Success("启用成功!");
  1686. }
  1687. else
  1688. {
  1689. return Error(msg);
  1690. }
  1691. }
  1692. [HttpPost]
  1693. [HandlerAjaxOnly]
  1694. [ValidateAntiForgeryToken]
  1695. public ActionResult ForbiddenInventoryLocation(string keyValue)
  1696. {
  1697. string msg = App.ForbiddenInventoryLocation(keyValue);
  1698. if (string.IsNullOrEmpty(msg))
  1699. {
  1700. return Success("禁用成功!");
  1701. }
  1702. else
  1703. {
  1704. return Error(msg);
  1705. }
  1706. }
  1707. /// <summary>
  1708. ///启用的料品仓库绑定关系
  1709. /// </summary>
  1710. /// <returns></returns>
  1711. [HttpPost]
  1712. [HandlerAjaxOnly]
  1713. [ValidateAntiForgeryToken]
  1714. public ActionResult EnableBatchEnable(string keyValue)
  1715. {
  1716. string msg = App.EnableBatchEnable(keyValue);
  1717. if (string.IsNullOrEmpty(msg))
  1718. {
  1719. return Success("启用成功!");
  1720. }
  1721. else
  1722. {
  1723. return Error(msg);
  1724. }
  1725. }
  1726. [HttpPost]
  1727. [HandlerAjaxOnly]
  1728. [ValidateAntiForgeryToken]
  1729. public ActionResult ForbiddenBatchEnable(string keyValue)
  1730. {
  1731. string msg = App.ForbiddenBatchEnable(keyValue);
  1732. if (string.IsNullOrEmpty(msg))
  1733. {
  1734. return Success("禁用成功!");
  1735. }
  1736. else
  1737. {
  1738. return Error(msg);
  1739. }
  1740. }
  1741. //新增标签数据源
  1742. [HttpPost]
  1743. [HandlerAjaxOnly]
  1744. public ActionResult CreateLableDataSource( string Sys_LableDataSource)
  1745. {
  1746. string msg = App.CreateLableDataSource(Sys_LableDataSource);
  1747. if (!string.IsNullOrEmpty(msg))
  1748. {
  1749. return Error(msg);
  1750. }
  1751. else
  1752. {
  1753. return Success("添加成功!");
  1754. }
  1755. }
  1756. [HttpGet]
  1757. [HandlerAjaxOnly]
  1758. public ActionResult GetTXT(string ID)
  1759. {
  1760. DataTable ListData = App.GetTXT(ID);
  1761. var JsonData = new
  1762. {
  1763. rows = ListData,
  1764. };
  1765. return Content(JsonData.ToJson());
  1766. }
  1767. //修改标签数据源
  1768. [HttpPost]
  1769. [HandlerAjaxOnly]
  1770. public ActionResult updateLableDataSource(string Sys_LableDataSource)
  1771. {
  1772. string msg = App.updateLableDataSource(Sys_LableDataSource);
  1773. if (!string.IsNullOrEmpty(msg))
  1774. {
  1775. return Error(msg);
  1776. }
  1777. else
  1778. {
  1779. return Success("添加成功!");
  1780. }
  1781. }
  1782. [HttpPost]
  1783. [HandlerAjaxOnly]
  1784. [ValidateAntiForgeryToken]
  1785. public ActionResult DeleteLableDataSource(string keyValue)
  1786. {
  1787. string msg = App.DeleteLableDataSource(keyValue);
  1788. if (string.IsNullOrEmpty(msg))
  1789. {
  1790. return Success("删除成功!");
  1791. }
  1792. else
  1793. {
  1794. return Error(msg);
  1795. }
  1796. }
  1797. [HttpGet]
  1798. [HandlerAjaxOnly]
  1799. public ActionResult GetLableType()
  1800. {
  1801. DataTable dt = App.GetLableType();
  1802. return Content(dt.ToJson());
  1803. }
  1804. [HttpGet]
  1805. [HandlerAjaxOnly]
  1806. public ActionResult GetLableSourceID()
  1807. {
  1808. DataTable dt = App.GetLableSourceID();
  1809. return Content(dt.ToJson());
  1810. }
  1811. //新增标签数据源
  1812. [HttpPost]
  1813. [HandlerAjaxOnly]
  1814. public ActionResult CreateLables(string txtLableName,string sel_LableType, string sel_LableSourceID )
  1815. {
  1816. string msg = App.CreateLables(txtLableName, sel_LableType, sel_LableSourceID);
  1817. if (!string.IsNullOrEmpty(msg))
  1818. {
  1819. return Error(msg);
  1820. }
  1821. else
  1822. {
  1823. return Success("添加成功!");
  1824. }
  1825. }
  1826. [HttpGet]
  1827. [HandlerAjaxOnly]
  1828. public ActionResult GetLabelTXT(string ID)
  1829. {
  1830. DataTable ListData = App.GetLabelTXT(ID);
  1831. var JsonData = new
  1832. {
  1833. rows = ListData,
  1834. };
  1835. return Content(JsonData.ToJson());
  1836. }
  1837. [HttpPost]
  1838. [HandlerAjaxOnly]
  1839. public ActionResult updateLables(string ID,string txtLableName, string sel_LableType, string sel_LableSourceID)
  1840. {
  1841. string msg = App.updateLables(ID,txtLableName, sel_LableType, sel_LableSourceID);
  1842. if (!string.IsNullOrEmpty(msg))
  1843. {
  1844. return Error(msg);
  1845. }
  1846. else
  1847. {
  1848. return Success("修改成功!");
  1849. }
  1850. }
  1851. [HttpPost]
  1852. [HandlerAjaxOnly]
  1853. [ValidateAntiForgeryToken]
  1854. public ActionResult DeleteICSLabelTemplate(string keyValue)
  1855. {
  1856. string msg = App.DeleteICSLabelTemplate(keyValue);
  1857. if (string.IsNullOrEmpty(msg))
  1858. {
  1859. return Success("删除成功!");
  1860. }
  1861. else
  1862. {
  1863. return Error(msg);
  1864. }
  1865. }
  1866. //获取父容器
  1867. [HttpGet]
  1868. [HandlerAjaxOnly]
  1869. public ActionResult GetContainerID()
  1870. {
  1871. DataTable dt = App.GetContainerID();
  1872. return Content(dt.ToJson());
  1873. }
  1874. [HttpPost]
  1875. public ActionResult UpLoadLabelFile()
  1876. {
  1877. //获取上传的文件集合
  1878. HttpFileCollection httpFile = System.Web.HttpContext.Current.Request.Files;
  1879. //获取送货单号
  1880. string ID = Request.Form["ID"].ToString();
  1881. string LableName = Request.Form["LableName"].ToString();
  1882. string fileName = Path.GetFileNameWithoutExtension(httpFile[0].FileName)
  1883. + "_" + LableName + Path.GetExtension(httpFile[0].FileName);
  1884. string filePath = System.Web.HttpContext.Current.Server.MapPath("~\\File\\LablesFile\\" + fileName);
  1885. int iLen = httpFile[0].ContentLength;
  1886. byte[] bData = new byte[iLen];
  1887. httpFile[0].InputStream.Read(bData, 0, iLen);
  1888. FileStream fs = new FileStream(filePath, FileMode.OpenOrCreate);
  1889. fs.Write(bData, 0, bData.Length);
  1890. fs.Flush();
  1891. fs.Close();
  1892. fs.Dispose();
  1893. int count = App.UpLoadLabelFile(ID, fileName);
  1894. if (count > 0)
  1895. {
  1896. return Success("上传成功!");
  1897. }
  1898. else
  1899. {
  1900. return Error("上传失败");
  1901. }
  1902. }
  1903. }
  1904. }