Exemplo n.º 1
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;
            }
        }
Exemplo n.º 2
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;
            }
        }