private void ProcessAccounts(TailoringStaffAdvancePayment objectName, bool isIn) { if (isIn) { if (objectName.PayMode == PayModes.Cash) { Utils.UpDateCashOutHand(db, objectName.PaymentDate, objectName.Amount); } //TODO: in future make it more robust if (objectName.PayMode != PayModes.Cash && objectName.PayMode != PayModes.Coupons && objectName.PayMode != PayModes.Points) { Utils.UpDateCashOutBank(db, objectName.PaymentDate, objectName.Amount); } } else { if (objectName.PayMode == PayModes.Cash) { Utils.UpDateCashOutHand(db, objectName.PaymentDate, 0 - objectName.Amount); } //TODO: in future make it more robust if (objectName.PayMode != PayModes.Cash && objectName.PayMode != PayModes.Coupons && objectName.PayMode != PayModes.Points) { Utils.UpDateCashOutBank(db, objectName.PaymentDate, 0 - objectName.Amount); } } }
public ActionResult DeleteConfirmed(int id) { TailoringStaffAdvancePayment tailoringStaffAdvancePayment = db.TailoringStaffAdvancePayments.Find(id); db.TailoringStaffAdvancePayments.Remove(tailoringStaffAdvancePayment); db.SaveChanges(); return(RedirectToAction("Index")); }
public void OnUpdate(AprajitaRetailsContext db, TailoringStaffAdvancePayment salPayment) { var old = db.TailoringStaffAdvancePayments.Where(c => c.TailoringStaffAdvancePaymentId == salPayment.TailoringStaffAdvancePaymentId).Select(d => new { d.Amount, d.PaymentDate, d.PayMode }).FirstOrDefault(); if (old != null) { UpdateOutAmount(db, old.Amount, old.PayMode, old.PaymentDate, true); } UpdateOutAmount(db, salPayment.Amount, salPayment.PayMode, salPayment.PaymentDate, false); }
public ActionResult Edit([Bind(Include = "TailoringStaffAdvancePaymentId,TailoringEmployeeId,PaymentDate,Amount,PayMode,Details")] TailoringStaffAdvancePayment tailoringStaffAdvancePayment) { if (ModelState.IsValid) { db.Entry(tailoringStaffAdvancePayment).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.TailoringEmployeeId = new SelectList(db.Tailors, "TailoringEmployeeId", "StaffName", tailoringStaffAdvancePayment.TailoringEmployeeId); return(View(tailoringStaffAdvancePayment)); }
public ActionResult Create([Bind(Include = "TailoringStaffAdvancePaymentId,TailoringEmployeeId,PaymentDate,Amount,PayMode,Details")] TailoringStaffAdvancePayment tailoringStaffAdvancePayment) { if (ModelState.IsValid) { db.TailoringStaffAdvancePayments.Add(tailoringStaffAdvancePayment); ProcessAccounts(tailoringStaffAdvancePayment, true); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.TailoringEmployeeId = new SelectList(db.Tailors, "TailoringEmployeeId", "StaffName", tailoringStaffAdvancePayment.TailoringEmployeeId); return(View(tailoringStaffAdvancePayment)); }
public async Task <IActionResult> Create([Bind("TailoringStaffAdvancePaymentId,TailoringEmployeeId,PaymentDate,Amount,PayMode,Details")] TailoringStaffAdvancePayment tailoringStaffAdvancePayment) { if (ModelState.IsValid) { _context.Add(tailoringStaffAdvancePayment); new TailoringManager().OnInsert(_context, tailoringStaffAdvancePayment); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["TailoringEmployeeId"] = new SelectList(_context.TailoringEmployees, "TailoringEmployeeId", "StaffName", tailoringStaffAdvancePayment.TailoringEmployeeId); return(PartialView(tailoringStaffAdvancePayment)); }
// GET: TailoringStaffAdvancePayments/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TailoringStaffAdvancePayment tailoringStaffAdvancePayment = db.TailoringStaffAdvancePayments.Find(id); if (tailoringStaffAdvancePayment == null) { return(HttpNotFound()); } return(PartialView(tailoringStaffAdvancePayment)); }
// GET: TailoringStaffAdvancePayments/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TailoringStaffAdvancePayment tailoringStaffAdvancePayment = db.TailoringStaffAdvancePayments.Find(id); if (tailoringStaffAdvancePayment == null) { return(HttpNotFound()); } ViewBag.TailoringEmployeeId = new SelectList(db.Tailors, "TailoringEmployeeId", "StaffName", tailoringStaffAdvancePayment.TailoringEmployeeId); return(View(tailoringStaffAdvancePayment)); }
[Authorize(Roles = "Admin,PowerUser")] public async Task <IActionResult> Edit(int id, [Bind("TailoringStaffAdvancePaymentId,TailoringEmployeeId,PaymentDate,Amount,PayMode,Details")] TailoringStaffAdvancePayment tailoringStaffAdvancePayment) { if (id != tailoringStaffAdvancePayment.TailoringStaffAdvancePaymentId) { return(NotFound()); } if (ModelState.IsValid) { try { new TailoringManager().OnUpdate(_context, tailoringStaffAdvancePayment); _context.Update(tailoringStaffAdvancePayment); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TailoringStaffAdvancePaymentExists(tailoringStaffAdvancePayment.TailoringStaffAdvancePaymentId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["TailoringEmployeeId"] = new SelectList(_context.TailoringEmployees, "TailoringEmployeeId", "StaffName", tailoringStaffAdvancePayment.TailoringEmployeeId); return(PartialView(tailoringStaffAdvancePayment)); }
public void OnDelete(AprajitaRetailsContext db, TailoringStaffAdvancePayment salPayment) { UpdateOutAmount(db, salPayment.Amount, salPayment.PayMode, salPayment.PaymentDate, true); }
public void OnInsert(AprajitaRetailsContext db, TailoringStaffAdvancePayment salPayment) { UpdateOutAmount(db, salPayment.Amount, salPayment.PayMode, salPayment.PaymentDate, false); }