public JsonResult RegPrj(PROJECT Project, List <PROJECT_PLAN> Plans, List <KPI> KPIs) { int result = 0; PlanManager plan = PlanManager.GetInstance(); ProjectManager prj = ProjectManager.GetInstance(); KpiManager km = KpiManager.GetInstance(); EmployeeManager em = EmployeeManager.GetInstance(); IdeaManager idea = IdeaManager.GetInstance(); string existID = prj.IsExist(Project.IDEA_ID); if (string.IsNullOrEmpty(existID)) { // generate id if (string.IsNullOrWhiteSpace(Project.IDEA_ID)) { Project.IDEA_ID = idea.GenerateId(); idea.Insert(Project.EMP_ID, Project.IDEA_TITLE, Project.BACKGROUND, "", ""); } result = prj.InsertProject(Project); if (result > 0) { foreach (var p in Plans) { plan.InsertPlan(Project.IDEA_ID, p.PLAN_CONTENTS, p.PLAN_DATE); } foreach (var kpi in KPIs) { km.InsertKPI(Project.IDEA_ID, kpi.PRJ_MONTH, kpi.TARGET_VALUE); } try { var emails = em.GetListEmail(); GMailer.GmailUsername = "******"; GMailer.GmailPassword = "******"; GMailer mailer = new GMailer(); mailer.Subject = "[Project Management - New project uploaded]"; mailer.Body = " Employee " + Project.EMP_ID + " Has uploaded a project: " + Project.IDEA_TITLE + ".<br> Please check it out at<br> <a href='http://172.25.215.17/idea'>Project Management</a>"; mailer.IsHtml = true; foreach (var email in emails) { mailer.ToEmail = email.EMAIL.Trim(); mailer.Send(); } } catch { return(Json(result)); } } } else { } return(Json(result)); }
public JsonResult UpdateProject(PROJECT Project, List <PROJECT_PLAN> Plans, List <KPI> KPIs) { int result = 0; PlanManager plan = PlanManager.GetInstance(); ProjectManager prj = ProjectManager.GetInstance(); KpiManager km = KpiManager.GetInstance(); string existID = prj.IsExist(Project.IDEA_ID); if (!string.IsNullOrEmpty(existID)) { result = prj.UpdatePrj(Project.IDEA_ID, Project.EMP_ID, Project.IDEA_TITLE, Project.KPI_NAME, Project.KPI_UNIT, Project.REMARK, Project.NAME, Project.PRJ_CURR, Project.CURR_VALUE, Project.PRJECT_GRADE, Project.ATTACHMENT, Project.ISSUE, Project.REQUEST); if (result > 0) { if (Plans != null) { foreach (var p in Plans) { if (string.IsNullOrWhiteSpace(p.ID)) { plan.InsertPlan(p.IDEA_ID, p.PLAN_CONTENTS, p.PLAN_DATE, p.COMPLETE_YN, p.COMPLETE_DATE); } else { plan.Update(p.IDEA_ID, p.PLAN_CONTENTS, p.PLAN_DATE, p.COMPLETE_YN, p.COMPLETE_DATE, p.ID); } } } if (KPIs != null) { foreach (var kpi in KPIs) { if (!string.IsNullOrWhiteSpace(kpi.ID)) { km.Update(kpi.IDEA_ID, kpi.PRJ_MONTH, kpi.TARGET_VALUE, kpi.RESULT_VALUE, kpi.ID); } else { km.InsertKPI(kpi.IDEA_ID, kpi.PRJ_MONTH, kpi.TARGET_VALUE, kpi.RESULT_VALUE); } } } } } return(Json(result)); }