Beispiel #1
0
        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;
            }
        }
Beispiel #2
0
        public bool InsertAccountCode(PeruntukanDipinda objAccountCode)
        {
            try
            {
                //PeruntukanDipinda PA = new PeruntukanDipinda();
                db.PeruntukanDipindas.Add(objAccountCode);
                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);
                return(true);

                throw ex;
            }
        }
Beispiel #3
0
        public bool InsertYearUpload(YearUploadSetup objYearUpload)
        {
            try
            {
                db.YearUploadSetups.Add(objYearUpload);
                db.SaveChanges();

                BPEventLog bpe = new BPEventLog();
                bpe.Object           = "Year Upload Setup";
                bpe.ObjectName       = objYearUpload.BudgetYear + " - " + objYearUpload.BudgetYearDesc;
                bpe.ObjectChanges    = "<tr><td>Status</td><td></td><td>" + ((objYearUpload.Status == "A") ? "Active" : "Ended") + "</td></tr>";
                bpe.EventMassage     = "Success";
                bpe.Status           = "A";
                bpe.CreatedBy        = objYearUpload.CreatedBy;
                bpe.CreatedTimeStamp = objYearUpload.CreatedTimeStamp;
                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    = "<tr><td>Status</td><td></td><td>" + ((objYearUpload.Status == "A") ? "Active" : "Ended") + "</td></tr>";
                bpe.EventMassage     = "Failure";
                bpe.Status           = "A";
                bpe.CreatedBy        = objYearUpload.CreatedBy;
                bpe.CreatedTimeStamp = objYearUpload.CreatedTimeStamp;
                new EventLogDAL().AddEventLog(bpe);

                throw ex;
            }
        }
Beispiel #4
0
        public bool InsertAccountCode(AccountCode objAccountCode)
        {
            try
            {
                db.AccountCodes.Add(objAccountCode);
                db.SaveChanges();

                BPEventLog bpe = new BPEventLog();
                bpe.Object           = "AccountCode";
                bpe.ObjectName       = objAccountCode.AccountCode1;
                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           = "AccountCode";
                bpe.ObjectName       = objAccountCode.AccountCode1;
                bpe.ObjectChanges    = string.Empty;
                bpe.EventMassage     = "Failure";
                bpe.Status           = "A";
                bpe.CreatedBy        = objAccountCode.CreatedBy;
                bpe.CreatedTimeStamp = objAccountCode.CreatedTimeStamp;
                new EventLogDAL().AddEventLog(bpe);
                return(true);

                throw ex;
            }
        }
Beispiel #5
0
        public bool InsertGroupPerjawatan(GroupPerjawatan objGroupPerjawatan)
        {
            try
            {
                db.GroupPerjawatans.Add(objGroupPerjawatan);
                db.SaveChanges();

                BPEventLog bpe = new BPEventLog();
                bpe.Object           = "ServiceGroup";
                bpe.ObjectName       = objGroupPerjawatan.GroupPerjawatanCode;
                bpe.ObjectChanges    = string.Empty;
                bpe.EventMassage     = "Success";
                bpe.Status           = "A";
                bpe.CreatedBy        = objGroupPerjawatan.CreatedBy;
                bpe.CreatedTimeStamp = objGroupPerjawatan.CreatedTimeStamp;
                new EventLogDAL().AddEventLog(bpe);

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

                throw ex;
            }
        }
Beispiel #6
0
        public bool InsertMasterRole(MasterRole objMasterRole)
        {
            try
            {
                db.MasterRoles.Add(objMasterRole);
                db.SaveChanges();

                BPEventLog bpe = new BPEventLog();
                bpe.Object           = "Roles";
                bpe.ObjectName       = objMasterRole.RoleName;
                bpe.ObjectChanges    = string.Empty;
                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    = string.Empty;
                bpe.EventMassage     = "Failure";
                bpe.Status           = "A";
                bpe.CreatedTimeStamp = DateTime.Now;
                new EventLogDAL().AddEventLog(bpe);

                throw ex;
            }
        }
Beispiel #7
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;
            }
        }
Beispiel #8
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;
            }
        }
Beispiel #9
0
        public bool InsertBudgetMenguru(BudgetMenguru objBudgetMenguru, List <JuncBgtMengurusSegDtl> lstBgtMengurusSegDtl)
        {
            PeriodMenguru per = db.PeriodMengurus.Where(x => x.PeriodMengurusID == objBudgetMenguru.PeriodMengurusID).FirstOrDefault();

            try
            {
                db.BudgetMengurus.Add(objBudgetMenguru);
                foreach (JuncBgtMengurusSegDtl obj in lstBgtMengurusSegDtl)
                {
                    JuncBgtMengurusSegDtl item = new JuncBgtMengurusSegDtl();
                    item.BudgetMenguru     = objBudgetMenguru;
                    item.SegmentDetailID   = obj.SegmentDetailID;
                    item.CreatedBy         = objBudgetMenguru.CreatedBy;
                    item.CreatedTimeStamp  = DateTime.Now;
                    item.ModifiedBy        = objBudgetMenguru.CreatedBy;
                    item.ModifiedTimeStamp = DateTime.Now;

                    db.JuncBgtMengurusSegDtls.Add(item);
                }
                db.SaveChanges();

                BPEventLog bpe = new BPEventLog();
                bpe.Object           = "Budget Mengurus-" + per.MengurusYear + "-" + per.FieldMenguru.FieldMengurusDesc;
                bpe.ObjectName       = GetAccountCodePrefix(lstBgtMengurusSegDtl) + "-" + objBudgetMenguru.AccountCode;
                bpe.ObjectChanges    = "<tr><td>Status</td><td>O</td><td>S</td></tr> <tr><td>Amount</td><td>0.00</td><td>" + objBudgetMenguru.Amount.ToString("F") + "</td></tr>";
                bpe.EventMassage     = "Success";
                bpe.Status           = "I";
                bpe.CreatedBy        = objBudgetMenguru.CreatedBy;
                bpe.CreatedTimeStamp = objBudgetMenguru.CreatedTimeStamp;
                new EventLogDAL().AddEventLog(bpe);
                return(true);
            }
            catch (Exception ex)
            {
                BPEventLog bpe = new BPEventLog();
                bpe.Object           = "Budget Mengurus-" + per.MengurusYear + "-" + per.FieldMenguru.FieldMengurusDesc;
                bpe.ObjectName       = GetAccountCodePrefix(lstBgtMengurusSegDtl) + "-" + objBudgetMenguru.AccountCode;
                bpe.ObjectChanges    = "<tr><td>Status</td><td>O</td><td>S</td></tr> <tr><td>Amount</td><td>0.00</td><td>" + objBudgetMenguru.Amount.ToString("F") + "</td></tr>";
                bpe.EventMassage     = "Failure";
                bpe.Status           = "I";
                bpe.CreatedBy        = objBudgetMenguru.CreatedBy;
                bpe.CreatedTimeStamp = objBudgetMenguru.CreatedTimeStamp;
                new EventLogDAL().AddEventLog(bpe);

                throw ex;
            }
        }
Beispiel #10
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;
            }
        }
Beispiel #11
0
        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;
            }
        }
Beispiel #12
0
        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;
            }
        }
Beispiel #13
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;
            }
        }
Beispiel #14
0
        public bool AddEventLogWithoutSubmit(BPEventLog objEventLog)
        {
            try
            {
                if (objEventLog.ObjectChanges == null)
                {
                    objEventLog.ObjectChanges = string.Empty;
                }

                db.BPEventLogs.Add(objEventLog);
                return(true);
            }
            catch
            {
                //throw ex;
            }
            return(false);
        }
Beispiel #15
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;
            }
        }
Beispiel #16
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;
            }
        }
Beispiel #17
0
        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;
            }
        }
Beispiel #18
0
        public bool InsertUserRole(JuncUserRole objUserRole)
        {
            try
            {
                foreach (JuncUserRole obj in db.JuncUserRoles.Where(x => x.UserID == objUserRole.UserID))
                {
                    db.JuncUserRoles.Remove(obj);
                }

                if (db.MasterRoles.Where(x => x.RoleID == objUserRole.RoleID && x.RoleStatus != objUserRole.Status).Count() > 0)
                {
                    UpdateStatusOnRole(objUserRole);
                }

                db.JuncUserRoles.Add(objUserRole);
                db.SaveChanges();

                BPEventLog bpe = new BPEventLog();
                bpe.Object           = "UserRoles";
                bpe.ObjectName       = GetRoles().Where(x => x.RoleID == objUserRole.RoleID).Select(y => y.RoleName).FirstOrDefault();
                bpe.ObjectChanges    = string.Empty;
                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           = "UserRoles";
                bpe.ObjectName       = GetRoles().Where(x => x.RoleID == objUserRole.RoleID).Select(y => y.RoleName).FirstOrDefault();
                bpe.ObjectChanges    = string.Empty;
                bpe.EventMassage     = "Failure";
                bpe.Status           = "A";
                bpe.CreatedTimeStamp = DateTime.Now;
                new EventLogDAL().AddEventLog(bpe);

                throw ex;
            }
        }
Beispiel #19
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;
            }
        }
Beispiel #20
0
        public bool InsertSegment(Segment objSegment)
        {
            try
            {
                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.");
                    }
                }
                db.Segments.Add(objSegment);
                db.SaveChanges();

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

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

                throw ex;
            }
        }
Beispiel #21
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;
            }
        }
Beispiel #22
0
        public bool ResetPassword(string UserName, string Password)
        {
            MasterUser user = db.MasterUsers.Where(x => x.UserName == UserName).FirstOrDefault();

            try
            {
                //string encstr = Security.Encrypt(Password);
                user.UserPassword      = Password;
                user.ModifiedBy        = user.UserID;
                user.ModifiedTimeStamp = DateTime.Now;
                db.SaveChanges();

                BPEventLog bpe = new BPEventLog();
                bpe.Object           = "User - Reset Password";
                bpe.ObjectName       = user.UserName;
                bpe.ObjectChanges    = string.Empty;
                bpe.EventMassage     = "Success";
                bpe.Status           = "A";
                bpe.CreatedBy        = user.ModifiedBy;
                bpe.CreatedTimeStamp = user.ModifiedTimeStamp;
                new EventLogDAL().AddEventLog(bpe);
            }
            catch
            {
                BPEventLog bpe = new BPEventLog();
                bpe.Object           = "User - Reset Password";
                bpe.ObjectName       = user.UserName;
                bpe.ObjectChanges    = string.Empty;
                bpe.EventMassage     = "Failure";
                bpe.Status           = "A";
                bpe.CreatedBy        = user.ModifiedBy;
                bpe.CreatedTimeStamp = user.ModifiedTimeStamp;
                new EventLogDAL().AddEventLog(bpe);

                return(false);
            }

            return(true);
        }
Beispiel #23
0
        public bool InsertPeriodMenguru(PeriodMenguru objPeriodMenguru)
        {
            FieldMenguru objfm = db.FieldMengurus.Where(x => x.FieldMengurusID == objPeriodMenguru.FieldMengurusID).FirstOrDefault();

            try
            {
                db.PeriodMengurus.Add(objPeriodMenguru);
                db.SaveChanges();

                BPEventLog bpe = new BPEventLog();
                bpe.Object           = "Period Mengurus";
                bpe.ObjectName       = objfm.FieldMengurusDesc + " - " + objPeriodMenguru.MengurusYear;
                bpe.ObjectChanges    = string.Empty;
                bpe.EventMassage     = "Success";
                bpe.Status           = "A";
                bpe.CreatedBy        = objPeriodMenguru.CreatedBy;
                bpe.CreatedTimeStamp = objPeriodMenguru.CreatedTimeStamp;
                new EventLogDAL().AddEventLog(bpe);

                return(true);
            }
            catch (Exception ex)
            {
                BPEventLog bpe = new BPEventLog();
                bpe.Object           = "Period Mengurus";
                bpe.ObjectName       = objfm.FieldMengurusDesc + " - " + objPeriodMenguru.MengurusYear;
                bpe.ObjectChanges    = string.Empty;
                bpe.EventMassage     = "Failure";
                bpe.Status           = "A";
                bpe.CreatedBy        = objPeriodMenguru.CreatedBy;
                bpe.CreatedTimeStamp = objPeriodMenguru.CreatedTimeStamp;
                new EventLogDAL().AddEventLog(bpe);

                throw ex;
            }
        }
Beispiel #24
0
        public bool InsertAccountCode(PerbelanjaanSebenar objAccountCode)
        {
            try
            {
                List <AccountCode> data = new AccountCodeDAL().GetAccountCodes().ToList();
                objAccountCode.ParentAccountCode = data.Where(x => x.AccountCode1 == objAccountCode.BudgetAccount.Substring(17, 6)).Select(y => y.ParentAccountCode).FirstOrDefault();
                db.PerbelanjaanSebenars.Add(objAccountCode);
                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);
                return(true);

                throw ex;
            }
        }
Beispiel #25
0
        public bool InsertFieldPerjawatan(FieldPerjawatan objFieldPerjawatan)
        {
            try
            {
                objFieldPerjawatan.FieldPerjawatanSDesc = string.Empty;

                db.FieldPerjawatans.Add(objFieldPerjawatan);
                db.SaveChanges();

                BPEventLog bpe = new BPEventLog();
                bpe.Object           = "FieldPerjawatan";
                bpe.ObjectName       = objFieldPerjawatan.FieldPerjawatanDesc;
                bpe.ObjectChanges    = string.Empty;
                bpe.EventMassage     = "Success";
                bpe.Status           = "A";
                bpe.CreatedBy        = objFieldPerjawatan.CreatedBy;
                bpe.CreatedTimeStamp = objFieldPerjawatan.CreatedTimeStamp;
                new EventLogDAL().AddEventLog(bpe);

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

                throw ex;
            }
        }
Beispiel #26
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;
            }
        }
Beispiel #27
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;
            }
        }
Beispiel #28
0
        public bool InsertUsers(MasterUser objMasterUser,
                                List <UserMengurusWorkflow> objUserMengurus,
                                List <UserPerjawatanWorkflow> objUserPerjawatan,
                                List <UserSegDtlWorkflow> objUserSegmentDetails,
                                ref int UserId)
        {
            try
            {
                if (db.MasterUsers.Where(x => x.UserName.Equals(objMasterUser.UserName)).Count() > 0)
                {
                    return(false);
                }
                else
                {
                    objMasterUser.SecAnswer = Security.Encrypt(objMasterUser.SecAnswer);

                    db.MasterUsers.Add(objMasterUser);

                    foreach (UserMengurusWorkflow o in objUserMengurus)
                    {
                        db.UserMengurusWorkflows.Add(o);
                    }

                    foreach (UserPerjawatanWorkflow o in objUserPerjawatan)
                    {
                        db.UserPerjawatanWorkflows.Add(o);
                    }

                    foreach (UserSegDtlWorkflow o in objUserSegmentDetails)
                    {
                        db.UserSegDtlWorkflows.Add(o);
                    }

                    db.SaveChanges();

                    UserId = objMasterUser.UserID;

                    BPEventLog bpe = new BPEventLog();
                    bpe.Object     = "User - New User";
                    bpe.ObjectName = objMasterUser.UserName;
                    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);
                    bpe.ObjectChanges    = "<tr><td>Mengurus Workflow</td><td>New</td><td>" + mw + "</td></tr><tr><td>Perjawatan Workflow</td><td>New</td><td>" + pw + "</td></tr>";
                    bpe.EventMassage     = "Success";
                    bpe.Status           = "A";
                    bpe.CreatedBy        = objMasterUser.CreatedBy;
                    bpe.CreatedTimeStamp = objMasterUser.CreatedTimeStamp;
                    new EventLogDAL().AddEventLog(bpe);

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

                throw ex;
            }
        }
Beispiel #29
0
        public bool UpdateMultipleBudgetMengurus(List <int> LstSegmentDetailIDs, List <int> LstPeriodMengurusIDs, string FromStatus, string ToStatus, string Remarks, MasterUser User)
        {
            DateTime             datestamp = DateTime.Now;
            List <BudgetMenguru> data      = GetBudgetMengurus(LstSegmentDetailIDs).Where(x => LstPeriodMengurusIDs.Contains(x.PeriodMengurusID) && x.Status == FromStatus).ToList();

            if (data.Count > 0)
            {
                try
                {
                    foreach (BudgetMenguru obj in data)
                    {
                        string changes = string.Empty;
                        if (FromStatus != ToStatus)
                        {
                            changes = changes + "<tr><td>Status</td><td>" + FromStatus.Trim() + "</td><td>" + ToStatus.Trim() + "</td></tr>";
                        }
                        if (obj.Remarks != Remarks)
                        {
                            changes = changes + "<tr><td>Remarks</td><td>" + ((obj.Remarks == null) ? string.Empty : obj.Remarks.Trim()) + "</td><td>" + Remarks.Trim() + "</td></tr>";
                        }

                        obj.Status            = ToStatus;
                        obj.Remarks           = Remarks;
                        obj.ModifiedBy        = User.UserID;
                        obj.ModifiedTimeStamp = datestamp;

                        BPEventLog bpe = new BPEventLog();
                        bpe.Object     = "Budget Mengurus-" + obj.PeriodMenguru.MengurusYear + "-" + obj.PeriodMenguru.FieldMenguru.FieldMengurusDesc;
                        bpe.ObjectName = GetAccountCodePrefix(LstSegmentDetailIDs) + "-" + obj.AccountCode;
                        //bpe.ObjectChanges = "Batch status Changed From '" + FromStatus + "' To '" + ToStatus + "', IDs : "
                        //    + data.Select(x => x.BudgetMengurusID.ToString()).Aggregate((x, y) => x + "," + y);
                        bpe.ObjectChanges    = changes;
                        bpe.EventMassage     = "Success";
                        bpe.Status           = "I";
                        bpe.CreatedBy        = User.UserID;
                        bpe.CreatedTimeStamp = datestamp;
                        new EventLogDAL().AddEventLog(bpe);
                    }
                    db.SaveChanges();


                    return(true);
                }
                catch (Exception ex)
                {
                    BPEventLog bpe = new BPEventLog();
                    bpe.Object     = "Budget Mengurus-Batch Change";
                    bpe.ObjectName = GetAccountCodePrefix(LstSegmentDetailIDs);
                    //bpe.ObjectChanges = "Batch status Changed From '" + FromStatus + "' To '" + ToStatus + "', IDs : "
                    //    + data.Select(x => x.BudgetMengurusID.ToString()).Aggregate((x, y) => x + "," + y);
                    bpe.EventMassage     = "Failure";
                    bpe.Status           = "I";
                    bpe.CreatedBy        = User.UserID;
                    bpe.CreatedTimeStamp = datestamp;
                    new EventLogDAL().AddEventLog(bpe);

                    throw ex;
                }
            }

            return(true);
        }