예제 #1
0
        public ActionResult DeleteEquipmentCost(int?id)
        {
            if (id == null)
            {
                return(Json(new { result = false }, JsonRequestBehavior.AllowGet));
            }
            EquipmentCosts equipmentCosts = equipmentCostManager.Find(x => x.ID == id);

            if (equipmentCosts == null)
            {
                return(Json(new { result = false }, JsonRequestBehavior.AllowGet));
            }
            var res = equipmentCostManager.Delete(equipmentCosts);

            if (res > 0)
            {
                SuppProjectCosts suppProjectCost = supportProjectsCostManager.Find(x => x.ID == equipmentCosts.CostID);
                //suppProjectCost.Total = suppProjectCost.Total - equipmentCosts.Actual;
                supportProjectsCostManager.Update(suppProjectCost);
                return(Json(new { result = true }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { result = false }, JsonRequestBehavior.AllowGet));
            }
        }
예제 #2
0
        public ActionResult EditEquipmentCost(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            EquipmentCosts equipmentCosts = equipmentCostManager.Find(x => x.ID == id);

            if (equipmentCosts == null)
            {
                return(HttpNotFound());
            }
            return(View(equipmentCosts));
        }
예제 #3
0
        public ActionResult AddEquipmentCost(EquipmentCosts equipmentCosts, 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)
                    {
                        equipmentCosts.CostID = suppProjectCost.ID;
                        suppProjectCost.EquipmentCosts.Add(equipmentCosts);
                        //suppProjectCost.Total = serviceCosts.Actual + suppProjectCost.Total;
                        supportProjectsCostManager.Update(suppProjectCost);
                        return(RedirectToAction("Detail", new { id = projectID }));
                    }
                }
                else
                {
                    equipmentCosts.CostID = suppProjectCost.ID;

                    suppProjectCost.EquipmentCosts.Add(equipmentCosts);
                    //suppProjectCost.Total = serviceCosts.Actual + suppProjectCost.Total;
                    supportProjectsCostManager.Update(suppProjectCost);
                    return(RedirectToAction("Detail", new { id = projectID }));
                }
            }
            return(View(equipmentCosts));
        }
예제 #4
0
 public ActionResult EditEquipmentCost(EquipmentCosts equipmentCosts)
 {
     return(View());
 }