Esempio n. 1
0
        public ActionResult DeleteConfirmed(int id)
        {
            StaffAdvancePayment staffAdvancePayment = db.StaffAdvancePayments.Find(id);

            db.StaffAdvancePayments.Remove(staffAdvancePayment);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public void OnUpdate(AprajitaRetailsContext db, StaffAdvancePayment salPayment)
        {
            var old = db.StaffAdvancePayments.Where(c => c.StaffAdvancePaymentId == salPayment.StaffAdvancePaymentId).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);
            HRMBot.NotifyStaffPayment(db, "", salPayment.EmployeeId, salPayment.Amount, "Advance Payment: " + salPayment.Details);
        }
Esempio n. 3
0
 private void ProcessAccounts(StaffAdvancePayment objectName)
 {
     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);
     }
 }
Esempio n. 4
0
 public ActionResult Edit([Bind(Include = "StaffAdvancePaymentId,EmployeeId,PaymentDate,Amount,PayMode,Details")] StaffAdvancePayment staffAdvancePayment)
 {
     if (ModelState.IsValid)
     {
         ProcessAccounts(staffAdvancePayment);
         db.Entry(staffAdvancePayment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.EmployeeId = new SelectList(db.Employees, "EmployeeId", "StaffName", staffAdvancePayment.EmployeeId);
     return(View(staffAdvancePayment));
 }
        public async Task <IActionResult> Create([Bind("StaffAdvancePaymentId,EmployeeId,PaymentDate,Amount,PayMode,Details")] StaffAdvancePayment staffAdvancePayment)
        {
            if (ModelState.IsValid)
            {
                _context.Add(staffAdvancePayment);
                new PayRollManager().OnInsert(_context, staffAdvancePayment);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EmployeeId"] = new SelectList(_context.Employees, "EmployeeId", "StaffName", staffAdvancePayment.EmployeeId);
            return(PartialView(staffAdvancePayment));
        }
Esempio n. 6
0
        // GET: StaffAdvancePayments/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            StaffAdvancePayment staffAdvancePayment = db.StaffAdvancePayments.Find(id);

            if (staffAdvancePayment == null)
            {
                return(HttpNotFound());
            }
            return(PartialView(staffAdvancePayment));
        }
Esempio n. 7
0
        // GET: StaffAdvancePayments/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            StaffAdvancePayment staffAdvancePayment = db.StaffAdvancePayments.Find(id);

            if (staffAdvancePayment == null)
            {
                return(HttpNotFound());
            }
            ViewBag.EmployeeId = new SelectList(db.Employees, "EmployeeId", "StaffName", staffAdvancePayment.EmployeeId);
            return(View(staffAdvancePayment));
        }
 public void OnDelete(AprajitaRetailsContext db, StaffAdvancePayment salPayment)
 {
     UpdateOutAmount(db, salPayment.Amount, salPayment.PayMode, salPayment.PaymentDate, true);
 }
 public void OnInsert(AprajitaRetailsContext db, StaffAdvancePayment salPayment)
 {
     UpdateOutAmount(db, salPayment.Amount, salPayment.PayMode, salPayment.PaymentDate, false);
     HRMBot.NotifyStaffPayment(db, "", salPayment.EmployeeId, salPayment.Amount, "Advance Payment: " + salPayment.Details);
 }
        [Authorize(Roles = "Admin,PowerUser")]     public async Task <IActionResult> Edit(int id, [Bind("StaffAdvancePaymentId,EmployeeId,PaymentDate,Amount,PayMode,Details")] StaffAdvancePayment staffAdvancePayment)
        {
            if (id != staffAdvancePayment.StaffAdvancePaymentId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    new PayRollManager().OnUpdate(_context, staffAdvancePayment);
                    _context.Update(staffAdvancePayment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StaffAdvancePaymentExists(staffAdvancePayment.StaffAdvancePaymentId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EmployeeId"] = new SelectList(_context.Employees, "EmployeeId", "StaffName", staffAdvancePayment.EmployeeId);
            return(PartialView(staffAdvancePayment));
        }