Exemple #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.DistributorPriceMarkup obj = this.SetDAL(this.Context.Context);
             this.Context.Context.DeleteObject(obj);
         }
     }
     else
     {
         IndicoContext objContext = new IndicoContext();
         Indico.DAL.DistributorPriceMarkup obj = this.SetDAL(objContext.Context);
         this.Context.Context.DeleteObject(obj);
         objContext.Context.SaveChanges();
         objContext.Dispose();
     }
 }
Exemple #2
0
        internal void SetBO(System.Data.Objects.DataClasses.EntityObject eObj)
        {
            this._doNotUpdateDALObject = true;

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

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

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

            this.Markup = obj.Markup;

            this.Distributor = (obj.DistributorReference.EntityKey != null && obj.DistributorReference.EntityKey.EntityKeyValues.Count() > 0)
                ? (int)((System.Data.EntityKeyMember)obj.DistributorReference.EntityKey.EntityKeyValues.GetValue(0)).Value
                : 0;
            this.PriceLevel = (obj.PriceLevelReference.EntityKey != null && obj.PriceLevelReference.EntityKey.EntityKeyValues.Count() > 0)
                ? (int)((System.Data.EntityKeyMember)obj.PriceLevelReference.EntityKey.EntityKeyValues.GetValue(0)).Value
                : 0;

            this._doNotUpdateDALObject = false;
        }
Exemple #3
0
        internal Indico.DAL.DistributorPriceMarkup SetDAL(IndicoEntities context)
        {
            this._doNotUpdateDALObject = true;

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

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

            obj.Markup = this.Markup;

            if (this.Distributor != null && this.Distributor > 0)
            {
                obj.Distributor = context.Company.FirstOrDefault(o => o.ID == this.Distributor);
            }
            if (this.PriceLevel > 0)
            {
                obj.PriceLevel = context.PriceLevel.FirstOrDefault(o => o.ID == this.PriceLevel);
            }


            this._doNotUpdateDALObject = false;

            return(obj);
        }
Exemple #4
0
 public void Add()
 {
     if (this.Context != null)
     {
         this.Context.Context.AddToDistributorPriceMarkup(this.ObjDAL);
     }
     else
     {
         IndicoContext objContext = new IndicoContext();
         Indico.DAL.DistributorPriceMarkup obj = this.SetDAL(objContext.Context);
         objContext.Context.AddToDistributorPriceMarkup(obj);
         objContext.SaveChanges();
         objContext.Dispose();
     }
 }
Exemple #5
0
        /// <summary>
        /// Creates an instance of the DistributorPriceMarkupBO class using the supplied Indico.DAL.DistributorPriceMarkup.
        /// </summary>
        /// <param name="obj">a Indico.DAL.DistributorPriceMarkup whose properties will be used to initialise the DistributorPriceMarkupBO</param>
        internal DistributorPriceMarkupBO(Indico.DAL.DistributorPriceMarkup obj, ref IndicoContext context)
        {
            this._doNotUpdateDALObject = true;

            this.Context = context;

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

            this.Distributor = (obj.DistributorReference.EntityKey != null && obj.DistributorReference.EntityKey.EntityKeyValues.Count() > 0)
                ? (int)((System.Data.EntityKeyMember)obj.DistributorReference.EntityKey.EntityKeyValues.GetValue(0)).Value
                : 0;
            this.Markup     = obj.Markup;
            this.PriceLevel = (obj.PriceLevelReference.EntityKey != null && obj.PriceLevelReference.EntityKey.EntityKeyValues.Count() > 0)
                ? (int)((System.Data.EntityKeyMember)obj.PriceLevelReference.EntityKey.EntityKeyValues.GetValue(0)).Value
                : 0;

            this._doNotUpdateDALObject = false;
        }
Exemple #6
0
 void DistributorPriceMarkupsWhereThisIsPriceLevelList_OnBeforeRemove(object sender, EventArgs e)
 {
     Indico.DAL.DistributorPriceMarkup obj = null;
     if (this.Context != null)
     {
         if (((IndicoList <Indico.BusinessObjects.DistributorPriceMarkupBO>)sender).Count > 0)
         {
             obj = ((IndicoList <Indico.BusinessObjects.DistributorPriceMarkupBO>)sender)[((IndicoList <Indico.BusinessObjects.DistributorPriceMarkupBO>)sender).Count - 1].ObjDAL;
             this.ObjDAL.DistributorPriceMarkupsWhereThisIsPriceLevel.Remove(obj);
         }
     }
     else
     {
         IndicoContext objContext = new IndicoContext();
         obj = ((IndicoList <Indico.BusinessObjects.DistributorPriceMarkupBO>)sender)[((IndicoList <Indico.BusinessObjects.DistributorPriceMarkupBO>)sender).Count - 1].SetDAL(objContext.Context);
         this.ObjDAL.DistributorPriceMarkupsWhereThisIsPriceLevel.Remove(obj);
         objContext.SaveChanges();
         objContext.Dispose();
     }
 }