Exemple #1
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!"));
        }
Exemple #2
0
        public async Task <IActionResult> OnPostAsync()
        {
            try
            {
                Received.CompanyID = (int)_session.GetInt32("Cid");

                _context.Received.Add(Received);
                await _context.SaveChangesAsync();


                _context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;

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

                var debtorrec = DebtorGroupOut - Received.ReceivedAmount;
                var dgout     = new Models.DebtorGroup {
                    DebtorGroupID = Received.DebtorGroupID, DebtorOutstanding = debtorrec
                };
                _context.DebtorGroup.Attach(dgout).Property(x => x.DebtorOutstanding).IsModified = true;
                _context.SaveChanges();
                return(RedirectToPage("./Index"));
            }
            catch (Exception)
            {
                return(Page());
            }
        }
        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 }));
        }
        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!"));
        }
Exemple #5
0
        public async Task <IActionResult> OnPostAsync(string id)
        {
            if (id == null)
            {
                return(NotFound());
            }

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

            if (Bill != null)
            {
                var billdetsum = _context.BillDetails.Where(a => a.BillNumber.Equals(Bill.BillNumber)).Select(a => a.BillAmountOutstanding).Sum();
                _context.Bill.Remove(Bill);
                await _context.SaveChangesAsync();

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

                var billout = DebtorGroupOut - billdetsum;
                var dgout   = new Models.DebtorGroup {
                    DebtorGroupID = Bill.DebtorGroupID, DebtorOutstanding = billout
                };
                _context.DebtorGroup.Attach(dgout).Property(x => x.DebtorOutstanding).IsModified = true;
                _context.SaveChanges();
            }
            if (Bill.SeriesName != null)
            {
                return(RedirectToPage("/Bill/Format1/Index"));
            }
            else
            {
                return(RedirectToPage("/Bill/Format2/Index"));
            }
        }
        public IActionResult OnPostSendMessage([FromBody] Models.DebtorGroup obj)
        {
            string[] msgcnt = new string[3];
            msgcnt[0] = SendSmsAsync(obj.DebtorGroupPhoneNumber.Substring(obj.DebtorGroupPhoneNumber.Length - 10), obj.DebtorGroupCity);
            msgcnt[1] = (obj.DebtorGroupPhoneNumber.Substring(obj.DebtorGroupPhoneNumber.Length - 10));
            msgcnt[2] = obj.DebtorGroupName;

            return(new JsonResult(msgcnt));
        }
Exemple #7
0
        //public async Task<IActionResult> OnPostAsync()
        //{
        //    if (!ModelState.IsValid)
        //    {
        //        return Page();
        //    }

        //    _context.DebtorGroup.Add(DebtorGroup);
        //    await _context.SaveChangesAsync();

        //    return RedirectToPage("./Index");
        //}

        public IActionResult OnPostInsert([FromBody] Models.DebtorGroup obj)
        {
            //return new JsonResult("Customer Added Successfully!");
            _context.DebtorGroup.Add(obj);
            _context.SaveChanges();

            var result = _context.AdHocReturns.FromSql("SELECT last_value FROM \"DebtorGroup_DebtorGroupID_seq\"").FirstOrDefault().last_value;

            return(new JsonResult("Debtor Added Successfully!" + result));
        }
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            DebtorGroup = await _context.DebtorGroup
                          .Include(d => d.Branch).FirstOrDefaultAsync(m => m.DebtorGroupID == id);

            if (DebtorGroup == null)
            {
                return(NotFound());
            }
            return(Page());
        }
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

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

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

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

            DebtorGroup = await _context.DebtorGroup
                          .Include(d => d.Branch).FirstOrDefaultAsync(m => m.DebtorGroupID == id);

            if (DebtorGroup == null)
            {
                return(NotFound());
            }
            ViewData["BranchID"] = new SelectList(_context.Branch, "BranchID", "BranchName");
            return(Page());
        }
Exemple #11
0
        public IActionResult OnDeleteDeleteBillDetails(int id, double billamt, int debid)
        {
            _context.BillDetails.Remove(_context.BillDetails.Find(id));
            _context.SaveChanges();

            _context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;

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

            var billout = DebtorGroupOut - billamt;
            var dgout   = new Models.DebtorGroup {
                DebtorGroupID = debid, DebtorOutstanding = billout
            };

            _context.DebtorGroup.Attach(dgout).Property(x => x.DebtorOutstanding).IsModified = true;
            _context.SaveChanges();
            return(new JsonResult("Deleted Successfully! Remove Row."));
        }
Exemple #12
0
        public IActionResult OnGetUpdateDebOut(double debout, int dgid)
        {
            try
            {
                if (Double.IsNaN(debout))
                {
                    return(NotFound());
                }
                var DebtorGroupOut = _context.DebtorGroup.Where(a => a.DebtorGroupID.Equals(dgid)).Select(a => a.DebtorOutstanding).FirstOrDefault();

                var billout = DebtorGroupOut + debout;
                var dgout   = new Models.DebtorGroup {
                    DebtorGroupID = dgid, DebtorOutstanding = billout
                };
                _context.DebtorGroup.Attach(dgout).Property(x => x.DebtorOutstanding).IsModified = true;
                _context.SaveChanges();

                return(new JsonResult("Information Updated!"));
            }
            catch (Exception e)
            {
                return(NotFound());
            }
        }
Exemple #13
0
 public IActionResult OnGetBillToDetails(int id)
 {
     Models.DebtorGroup data = _context.DebtorGroup.Find(id);
     return(new JsonResult(data));
 }