/// <summary>
 /// Create a new Risk object.
 /// </summary>
 /// <param name="riskId">Initial value of the RiskId property.</param>
 /// <param name="userId">Initial value of the UserId property.</param>
 /// <param name="riskCode">Initial value of the RiskCode property.</param>
 /// <param name="riskName">Initial value of the RiskName property.</param>
 /// <param name="riskDate">Initial value of the RiskDate property.</param>
 /// <param name="orgPos">Initial value of the OrgPos property.</param>
 /// <param name="isReadOnly">Initial value of the IsReadOnly property.</param>
 public static Risk CreateRisk(global::System.Int32 riskId, global::System.Guid userId, global::System.String riskCode, global::System.String riskName, global::System.DateTime riskDate, global::System.Int32 orgPos, global::System.Boolean isReadOnly)
 {
     Risk risk = new Risk();
     risk.RiskId = riskId;
     risk.UserId = userId;
     risk.RiskCode = riskCode;
     risk.RiskName = riskName;
     risk.RiskDate = riskDate;
     risk.OrgPos = orgPos;
     risk.IsReadOnly = isReadOnly;
     return risk;
 }
Exemple #2
0
        private int GetValueId(Risk r, int groupId, List<int> Ids)
        {
            switch(groupId)
            {
                case GROUP_NONE:
                    return 1;
                case GROUP_CAUSE:
                    return (int)r.CauseGroupId;
                case GROUP_EFFECT:
                    return (int)r.EffectGroupId;
                case GROUP_RISKCLASS:
                    return (int)r.RiskCatId;
                case GROUP_HQ_BRANCH:
                    if (r.DeptId != null)
                        return 1;
                    else
                        return 2;
                case GROUP_CLASSBRANCH:
                    if (r.BranchId != null)
                        return r.Branch.ClassId;
                    else
                        return -1;
                case GROUP_BRANCH_CLASS1:
                    if (r.BranchId != null && r.Branch.ClassId == Utils.BRANCHCLASS1)
                        return (int)r.BranchId;
                    else
                        return -1;
                case GROUP_BRANCH_CLASS2:
                    if (r.BranchId != null && r.Branch.ClassId == Utils.BRANCHCLASS2)
                        return (int)r.BranchId;
                    else
                        return -1;
                case GROUP_BRANCH_CLASS3:
                    if (r.BranchId != null && r.Branch.ClassId == Utils.BRANCHCLASS3)
                        return (int)r.BranchId;
                    else
                        return -1;
                case GROUP_PROBLEVEL:
                    return (int)r.ProbLevelId;
                case GROUP_IMPACTLEVEL:
                    return (int)r.ImpactLevelId;
                case GROUP_RISKLEVEL:
                    return (int)r.RiskLevel;
                case GROUP_RANGERISKLEVEL:
                    if (r.RiskLevel <= 5)
                        return 1;
                    else if (r.RiskLevel > 5 && r.RiskLevel <= 8)
                        return 2;
                    else if (r.RiskLevel > 8 && r.RiskLevel <= 12)
                        return 3;
                    else
                        return 4;
                default:
                    return -1;

            }
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the Risks EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToRisks(Risk risk)
 {
     base.AddObject("Risks", risk);
 }
Exemple #4
0
 public static string GetRiskOrgName(Risk r)
 {
     switch (r.OrgPos)
     {
         case ORGPOS_DEPT:
             return r.Dept.DeptName;
         case ORGPOS_SUBDEPT:
             return r.SubDept.SubDeptName;
         case ORGPOS_DIVISION:
             return r.Division.DivisionName;
         case ORGPOS_SUBDIV:
             return r.SubDiv.SubDivName;
         case ORGPOS_BRANCH:
             return r.Branch.BranchName;
         case ORGPOS_SUBBRANCH:
             return r.SubBranch.SubBranchName;
         case ORGPOS_BIZUNIT:
             return r.BizUnit.BizUnitName;
         default:
             return string.Empty;
     }
 }
Exemple #5
0
 public static bool IsRiskDataCompleted(Risk risk)
 {
     return risk.CauseId != null && risk.EffectId != null && risk.RiskTypeId != null && risk.ProbLevelId != null && risk.ImpactLevelId != null;
 }
Exemple #6
0
 public static void CalcRiskLevel(Risk risk)
 {
     if (risk.ProbLevelId == null || risk.ImpactLevelId == null)
         risk.RiskLevel = null;
     else
         risk.RiskLevel = (int)risk.ProbLevelId * (int)risk.ImpactLevelId;
 }
Exemple #7
0
 private static void GetChartDataValue(Risk r, ChartData data, int yValueId)
 {
     switch (yValueId)
     {
         case DATA_COUNT:
             data.Value++;
             break;
         case DATA_PROBLEVEL:
             data.Value += (int)r.ProbLevelId;
             break;
         case DATA_IMPACTLEVEL:
             data.Value += (int)r.ImpactLevelId;
             break;
         case DATA_PROBIMPACTLEVEL:
             data.Value += (int)r.ProbLevelId;
             data.Value2 += (int)r.ImpactLevelId;
             break;
         case DATA_RISKLEVEL:
             data.Value += (int)r.RiskLevel;
             break;
     }
     data.Count++;
 }
Exemple #8
0
 private void AddRiskToList(Risk r, int newProb, int newImpact, List<Risk> list)
 {
     r.ProbLevelId = newProb;
     r.ImpactLevelId = newImpact;
     r.RiskLevel = newProb * newImpact;
     list.Add(r);
 }
Exemple #9
0
 private void AddRiskToList(Risk r, List<RiskMapData> list)
 {
     foreach(var item in list)
         if (r.ProbLevelId == item.ProbLevelId && r.ImpactLevelId == item.ImpactLevelId)
         {
             item.Count++;
             return;
         }
 }
Exemple #10
0
        public ActionResult RiskNew(RiskEditViewModel vm)
        {
            UserData data = Utils.LoadUserDataFromSession();
            bool saved = true;
            if (ModelState.IsValid)
            {
                if (vm.Risk.CauseGroupId != null && vm.Risk.CauseId == null)
                {
                    ModelState.AddModelError("", "Sebab Risiko harus diisi lengkap atau kosong sama sekali");
                    saved = false;
                }
                if (vm.Risk.EffectGroupId != null && vm.Risk.EffectId == null)
                {
                    ModelState.AddModelError("", "Akibat Risiko harus diisi lengkap atau kosong sama sekali");
                    saved = false;
                }
                if (vm.Risk.RiskCatId != null && vm.Risk.RiskTypeId == null)
                {
                    ModelState.AddModelError("", "Klasifikasi Risiko harus diisi lengkap atau kosong sama sekali");
                    saved = false;
                }

                if (saved)
                {
                    try
                    {
                        using (TransactionScope trans = new TransactionScope())
                        {
                            Risk risk = new Risk();
                            risk.UserId = data.UserId;
                            risk.JobTitle = data.JobTitle;
                            risk.RiskCode = Utils.GetFormattedSerialNumber(data);
                            risk.RiskName = vm.Risk.RiskName;
                            risk.RiskDate = vm.Risk.RiskDate;
                            risk.OrgPos = data.OrgPos;
                            risk.DeptId = data.DeptId;
                            risk.SubDeptId = data.SubDeptId;
                            risk.DivisionId = data.DivisionId;
                            risk.SubDivId = data.SubDivId;
                            risk.BranchId = data.BranchId;
                            risk.SubBranchId = data.SubBranchId;
                            risk.BizUnitId = data.BizUnitId;
                            if (vm.Risk.CauseId != null)
                            {
                                risk.CauseGroupId = vm.Risk.CauseGroupId;
                                risk.CauseTypeId = vm.Risk.CauseTypeId;
                                risk.CauseId = vm.Risk.CauseId;
                            }
                            if (vm.Risk.EffectId != null)
                            {
                                risk.EffectGroupId = vm.Risk.EffectGroupId;
                                risk.EffectTypeId = vm.Risk.EffectTypeId;
                                risk.EffectId = vm.Risk.EffectId;
                            }
                            if (vm.Risk.RiskTypeId != null)
                            {
                                risk.RiskCatId = vm.Risk.RiskCatId;
                                risk.RiskGroupId = vm.Risk.RiskGroupId;
                                risk.RiskTypeId = vm.Risk.RiskTypeId;
                            }
                            risk.ProbLevelId = Utils.PROBLEVEL1;
                            risk.ImpactLevelId = Utils.IMPACTLEVEL1;
                            risk.RiskLevel = risk.ProbLevelId * risk.ImpactLevelId;
                            risk.IsReadOnly = false;
                            db.Risks.AddObject(risk);
                            db.SaveChanges();

                            RiskProb prob = new RiskProb();
                            prob.RiskId = risk.RiskId;
                            prob.ProbOption = Utils.PROBOPTION_FREQUENCY;
                            prob.FreqId = Utils.FREQUENCY1;
                            prob.ProbLevelId = Utils.PROBLEVEL1;
                            db.RiskProbs.AddObject(prob);
                            db.SaveChanges();

                            RiskImpact impact = new RiskImpact();
                            impact.RiskId = risk.RiskId;
                            impact.IsMoneyImpact = true;
                            impact.ImpactLevelId = Utils.IMPACTLEVEL1;
                            db.RiskImpacts.AddObject(impact);
                            db.SaveChanges();

                            Utils.CreateFirstApprovalSchedule(risk.RiskId);
                            Utils.IncrementSerialNumber(db);

                            trans.Complete();
                            return RedirectToAction("RiskDetail", new { id = risk.RiskId });
                        }
                    }
                    catch (Exception e)
                    {
                        ModelState.AddModelError("", "Tidak bisa menyimpan data risiko. Error: " + e.Message);
                    }
                }
            }

            vm.Risk.RiskCode = Utils.GetFormattedSerialNumber(data);

            vm.CauseGroups = new SelectList(db.CauseGroups, "CauseGroupId", "CauseGroupName");
            vm.CauseTypes = new SelectList(db.CauseTypes.Where(p => p.CauseGroupId == vm.Risk.CauseGroupId), "CauseTypeId", "CauseTypeName");
            vm.Causes = new SelectList(db.Causes.Where(p => p.CauseTypeId == vm.Risk.CauseTypeId), "CauseId", "CauseName");

            vm.EffectGroups = new SelectList(db.EffectGroups, "EffectGroupId", "EffectGroupName");
            vm.EffectTypes = new SelectList(db.EffectTypes.Where(p => p.EffectGroupId == vm.Risk.EffectGroupId), "EffectTypeId", "EffectTypeName");
            vm.Effects = new SelectList(db.Effects.Where(p => p.EffectTypeId == vm.Risk.EffectTypeId), "EffectId", "EffectName");

            vm.RiskCats = new SelectList(db.RiskCats, "RiskCatId", "RiskCatName");
            vm.RiskGroups = new SelectList(db.RiskGroups.Where(p => p.RiskCatId == vm.Risk.RiskCatId), "RiskGroupId", "RiskGroupName");
            vm.RiskTypes = new SelectList(db.RiskTypes.Where(p => p.RiskGroupId == vm.Risk.RiskGroupId), "RiskTypeId", "RiskTypeName");

            return View(vm);
        }