//[Route("AdjustmentRecords/Details/{id?}")]
        public async Task <IActionResult> VoucherItemDelete(string id, int rdid)
        {
            ADTeam5User user = await _userManager.GetUserAsync(HttpContext.User);

            List <string> identity = userCheck.checkUserIdentityAsync(user);
            int           userID   = user.WorkID;

            //string voucherNo = _context.RecordDetails.FirstOrDefault(x => x.Rdid == rdid).Rrid;
            List <AdjustmentRecordDetails> adjustmentRecordDetailsList = new List <AdjustmentRecordDetails>();

            if (id != null)
            {
                List <AdjustmentRecordDetails> adjustmentRecordDetailsList1 = b.GetAdjustmentRecordDetails(id);
                b.DeleteVoucherItem(rdid, adjustmentRecordDetailsList1);
                adjustmentRecordDetailsList = b.GetAdjustmentRecordDetails(id);
            }

            if (adjustmentRecordDetailsList == null)
            {
                adjustmentRecordDetailsList = new List <AdjustmentRecordDetails>();
            }

            //ViewData for voucherNo
            ViewData["VoucherNo"] = id;

            //ViewBag for voucher price
            decimal?amount = b.GetTotalAmountForVoucher(id);
            decimal?GST    = Math.Round((decimal)(amount * (decimal?)0.07), 2);

            ViewBag.Amount      = amount;
            ViewBag.GST         = GST;
            ViewBag.TotalAmount = amount + GST;

            List <AdjustmentRecordDetails> result = b.GetAdjustmentRecordDetails(id);

            //Viewbag for category dropdown list, need to post back
            List <Catalogue> categoryList = new List <Catalogue>();
            var q = _context.Catalogue.GroupBy(x => new { x.Category }).Select(x => x.FirstOrDefault());

            foreach (var item in q)
            {
                categoryList.Add(item);
            }
            categoryList.Insert(0, new Catalogue {
                ItemNumber = "0", Category = "---Select Category---"
            });
            ViewBag.ListofCategory = categoryList;

            //ViewBag for record status
            ViewBag.AdjustmentRecordStatus = _context.AdjustmentRecord.FirstOrDefault(x => x.VoucherNo == id).Status;

            return(PartialView("_TempDetails", adjustmentRecordDetailsList));
        }
Exemplo n.º 2
0
        //[ActionName("VoucherItemDelete"), Route("~/IssueVoucher")]
        public async Task <IActionResult> VoucherItemDelete(int id)
        {
            ADTeam5User user = await _userManager.GetUserAsync(HttpContext.User);

            List <string> identity = userCheck.checkUserIdentityAsync(user);
            int           userID   = user.WorkID;

            //Viewbag for category dropdown list, need to post back
            List <Catalogue> categoryList = new List <Catalogue>();
            var q = _context.Catalogue.GroupBy(x => new { x.Category }).Select(x => x.FirstOrDefault());

            foreach (var item in q)
            {
                categoryList.Add(item);
            }
            categoryList.Insert(0, new Catalogue {
                ItemNumber = "0", Category = "---Select Category---"
            });
            ViewBag.ListofCategory = categoryList;

            List <TempVoucherDetails> tempVoucherDetailsList1 = b.GetTempVoucherDetailsList(userID);

            b.DeleteVoucherItem(id, tempVoucherDetailsList1);

            List <TempVoucherDetails> tempVoucherDetailsList = b.GetTempVoucherDetailsList(userID);

            if (tempVoucherDetailsList.Count == 0)
            {
                tempVoucherDetailsList = new List <TempVoucherDetails>();
            }

            //ViewBag for voucher price
            string  tempVoucherNo = "VTemp" + userID;
            decimal?amount        = b.GetTotalAmountForVoucher(tempVoucherNo);
            decimal?GST           = Math.Round((decimal)(amount * (decimal?)0.07), 2);

            ViewBag.Amount      = amount;
            ViewBag.GST         = GST;
            ViewBag.TotalAmount = amount + GST;

            return(PartialView("_TempVoucherDetailsList", tempVoucherDetailsList));
        }