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.

254 lines
7.3 KiB

1 year ago
1 year 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 ICSMTDOCController : ControllerBase
  18. {
  19. ICSMTDOCApp App = new ICSMTDOCApp();
  20. // GET: WMS/ICSMTDOC
  21. public ActionResult Metamorphosis()
  22. {
  23. return View();
  24. }
  25. public ActionResult ICSMTDOCAdd()
  26. {
  27. return View();
  28. }
  29. public ActionResult GetICSInventory()
  30. {
  31. return View();
  32. }
  33. public ActionResult GetBatchCode()
  34. {
  35. return View();
  36. }
  37. public ActionResult MetamorphosisToLead()
  38. {
  39. return View();
  40. }
  41. public ActionResult GetLocationCode()
  42. {
  43. return View();
  44. }
  45. [HttpGet]
  46. [HandlerAjaxOnly]
  47. public ActionResult GetGridJson(Pagination pagination, string queryJson)
  48. {
  49. DataTable ListData = App.GetGridJson(queryJson, ref pagination);
  50. var JsonData = new
  51. {
  52. total = pagination.total,
  53. page = pagination.page,
  54. records = pagination.records,
  55. rows = ListData,
  56. };
  57. return Content(JsonData.ToJson());
  58. }
  59. [HttpGet]
  60. [HandlerAjaxOnly]
  61. public ActionResult GetSubGridJson(string MTDOCCode)
  62. {
  63. DataTable ListData = App.GetSubGridJson(MTDOCCode);
  64. var JsonData = new
  65. {
  66. rows = ListData,
  67. };
  68. return Content(JsonData.ToJson());
  69. }
  70. //在库条码
  71. public ActionResult GetRepertory(string LotNo ,Pagination pagination)
  72. {
  73. DataTable ListData = App.GetRepertory(LotNo, ref pagination);
  74. var JsonData = new
  75. {
  76. total = pagination.total,
  77. page = pagination.page,
  78. records = pagination.records,
  79. rows = ListData,
  80. };
  81. return Content(JsonData.ToJson());
  82. }
  83. public ActionResult GetInvcode(string Invcode, Pagination pagination)
  84. {
  85. DataTable ListData = App.GetInvcode(Invcode, ref pagination);
  86. var JsonData = new
  87. {
  88. total = pagination.total,
  89. page = pagination.page,
  90. records = pagination.records,
  91. rows = ListData,
  92. };
  93. return Content(JsonData.ToJson());
  94. }
  95. public ActionResult GetGridLocationCode(string LocationCode, Pagination pagination)
  96. {
  97. DataTable ListData = App.GetLocationCode(LocationCode, ref pagination);
  98. var JsonData = new
  99. {
  100. total = pagination.total,
  101. page = pagination.page,
  102. records = pagination.records,
  103. rows = ListData,
  104. };
  105. return Content(JsonData.ToJson());
  106. }
  107. public ActionResult GetCode(string Type, string Common ,Pagination pagination)
  108. {
  109. DataTable ListData = App.GetCode(Type, Common, ref pagination);
  110. var JsonData = new
  111. {
  112. total = pagination.total,
  113. page = pagination.page,
  114. records = pagination.records,
  115. rows = ListData,
  116. };
  117. return Content(JsonData.ToJson());
  118. }
  119. /// <summary>
  120. /// 创建形态转换
  121. /// </summary>
  122. /// <param name="keyValue"></param>
  123. /// <returns></returns>
  124. [HttpPost]
  125. [HandlerAjaxOnly]
  126. public ActionResult CreateICSMTDOC(string ICSMTDOC, string InvCode, string Memo)
  127. {
  128. string msg = App.CreateICSMTDOC(ICSMTDOC, InvCode, Memo);
  129. if (!string.IsNullOrEmpty(msg))
  130. {
  131. return Error(msg);
  132. }
  133. else
  134. {
  135. return Success("添加成功!");
  136. }
  137. }
  138. //审核
  139. public ActionResult ICSMTDOCAudit(string MTDOCCode)
  140. {
  141. string msg = App.ICSMTDOCAudit(MTDOCCode);
  142. if (string.IsNullOrEmpty(msg))
  143. {
  144. return Success("操作成功!");
  145. }
  146. else
  147. {
  148. return Error("" + msg + "");
  149. }
  150. }
  151. [HttpPost]
  152. /// <summary>
  153. /// 文件上传到本地
  154. /// </summary>
  155. public string UploadFile()
  156. {
  157. try
  158. {
  159. string str_Year = Request.Form["txt_Year"];
  160. String UPLoadType = Request.Form["UPLoadType"];
  161. HttpFileCollection hpFiles = System.Web.HttpContext.Current.Request.Files;
  162. if (hpFiles != null && hpFiles.Count > 0)
  163. {
  164. string IsXls = System.IO.Path.GetExtension(hpFiles[0].FileName).ToString().ToLower();//System.IO.Path.GetExtension获得文件的扩展名
  165. if (IsXls != ".xls" && IsXls != ".xlsx")
  166. {
  167. return "只可以选择Excel(.xls .xlsx)文件";//当选择的不是Excel文件时,返回
  168. }
  169. string filename = DateTime.Now.ToString("yyyyMMddhhmmss") + UPLoadType + IsXls; //获取Execle文件名 DateTime日期函数
  170. string savePath = System.Web.HttpContext.Current.Server.MapPath("~\\File\\UPLoadFile\\" + filename);//Server.MapPath 获得虚拟服务器相对路径
  171. int iLen = hpFiles[0].ContentLength;
  172. if (Directory.Exists(savePath)) return "文件已存在";
  173. byte[] bData = new byte[iLen];
  174. hpFiles[0].InputStream.Read(bData, 0, iLen);
  175. FileStream newFile = new FileStream(savePath, FileMode.OpenOrCreate);
  176. newFile.Write(bData, 0, bData.Length);
  177. newFile.Flush();
  178. int _FileSizeTemp = hpFiles[0].ContentLength;
  179. newFile.Close();
  180. newFile.Dispose();
  181. //bool del = false;
  182. string mess = "";
  183. mess = App.ToLead(savePath, str_Year);
  184. if (System.IO.File.Exists(savePath))//删除文件
  185. {
  186. System.IO.File.Delete(savePath);
  187. }
  188. return mess;
  189. }
  190. else
  191. {
  192. return "获取文件失败";
  193. }
  194. }
  195. catch (Exception ex)
  196. {
  197. return ex.ToString();
  198. }
  199. }
  200. [HttpPost]
  201. [HandlerAjaxOnly]
  202. [ValidateAntiForgeryToken]
  203. public ActionResult DeleteICSMTDOC(string keyValue)
  204. {
  205. string msg = App.DeleteICSMTDOC(keyValue);
  206. if (string.IsNullOrEmpty(msg))
  207. {
  208. return Success("删除成功!");
  209. }
  210. else
  211. {
  212. return Error(msg);
  213. }
  214. }
  215. }
  216. }