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.IndimanCostSheetRemarks obj = this.SetDAL(this.Context.Context);
             this.Context.Context.DeleteObject(obj);
         }
     }
     else
     {
         IndicoContext objContext = new IndicoContext();
         Indico.DAL.IndimanCostSheetRemarks obj = this.SetDAL(objContext.Context);
         this.Context.Context.DeleteObject(obj);
         objContext.Context.SaveChanges();
         objContext.Dispose();
     }
 }
        internal Indico.DAL.IndimanCostSheetRemarks SetDAL(IndicoEntities context)
        {
            this._doNotUpdateDALObject = true;

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

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

            obj.ModifiedDate = this.ModifiedDate;
            obj.Remarks      = this.Remarks;

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


            this._doNotUpdateDALObject = false;

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

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

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

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

            this.ModifiedDate = obj.ModifiedDate;
            this.Remarks      = obj.Remarks;

            this.CostSheet = (obj.CostSheetReference.EntityKey != null && obj.CostSheetReference.EntityKey.EntityKeyValues.Count() > 0)
                ? (int)((System.Data.EntityKeyMember)obj.CostSheetReference.EntityKey.EntityKeyValues.GetValue(0)).Value
                : 0;
            this.Modifier = (obj.ModifierReference.EntityKey != null && obj.ModifierReference.EntityKey.EntityKeyValues.Count() > 0)
                ? (int)((System.Data.EntityKeyMember)obj.ModifierReference.EntityKey.EntityKeyValues.GetValue(0)).Value
                : 0;

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

            this.Context = context;

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

            this.CostSheet = (obj.CostSheetReference.EntityKey != null && obj.CostSheetReference.EntityKey.EntityKeyValues.Count() > 0)
                ? (int)((System.Data.EntityKeyMember)obj.CostSheetReference.EntityKey.EntityKeyValues.GetValue(0)).Value
                : 0;
            this.ModifiedDate = obj.ModifiedDate;
            this.Modifier     = (obj.ModifierReference.EntityKey != null && obj.ModifierReference.EntityKey.EntityKeyValues.Count() > 0)
                ? (int)((System.Data.EntityKeyMember)obj.ModifierReference.EntityKey.EntityKeyValues.GetValue(0)).Value
                : 0;
            this.Remarks = obj.Remarks;

            this._doNotUpdateDALObject = false;
        }