public ActionResult DeleteMaterialCost(int?id) { if (id == null) { return(Json(new { result = false }, JsonRequestBehavior.AllowGet)); } MaterialCosts materialCosts = materialCostManager.Find(x => x.ID == id); if (materialCosts == null) { return(Json(new { result = false }, JsonRequestBehavior.AllowGet)); } var res = materialCostManager.Delete(materialCosts); if (res > 0) { SuppProjectCosts suppProjectCost = supportProjectsCostManager.Find(x => x.ID == materialCosts.CostID); //suppProjectCost.Total = suppProjectCost.Total - materialCosts.Actual; supportProjectsCostManager.Update(suppProjectCost); return(Json(new { result = true }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { result = false }, JsonRequestBehavior.AllowGet)); } }
public ActionResult EditMaterialCost(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } MaterialCosts materialCosts = materialCostManager.Find(x => x.ID == id); if (materialCosts == null) { return(HttpNotFound()); } return(View(materialCosts)); }
public ActionResult AddMaterialCost(MaterialCosts materialCosts, string Year, string Period) { int?projectID = (int)TempData["suppProjectID"]; if (ModelState.IsValid) { if (projectID == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SuppProjectCosts suppProjectCost = supportProjectsCostManager.Find(x => x.ProjectID == projectID && x.Year == Year && x.Period == Period); if (suppProjectCost == null) { suppProjectCost = new SuppProjectCosts(); suppProjectCost.ProjectID = projectID; //suppProjectCost.Total = 0; suppProjectCost.Year = Year; suppProjectCost.Period = Period; var res = supportProjectsCostManager.Insert(suppProjectCost); if (res > 0) { materialCosts.CostID = suppProjectCost.ID; suppProjectCost.MaterialCosts.Add(materialCosts); //suppProjectCost.Total = materialCosts.Actual + suppProjectCost.Total; supportProjectsCostManager.Update(suppProjectCost); return(RedirectToAction("Detail", new { id = projectID })); } } else { materialCosts.CostID = suppProjectCost.ID; suppProjectCost.MaterialCosts.Add(materialCosts); //suppProjectCost.Total = materialCosts.Actual + suppProjectCost.Total; supportProjectsCostManager.Update(suppProjectCost); return(RedirectToAction("Detail", new { id = projectID })); } } return(View(materialCosts)); }
public ActionResult EditMaterialCost(MaterialCosts materialCosts) { return(View()); }