public JsonResult updateSubProject(CSubproject2 model) { string message = ""; try { pdsTidRedLiveEntities db = new pdsTidRedLiveEntities(); subProject2 p = null; if (model.subProjectID == 0) { p = new subProject2(); p.projectID = model.projectID; } else { p = db.subProject2.SingleOrDefault(x => x.subProjectID == model.subProjectID); } p.subProjectName = model.subProjectName; if (model.subProjectID == 0) { db.subProject2.Add(p); } db.SaveChanges(); } catch (Exception ex) { message = ex.Message; } return(Json(message, JsonRequestBehavior.AllowGet)); }
public ActionResult GetSubProjectList(int projectId) { CSubproject2 cs2 = new CSubproject2(); SelectList subProjList = cs2.getSubProjects(projectId); ViewBag.subProjList = subProjList; return(PartialView("GetSubProjectList")); }
public ActionResult AddEditTimeTrack2(int timeTrackRowID, int customerID, int projectID) { pdsTidRedLiveEntities db = new pdsTidRedLiveEntities(); int userId = Convert.ToInt32(Session["userId"]); SelectList custList = null; SelectList projList = null; SelectList subProjList = null; CTimeTrack model = new CTimeTrack(); CSubproject2 cs2 = new CSubproject2(); if (timeTrackRowID == 0) { model.timeTrackRowID = timeTrackRowID; model.tDate = System.DateTime.Today; model.customerID = customerID; //model.projectId = projectID; CTimeTrack ct = new CTimeTrack(); custList = ct.getMyCustomers(userId); //projList = ctc.getMyCustProjects(userId, customerID); //subProjList = cs2.getSubProjects(0); } else { timeTrackRow ttr = db.timeTrackRow.FirstOrDefault(x => x.timeTrackRowID == timeTrackRowID); if (ttr != null) { model.timeTrackHeadID = ttr.timeTrackHeadID; model.customerID = ttr.timeTrackHead.customerID; model.tDate = ttr.timeTrackHead.tDate; model.userId = ttr.timeTrackHead.userId; model.timeTrackRowID = ttr.timeTrackRowID; model.subProjectID = ttr.subProjectID; model.hours = ttr.hours; model.regDate = ttr.regDate; model.note = ttr.note; model.projectId = ttr.subProject2.projectID; model.projectName = ttr.subProject2.project.projectName; model.customerName = ttr.timeTrackHead.customer.custName; model.timeTrackHeadID = ttr.timeTrackHeadID; } // First get the timeTrackHead /* custList = ctc.getMyCustomers(0, model.customerID); * projList = ctc.getMyCustProjects(userId, ttr.timeTrackHead.customerID); */ } ViewBag.custList = custList; ViewBag.projList = projList; subProjList = cs2.getSubProjects(model.projectId); ViewBag.subProjList = subProjList; return(PartialView("AddEditTimeTrack", model)); }
public ActionResult AddEditSubProj(int subProjectID, int ProjectID) { pdsTidRedLiveEntities db = new pdsTidRedLiveEntities(); CSubproject2 model = new CSubproject2(); if (subProjectID > 0) { subProject2 p = db.subProject2.FirstOrDefault(x => x.subProjectID == subProjectID); model.subProjectID = p.subProjectID; model.subProjectName = p.subProjectName; model.projectID = p.projectID; } return(PartialView("AddEditSubProj", model)); }
public ActionResult AddEditTimeTrack(int timeTrackRowID, int customerID, int projectID) { pdsTidRedLiveEntities db = new pdsTidRedLiveEntities(); CTimeTrack model = new CTimeTrack(); int userId = Convert.ToInt32(Session["userId"]); if (timeTrackRowID == 0) { model.timeTrackRowID = 0; model.userId = userId; model.customerID = customerID; model.projectId = projectID; model.tDate = System.DateTime.Today; CTimeTrack ct = new CTimeTrack(); ViewBag.custList = ct.getMyCustomers(userId); ViewBag.projList = ct.getMyCustProjects(userId, customerID); CSubproject2 cs2 = new CSubproject2(); ViewBag.subProjList = cs2.getSubProjects(projectID); return(PartialView("AddTimeTrack", model)); } else { timeTrackRow ttr = db.timeTrackRow.FirstOrDefault(x => x.timeTrackRowID == timeTrackRowID); if (ttr != null) { model.tDate = ttr.timeTrackHead.tDate; model.subProjectID = ttr.subProjectID; model.hours = ttr.hours; model.note = ttr.note; model.projectName = ttr.subProject2.project.projectName; model.customerName = ttr.timeTrackHead.customer.custName; model.tDateStr = ttr.timeTrackHead.tDate.ToShortDateString(); model.timeTrackHeadID = ttr.timeTrackHeadID; model.customerID = ttr.timeTrackHead.customerID; CSubproject2 cs2 = new CSubproject2(); ViewBag.subProjList = cs2.getSubProjects(ttr.subProject2.projectID); } } return(PartialView("EditTimeTrack", model)); }
public JsonResult updateProject(CProject model) { string message = ""; bool bNew = false; int projID = 0; try { pdsTidRedLiveEntities db = new pdsTidRedLiveEntities(); project p = null; if (model.projectID == 0) { p = new project(); p.customerID = model.customerID; bNew = true; } else { p = db.project.SingleOrDefault(x => x.projectID == model.projectID); } p.projectName = model.projectName; p.active = model.active; if (model.projectID == 0) { db.project.Add(p); } db.SaveChanges(); projID = p.projectID; } catch (Exception ex) { message = ex.Message; } if (message == "" && bNew) { CSubproject2 cs2 = new CSubproject2(); message = cs2.addStdActivity(projID); } return(Json(message, JsonRequestBehavior.AllowGet)); }