using NFine.Application.WMS; using NFine.Code; using System; using System.Collections.Generic; using System.Data; using System.IO; using System.Linq; using System.Web; using System.Web.Mvc; namespace NFine.Web.Areas.WMS.Controllers { public class ICSMOApplyController : ControllerBase { ICSMOApplyApp App = new ICSMOApplyApp(); // GET: WMS/ICSMOApply public ActionResult ICSMOApplyNegQuery() { return View(); } public ActionResult ICSMOApplyEdit() { return View(); } public ActionResult SeachICSMOApply() { return View(); } public ActionResult SeachInventory() { return View(); } [HttpPost] [HandlerAjaxOnly] [ValidateAntiForgeryToken] public ActionResult DeleteMOApplyApplyNeg(string keyValue) { string msg = App.DeleteMOApplyApplyNeg(keyValue); if (string.IsNullOrEmpty(msg)) { return Success("删除成功!"); } else { return Error(msg); } } /// /// 详情 /// /// /// /// [HttpGet] [HandlerAjaxOnly] public ActionResult GetMOApplyApplyNegDetail(string ApplyNegCode, Pagination pagination) { DataTable ListData = App.GetMOApplyApplyNegDetail(ApplyNegCode, ref pagination); var JsonData = new { total = pagination.total, page = pagination.page, records = pagination.records, rows = ListData, }; return Content(JsonData.ToJson()); } public void ClearTemp() { App.ClearTemp(); } public ActionResult GetOOCode(string WorkPoint) { try { string Code = App.GetOOCode(WorkPoint); var JsonData = new { Code = Code, }; return Content(JsonData.ToJson()); } catch (Exception ex) { return Error(ex.Message); } } /// /// 汇总 /// /// /// [HttpGet] public ActionResult GetMOApplyApplyNeg(Pagination pagination) { DataTable ListData = App.GetMOApplyApplyNeg(ref pagination); var JsonData = new { total = pagination.total, page = pagination.page, records = pagination.records, rows = ListData, }; return Content(JsonData.ToJson()); } /// /// 修改弹出框的数据来源 /// /// /// /// public ActionResult GetICSMOApplyReturnTemporary(string ApplyCode, Pagination pagination) { DataTable table = App.GetICSMOApplyReturnTemporary(ApplyCode); var JsonData = new { total = pagination.total, page = pagination.page, records = pagination.records, rows = table }; return Content(JsonData.ToJson()); } /// /// 新增和修改 /// /// /// [HttpPost] [HandlerAjaxOnly] public ActionResult SaveICSMOApplyApplyNeg(string keyValue, string deleteIDs) { string msg = App.SaveICSMOApplyApplyNeg(keyValue, deleteIDs); if (!string.IsNullOrEmpty(msg)) { return Error(msg); } else { return Success("保存成功!"); } } ///// ///// 修改 ///// ///// ///// //[HttpPost] //[HandlerAjaxOnly] //public ActionResult UpdateICSMOApplyApplyNeg(string ICSASN) //{ // string msg = App.UpdateICSMOApplyApplyNeg(ICSASN); // if (!string.IsNullOrEmpty(msg)) // { // return Error(msg); // } // else // { // return Success("修改成功!"); // } //} //库位导入 [HttpPost] /// /// 文件上传到本地 /// public string UploadFile() { try { HttpFileCollection hpFiles = System.Web.HttpContext.Current.Request.Files; if (hpFiles != null && hpFiles.Count > 0) { string IsXls = System.IO.Path.GetExtension(hpFiles[0].FileName).ToString().ToLower();//System.IO.Path.GetExtension获得文件的扩展名 if (IsXls != ".xls" && IsXls != ".xlsx") { return "只可以选择Excel(.xls .xlsx)文件";//当选择的不是Excel文件时,返回 } string filename = DateTime.Now.ToString("yyyyMMddhhmmss") + Guid.NewGuid() + IsXls; //获取Execle文件名 DateTime日期函数 string savePath = System.Web.HttpContext.Current.Server.MapPath("~\\File\\UPLoadFile\\" + filename);//Server.MapPath 获得虚拟服务器相对路径 int iLen = hpFiles[0].ContentLength; if (Directory.Exists(savePath)) return "文件已存在"; byte[] bData = new byte[iLen]; hpFiles[0].InputStream.Read(bData, 0, iLen); FileStream newFile = new FileStream(savePath, FileMode.OpenOrCreate); newFile.Write(bData, 0, bData.Length); newFile.Flush(); int _FileSizeTemp = hpFiles[0].ContentLength; newFile.Close(); newFile.Dispose(); //bool del = false; string mess = ""; mess = App.SetData_PR(savePath); if (System.IO.File.Exists(savePath))//删除文件 { System.IO.File.Delete(savePath); } return mess; } else { return "获取文件失败"; } } catch (Exception ex) { return ex.ToString(); } } //导出 [HttpPost] public void ExportAll(string keyValue) { DataTable dt = App.GetASNListExport(); AsposeCell.Export(dt); } } }