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.

151 lines
4.5 KiB

4 days ago
  1. using NFine.Application.KBSSRM;
  2. using NFine.Code;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Data;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Web;
  9. using System.Web.Mvc;
  10. namespace NFine.Web.Areas.KBSSRM.Controllers
  11. {
  12. public class InvMaintenanceController : ControllerBase
  13. {
  14. private InvMaintenanceApp App = new InvMaintenanceApp();
  15. // GET: KBSSRM/InvMaintenance
  16. public ActionResult InvMaintenance()
  17. {
  18. return View();
  19. }
  20. public ActionResult InvMaintenanceUpdate()
  21. {
  22. return View();
  23. }
  24. [HttpGet]
  25. [HandlerAjaxOnly]
  26. public ActionResult GetGridJson(Pagination pagination, string queryJson)
  27. {
  28. DataTable ListData = App.GetGridJson(queryJson, ref pagination);
  29. var JsonData = new
  30. {
  31. total = pagination.total,
  32. page = pagination.page,
  33. records = pagination.records,
  34. rows = ListData,
  35. };
  36. return Content(JsonData.ToJson());
  37. }
  38. [HttpPost]
  39. [HandlerAjaxOnly]
  40. public ActionResult GetICSInventoryInfo(string InvCode, string WorkPoint)
  41. {
  42. DataTable ListData = App.GetICSInventoryInfo(InvCode, WorkPoint);
  43. var JsonData = new
  44. {
  45. rows = ListData,
  46. };
  47. return Content(JsonData.ToJson());
  48. }
  49. [HttpPost]
  50. [HandlerAjaxOnly]
  51. public ActionResult UpdateICSInventory(string keyValue)
  52. {
  53. string msg = App.UpdateICSInventory(keyValue);
  54. if (!string.IsNullOrEmpty(msg))
  55. {
  56. return Error(msg);
  57. }
  58. else
  59. {
  60. return Success("维护成功!");
  61. }
  62. }
  63. /// <summary>
  64. /// 文件上传到本地
  65. /// </summary>
  66. public ActionResult UploadFile()
  67. {
  68. string mess = "";
  69. try
  70. {
  71. HttpFileCollection hpFiles = System.Web.HttpContext.Current.Request.Files;
  72. if (hpFiles != null && hpFiles.Count > 0)
  73. {
  74. string IsXls = System.IO.Path.GetExtension(hpFiles[0].FileName).ToString().ToLower();//System.IO.Path.GetExtension获得文件的扩展名
  75. if (IsXls != ".xls" && IsXls != ".xlsx")
  76. {
  77. mess = "只可以选择Excel(.xls .xlsx)文件";//当选择的不是Excel文件时,返回
  78. }
  79. string filename = DateTime.Now.ToString("yyyyMMddhhmmss") + Guid.NewGuid() + IsXls; //获取Execle文件名 DateTime日期函数
  80. string Paths = System.Web.HttpContext.Current.Server.MapPath("~\\File\\UPLoadFile");
  81. if (!Directory.Exists(Paths))
  82. {
  83. Directory.CreateDirectory(Paths);
  84. }
  85. string savePath = System.Web.HttpContext.Current.Server.MapPath("~\\File\\UPLoadFile\\" + filename);//Server.MapPath 获得虚拟服务器相对路径
  86. int iLen = hpFiles[0].ContentLength;
  87. if (Directory.Exists(savePath)) mess = "文件已存在";
  88. byte[] bData = new byte[iLen];
  89. hpFiles[0].InputStream.Read(bData, 0, iLen);
  90. FileStream newFile = new FileStream(savePath, FileMode.OpenOrCreate);
  91. newFile.Write(bData, 0, bData.Length);
  92. newFile.Flush();
  93. int _FileSizeTemp = hpFiles[0].ContentLength;
  94. newFile.Close();
  95. newFile.Dispose();
  96. //bool del = false;
  97. mess = App.SetData_PR(savePath);
  98. if (System.IO.File.Exists(savePath))//删除文件
  99. {
  100. System.IO.File.Delete(savePath);
  101. }
  102. }
  103. }
  104. catch (Exception ex)
  105. {
  106. mess = ex.Message;
  107. //return Error(ex.Message);
  108. }
  109. var JsonData = new
  110. {
  111. mass = mess,
  112. };
  113. return Content(JsonData.ToJson());
  114. }
  115. [HttpPost]
  116. public void ExportAll(string keyValue, string InvCode, string InvName, string VenCode, string VenName)
  117. {
  118. DataTable dt = App.GetInvInfo(InvCode, InvName, VenCode, VenName);
  119. AsposeCell.Export(dt);
  120. }
  121. }
  122. }