Esempio n. 1
0
        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  = detail.Quantity;
                    detailEntity.PriceId    = detail.Price_Id;
                    detailEntity.fUnitPrice = detail.UnitPrice;
                    detailEntity.iDiscount  = detail.Discount;
                    detailEntity.fVAT       = detail.VAT;
                    detailEntity.fItemTotal = detail.ItemTotal;
                    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       = detail.Discount,
                        vProductID      = detail.StockId,
                        fQuantity       = detail.Quantity,
                        fVAT            = detail.VAT,
                        fItemTotal      = detail.ItemTotal,
                        vRemark         = detail.Remark,
                        vPODetailStatus = "Open",
                        fUnitPrice      = detail.UnitPrice,
                        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);
        }
Esempio n. 2
0
        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       = detail.Discount,
                    vProductID      = detail.StockId,
                    fQuantity       = detail.Quantity,
                    fVAT            = detail.VAT,
                    fItemTotal      = detail.ItemTotal,
                    vRemark         = detail.Remark,
                    vPODetailStatus = "Open",
                    fUnitPrice      = detail.UnitPrice,
                    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 = detail.Quantity
                }));
            }
            _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);
        }
        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));
        }
Esempio n. 4
0
        public ActionResult Create()
        {
            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 listDetail       = new List <V3_Pe_Detail>();
            var poGetInformation = new V3_PE_Information();
            var item             = new WAMS_PURCHASE_ORDER
            {
                vPOID        = _service.GetAutoPoCode(),
                dPODate      = DateTime.Now,
                dDeliverDate = DateTime.Now
            };

            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      = 0,
                                    PoDetailsVResults = listDetail,
                                    PoGetInformation  = poGetInformation
            };

            return(View(model));
        }