public ActionResult AddCost(int?id, int actual, int planned, int accepted, string year, string period) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SuppProjects projects = suppProjectManager.Find(x => x.ID == id); if (projects == null) { return(HttpNotFound()); } suppProjectCostGlb = supportProjectsCostManager.Find(x => x.ProjectID == id && x.Year == year && x.Period == period); if (suppProjectCostGlb == null) { SuppProjectCosts projectCosts = new SuppProjectCosts(); projectCosts.Accepted = accepted; projectCosts.Actual = actual; projectCosts.Planned = planned; projectCosts.ProjectID = id; projectCosts.Year = year; projectCosts.Period = period; var res = supportProjectsCostManager.Insert(projectCosts); if (res > 0) { ViewBag.COSTMESSAGE = "Cost Added"; return(View(projects)); } else { ViewBag.COSTMESSAGE = "Error"; return(View(projects)); } } else { suppProjectCostGlb.Actual = actual; suppProjectCostGlb.Accepted = accepted; suppProjectCostGlb.Planned = planned; var res = supportProjectsCostManager.Update(suppProjectCostGlb); if (res > 0) { ViewBag.COSTMESSAGE = "Cost Already Exist.Updated."; return(View(projects)); } else { ViewBag.COSTMESSAGE = "Error"; return(View(projects)); } } }
public ActionResult Edit(int?id) { ViewBag.FUNDINGSCHEMES = fundingSchemesManager.List(); ViewBag.STATUS = projectsStatusManager.List(); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SuppProjects suppProject = suppProjectManager.Find(x => x.ID == id); if (suppProject == null) { return(HttpNotFound()); } return(View(suppProject)); }
public ActionResult Create(SuppProjects suppProject /*,decimal Planned,decimal Actual,decimal Accepted*/) { if (ModelState.IsValid) { SuppProjectCosts suppProjectCosts = new SuppProjectCosts(); //suppProjectCosts.Planned = Planned; //suppProjectCosts.Actual = Actual; //suppProjectCosts.Accepted = Accepted; //suppProjectCosts.Total = 0; //suppProject.SuppProjectCosts = suppProjectCosts; var res = suppProjectManager.Insert(suppProject); if (res > 0) { TempData["mesaj"] = "Created."; return(RedirectToAction("Index")); } } ViewBag.FUNDINGSCHEMES = fundingSchemesManager.List(); ViewBag.STATUS = projectsStatusManager.List(); TempData["mesaj"] = "Error. Please check fields."; return(View(suppProject)); }
public ActionResult Delete(int?id) { if (id == null) { return(Json(new { result = false }, JsonRequestBehavior.AllowGet)); } SuppProjects suppProject = suppProjectManager.Find(x => x.ID == id); if (suppProject == null) { return(Json(new { result = false }, JsonRequestBehavior.AllowGet)); } var res = suppProjectManager.Delete(suppProject); if (res > 0) { return(Json(new { result = true }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { result = false }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Detail(int?id, string yearperioddata) { double years; List <YearPeriodModel> yearPeriodModels = new List <YearPeriodModel>(); YearPeriodModel yearPeriod = new YearPeriodModel(); globalSupportProject = suppProjectManager.Find(x => x.ID == id); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (yearperioddata != null) { splitData = yearperioddata.Split('/'); int i = 0; foreach (var item in splitData) { if (i == 0) { year = item.Trim(); i++; } else if (i == 1) { period = item.Trim(); i++; } } } SuppProjects projects = suppProjectManager.Find(x => x.ID == id); DateTime startDate = projects.SignedDate.Value; DateTime endDate = projects.SuppEndDate.Value; if (endDate != null) { var timeSpan = (endDate - startDate); years = timeSpan.TotalDays / 365; } else { endDate = DateTime.Now; var timeSpan = endDate - startDate; years = timeSpan.TotalDays / 365; } while (startDate <= endDate) { if (startDate.Month < 7) { yearPeriod.Period = "1"; yearPeriod.Year = startDate.Year.ToString(); yearPeriod.YearPeriod = (startDate.Year.ToString() + "/" + " 1"); yearPeriodModels.Add(yearPeriod); yearPeriod = new YearPeriodModel(); } else if (startDate.Month > 6) { yearPeriod.Period = "2"; yearPeriod.Year = startDate.Year.ToString(); yearPeriod.YearPeriod = (startDate.Year.ToString() + "/" + " 2"); yearPeriodModels.Add(yearPeriod); yearPeriod = new YearPeriodModel(); } startDate = startDate.AddMonths(6).AddDays(-1); } ViewBag.YEARPERIOD = yearPeriodModels; ViewBag.SELECTEDPERIOD = yearperioddata; if (year != null && period != null) { SuppProjects tempProject = new SuppProjects(); tempProject.SuppProjectCosts.Clear(); tempProject.AppealDate = projects.AppealDate; tempProject.Budget = projects.Budget; tempProject.FundingSchemes = projects.FundingSchemes; tempProject.FundingSchemesID = projects.FundingSchemesID; tempProject.ID = projects.ID; tempProject.PlannedManMonth = projects.PlannedManMonth; tempProject.ProjectNo = projects.ProjectNo; tempProject.SignedDate = projects.SignedDate; tempProject.StatusID = projects.StatusID; tempProject.SuppEndDate = projects.SuppEndDate; tempProject.SupportRate = projects.SupportRate; tempProject.SuppProjectPersonnels = projects.SuppProjectPersonnels; tempProject.SuppProjectsStatus = projects.SuppProjectsStatus; tempProject.SuppStartDate = projects.SuppStartDate; if (projects.SuppProjectCosts != null) { foreach (var cost in projects.SuppProjectCosts.ToList()) { if (cost.Year == year && cost.Period == period) { tempProject.SuppProjectCosts.Add(cost); } } } return(View(tempProject)); } if (projects == null) { return(HttpNotFound()); } return(View(projects)); }
public ActionResult AddCost(int?id) { SuppProjects projects = suppProjectManager.Find(x => x.ID == id); return(View(projects)); }
public ActionResult Edit(int?projectID, string ProjectNo, int FundingSchemesID, int StatusID, DateTime AppealDate, DateTime SignedDate, DateTime SuppStartDate, DateTime SuppEndDate, string PlannedManMonth, decimal Budget, int SupportRate) { SuppProjects suppPr = new SuppProjects(); if (ModelState.IsValid) { if (projectID == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } suppPr = suppProjectManager.Find(x => x.ID == projectID); if (ProjectNo != null) { suppPr.ProjectNo = ProjectNo; } if (FundingSchemesID > 0) { suppPr.FundingSchemesID = FundingSchemesID; } if (StatusID > 0) { suppPr.StatusID = StatusID; } if (AppealDate != null) { suppPr.AppealDate = AppealDate; } if (SignedDate != null) { suppPr.SignedDate = SignedDate; } if (SuppStartDate != null) { suppPr.SuppStartDate = SuppStartDate; } if (SuppEndDate != null) { suppPr.SuppEndDate = SuppEndDate; } if (PlannedManMonth != null) { suppPr.PlannedManMonth = PlannedManMonth; } if (Budget > 0) { suppPr.Budget = Budget; } if (SupportRate > 0) { suppPr.SupportRate = SupportRate; } var res = suppProjectManager.Update(suppPr); if (res > 0) { ViewBag.MESAJ = "Updated"; return(RedirectToAction("Index")); } else { ViewBag.MESAJ = "Error. Please check fields."; return(Json(new { result = false }, JsonRequestBehavior.AllowGet)); } } ViewBag.MESAJ = "Server Error."; return(View(suppPr)); }