Пример #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.CostSheetRemarks obj = this.SetDAL(this.Context.Context);
             this.Context.Context.DeleteObject(obj);
         }
     }
     else
     {
         IndicoContext objContext        = new IndicoContext();
         Indico.DAL.CostSheetRemarks obj = this.SetDAL(objContext.Context);
         this.Context.Context.DeleteObject(obj);
         objContext.Context.SaveChanges();
         objContext.Dispose();
     }
 }
Пример #2
0
        internal Indico.DAL.CostSheetRemarks SetDAL(IndicoEntities context)
        {
            this._doNotUpdateDALObject = true;

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

            if (this.ID > 0)
            {
                obj = context.CostSheetRemarks.FirstOrDefault <CostSheetRemarks>(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);
        }
Пример #3
0
        internal void SetBO(System.Data.Objects.DataClasses.EntityObject eObj)
        {
            this._doNotUpdateDALObject = true;

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

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

            // set the Indico.BusinessObjects.CostSheetRemarksBO 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;
        }
Пример #4
0
 public void Add()
 {
     if (this.Context != null)
     {
         this.Context.Context.AddToCostSheetRemarks(this.ObjDAL);
     }
     else
     {
         IndicoContext objContext        = new IndicoContext();
         Indico.DAL.CostSheetRemarks obj = this.SetDAL(objContext.Context);
         objContext.Context.AddToCostSheetRemarks(obj);
         objContext.SaveChanges();
         objContext.Dispose();
     }
 }
Пример #5
0
        /// <summary>
        /// Creates an instance of the CostSheetRemarksBO class using the supplied Indico.DAL.CostSheetRemarks.
        /// </summary>
        /// <param name="obj">a Indico.DAL.CostSheetRemarks whose properties will be used to initialise the CostSheetRemarksBO</param>
        internal CostSheetRemarksBO(Indico.DAL.CostSheetRemarks obj, ref IndicoContext context)
        {
            this._doNotUpdateDALObject = true;

            this.Context = context;

            // set the properties from the Indico.DAL.CostSheetRemarks
            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;
        }