コード例 #1
0
        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);
        }
コード例 #2
0
ファイル: POService.cs プロジェクト: xuantranm/V3System
        public bool Update(WAMS_PURCHASE_ORDER entity, List<V3_Pe_Detail_Data> entityDetails, string lstDeleteDetailItem)
        {
            _repository.Update(entity);
            foreach (var detail in entityDetails)
            {
                if (detail.Id != 0)
                {
                    var detailEntity = _repositoryDetail.GetByKey(detail.Id);
                    detailEntity.vProductID = detail.StockId;
                    detailEntity.fQuantity = decimal.Parse(detail.Quantity, new CultureInfo(Constants.MyCultureInfo));
                    detailEntity.PriceId = detail.Price_Id;
                    detailEntity.fUnitPrice = decimal.Parse(detail.UnitPrice, new CultureInfo(Constants.MyCultureInfo));
                    detailEntity.iDiscount = int.Parse(detail.Discount, new CultureInfo(Constants.MyCultureInfo));
                    detailEntity.fVAT = int.Parse(detail.VAT, new CultureInfo(Constants.MyCultureInfo));
                    detailEntity.fItemTotal = decimal.Parse(detail.ItemTotal, new CultureInfo(Constants.MyCultureInfo));
                    detailEntity.vRemark = detail.Remark;
                    detailEntity.dModified = DateTime.Now;
                    detailEntity.iModified = entity.iModified;
                    _repositoryDetail.Update(detailEntity);
                }
                else
                {
                    var detailEntity = new WAMS_PO_DETAILS
                    {
                        vPOID = entity.Id,
                        vMRF = detail.MRFId,
                        iDiscount = int.Parse(detail.Discount, new CultureInfo(Constants.MyCultureInfo)),
                        vProductID = detail.StockId,
                        fQuantity = decimal.Parse(detail.Quantity, new CultureInfo(Constants.MyCultureInfo)),
                        fVAT = int.Parse(detail.VAT, new CultureInfo(Constants.MyCultureInfo)),
                        fItemTotal = decimal.Parse(detail.ItemTotal, new CultureInfo(Constants.MyCultureInfo)),
                        vRemark = detail.Remark,
                        vPODetailStatus = "Open",
                        fUnitPrice = decimal.Parse(detail.UnitPrice, new CultureInfo(Constants.MyCultureInfo)),
                        PriceId = detail.Price_Id,
                        iEnable = true,
                        dDateAssign = entity.dCreated,
                        dCreated = entity.dCreated,
                        iCreated = entity.iCreated
                    };
                    _repositoryDetail.Add(detailEntity);
                }
            }

            if (!string.IsNullOrEmpty(lstDeleteDetailItem))
            {
                var listStrLineElements = lstDeleteDetailItem.Split(';').ToList();
                foreach (var itemDetail in listStrLineElements)
                {
                    _customRepository.DeleteDetail(Convert.ToInt32(itemDetail));
                }
            }
            _unitOfWork.CommitChanges();
            // Update Total PE
            _customRepository.UpdatePeTotal(entity.Id);

            // Insert New Payment Type
            _customRepository.UpdatePaymentType(entity.vTermOfPayment);
            return true;
        }
コード例 #3
0
ファイル: POService.cs プロジェクト: xuantranm/V3System
        public bool Insert(WAMS_PURCHASE_ORDER entity, List<V3_Pe_Detail_Data> entityDetails)
        {
            _repository.Add(entity);
            _unitOfWork.CommitChanges();
            var listRequisitionUpdate = new List<PeRequisitionUpdate>();
            foreach (var detail in entityDetails)
            {
                var detailEntity = new WAMS_PO_DETAILS
                {
                    vPOID = entity.Id,
                    vMRF = detail.MRFId,
                    iDiscount = int.Parse(detail.Discount, new CultureInfo(Constants.MyCultureInfo)),
                    vProductID = detail.StockId,
                    fQuantity = decimal.Parse(detail.Quantity, new CultureInfo(Constants.MyCultureInfo)),
                    fVAT = int.Parse(detail.VAT, new CultureInfo(Constants.MyCultureInfo)),
                    fItemTotal = decimal.Parse(detail.ItemTotal, new CultureInfo(Constants.MyCultureInfo)),
                    vRemark = detail.Remark,
                    vPODetailStatus = "Open",
                    fUnitPrice = decimal.Parse(detail.UnitPrice, new CultureInfo(Constants.MyCultureInfo)),
                    PriceId = detail.Price_Id,
                    iEnable = true,
                    dDateAssign = entity.dCreated,
                    dCreated = entity.dCreated,
                    iCreated = entity.iCreated
                };
                _repositoryDetail.Add(detailEntity);
                var listMrf = detail.MRFId.Split(';').ToList();
                listRequisitionUpdate.AddRange(listMrf.Select(mrf => new PeRequisitionUpdate
                {
                    Mrf = Convert.ToInt32(mrf), Stock = detail.StockId, Quantity = decimal.Parse(detail.Quantity, new CultureInfo(Constants.MyCultureInfo))
                }));
            }
            _unitOfWork.CommitChanges();
            // Update Total PE

            // Update Requisition : Store insert PO
            foreach (var requistionUpdate in listRequisitionUpdate)
            {
                _customRepository.UpdateRequisition(requistionUpdate.Mrf, requistionUpdate.Stock, requistionUpdate.Quantity);
            }

            _customRepository.UpdatePeTotal(entity.Id);
            // Insert New Payment Type
            _customRepository.UpdatePaymentType(entity.vTermOfPayment);
            return true;
        }