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.

299 lines
9.4 KiB

4 days ago
  1. using NFine.Application;
  2. using NFine.Application.ProductManage;
  3. using NFine.Code;
  4. using NFine.Domain.Entity.ProductManage;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Data;
  8. using System.IO;
  9. using System.Linq;
  10. using System.Web;
  11. using System.Web.Mvc;
  12. namespace NFine.Web.Areas.SRM.Controllers
  13. {
  14. public class InvoiceAddController : ControllerBase
  15. {
  16. private InvoiceManageApp App = new InvoiceManageApp();
  17. [HttpGet]
  18. [HandlerAjaxOnly]
  19. public ActionResult GetGridJson(Pagination pagination, string queryJson)
  20. {
  21. DataTable ListData = App.GetGridJson(queryJson, ref pagination);
  22. var JsonData = new
  23. {
  24. total = pagination.total,
  25. page = pagination.page,
  26. records = pagination.records,
  27. rows = ListData,
  28. };
  29. return Content(JsonData.ToJson());
  30. }
  31. [HttpGet]
  32. [HandlerAjaxOnly]
  33. public ActionResult GetSubGridJson(string queryJson, Pagination pagination)
  34. {
  35. DataTable ListData = App.GetSubGridJson_Add(queryJson, ref pagination);
  36. var JsonData = new
  37. {
  38. total = pagination.total,
  39. page = pagination.page,
  40. records = pagination.records,
  41. rows = ListData,
  42. };
  43. return Content(JsonData.ToJson());
  44. }
  45. [HttpGet]
  46. [HandlerAjaxOnly]
  47. public ActionResult GetSubGridJson(string queryJson, string CartonNo, Pagination pagination, string WorkPoint)
  48. {
  49. DataTable ListData = App.GetSubGridJson(CartonNo, ref pagination, WorkPoint);
  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. public ActionResult Index()
  60. {
  61. return View();
  62. }
  63. [HttpPost]
  64. [HandlerAjaxOnly]
  65. [ValidateAntiForgeryToken]
  66. public ActionResult SubmitForm(string POCode, string PORow, string keyValue)
  67. {
  68. int i = App.CreateItemLotNo(POCode, PORow, keyValue);
  69. if (i > 0)
  70. {
  71. return Success("发布成功!");
  72. }
  73. else
  74. {
  75. return Error("发布失败!");
  76. }
  77. }
  78. [HttpGet]
  79. [HandlerAjaxOnly]
  80. public ActionResult GetSubGridJsonByCreate(string POCode, string PORow)
  81. {
  82. DataTable ListData = App.GetSubGridJsonByCreate(POCode, PORow);
  83. var JsonData = new
  84. {
  85. rows = ListData,
  86. };
  87. return Content(JsonData.ToJson());
  88. }
  89. [HttpGet]
  90. [HandlerAjaxOnly]
  91. public ActionResult GetVendorLotNo(string VenCode, string WorkPoint)
  92. {
  93. DataTable ListData = App.GetVendorLotNo(VenCode, WorkPoint);
  94. var JsonData = new
  95. {
  96. VendorLotNo = ListData.Rows[0][0].ToString(),
  97. };
  98. return Content(JsonData.ToJson());
  99. }
  100. [HttpGet]
  101. [HandlerAjaxOnly]
  102. public ActionResult GetVendor()
  103. {
  104. DataTable dt = App.GetVendor();
  105. return Content(dt.ToJson());
  106. }
  107. [HttpGet]
  108. [HandlerAjaxOnly]
  109. public ActionResult GetDocNo(string InvoiceType, string WorkPoint, string Vendor)
  110. {
  111. string cDocNo = App.GetDocNo(InvoiceType, WorkPoint, Vendor);
  112. var JsonData = new
  113. {
  114. DocNo = cDocNo,
  115. VenCode = NFine.Code.OperatorProvider.Provider.GetCurrent().VenCode
  116. };
  117. return Content(JsonData.ToJson());
  118. }
  119. [HttpGet]
  120. [HandlerAjaxOnly]
  121. public ActionResult GetDocNoByPerson(string SupplierCode, string InvoiceType, string WorkPoint)
  122. {
  123. string cDocNo = App.GetDocNoByPerson(SupplierCode, InvoiceType, WorkPoint);
  124. var JsonData = new
  125. {
  126. DocNo = cDocNo,
  127. VenCode = NFine.Code.OperatorProvider.Provider.GetCurrent().VenCode
  128. };
  129. return Content(JsonData.ToJson());
  130. }
  131. [HttpPost]
  132. [HandlerAjaxOnly]
  133. public ActionResult SaveItemCode(string queryJson, string DocNo, string WorkPoint)
  134. {
  135. queryJson = queryJson.Substring(1, queryJson.Length - 2);
  136. string msg = App.CheckSTNO_ItemCode(queryJson, DocNo, WorkPoint);
  137. if (!string.IsNullOrEmpty(msg))
  138. {
  139. return Error(msg);
  140. }
  141. else
  142. {
  143. return Success("添加成功!");
  144. }
  145. }
  146. [HttpPost]
  147. [HandlerAjaxOnly]
  148. [ValidateAntiForgeryToken]
  149. public ActionResult DeleteInfo(string keyValue, string WorkPoint, string objInvCode)
  150. {
  151. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  152. WorkPoint = WorkPoint.Substring(1, WorkPoint.Length - 2);
  153. objInvCode = objInvCode.Substring(1, objInvCode.Length - 2);
  154. string msg = App.DeleteInfo(keyValue, WorkPoint, objInvCode);
  155. if (string.IsNullOrEmpty(msg))
  156. {
  157. return Success("删除成功!");
  158. }
  159. else
  160. {
  161. return Error(msg);
  162. }
  163. }
  164. [HttpPost]
  165. [HandlerAjaxOnly]
  166. [ValidateAntiForgeryToken]
  167. public ActionResult DeleteDocNo(string keyValue, string DeleteFlag, string PaperNo, string WorkPoint, string dVouDate)
  168. {
  169. if (DeleteFlag == "1")
  170. {
  171. string msg = App.DeleteDocNo(keyValue, WorkPoint);
  172. }
  173. else
  174. {
  175. string msg = App.UpdatePaperNo(keyValue, PaperNo, WorkPoint, dVouDate);
  176. }
  177. return Success("操作成功!");
  178. }
  179. public ActionResult DeleteDocNoBYX(string keyValue, string DeleteFlag, string PaperNo, string WorkPoint)
  180. {
  181. string msg = App.DeleteDocNo(keyValue, WorkPoint);
  182. return Success("操作成功!");
  183. }
  184. //public ActionResult ISInvoice(string queryJson, string WorkPoint)
  185. //{
  186. // try
  187. // {
  188. // App.ISInvoice(queryJson, WorkPoint);
  189. // return Success("修改成功!");
  190. // }
  191. // catch (Exception ex)
  192. // {
  193. // return Error(ex.Message);
  194. // }
  195. //}
  196. public ActionResult ISPaperNo(string PaperNo)
  197. {
  198. bool MSg;
  199. try
  200. {
  201. DataTable ListData = App.ISPaperNo(PaperNo);
  202. if (ListData.Rows.Count > 0)
  203. {
  204. MSg = true;
  205. }
  206. else
  207. {
  208. MSg = false;
  209. }
  210. var JsonData = new
  211. {
  212. MSg = MSg,
  213. };
  214. return Content(JsonData.ToJson());
  215. }
  216. catch (Exception ex)
  217. {
  218. return Error(ex.Message);
  219. }
  220. }
  221. public ActionResult GetVendorWorkPoint(string WorkPoint)
  222. {
  223. string VenCode = App.GetVendorWorkPoint(WorkPoint);
  224. return Content(VenCode);
  225. }
  226. [HttpPost]
  227. public ActionResult UpLoadFileImport(string DocNo)
  228. {
  229. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  230. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  231. string FileName = "";
  232. string Name = "";
  233. //获取上传的文件集合
  234. HttpFileCollection httpFile = System.Web.HttpContext.Current.Request.Files;
  235. try
  236. {
  237. for (int i = 0; i < httpFile.Count; i++)
  238. {
  239. FileName = Path.GetFileNameWithoutExtension(httpFile[i].FileName) + Path.GetExtension(httpFile[i].FileName);
  240. string Paths = System.Web.HttpContext.Current.Server.MapPath("~\\File\\InvoiceFile\\" + DocNo + "\\");
  241. if (!Directory.Exists(Paths))
  242. {
  243. Directory.CreateDirectory(Paths);
  244. }
  245. string PathName = System.Web.HttpContext.Current.Server.MapPath("~\\File\\InvoiceFile\\" + DocNo + "\\" + FileName);
  246. int iLen = httpFile[0].ContentLength;
  247. byte[] bData = new byte[iLen];
  248. httpFile[0].InputStream.Read(bData, 0, iLen);
  249. FileStream fs = new FileStream(PathName, FileMode.OpenOrCreate);
  250. fs.Write(bData, 0, bData.Length);
  251. fs.Flush();
  252. fs.Close();
  253. fs.Dispose();
  254. Name = "" + FileName + ";";
  255. }
  256. }
  257. catch (Exception ex)
  258. {
  259. return Error(ex.Message);
  260. }
  261. return Success("上传成功!");
  262. }
  263. [HttpGet]
  264. [HandlerAjaxOnly]
  265. public ActionResult GetInvoiceFile(string DocNo)
  266. {
  267. DataTable ListData = App.GetInvoiceFile(DocNo);
  268. var JsonData = new
  269. {
  270. rows = ListData,
  271. };
  272. return Content(JsonData.ToJson());
  273. }
  274. }
  275. }