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.

243 lines
7.1 KiB

3 weeks ago
  1. using NFine.Application.WMS;
  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.WMS.Controllers
  11. {
  12. public class ICSMOApplyController : ControllerBase
  13. {
  14. ICSMOApplyApp App = new ICSMOApplyApp();
  15. // GET: WMS/ICSMOApply
  16. public ActionResult ICSMOApplyNegQuery()
  17. {
  18. return View();
  19. }
  20. public ActionResult ICSMOApplyEdit()
  21. {
  22. return View();
  23. }
  24. public ActionResult SeachICSMOApply()
  25. {
  26. return View();
  27. }
  28. public ActionResult SeachInventory()
  29. {
  30. return View();
  31. }
  32. [HttpPost]
  33. [HandlerAjaxOnly]
  34. [ValidateAntiForgeryToken]
  35. public ActionResult DeleteMOApplyApplyNeg(string keyValue)
  36. {
  37. string msg = App.DeleteMOApplyApplyNeg(keyValue);
  38. if (string.IsNullOrEmpty(msg))
  39. {
  40. return Success("删除成功!");
  41. }
  42. else
  43. {
  44. return Error(msg);
  45. }
  46. }
  47. /// <summary>
  48. /// 详情
  49. /// </summary>
  50. /// <param name="ApplyNegCode"></param>
  51. /// <param name="pagination"></param>
  52. /// <returns></returns>
  53. [HttpGet]
  54. [HandlerAjaxOnly]
  55. public ActionResult GetMOApplyApplyNegDetail(string ApplyNegCode, Pagination pagination)
  56. {
  57. DataTable ListData = App.GetMOApplyApplyNegDetail(ApplyNegCode, ref pagination);
  58. var JsonData = new
  59. {
  60. total = pagination.total,
  61. page = pagination.page,
  62. records = pagination.records,
  63. rows = ListData,
  64. };
  65. return Content(JsonData.ToJson());
  66. }
  67. public void ClearTemp()
  68. {
  69. App.ClearTemp();
  70. }
  71. public ActionResult GetOOCode(string WorkPoint)
  72. {
  73. try
  74. {
  75. string Code = App.GetOOCode(WorkPoint);
  76. var JsonData = new
  77. {
  78. Code = Code,
  79. };
  80. return Content(JsonData.ToJson());
  81. }
  82. catch (Exception ex)
  83. {
  84. return Error(ex.Message);
  85. }
  86. }
  87. /// <summary>
  88. /// 汇总
  89. /// </summary>
  90. /// <param name="pagination"></param>
  91. /// <returns></returns>
  92. [HttpGet]
  93. public ActionResult GetMOApplyApplyNeg(Pagination pagination)
  94. {
  95. DataTable ListData = App.GetMOApplyApplyNeg(ref pagination);
  96. var JsonData = new
  97. {
  98. total = pagination.total,
  99. page = pagination.page,
  100. records = pagination.records,
  101. rows = ListData,
  102. };
  103. return Content(JsonData.ToJson());
  104. }
  105. /// <summary>
  106. /// 修改弹出框的数据来源
  107. /// </summary>
  108. /// <param name="ApplyCode"></param>
  109. /// <param name="pagination"></param>
  110. /// <returns></returns>
  111. public ActionResult GetICSMOApplyReturnTemporary(string ApplyCode, Pagination pagination)
  112. {
  113. DataTable table = App.GetICSMOApplyReturnTemporary(ApplyCode);
  114. var JsonData = new
  115. {
  116. total = pagination.total,
  117. page = pagination.page,
  118. records = pagination.records,
  119. rows = table
  120. };
  121. return Content(JsonData.ToJson());
  122. }
  123. /// <summary>
  124. /// 新增和修改
  125. /// </summary>
  126. /// <param name="ICSASN"></param>
  127. /// <returns></returns>
  128. [HttpPost]
  129. [HandlerAjaxOnly]
  130. public ActionResult SaveICSMOApplyApplyNeg(string keyValue, string deleteIDs)
  131. {
  132. string msg = App.SaveICSMOApplyApplyNeg(keyValue, deleteIDs);
  133. if (!string.IsNullOrEmpty(msg))
  134. {
  135. return Error(msg);
  136. }
  137. else
  138. {
  139. return Success("保存成功!");
  140. }
  141. }
  142. ///// <summary>
  143. ///// 修改
  144. ///// </summary>
  145. ///// <param name="ICSASN"></param>
  146. ///// <returns></returns>
  147. //[HttpPost]
  148. //[HandlerAjaxOnly]
  149. //public ActionResult UpdateICSMOApplyApplyNeg(string ICSASN)
  150. //{
  151. // string msg = App.UpdateICSMOApplyApplyNeg(ICSASN);
  152. // if (!string.IsNullOrEmpty(msg))
  153. // {
  154. // return Error(msg);
  155. // }
  156. // else
  157. // {
  158. // return Success("修改成功!");
  159. // }
  160. //}
  161. //库位导入
  162. [HttpPost]
  163. /// <summary>
  164. /// 文件上传到本地
  165. /// </summary>
  166. public string UploadFile()
  167. {
  168. try
  169. {
  170. HttpFileCollection hpFiles = System.Web.HttpContext.Current.Request.Files;
  171. if (hpFiles != null && hpFiles.Count > 0)
  172. {
  173. string IsXls = System.IO.Path.GetExtension(hpFiles[0].FileName).ToString().ToLower();//System.IO.Path.GetExtension获得文件的扩展名
  174. if (IsXls != ".xls" && IsXls != ".xlsx")
  175. {
  176. return "只可以选择Excel(.xls .xlsx)文件";//当选择的不是Excel文件时,返回
  177. }
  178. string filename = DateTime.Now.ToString("yyyyMMddhhmmss") + Guid.NewGuid() + IsXls; //获取Execle文件名 DateTime日期函数
  179. string savePath = System.Web.HttpContext.Current.Server.MapPath("~\\File\\UPLoadFile\\" + filename);//Server.MapPath 获得虚拟服务器相对路径
  180. int iLen = hpFiles[0].ContentLength;
  181. if (Directory.Exists(savePath)) return "文件已存在";
  182. byte[] bData = new byte[iLen];
  183. hpFiles[0].InputStream.Read(bData, 0, iLen);
  184. FileStream newFile = new FileStream(savePath, FileMode.OpenOrCreate);
  185. newFile.Write(bData, 0, bData.Length);
  186. newFile.Flush();
  187. int _FileSizeTemp = hpFiles[0].ContentLength;
  188. newFile.Close();
  189. newFile.Dispose();
  190. //bool del = false;
  191. string mess = "";
  192. mess = App.SetData_PR(savePath);
  193. if (System.IO.File.Exists(savePath))//删除文件
  194. {
  195. System.IO.File.Delete(savePath);
  196. }
  197. return mess;
  198. }
  199. else
  200. {
  201. return "获取文件失败";
  202. }
  203. }
  204. catch (Exception ex)
  205. {
  206. return ex.ToString();
  207. }
  208. }
  209. //导出
  210. [HttpPost]
  211. public void ExportAll(string keyValue)
  212. {
  213. DataTable dt = App.GetASNListExport();
  214. AsposeCell.Export(dt);
  215. }
  216. }
  217. }