예제 #1
0
        private void OnItemOnPropertyChanged(object s1, PropertyChangedEventArgs e1)
        {
            RaisePropertyChanged(e1.PropertyName);
            if (e1.PropertyName != "SizeConsumption")
            {
                return;
            }
            if (IsCalculatingQts)
            {
                return;
            }
            if (ObjStatus.IsLoading)
            {
                return;
            }
            var tmp = (int)PurchaseOrderSizes.Sum(x => x.SizeConsumption);

            if (IsCalculatingQts)
            {
                return;
            }
            if (tmp <= ParentRfqSub.Qty)
            {
                TextBoxBackColor           = new SolidColorBrush(Colors.White);
                RowTotal                   = tmp;
                ObjStatus.IsReadyForSaving = true;
            }
            else
            {
                TextBoxBackColor
                         = new SolidColorBrush(Color.FromArgb(255, 255, 22, 22));
                RowTotal = ParentRfqSub.Qty;
                ObjStatus.IsReadyForSaving = false;
            }
        }
예제 #2
0
        private void CalculateBasedOnRatio()
        {
            IsCalculatingQts = true;
            double floatingNumbers = 0;
            var    sum             = double.Parse(PurchaseOrderSizes.Where(x => x.IsTextBoxEnabled).Sum(x => x.SizeRatio).ToString(CultureInfo.InvariantCulture));
            var    num1            = RowTotal;

            foreach (var s in PurchaseOrderSizes.Where(x => x.IsTextBoxEnabled))
            {
                s.SizeConsumption = (num1 * (double.Parse((s.SizeRatio.ToString(CultureInfo.InvariantCulture))) / sum));
            }
            foreach (var s in PurchaseOrderSizes.Where(x => x.IsTextBoxEnabled))
            {
                int dummyValueHolder;
                if (int.TryParse(s.SizeConsumption.ToString(CultureInfo.InvariantCulture), out dummyValueHolder))
                {
                    continue;
                }
                var x = (Double.Parse(s.SizeConsumption.ToString(CultureInfo.InvariantCulture).Substring(s.SizeConsumption.ToString(CultureInfo.InvariantCulture).IndexOf('.'))));
                floatingNumbers  += x;
                s.SizeConsumption = int.Parse(s.SizeConsumption.ToString(CultureInfo.InvariantCulture).Split('.')[0]);
            }
            var topNearInt            = (int)(Math.Ceiling(double.Parse(floatingNumbers.ToString(CultureInfo.InvariantCulture))));
            var purchaseOrderSizeInfo =
                PurchaseOrderSizes
                .FirstOrDefault(x => Math.Abs(x.SizeConsumption - PurchaseOrderSizes.Max(m => m.SizeConsumption)) < double.Epsilon);

            if (purchaseOrderSizeInfo != null)
            {
                purchaseOrderSizeInfo
                .SizeConsumption = (purchaseOrderSizeInfo
                                    .SizeConsumption + topNearInt);
            }

            IsCalculatingQts = false;
        }
예제 #3
0
 private void item_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     RowTotal = PurchaseOrderSizes.Sum(x => x.SizeConsumption);
 }