public ActionResult DeleteConfirmed(int id)
        {
            thanhtoan thanhtoan = db.thanhtoan.Find(id);

            db.thanhtoan.Remove(thanhtoan);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "maphuongthucthanhtoan,tenphuongthucthanhtoan")] thanhtoan thanhtoan)
 {
     if (ModelState.IsValid)
     {
         db.Entry(thanhtoan).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(thanhtoan));
 }
        public ActionResult Create([Bind(Include = "maphuongthucthanhtoan,tenphuongthucthanhtoan")] thanhtoan thanhtoan)
        {
            if (ModelState.IsValid)
            {
                db.thanhtoan.Add(thanhtoan);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(thanhtoan));
        }
        // GET: Areas/Thanhtoan/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            thanhtoan thanhtoan = db.thanhtoan.Find(id);

            if (thanhtoan == null)
            {
                return(HttpNotFound());
            }
            return(View(thanhtoan));
        }
        public IActionResult GetPayData(int year)
        {
            List <int?> arrayPay = new List <int?>();

            for (var i = 1; i <= 12; i++)
            {
                int?pay = 0;
                if (i == 12)
                {
                    var paid = _context.Pays.Where(p => p.DateOfPayment >= DateTime.Parse("01/" + i + "/" + year) && p.DateOfPayment < DateTime.Parse("31/" + i + "/" + year));
                    foreach (var item in paid)
                    {
                        pay += item.Paid;
                    }
                }
                else
                {
                    var paid = _context.Pays.Where(p => p.DateOfPayment >= DateTime.Parse("01/" + i + "/" + year) && p.DateOfPayment < DateTime.Parse("01/" + (i + 1) + "/" + year));
                    foreach (var item in paid)
                    {
                        pay += item.Paid;
                    }
                }
                arrayPay.Add(pay);
            }
            arrayPay.ToArray();

            List <int?> arraytotal = new List <int?>();

            for (var i = 1; i <= 12; i++)
            {
                int?sumTotal = 0;
                if (i == 12)
                {
                    var paid = _context.Pays.Where(p => p.DateOfPayment >= DateTime.Parse("01/" + i + "/" + year) && p.DateOfPayment < DateTime.Parse("31/" + i + "/" + year));
                    foreach (var item in paid)
                    {
                        sumTotal += item.Total;
                    }
                }
                else
                {
                    var paid = _context.Pays.Where(p => p.DateOfPayment >= DateTime.Parse("01/" + i + "/" + year) && p.DateOfPayment < DateTime.Parse("01/" + (i + 1) + "/" + year));
                    foreach (var item in paid)
                    {
                        sumTotal += item.Total;
                    }
                }
                arraytotal.Add(sumTotal);
            }
            arraytotal.ToArray();
            List <int?> arrayowe = new List <int?>();

            for (int i = 0; i <= 11; i++)
            {
                arrayowe.Add(arraytotal[i] - arrayPay[i]);
            }
            arrayowe.ToArray();
            thanhtoan thanhtoan = new thanhtoan();

            thanhtoan.paid = arrayPay;
            thanhtoan.owe  = arrayowe;
            return(Json(thanhtoan));
        }