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.

409 lines
13 KiB

4 days ago
  1. using NFine.Application;
  2. using NFine.Code;
  3. using NFine.Domain._03_Entity;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.IO;
  8. using System.Linq;
  9. using System.Web;
  10. using System.Web.Mvc;
  11. namespace NFine.Web.Areas.SRM.Controllers
  12. {
  13. public class QuotedPriceController : ControllerBase
  14. {
  15. private QuotedPriceApp App = new QuotedPriceApp();
  16. //初次加载页面数据
  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 SelectOffer(string RFQCODE, Pagination pagination, string WorkPoint)
  34. {
  35. DataTable ListData = App.SelectOffer(RFQCODE, ref pagination, WorkPoint);
  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 SelectOfferByYL(string RFQCODE, Pagination pagination, string WorkPoint)
  48. {
  49. DataTable ListData = App.SelectOfferByYL(RFQCODE, 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. [HttpGet]
  60. [HandlerAjaxOnly]
  61. public ActionResult SecondSelectOffer(string RFQCODE, string QUOTATIONCODE, Pagination pagination)
  62. {
  63. DataTable ListData = App.SecondSelectOffer(RFQCODE, QUOTATIONCODE, ref pagination);
  64. var JsonData = new
  65. {
  66. total = pagination.total,
  67. page = pagination.page,
  68. records = pagination.records,
  69. rows = ListData,
  70. };
  71. return Content(JsonData.ToJson());
  72. }
  73. [HttpGet]
  74. [HandlerAjaxOnly]
  75. public ActionResult SecondSelectOfferByYL(string RFQCODE, string QUOTATIONCODE, Pagination pagination)
  76. {
  77. DataTable ListData = App.SecondSelectOfferByYL(RFQCODE, QUOTATIONCODE, 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. // GET: SRM/QuotedPrice
  88. public ActionResult Index()
  89. {
  90. return View();
  91. }
  92. //查看报价详情子页面
  93. public ActionResult QuotedPriceDetails()
  94. {
  95. return View();
  96. }
  97. //提交报价单页面
  98. public ActionResult QuotedPrice()
  99. {
  100. return View();
  101. }
  102. public ActionResult QuotedPriceLIst()
  103. {
  104. return View();
  105. }
  106. public ActionResult IndexByYL()
  107. {
  108. return View();
  109. }
  110. public ActionResult QuotedPriceDetailsByYL()
  111. {
  112. return View();
  113. }
  114. public ActionResult LookQuotedPriceDetails()
  115. {
  116. return View();
  117. }
  118. /// <summary>
  119. /// 获取物料名称、单位、规格型号
  120. /// </summary>
  121. /// <param name="WorkPoint"></param>
  122. /// <returns></returns>
  123. [HttpGet]
  124. [HandlerAjaxOnly]
  125. public ActionResult GetTxtInfo(string RFQCODE)
  126. {
  127. DataTable ListData = App.GetTxtInfo(RFQCODE);
  128. var JsonData = new
  129. {
  130. RFQCODE = ListData.Rows[0][0].ToString(),
  131. RFQNAME = ListData.Rows[0][1].ToString(),
  132. PURCHUGCODE = ListData.Rows[0][2].ToString(),
  133. ITEMTYPE = ListData.Rows[0][3].ToString(),
  134. PURCHUGNAME = ListData.Rows[0][4].ToString(),
  135. PURCHUGCONECT = ListData.Rows[0][5].ToString(),
  136. VENDORCODE = ListData.Rows[0][6].ToString(),
  137. cVenName = ListData.Rows[0][7].ToString(),
  138. VENDORTYPE = ListData.Rows[0][8].ToString(),
  139. CURRENCY = ListData.Rows[0][9].ToString(),
  140. TAXRATE = ListData.Rows[0][10].ToString(),
  141. PAYMENTCONDITION = ListData.Rows[0][11].ToString(),
  142. MEMO = ListData.Rows[0][12].ToString(),
  143. COMPANYCODE = ListData.Rows[0][13].ToString(),
  144. HASCOSTDETAILS = ListData.Rows[0][14].ToString(),
  145. FileName = ListData.Rows[0][15].ToString(),
  146. //AccountPeriod = ListData.Rows[0][16].ToString(),
  147. };
  148. return Content(JsonData.ToJson());
  149. }
  150. //新增获取报价单号
  151. [HttpGet]
  152. [HandlerAjaxOnly]
  153. public ActionResult GetQuotationNo(string RFQCODE, string WorkPoint)
  154. {
  155. string QuotationNo = App.GetQuotationNo(RFQCODE, WorkPoint);
  156. var JsonData = new
  157. {
  158. QuotationNo = QuotationNo,
  159. };
  160. return Content(JsonData.ToJson());
  161. }
  162. [HttpPost]
  163. public ActionResult UpLoadFile(string QuotationNo)
  164. {
  165. try
  166. {
  167. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  168. string FileName = "";
  169. string PathName = "";
  170. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  171. string Name="";
  172. //获取上传的文件集合
  173. HttpFileCollection httpFile = System.Web.HttpContext.Current.Request.Files;
  174. for (int i = 0; i < httpFile.Count; i++)
  175. {
  176. FileName =Path.GetFileNameWithoutExtension(httpFile[i].FileName) + Path.GetExtension(httpFile[i].FileName);
  177. string Paths = System.Web.HttpContext.Current.Server.MapPath("~\\File\\VendorFile\\" + MUSER + "\\" + QuotationNo + "");
  178. if (!Directory.Exists(Paths))
  179. {
  180. Directory.CreateDirectory(Paths);
  181. }
  182. PathName = System.Web.HttpContext.Current.Server.MapPath("~\\File\\VendorFile\\" + MUSER + "\\" + QuotationNo + "\\" + FileName);
  183. int iLen = httpFile[0].ContentLength;
  184. byte[] bData = new byte[iLen];
  185. httpFile[0].InputStream.Read(bData, 0, iLen);
  186. FileStream fs = new FileStream(PathName, FileMode.OpenOrCreate);
  187. fs.Write(bData, 0, bData.Length);
  188. fs.Flush();
  189. fs.Close();
  190. fs.Dispose();
  191. Name += "" + FileName + ";";
  192. }
  193. //int count = App.UpLoadFile(Name, QuotationNo);
  194. //if (count > 0)
  195. //{
  196. // return Success("上传成功!");
  197. //}
  198. //else
  199. //{
  200. // return Error("上传失败!");
  201. //}
  202. }
  203. catch (Exception ex)
  204. {
  205. return Error(ex.Message);
  206. }
  207. return Success("上传成功!");
  208. }
  209. [HttpGet]
  210. [HandlerAjaxOnly]
  211. public ActionResult GetVendor(string RFQCODE)
  212. {
  213. DataTable dt = App.GetVendor(RFQCODE);
  214. return Content(dt.ToJson());
  215. }
  216. [HttpGet]
  217. [HandlerAjaxOnly]
  218. public ActionResult GetcVenName(string VenCode, string RFQCODE)
  219. {
  220. DataTable dt = App.GetcVenName(VenCode, RFQCODE);
  221. return Content(dt.ToJson());
  222. }
  223. [HttpPost]
  224. [HandlerAjaxOnly]
  225. //[ValidateAntiForgeryToken]
  226. public ActionResult SaveQuotation(string keyValue)
  227. {
  228. string msg = "";
  229. msg = App.SaveQuotation(keyValue);
  230. if (string.IsNullOrWhiteSpace(msg))
  231. {
  232. return Success("信息保存成功!");
  233. }
  234. else
  235. {
  236. return Error("" + msg + "");
  237. }
  238. }
  239. [HttpPost]
  240. [HandlerAjaxOnly]
  241. //[ValidateAntiForgeryToken]
  242. public ActionResult SaveQuotationByYL(string keyValue)
  243. {
  244. string msg = "";
  245. msg = App.SaveQuotationByYL(keyValue);
  246. if (string.IsNullOrWhiteSpace(msg))
  247. {
  248. return Success("信息保存成功!");
  249. }
  250. else
  251. {
  252. return Error("" + msg + "");
  253. }
  254. }
  255. [HttpGet]
  256. [HandlerAjaxOnly]
  257. public ActionResult SecondGetTxtInfo(string RFQCODE, string QUOTATIONCODE)
  258. {
  259. DataTable ListData = App.SecondGetTxtInfo(RFQCODE, QUOTATIONCODE);
  260. var JsonData = new
  261. {
  262. rows = ListData,
  263. };
  264. return Content(JsonData.ToJson());
  265. }
  266. [HttpGet]
  267. [HandlerAjaxOnly]
  268. public ActionResult GetVenDorFileTB(string QUOTATIONCODE)
  269. {
  270. DataTable ListData = App.GetVenDorFileTB(QUOTATIONCODE);
  271. var JsonData = new
  272. {
  273. rows = ListData,
  274. };
  275. return Content(JsonData.ToJson());
  276. }
  277. [HttpGet]
  278. [HandlerAjaxOnly]
  279. public ActionResult GetSORRVenDorFile(string QUOTATIONCODE)
  280. {
  281. DataTable ListData = App.GetSORRVenDorFile(QUOTATIONCODE);
  282. var JsonData = new
  283. {
  284. rows = ListData,
  285. };
  286. return Content(JsonData.ToJson());
  287. }
  288. [HttpGet]
  289. [HandlerAjaxOnly]
  290. public ActionResult GetVenDorFileSSOR(string rfqno)
  291. {
  292. DataTable ListData = App.GetVenDorFileSSOR(rfqno);
  293. var JsonData = new
  294. {
  295. rows = ListData,
  296. };
  297. return Content(JsonData.ToJson());
  298. }
  299. [HttpPost]
  300. public void ExportAll(string RFQCODE, string WorkPoint)
  301. {
  302. DataTable dt = App.GetPOListExport(RFQCODE, WorkPoint);
  303. AsposeCell.Export(dt);
  304. }
  305. [HttpPost]
  306. public ActionResult GetICSImport(string BidCode, string WorkPoint)
  307. {
  308. string mess = "";
  309. DataTable dts=null;
  310. try
  311. {
  312. HttpFileCollection hpFiles = System.Web.HttpContext.Current.Request.Files;
  313. if (hpFiles != null && hpFiles.Count > 0)
  314. {
  315. string IsXls = System.IO.Path.GetExtension(hpFiles[0].FileName).ToString().ToLower();//System.IO.Path.GetExtension获得文件的扩展名
  316. if (IsXls != ".xls" && IsXls != ".xlsx")
  317. {
  318. mess = "只可以选择Excel(.xls .xlsx)文件";//当选择的不是Excel文件时,返回
  319. }
  320. string filename = DateTime.Now.ToString("yyyyMMddhhmmss") + Guid.NewGuid() + IsXls; //获取Execle文件名 DateTime日期函数
  321. string savePath = System.Web.HttpContext.Current.Server.MapPath("~\\File\\UPLoadFile\\" + filename);//Server.MapPath 获得虚拟服务器相对路径
  322. int iLen = hpFiles[0].ContentLength;
  323. if (Directory.Exists(savePath)) mess = "文件已存在";
  324. byte[] bData = new byte[iLen];
  325. hpFiles[0].InputStream.Read(bData, 0, iLen);
  326. FileStream newFile = new FileStream(savePath, FileMode.OpenOrCreate);
  327. newFile.Write(bData, 0, bData.Length);
  328. newFile.Flush();
  329. int _FileSizeTemp = hpFiles[0].ContentLength;
  330. newFile.Close();
  331. newFile.Dispose();
  332. //bool del = false;
  333. dts = App.GetICSImport(savePath);
  334. if (System.IO.File.Exists(savePath))//删除文件
  335. {
  336. System.IO.File.Delete(savePath);
  337. }
  338. }
  339. else
  340. {
  341. mess = "获取文件失败";
  342. }
  343. }
  344. catch (Exception ex)
  345. {
  346. mess = ex.Message;
  347. }
  348. return Content(dts.ToJson());
  349. }
  350. }
  351. }