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

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

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

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

            this.Efficiency      = obj.Efficiency;
            this.FivePcsCapacity = obj.FivePcsCapacity;
            this.SampleCapacity  = obj.SampleCapacity;
            this.TotalCapacity   = obj.TotalCapacity;
            this.Workers         = obj.Workers;

            this.ItemType = (obj.ItemTypeReference.EntityKey != null && obj.ItemTypeReference.EntityKey.EntityKeyValues.Count() > 0)
                ? (int)((System.Data.EntityKeyMember)obj.ItemTypeReference.EntityKey.EntityKeyValues.GetValue(0)).Value
                : 0;
            this.WeeklyProductionCapacity = (obj.WeeklyProductionCapacityReference.EntityKey != null && obj.WeeklyProductionCapacityReference.EntityKey.EntityKeyValues.Count() > 0)
                ? (int)((System.Data.EntityKeyMember)obj.WeeklyProductionCapacityReference.EntityKey.EntityKeyValues.GetValue(0)).Value
                : 0;

            this._doNotUpdateDALObject = false;
        }
        internal Indico.DAL.WeeklyProductionCapacityDetails SetDAL(IndicoEntities context)
        {
            this._doNotUpdateDALObject = true;

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

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

            obj.Efficiency      = this.Efficiency;
            obj.FivePcsCapacity = this.FivePcsCapacity;
            obj.SampleCapacity  = this.SampleCapacity;
            obj.TotalCapacity   = this.TotalCapacity;
            obj.Workers         = this.Workers;

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


            this._doNotUpdateDALObject = false;

            return(obj);
        }
 public void Add()
 {
     if (this.Context != null)
     {
         this.Context.Context.AddToWeeklyProductionCapacityDetails(this.ObjDAL);
     }
     else
     {
         IndicoContext objContext = new IndicoContext();
         Indico.DAL.WeeklyProductionCapacityDetails obj = this.SetDAL(objContext.Context);
         objContext.Context.AddToWeeklyProductionCapacityDetails(obj);
         objContext.SaveChanges();
         objContext.Dispose();
     }
 }
Ejemplo n.º 5
0
 void WeeklyProductionCapacityDetailssWhereThisIsItemTypeList_OnBeforeRemove(object sender, EventArgs e)
 {
     Indico.DAL.WeeklyProductionCapacityDetails obj = null;
     if (this.Context != null)
     {
         if (((IndicoList <Indico.BusinessObjects.WeeklyProductionCapacityDetailsBO>)sender).Count > 0)
         {
             obj = ((IndicoList <Indico.BusinessObjects.WeeklyProductionCapacityDetailsBO>)sender)[((IndicoList <Indico.BusinessObjects.WeeklyProductionCapacityDetailsBO>)sender).Count - 1].ObjDAL;
             this.ObjDAL.WeeklyProductionCapacityDetailssWhereThisIsItemType.Remove(obj);
         }
     }
     else
     {
         IndicoContext objContext = new IndicoContext();
         obj = ((IndicoList <Indico.BusinessObjects.WeeklyProductionCapacityDetailsBO>)sender)[((IndicoList <Indico.BusinessObjects.WeeklyProductionCapacityDetailsBO>)sender).Count - 1].SetDAL(objContext.Context);
         this.ObjDAL.WeeklyProductionCapacityDetailssWhereThisIsItemType.Remove(obj);
         objContext.SaveChanges();
         objContext.Dispose();
     }
 }
        /// <summary>
        /// Creates an instance of the WeeklyProductionCapacityDetailsBO class using the supplied Indico.DAL.WeeklyProductionCapacityDetails.
        /// </summary>
        /// <param name="obj">a Indico.DAL.WeeklyProductionCapacityDetails whose properties will be used to initialise the WeeklyProductionCapacityDetailsBO</param>
        internal WeeklyProductionCapacityDetailsBO(Indico.DAL.WeeklyProductionCapacityDetails obj, ref IndicoContext context)
        {
            this._doNotUpdateDALObject = true;

            this.Context = context;

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

            this.Efficiency      = obj.Efficiency;
            this.FivePcsCapacity = obj.FivePcsCapacity;
            this.ItemType        = (obj.ItemTypeReference.EntityKey != null && obj.ItemTypeReference.EntityKey.EntityKeyValues.Count() > 0)
                ? (int)((System.Data.EntityKeyMember)obj.ItemTypeReference.EntityKey.EntityKeyValues.GetValue(0)).Value
                : 0;
            this.SampleCapacity           = obj.SampleCapacity;
            this.TotalCapacity            = obj.TotalCapacity;
            this.WeeklyProductionCapacity = (obj.WeeklyProductionCapacityReference.EntityKey != null && obj.WeeklyProductionCapacityReference.EntityKey.EntityKeyValues.Count() > 0)
                ? (int)((System.Data.EntityKeyMember)obj.WeeklyProductionCapacityReference.EntityKey.EntityKeyValues.GetValue(0)).Value
                : 0;
            this.Workers = obj.Workers;

            this._doNotUpdateDALObject = false;
        }