public ActionResult Detail(string id) { MD_IMPORTCONTRACT model = new MD_IMPORTCONTRACT(); if (!string.IsNullOrEmpty(id)) { var result = APIHelper.CallAPI <JsonResultObject <List <MD_IMPORTCONTRACT> > >("importcontract/getdetail", new { id = id }); if (result.IsOk) { model = result.dataObj.FirstOrDefault(); } } var contractfulldetail = new ImpContractEditViewModel(model); return(View(contractfulldetail)); }
public JsonResult Update(ImportFileDetailViewModel info) { info.UPDATEDDATE = DateTime.Now; info.UPDATEDUSER = LoginUser.Current.USERNAME; MD_IMPORTDETAIL detail = info.GetDetailImportFile(); var resultJson = APIHelper.CallAPI <JsonResultData>("importdetail/Update", new { data = detail }); if (!resultJson.IsOk) { return(Json(resultJson, JsonRequestBehavior.AllowGet)); } var lstCnt = info.GetImportContainer(); foreach (var cnt in lstCnt) { if (cnt.ID != 0) { resultJson = APIHelper.CallAPI <JsonResultData>("importpkl/Update", new { data = cnt }); if (!resultJson.IsOk) { return(Json(resultJson, JsonRequestBehavior.AllowGet)); } } else { resultJson = APIHelper.CallAPI <JsonResultData>("importpkl/Insert", new { data = cnt }); if (!resultJson.IsOk) { return(Json(resultJson, JsonRequestBehavior.AllowGet)); } } } var lstPallet = info.GetImportPallet(); foreach (var pallet in lstPallet) { var searchcontract = APIHelper.CallAPI <JsonResultObject <List <MD_IMPORTCONTRACT> > >("importcontract/getdetailbycode", new { code = detail.IMPORTCONTRACTCODE }); if (!searchcontract.IsOk) { return(Json(searchcontract, JsonRequestBehavior.AllowGet)); } var contract = searchcontract.dataObj.First(); var fullcontract = new ImpContractEditViewModel(contract); var supplier = fullcontract.SupplierDetail.SUPPLIERNAME; var material = APIHelper.CallAPI <JsonResultObject <List <MD_MATERIAL> > >("material/getdetail", new { id = pallet.MATERIALID }); if (!material.IsOk) { return(Json(material, JsonRequestBehavior.AllowGet)); } var materialName = material.dataObj != null?material.dataObj.FirstOrDefault().NAME : string.Empty; var submaterialName = string.Empty; if (pallet.SUBMATERIALID.HasValue) { var submaterial = APIHelper.CallAPI <JsonResultObject <List <MD_SUBMATERIAL> > >("submaterial/getdetail", new { id = pallet.SUBMATERIALID.Value }); if (!submaterial.IsOk) { return(Json(submaterial, JsonRequestBehavior.AllowGet)); } submaterialName = submaterial.dataObj != null?submaterial.dataObj.FirstOrDefault().NAME : string.Empty; } string Origin = string.Empty; var Sorigin = fullcontract.ItemList.Where(x => x.MATERIALID == pallet.MATERIALID && pallet.SUBMATERIALID.HasValue ? pallet.SUBMATERIALID.Value == x.SUBMATERIALID.Value : !x.SUBMATERIALID.HasValue); if (Sorigin.Count() > 0) { Origin = Sorigin.First().ORIGIN; } var fullNameMaterial = materialName + (string.IsNullOrEmpty(submaterialName) ? "" : " " + submaterialName); string objectSerialize = string.Format("LAMIPEL ERP\nMaterial:{5}\nPallet No:{0}\nFile No:{1}\nSupplier:{2}\nContract No:{3}\nInvoice PKL:{4}\nContainer:{6}\nPCS:{7}\nNW:{8}\nSQFT:{9}\nSAVG:{10}\nWAVG:{11}", string.IsNullOrEmpty(pallet.PALLETDONECODE) ? "" : pallet.PALLETDONECODE, detail.IMPFILE, supplier, contract.IMPORTCODE, detail.INVOICE, fullNameMaterial, pallet.IMPORTPKL, pallet.PCS, pallet.NW, pallet.SQFT, pallet.SAVG, pallet.WAVG); pallet.SCANCODE = Barcode.Current.CreateQRString(objectSerialize); List <string> dataprint = new List <string>(); dataprint.Add(string.IsNullOrEmpty(pallet.PALLETDONECODE) ? "" : pallet.PALLETDONECODE);//dataprint.Add(pallet.NAME); dataprint.Add(materialName); dataprint.Add(submaterialName); dataprint.Add(pallet.PCS.HasValue ? pallet.PCS.Value.ToString("#,##0") : "0"); dataprint.Add(pallet.NW.HasValue ? pallet.NW.Value.ToString("#,##0") : "0"); dataprint.Add(lstCnt.Where(x => x.PKLNAME == pallet.IMPORTPKL).First().PKLIDENTITY); //dataprint.Add(pallet.WAVG.HasValue ? pallet.WAVG.Value.ToString("#,##0") : "0"); dataprint.Add(pallet.SQFT.HasValue ? pallet.SQFT.Value.ToString("#,##0") : "0"); dataprint.Add(Origin); //origin dataprint.Add(info.ISLWG ? "YES" : "NO"); //lwg dataprint.Add(pallet.SCANCODE); var cnt = lstCnt.Where(x => x.PKLNAME == pallet.IMPORTPKL && x.IMPFILE == detail.IMPFILE); dataprint.Add(cnt != null && cnt.Count() > 0 ? cnt.First().PKLDONECODE : ""); //dataprint.Add(pallet.IMPORTPKL); dataprint.Add(supplier.Length > 15 ? supplier.Substring(0, 15) : supplier); pallet.TEMPLATEPRINT = BarcodeHelper.XMLHelper.Current.BuilResouce("ImportLabelPrint", dataprint.ToArray()); if (pallet.ID == 0) { pallet.CREATEDDATE = DateTime.Now; pallet.CREATEDUSER = LoginUser.Current.USERNAME; resultJson = APIHelper.CallAPI <JsonResultData>("importpallet/Insert", new { data = pallet }); if (!resultJson.IsOk) { return(Json(resultJson, JsonRequestBehavior.AllowGet)); } } else { pallet.UPDATEDDATE = DateTime.Now; pallet.UPDATEDUSER = LoginUser.Current.USERNAME; resultJson = APIHelper.CallAPI <JsonResultData>("importpallet/Update", new { data = pallet }); if (!resultJson.IsOk) { return(Json(resultJson, JsonRequestBehavior.AllowGet)); } } } return(Json(resultJson, JsonRequestBehavior.AllowGet)); }
public string GetAllPalletPrint(long id) { var resultJsonPKL = APIHelper.CallAPI <JsonResultObject <List <MD_IMPORTPKL> > >("importpkl/getlist", new { PageIndex = 0, PageSize = 1, FilterQuery = string.Format(" ID = {0} ", id), OrderBy = " ID ASC " }); if (!resultJsonPKL.IsOk) { return(string.Empty); } var importpkldetail = resultJsonPKL.dataObj.First(); var resultJsonImpFile = APIHelper.CallAPI <JsonResultObject <List <MD_IMPORTDETAIL> > >("importdetail/getlist", new { PageIndex = 0, PageSize = 1, FilterQuery = string.Format(" IMPFILE = '{0}' ", importpkldetail.IMPFILE), OrderBy = " ID ASC " }); if (!resultJsonImpFile.IsOk) { return(string.Empty); } var impfiledetail = resultJsonImpFile.dataObj.First(); var resultJson = APIHelper.CallAPI <JsonResultObject <List <MD_IMPPALLET> > >("importpallet/getlist", new { PageIndex = 0, PageSize = -1, FilterQuery = string.Format(" IMPORTPKL = '{0}' AND IMPFILEID = '{1}' ", importpkldetail.PKLNAME, importpkldetail.IMPFILE), OrderBy = " INDEXPKL ASC " }); if (!resultJson.IsOk) { return(string.Empty); } var lstPallet = resultJson.dataObj; string palletPrint = string.Empty; for (int i = 0; i < lstPallet.Count; i++) { var item = lstPallet[i]; var searchcontract = APIHelper.CallAPI <JsonResultObject <List <MD_IMPORTCONTRACT> > >("importcontract/getdetailbycode", new { code = impfiledetail.IMPORTCONTRACTCODE }); if (!searchcontract.IsOk) { return(string.Empty); } var contract = searchcontract.dataObj.First(); var fullcontract = new ImpContractEditViewModel(contract); var supplier = fullcontract.SupplierDetail.SUPPLIERNAME; var material = APIHelper.CallAPI <JsonResultObject <List <MD_MATERIAL> > >("material/getdetail", new { id = item.MATERIALID }); if (!material.IsOk) { return(string.Empty); } var materialName = material.dataObj != null?material.dataObj.FirstOrDefault().NAME : string.Empty; var submaterialName = string.Empty; if (item.SUBMATERIALID.HasValue) { var submaterial = APIHelper.CallAPI <JsonResultObject <List <MD_SUBMATERIAL> > >("submaterial/getdetail", new { id = item.SUBMATERIALID.Value }); if (!submaterial.IsOk) { return(string.Empty); } submaterialName = submaterial.dataObj != null?submaterial.dataObj.FirstOrDefault().NAME : string.Empty; } string Origin = string.Empty; var Sorigin = fullcontract.ItemList.Where(x => x.MATERIALID == item.MATERIALID && item.SUBMATERIALID.HasValue ? item.SUBMATERIALID.Value == x.SUBMATERIALID.Value : !x.SUBMATERIALID.HasValue); if (Sorigin.Count() > 0) { Origin = Sorigin.First().ORIGIN; } var fullNameMaterial = materialName + (string.IsNullOrEmpty(submaterialName) ? "" : " " + submaterialName); //string objectSerialize = string.Format("LAMIPEL ERP\nMaterial:{5}\nPallet No:{0}\nFile No:{1}\nSupplier:{2}\nContract No:{3}\nInvoice PKL:{4}\nContainer:{6}\nPCS:{7}\nNW:{8}\nSQFT:{9}\nSAVG:{10}\nWAVG:{11}", item.NAME, impfiledetail.IMPFILE, supplier, contract.IMPORTCODE, impfiledetail.INVOICE, fullNameMaterial, item.IMPORTPKL, item.PCS, item.NW, item.SQFT, item.SAVG, item.WAVG); string objectSerialize = string.Format("LAMIPEL ERP\nMaterial:{5}\nPallet No:{0}\nFile No:{1}\nSupplier:{2}\nContract No:{3}\nInvoice PKL:{4}\nContainer:{6}\nPCS:{7}\nNW:{8}\nSQFT:{9}\nSAVG:{10}\nWAVG:{11}", item.PALLETDONECODE, impfiledetail.IMPDONEFILEID, supplier, contract.IMPORTCODE, impfiledetail.INVOICE, fullNameMaterial, importpkldetail.PKLDONECODE, item.PCS, item.NW, item.SQFT, item.SAVG, item.WAVG); item.SCANCODE = Barcode.Current.CreateQRString(objectSerialize); List <string> dataprint = new List <string>(); dataprint.Add(item.PALLETDONECODE);//dataprint.Add(item.NAME); dataprint.Add(materialName); dataprint.Add(submaterialName); dataprint.Add(item.PCS.HasValue ? item.PCS.Value.ToString("#,##0") : "0"); dataprint.Add(item.NW.HasValue ? item.NW.Value.ToString("#,##0") : "0"); dataprint.Add(importpkldetail.PKLIDENTITY); //dataprint.Add(item.WAVG.HasValue ? item.WAVG.Value.ToString("#,##0") : "0"); dataprint.Add(item.SQFT.HasValue ? item.SQFT.Value.ToString("#,##0") : "0"); dataprint.Add(Origin); //origin dataprint.Add(impfiledetail.ISLWG ? "YES" : "NO"); //lwg dataprint.Add(item.SCANCODE); dataprint.Add(importpkldetail.PKLDONECODE); //dataprint.Add(item.IMPORTPKL); dataprint.Add(supplier.Length > 15 ? supplier.Substring(0, 15) : supplier); item.TEMPLATEPRINT = BarcodeHelper.XMLHelper.Current.BuilResouce("ImportLabelPrint", dataprint.ToArray()); var resultJsonUpdate = APIHelper.CallAPI <JsonResultData>("importpallet/Update", new { data = item }); //var resultJsonUpdate = new JsonResultData //{ // IsOk = true //}; if (!resultJsonUpdate.IsOk) { return(string.Empty); } palletPrint += item.TEMPLATEPRINT; if (i < lstPallet.Count - 1) { palletPrint += "<div style='clear: both; height: 36.5mm; '></div>"; } } return(palletPrint); }