public ActionResult EditITShipmentTranCreate(Entities.ImportTrans_main_record model, IFormFile excelfile, string returnUrl = null) { ModelState.Remove("Id"); int a = 0; ViewBag.ReturnUrl = Url.IsLocalUrl(returnUrl) ? returnUrl : Url.RouteUrl("itShipmentCreatetran"); if (!ModelState.IsValid) { return(View(model)); } if (!String.IsNullOrEmpty(model.Invcurr)) { model.Invcurr = model.Invcurr.Trim(); } if (!String.IsNullOrEmpty(model.Itemno)) { model.Itemno = model.Itemno.Trim(); } if (!String.IsNullOrEmpty(model.PoNo)) { model.PoNo = model.PoNo.Trim(); } if (model.Id.Equals(0)) { model.CreationTime = DateTime.Now; model.IsDeleted = false; model.Modifier = null; model.ModifiedTime = null; model.Creator = WorkContext.CurrentUser.Id; var inc = _orderMainService.getByAccount(model.PoNo); if (inc == null) { //Response.WriteAsync("<script>alert('未创建采购订单!');window.location.href ='editTran'</script>", Encoding.GetEncoding("GB2312")); } else { model.CargoType = inc.MaterialCategory; model.Buyer = inc.OrderSigner; model.Incoterms = inc.TradeTerms; model.Shipper = inc.SupplierName; } if (model.Transportation == null || model.Transportation == "") { Response.WriteAsync("<script>alert('未填写运输代理!');window.location.href ='editTran'</script>", Encoding.GetEncoding("GB2312")); } _importTrans_main_recordService.insertImportTransmain(model); } return(Redirect(ViewBag.ReturnUrl)); }
public ActionResult EditITLogistics(Entities.ImportTrans_main_record model, string returnUrl = null) { ModelState.Remove("Id"); ViewBag.ReturnUrl = Url.IsLocalUrl(returnUrl) ? returnUrl : Url.RouteUrl("itLogistics"); if (!ModelState.IsValid) { return(View(model)); } if (!String.IsNullOrEmpty(model.Invcurr)) { model.Invcurr = model.Invcurr.Trim(); } if (!String.IsNullOrEmpty(model.Shipper)) { model.Shipper = model.Shipper.Trim(); } if (!String.IsNullOrEmpty(model.Itemno)) { model.Itemno = model.Itemno.Trim(); } if (!String.IsNullOrEmpty(model.PoNo)) { model.PoNo = model.PoNo.Trim(); } if (!String.IsNullOrEmpty(model.PoNo)) { model.Buyer = model.PoNo.Substring(1, 2); } if (model.Id.Equals(0)) { model.CreationTime = DateTime.Now; model.IsDeleted = false; model.Modifier = null; model.ModifiedTime = null; model.Creator = WorkContext.CurrentUser.Id; _importTrans_main_recordService.insertImportTransmain(model); } else { model.Modifier = WorkContext.CurrentUser.Id; model.ModifiedTime = DateTime.Now; _importTrans_main_recordService.updateImportTransmain(model); } return(Redirect(ViewBag.ReturnUrl)); }
public ActionResult EditITPorkCustoms(Entities.ImportTrans_main_record model, IFormFile notefile, string returnUrl = null) { ModelState.Remove("Id"); ViewBag.ReturnUrl = Url.IsLocalUrl(returnUrl) ? returnUrl : Url.RouteUrl("itPorkCustoms"); if (!ModelState.IsValid) { return(View(model)); } if (!String.IsNullOrEmpty(model.Invcurr)) { model.Invcurr = model.Invcurr.Trim(); } if (!String.IsNullOrEmpty(model.Shipper)) { model.Shipper = model.Shipper.Trim(); } if (!String.IsNullOrEmpty(model.Itemno)) { model.Itemno = model.Itemno.Trim(); } if (!String.IsNullOrEmpty(model.PoNo)) { model.PoNo = model.PoNo.Trim(); } if (!String.IsNullOrEmpty(model.PoNo)) { model.Buyer = model.PoNo.Substring(1, 2); } if (model.Id.Equals(0)) { model.CreationTime = DateTime.Now; model.IsDeleted = false; model.Modifier = null; model.ModifiedTime = null; model.Creator = WorkContext.CurrentUser.Id; _importTrans_main_recordService.insertImportTransmain(model); } else { var modela = _importTrans_main_recordService.getById(model.Id); string sWebRootFolder = _hostingEnvironment.WebRootPath; if (notefile != null) { var fileProfilef = sWebRootFolder + "\\Files\\notefile\\"; string f = Guid.NewGuid().ToString("N"); string sFileNamef = f + notefile.FileName; FileInfo filef = new FileInfo(Path.Combine(fileProfilef, sFileNamef)); using (FileStream fsf = new FileStream(filef.ToString(), FileMode.Create)) { notefile.CopyTo(fsf); fsf.Flush(); } Attachment attachmentf = new Attachment(); attachmentf.AttachmentLoad = sFileNamef; attachmentf.Name = notefile.FileName; attachmentf.Type = "破损记录"; attachmentf.ImportId = model.Id; attachmentf.Creator = WorkContext.CurrentUser.Account; attachmentf.CreationTime = DateTime.Now; modela.Note = sFileNamef; _attachmentService.insertAttachment(attachmentf); } _importTrans_main_recordService.updateImportTransmain(modela); } return(Redirect(ViewBag.ReturnUrl)); }
public ActionResult EditITTransportW(Entities.ImportTrans_main_record model, IFormFile fpfile, IFormFile mblfile, IFormFile hblfile, string returnUrl = null) { ModelState.Remove("Id"); int a = 0; ViewBag.ReturnUrl = Url.IsLocalUrl(returnUrl) ? returnUrl : Url.RouteUrl("itTransportw"); if (!ModelState.IsValid) { return(View(model)); } if (!String.IsNullOrEmpty(model.Invcurr)) { model.Invcurr = model.Invcurr.Trim(); } if (!String.IsNullOrEmpty(model.Shipper)) { model.Shipper = model.Shipper.Trim(); } if (!String.IsNullOrEmpty(model.Itemno)) { model.Itemno = model.Itemno.Trim(); } if (!String.IsNullOrEmpty(model.PoNo)) { model.PoNo = model.PoNo.Trim(); } if (!String.IsNullOrEmpty(model.PoNo)) { model.Buyer = model.PoNo.Substring(1, 2); } if (model.Id.Equals(0)) { model.CreationTime = DateTime.Now; model.IsDeleted = false; model.Modifier = null; model.ModifiedTime = null; model.Creator = WorkContext.CurrentUser.Id; _importTrans_main_recordService.insertImportTransmain(model); } else { string sWebRootFolder = _hostingEnvironment.WebRootPath; var modela = _importTrans_main_recordService.getById(model.Id); if (fpfile != null) { var fileProfilef = sWebRootFolder + "\\Files\\fp\\"; string f = Guid.NewGuid().ToString("N"); string sFileNamef = f + fpfile.FileName; FileInfo filef = new FileInfo(Path.Combine(fileProfilef, sFileNamef)); using (FileStream fsf = new FileStream(filef.ToString(), FileMode.Create)) { fpfile.CopyTo(fsf); fsf.Flush(); } Attachment attachmentf = new Attachment(); attachmentf.AttachmentLoad = sFileNamef; attachmentf.Name = fpfile.FileName; attachmentf.Type = "箱单发票"; attachmentf.ImportId = model.Id; attachmentf.Creator = WorkContext.CurrentUser.Account; attachmentf.CreationTime = DateTime.Now; modela.InventoryAttachment = "箱单发票"; _attachmentService.insertAttachment(attachmentf); } if (mblfile != null) { var fileProfilem = sWebRootFolder + "\\Files\\mbl\\"; string m = Guid.NewGuid().ToString("N"); string sFileNamem = m + mblfile.FileName; FileInfo filem = new FileInfo(Path.Combine(fileProfilem, sFileNamem)); using (FileStream fsm = new FileStream(filem.ToString(), FileMode.Create)) { mblfile.CopyTo(fsm); fsm.Flush(); } Attachment attachmentm = new Attachment(); attachmentm.AttachmentLoad = sFileNamem; attachmentm.Type = "主运单"; attachmentm.Name = mblfile.FileName; attachmentm.ImportId = model.Id; attachmentm.Creator = WorkContext.CurrentUser.Account; attachmentm.CreationTime = DateTime.Now; modela.MblAttachment = "主运单"; _attachmentService.insertAttachment(attachmentm); } if (hblfile != null) { var fileProfileh = sWebRootFolder + "\\Files\\hbl\\"; string sFileNameh = Guid.NewGuid().ToString("N") + hblfile.FileName; FileInfo fileh = new FileInfo(Path.Combine(fileProfileh, sFileNameh)); using (FileStream fsh = new FileStream(fileh.ToString(), FileMode.Create)) { hblfile.CopyTo(fsh); fsh.Flush(); } Attachment attachmenth = new Attachment(); attachmenth.AttachmentLoad = sFileNameh; attachmenth.Type = "分运单"; attachmenth.Name = hblfile.FileName; attachmenth.ImportId = model.Id; attachmenth.Creator = WorkContext.CurrentUser.Account; attachmenth.CreationTime = DateTime.Now; modela.HblAttachment = "分运单"; _attachmentService.insertAttachment(attachmenth); } _importTrans_main_recordService.updateImportTransmain(model); } return(Redirect(ViewBag.ReturnUrl)); }