Ejemplo n.º 1
0
 public void Delete()
 {
     if (this.Context != null)
     {
         if (this.ObjDAL != null && this.ObjDAL.EntityKey != null)
         {
             if (this.ObjDAL.EntityState == System.Data.EntityState.Detached)
             {
                 this.Context.Context.Attach(this.ObjDAL);
                 this.Context.Context.DeleteObject(this.ObjDAL);
             }
             else
             {
                 this.Context.Context.DeleteObject(this.ObjDAL);
             }
         }
         else
         {
             Indico.DAL.PriceHistroy obj = this.SetDAL(this.Context.Context);
             this.Context.Context.DeleteObject(obj);
         }
     }
     else
     {
         IndicoContext           objContext = new IndicoContext();
         Indico.DAL.PriceHistroy obj        = this.SetDAL(objContext.Context);
         this.Context.Context.DeleteObject(obj);
         objContext.Context.SaveChanges();
         objContext.Dispose();
     }
 }
Ejemplo n.º 2
0
        internal Indico.DAL.PriceHistroy SetDAL(IndicoEntities context)
        {
            this._doNotUpdateDALObject = true;

            // set the Indico.DAL.PriceHistroy properties
            Indico.DAL.PriceHistroy obj = new Indico.DAL.PriceHistroy();

            if (this.ID > 0)
            {
                obj = context.PriceHistroy.FirstOrDefault <PriceHistroy>(o => o.ID == this.ID);
            }

            obj.ConvertionFactor = this.ConvertionFactor;
            obj.CreatedDate      = this.CreatedDate;
            obj.Creator          = this.Creator;
            obj.FabricCode       = this.FabricCode;
            obj.FactoryCost      = this.FactoryCost;
            obj.IndimanCost      = this.IndimanCost;
            obj.Pattern          = this.Pattern;
            obj.PriceLevel       = this.PriceLevel;
            obj.PriceLevelCost   = this.PriceLevelCost;
            obj.Remarks          = this.Remarks;

            if (this.Price > 0)
            {
                obj.Price = context.Price.FirstOrDefault(o => o.ID == this.Price);
            }


            this._doNotUpdateDALObject = false;

            return(obj);
        }
Ejemplo n.º 3
0
        internal void SetBO(System.Data.Objects.DataClasses.EntityObject eObj)
        {
            this._doNotUpdateDALObject = true;

            // Check the received type
            if (eObj.GetType() != typeof(Indico.DAL.PriceHistroy))
            {
                throw new FormatException("Received wrong parameter type...");
            }

            Indico.DAL.PriceHistroy obj = (Indico.DAL.PriceHistroy)eObj;

            // set the Indico.BusinessObjects.PriceHistroyBO properties
            this.ID = obj.ID;

            this.ConvertionFactor = obj.ConvertionFactor;
            this.CreatedDate      = obj.CreatedDate;
            this.Creator          = obj.Creator;
            this.FabricCode       = obj.FabricCode;
            this.FactoryCost      = obj.FactoryCost;
            this.IndimanCost      = obj.IndimanCost;
            this.Pattern          = obj.Pattern;
            this.PriceLevel       = obj.PriceLevel;
            this.PriceLevelCost   = obj.PriceLevelCost;
            this.Remarks          = obj.Remarks;

            this.Price = (obj.PriceReference.EntityKey != null && obj.PriceReference.EntityKey.EntityKeyValues.Count() > 0)
                ? (int)((System.Data.EntityKeyMember)obj.PriceReference.EntityKey.EntityKeyValues.GetValue(0)).Value
                : 0;

            this._doNotUpdateDALObject = false;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates an instance of the PriceHistroyBO class using the supplied Indico.DAL.PriceHistroy.
        /// </summary>
        /// <param name="obj">a Indico.DAL.PriceHistroy whose properties will be used to initialise the PriceHistroyBO</param>
        internal PriceHistroyBO(Indico.DAL.PriceHistroy obj, ref IndicoContext context)
        {
            this._doNotUpdateDALObject = true;

            this.Context = context;

            // set the properties from the Indico.DAL.PriceHistroy
            this.ID = obj.ID;

            this.ConvertionFactor = obj.ConvertionFactor;
            this.CreatedDate      = obj.CreatedDate;
            this.Creator          = obj.Creator;
            this.FabricCode       = obj.FabricCode;
            this.FactoryCost      = obj.FactoryCost;
            this.IndimanCost      = obj.IndimanCost;
            this.Pattern          = obj.Pattern;
            this.Price            = (obj.PriceReference.EntityKey != null && obj.PriceReference.EntityKey.EntityKeyValues.Count() > 0)
                ? (int)((System.Data.EntityKeyMember)obj.PriceReference.EntityKey.EntityKeyValues.GetValue(0)).Value
                : 0;
            this.PriceLevel     = obj.PriceLevel;
            this.PriceLevelCost = obj.PriceLevelCost;
            this.Remarks        = obj.Remarks;

            this._doNotUpdateDALObject = false;
        }
Ejemplo n.º 5
0
 public void Add()
 {
     if (this.Context != null)
     {
         this.Context.Context.AddToPriceHistroy(this.ObjDAL);
     }
     else
     {
         IndicoContext           objContext = new IndicoContext();
         Indico.DAL.PriceHistroy obj        = this.SetDAL(objContext.Context);
         objContext.Context.AddToPriceHistroy(obj);
         objContext.SaveChanges();
         objContext.Dispose();
     }
 }