Пример #1
0
        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));
            }
        }
Пример #2
0
        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));
        }
Пример #3
0
        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));
        }
Пример #4
0
 public ActionResult EditMaterialCost(MaterialCosts materialCosts)
 {
     return(View());
 }