Esempio n. 1
0
        public ActionResult Edit(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.PER == 0)
            {
                return(RedirectToAction("Index", "Home"));
            }

            var item               = _service.GetByKey(id);
            var listDetail         = _service.ListConditionDetail(id, "1");
            var totalDetailRecords = listDetail.Count();
            var poGetInformation   = _service.GetPeInformation(id);

            var vatList = _systemService.GetLookUp(Constants.LuVat);

            vatList.Add(new LookUp
            {
                LookUpKey   = "0",
                LookUpValue = "0"
            });
            vatList = vatList.OrderBy(m => m.LookUpKey).ToList();
            var model = new POViewModel
            {
                Id            = item.Id,
                vPOID         = item.vPOID,
                vPOStatus     = item.vPOStatus,
                sPODate       = item.dPODate.ToString("dd/MM/yyyy"),
                sDeliveryDate = item.dDeliverDate != null?item.dDeliverDate.Value.ToString("dd/MM/yyyy") : string.Empty,
                                    vLocation         = item.vLocation,
                                    vProjectID        = item.vProjectID,
                                    vRemark           = item.vRemark,
                                    Timestamp         = item.Timestamp,
                                    UserLogin         = user,
                                    Stores            = new SelectList(this._systemService.StoreList(), "Id", "Name"),
                                    iStore            = item.iStore != null ? item.iStore.Value : 0,
                                    Projects          = new SelectList(this._systemService.ProjectList(), "Id", "vProjectID"),
                                    ProjectNames      = new SelectList(this._systemService.ProjectList(), "Id", "vProjectName"),
                                    PoTypes           = new SelectList(this._systemService.PoTypeList(), "Id", "Name"),
                                    bPOTypeID         = item.bPOTypeID,
                                    Suppliers         = new SelectList(this._systemService.SupplierList(), "Id", "Name"),
                                    bSupplierID       = item.bSupplierID,
                                    bCurrencyTypeID   = item.bCurrencyTypeID,
                                    Currencies        = new SelectList(this._systemService.CurrencyList(), "Id", "Name"),
                                    Payments          = new SelectList(this._systemService.PaymentList(), "Id", "Name"),
                                    VatList           = new SelectList(vatList, Constants.LookUpKey, Constants.LookUpValue),
                                    Payment           = item.vTermOfPayment,
                                    TotalRecords      = totalDetailRecords,
                                    PoDetailsVResults = listDetail,
                                    PoGetInformation  = poGetInformation
            };

            return(View(model));
        }
        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));
        }