Exemple #1
0
        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));
        }
Exemple #2
0
        public JsonResult RegIdea(IDEA idea, string division, string department, int action)
        {
            EmployeeManager em           = EmployeeManager.GetInstance();
            IdeaManager     ideaManager  = IdeaManager.GetInstance();
            int             affectedRows = 0;

            if (action == 0)
            {
                affectedRows = ideaManager.Insert(idea.EMP_ID, idea.IDEA_TITLE, idea.DETAIL, idea.QUANTITATIVE, idea.QUALITATIVE);
                if (affectedRows > 0)
                {
                    try
                    {
                        var emails = em.GetListEmail();
                        GMailer.GmailUsername = "******";
                        GMailer.GmailPassword = "******";

                        GMailer mailer = new GMailer();

                        mailer.Subject = "[Project Management - New idea uploaded]";
                        mailer.Body    = " Employee " + idea.EMP_ID + " Has uploaded an idea: " + idea.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(affectedRows));
                    }
                }
            }
            else
            {
                affectedRows = ideaManager.Update(idea.ID, idea.EMP_ID, idea.IDEA_TITLE, idea.DETAIL, idea.QUANTITATIVE, idea.QUALITATIVE);
            }
            if (!string.IsNullOrWhiteSpace(division))
            {
                em.UpdateDivision(idea.EMP_ID, division.Trim());
            }
            if (!string.IsNullOrWhiteSpace(department))
            {
                em.UpdateDepartment(idea.EMP_ID, department.Trim());
            }

            return(Json(affectedRows));
        }