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.

480 lines
14 KiB

3 weeks ago
  1. using NFine.Application.DHAY;
  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.Reflection.Emit;
  9. using System.Web;
  10. using System.Web.Mvc;
  11. namespace NFine.Web.Areas.DHAY.Controllers
  12. {
  13. public class ICSAccessoriesMOApplyController : ControllerBase
  14. {
  15. ICSAccessoriesMOIApplyApp App = new ICSAccessoriesMOIApplyApp();
  16. // GET: DHAY/ICSCustomerSuppliedReturn
  17. public ActionResult Index()
  18. {
  19. return View();
  20. }
  21. public ActionResult Create()
  22. {
  23. return View();
  24. }
  25. public ActionResult GetInvCode()
  26. {
  27. return View();
  28. }
  29. public ActionResult Update()
  30. {
  31. return View();
  32. }
  33. public ActionResult GetWHCode()
  34. {
  35. return View();
  36. }
  37. public ActionResult InitialImportUpLoad()
  38. {
  39. return View();
  40. }
  41. [HttpPost]
  42. [HandlerAjaxOnly]
  43. [ValidateAntiForgeryToken]
  44. public ActionResult DeleteICSMOApply(string keyValue)
  45. {
  46. string msg = App.DeleteICSMOApply(keyValue);
  47. if (string.IsNullOrEmpty(msg))
  48. {
  49. return Success("删除成功!");
  50. }
  51. else
  52. {
  53. return Error(msg);
  54. }
  55. }
  56. [HttpPost]
  57. [HandlerAjaxOnly]
  58. public ActionResult SaveICSMOApply(string ICSASN)
  59. {
  60. string msg = App.SaveICSMOApply(ICSASN);
  61. if (!string.IsNullOrEmpty(msg))
  62. {
  63. return Error(msg);
  64. }
  65. else
  66. {
  67. return Success("添加成功!");
  68. }
  69. }
  70. [HttpGet]
  71. public ActionResult GetICSMOApply(Pagination pagination,string MenuID, string queryJson)
  72. {
  73. DataTable ListData = App.GetICSMOApply(ref pagination, MenuID, queryJson);
  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. [HttpGet]
  84. public ActionResult GetICSMOApplyByApplyCode(string ApplyCode)
  85. {
  86. DataTable ListData = App.GetICSMOApplyByApplyCode(ApplyCode);
  87. var JsonData = new
  88. {
  89. rows = ListData,
  90. };
  91. return Content(JsonData.ToJson());
  92. }
  93. [HttpGet]
  94. [HandlerAjaxOnly]
  95. public ActionResult GetICSMOApplyDetail(string ApplyCode, string queryJson, Pagination pagination)
  96. {
  97. DataTable ListData = App.GetICSMOApplyDetail(ApplyCode, queryJson, 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. [HttpPost]
  108. [HandlerAjaxOnly]
  109. [ValidateAntiForgeryToken]
  110. public ActionResult DeleteICSMOApplyByCode(string keyValue)
  111. {
  112. string msg = App.DeleteICSMOApplyByCode(keyValue);
  113. if (string.IsNullOrEmpty(msg))
  114. {
  115. return Success("删除成功!");
  116. }
  117. else
  118. {
  119. return Error(msg);
  120. }
  121. }
  122. [HttpPost]
  123. [HandlerAjaxOnly]
  124. [ValidateAntiForgeryToken]
  125. public ActionResult DeleteICSMOApplyById(string keyValue)
  126. {
  127. string msg = App.DeleteICSMOApplyById(keyValue);
  128. if (string.IsNullOrEmpty(msg))
  129. {
  130. return Success("删除成功!");
  131. }
  132. else
  133. {
  134. return Error(msg);
  135. }
  136. }
  137. [HttpPost]
  138. [HandlerAjaxOnly]
  139. [ValidateAntiForgeryToken]
  140. public ActionResult ApproveICSMOApplyByCode(string keyValue)
  141. {
  142. string msg = App.ApproveICSMOApplyByCode(keyValue);
  143. if (string.IsNullOrEmpty(msg))
  144. {
  145. return Success("审核成功!");
  146. }
  147. else
  148. {
  149. return Error(msg);
  150. }
  151. }
  152. [HttpPost]
  153. [HandlerAjaxOnly]
  154. [ValidateAntiForgeryToken]
  155. public ActionResult AbandonICSMOApplyByCode(string keyValue)
  156. {
  157. string msg = App.AbandonICSMOApplyByCode(keyValue);
  158. if (string.IsNullOrEmpty(msg))
  159. {
  160. return Success("操作成功!");
  161. }
  162. else
  163. {
  164. return Error(msg);
  165. }
  166. }
  167. [HttpPost]
  168. [HandlerAjaxOnly]
  169. [ValidateAntiForgeryToken]
  170. public ActionResult ICSMOApplyByCodeFL(Pagination pagination, string MOCodes, string Type, string flag, string Mechanism, string InvCode)
  171. {
  172. string msg = App.ICSMOApplyByCodeFL(MOCodes, Type, Mechanism, InvCode);
  173. if (string.IsNullOrEmpty(msg))
  174. {
  175. return Success("操作成功!");
  176. }
  177. else
  178. {
  179. return Error(msg);
  180. }
  181. }
  182. [HttpPost]
  183. [HandlerAjaxOnly]
  184. [ValidateAntiForgeryToken]
  185. public ActionResult CloseICSMOApplyByCode(string keyValue)
  186. {
  187. string msg = App.CloseICSMOApplyByCode(keyValue);
  188. if (string.IsNullOrEmpty(msg))
  189. {
  190. return Success("关闭成功!");
  191. }
  192. else
  193. {
  194. return Error(msg);
  195. }
  196. }
  197. public ActionResult GetBidCode(string WorkPoint)
  198. {
  199. try
  200. {
  201. string Code = App.GetBidCode(WorkPoint);
  202. var JsonData = new
  203. {
  204. Code = Code,
  205. };
  206. return Content(JsonData.ToJson());
  207. }
  208. catch (Exception ex)
  209. {
  210. return Error(ex.Message);
  211. }
  212. }
  213. /// <summary>
  214. /// 获取单据必填信息
  215. /// </summary>
  216. /// <param name="dept">部门名称</param>
  217. /// <param name="codeType">单据名称</param>
  218. /// <returns></returns>
  219. public ActionResult GetCodeInformation(string dept="",string codeType="")
  220. {
  221. try
  222. {
  223. DataTable Code = App.GetCodeInformation(dept, codeType);
  224. var JsonData = new
  225. {
  226. Code = Code,
  227. };
  228. return Content(JsonData.ToJson());
  229. }
  230. catch (Exception ex)
  231. {
  232. return Error(ex.Message);
  233. }
  234. }
  235. /// <summary>
  236. /// 获取用户的领用部门
  237. /// </summary>
  238. /// <returns></returns>
  239. public ActionResult GetUserDept()
  240. {
  241. try
  242. {
  243. DataTable Code = App.GetUserDept();
  244. var JsonData = new
  245. {
  246. Code = Code,
  247. };
  248. return Content(JsonData.ToJson());
  249. }
  250. catch (Exception ex)
  251. {
  252. return Error(ex.Message);
  253. }
  254. }
  255. [HttpPost]
  256. [HandlerAjaxOnly]
  257. public ActionResult UpdateICSMOApply(string ICSASN)
  258. {
  259. string msg = App.UpdateICSMOApply(ICSASN);
  260. if (!string.IsNullOrEmpty(msg))
  261. {
  262. return Error(msg);
  263. }
  264. else
  265. {
  266. return Success("修改成功!");
  267. }
  268. }
  269. public ActionResult GetICSReturnTemporary(string rfqno, Pagination pagination)
  270. {
  271. DataTable table = App.GetICSReturnTemporary(rfqno);
  272. var JsonData = new
  273. {
  274. total = pagination.total,
  275. page = pagination.page,
  276. records = pagination.records,
  277. rows = table
  278. };
  279. return Content(JsonData.ToJson());
  280. }
  281. [HttpGet]
  282. [HandlerAjaxOnly]
  283. public ActionResult GetU9CodeType(string type)
  284. {
  285. string dt = App.GetU9CodeType(type);
  286. return Content(dt);
  287. }
  288. [HttpGet]
  289. [HandlerAjaxOnly]
  290. public ActionResult GetItemList(Pagination pagination, string queryJson)
  291. {
  292. DataTable ListData = App.GetItemList(queryJson, ref pagination);
  293. var JsonData = new
  294. {
  295. total = pagination.total,
  296. page = pagination.page,
  297. records = pagination.records,
  298. rows = ListData,
  299. };
  300. return Content(JsonData.ToJson());
  301. }
  302. /// <summary>
  303. /// 根据物料编码获取物料信息
  304. /// </summary>
  305. /// <param name="InvCode">物料编码</param>
  306. /// <returns></returns>
  307. [HttpGet]
  308. [HandlerAjaxOnly]
  309. public ActionResult GetItemListInv(string InvCode)
  310. {
  311. DataTable ListData = App.GetItemListInv(InvCode);
  312. var JsonData = new
  313. {
  314. rows = ListData,
  315. };
  316. return Content(JsonData.ToJson());
  317. }
  318. [HttpGet]
  319. [HandlerAjaxOnly]
  320. public ActionResult GetDHDocType(string Code)
  321. {
  322. DataTable dt = App.GetDHDocType(Code);
  323. return Content(dt.ToJson());
  324. }
  325. /// <summary>
  326. /// 获取客户信息
  327. /// </summary>
  328. /// <param name="Code"></param>
  329. /// <returns></returns>
  330. [HttpGet]
  331. [HandlerAjaxOnly]
  332. public ActionResult GetCustomer(string Code)
  333. {
  334. DataTable dt = App.GetCustomer(Code);
  335. return Content(dt.ToJson());
  336. }
  337. /// <summary>
  338. /// 辅料领料单单据类型(角色与单据类型绑定,对应角色进入界面只能选择某些单据类型)
  339. /// </summary>
  340. /// <param name="Code"></param>s
  341. /// <returns></returns>
  342. [HttpGet]
  343. [HandlerAjaxOnly]
  344. public ActionResult GetFLDocType(string Code)
  345. {
  346. string dt = App.GetFLDocType(Code);
  347. return Content(dt);
  348. }
  349. /// <summary>
  350. /// 获取东辉特有单据类型
  351. /// </summary>
  352. /// <param name="InvCode">物料编码</param>
  353. /// <returns></returns>
  354. [HttpGet]
  355. [HandlerAjaxOnly]
  356. public ActionResult GetDHCode()
  357. {
  358. DataTable ListData = App.GetDHCode();
  359. var JsonData = new
  360. {
  361. rows = ListData,
  362. };
  363. return Content(JsonData.ToJson());
  364. }
  365. [HttpGet]
  366. [HandlerAjaxOnly]
  367. public ActionResult GetItemListCount(Pagination pagination, string queryJson)
  368. {
  369. DataTable ListData = App.GetItemListCount(queryJson,ref pagination);
  370. var JsonData = new
  371. {
  372. total = pagination.total,
  373. page = pagination.page,
  374. records = pagination.records,
  375. rows = ListData,
  376. };
  377. return Content(JsonData.ToJson());
  378. }
  379. /// <summary>
  380. /// 获取物料的可用库存量
  381. /// </summary>
  382. /// <param name="invCode">物料编码</param>
  383. /// <param name="whCode">仓库</param>
  384. /// <param name="batchCode">批次</param>
  385. /// <returns></returns>
  386. [HttpGet]
  387. [HandlerAjaxOnly]
  388. public decimal GetInvCodeCount( string invCode, string whCode = "", string batchCode = "")
  389. {
  390. return App.GetInvCodeCount(invCode, whCode, batchCode);
  391. }
  392. [HttpGet]
  393. public ActionResult GetLYDep()
  394. {
  395. DataTable dt = App.GetLYDep();
  396. return Content(dt.ToJson());
  397. }
  398. [HttpPost]
  399. /// <summary>
  400. /// 文件上传到本地
  401. /// </summary>
  402. public string UploadFile()
  403. {
  404. try
  405. {
  406. string str_Year = Request.Form["txt_Year"];
  407. String UPLoadType = Request.Form["UPLoadType"];
  408. HttpFileCollection hpFiles = System.Web.HttpContext.Current.Request.Files;
  409. if (hpFiles != null && hpFiles.Count > 0)
  410. {
  411. string IsXls = System.IO.Path.GetExtension(hpFiles[0].FileName).ToString().ToLower();//System.IO.Path.GetExtension获得文件的扩展名
  412. if (IsXls != ".xls" && IsXls != ".xlsx")
  413. {
  414. return "只可以选择Excel(.xls .xlsx)文件";//当选择的不是Excel文件时,返回
  415. }
  416. string filename = DateTime.Now.ToString("yyyyMMddhhmmss") + UPLoadType + IsXls; //获取Execle文件名 DateTime日期函数
  417. string savePath = System.Web.HttpContext.Current.Server.MapPath("~\\File\\UPLoadFile\\" + filename);//Server.MapPath 获得虚拟服务器相对路径
  418. int iLen = hpFiles[0].ContentLength;
  419. if (Directory.Exists(savePath)) return "文件已存在";
  420. byte[] bData = new byte[iLen];
  421. hpFiles[0].InputStream.Read(bData, 0, iLen);
  422. FileStream newFile = new FileStream(savePath, FileMode.OpenOrCreate);
  423. newFile.Write(bData, 0, bData.Length);
  424. newFile.Flush();
  425. int _FileSizeTemp = hpFiles[0].ContentLength;
  426. newFile.Close();
  427. newFile.Dispose();
  428. //bool del = false;
  429. string mess = "";
  430. mess = App.SetData_PR(savePath, str_Year);
  431. if (System.IO.File.Exists(savePath))//删除文件
  432. {
  433. System.IO.File.Delete(savePath);
  434. }
  435. return mess;
  436. }
  437. else
  438. {
  439. return "获取文件失败";
  440. }
  441. }
  442. catch (Exception ex)
  443. {
  444. return ex.ToString();
  445. }
  446. }
  447. }
  448. }