Exemple #1
0
        public void SetQuoteItems(List <QuotationDetail> quoteDetails)
        {
            this.QuoteItems.Clear();

            this.QuoteItems = quoteDetails
                              .Select(x => new QuoteItemViewModel()
            {
                QuoteId                      = x.quoteId,
                LineNo                       = x.line_No.Value,
                PartNo                       = x.partNo,
                Description                  = x.description,
                ListPrice                    = x.listPrice.Value,
                UnitPrice                    = x.unitPrice.Value,
                QuotingPrice                 = x.newUnitPrice.Value,
                Itp                          = x.itp.Value,
                NewItp                       = x.newItp.Value,
                Qty                          = x.qty.Value,
                CurrentQty                   = x.qty.Value,
                SprNo                        = x.sprNo,
                HigherLevel                  = x.HigherLevel.Value,
                DMF_Flag                     = x.DMF_Flag,
                ItemType                     = x.ItemType.Value,
                DeliveryPlant                = x.deliveryPlant,
                NCNR                         = Convert.ToBoolean(x.NCNR.GetValueOrDefault(0)),
                RecyclingFee                 = x.RecyclingFee.GetValueOrDefault(0),
                Category                     = x.category,
                ClassABC                     = x.classABC,
                Rohs                         = x.rohs.GetValueOrDefault(1),
                EWFlag                       = x.ewFlag.GetValueOrDefault(0),
                RequiredDate                 = x.reqDate.GetValueOrDefault(DateTime.Now.AddDays(5)),
                DueDate                      = x.dueDate.GetValueOrDefault(DateTime.Now.AddDays(5)),
                SatisfyFlag                  = x.satisfyFlag.GetValueOrDefault(0),
                CanBeConfirmed               = x.canBeConfirmed.GetValueOrDefault(1),
                CusMaterial                  = x.custMaterial,
                Inventory                    = x.inventory.GetValueOrDefault(0),
                ModelNo                      = x.modelNo,
                VirtualPartNo                = x.VirtualPartNo,
                Recfigid                     = x.RECFIGID,
                SequenceNo                   = x.SequenceNo.GetValueOrDefault(0),
                IsEWPart                     = x.IsEWpartnoX,
                EWDrpIsEditable              = (!x.IsEWpartnoX && x.ItemType != (int)LineItemType.BTOSChild && x.IsServicePartX == false && x.IsSoftwarePart == false),
                PostTaxListPrice             = x.PostTaxListPrice,
                PostTaxUnitPrice             = x.PostTaxUnitPrice,
                PostTaxQuotingPrice          = x.PostTaxNewUnitPrice,
                PostTaxBtoParentListPrice    = quoteDetails.Where(d => d.quoteId.Equals(x.quoteId) && d.HigherLevel == x.line_No).Sum(d => d.PostTaxListPrice),
                PostTaxBtoParentUnitPrice    = quoteDetails.Where(d => d.quoteId.Equals(x.quoteId) && d.HigherLevel == x.line_No).Sum(d => d.PostTaxUnitPrice),
                PostTaxBtoParentQuotingPrice = quoteDetails.Where(d => d.quoteId.Equals(x.quoteId) && d.HigherLevel == x.line_No).Sum(d => d.PostTaxNewUnitPrice),
                PostTaxBtoParentSubTotal     = quoteDetails.Where(d => d.quoteId.Equals(x.quoteId) && d.HigherLevel == x.line_No).Sum(d => d.PostTaxSubTotal)
            })
                              .ToList();

            //Extend warranty options
            var ExWarrantyList = MyAdvantechDAL.GetExtendedWarrantyByOrg(this.Org);

            foreach (var ewItem in ExWarrantyList)
            {
                foreach (var quoteItem in this.QuoteItems)
                {
                    quoteItem.EWPartOptions.Add(new SelectListItem()
                    {
                        Text     = ewItem.EW_PartNO,
                        Value    = ewItem.ID.ToString(),
                        Selected = ewItem.ID == quoteItem.EWFlag
                    });
                }
            }

            //Prepare parent items
            foreach (var item in this.QuoteItems)
            {
                if (item.PartNo.IndexOf("-BTO", StringComparison.OrdinalIgnoreCase) >= 0)
                {
                    this.ParentItemOptions.Add(new SelectListItem()
                    {
                        Text     = item.PartNo,
                        Value    = item.LineNo.ToString(),
                        Selected = item.PartNo == this.currentPartentOption
                    });
                }
            }
        }