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.

282 lines
8.2 KiB

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