예제 #1
0
 public IActionResult OnPostInsertBillDetails([FromBody] Models.BillDetails obj)
 {
     obj.BillAmountOutstanding = obj.Amount;
     _context.BillDetails.Add(obj);
     _context.SaveChanges();
     return(new JsonResult("Added Successfully!"));
 }
예제 #2
0
        public IActionResult OnPutUpdateBillDetails(int id, double damt, [FromBody] Models.BillDetails obj)
        {
            obj.BillAmountOutstanding  = obj.Amount;
            _context.Attach(obj).State = EntityState.Modified;

            try
            {
                _context.SaveChanges();
                _context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;

                var DebtorGroupOut = _context.DebtorGroup.Where(a => a.DebtorGroupID.Equals(obj.DebtorGroupID)).Select(a => a.DebtorOutstanding).FirstOrDefault();

                var billout = DebtorGroupOut + damt;
                var dgout   = new Models.DebtorGroup {
                    DebtorGroupID = obj.DebtorGroupID, DebtorOutstanding = billout
                };
                _context.DebtorGroup.Attach(dgout).Property(x => x.DebtorOutstanding).IsModified = true;
                _context.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BillDetailsExists(obj.BillDetailsID))
                {
                    return(new JsonResult("Update Error!"));
                }
                else
                {
                    return(new JsonResult("Update Error!"));
                }
            }

            return(new JsonResult("Information Updated!"));
        }
예제 #3
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Received = await _context.Received.FindAsync(id);

            if (Received != null)
            {
                _context.Received.Remove(Received);
                await _context.SaveChangesAsync();

                _context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
                var amtout = _context.BillDetails.Where(a => a.BillDetailsID.Equals(Received.BillDetailsID)).FirstOrDefault().BillAmountOutstanding;
                // var amtout = _context.DebtorGroup.Where(a => a.DebtorGroupID.Equals(dgid)).FirstOrDefault().DebtorOutstanding;
                var billout = amtout + Received.ReceivedAmount;
                var billdet = new Models.BillDetails {
                    BillDetailsID = Received.BillDetailsID, BillAmountOutstanding = billout
                };
                _context.BillDetails.Attach(billdet).Property(x => x.BillAmountOutstanding).IsModified = true;
                _context.SaveChanges();

                var dgout = _context.DebtorGroup.Where(a => a.DebtorGroupID.Equals(Received.DebtorGroupID)).FirstOrDefault().DebtorOutstanding;

                var debout = dgout + Received.ReceivedAmount;
                var dgdet  = new Models.DebtorGroup {
                    DebtorGroupID = Received.DebtorGroupID, DebtorOutstanding = debout
                };
                _context.DebtorGroup.Attach(dgdet).Property(x => x.DebtorOutstanding).IsModified = true;
                _context.SaveChanges();
            }
            return(RedirectToPage("./Index", new { companyid = Received.CompanyID }));
        }
예제 #4
0
        public IActionResult OnPostInsertReceived(int dgid, [FromBody] Models.Received obj)
        {
            obj.CompanyID     = (int)_session.GetInt32("Cid");
            obj.DebtorGroupID = _context.BillDetails.Where(a => a.BillDetailsID.Equals(obj.BillDetailsID)).Select(a => a.DebtorGroupID).FirstOrDefault();
            _context.Received.Add(obj);
            _context.SaveChanges();

            _context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
            var amtout = _context.BillDetails.Where(a => a.BillDetailsID.Equals(obj.BillDetailsID)).FirstOrDefault().BillAmountOutstanding;
            // var amtout = _context.DebtorGroup.Where(a => a.DebtorGroupID.Equals(dgid)).FirstOrDefault().DebtorOutstanding;
            var billout = amtout - obj.ReceivedAmount;
            var billdet = new Models.BillDetails {
                BillDetailsID = obj.BillDetailsID, BillAmountOutstanding = billout
            };

            _context.BillDetails.Attach(billdet).Property(x => x.BillAmountOutstanding).IsModified = true;
            _context.SaveChanges();

            var dgout = _context.DebtorGroup.Where(a => a.DebtorGroupID.Equals(dgid)).FirstOrDefault().DebtorOutstanding;

            var debout = dgout - obj.ReceivedAmount;
            var dgdet  = new Models.DebtorGroup {
                DebtorGroupID = dgid, DebtorOutstanding = debout
            };

            _context.DebtorGroup.Attach(dgdet).Property(x => x.DebtorOutstanding).IsModified = true;
            _context.SaveChanges();

            return(new JsonResult("Successful!"));
        }
예제 #5
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            BillDetails = await _context.BillDetails
                          .Include(b => b.Bill)
                          .Include(b => b.Company)
                          .Include(b => b.Debtor)
                          .Include(b => b.DebtorGroup)
                          .Include(b => b.Particulars).FirstOrDefaultAsync(m => m.BillDetailsID == id);

            if (BillDetails == null)
            {
                return(NotFound());
            }
            ViewData["BillNumber"]    = new SelectList(_context.Bill, "BillNumber", "BillNumber");
            ViewData["CompanyID"]     = new SelectList(_context.Company, "CompanyID", "CompanyName");
            ViewData["DebtorID"]      = new SelectList(_context.Debtor, "DebtorID", "DebtorName");
            ViewData["DebtorGroupID"] = new SelectList(_context.DebtorGroup, "DebtorGroupID", "DebtorGroupName");
            ViewData["ParticularsID"] = new SelectList(_context.Particulars, "ParticularsID", "ParticularsName");
            return(Page());
        }
예제 #6
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            BillDetails = await _context.BillDetails.FindAsync(id);

            if (BillDetails != null)
            {
                _context.BillDetails.Remove(BillDetails);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
예제 #7
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            BillDetails = await _context.BillDetails
                          .Include(b => b.Bill)
                          .Include(b => b.Company)
                          .Include(b => b.Debtor)
                          .Include(b => b.DebtorGroup)
                          .Include(b => b.Particulars).FirstOrDefaultAsync(m => m.BillDetailsID == id);

            if (BillDetails == null)
            {
                return(NotFound());
            }
            return(Page());
        }