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

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

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

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

            this.SewingDate = obj.SewingDate;

            this.OrderDetail = (obj.OrderDetailReference.EntityKey != null && obj.OrderDetailReference.EntityKey.EntityKeyValues.Count() > 0)
                ? (int)((System.Data.EntityKeyMember)obj.OrderDetailReference.EntityKey.EntityKeyValues.GetValue(0)).Value
                : 0;
            this.ProductionLine = (obj.ProductionLineReference.EntityKey != null && obj.ProductionLineReference.EntityKey.EntityKeyValues.Count() > 0)
                ? (int)((System.Data.EntityKeyMember)obj.ProductionLineReference.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;
        }
Exemplo n.º 3
0
        internal Indico.DAL.ProductionPlanning SetDAL(IndicoEntities context)
        {
            this._doNotUpdateDALObject = true;

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

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

            obj.SewingDate = this.SewingDate;

            if (this.OrderDetail > 0)
            {
                obj.OrderDetail = context.OrderDetail.FirstOrDefault(o => o.ID == this.OrderDetail);
            }
            if (this.ProductionLine != null && this.ProductionLine > 0)
            {
                obj.ProductionLine = context.ProductionLine.FirstOrDefault(o => o.ID == this.ProductionLine);
            }
            if (this.WeeklyProductionCapacity > 0)
            {
                obj.WeeklyProductionCapacity = context.WeeklyProductionCapacity.FirstOrDefault(o => o.ID == this.WeeklyProductionCapacity);
            }


            this._doNotUpdateDALObject = false;

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

            this.Context = context;

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

            this.OrderDetail = (obj.OrderDetailReference.EntityKey != null && obj.OrderDetailReference.EntityKey.EntityKeyValues.Count() > 0)
                ? (int)((System.Data.EntityKeyMember)obj.OrderDetailReference.EntityKey.EntityKeyValues.GetValue(0)).Value
                : 0;
            this.ProductionLine = (obj.ProductionLineReference.EntityKey != null && obj.ProductionLineReference.EntityKey.EntityKeyValues.Count() > 0)
                ? (int)((System.Data.EntityKeyMember)obj.ProductionLineReference.EntityKey.EntityKeyValues.GetValue(0)).Value
                : 0;
            this.SewingDate = obj.SewingDate;
            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;
        }