public bool InsertSegmentDetail(SegmentDetail objSegmentDetail)
        {
            try
            {
                db.SegmentDetails.Add(objSegmentDetail);
                db.SaveChanges();

                BPEventLog bpe = new BPEventLog();
                bpe.Object           = "Segment";
                bpe.ObjectName       = objSegmentDetail.DetailCode;
                bpe.ObjectChanges    = string.Empty;
                bpe.EventMassage     = "Success";
                bpe.Status           = "A";
                bpe.CreatedBy        = objSegmentDetail.CreatedBy;
                bpe.CreatedTimeStamp = objSegmentDetail.CreatedTimeStamp;
                new EventLogDAL().AddEventLog(bpe);

                return(true);
            }
            catch (Exception ex)
            {
                BPEventLog bpe = new BPEventLog();
                bpe.Object           = "SegmentDetail";
                bpe.ObjectName       = objSegmentDetail.DetailCode;
                bpe.ObjectChanges    = string.Empty;
                bpe.EventMassage     = "Failure";
                bpe.Status           = "A";
                bpe.CreatedBy        = objSegmentDetail.CreatedBy;
                bpe.CreatedTimeStamp = objSegmentDetail.CreatedTimeStamp;
                new EventLogDAL().AddEventLog(bpe);

                throw ex;
            }
        }
        public bool UpdateSegmentDetail(SegmentDetail objSegmentDetail)
        {
            SegmentDetail obj     = db.SegmentDetails.Where(x => x.SegmentDetailID == objSegmentDetail.SegmentDetailID).FirstOrDefault();
            string        changes = new EventLogDAL().ObjectDifference(obj, objSegmentDetail);

            try
            {
                if (obj != null)
                {
                    obj.SegmentID         = objSegmentDetail.SegmentID;
                    obj.DetailCode        = objSegmentDetail.DetailCode;
                    obj.DetailDesc        = objSegmentDetail.DetailDesc;
                    obj.ParentDetailID    = objSegmentDetail.ParentDetailID;
                    obj.Status            = objSegmentDetail.Status;
                    obj.ModifiedBy        = objSegmentDetail.ModifiedBy;
                    obj.ModifiedTimeStamp = objSegmentDetail.ModifiedTimeStamp;
                    db.SaveChanges();

                    BPEventLog bpe = new BPEventLog();
                    bpe.Object           = "Segment";
                    bpe.ObjectName       = objSegmentDetail.DetailCode;
                    bpe.ObjectChanges    = changes;
                    bpe.EventMassage     = "Success";
                    bpe.Status           = "A";
                    bpe.CreatedBy        = objSegmentDetail.ModifiedBy;
                    bpe.CreatedTimeStamp = objSegmentDetail.ModifiedTimeStamp;
                    new EventLogDAL().AddEventLog(bpe);
                }
                return(true);
            }
            catch (Exception ex)
            {
                BPEventLog bpe = new BPEventLog();
                bpe.Object           = "Segment";
                bpe.ObjectName       = objSegmentDetail.DetailCode;
                bpe.ObjectChanges    = changes;
                bpe.EventMassage     = "Success";
                bpe.Status           = "A";
                bpe.CreatedBy        = objSegmentDetail.ModifiedBy;
                bpe.CreatedTimeStamp = objSegmentDetail.ModifiedTimeStamp;
                new EventLogDAL().AddEventLog(bpe);

                throw ex;
            }
        }