internal void FromCalculatedItem(CalculatedItem ci)
        {
            this.SetAllNull();

            if (ci.Field != null) this.Field = ci.Field.Value;
            if (ci.Formula != null) this.Formula = ci.Formula.Value;

            if (ci.PivotArea != null) this.PivotArea.FromPivotArea(ci.PivotArea);
        }
        internal CalculatedItem ToCalculatedItem()
        {
            CalculatedItem ci = new CalculatedItem();
            if (this.Field != null) ci.Field = this.Field.Value;
            if (this.Formula != null && this.Formula.Length > 0) ci.Formula = this.Formula;

            ci.PivotArea = this.PivotArea.ToPivotArea();

            return ci;
        }
Example #3
0
        public void SaveForSearch()
        {
            var products = new List <AppCore.Models.CalculatedProduct>();

            /*foreach (var i in calculatedProducts)
             * {
             *  AppCore.Models.CalculatedProduct pr = new AppCore.Models.CalculatedProduct
             *  {
             *      CalculationInstanceID = calculationInstance.ID,
             *      ProductName = i.Product.Product.Name,
             *      VendorCode = i.Product.Product.VendorCode,
             *      Count = i.Product.Count,
             *      Price = i.Product.Product.Price
             *  };
             *  products.Add(pr);
             *
             * }
             *
             * using (UserContext db = new UserContext(Settings.constr))
             * {
             *  db.CalculatedProducts.AddRange(products);
             *  db.SaveChanges();
             * }*/

            foreach (var i in calculatedProducts)
            {
                AppCore.Models.CalculatedProduct pr = new AppCore.Models.CalculatedProduct
                {
                    CalculationInstanceID = calculationInstance.ID,
                    ProductName           = i.Product.Product.Name,
                    VendorCode            = i.Product.Product.VendorCode,
                    Count = i.Product.Count,
                    Price = i.Product.Product.Price
                };
                //products.Add(pr);
                using (UserContext db = new UserContext(Settings.constr))
                {
                    db.CalculatedProducts.Add(pr);
                    db.SaveChanges();
                    foreach (var item in i.CalculatedValues)
                    {
                        var calcItem = new CalculatedItem
                        {
                            CalculatedProductID   = pr.ID,
                            CalculationInstanceID = calculationInstance.ID,
                            ItemID = item.Item.ID,
                            Value  = item.Value
                        };
                        db.CalculatedItems.Add(calcItem);
                    }

                    db.SaveChanges();
                }
            }
        }
        internal CalculatedItem ToCalculatedItem()
        {
            CalculatedItem ci = new CalculatedItem();

            if (this.Field != null)
            {
                ci.Field = this.Field.Value;
            }
            if (this.Formula != null && this.Formula.Length > 0)
            {
                ci.Formula = this.Formula;
            }

            ci.PivotArea = this.PivotArea.ToPivotArea();

            return(ci);
        }
        internal CalculatedItem ToCalculatedItem()
        {
            var ci = new CalculatedItem();

            if (Field != null)
            {
                ci.Field = Field.Value;
            }
            if ((Formula != null) && (Formula.Length > 0))
            {
                ci.Formula = Formula;
            }

            ci.PivotArea = PivotArea.ToPivotArea();

            return(ci);
        }
        internal void FromCalculatedItem(CalculatedItem ci)
        {
            this.SetAllNull();

            if (ci.Field != null)
            {
                this.Field = ci.Field.Value;
            }
            if (ci.Formula != null)
            {
                this.Formula = ci.Formula.Value;
            }

            if (ci.PivotArea != null)
            {
                this.PivotArea.FromPivotArea(ci.PivotArea);
            }
        }