using NFine.Application.KBSWMS; 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.KBSWMS.Controllers { public class ICSManufactureReceiveController : ControllerBase { private ICSManufactureReceiveApp App = new ICSManufactureReceiveApp(); public ActionResult Index() { return View(); } public ActionResult BindAdd() { return View(); } /// /// 获取产成品入库单数据 /// /// /// /// [HttpGet] [HandlerAjaxOnly] public ActionResult GetManufactureReceive(Pagination pagination, string queryJson) { DataTable ListData = App.GetManufactureReceive(queryJson, ref pagination); var JsonData = new { total = pagination.total, page = pagination.page, records = pagination.records, rows = ListData, }; return Content(JsonData.ToJson()); } [HttpGet] [HandlerAjaxOnly] public ActionResult GetManufactureReceiveLot(string ProductionCode, string WHCode,string InvCode,Pagination pagination) { DataTable ListData = App.GetManufactureReceiveLot(ProductionCode, WHCode, InvCode,ref pagination); var JsonData = new { total = pagination.total, page = pagination.page, records = pagination.records, rows = ListData, }; return Content(JsonData.ToJson()); } //入库单绑定条码 [HttpPost] [HandlerAjaxOnly] [ValidateAntiForgeryToken] public ActionResult BindingLot( string ICSASN) { string msg = App.BindingLot(ICSASN); if (msg=="") { return Success("绑定成功!"); } else { return Error(msg); } } //入库单解绑定条码 [HttpPost] [HandlerAjaxOnly] [ValidateAntiForgeryToken] public ActionResult PostUnBind(string ids) { string msg = App.PostUnBind(ids); if (msg == "") { return Success("解绑成功!"); } else { return Error(msg); } } /// /// 产成品入库单提交过账 /// /// /// [HttpPost] [HandlerAjaxOnly] [ValidateAntiForgeryToken] public ActionResult PostExamine(string RCVCodes) { string msg = App.PostExamine(RCVCodes); if (msg == "") { return Success("操作成功!"); } else { return Error(msg); } } /// /// 删除子件条码信息 /// /// /// [HttpPost] [HandlerAjaxOnly] [ValidateAntiForgeryToken] public ActionResult DeleteItemLot(string MOCodes) { MOCodes = MOCodes.Substring(1, MOCodes.Length-2); string msg = App.DeleteItemLot(MOCodes); if (string.IsNullOrWhiteSpace(msg)) { return Success("删除成功!"); } else { return Error(msg); } } [HttpPost] /// /// 条码绑定入库单导入 /// public string UploadFileBinding() { 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.UploadFileBinding(savePath); if (System.IO.File.Exists(savePath))//删除文件 { System.IO.File.Delete(savePath); } return mess; } else { return "获取文件失败"; } } catch (Exception ex) { return ex.ToString(); } } } }