Ejemplo n.º 1
0
        public ActionResult DeleteConfirmed(int IncomeID)
        {
            income income = IncomeRepository.GetIncomeByID(IncomeID);

            IncomeRepository.DeleteRecord(income);
            return(RedirectToAction("Create"));
        }
Ejemplo n.º 2
0
        public ActionResult Edit(income income)
        {
            try
            {
                subcategory subCat = SubCategoryRepository.GetBySubCategoryID(income.subCategoryID);

                if (income.bankAccountID == 0)
                {
                    income.bankAccountID = subCat.bankAccountID;
                }
                if (income.Comment == null)
                {
                    income.Comment = "";
                }
                income.Title = subCat.SubCategoryName;

                income.bankAccountID = subCat.bankAccountID;

                if (ModelState.IsValid)
                {
                    db.Entry(income).State = EntityState.Modified;
                    db.SaveChanges();
                    TempData["Message2"] = "Record update successfully.";
                    GetData();
                    return(RedirectToAction("Create"));
                }
            }
            catch (Exception ex)
            {
                TempData["Message2"] = "Error editing record.";
            }
            GetData();
            return(PartialView(income));
        }
Ejemplo n.º 3
0
        public ActionResult Edit(int IncomeID)
        {
            GetData();
            income income = db.incomes.Find(IncomeID);

            return(PartialView(income));
        }
Ejemplo n.º 4
0
        public ActionResult Create(income income)
        {
            try
            {
                subcategory subCat = SubCategoryRepository.GetBySubCategoryID(income.subCategoryID);

                if (income.bankAccountID == 0)
                {
                    income.bankAccountID = subCat.bankAccountID;
                }
                if (income.Title == null)
                {
                    income.Title = subCat.SubCategoryName;
                }
                if (income.Comment == null)
                {
                    income.Comment = "";
                }

                if (ModelState.IsValid)
                {
                    db.incomes.Add(income);
                    db.SaveChanges();
                    IncomeRepository.AddRecord(income);
                    TempData["Message2"] = "Income added successfully.";
                    return(RedirectToAction("Create"));
                }
            }
            catch (Exception ex)
            {
                TempData["Message2"] = "Error adding income";
            }
            GetData();
            return(PartialView(income));
        }
Ejemplo n.º 5
0
        public ActionResult Delete(int IncomeID)
        {
            ViewBag.IncomeID = IncomeID;
            income income = IncomeRepository.GetIncomeByID(IncomeID);

            ViewBag.TotalAmount = income.CashAmount + income.CheckAmount + income.CoinAmount;
            return(PartialView(income));
        }
 //[Route("api/expense/add")]
 public IHttpActionResult AddIncome([FromBody] income inc)
 {
     if (ModelState.IsValid)
     {
         dbContext.incomes.Add(inc);
         dbContext.SaveChanges();
         return(Ok(inc));
     }
     else
     {
         return(BadRequest());
     }
 }
Ejemplo n.º 7
0
        public ActionResult incomeDelete(String id)
        {
            if (id != "")
            {
                income income = new income();

                income.id = int.Parse(id);

                db.deleteIncome(income);

                return(Json("success", JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json("error", JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 8
0
        public ActionResult InsertData(String date, String category, String cash, String pos, String amount)
        {
            if (date != "" && category != "" && cash != "" && pos != "" && amount != "")
            {
                income income = new income();

                income.date     = date;
                income.category = category;
                income.cash     = Double.Parse(cash);
                income.pos      = Double.Parse(pos);
                income.total    = Double.Parse(amount);

                db.incomeInsert(income);

                return(Json("success", JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json("error", JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 9
0
 public income GetIncomeByID(int incomeID)
 {
     record = myRecords.FirstOrDefault(e => e.incomeID == incomeID);
     return(record);
 }
Ejemplo n.º 10
0
 public void AddRecord(income Record)
 {
     myRecords.Add(record);
 }
Ejemplo n.º 11
0
 public void DeleteRecord(income record)
 {
     myRecords.Remove(record);
     context.incomes.Remove(record);
     context.SaveChanges();
 }
Ejemplo n.º 12
0
 public int GetLastIncomeRecordID()
 {
     record = myRecords.OrderByDescending(e => e.incomeID).Take(1).SingleOrDefault();
     return(record.incomeID);
 }