private void GetSubBranchInfo(int?subBranchId, List <KeyValuePair <string, string> > orgList) { SubBranch sub = db.SubBranches.Single(p => p.SubBranchId == subBranchId); orgList.Insert(0, new KeyValuePair <string, string>("Bagian", sub.SubBranchName)); orgList.Insert(0, new KeyValuePair <string, string>("Cabang", sub.Branch.BranchName)); }
public ActionResult DeleteConfirmed(int id) { SubBranch subBranch = db.SubBranches.Find(id); db.SubBranches.Remove(subBranch); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult BagianCabangDeleteConfirmed(int id) { SubBranch bgncabang = db.SubBranches.Single(p => p.SubBranchId == id); db.SubBranches.Remove(bgncabang); db.SaveChanges(); return(RedirectToAction("BagianCabang")); }
public ActionResult SubBranchDeleteConfirmed(int id) { SubBranch subBranch = db.SubBranches.Single(p => p.SubBranchId == id); var branchId = subBranch.BranchId; db.SubBranches.Remove(subBranch); db.SaveChanges(); return(RedirectToAction("SubBranchList", new { branchId = branchId })); }
public ActionResult Edit([Bind(Include = "SubBranchId,SubBranchName")] SubBranch subBranch) { if (ModelState.IsValid) { db.Entry(subBranch).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(subBranch)); }
public ActionResult Create([Bind(Include = "SubBranchId,SubBranchName")] SubBranch subBranch) { if (ModelState.IsValid) { db.SubBranches.Add(subBranch); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(subBranch)); }
// GET: SubBranches/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SubBranch subBranch = db.SubBranches.Find(id); if (subBranch == null) { return(HttpNotFound()); } return(View(subBranch)); }
public ActionResult SubBranchEdit(SubBranch subBranch, int id) { if (ModelState.IsValid) { db.SubBranches.Attach(subBranch); db.Entry(subBranch).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("SubBranchList", new { branchId = subBranch.BranchId })); } SubBranchViewModel vm = new SubBranchViewModel(); vm.SubBranch = subBranch; return(View()); }
public ActionResult UserNew(UserModel model, int orgPos, int?divisionId, int?subDivId, int?subDeptId, int?branchId, int?subBranchId, int?bizUnitId) { if (ModelState.IsValid) { //using (TransactionScope trans = new TransactionScope()) //{ MembershipCreateStatus createStatus; Membership.CreateUser(model.UserName, model.Password, model.Email, null, null, true, null, out createStatus); if (createStatus == MembershipCreateStatus.Success) { MembershipUser usr = Membership.GetUser(model.UserName); Guid userId = (Guid)usr.ProviderUserKey; UserInfo nfo = new UserInfo(); nfo.UserId = userId; nfo.FullName = model.FullName; nfo.JobTitle = model.JobTitle; nfo.IsRiskOwner = model.IsRCP; nfo.OrgPos = orgPos; switch (orgPos) { case Utils.ORGPOS_DIVISION: Division div = db.Divisions.Single(p => p.DivisionId == divisionId); nfo.DivisionId = divisionId; nfo.DeptId = div.DeptId; break; case Utils.ORGPOS_SUBDEPT: SubDept subDept = db.SubDepts.Single(p => p.SubDeptId == subDeptId); nfo.SubDeptId = subDeptId; nfo.DeptId = subDept.DeptId; break; case Utils.ORGPOS_SUBDIV: SubDiv subDiv = db.SubDivs.Single(p => p.SubDivId == subDivId); nfo.SubDivId = subDivId; nfo.DivisionId = subDiv.DivisionId; nfo.DeptId = subDiv.Division.DeptId; break; case Utils.ORGPOS_BRANCH: Branch branch = db.Branches.Single(p => p.BranchId == branchId); nfo.BranchId = branchId; nfo.DeptId = branch.DeptId; break; case Utils.ORGPOS_SUBBRANCH: SubBranch subBranch = db.SubBranches.Single(p => p.SubBranchId == subBranchId); nfo.SubBranchId = subBranchId; nfo.BranchId = subBranch.BranchId; nfo.DeptId = subBranch.Branch.DeptId; break; case Utils.ORGPOS_BIZUNIT: BizUnit biz = db.BizUnits.Single(p => p.BizUnitId == bizUnitId); nfo.BizUnitId = bizUnitId; nfo.BranchId = biz.BranchId; nfo.DeptId = biz.Branch.DeptId; break; } db.UserInfos.Add(nfo); db.SaveChanges(); //trans.Complete(); return(RedirectToAction("Index")); } else { ModelState.AddModelError("", ErrorCodeToString(createStatus)); } //} } GetOrgPosInfo(divisionId, subDivId, subDeptId, branchId, subBranchId, bizUnitId); return(View(model)); }
public ActionResult ApproveRiskConfirmed(int id) { UserData data = Utils.LoadUserDataFromSession(); var apr = db.RiskApprovals.Where(p => p.ApprovalId == id).FirstOrDefault(); using (var trans = db.Database.BeginTransaction()) { try { apr.ApprovalDate = DateTime.Now; apr.UserId = data.UserId; apr.JobTitle = data.JobTitle; db.SaveChanges(); apr.Risk.IsReadOnly = true; db.SaveChanges(); if (apr.LastApproval) { // risk approval completed apr.Risk.ApprovalDate = apr.ApprovalDate; db.SaveChanges(); var prevApr = db.RiskApprovals .Where(p => p.RiskId == apr.RiskId && p.ApprovalId != apr.ApprovalId && p.ApprovalDate != null) .FirstOrDefault(); if (prevApr != null) { prevApr.IsReadOnly = true; db.SaveChanges(); } var rs = new RiskState(); rs.RiskId = apr.RiskId; rs.StateDate = (DateTime)apr.ApprovalDate; rs.ProbLevelId = (int)apr.Risk.ProbLevelId; rs.ImpactLevelId = (int)apr.Risk.ImpactLevelId; rs.RiskLevel = (int)apr.Risk.RiskLevel; db.RiskStates.Add(rs); db.SaveChanges(); } else { // next approval schedule RiskApproval nextApr = new RiskApproval(); nextApr.RiskId = apr.RiskId; nextApr.LimitDate = DateTime.Now.AddDays(Utils.MAX_LIMIT_APPROVAL_DAYS); nextApr.LastApproval = true; switch (apr.OrgPos) { case Utils.ORGPOS_SUBDIV: SubDiv subDiv = db.SubDivs.Single(p => p.SubDivId == apr.SubDivId); nextApr.OrgPos = Utils.ORGPOS_DIVISION; nextApr.DivisionId = subDiv.DivisionId; nextApr.OrgName = subDiv.Division.DivisionName; break; case Utils.ORGPOS_SUBBRANCH: SubBranch subBranch = db.SubBranches.Single(p => p.SubBranchId == apr.SubBranchId); nextApr.OrgPos = Utils.ORGPOS_BRANCH; nextApr.BranchId = subBranch.BranchId; nextApr.OrgName = subBranch.Branch.BranchName; break; case Utils.ORGPOS_BIZUNIT: BizUnit biz = db.BizUnits.Single(p => p.BizUnitId == apr.BizUnitId); nextApr.OrgPos = Utils.ORGPOS_BRANCH; nextApr.BranchId = biz.BranchId; nextApr.OrgName = biz.Branch.BranchName; break; } db.RiskApprovals.Add(nextApr); db.SaveChanges(); } trans.Commit(); } catch (Exception e) { trans.Rollback(); ViewBag.Message = "Tidak bisa meng-approve data peristiwa risiko : " + e.Message; return(View("Error")); } } return(RedirectToAction("Detail", new { id = apr.RiskId })); }