public ActionResult Edit([Bind(Include = "JournalVoucherDetailAllocationID,Name,JournalVoucherDetailID,AllocationTypeID,Amount")] JournalVoucherDetailAllocation journalvoucherdetailallocation) { if (ModelState.IsValid) { db.Entry(journalvoucherdetailallocation).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.AllocationTypeID = new SelectList(db.AllocationTypes, "AllocationTypeID", "Name", journalvoucherdetailallocation.AllocationTypeID); ViewBag.JournalVoucherDetailID = new SelectList(db.JournalVoucherDetails, "JournalVoucherDetailID", "Name", journalvoucherdetailallocation.JournalVoucherDetailID); return(View(journalvoucherdetailallocation)); }
public ActionResult CreatePopUp(int id) { ViewBag.Message = Session["msg"]; ViewBag.Error = Session["err"]; Session["err"] = ""; Session["msg"] = ""; ViewBag.MessageD = Session["msgD"]; ViewBag.ErrorD = Session["errD"]; Session["errD"] = ""; Session["msgD"] = ""; var journalvoucherdetailallocation = db.JournalVoucherDetailAllocations.Include(b => b.CurrentJournalVoucherDetail).Where(b => b.JournalVoucherDetailID == id).ToList(); if (journalvoucherdetailallocation.Count == 0) { //return HttpNotFound(); JournalVoucherDetailAllocation journalvoucherdetailallocation1 = new JournalVoucherDetailAllocation(); journalvoucherdetailallocation1.JournalVoucherDetailID = id; journalvoucherdetailallocation1.AllocationTypeID = 0; journalvoucherdetailallocation1.Amount = 0.00M; db.JournalVoucherDetailAllocations.Add(journalvoucherdetailallocation1); db.SaveChanges(); journalvoucherdetailallocation = db.JournalVoucherDetailAllocations.Include(b => b.CurrentJournalVoucherDetail).Where(b => b.JournalVoucherDetailID == id).ToList(); } ViewBag.AllocationGroupID = new SelectList(db.AllocationGroups, "AllocationGroupID", "Name"); List <SelectListItem> AllocationGroupTypeCombinedItems = new List <SelectListItem>(); int repeatedgroupid = 0; var atm = db.AllocationTypes.Include(a => a.CurrentAllocationGroup).OrderBy(a => a.AllocationGroupID).ToList(); foreach (AllocationType at in atm) { if (repeatedgroupid != at.AllocationGroupID) { AllocationGroupTypeCombinedItems.Add(new SelectListItem { Text = at.CurrentAllocationGroup.Name, Value = "0" }); repeatedgroupid = at.AllocationGroupID; } AllocationGroupTypeCombinedItems.Add(new SelectListItem { Text = "----" + at.Name, Value = at.AllocationTypeID.ToString() }); } ViewBag.AllocationTypes = AllocationGroupTypeCombinedItems; ViewBag.JournalVoucherDetailID = id.ToString(); return(View(journalvoucherdetailallocation)); }
// GET: /JournalVoucherDetailAllocation/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } JournalVoucherDetailAllocation journalvoucherdetailallocation = db.JournalVoucherDetailAllocations.Find(id); if (journalvoucherdetailallocation == null) { return(HttpNotFound()); } return(View(journalvoucherdetailallocation)); }
public ActionResult DeleteConfirm(int id) { Session["err"] = "Error"; Session["msg"] = ""; JournalVoucherDetailAllocation journalvoucherdetailallocation = db.JournalVoucherDetailAllocations.Find(id); try { db.JournalVoucherDetailAllocations.Remove(journalvoucherdetailallocation); db.SaveChanges(); Session["err"] = ""; Session["msg"] = "Success"; } catch { } return(RedirectToAction("CreatePopUp", "JournalVoucherDetailAllocation", new { id = journalvoucherdetailallocation.JournalVoucherDetailID })); }
// GET: /JournalVoucherDetailAllocation/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } JournalVoucherDetailAllocation journalvoucherdetailallocation = db.JournalVoucherDetailAllocations.Find(id); if (journalvoucherdetailallocation == null) { return(HttpNotFound()); } ViewBag.AllocationTypeID = new SelectList(db.AllocationTypes, "AllocationTypeID", "Name", journalvoucherdetailallocation.AllocationTypeID); ViewBag.JournalVoucherDetailID = new SelectList(db.JournalVoucherDetails, "JournalVoucherDetailID", "Name", journalvoucherdetailallocation.JournalVoucherDetailID); return(View(journalvoucherdetailallocation)); }
public ActionResult CreatePopUp(List <tempJournalVoucherDetailAllocation> journalVoucherDetailAllocationList) { Session["msg"] = ""; Session["err"] = "Error"; int journalvoucherdetailid = 0; try { foreach (tempJournalVoucherDetailAllocation t in journalVoucherDetailAllocationList.ToList()) { journalvoucherdetailid = t.journalvoucherdetailid; if (t.allocationtypeid.ToString() != "0") { JournalVoucherDetailAllocation journalvoucherdetailallocation = db.JournalVoucherDetailAllocations.Find(t.journalvoucherdetailallocationid); if (journalvoucherdetailallocation == null) { JournalVoucherDetailAllocation journalvoucherdetailallocation1 = new JournalVoucherDetailAllocation(); journalvoucherdetailallocation1.JournalVoucherDetailID = t.journalvoucherdetailid; journalvoucherdetailallocation1.AllocationTypeID = t.allocationtypeid; journalvoucherdetailallocation1.Amount = decimal.Round(Convert.ToDecimal(t.Amount.ToString("#.##")), 2, MidpointRounding.AwayFromZero); db.JournalVoucherDetailAllocations.Add(journalvoucherdetailallocation1); db.SaveChanges(); } else { journalvoucherdetailallocation.JournalVoucherDetailID = t.journalvoucherdetailid; journalvoucherdetailallocation.AllocationTypeID = t.allocationtypeid; journalvoucherdetailallocation.Amount = decimal.Round(Convert.ToDecimal(t.Amount.ToString("#.##")), 2, MidpointRounding.AwayFromZero); db.Entry(journalvoucherdetailallocation).State = EntityState.Modified; db.SaveChanges(); } } } Session["msg"] = "Success"; Session["err"] = ""; } catch { } ViewBag.AllocationGroupID = new SelectList(db.AllocationGroups, "AllocationGroupID", "Name"); List <SelectListItem> AllocationGroupTypeCombinedItems = new List <SelectListItem>(); int repeatedgroupid = 0; var atm = db.AllocationTypes.Include(a => a.CurrentAllocationGroup).OrderBy(a => a.AllocationGroupID).ToList(); foreach (AllocationType at in atm) { if (repeatedgroupid != at.AllocationGroupID) { AllocationGroupTypeCombinedItems.Add(new SelectListItem { Text = at.CurrentAllocationGroup.Name, Value = "0" }); repeatedgroupid = at.AllocationGroupID; } AllocationGroupTypeCombinedItems.Add(new SelectListItem { Text = "----" + at.Name, Value = at.AllocationTypeID.ToString() }); } ViewBag.AllocationTypes = AllocationGroupTypeCombinedItems; ViewBag.JournalVoucherDetailID = journalvoucherdetailid.ToString(); var journalvoucherdetailallocation2 = db.JournalVoucherDetailAllocations.Include(b => b.CurrentJournalVoucherDetail).Where(b => b.JournalVoucherDetailID == journalvoucherdetailid).ToList(); return(View(journalvoucherdetailallocation2)); }