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

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

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

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


            this.Fabric = (obj.FabricReference.EntityKey != null && obj.FabricReference.EntityKey.EntityKeyValues.Count() > 0)
                ? (int)((System.Data.EntityKeyMember)obj.FabricReference.EntityKey.EntityKeyValues.GetValue(0)).Value
                : 0;
            this.FabricCodeType = (obj.FabricCodeTypeReference.EntityKey != null && obj.FabricCodeTypeReference.EntityKey.EntityKeyValues.Count() > 0)
                ? (int)((System.Data.EntityKeyMember)obj.FabricCodeTypeReference.EntityKey.EntityKeyValues.GetValue(0)).Value
                : 0;
            this.VisualLayout = (obj.VisualLayoutReference.EntityKey != null && obj.VisualLayoutReference.EntityKey.EntityKeyValues.Count() > 0)
                ? (int)((System.Data.EntityKeyMember)obj.VisualLayoutReference.EntityKey.EntityKeyValues.GetValue(0)).Value
                : 0;

            this._doNotUpdateDALObject = false;
        }
コード例 #3
0
        internal Indico.DAL.VisualLayoutFabric SetDAL(IndicoEntities context)
        {
            this._doNotUpdateDALObject = true;

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

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


            if (this.Fabric > 0)
            {
                obj.Fabric = context.FabricCode.FirstOrDefault(o => o.ID == this.Fabric);
            }
            if (this.FabricCodeType != null && this.FabricCodeType > 0)
            {
                obj.FabricCodeType = context.FabricCodeType.FirstOrDefault(o => o.ID == this.FabricCodeType);
            }
            if (this.VisualLayout > 0)
            {
                obj.VisualLayout = context.VisualLayout.FirstOrDefault(o => o.ID == this.VisualLayout);
            }


            this._doNotUpdateDALObject = false;

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

            this.Context = context;

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

            this.Fabric = (obj.FabricReference.EntityKey != null && obj.FabricReference.EntityKey.EntityKeyValues.Count() > 0)
                ? (int)((System.Data.EntityKeyMember)obj.FabricReference.EntityKey.EntityKeyValues.GetValue(0)).Value
                : 0;
            this.FabricCodeType = (obj.FabricCodeTypeReference.EntityKey != null && obj.FabricCodeTypeReference.EntityKey.EntityKeyValues.Count() > 0)
                ? (int)((System.Data.EntityKeyMember)obj.FabricCodeTypeReference.EntityKey.EntityKeyValues.GetValue(0)).Value
                : 0;
            this.VisualLayout = (obj.VisualLayoutReference.EntityKey != null && obj.VisualLayoutReference.EntityKey.EntityKeyValues.Count() > 0)
                ? (int)((System.Data.EntityKeyMember)obj.VisualLayoutReference.EntityKey.EntityKeyValues.GetValue(0)).Value
                : 0;

            this._doNotUpdateDALObject = false;
        }