Exemple #1
0
        public bool UpdateSegment(Segment objSegment)
        {
            if (objSegment.AccountCodeFlag == true)
            {
                if (db.Segments.Where(x => x.AccountCodeFlag == true).Count() > 0)
                {
                    throw new Exception("Account Code Flag Already Been Triggered By Other Segment. Please Try Again.");
                }
            }

            Segment obj     = db.Segments.Where(x => x.SegmentID == objSegment.SegmentID).FirstOrDefault();
            string  changes = new EventLogDAL().ObjectDifference(obj, objSegment);

            try
            {
                if (obj != null)
                {
                    obj.SegmentName       = objSegment.SegmentName;
                    obj.ShapeFormat       = objSegment.ShapeFormat;
                    obj.SegmentOrder      = objSegment.SegmentOrder;
                    obj.Status            = objSegment.Status;
                    obj.ModifiedBy        = objSegment.ModifiedBy;
                    obj.ModifiedTimeStamp = objSegment.ModifiedTimeStamp;
                    obj.AccountCodeFlag   = objSegment.AccountCodeFlag;
                    db.SaveChanges();

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

                throw ex;
            }
        }
Exemple #2
0
        public bool UpdateAccountCode(PeruntukanDipinda objAccountCode)
        {
            PeruntukanDipinda obj     = db.PeruntukanDipindas.Where(x => x.BudgetAccount == objAccountCode.BudgetAccount).FirstOrDefault();
            string            changes = new EventLogDAL().ObjectDifference(obj, objAccountCode);

            try
            {
                if (obj != null && changes != string.Empty)
                {
                    //obj.AccountCode1 = objAccountCode.AccountCode1;
                    obj.BudgetAccount   = objAccountCode.BudgetAccount;
                    obj.Description     = objAccountCode.Description;
                    obj.BudgetAccKey    = objAccountCode.BudgetAccKey;
                    obj.BudgetLedgerKey = objAccountCode.BudgetLedgerKey;
                    obj.BudgetType      = objAccountCode.BudgetType;
                    obj.BudgetYear      = objAccountCode.BudgetYear;
                    obj.BudgetAmount    = objAccountCode.BudgetAmount;
                    obj.Type            = objAccountCode.Type;
                    db.SaveChanges();

                    BPEventLog bpe = new BPEventLog();
                    bpe.Object        = "PeruntukanDipinda";
                    bpe.ObjectName    = objAccountCode.BudgetAccount;
                    bpe.ObjectChanges = string.Empty;
                    bpe.EventMassage  = "Success";
                    bpe.Status        = "A";
                    //bpe.CreatedBy = objAccountCode.CreatedBy;
                    //bpe.CreatedTimeStamp = objAccountCode.CreatedTimeStamp;
                    new EventLogDAL().AddEventLog(bpe);
                }
                return(true);
            }
            catch (Exception ex)
            {
                BPEventLog bpe = new BPEventLog();
                bpe.Object        = "PeruntukanDipinda";
                bpe.ObjectName    = objAccountCode.BudgetAccount;
                bpe.ObjectChanges = string.Empty;
                bpe.EventMassage  = "Failure";
                bpe.Status        = "A";
                //bpe.CreatedBy = objAccountCode.CreatedBy;
                //bpe.CreatedTimeStamp = objAccountCode.CreatedTimeStamp;
                new EventLogDAL().AddEventLog(bpe);

                throw ex;
            }
        }
Exemple #3
0
        public bool UpdateAccountCode(AccountCode objAccountCode)
        {
            AccountCode obj     = db.AccountCodes.Where(x => x.AccountCode1 == objAccountCode.AccountCode1).FirstOrDefault();
            string      changes = new EventLogDAL().ObjectDifference(obj, objAccountCode);

            try
            {
                if (obj != null && changes != string.Empty)
                {
                    //obj.AccountCode1 = objAccountCode.AccountCode1;
                    obj.AccountDesc       = objAccountCode.AccountDesc;
                    obj.ParentAccountCode = objAccountCode.ParentAccountCode;
                    obj.Keterangan        = objAccountCode.Keterangan;
                    obj.Pengiraan         = objAccountCode.Pengiraan;
                    obj.Status            = objAccountCode.Status;
                    obj.ModifiedBy        = objAccountCode.ModifiedBy;
                    obj.ModifiedTimeStamp = objAccountCode.ModifiedTimeStamp;
                    db.SaveChanges();

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

                throw ex;
            }
        }
        public bool UpdateFieldPerjawatan(FieldPerjawatan objFieldPerjawatan)
        {
            FieldPerjawatan obj     = db.FieldPerjawatans.Where(x => x.FieldPerjawatanID == objFieldPerjawatan.FieldPerjawatanID).FirstOrDefault();
            string          changes = new EventLogDAL().ObjectDifference(obj, objFieldPerjawatan);

            try
            {
                if (obj != null)
                {
                    obj.FieldPerjawatanID = objFieldPerjawatan.FieldPerjawatanID;
                    //obj.FieldPerjawatanSDesc = objFieldPerjawatan.FieldPerjawatanSDesc;
                    obj.FieldPerjawatanSDesc = string.Empty;
                    obj.FieldPerjawatanDesc  = objFieldPerjawatan.FieldPerjawatanDesc;
                    obj.Status            = objFieldPerjawatan.Status;
                    obj.ModifiedBy        = objFieldPerjawatan.ModifiedBy;
                    obj.ModifiedTimeStamp = objFieldPerjawatan.ModifiedTimeStamp;
                    db.SaveChanges();

                    BPEventLog bpe = new BPEventLog();
                    bpe.Object           = "FieldPerjawatan";
                    bpe.ObjectName       = objFieldPerjawatan.FieldPerjawatanDesc;
                    bpe.ObjectChanges    = changes;
                    bpe.EventMassage     = "Success";
                    bpe.Status           = "A";
                    bpe.CreatedBy        = objFieldPerjawatan.ModifiedBy;
                    bpe.CreatedTimeStamp = objFieldPerjawatan.ModifiedTimeStamp;
                    new EventLogDAL().AddEventLog(bpe);
                }
                return(true);
            }
            catch (Exception ex)
            {
                BPEventLog bpe = new BPEventLog();
                bpe.Object           = "FieldPerjawatan";
                bpe.ObjectName       = objFieldPerjawatan.FieldPerjawatanDesc;
                bpe.ObjectChanges    = changes;
                bpe.EventMassage     = "Failure";
                bpe.Status           = "A";
                bpe.CreatedBy        = objFieldPerjawatan.ModifiedBy;
                bpe.CreatedTimeStamp = objFieldPerjawatan.ModifiedTimeStamp;
                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;
            }
        }
Exemple #6
0
        public bool UpdateAccountCode(PerbelanjaanSebenar objAccountCode)
        {
            PerbelanjaanSebenar obj = db.PerbelanjaanSebenars.Where(x => x.BudgetAccount == objAccountCode.BudgetAccount).FirstOrDefault();
            string changes          = new EventLogDAL().ObjectDifference(obj, objAccountCode);

            try
            {
                if (obj != null && changes != string.Empty)
                {
                    //obj.AccountCode1 = objAccountCode.AccountCode1;
                    List <AccountCode> data = new AccountCodeDAL().GetAccountCodes().ToList();
                    obj.ParentAccountCode = data.Where(x => x.AccountCode1 == objAccountCode.BudgetAccount.Substring(17, 6)).Select(y => y.ParentAccountCode).FirstOrDefault();
                    obj.BudgetAccount     = objAccountCode.BudgetAccount;
                    obj.Description       = objAccountCode.Description;
                    obj.BudgetAmount      = objAccountCode.BudgetAmount;
                    obj.BudgetYear        = objAccountCode.BudgetYear;
                    db.SaveChanges();

                    BPEventLog bpe = new BPEventLog();
                    bpe.Object        = "PerbelanjaanSebenar";
                    bpe.ObjectName    = objAccountCode.BudgetAccount;
                    bpe.ObjectChanges = string.Empty;
                    bpe.EventMassage  = "Success";
                    bpe.Status        = "A";
                    //bpe.CreatedBy = objAccountCode.CreatedBy;
                    //bpe.CreatedTimeStamp = objAccountCode.CreatedTimeStamp;
                    new EventLogDAL().AddEventLog(bpe);
                }
                return(true);
            }
            catch (Exception ex)
            {
                BPEventLog bpe = new BPEventLog();
                bpe.Object        = "PerbelanjaanSebenar";
                bpe.ObjectName    = objAccountCode.BudgetAccount;
                bpe.ObjectChanges = string.Empty;
                bpe.EventMassage  = "Failure";
                bpe.Status        = "A";
                //bpe.CreatedBy = objAccountCode.CreatedBy;
                //bpe.CreatedTimeStamp = objAccountCode.CreatedTimeStamp;
                new EventLogDAL().AddEventLog(bpe);

                throw ex;
            }
        }
Exemple #7
0
        public bool UpdateGroupPerjawatan(GroupPerjawatan objGroupPerjawatan)
        {
            GroupPerjawatan obj     = db.GroupPerjawatans.Where(x => x.GroupPerjawatanCode == objGroupPerjawatan.GroupPerjawatanCode).FirstOrDefault();
            string          changes = new EventLogDAL().ObjectDifference(obj, objGroupPerjawatan);

            try
            {
                if (obj != null)
                {
                    //obj.GroupPerjawatanCode = objGroupPerjawatan.GroupPerjawatanCode;
                    obj.GroupPerjawatanDesc     = objGroupPerjawatan.GroupPerjawatanDesc;
                    obj.ParentGroupPerjawatanID = objGroupPerjawatan.ParentGroupPerjawatanID;
                    obj.Status            = objGroupPerjawatan.Status;
                    obj.ModifiedBy        = objGroupPerjawatan.ModifiedBy;
                    obj.ModifiedTimeStamp = objGroupPerjawatan.ModifiedTimeStamp;
                    db.SaveChanges();

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

                throw ex;
            }
        }
Exemple #8
0
        public bool UpdateYearUpload(YearUploadSetup objYearUpload)
        {
            YearUploadSetup obj     = db.YearUploadSetups.Where(x => x.BudgetYear == objYearUpload.BudgetYear).FirstOrDefault();
            string          changes = new EventLogDAL().ObjectDifference(obj, objYearUpload);

            try
            {
                if (obj != null)
                {
                    obj.BudgetYear        = objYearUpload.BudgetYear;
                    obj.BudgetYearDesc    = objYearUpload.BudgetYearDesc;
                    obj.Status            = objYearUpload.Status;
                    obj.ModifiedBy        = objYearUpload.ModifiedBy;
                    obj.ModifiedTimeStamp = objYearUpload.ModifiedTimeStamp;
                    db.SaveChanges();

                    BPEventLog bpe = new BPEventLog();
                    bpe.Object           = "Year Upload Setup";
                    bpe.ObjectName       = objYearUpload.BudgetYear + " - " + objYearUpload.BudgetYearDesc;;
                    bpe.ObjectChanges    = changes;
                    bpe.EventMassage     = "Success";
                    bpe.Status           = "A";
                    bpe.CreatedBy        = objYearUpload.ModifiedBy;
                    bpe.CreatedTimeStamp = objYearUpload.ModifiedTimeStamp;
                    new EventLogDAL().AddEventLog(bpe);
                }
                return(true);
            }
            catch (Exception ex)
            {
                BPEventLog bpe = new BPEventLog();
                bpe.Object           = "Year Upload Setup";
                bpe.ObjectName       = objYearUpload.BudgetYear + " - " + objYearUpload.BudgetYearDesc;
                bpe.ObjectChanges    = changes;
                bpe.EventMassage     = "Failure";
                bpe.Status           = "A";
                bpe.CreatedBy        = objYearUpload.ModifiedBy;
                bpe.CreatedTimeStamp = objYearUpload.ModifiedTimeStamp;
                new EventLogDAL().AddEventLog(bpe);

                throw ex;
            }
        }
        public bool UpdatePeriodMenguru(PeriodMenguru objPeriodMenguru)
        {
            PeriodMenguru obj     = db.PeriodMengurus.Where(x => x.PeriodMengurusID == objPeriodMenguru.PeriodMengurusID).FirstOrDefault();
            string        changes = new EventLogDAL().ObjectDifference(obj, objPeriodMenguru);

            try
            {
                if (obj != null)
                {
                    obj.FieldMengurusID   = objPeriodMenguru.FieldMengurusID;
                    obj.MengurusYear      = objPeriodMenguru.MengurusYear;
                    obj.Status            = objPeriodMenguru.Status;
                    obj.ModifiedBy        = objPeriodMenguru.ModifiedBy;
                    obj.ModifiedTimeStamp = objPeriodMenguru.ModifiedTimeStamp;
                    db.SaveChanges();

                    BPEventLog bpe = new BPEventLog();
                    bpe.Object           = "Period Mengurus";
                    bpe.ObjectName       = obj.FieldMenguru.FieldMengurusDesc + " - " + objPeriodMenguru.MengurusYear;
                    bpe.ObjectChanges    = changes;
                    bpe.EventMassage     = "Success";
                    bpe.Status           = "A";
                    bpe.CreatedBy        = objPeriodMenguru.ModifiedBy;
                    bpe.CreatedTimeStamp = objPeriodMenguru.ModifiedTimeStamp;
                    new EventLogDAL().AddEventLog(bpe);
                }
                return(true);
            }
            catch (Exception ex)
            {
                BPEventLog bpe = new BPEventLog();
                bpe.Object           = "Period Mengurus";
                bpe.ObjectName       = obj.FieldMenguru.FieldMengurusDesc + " - " + objPeriodMenguru.MengurusYear;
                bpe.ObjectChanges    = changes;
                bpe.EventMassage     = "Failure";
                bpe.Status           = "A";
                bpe.CreatedBy        = objPeriodMenguru.ModifiedBy;
                bpe.CreatedTimeStamp = objPeriodMenguru.ModifiedTimeStamp;
                new EventLogDAL().AddEventLog(bpe);

                throw ex;
            }
        }
Exemple #10
0
        public bool UpdateBudgetMenguru(BudgetMenguru objBudgetMenguru, List <int> LstSegmentDetailIDs)
        {
            BudgetMenguru obj = GetBudgetMengurus(LstSegmentDetailIDs)
                                .Where(x => x.PeriodMengurusID == objBudgetMenguru.PeriodMengurusID && x.AccountCode == objBudgetMenguru.AccountCode).FirstOrDefault();
            string changes = new EventLogDAL().ObjectDifference(obj, objBudgetMenguru);

            try
            {
                obj.Amount            = objBudgetMenguru.Amount;
                obj.Status            = objBudgetMenguru.Status;
                obj.Remarks           = objBudgetMenguru.Remarks;
                obj.ModifiedBy        = objBudgetMenguru.ModifiedBy;
                obj.ModifiedTimeStamp = objBudgetMenguru.ModifiedTimeStamp;
                db.SaveChanges();

                BPEventLog bpe = new BPEventLog();
                bpe.Object           = "Budget Mengurus-" + obj.PeriodMenguru.MengurusYear + "-" + obj.PeriodMenguru.FieldMenguru.FieldMengurusDesc;
                bpe.ObjectName       = GetAccountCodePrefix(LstSegmentDetailIDs) + "-" + objBudgetMenguru.AccountCode;
                bpe.ObjectChanges    = changes;
                bpe.EventMassage     = "Success";
                bpe.Status           = "I";
                bpe.CreatedBy        = objBudgetMenguru.ModifiedBy;
                bpe.CreatedTimeStamp = objBudgetMenguru.ModifiedTimeStamp;
                new EventLogDAL().AddEventLog(bpe);

                return(true);
            }
            catch (Exception ex)
            {
                BPEventLog bpe = new BPEventLog();
                bpe.Object           = "Budget Mengurus-" + obj.PeriodMenguru.MengurusYear + "-" + obj.PeriodMenguru.FieldMenguru.FieldMengurusDesc;
                bpe.ObjectName       = GetAccountCodePrefix(LstSegmentDetailIDs) + "-" + objBudgetMenguru.AccountCode;
                bpe.ObjectChanges    = changes;
                bpe.EventMassage     = "Failure";
                bpe.Status           = "I";
                bpe.CreatedBy        = objBudgetMenguru.ModifiedBy;
                bpe.CreatedTimeStamp = objBudgetMenguru.ModifiedTimeStamp;
                new EventLogDAL().AddEventLog(bpe);

                throw ex;
            }
        }
Exemple #11
0
        public bool UpdateMasterRole(MasterRole objMasterRole)
        {
            MasterRole obj     = db.MasterRoles.Where(x => x.RoleID == objMasterRole.RoleID).FirstOrDefault();
            string     changes = new EventLogDAL().ObjectDifference(obj, objMasterRole);

            try
            {
                if (obj != null)
                {
                    obj.RoleName    = objMasterRole.RoleName;
                    obj.Description = objMasterRole.Description;
                    obj.RoleStatus  = objMasterRole.RoleStatus;
                    db.SaveChanges();

                    BPEventLog bpe = new BPEventLog();
                    bpe.Object           = "Roles";
                    bpe.ObjectName       = objMasterRole.RoleName;
                    bpe.ObjectChanges    = changes;
                    bpe.EventMassage     = "Success";
                    bpe.Status           = "A";
                    bpe.CreatedTimeStamp = DateTime.Now;
                    new EventLogDAL().AddEventLog(bpe);
                }
                return(true);
            }
            catch (Exception ex)
            {
                BPEventLog bpe = new BPEventLog();
                bpe.Object           = "Roles";
                bpe.ObjectName       = objMasterRole.RoleName;
                bpe.ObjectChanges    = changes;
                bpe.EventMassage     = "Failure";
                bpe.Status           = "A";
                bpe.CreatedTimeStamp = DateTime.Now;
                new EventLogDAL().AddEventLog(bpe);

                throw ex;
            }
        }
Exemple #12
0
        public bool UpdateProfileUser(MasterUser objMasterUser)
        {
            MasterUser objuser = db.MasterUsers.Where(x => x.UUID == objMasterUser.UUID).FirstOrDefault();
            string     changes = new EventLogDAL().ObjectDifference(objuser, objMasterUser);

            try
            {
                if (objuser != null)
                {
                    objuser.FullName    = objMasterUser.FullName;
                    objuser.Image       = objMasterUser.Image;
                    objuser.BirthDate   = objMasterUser.BirthDate;
                    objuser.Gender      = objMasterUser.Gender;
                    objuser.Comment     = objMasterUser.Comment;
                    objuser.Website     = objMasterUser.Website;
                    objuser.UserPhoneNo = objMasterUser.UserPhoneNo;
                    if (!string.IsNullOrEmpty(objMasterUser.UserEmail))
                    {
                        objuser.UserEmail = objMasterUser.UserEmail;
                    }
                    if (!string.IsNullOrEmpty(objMasterUser.UserPassword))
                    {
                        objuser.UserPassword = objMasterUser.UserPassword;
                    }
                    if (!string.IsNullOrEmpty(objMasterUser.SecQuestion))
                    {
                        objuser.SecQuestion = objMasterUser.SecQuestion;
                    }
                    if (!string.IsNullOrEmpty(objMasterUser.SecAnswer))
                    {
                        objuser.SecAnswer = Security.Encrypt(objMasterUser.SecAnswer);
                    }
                    objuser.ModifiedBy        = objMasterUser.ModifiedBy;
                    objuser.ModifiedTimeStamp = objMasterUser.ModifiedTimeStamp;

                    db.SaveChanges();

                    BPEventLog bpe = new BPEventLog();
                    bpe.Object     = "User Profile - Updated";
                    bpe.ObjectName = objMasterUser.UserName;
                    //changes = changes + rolechange + wochanges;
                    bpe.ObjectChanges    = changes;
                    bpe.EventMassage     = "Success";
                    bpe.Status           = "A";
                    bpe.CreatedBy        = objMasterUser.ModifiedBy;
                    bpe.CreatedTimeStamp = objMasterUser.ModifiedTimeStamp;
                    new EventLogDAL().AddEventLog(bpe);
                }

                return(true);
            }
            catch (Exception ex)
            {
                BPEventLog bpe = new BPEventLog();
                bpe.Object           = "User Profile - Updated";
                bpe.ObjectName       = objMasterUser.UserName;
                bpe.ObjectChanges    = string.Empty;
                bpe.EventMassage     = "Failure";
                bpe.Status           = "A";
                bpe.CreatedBy        = objMasterUser.ModifiedBy;
                bpe.CreatedTimeStamp = objMasterUser.ModifiedTimeStamp;
                new EventLogDAL().AddEventLog(bpe);

                throw ex;
            }
        }
Exemple #13
0
        public bool UpdateUsers(MasterUser objMasterUser, string Role,
                                List <UserMengurusWorkflow> objUserMengurus,
                                List <UserPerjawatanWorkflow> objUserPerjawatan,
                                List <UserSegDtlWorkflow> objUserSegmentDetails)
        {
            MasterUser objuser    = db.MasterUsers.Where(x => x.UserID == objMasterUser.UserID).FirstOrDefault();
            string     changes    = new EventLogDAL().ObjectDifference(objuser, objMasterUser);
            string     rolechange = (db.JuncUserRoles.Where(x => x.UserID == objMasterUser.UserID).FirstOrDefault().RoleID == Convert.ToInt32(Role)) ?
                                    string.Empty : "<tr><td>RoleID</td><td>" + db.JuncUserRoles.Where(x => x.UserID == objMasterUser.UserID).FirstOrDefault().RoleID + "</td><td>"
                                    + Convert.ToInt32(Role) + "</td></tr>";

            try
            {
                if (objuser != null)
                {
                    objuser.UserName          = objMasterUser.UserName;
                    objuser.FullName          = objMasterUser.FullName;
                    objuser.UserEmail         = objMasterUser.UserEmail;
                    objuser.UserIC            = objMasterUser.UserIC;
                    objuser.Department        = objMasterUser.Department;
                    objuser.UserPhoneNo       = objMasterUser.UserPhoneNo;
                    objuser.Designation       = objMasterUser.Designation;
                    objuser.Fax               = objMasterUser.Fax;
                    objuser.OfficeAddress     = objMasterUser.OfficeAddress;
                    objuser.PeriodOfService   = objMasterUser.PeriodOfService;
                    objuser.PositionGrade     = objMasterUser.PositionGrade;
                    objuser.Title             = objMasterUser.Title;
                    objuser.UserStatus        = objMasterUser.UserStatus;
                    objuser.ModifiedBy        = objMasterUser.ModifiedBy;
                    objuser.ModifiedTimeStamp = objMasterUser.ModifiedTimeStamp;

                    string mwo = (objuser.UserMengurusWorkflows.Count() == 0) ? string.Empty : objuser.UserMengurusWorkflows.ToList().Select(x => x.AccountCode).Aggregate((x, y) => x + "," + y);
                    string pwo = (objuser.UserPerjawatanWorkflows.Count() == 0) ? string.Empty : objuser.UserPerjawatanWorkflows.ToList().Select(x => x.GroupPerjawatanCode).Aggregate((x, y) => x + "," + y);
                    string swo = (objuser.UserSegDtlWorkflows.Count() == 0) ? string.Empty : objuser.UserSegDtlWorkflows.ToList().Select(x => x.SegmentDetailID.ToString()).Aggregate((x, y) => x + "," + y);
                    string mw  = (objUserMengurus.Count == 0) ? string.Empty : objUserMengurus.Select(x => x.AccountCode).Aggregate((x, y) => x + "," + y);
                    string pw  = (objUserPerjawatan.Count == 0) ? string.Empty : objUserPerjawatan.Select(x => x.GroupPerjawatanCode).Aggregate((x, y) => x + "," + y);
                    string sw  = (objUserSegmentDetails.Count == 0) ? string.Empty : objUserSegmentDetails.Select(x => x.SegmentDetailID.ToString()).Aggregate((x, y) => x + "," + y);

                    string wochanges = string.Empty;
                    if (mwo != mw)
                    {
                        wochanges = wochanges + "<tr><td>Mengurus Workflow</td><td>" + mwo + "</td><td>" + mw + "</td></tr>";
                    }
                    if (pwo != pw)
                    {
                        wochanges = wochanges + "<tr><td>Perjawatan Workflow</td><td>" + pwo + "</td><td>" + pw + "</td></tr>";
                    }
                    if (swo != sw)
                    {
                        wochanges = wochanges + "<tr><td>SegmentDetails Workflow</td><td>" + swo + "</td><td>" + sw + "</td></tr>";
                    }

                    if (objUserMengurus.Count() >= 0)
                    {
                        foreach (UserMengurusWorkflow o in db.UserMengurusWorkflows.Where(x => x.UserID == objMasterUser.UserID).ToList())
                        {
                            db.UserMengurusWorkflows.Remove(o);
                        }
                    }

                    if (objUserPerjawatan.Count() >= 0)
                    {
                        foreach (UserPerjawatanWorkflow o in db.UserPerjawatanWorkflows.Where(x => x.UserID == objMasterUser.UserID).ToList())
                        {
                            db.UserPerjawatanWorkflows.Remove(o);
                        }
                    }

                    if (objUserSegmentDetails.Count() >= 0)
                    {
                        foreach (UserSegDtlWorkflow o in db.UserSegDtlWorkflows.Where(x => x.UserID == objMasterUser.UserID).ToList())
                        {
                            db.UserSegDtlWorkflows.Remove(o);
                        }
                    }

                    foreach (UserMengurusWorkflow o in objUserMengurus)
                    {
                        db.UserMengurusWorkflows.Add(new UserMengurusWorkflow()
                        {
                            AccountCode = o.AccountCode,
                            UserID      = objMasterUser.UserID,
                            Status      = "A"
                        });
                    }
                    foreach (UserPerjawatanWorkflow o in objUserPerjawatan)
                    {
                        db.UserPerjawatanWorkflows.Add(new UserPerjawatanWorkflow()
                        {
                            GroupPerjawatanCode = o.GroupPerjawatanCode,
                            UserID = objMasterUser.UserID,
                            Status = "A"
                        });
                    }
                    foreach (UserSegDtlWorkflow o in objUserSegmentDetails)
                    {
                        db.UserSegDtlWorkflows.Add(new UserSegDtlWorkflow()
                        {
                            SegmentDetailID = o.SegmentDetailID,
                            UserID          = objMasterUser.UserID,
                            Status          = "A"
                        });
                    }

                    db.SaveChanges();

                    BPEventLog bpe = new BPEventLog();
                    bpe.Object           = "User - Updated";
                    bpe.ObjectName       = objMasterUser.UserName;
                    changes              = changes + rolechange + wochanges;
                    bpe.ObjectChanges    = changes;
                    bpe.EventMassage     = "Success";
                    bpe.Status           = "A";
                    bpe.CreatedBy        = objMasterUser.ModifiedBy;
                    bpe.CreatedTimeStamp = objMasterUser.ModifiedTimeStamp;
                    new EventLogDAL().AddEventLog(bpe);
                }

                return(true);
            }
            catch (Exception ex)
            {
                BPEventLog bpe = new BPEventLog();
                bpe.Object           = "User - Updated";
                bpe.ObjectName       = objMasterUser.UserName;
                bpe.ObjectChanges    = string.Empty;
                bpe.EventMassage     = "Failure";
                bpe.Status           = "A";
                bpe.CreatedBy        = objMasterUser.ModifiedBy;
                bpe.CreatedTimeStamp = objMasterUser.ModifiedTimeStamp;
                new EventLogDAL().AddEventLog(bpe);

                throw ex;
            }
        }