コード例 #1
0
        public MetalViewModel(JobSetup js)
        {
            prevailingWage = js.ActualPrevailingWage == 0?0:(js.ActualPrevailingWage - laborRate) / laborRate;
            GetMetalDetailsFromGoogle(js.ProjectName);
            if (js.ProjectName == "Paraseal LG")
            {
                Metals      = GetMetalsLG();
                AddOnMetals = GetAddOnMetalsLG();
            }
            else
            {
                Metals      = GetMetals();
                AddOnMetals = GetAddOnMetals();
            }

            MiscMetals = GetMiscMetals();
            if (js.ProjectName == "Multicoat")
            {
                MiscMetals.Where(x => x.Name == "Nosing for Concrete risers").FirstOrDefault().Units = 0;
            }
            //if (js.ProjectName == "Paraseal LG")
            //{
            //    foreach (Metal item in Metals.Where(x=>x.Name.Contains("STAIR METAL")))
            //    {
            //        item.Units = 0;
            //    }
            //}
            CalculateCost(null);
            js.JobSetupChange += JobSetup_OnJobSetupChange;
        }
コード例 #2
0
 private void AddRow(object obj)
 {
     AddInt = AddInt + 1;
     MiscMetals.Add(new MiscMetal {
         Name = "Misc Metal", Units = 1, MaterialPrice = 0, UnitPrice = 0, IsEditable = true
     });
 }
コード例 #3
0
        private void RemoveRow(object obj)
        {
            int index = MiscMetals.IndexOf(obj as MiscMetal);

            if (AddInt > 2 && index < MiscMetals.Count)
            {
                MiscMetals.RemoveAt(AddInt);
                AddInt = AddInt - 1;
            }
            //   MiscMetals.Remove(MiscMetals.Last(x => x.CanRemove == true));
        }
コード例 #4
0
        public override void updateLaborCost()
        {
            double stairCost                = 0;
            double addOnMetalCost           = 0;
            double normCost                 = 0;
            IEnumerable <Metal> stairMetals = Metals.Where(x => x.IsStairMetalChecked == true);

            if (stairMetals.Count() > 0)
            {
                stairCost = stairMetals.Select(x => x.LaborExtension).Sum();
            }

            //IEnumerable<Metal> normMetals = Metals.Where(x => x.Name.Contains("STAIR") == false);
            //if (normMetals.Count() > 0)
            //{
            //    normCost = normMetals.Select(x => x.LaborExtension).Sum();
            //}

            //New Changes for Addon Metals
            IEnumerable <AddOnMetal> selectedAddOnMetals = AddOnMetals.Where(x => x.IsMetalChecked);

            if (selectedAddOnMetals.Count() > 0)
            {
                addOnMetalCost = selectedAddOnMetals.Select(x => x.LaborExtension).Sum();
            }

            normCost = Math.Round(normCost + stairCost + addOnMetalCost + MiscMetals.Select(x => x.LaborExtension).Sum(), 2);

            if (isPrevailingWage)
            {
                if (isDiscount)
                {
                    TotalLaborCost = Math.Round(normCost * (1 + prevailingWage + deductionOnLargeJob), 2);
                }
                else
                {
                    TotalLaborCost = Math.Round(normCost * (1 + prevailingWage), 2);
                }
            }
            else
            {
                if (isDiscount)
                {
                    TotalLaborCost = Math.Round(normCost * (1 + deductionOnLargeJob), 2);
                }
                else
                {
                    TotalLaborCost = Math.Round(normCost, 2);
                }
            }
        }
コード例 #5
0
        protected override void updateMaterialCost()
        {
            double stairCost      = 0;
            double normCost       = 0;
            double nl             = Nails / 100;
            double addOnMetalCost = 0;

            if (Metals.Count > 0 && MiscMetals.Count > 0)
            {
                IEnumerable <Metal> stairMetals = Metals.Where(x => x.IsStairMetalChecked == true);
                if (stairMetals.Count() > 0)
                {
                    stairCost = stairMetals.Select(x => x.MaterialExtension).Sum();
                }
                IEnumerable <AddOnMetal> selectedAddOnMetals = AddOnMetals.Where(x => x.IsMetalChecked == true);
                if (selectedAddOnMetals.Count() > 0)
                {
                    addOnMetalCost = selectedAddOnMetals.Select(x => x.MaterialExtension).Sum();
                }

                //IEnumerable<Metal> normMetals = Metals.Where(x => x.Name.Contains("STAIR") == false);
                //if (normMetals.Count() > 0)
                //{
                //    normCost = normMetals.Select(x => x.MaterialExtension).Sum();
                //}

                //double misSum = Metals.Select(x => x.MaterialExtension).Sum() * nl;

                TotalMaterialCost = Math.Round((normCost + stairCost) * (1 + nl) + addOnMetalCost * (1 + nl) + MiscMetals.Select(x => x.MaterialExtension).Sum(), 2);
            }
        }
コード例 #6
0
        public void OnJobSetupChange(JobSetup Js)
        {
            if (Js == null)
            {
                return;
            }
            if (Js != null)
            {
                MetalName        = Js.MaterialName;
                isPrevailingWage = Js.IsPrevalingWage;
                isDiscount       = Js.HasDiscount;
                vendorName       = Js.VendorName;
                stairWidth       = Js.StairWidth;
                isFlash          = Js.IsFlashingRequired;
                riserCount       = Js.RiserCount;
                MaterialPerc     = getMaterialDiscount(Js.ProjectDelayFactor);
                prevailingWage   = Js.ActualPrevailingWage == 0?0:(Js.ActualPrevailingWage - laborRate) / laborRate;
                if (Js.HasSpecialPricing)
                {
                    ShowSpecialPriceColumn = System.Windows.Visibility.Visible;
                }
                else
                {
                    ShowSpecialPriceColumn = System.Windows.Visibility.Hidden;
                }
            }
            ObservableCollection <Metal> met = new ObservableCollection <Metal>();

            if (Js.ProjectName == "Paraseal LG")
            {
                met = GetMetalsLG();
            }
            else
            {
                met = GetMetals();
            }

            for (int i = 0; i < Metals.Count; i++)
            {
                double units      = Metals[i].Units;
                double sp         = Metals[i].SpecialMetalPricing;
                bool   isSelected = Metals[i].IsStairMetalChecked;

                Metals[i] = met[i];
                if (!Metals[i].Name.Contains("STAIR METAL"))
                {
                    Metals[i].Units = units;
                    Metals[i].IsStairMetalChecked = isSelected;
                }
                else
                {
                    Metals[i].IsStairMetalChecked = isSelected;
                }

                Metals[i].SpecialMetalPricing = sp;
            }
            ObservableCollection <AddOnMetal> addOnMet = new ObservableCollection <AddOnMetal>();

            if (Js.ProjectName == "Paraseal LG")
            {
                addOnMet = GetAddOnMetalsLG();
            }
            else
            {
                addOnMet = GetAddOnMetals();
            }

            for (int i = 0; i < AddOnMetals.Count; i++)
            {
                double units     = AddOnMetals[i].Units;
                double sp        = AddOnMetals[i].SpecialMetalPricing;
                bool   ischecked = AddOnMetals[i].IsMetalChecked;
                AddOnMetals[i] = addOnMet[i];
                if (!AddOnMetals[i].Name.Contains("STAIR METAL"))
                {
                    AddOnMetals[i].Units = units;
                }
                AddOnMetals[i].IsMetalChecked      = ischecked;
                AddOnMetals[i].SpecialMetalPricing = sp;
            }

            if (Js != null)
            {
                if (Js.ProjectName == "Multicoat")
                {
                    MiscMetals.Where(x => x.Name == "Nosing for Concrete risers").FirstOrDefault().Units = 0;
                }
                else
                {
                    MiscMetals[1].Units = getUnits(3);
                }
            }

            CalculateCost(null);
        }