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.

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