public ActionResult Edit(int BudgetID) { budget budget = BudgetRepository.GetBudgetByID(BudgetID); GetData(budget.Type); return(PartialView(budget)); }
public ActionResult Create(budget budget) { try { if (budget.Comment == null) { budget.Comment = ""; } if (ModelState.IsValid) { db.budgets.Add(budget); db.SaveChanges(); BudgetRepository.AddRecord(budget); TempData["Message2"] = "Budget record added successfully."; GetData(budget.Type); return(RedirectToAction("Create", new { BudgetType = budget.Type })); } } catch (Exception ex) { TempData["Message2"] = "Error adding budget item"; } GetData(budget.Type); return(PartialView(budget)); }
public JsonResult add([FromBody] budget b) { if (b.budgetID == -1) { var c = new budget(); c.creationDate = DateTime.Now; c.totalIncome = b.totalIncome; c.month = b.month; c.year = b.year; b.creationDate = DateTime.Now; c.userID = userID; DbContext.budgets.Add(c); DbContext.SaveChanges(); //insert categories that are recurring from the previous month DbContext.Database.ExecuteSqlCommand("insert into budgetCategories (budgetID, name, amount, isRecurring) select @budgetID, name, amount, isRecurring from budgetCategories c inner join budgets b on c.budgetID=b.budgetID where b.month=@month-1 and b.year=@year and isRecurring=1 and b.userID=@userID", new SqlParameter("@budgetID", c.budgetID), new SqlParameter("@month", c.month), new SqlParameter("@year", c.year), new SqlParameter("@userID", userID)); DbContext.SaveChanges(); var r = from newBudget in DbContext.budgets.Include(cat => cat.categories) where newBudget.budgetID == c.budgetID select newBudget; return(new JsonResult(r.FirstOrDefault(), JsonSettings)); } else { var q = from bdg in DbContext.budgets where bdg.budgetID == b.budgetID select bdg; budget updatedBudget = new budget(); updatedBudget = q.Single(); updatedBudget.totalIncome = b.totalIncome; DbContext.SaveChanges(); var r = from rec in DbContext.budgets.Include(c => c.categories) where rec.budgetID == updatedBudget.budgetID select rec; return(new JsonResult(r.FirstOrDefault(), JsonSettings)); } }
public ActionResult DeleteConfirmed(int BudgetID) { budget budget = BudgetRepository.GetBudgetByID(BudgetID); BudgetRepository.DeleteRecord(budget); // return RedirectToAction("List"); return(Content("Record deleted successfully")); }
// // GET: /Budget/Delete/5 public ActionResult Delete(int BudgetID) { ViewBag.BudgetID = BudgetID; budget budget = BudgetRepository.GetBudgetByID(BudgetID); budget.subcategory = SubCategoryRepository.GetBySubCategoryID(budget.SubCategoryID); return(PartialView(budget)); }
public ActionResult Presupuesto(budget obpresu, string command) { if (command == "Ginecologia") { double resultado = obpresu.presupuesto * 0.4; ViewBag.resultado = resultado; } if (command == "Traumatologia" || command == "Pediatria") { double resultado = obpresu.presupuesto * 0.3; ViewBag.resultado = resultado; } return(View(obpresu)); }
public ActionResult DeleteConfirmed(int SubCategoryID, int BudgetYear = 0) { subcategory subcategory = SubCategoryRepository.GetBySubCategoryID(SubCategoryID); subcategory.category = CategoryRepository.GetCategoryByID(subcategory.categoryID); string CategoryName = subcategory.category.CategoryName; budget budget = BudgetRepository.GetBudgetByCategory(SubCategoryID); subcategoryitem child = SubCategoryItemRepository.GetCategoryByChild(SubCategoryID); int parentCount = SubCategoryItemRepository.GetCategoryByParent(SubCategoryID).Count(); if ((budget != null) || (child != null) || (parentCount > 0)) { TempData["Message2"] = string.Format("Can not delete record! Budget items attached to this category"); } else { SubCategoryRepository.DeleteRecord(subcategory); } return(RedirectToAction("List", new { CategoryType = CategoryName, budgetYear = BudgetYear })); }
public ActionResult Edit(budget budget) { try { if (budget.Comment == null) { budget.Comment = ""; } if (ModelState.IsValid) { db.Entry(budget).State = EntityState.Modified; db.SaveChanges(); TempData["Message2"] = string.Format("budget data update successfully."); GetData(budget.Type); return(RedirectToAction("Edit", new { BudgetID = budget.budgetID })); } } catch (Exception ex) { TempData["Message2"] = string.Format("Error editing {0} budget data.", budget.budgetID); } GetData(budget.Type); return(PartialView(budget)); }
public void DeleteRecord(budget record) { myRecords.Remove(record); context.budgets.Remove(record); context.SaveChanges(); }
public budget GetBudgetByCategory(int subCategoryID) { record = myRecords.FirstOrDefault(e => e.SubCategoryID == subCategoryID); return(record); }
/* public Dictionary<string, int> GetBudgetList() * { * Dictionary<string, int> BudgetList; * BudgetList = myRecords * .OrderBy(e => (string)e.Title) * .ToDictionary(e => (string)e.Title, e => (int)e.budgetID); * * return (BudgetList); * } */ public budget GetBudgetByID(int budgetID) { record = myRecords.FirstOrDefault(e => e.budgetID == budgetID); return(record); }
public void AddRecord(budget Record) { myRecords.Add(record); }
private void pictureBox7_Click(object sender, EventArgs e) { budget Objbudget = new budget(); Objbudget.ShowDialog(); }