Beispiel #1
0
        public void SaveCostInDictionary(Cost c)
        {
            CheckExistDic();
            Cost val;
            if (DocumentCostsDic.TryGetValue(c.CodCost, out val))
            {
                // yay, value exists!
                DocumentCostsDic[c.CodCost] = c;
            }
            else
            {
                // darn, lets add the value
                DocumentCostsDic.Add(c.CodCost, c);
            }

            //aggiorno anche il costdetail con il riferimento!!!
            var x = GetCostDetailFromDictionary(c.CodCost);
            if (x != null)
            {
                x.TaskCost = c;

                if (!c.CostDetails.Contains(x))
                {
                    c.CostDetails.Add(x);
                }


            }

        }
Beispiel #2
0
        public virtual void Copy(Cost to)
        {


            to.TimeStampTable = this.TimeStampTable;
            to.CodCost = this.CodCost;
            //        to.CodDocumentProduct = this.    	 		
            to.CodProductTask = this.CodProductTask;
            to.CodProductPartTask = this.CodProductPartTask;
            to.CodProductPartPrintableArticle = this.CodProductPartPrintableArticle;
            to.Description = this.Description;
            to.Quantity = this.Quantity;
            to.QuantityMaterial = this.QuantityMaterial;
            to.UnitCost = this.UnitCost;
            to.TotalCost = this.TotalCost;
            to.ForceZero = this.ForceZero;
            to.Hidden = this.Hidden;
            to.CodProductPartImplantTask = this.CodProductPartImplantTask;
            to.Locked = this.Locked;
            to.CodItemGraph = this.CodItemGraph;
            to.Markup = this.Markup;
            to.GranTotalCost = this.GranTotalCost;
            to.TypeOfCalcolous = this.TypeOfCalcolous;

            //   to.DocumentProduct = this.DocumentProduct;

            to.ProductPartsPrintableArticle = this.ProductPartsPrintableArticle;
            to.ProductPartTask = this.ProductPartTask;
            to.ProductTask = this.ProductTask;

            to.ProductPartImplantTask = this.ProductPartImplantTask;

            //foreach (var costDet in CostDetails)
            //{
            //    var cd= (CostDetail) costDet.Clone();
            //    //cd.TaskCost=to;
            //    to.CostDetails.Add(cd);
            //}

            to.Manual = this.Manual;

        }
Beispiel #3
0
        public void InitCost()
        {
            Cost cost;

            this.CodProduct = Product.CodProduct;
            this.ProductName = Product.ProductName;

            //for each ProductTask / ProductPartTask / ProductPartsPrintableArticle in Product
            //adding new cost

            //ProductTask
            //only code 
            //                            foreach (var productTask in product.ProductTasks.Where(x => !x.CodOptionTypeOfTask.Contains("_NO")))

            var tsks = Product.ProductTasks.Where(x => !x.CodOptionTypeOfTask.Contains("_NO"));
            tsks = tsks.OrderBy(x => x.IndexOf);

            foreach (var productTask in tsks)
            {
                cost = new Cost();
                cost.CodItemGraph = productTask.CodItemGraph;

                cost.DocumentProduct = this;
                cost.CodDocumentProduct = this.CodDocumentProduct;

                cost.CodProductTask = productTask.CodProductTask;
                cost.Description = "***Lavorazione del prodotto";

                if (productTask.CodOptionTypeOfTask.Contains("_NO"))
                {
                    cost.Hidden = true;
                    cost.ForceZero = true;
                }

                cost.IndexOf = productTask.IndexOf;
                this.Costs.Add(cost);
            }

            //ProductPartTask & ProductPartsPrintableArticle
            foreach (var productPart in Product.ProductParts)
            {
                #region ProductPartPrintableArticle
                foreach (var productPartsPrintableArticle in productPart.ProductPartPrintableArticles)
                {
                    cost = new Cost();
                    cost.DocumentProduct = this;
                    cost.CodDocumentProduct = this.CodDocumentProduct;

                    cost.CodProductPartPrintableArticle = productPartsPrintableArticle.CodProductPartPrintableArticle;
                    cost.ProductPartsPrintableArticle = productPartsPrintableArticle;
                    cost.ProductPartsPrintableArticle.ProductPart = productPart;

                    cost.Description = productPartsPrintableArticle.ToString();
                    cost.Description += (productPart.ProductPartName ?? "") == "" ? "" : " (" + productPart.ProductPartName + ")";

                    cost.IndexOf = 0;

                    this.Costs.Add(cost);
                }
                #endregion

                #region ProductPartTask

                foreach (var productPartTask in productPart.ProductPartTasks.OrderBy(z => z.IndexOf))
                {
                    cost = new Cost();
                    cost.CodItemGraph = productPartTask.CodItemGraph;

                    cost.DocumentProduct = this;
                    cost.CodDocumentProduct = this.CodDocumentProduct;

                    cost.CodProductPartTask = productPartTask.CodProductPartTask;
                    cost.ProductPartTask = productPartTask;
                    cost.ProductPartTask.ProductPart = productPart;

                    cost.Description = productPartTask.ToString();
                    cost.Description += (productPart.ProductPartName ?? "") == "" ? "" : " (" + productPart.ProductPartName + ")";
                    if (cost.Description != "")
                    {
                        cost.Description = char.ToUpper(cost.Description[0]) + cost.Description.Substring(1);
                    }

                    if (productPartTask.CodOptionTypeOfTask.Contains("_NO"))
                    {
                        cost.Hidden = true;
                        cost.ForceZero = true;
                    }

                    cost.IndexOf = productPartTask.IndexOf;
                    this.Costs.Add(cost);

                    #region impianti
                    cost = new Cost();
                    //cost
                    cost.TypeOfCalcolous = 1;

                    cost.DocumentProduct = this;
                    cost.CodDocumentProduct = this.CodDocumentProduct;

                    cost.CodProductPartImplantTask = productPartTask.CodProductPartTask;
                    cost.ProductPartImplantTask = productPartTask;
                    cost.ProductPartImplantTask.ProductPart = productPart;

                    String str = productPartTask.ToString();
                    str = str != "" ? str.Substring(0, str.IndexOf(" ")) : "";

                    cost.Description = productPartTask.ImplantToString(); // "impianti " + str;
                    cost.Description += (productPart.ProductPartName ?? "") == "" ? "" : " (" + productPart.ProductPartName + ")";
                    cost.Description = cost.Description == "" ? "" : char.ToUpper(cost.Description[0]) + cost.Description.Substring(1);

                    if (productPartTask.CodOptionTypeOfTask.Contains("_NO"))
                    {
                        cost.Hidden = true;
                        cost.ForceZero = true;
                    }

                    //if implant Hidden is not specified then CodOptionTypeOfTask decides
                    cost.Hidden = productPartTask.ImplantHidden == null ? cost.Hidden : productPartTask.ImplantHidden;
                    cost.ForceZero = productPartTask.ImplantHidden == null ? cost.Hidden : productPartTask.ImplantHidden;

                    cost.IndexOf = productPartTask.IndexOf - 1;
                    this.Costs.Add(cost);

                    #endregion
                }
                #endregion
            }



        }
Beispiel #4
0
        //#region Error Handle

        //private static readonly string[] proprietaDaValidare =
        //       {
        //           //Specify validation property
        //               ""
        //       };

        //public string Error
        //{
        //    get
        //    {
        //        return null;
        //    }
        //}

        //public virtual string this[string proprieta]
        //{
        //    get
        //    {
        //        string result = null;
        //        return result;
        //    }
        //}

        ////Check validation of entity
        //public virtual bool IsValid
        //{
        //    get
        //    {
        //        bool ret = true;
        //        foreach (string prop in proprietaDaValidare)
        //        {
        //            if (this[prop] != null)
        //                ret = false;
        //        }
        //        return ret;
        //    }
        //}

        //#endregion

        //#region Handle copy for modify

        //public virtual void Copy(DocumentProduct to)
        //{
        //    //All properties of object
        //    //and pointer of sons
        //    to.CodDocument = this.CodDocument;
        //    to.CodDocumentProduct = this.CodDocumentProduct;
        //    to.CodProduct = this.CodProduct;
        //    to.Costs = this.Costs;
        //    to.Document = this.Document;
        //    to.Product = this.Product;
        //    to.ProductName = this.ProductName;
        //    to.Quantity = this.Quantity;
        //    to.TimeStampTable = this.TimeStampTable;

        //}

        //public object Clone()
        //{
        //    //creo una copia dell'oggetto da utilizzare per le modifiche
        //    var kindOfObject = this.GetType();

        //    //istanzio una copia che sarà gestita dall'invio
        //    DocumentProduct copyOfObject = (DocumentProduct)Activator.CreateInstance(kindOfObject);
        //    //l'oggetto copia sarà una copia del contenuto dell'oggetto originale
        //    this.Copy(copyOfObject);

        //    //CREATE DUPLICATION OF ANY FIRST GENERATION OF CHILD
        //    //Example
        //    //DocumentProduct partCopy = (DocumentProduct)Activator.CreateInstance(copyOfObject.Prodotto.GetType());
        //    ////l'oggetto partCopy sarà una copia del contenuto dell'oggetto originale
        //    //this.Prodotto.Copia(partCopy);

        //    //sulla copia del prodotto in producto assegno la copia del suo prodotto
        //    //Example
        //    //copiaProdottoInProducto.Prodotto = null;
        //    //copiaProdotto.ProdottoInProducto = null;
        //    //copiaProdottoInProducto.Prodotto = copiaProdotto;
        //    //copiaProdotto.ProdottoInProducto.Add(copiaProdottoInProducto);
        //    //END COPY OF CHILD

        //    return copyOfObject;
        //}

        //public void ChildsNull()
        //{
        //    //Set all chied to null 

        //    //Example
        //    //this.Prodotto = null;
        //}

        //#endregion


        public void NewManualCost(string description)
        {
            Cost cost;

            cost = new Cost();
            cost.CodItemGraph = "FF";

            cost.DocumentProduct = this;
            cost.CodDocumentProduct = this.CodDocumentProduct;

            cost.Description = description;
            cost.Manual = true;
            cost.Hidden = false;
            cost.ForceZero = false;

            cost.IndexOf = this.Costs.Max(x => x.IndexOf) + 1;
            this.Costs.Add(cost);

        }