private void ProcessAccounts(TailoringSalaryPayment 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);
         }
     }
 }
Exemple #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            TailoringSalaryPayment tailoringSalaryPayment = db.TailoringSalaries.Find(id);

            db.TailoringSalaries.Remove(tailoringSalaryPayment);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public void OnUpdate(AprajitaRetailsContext db, TailoringSalaryPayment salPayment)
        {
            var old = db.TailoringSalaryPayments.Where(c => c.TailoringSalaryPaymentId == salPayment.TailoringSalaryPaymentId).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 = "TailoringSalaryPaymentId,TailoringEmployeeId,SalaryMonth,SalaryComponet,PaymentDate,Amount,PayMode,Details")] TailoringSalaryPayment tailoringSalaryPayment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tailoringSalaryPayment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.TailoringEmployeeId = new SelectList(db.Tailors, "TailoringEmployeeId", "StaffName", tailoringSalaryPayment.TailoringEmployeeId);
     return(View(tailoringSalaryPayment));
 }
Exemple #5
0
        public async Task <IActionResult> Create([Bind("TailoringSalaryPaymentId,TailoringEmployeeId,SalaryMonth,SalaryComponet,PaymentDate,Amount,PayMode,Details")] TailoringSalaryPayment tailoringSalaryPayment)
        {
            if (ModelState.IsValid)
            {
                _context.Add(tailoringSalaryPayment);
                new TailoringManager().OnInsert(_context, tailoringSalaryPayment);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TailoringEmployeeId"] = new SelectList(_context.TailoringEmployees, "TailoringEmployeeId", "StaffName", tailoringSalaryPayment.TailoringEmployeeId);
            return(PartialView(tailoringSalaryPayment));
        }
        public ActionResult Create([Bind(Include = "TailoringSalaryPaymentId,TailoringEmployeeId,SalaryMonth,SalaryComponet,PaymentDate,Amount,PayMode,Details")] TailoringSalaryPayment tailoringSalaryPayment)
        {
            if (ModelState.IsValid)
            {
                db.TailoringSalaries.Add(tailoringSalaryPayment);
                ProcessAccounts(tailoringSalaryPayment, true);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.TailoringEmployeeId = new SelectList(db.Tailors, "TailoringEmployeeId", "StaffName", tailoringSalaryPayment.TailoringEmployeeId);
            return(View(tailoringSalaryPayment));
        }
        // GET: TailoringSalaryPayments/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TailoringSalaryPayment tailoringSalaryPayment = db.TailoringSalaries.Find(id);

            if (tailoringSalaryPayment == null)
            {
                return(HttpNotFound());
            }
            return(PartialView(tailoringSalaryPayment));
        }
        // GET: TailoringSalaryPayments/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TailoringSalaryPayment tailoringSalaryPayment = db.TailoringSalaries.Find(id);

            if (tailoringSalaryPayment == null)
            {
                return(HttpNotFound());
            }
            ViewBag.TailoringEmployeeId = new SelectList(db.Tailors, "TailoringEmployeeId", "StaffName", tailoringSalaryPayment.TailoringEmployeeId);
            return(View(tailoringSalaryPayment));
        }
 public void OnDelete(AprajitaRetailsContext db, TailoringSalaryPayment salPayment)
 {
     UpdateOutAmount(db, salPayment.Amount, salPayment.PayMode, salPayment.PaymentDate, true);
 }
 public void OnInsert(AprajitaRetailsContext db, TailoringSalaryPayment salPayment)
 {
     UpdateOutAmount(db, salPayment.Amount, salPayment.PayMode, salPayment.PaymentDate, false);
 }
Exemple #11
0
        [Authorize(Roles = "Admin,PowerUser")]     public async Task <IActionResult> Edit(int id, [Bind("TailoringSalaryPaymentId,TailoringEmployeeId,SalaryMonth,SalaryComponet,PaymentDate,Amount,PayMode,Details")] TailoringSalaryPayment tailoringSalaryPayment)
        {
            if (id != tailoringSalaryPayment.TailoringSalaryPaymentId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    new TailoringManager().OnUpdate(_context, tailoringSalaryPayment);
                    _context.Update(tailoringSalaryPayment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TailoringSalaryPaymentExists(tailoringSalaryPayment.TailoringSalaryPaymentId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TailoringEmployeeId"] = new SelectList(_context.TailoringEmployees, "TailoringEmployeeId", "StaffName", tailoringSalaryPayment.TailoringEmployeeId);
            return(PartialView(tailoringSalaryPayment));
        }