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.

353 lines
11 KiB

3 weeks ago
  1. using NFine.Application.DHAY;
  2. using NFine.Application.WMS;
  3. using NFine.Code;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.IO;
  8. using System.Linq;
  9. using System.Reflection.Emit;
  10. using System.Web;
  11. using System.Web.Mvc;
  12. namespace NFine.Web.Areas.WMS.Controllers
  13. {
  14. public class WMSCreateMOApplyController : ControllerBase
  15. {
  16. WMSCreateMOApplyApp App = new WMSCreateMOApplyApp();
  17. // GET: DHAY/ICSCustomerSuppliedReturn
  18. public ActionResult Index()
  19. {
  20. return View();
  21. }
  22. public ActionResult Create()
  23. {
  24. return View();
  25. }
  26. public ActionResult GetInvCode()
  27. {
  28. return View();
  29. }
  30. public ActionResult Update()
  31. {
  32. return View();
  33. }
  34. public ActionResult GetWHCode()
  35. {
  36. return View();
  37. }
  38. public ActionResult InitialImportUpLoad()
  39. {
  40. return View();
  41. }
  42. [HttpPost]
  43. [HandlerAjaxOnly]
  44. [ValidateAntiForgeryToken]
  45. public ActionResult DeleteICSMOApply(string keyValue)
  46. {
  47. string msg = App.DeleteICSMOApply(keyValue);
  48. if (string.IsNullOrEmpty(msg))
  49. {
  50. return Success("删除成功!");
  51. }
  52. else
  53. {
  54. return Error(msg);
  55. }
  56. }
  57. [HttpPost]
  58. [HandlerAjaxOnly]
  59. public ActionResult SaveICSMOApply(string ICSASN)
  60. {
  61. string msg = App.SaveICSMOApply(ICSASN);
  62. if (!string.IsNullOrEmpty(msg))
  63. {
  64. return Error(msg);
  65. }
  66. else
  67. {
  68. return Success("添加成功!");
  69. }
  70. }
  71. [HttpGet]
  72. public ActionResult GetICSMOApply(Pagination pagination, string queryJson)
  73. {
  74. DataTable ListData = App.GetICSMOApply(ref pagination, queryJson);
  75. var JsonData = new
  76. {
  77. total = pagination.total,
  78. page = pagination.page,
  79. records = pagination.records,
  80. rows = ListData,
  81. };
  82. return Content(JsonData.ToJson());
  83. }
  84. [HttpGet]
  85. public ActionResult GetICSMOApplyByApplyCode(string ApplyCode)
  86. {
  87. DataTable ListData = App.GetICSMOApplyByApplyCode(ApplyCode);
  88. var JsonData = new
  89. {
  90. rows = ListData,
  91. };
  92. return Content(JsonData.ToJson());
  93. }
  94. [HttpGet]
  95. [HandlerAjaxOnly]
  96. public ActionResult GetICSMOApplyDetail(string ApplyCode, string queryJson, Pagination pagination)
  97. {
  98. DataTable ListData = App.GetICSMOApplyDetail(ApplyCode, queryJson, ref pagination);
  99. var JsonData = new
  100. {
  101. total = pagination.total,
  102. page = pagination.page,
  103. records = pagination.records,
  104. rows = ListData,
  105. };
  106. return Content(JsonData.ToJson());
  107. }
  108. [HttpPost]
  109. [HandlerAjaxOnly]
  110. [ValidateAntiForgeryToken]
  111. public ActionResult DeleteICSMOApplyByCode(string keyValue)
  112. {
  113. string msg = App.DeleteICSMOApplyByCode(keyValue);
  114. if (string.IsNullOrEmpty(msg))
  115. {
  116. return Success("删除成功!");
  117. }
  118. else
  119. {
  120. return Error(msg);
  121. }
  122. }
  123. [HttpPost]
  124. [HandlerAjaxOnly]
  125. [ValidateAntiForgeryToken]
  126. public ActionResult ApproveICSMOApplyByCode(string keyValue)
  127. {
  128. string msg = App.ApproveICSMOApplyByCode(keyValue);
  129. if (string.IsNullOrEmpty(msg))
  130. {
  131. return Success("审核成功!");
  132. }
  133. else
  134. {
  135. return Error(msg);
  136. }
  137. }
  138. [HttpPost]
  139. [HandlerAjaxOnly]
  140. [ValidateAntiForgeryToken]
  141. public ActionResult AbandonICSMOApplyByCode(string keyValue)
  142. {
  143. string msg = App.AbandonICSMOApplyByCode(keyValue);
  144. if (string.IsNullOrEmpty(msg))
  145. {
  146. return Success("操作成功!");
  147. }
  148. else
  149. {
  150. return Error(msg);
  151. }
  152. }
  153. [HttpPost]
  154. [HandlerAjaxOnly]
  155. [ValidateAntiForgeryToken]
  156. public ActionResult ICSMOApplyByCodeFL(Pagination pagination, string ID, string Type, string flag, string Mechanism, string InvCode)
  157. {
  158. string msg = App.ICSMOApplyByCodeFL(ID, Type, Mechanism, InvCode);
  159. if (string.IsNullOrEmpty(msg))
  160. {
  161. return Success("操作成功!");
  162. }
  163. else
  164. {
  165. return Error(msg);
  166. }
  167. }
  168. [HttpPost]
  169. [HandlerAjaxOnly]
  170. [ValidateAntiForgeryToken]
  171. public ActionResult CloseICSMOApplyByCode(string keyValue)
  172. {
  173. string msg = App.CloseICSMOApplyByCode(keyValue);
  174. if (string.IsNullOrEmpty(msg))
  175. {
  176. return Success("关闭成功!");
  177. }
  178. else
  179. {
  180. return Error(msg);
  181. }
  182. }
  183. public ActionResult GetBidCode(string WorkPoint)
  184. {
  185. try
  186. {
  187. string Code = App.GetBidCode(WorkPoint);
  188. var JsonData = new
  189. {
  190. Code = Code,
  191. };
  192. return Content(JsonData.ToJson());
  193. }
  194. catch (Exception ex)
  195. {
  196. return Error(ex.Message);
  197. }
  198. }
  199. [HttpPost]
  200. [HandlerAjaxOnly]
  201. public ActionResult UpdateICSMOApply(string ICSASN)
  202. {
  203. string msg = App.UpdateICSMOApply(ICSASN);
  204. if (!string.IsNullOrEmpty(msg))
  205. {
  206. return Error(msg);
  207. }
  208. else
  209. {
  210. return Success("修改成功!");
  211. }
  212. }
  213. public ActionResult GetICSReturnTemporary(string rfqno, Pagination pagination)
  214. {
  215. DataTable table = App.GetICSReturnTemporary(rfqno);
  216. var JsonData = new
  217. {
  218. total = pagination.total,
  219. page = pagination.page,
  220. records = pagination.records,
  221. rows = table
  222. };
  223. return Content(JsonData.ToJson());
  224. }
  225. [HttpGet]
  226. [HandlerAjaxOnly]
  227. public ActionResult GetU9CodeType(string type)
  228. {
  229. string dt = App.GetU9CodeType(type);
  230. return Content(dt);
  231. }
  232. [HttpGet]
  233. [HandlerAjaxOnly]
  234. public ActionResult GetItemList(Pagination pagination, string queryJson)
  235. {
  236. DataTable ListData = App.GetItemList(queryJson, ref pagination);
  237. var JsonData = new
  238. {
  239. total = pagination.total,
  240. page = pagination.page,
  241. records = pagination.records,
  242. rows = ListData,
  243. };
  244. return Content(JsonData.ToJson());
  245. }
  246. [HttpGet]
  247. [HandlerAjaxOnly]
  248. public ActionResult GetItemListCount(Pagination pagination, string queryJson)
  249. {
  250. DataTable ListData = App.GetItemListCount(queryJson,ref pagination);
  251. var JsonData = new
  252. {
  253. total = pagination.total,
  254. page = pagination.page,
  255. records = pagination.records,
  256. rows = ListData,
  257. };
  258. return Content(JsonData.ToJson());
  259. }
  260. /// <summary>
  261. /// 获取物料的可用库存量
  262. /// </summary>
  263. /// <param name="invCode">物料编码</param>
  264. /// <param name="whCode">仓库</param>
  265. /// <param name="batchCode">批次</param>
  266. /// <returns></returns>
  267. [HttpGet]
  268. [HandlerAjaxOnly]
  269. public decimal GetInvCodeCount(string invCode, string whCode = "", string batchCode = "")
  270. {
  271. return App.GetInvCodeCount(invCode, whCode, batchCode);
  272. }
  273. [HttpGet]
  274. public ActionResult GetLYDep()
  275. {
  276. DataTable dt = App.GetLYDep();
  277. return Content(dt.ToJson());
  278. }
  279. [HttpPost]
  280. /// <summary>
  281. /// 文件上传到本地
  282. /// </summary>
  283. public string UploadFile()
  284. {
  285. try
  286. {
  287. string str_Year = Request.Form["txt_Year"];
  288. String UPLoadType = Request.Form["UPLoadType"];
  289. HttpFileCollection hpFiles = System.Web.HttpContext.Current.Request.Files;
  290. if (hpFiles != null && hpFiles.Count > 0)
  291. {
  292. string IsXls = System.IO.Path.GetExtension(hpFiles[0].FileName).ToString().ToLower();//System.IO.Path.GetExtension获得文件的扩展名
  293. if (IsXls != ".xls" && IsXls != ".xlsx")
  294. {
  295. return "只可以选择Excel(.xls .xlsx)文件";//当选择的不是Excel文件时,返回
  296. }
  297. string filename = DateTime.Now.ToString("yyyyMMddhhmmss") + UPLoadType + IsXls; //获取Execle文件名 DateTime日期函数
  298. string savePath = System.Web.HttpContext.Current.Server.MapPath("~\\File\\UPLoadFile\\" + filename);//Server.MapPath 获得虚拟服务器相对路径
  299. int iLen = hpFiles[0].ContentLength;
  300. if (Directory.Exists(savePath)) return "文件已存在";
  301. byte[] bData = new byte[iLen];
  302. hpFiles[0].InputStream.Read(bData, 0, iLen);
  303. FileStream newFile = new FileStream(savePath, FileMode.OpenOrCreate);
  304. newFile.Write(bData, 0, bData.Length);
  305. newFile.Flush();
  306. int _FileSizeTemp = hpFiles[0].ContentLength;
  307. newFile.Close();
  308. newFile.Dispose();
  309. //bool del = false;
  310. string mess = "";
  311. mess = App.SetData_PR(savePath, str_Year);
  312. if (System.IO.File.Exists(savePath))//删除文件
  313. {
  314. System.IO.File.Delete(savePath);
  315. }
  316. return mess;
  317. }
  318. else
  319. {
  320. return "获取文件失败";
  321. }
  322. }
  323. catch (Exception ex)
  324. {
  325. return ex.ToString();
  326. }
  327. }
  328. }
  329. }