public ActionResult Create(int?id) { var userName = System.Web.HttpContext.Current.User.Identity.Name; var user = _systemService.GetUserAndRole(0, userName); if (user == null) { return(RedirectToAction("Index", "Login")); } if (user.StockInR == 0) { return(RedirectToAction("Index", "Home")); } var pe = new WAMS_PURCHASE_ORDER(); var stockInDetailList = new List <V3_List_StockIn_Detail>(); var totalDetailRecords = 0; if (id.HasValue) { pe = _peservice.GetByKey(id.Value); stockInDetailList = _service.ListConditionDetail(id.Value, "1"); totalDetailRecords = stockInDetailList.Count(); } var peCodeModel = _systemService.Ddlpe(1, 100, 0, 0, Constants.StatusOpen); var model = new FulfillmentViewModel { vPOID = pe.Id, iStore = pe.iStore, UserLogin = user, Stores = new SelectList(_systemService.StoreList(), "Id", "Name"), Suppliers = new SelectList(_systemService.SupplierList(), "Id", "Name"), SupplierId = pe.bSupplierID, PEs = new SelectList(peCodeModel.PEs, "Id", "Code"), StockInDetailList = stockInDetailList, TotalRecords = totalDetailRecords }; return(View(model)); }