Beispiel #1
0
        public ActionResult SaveEdit(ProjectModel Model)
        {
            string status = null;
            var    p      = db.Projects.Where(m => m.ProjectID == Model.ProjectID).FirstOrDefault();

            p.Name        = Model.ProjectName;
            p.Description = Model.ProjectDescription;
            if (Model.status.ToString() == "หยุดดำเนินการ")
            {
                p.Status = 3;
            }
            else if (Model.status.ToString() == "พัก")
            {
                p.Status = 2;
            }
            else if (Model.status.ToString() == "ดำเนินการ")
            {
                p.Status = 1;
            }
            if (Model.SIT.ToString() == "ใช่")
            {
                p.SIT_Menu = 1;
            }
            else if (Model.SIT.ToString() == "ไม่ใช่")
            {
                p.SIT_Menu = 0;
            }
            p.UpdateDate = DateTime.Now;
            p.UpdateBy   = Convert.ToInt32(Session["userID"]);
            db.SaveChanges();
            var PM = db.Users.Where(m => m.User_ID == p.CreateBy).FirstOrDefault();
            var p2 = db.ProjectMembers.Where(m => m.ProjectID == Model.ProjectID).ToList();

            foreach (var e in p2)
            {
                var    Email  = db.Users.Where(m => m.User_ID == e.UserID).FirstOrDefault();
                string sender = PM.User_Email;
                //string sender = "*****@*****.**";
                string subject  = Model.ProjectName;
                string receiver = Email.User_Email;
                //string receiver = "*****@*****.**";
                if (Convert.ToInt32(Model.status) == 1)
                {
                    status = "ดำเนินการ";
                }
                else if (Convert.ToInt32(Model.status) == 2)
                {
                    status = "พัก";
                }
                else if (Convert.ToInt32(Model.status) == 1)
                {
                    status = "หยุดดำเนินการ";
                }
                string          mess = "<html><body><p>โครงการ " + Model.ProjectName + "</p><p> ได้มีการแก้ไขข้อมูลสถานะของโครงการ " + status + " วันที่ที่แก้ไข " + p.UpdateDate.ToString() + "ผู้แก้ไขคือคุณ " + PM.User_Name + " " + PM.User_LastName + "</p></body></html>";
                InboxController i    = new InboxController();
                i.SendEmail(receiver, subject, mess, sender);
            }
            return(RedirectToAction("ShowProject"));
        }
Beispiel #2
0
        public ActionResult DeleteProject(int ProjectID)
        {
            Project d = db.Projects.Where(m => m.ProjectID == ProjectID).FirstOrDefault();
            var     t = db.Tasks.Where(m => m.ProjectID == d.ProjectID).ToList();

            foreach (var item in t)
            {
                var st = db.SubTasks.Where(m => m.TaskID == item.TaskID).ToList();
                foreach (var item2 in st)
                {
                    var df = db.Defects.Where(m => m.Sub_ID == item2.SubDevID).ToList();
                    foreach (var item3 in df)
                    {
                        db.Defects.Remove(item3);
                    }
                    db.SubTasks.Remove(item2);
                }
                var sit_t = db.SITs.Where(m => m.Project_ID == d.ProjectID).ToList();
                foreach (var item4 in sit_t)
                {
                    var step = db.SITSteps.Where(m => m.SIT_ID == item4.SIT_ID).ToList();
                    foreach (var item5 in step)
                    {
                        db.SITSteps.Remove(item5);
                    }
                    db.SITs.Remove(item4);
                }
                db.Tasks.Remove(item);
            }
            var dc = db.Documents.Where(m => m.Project_ID == ProjectID).ToList();

            foreach (var item6 in dc)
            {
                db.Documents.Remove(item6);
            }
            var CreateBy = db.Users.Where(m => m.User_ID == d.CreateBy).FirstOrDefault();
            var pm       = db.ProjectMembers.Where(s => s.ProjectID == ProjectID).ToList();

            foreach (var c in pm)
            {
                DateTime time   = DateTime.Now;
                var      Email  = db.Users.Where(m => m.User_ID == c.UserID).FirstOrDefault();
                string   sender = Email.User_Email;
                //string sender = "*****@*****.**";
                string subject = d.Name;
                //string receiver = d.CreateBy.ToString(); รอส่งเมล์ให้ทั้งทีม
                string          receiver = "*****@*****.**";
                string          mess     = "<html><body><p>โครงการ" + d.Name + "</p><p>ได้ถูกลบ" + "ผู้ลบโครงการ" + CreateBy.User_Name + " " + CreateBy.User_LastName + "วันที่" + time + "</p></html></body>";
                InboxController i        = new InboxController();
                i.SendEmail(receiver, subject, mess, sender);
                db.ProjectMembers.Remove(c);
            }
            db.Projects.Remove(d);
            db.SaveChanges();
            return(RedirectToAction("ShowProject"));
        }
        public ActionResult DeleteDefect(int DefectID)
        {
            var i = db.Defects.Where(m => m.Defect_ID == DefectID).FirstOrDefault();

            System.IO.File.Delete("C:/Users/SWNGMN/source/repos/SystemManage/SystemManage/SystemManage" + i.AttachFile);
            db.Defects.Remove(i);
            db.SaveChanges();
            var    Email  = db.Users.Where(m => m.User_ID == i.CreateBy).FirstOrDefault();
            var    u      = db.SubTasks.Where(m => m.SubID == i.Sub_ID).FirstOrDefault();
            var    Sendto = db.Users.Where(m => m.User_ID == u.SubDevID).FirstOrDefault();
            string sender = Email.User_Email.ToString();
            //string sender = "*****@*****.**";
            string subject  = "Defect" + u.SubName;
            string receiver = Sendto.User_Email.ToString();
            //string receiver = "*****@*****.**";
            string          mess = "ได้ลบหัวข้อ" + u.SubName;
            InboxController ms   = new InboxController();

            ms.SendEmail(receiver, subject, mess, sender);
            return(RedirectToAction("ShowDefect", "Defect"));
        }
Beispiel #4
0
        public ActionResult DeleteMember(int UserID)
        {
            int ProjectID = Convert.ToInt32(Session["ProjectID"]);
            var pm        = db.ProjectMembers.Where(m => m.UserID == UserID && m.ProjectID == ProjectID).FirstOrDefault();

            db.ProjectMembers.Remove(pm);
            db.SaveChanges();
            var    Cb      = db.Projects.Where(m => m.ProjectID == pm.ProjectID).FirstOrDefault();
            var    Email   = db.Users.Where(m => m.User_ID == Cb.CreateBy).FirstOrDefault();
            var    Sendto  = db.Users.Where(m => m.User_ID == UserID).FirstOrDefault();
            var    project = db.Projects.Where(m => m.ProjectID == pm.ProjectID).FirstOrDefault();
            string sender  = Email.User_Email.ToString();
            //string sender = "*****@*****.**";
            string subject   = Cb.Name;
            string receiver  = Sendto.User_Email.ToString();
            string Exit_Date = string.Format("{0:dd/MM/yyyy}", DateTime.Now);
            //string receiver = "*****@*****.**";
            string          mess = "<html><body><p>ถึงคุณ" + Sendto.User_Name + " " + Sendto.User_LastName + "</p><p>&nbsp;&nbsp;&nbsp;&nbsp; คุณถูกเชิญออกจากโครงการ " + project.Name + " ณ วันที่ " + Exit_Date + "หากมีข้อสงสัยกรุณาติดต่อกับหัวหน้าโครงการ คุณ" + Email.User_Name + " " + Email.User_LastName + "</p><p>" + Email.User_Name + " " + Email.User_LastName + "</p></body></html>";
            InboxController i    = new InboxController();

            i.SendEmail(receiver, subject, mess, sender);
            return(RedirectToAction("ShowMember", "Member"));
        }
        public ActionResult DeleteTask(int SubID)
        {
            var st = db.SubTasks.Where(m => m.SubID == SubID).FirstOrDefault();
            var t  = db.Tasks.Where(m => m.TaskID == st.TaskID).FirstOrDefault();
            var d  = db.SubTasks.Where(m => m.TaskID == t.TaskID).ToList();

            if (st.AttachFile != null)
            {
                System.IO.File.Delete("C:/Users/SWNGMN/source/repos/SystemManage/SystemManage/SystemManage" + st.AttachFile);
            }
            db.SubTasks.Remove(st);
            db.SaveChanges();
            var d2 = db.SubTasks.Where(m => m.TaskID == t.TaskID).ToList();

            if (d2.Count == 0)
            {
                if (t.AttachFile != null)
                {
                    System.IO.File.Delete("C:/Users/SWNGMN/source/repos/SystemManage/SystemManage/SystemManage" + t.AttachFile);
                }
                db.Tasks.Remove(t);
                db.SaveChanges();
            }
            var    Email  = db.Users.Where(m => m.User_ID == t.CreateBy).FirstOrDefault();
            var    Sendto = db.Users.Where(m => m.User_ID == st.Handle).FirstOrDefault();
            string sender = Email.User_Email.ToString();
            //string sender = "*****@*****.**";
            string subject  = t.TaskName + "" + st.SubName;
            string receiver = Sendto.User_Email.ToString();
            //string receiver = "*****@*****.**";
            string          mess = "ยืนยันการทำงานของงาน" + t.TaskName + "และมีมีงานรองคือ" + st.SubName;
            InboxController i    = new InboxController();

            i.SendEmail(receiver, subject, mess, sender);
            return(RedirectToAction("ShowTask"));
        }
Beispiel #6
0
        public ActionResult AddMember(int UserID)
        {
            if ((Session["userID"]) == null)
            {
                return(RedirectToAction("Index", "Login"));
            }
            ProjectMember pm = new ProjectMember();

            pm.UserID    = UserID;
            pm.ProjectID = Convert.ToInt32(Session["ProjectID"]);
            var PoList = db.Users.Where(m => m.User_ID == UserID).FirstOrDefault();

            if (PoList.Position_ID == 113)//PositionID = 113 Dev
            {
                pm.Role        = 2;
                pm.Member_name = PoList.NickName;
                db.ProjectMembers.Add(pm);
                db.SaveChanges();
                //return RedirectToAction("ListMember");
            }
            else if (PoList.Position_ID == 110)//PositionID = 110 Tester
            {
                pm.Role        = 3;
                pm.Member_name = PoList.NickName;
                db.ProjectMembers.Add(pm);
                db.SaveChanges();
                //return RedirectToAction("ListMember");
            }
            else if (PoList.Position_ID == 142)//PositionID = 142 QA
            {
                pm.Role        = 4;
                pm.Member_name = PoList.NickName;
                db.ProjectMembers.Add(pm);
                db.SaveChanges();
                //return RedirectToAction("ListMember");
            }
            else if (PoList.Position_ID == 143)//PositionID = 143 ลูกค้า
            {
                pm.Role        = 5;
                pm.Member_name = PoList.NickName;
                db.ProjectMembers.Add(pm);
                db.SaveChanges();
                //return RedirectToAction("ListMember");
            }
            else //ถ้าไม่เข้าเงื่อไขให้เป็น Dev ทั้งหมด
            {
                pm.Role        = 2;
                pm.Member_name = PoList.NickName;
                db.ProjectMembers.Add(pm);
                db.SaveChanges();
            }
            ///////////////////////////////////////
            var    Cb      = db.Projects.Where(m => m.ProjectID == pm.ProjectID).FirstOrDefault();
            var    Email   = db.Users.Where(m => m.User_ID == Cb.CreateBy).FirstOrDefault();
            var    Sendto  = db.Users.Where(m => m.User_ID == UserID).FirstOrDefault();
            var    project = db.Projects.Where(m => m.ProjectID == pm.ProjectID).FirstOrDefault();
            string sender  = Email.User_Email.ToString();
            //string sender = "*****@*****.**";
            string subject    = Cb.Name;
            string receiver   = Sendto.User_Email.ToString();
            string SendDate   = string.Format("{0:dd/MM/yyyy}", project.SendDate);
            string CreateDate = string.Format("{0:dd/MM/yyyy}", project.CreateDate);
            //string receiver = "*****@*****.**";
            string mess = "<html><body><p>ถึงคุณ" + Sendto.User_Name + " " + Sendto.User_LastName + "</p><p>&nbsp;&nbsp;&nbsp;&nbsp; คุณได้รับสิทธิ์ในการเข้าถึงโครงการ " + project.Name + " มีรายละเอียดโครงการดังนี้  " + project.Description + " กำหนดส่งวันที่ " + SendDate + " สร้างเมื่อวันที่ " + CreateDate + " มีหัวหน้าโครงการคือคุณ " + Email.User_Name + " " + Email.User_LastName + "</p><p></p>" + Email.User_Name + " " + Email.User_LastName + "</body></html>";

            InboxController i = new InboxController();

            i.SendEmail(receiver, subject, mess, sender);
            return(RedirectToAction("ListMember"));
        }
        public ActionResult SendTask(int SubID)
        {
            int ProjectID           = Convert.ToInt32(Session["ProjectID"]);
            int userID              = Convert.ToInt32(Session["userID"]);
            SubTaskSubmisstion ts   = new SubTaskSubmisstion();
            SubTask            st   = db.SubTasks.Where(m => m.SubID == SubID).FirstOrDefault();
            Task          t         = db.Tasks.Where(m => m.TaskID == st.TaskID).FirstOrDefault();
            User          PointCode = db.Users.Where(m => m.User_ID == userID).FirstOrDefault();
            ProjectMember r         = db.ProjectMembers.Where(m => m.ProjectID == ProjectID && m.UserID == userID).FirstOrDefault();

            //Dev
            if (r.Role == 2)
            {
                st.SubStatus  = 1;
                st.SubPercent = 25;
                st.Handle     = t.TestID;
                st.UpdateDate = DateTime.Now;
                st.UpdateBy   = Convert.ToInt32(Session["userID"]);
                ++st.RoundCoding;
                ++PointCode.TotalCoding;
                db.SaveChanges();
                t.UpdateDate = DateTime.Now;
                t.UpdateBy   = Convert.ToInt32(Session["userID"]);
                db.SaveChanges();
                ts.SubID      = st.SubID;
                ts.HandleBy   = t.TestID;
                ts.SubmitDate = DateTime.Now;
                ts.AssignDate = t.CreateDate;
                ts.Deadline   = t.TestSentDate;
                db.SubTaskSubmisstions.Add(ts);
                db.SaveChanges();
                var    Email  = db.Users.Where(m => m.User_ID == st.UpdateBy).FirstOrDefault();
                var    Sendto = db.Users.Where(m => m.User_ID == t.TestID).FirstOrDefault();
                string sender = Email.User_Email.ToString();
                //string sender = "*****@*****.**";
                string subject  = t.TaskName + "" + st.SubName;
                string receiver = Sendto.User_Email.ToString();
                //string receiver = "*****@*****.**";
                string          mess = "<html><body><p>ถึงคูณ " + Sendto.User_Name + " " + Sendto.User_LastName + ",</p><p>&nbsp;&nbsp;&nbsp;&nbsp; งาน " + t.TaskName + "</p><p>ผู้พัฒนาระบบได้ทำการยืนยันการทำรายการส่งต่อไปยังผู้ทดสอบระบบ กำหนดส่งภายในวันที่ " + string.Format("{0:dd/MM/yyyy}", t.TestSentDate) + "</p><p>รายละเอียดงานมีดังนี้</p><p>" + t.DescriptionTask + " และรายละเอียดเพิ่มของผู้พัฒนาระบบ  " + t.DescriptionTest + "</p><p>############################</p><p>" + Email.User_Name + " " + Email.User_LastName + "</p></body></html>";
                InboxController i    = new InboxController();
                i.SendEmail(receiver, subject, mess, sender);
                if (st.SubDevSend >= st.UpdateDate)
                {
                    PointCode.Amount_Succ = PointCode.Amount_Succ + 1;
                    db.SaveChanges();
                }
                else if (st.SubDevSend < st.UpdateDate)
                {
                    PointCode.Amount_Non = PointCode.Amount_Non + 1;
                    db.SaveChanges();
                }
                Session["Save"] = 0;
                return(RedirectToAction("ShowTask"));
            }
            //Tester
            else if (r.Role == 3)
            {
                st.SubStatus  = 2;
                st.SubPercent = 50;
                st.Handle     = t.QAID;
                st.UpdateDate = DateTime.Now;
                st.UpdateBy   = Convert.ToInt32(Session["userID"]);
                db.SaveChanges();
                t.UpdateDate = DateTime.Now;
                t.UpdateBy   = Convert.ToInt32(Session["userID"]);
                db.SaveChanges();
                ts.SubID      = st.SubID;
                ts.HandleBy   = t.QAID;
                ts.SubmitDate = DateTime.Now;
                ts.AssignDate = t.CreateDate;
                ts.Deadline   = t.QASentDate;
                db.SubTaskSubmisstions.Add(ts);
                db.SaveChanges();
                var    Email  = db.Users.Where(m => m.User_ID == st.UpdateBy).FirstOrDefault();
                var    Sendto = db.Users.Where(m => m.User_ID == t.QAID).FirstOrDefault();
                string sender = Email.User_Email.ToString();
                //string sender = "*****@*****.**";
                string subject  = t.TaskName + "" + st.SubName;
                string receiver = Sendto.User_Email.ToString();
                //string receiver = "*****@*****.**";
                string          mess = "<html><body><p>ถึงคูณ " + Sendto.User_Name + " " + Sendto.User_LastName + ",</p><p>&nbsp;&nbsp;&nbsp;&nbsp; งาน " + t.TaskName + "</p><p>ผู้ทดสอบได้ทำการยืนยันการทำรายการส่งต่อไปยังผู้ตรวจคุณภาพ กำหนดส่งภายในวันที่ " + string.Format("{0:dd/MM/yyyy}", t.QASentDate) + "</p><p>รายละเอียดงานมีดังนี้</p><p>" + t.DescriptionTask + " และรายละเอียดเพิ่มของผู้พัฒนาระบบ  " + t.DescriptionQA + "</p><p>############################</p><p>" + Email.User_Name + " " + Email.User_LastName + "</p></body></html>";
                InboxController i    = new InboxController();
                i.SendEmail(receiver, subject, mess, sender);
                if (t.TestSentDate >= t.UpdateDate)
                {
                    PointCode.Amount_Succ = PointCode.Amount_Succ + 1;
                    db.SaveChanges();
                }
                else if (t.TestSentDate < t.UpdateDate)
                {
                    PointCode.Amount_Non = PointCode.Amount_Non + 1;
                    db.SaveChanges();
                }
                Session["Save"] = 0;
                return(RedirectToAction("ShowTask"));
            }
            //QA
            else if (r.Role == 4)
            {
                st.SubStatus  = 3;
                st.SubPercent = 75;
                st.UpdateDate = DateTime.Now;
                st.Handle     = 0; //ลูกค้า
                st.UpdateBy   = Convert.ToInt32(Session["userID"]);
                db.SaveChanges();
                t.UpdateDate = DateTime.Now;
                t.UpdateBy   = Convert.ToInt32(Session["userID"]);
                db.SaveChanges();
                ts.SubID      = st.SubID;
                ts.HandleBy   = t.QAID;
                ts.SubmitDate = DateTime.Now;
                ts.AssignDate = t.CreateDate;
                ts.Deadline   = t.QASentDate;
                db.SubTaskSubmisstions.Add(ts);
                db.SaveChanges();
                var    Email  = db.Users.Where(m => m.User_ID == st.UpdateBy).FirstOrDefault();
                var    Sendto = db.Users.Where(m => m.User_ID == t.CreateBy).FirstOrDefault();
                string sender = Email.User_Email.ToString();
                //string sender = "*****@*****.**";
                string subject  = t.TaskName + "" + st.SubName;
                string receiver = Sendto.User_Email.ToString();
                //string receiver = "*****@*****.**";
                string          mess = "<html><body><p>ถึงคูณ " + Sendto.User_Name + " " + Sendto.User_LastName + ",</p><p>&nbsp;&nbsp;&nbsp;&nbsp; งาน " + t.TaskName + "</p><p>ผู้ตรวจสอบได้ทำการยืนยันการทำรายการส่งต่อไปยังลูกค้าเพื่อยืนยันการทำงาน กำหนดส่งภายในวันที่ </p><p>รายละเอียดงานมีดังนี้</p><p>" + t.DescriptionTask + " และรายละเอียดเพิ่มของผู้พัฒนาระบบ  " + t.DescriptionQA + "</p><p>############################</p><p>" + Email.User_Name + " " + Email.User_LastName + "</p></body></html>";
                InboxController i    = new InboxController();
                i.SendEmail(receiver, subject, mess, sender);
                if (t.QASentDate >= t.UpdateDate)
                {
                    PointCode.Amount_Succ = PointCode.Amount_Succ + 1;
                    db.SaveChanges();
                }
                else if (t.QASentDate < t.UpdateDate)
                {
                    PointCode.Amount_Non = PointCode.Amount_Non + 1;
                    db.SaveChanges();
                }
                Session["Save"] = 0;
                return(RedirectToAction("ShowTask"));
            }
            //CM
            else if (r.Role == 5)
            {
                st.SubStatus  = 4;
                st.SubPercent = 100;
                st.UpdateDate = DateTime.Now;
                st.Handle     = Convert.ToInt32(Session["userID"]);
                st.UpdateBy   = Convert.ToInt32(Session["userID"]);
                db.SaveChanges();
                t.UpdateDate = DateTime.Now;
                t.UpdateBy   = Convert.ToInt32(Session["userID"]);
                db.SaveChanges();
                ts.SubID      = st.SubID;
                ts.HandleBy   = Convert.ToInt32(Session["userID"]);
                ts.SubmitDate = DateTime.Now;
                ts.AssignDate = t.CreateDate;
                ts.Deadline   = DateTime.Now;
                db.SubTaskSubmisstions.Add(ts);
                db.SaveChanges();
                var    Email  = db.Users.Where(m => m.User_ID == st.UpdateBy).FirstOrDefault();
                var    Sendto = db.Users.Where(m => m.User_ID == t.CreateBy).FirstOrDefault();
                string sender = Email.User_Email.ToString();
                //string sender = "*****@*****.**";
                string subject  = t.TaskName + "" + st.SubName;
                string receiver = Sendto.User_Email.ToString();
                //string receiver = "*****@*****.**";
                string          mess = "<html><body><p>ถึงคูณ " + Sendto.User_Name + " " + Sendto.User_LastName + ",</p><p>&nbsp;&nbsp;&nbsp;&nbsp; งาน " + t.TaskName + "</p><p>ลูกค้าได้ทำการยืนยันงานที่ได้สร้างขึ้นถูกต้องตามความต้อง </p><p>รายละเอียดงานมีดังนี้</p><p>" + t.DescriptionTask + " และรายละเอียดเพิ่มของผู้พัฒนาระบบ  " + t.DescriptionQA + "</p><p>############################</p><p>" + Email.User_Name + " " + Email.User_LastName + "</p></body></html>";
                InboxController i    = new InboxController();
                i.SendEmail(receiver, subject, mess, sender);
                Session["Save"] = 0;
                return(RedirectToAction("ShowTask"));
            }
            return(RedirectToAction("ShowTask"));
        }
        public ActionResult EditTask(TaskModel model)
        {
            int ProjectID           = Convert.ToInt32(Session["ProjectID"]);
            int userID              = Convert.ToInt32(Session["userID"]);
            SubTaskSubmisstion ts   = new SubTaskSubmisstion();
            SubTask            st   = db.SubTasks.Where(m => m.SubID == model.SubTaskID).FirstOrDefault();
            Task          t         = db.Tasks.Where(m => m.TaskID == st.TaskID).FirstOrDefault();
            User          PointCode = db.Users.Where(m => m.User_ID == userID).FirstOrDefault();
            ProjectMember r         = db.ProjectMembers.Where(m => m.ProjectID == ProjectID && m.UserID == userID).FirstOrDefault();

            //PM
            if (r.Role == 1)
            {
                st.SubName           = model.SubTaskNames;
                st.SubDevID          = model.SubDevID;
                st.SubDescriptionDev = model.SubTasksDes;
                st.SubDevSend        = model.SubTaskDateSend;
                st.Handle            = model.SubDevID;
                st.SubStatus         = 0;
                st.SubPercent        = 0;
                st.UpdateBy          = Convert.ToInt32(Session["userID"]);
                st.UpdateDate        = DateTime.Now;
                if (model.AttachFile_Task != null)
                {
                    var      Upload_Sub = Upload_FileTask(model.AttachFile_Task);
                    string[] txt        = Upload_Sub.Split(",".ToCharArray());
                    string   fileName   = txt[1];
                    st.AttachFile = txt[0];
                    st.AttachShow = fileName;
                }
                db.SaveChanges();
                t.TaskName = model.TaskName;
                if (model.level.ToString() == "ง่าย")
                {
                    t.Task_level = 1;
                }
                else if (model.level.ToString() == "ปานกลาง")
                {
                    t.Task_level = 2;
                }
                else if (model.level.ToString() == "ยาก")
                {
                    t.Task_level = 3;
                }
                t.DescriptionTask = model.DescriptionTask;
                t.TestID          = model.TestID;
                t.DescriptionTest = model.DescriptionTest;
                t.TestSentDate    = model.TestSentDate;
                t.TestStatus      = 0;
                t.QAID            = model.QAID;
                t.DescriptionQA   = model.DescriptionQA;
                t.QASentDate      = model.QASentDate;
                t.QAStatus        = 0;
                if (model.AttachFile != null)
                {
                    var      Upload_Task = Upload_FileTask(model.AttachFile);
                    string[] txt_Name    = Upload_Task.Split(",".ToCharArray());
                    t.AttachFile = txt_Name[0];
                    t.AttachShow = txt_Name[1];
                }
                t.UpdateDate = DateTime.Now;
                t.UpdateBy   = Convert.ToInt32(Session["userID"]);
                db.SaveChanges();
                ts.SubID      = st.SubID;
                ts.HandleBy   = st.SubDevID;
                ts.SubmitDate = DateTime.Now;
                ts.AssignDate = st.CreateDate;
                ts.Deadline   = st.SubDevSend;
                db.SubTaskSubmisstions.Add(ts);
                db.SaveChanges();
                var    Email  = db.Users.Where(m => m.User_ID == t.CreateBy).FirstOrDefault();
                var    Sendto = db.Users.Where(m => m.User_ID == model.SubDevID).FirstOrDefault();
                string sender = Email.User_Email.ToString();
                //string sender = "*****@*****.**";
                string subject  = t.TaskName + " " + st.SubName;
                string receiver = Sendto.User_Email.ToString();
                //string receiver = "*****@*****.**";
                string          mess = "<html><body><p>ถึงคูณ " + Sendto.User_Name + " " + Sendto.User_LastName + ",</p><p>&nbsp;&nbsp;&nbsp;&nbsp; " + model.TaskName + " มีการแก้ไขรายละเอียดของงาน</p><p><p>รายละเอียดมีดังนี้</p>กำหนดส่งภายในวันที่ " + string.Format("{0:dd/MM/yyyy}", model.SubTaskDateSend) + "</p><p>รายละเอียดงานมีดังนี้</p><p>" + model.DescriptionTask + " และรายละเอียดเพิ่มของผู้พัฒนา  " + model.SubTasksDes + "</p><p>############################</p><p>" + Email.User_Name + " " + Email.User_LastName + "</p></body></html>";
                InboxController i    = new InboxController();
                i.SendEmail(receiver, subject, mess, sender);
                return(RedirectToAction("ShowTask", "Task"));
            }
            //Dev
            else if (r.Role == 2)
            {
                st.Comment_Dev = model.Comment_Dev;
                db.SaveChanges();
                Session["Save"] = 1;
                return(RedirectToAction("DetailTask", "Task", new { SubID = model.SubTaskID }));
            }
            //Tester
            else if (r.Role == 3)
            {
                st.Comment_Tester = model.Comment_Tester;
                db.SaveChanges();
                Session["Save"] = 1;
                return(RedirectToAction("DetailTask", "Task", new { SubID = model.SubTaskID }));
            }
            //QA
            else if (r.Role == 4)
            {
                st.Comment_QA = model.Comment_QA;
                db.SaveChanges();
                Session["Save"] = 1;
                return(RedirectToAction("DetailTask", "Task", new { SubID = model.SubTaskID }));
            }
            //CM
            else if (r.Role == 5)
            {
                st.Comment_CM = model.Comment_CM;
                db.SaveChanges();
                Session["Save"] = 1;
                return(RedirectToAction("DetailTask", "Task", new { SubID = model.SubTaskID }));
            }
            return(RedirectToAction("ShowTask"));
        }
 public ActionResult AddTask(TaskModel model, SubTask modelSub)
 {
     try {
         InboxController sendMail = new InboxController();
         Task            t        = new Task();
         SubTask         st       = new SubTask();
         InboxController e        = new InboxController();
         t.ProjectID       = Convert.ToInt32(Session["ProjectID"]);
         t.TaskName        = model.TaskName;
         t.DescriptionTask = model.DescriptionTask;
         t.TotalPercent    = 0;
         if (model.level.ToString() == "ง่าย")
         {
             t.Task_level = 1;
         }
         else if (model.level.ToString() == "ปานกลาง")
         {
             t.Task_level = 3;
         }
         else if (model.level.ToString() == "ยาก")
         {
             t.Task_level = 5;
         }
         t.DescriptionTest = model.DescriptionTest;
         t.TestID          = model.TestID; //เลือกการค้นหาจาก Table Member ที่ Role เป็น Tester = 4
         t.TestSentDate    = model.TestSentDate;
         t.TestStatus      = model.TestStatus;
         t.DescriptionQA   = model.DescriptionQA;
         t.QAID            = model.QAID; //เลือกการค้นหาจาก Table Member ที่ Role เป็น QA = 3
         t.QASentDate      = model.QASentDate;
         t.QAStatus        = model.QAStatus;
         if (model.AttachFile != null)
         {
             var      Upload   = Upload_FileTask(model.AttachFile);
             string[] txt      = Upload.Split(",".ToCharArray());
             string   fileName = txt[1];
             t.AttachFile = txt[0];
             t.AttachShow = fileName;
         }
         t.CreateDate = DateTime.Now;
         t.CreateBy   = Convert.ToInt32(Session["userID"]);
         db.Tasks.Add(t);
         db.SaveChanges();
         //var tester = db.Tasks.Where(m => m.TestID == model.TestID).ToList();
         //float total_tester = 0;
         //foreach (var item in tester)
         //{
         //    total_tester = total_tester + item.Task_level;
         //}
         //total_tester = total_tester / tester.Count;
         //var User_Tester = db.Users.Where(m => m.User_ID == model.TestID).FirstOrDefault();
         //User_Tester.AVG = total_tester;
         //db.SaveChanges();
         //var QA = db.Tasks.Where(m => m.QAID == model.QAID).ToList();
         //float total_QA = 0;
         //foreach (var item2 in QA)
         //{
         //    total_QA = total_QA + item2.Task_level;
         //}
         //total_QA = total_QA / QA.Count;
         //var User_QA = db.Users.Where(m => m.User_ID == model.QAID).FirstOrDefault();
         //User_QA.AVG = total_QA;
         //db.SaveChanges();
         /////////////////////////////////////
         var    Host        = db.Users.Where(m => m.User_ID == t.CreateBy).FirstOrDefault();
         var    recevier    = db.Users.Where(m => m.User_ID == model.TestID).FirstOrDefault();
         var    QA_Recevier = db.Users.Where(m => m.User_ID == model.QAID).FirstOrDefault();
         string senders     = Host.User_Email.ToString();
         //string sender = "*****@*****.**";
         string subjects         = t.TaskName + "" + st.SubName;
         string receivers_Tester = recevier.User_Email.ToString();
         //string receiver = "*****@*****.**";
         string messs_Tester = "<html><body><p>ถึงคูณ " + recevier.User_Name + " " + recevier.User_LastName + ",</p><p>&nbsp;&nbsp;&nbsp;&nbsp; คุณได้รับมอบหมายงาน  " + model.TaskName + "(" + model.level + ")" + "</p><p>กำหนดส่งภายในวันที่ " + string.Format("{0:dd/MM/yyyy}", model.TestSentDate) + "</p><p>รายละเอียดงานมีดังนี้</p><p>" + model.DescriptionTask + " และรายละเอียดเพิ่มของผู้ทดสอบ  " + model.DescriptionTest + "</p><p>############################</p><p>" + Host.User_Name + " " + Host.User_LastName + "</p></body></html>";
         e.SendEmail(receivers_Tester, subjects, messs_Tester, senders);
         ///////////////////////////////////////
         string receivers_QA = QA_Recevier.User_Email.ToString();
         //string receiver = "*****@*****.**";
         string messs_QA = "<html><body><p>ถึงคูณ " + QA_Recevier.User_Name + " " + QA_Recevier.User_LastName + ",</p><p>&nbsp;&nbsp;&nbsp;&nbsp; คุณได้รับมอบหมายงาน  " + model.TaskName + "(" + model.level + ")" + "</p><p>กำหนดส่งภายในวันที่ " + string.Format("{0:dd/MM/yyyy}", model.QASentDate) + "</p><p>รายละเอียดงานมีดังนี้</p><p>" + model.DescriptionTask + " และรายละเอียดเพิ่มของผู้ตรวจสอบ  " + model.DescriptionQA + "</p><p>############################</p><p>" + Host.User_Name + " " + Host.User_LastName + "</p></body></html>";
         e.SendEmail(receivers_QA, subjects, messs_QA, senders);
         var count = model.SubTasksName.Count;
         if (count > 1)
         {
             for (int item = 0; item < count; item++)
             {
                 st.TaskID            = t.TaskID;
                 st.SubName           = model.SubTasksName[item].ToString();
                 st.SubDescriptionDev = model.SubTasksDis[item].ToString();
                 st.SubDevID          = model.SubTaskDevID[item];//เลือกการค้นหาจาก Table Member ที่ Role เป็น Dev = 2
                 st.SubPercent        = 0;
                 st.Handle            = model.SubTaskDevID[item];
                 st.SubStatus         = 0;
                 st.SubDevSend        = model.SubTaskSendDate[item];
                 st.CreateDate        = DateTime.Now;
                 st.CreateBy          = Convert.ToInt32(Session["userID"]);
                 if (model.AttachFile_List[item] != null)
                 {
                     var      Upload_Sub = Upload_FileTask(model.AttachFile_List[item]);
                     string[] txt        = Upload_Sub.Split(",".ToCharArray());
                     string   fileName   = txt[1];
                     st.AttachFile = txt[0];
                     st.AttachShow = fileName;
                 }
                 db.SubTasks.Add(st);
                 db.SaveChanges();
                 var Sendtos = db.Users.Where(m => m.User_ID == st.SubDevID).FirstOrDefault();
                 //string sender = "*****@*****.**";
                 string receiversDev = Sendtos.User_Email.ToString();
                 //string receiver = "*****@*****.**";
                 string messs_Dev = "<html><body><p>ถึงคูณ " + Sendtos.User_Name + " " + Sendtos.User_LastName + ",</p><p>&nbsp;&nbsp;&nbsp;&nbsp; คุณได้รับมอบหมายงาน  " + model.TaskName + "(" + model.level + ")" + "</p><p>กำหนดส่งภายในวันที่ " + string.Format("{0:dd/MM/yyyy}", model.SubTaskSendDate[item]) + "</p><p>รายละเอียดงานมีดังนี้</p><p>" + model.DescriptionTask + " และรายละเอียดเพิ่มของผู้พัฒนาระบบ  " + model.SubTasksDis[item].ToString() + "</p><p>############################</p><p>" + Host.User_Name + " " + Host.User_LastName + "</p></body></html>";
                 e.SendEmail(receiversDev, subjects, messs_Dev, senders);
                 //int total = 0;
                 //float AVG = 0;
                 /////Dev
                 //var vs = db.SubTasks.Where(m => m.SubDevID == st.SubDevID).ToList();
                 //foreach (var h in vs)
                 //{
                 //    var y = db.Tasks.Where(m => m.TaskID == h.TaskID).FirstOrDefault();
                 //    total = total + y.Task_level;
                 //}
                 //AVG = total / vs.Count;
                 //var us = db.Users.Where(m => m.User_ID == st.SubDevID).FirstOrDefault();
                 //us.AVG = AVG;
                 //db.SaveChanges();
             }
             return(RedirectToAction("ShowTask", "Task"));
         }
         else
         {
             st.TaskID            = t.TaskID;
             st.SubName           = model.SubTasksName[0].ToString();
             st.SubDescriptionDev = model.SubTasksDis[0].ToString();
             st.SubDevID          = model.SubTaskDevID[0];////เลือกการค้นหาจาก Table Member ที่ Role เป็น Dev = 2
             st.SubPercent        = 0;
             st.SubStatus         = 0;
             st.Handle            = model.SubTaskDevID[0];
             st.SubDevSend        = model.SubTaskSendDate[0];
             st.CreateDate        = DateTime.Now;
             st.CreateBy          = Convert.ToInt32(Session["userID"]);
             if (model.AttachFile_List != null)
             {
                 if (model.AttachFile_List[0] != null)
                 {
                     var      Upload_Sub = Upload_FileTask(model.AttachFile_List[0]);
                     string[] txt        = Upload_Sub.Split(",".ToCharArray());
                     string   fileName   = txt[1];
                     st.AttachFile = txt[0];
                     st.AttachShow = fileName;
                 }
             }
             db.SubTasks.Add(st);
             db.SaveChanges();
             //var PoinCode2 = db.Users.Where(m => m.User_ID == st.SubDevID).FirstOrDefault();
             //PoinCode2.TotalCoding = PoinCode2.TotalCoding + 1;
             //db.SaveChanges();
             var    Email  = db.Users.Where(m => m.User_ID == t.CreateBy).FirstOrDefault();
             var    Sendto = db.Users.Where(m => m.User_ID == st.SubDevID).FirstOrDefault();
             string sender = Email.User_Email.ToString();
             //string sender = "*****@*****.**";
             string subject  = t.TaskName + "" + st.SubName;
             string receiver = Sendto.User_Email.ToString();
             //string receiver = "*****@*****.**";
             string          mess = "<html><body><p>ถึงคูณ " + Sendto.User_Name + " " + Sendto.User_LastName + ",</p><p>&nbsp;&nbsp;&nbsp;&nbsp; คุณได้รับมอบหมายงาน  " + model.TaskName + "(" + model.level + ")" + "</p><p>กำหนดส่งภายในวันที่ " + string.Format("{0:dd/MM/yyyy}", model.SubTaskSendDate[0]) + "</p><p>รายละเอียดงานมีดังนี้</p><p>" + model.DescriptionTask + " และรายละเอียดเพิ่มของผู้พัฒนาระบบ  " + model.SubTasksDis[0].ToString() + "</p><p>############################</p><p>" + Host.User_Name + " " + Host.User_LastName + "</p></body></html>";
             InboxController i    = new InboxController();
             i.SendEmail(receiver, subject, mess, sender);
             //int totals = 0;
             //float AVGs = 0;
             //var v = db.SubTasks.Where(m => m.SubDevID == st.SubDevID).ToList();
             //foreach (var h in v)
             //{
             //    var y = db.Tasks.Where(m => m.TaskID == h.TaskID).FirstOrDefault();
             //    totals = totals + y.Task_level;
             //}
             //AVGs = totals / v.Count;
             //var u = db.Users.Where(m => m.User_ID == st.SubDevID).FirstOrDefault();
             //u.AVG = AVGs;
             //db.SaveChanges();
             return(RedirectToAction("ShowTask", "Task"));
         }
     }
     catch (Exception)
     {
         TaskModel t         = new TaskModel();
         int       ProjectID = Convert.ToInt32(Session["ProjectID"]);
         var       L         = db.Tasks.Where(m => m.ProjectID == ProjectID).FirstOrDefault();
         t.DevList  = db.ProjectMembers.Where(m => m.ProjectID == ProjectID && m.Role == 2).ToList();
         t.TestList = db.ProjectMembers.Where(m => m.Role == 3 && m.ProjectID == ProjectID).ToList();
         t.QAList   = db.ProjectMembers.Where(m => m.Role == 4 && m.ProjectID == ProjectID).ToList();
         return(View(t));
     }
 }
 public ActionResult AddDefect(DefectModel model)
 {
     if (Convert.ToInt32(Session["Defect_SIT"]) == 1)
     {
         if (model.DetailList[0] != "")
         {
             int     projectID = Convert.ToInt32(Session["ProjectID"]);
             Defect  d         = new Defect();
             SubTask st        = new SubTask();
             int     SIT_ID    = Convert.ToInt32(Session["SIT_ID"]);
             var     count     = model.DetailList.Count;
             if (count > 1)
             {
                 for (int i = 0; i < count; ++i)
                 {
                     d.Sub_ID     = SIT_ID;
                     d.Detail     = model.DetailList[i].ToString();
                     d.SendDate   = model.SendDateList[i];
                     d.Status     = 0;
                     d.CreateDate = DateTime.Now;
                     d.CreateBy   = Convert.ToInt32(Session["userID"]);
                     d.Project_ID = projectID;
                     if (model.AttachFileList[i] != null)
                     {
                         var      Upload = Upload_Defect(model.AttachFileList[i]);
                         string[] txt    = Upload.Split(",".ToCharArray());
                         d.AttachFile = txt[0];
                         d.AttachShow = txt[1];
                     }
                     db.Defects.Add(d);
                     db.SaveChanges();
                     var SIT = db.SITs.Where(m => m.SIT_ID == SIT_ID).FirstOrDefault();
                     SIT.Defect_SIT = 1;
                     SIT.Status     = 4;
                     db.SaveChanges();
                     var    Email  = db.Users.Where(m => m.User_ID == d.CreateBy).FirstOrDefault();
                     var    Sendto = db.Users.Where(m => m.User_ID == SIT.Dev_ID).FirstOrDefault();
                     string sender = Email.User_Email.ToString();
                     //string sender = "*****@*****.**";
                     string subject  = "Defect หัวข้อ" + st.SubName;
                     string receiver = Sendto.User_Email.ToString();
                     //string receiver = "*****@*****.**";
                     string          mess = "มีข้อผิดพลาดในหัวข้อ" + st.SubName;
                     InboxController ms   = new InboxController();
                     ms.SendEmail(receiver, subject, mess, sender);
                 }
             }
             else
             {
                 d.Sub_ID     = SIT_ID;
                 d.Detail     = model.DetailList[0].ToString();
                 d.SendDate   = model.SendDateList[0];
                 d.Status     = 0;
                 d.CreateDate = DateTime.Now;
                 d.CreateBy   = Convert.ToInt32(Session["userID"]);
                 d.Project_ID = projectID;
                 if (model.AttachFileList[0] != null)
                 {
                     var      Upload = Upload_Defect(model.AttachFileList[0]);
                     string[] txt    = Upload.Split(",".ToCharArray());
                     d.AttachFile = txt[0];
                     d.AttachShow = txt[1];
                 }
                 db.Defects.Add(d);
                 db.SaveChanges();
                 var SIT = db.SITs.Where(m => m.SIT_ID == SIT_ID).FirstOrDefault();
                 SIT.Defect_SIT = 1;
                 SIT.Status     = 4;
                 db.SaveChanges();
                 var    Email  = db.Users.Where(m => m.User_ID == d.CreateBy).FirstOrDefault();
                 var    Sendto = db.Users.Where(m => m.User_ID == SIT.Dev_ID).FirstOrDefault();
                 string sender = Email.User_Email.ToString();
                 //string sender = "*****@*****.**";
                 string subject  = "Defect หัวข้อ" + st.SubName;
                 string receiver = Sendto.User_Email.ToString();
                 //string receiver = "*****@*****.**";
                 string          mess = "มีข้อผิดพลาดในหัวข้อ" + st.SubName;
                 InboxController ms   = new InboxController();
                 ms.SendEmail(receiver, subject, mess, sender);
             }
             return(RedirectToAction("ShowDefect"));
         }
         return(View(new DefectModel
         {
             Error_Detail = "กรุณาใส่ข้อมูลให้ครบถ้วน"
         }));
     }
     else
     {
         if (model.DetailList[0] != "")
         {
             int     projectID = Convert.ToInt32(Session["ProjectID"]);
             Defect  d         = new Defect();
             SubTask st        = new SubTask();
             int     SubID     = Convert.ToInt32(Session["SubID"]);
             var     count     = model.DetailList.Count;
             if (count > 1)
             {
                 for (int i = 0; i < count; ++i)
                 {
                     d.Sub_ID     = model.Sub_ID;
                     d.Detail     = model.DetailList[i].ToString();
                     d.SendDate   = model.SendDateList[i];
                     d.Status     = 0;
                     d.CreateDate = DateTime.Now;
                     d.CreateBy   = Convert.ToInt32(Session["userID"]);
                     d.Project_ID = projectID;
                     if (model.AttachFileList[i] != null)
                     {
                         var      Upload = Upload_Defect(model.AttachFileList[i]);
                         string[] txt    = Upload.Split(",".ToCharArray());
                         d.AttachFile = txt[0];
                         d.AttachShow = txt[1];
                     }
                     db.Defects.Add(d);
                     db.SaveChanges();
                     var s = db.SubTasks.Where(m => m.SubID == model.Sub_ID).FirstOrDefault();
                     s.HaveDefect = 1;
                     s.SubStatus  = 5;
                     s.SubPercent = 25;
                     db.SaveChanges();
                     var    Email  = db.Users.Where(m => m.User_ID == d.CreateBy).FirstOrDefault();
                     var    Sendto = db.Users.Where(m => m.User_ID == s.SubDevID).FirstOrDefault();
                     string sender = Email.User_Email.ToString();
                     //string sender = "*****@*****.**";
                     string subject  = "Defect หัวข้อ" + st.SubName;
                     string receiver = Sendto.User_Email.ToString();
                     //string receiver = "*****@*****.**";
                     string          mess = "มีข้อผิดพลาดในหัวข้อ" + st.SubName;
                     InboxController ms   = new InboxController();
                     ms.SendEmail(receiver, subject, mess, sender);
                 }
             }
             else
             {
                 d.Sub_ID     = model.Sub_ID;
                 d.Detail     = model.DetailList[0].ToString();
                 d.SendDate   = model.SendDateList[0];
                 d.Status     = 0;
                 d.CreateDate = DateTime.Now;
                 d.CreateBy   = Convert.ToInt32(Session["userID"]);
                 d.Project_ID = projectID;
                 if (model.AttachFileList[0] != null)
                 {
                     var      Upload = Upload_Defect(model.AttachFileList[0]);
                     string[] txt    = Upload.Split(",".ToCharArray());
                     d.AttachFile = txt[0];
                     d.AttachShow = txt[1];
                 }
                 db.Defects.Add(d);
                 db.SaveChanges();
                 var s = db.SubTasks.Where(m => m.SubID == model.Sub_ID).FirstOrDefault();
                 s.HaveDefect = 1;
                 s.SubStatus  = 5;
                 db.SaveChanges();
                 var    Email  = db.Users.Where(m => m.User_ID == d.CreateBy).FirstOrDefault();
                 var    Sendto = db.Users.Where(m => m.User_ID == s.SubDevID).FirstOrDefault();
                 string sender = Email.User_Email.ToString();
                 //string sender = "*****@*****.**";
                 string subject  = "Defect หัวข้อ" + st.SubName;
                 string receiver = Sendto.User_Email.ToString();
                 //string receiver = "*****@*****.**";
                 string          mess = "มีข้อผิดพลาดในหัวข้อ" + st.SubName;
                 InboxController ms   = new InboxController();
                 ms.SendEmail(receiver, subject, mess, sender);
             }
             return(RedirectToAction("ShowDefect"));
         }
         return(View(new DefectModel
         {
             Error_Detail = "กรุณาใส่ข้อมูลให้ครบถ้วน"
         }));
     }
 }
Beispiel #11
0
        public ActionResult Check_Project(int userID)
        {
            var user = db.ProjectMembers.Where(m => m.UserID == userID).ToList();

            foreach (var item in user)
            {
                var project = db.Projects.Where(m => m.ProjectID == item.ProjectID).FirstOrDefault();
                if (project.Status != 4)
                {
                    if (project.SIT_Menu == 0)
                    {
                        double count = 0;
                        var    Task  = db.Tasks.Where(m => m.ProjectID == item.ProjectID).ToList();
                        foreach (var item2 in Task)
                        {
                            count = count + item2.TotalPercent;
                        }
                        count = (count / Task.Count());
                        if (count == 100 && project.SendDate >= DateTime.Now)
                        {
                            project.Status = 4;
                            db.SaveChanges();
                            var PM = db.Users.Where(m => m.User_ID == project.CreateBy).FirstOrDefault();
                            PM.Amount_Succ = PM.Amount_Succ + 1;
                            db.SaveChanges();
                            InboxController Inbox  = new InboxController();
                            var             member = db.ProjectMembers.Where(m => m.ProjectID == project.ProjectID).ToList();
                            foreach (var c in member)
                            {
                                var    re       = db.Users.Where(m => m.User_ID == c.UserID).FirstOrDefault();
                                var    se       = db.Users.Where(m => m.User_ID == project.CreateBy).FirstOrDefault();
                                string receiver = re.User_Email;
                                string subject  = project.Name;
                                string mess     = "<html><body><p>โครการ" + project.Name + "</p><p>ได้มีสถานะเป็นเสร็จสมบูรณ์</p></body></html>";
                                string sender   = se.User_Email;
                                Inbox.SendEmail(receiver, subject, mess, sender);
                            }
                        }
                        else if (count == 100 && project.SendDate < DateTime.Now)
                        {
                            project.Status = 4;
                            db.SaveChanges();
                            var PM = db.Users.Where(m => m.User_ID == project.CreateBy).FirstOrDefault();
                            PM.Amount_Non = PM.Amount_Non + 1;
                            db.SaveChanges();
                            InboxController Inbox  = new InboxController();
                            var             member = db.ProjectMembers.Where(m => m.ProjectID == project.ProjectID).ToList();
                            foreach (var c in member)
                            {
                                var    re       = db.Users.Where(m => m.User_ID == c.UserID).FirstOrDefault();
                                var    se       = db.Users.Where(m => m.User_ID == project.CreateBy).FirstOrDefault();
                                string receiver = re.User_Email;
                                string subject  = project.Name;
                                string mess     = "<html><body><p>โครการ" + project.Name + "</p><p>ได้มีสถานะเป็นเสร็จสมบูรณ์</p></body></html>";
                                string sender   = se.User_Email;
                                Inbox.SendEmail(receiver, subject, mess, sender);
                            }
                        }
                    }
                    else if (project.SIT_Menu == 1)
                    {
                        var    sit   = db.SITs.Where(m => m.Project_ID == project.ProjectID).ToList();
                        double count = 0;
                        foreach (var i in sit)
                        {
                            if (i.Status == 3)
                            {
                                count = count + 1;
                                if (count == sit.Count() && project.SendDate >= DateTime.Now)
                                {
                                    project.Status = 4;
                                    db.SaveChanges();
                                    var PM = db.Users.Where(m => m.User_ID == project.CreateBy).FirstOrDefault();
                                    PM.Amount_Succ = PM.Amount_Succ + 1;
                                    db.SaveChanges();
                                    InboxController Inbox  = new InboxController();
                                    var             member = db.ProjectMembers.Where(m => m.ProjectID == project.ProjectID).ToList();
                                    foreach (var c in member)
                                    {
                                        var    re       = db.Users.Where(m => m.User_ID == c.UserID).FirstOrDefault();
                                        var    se       = db.Users.Where(m => m.User_ID == project.CreateBy).FirstOrDefault();
                                        string receiver = re.User_Email;
                                        string subject  = project.Name;
                                        string mess     = "<html><body><p>โครการ" + project.Name + "</p><p>ได้มีสถานะเป็นเสร็จสมบูรณ์</p></body></html>";
                                        string sender   = se.User_Email;
                                        Inbox.SendEmail(receiver, subject, mess, sender);
                                    }
                                }
                                else if (count == sit.Count() && project.SendDate < DateTime.Now)
                                {
                                    project.Status = 4;
                                    db.SaveChanges();
                                    var PM = db.Users.Where(m => m.User_ID == project.CreateBy).FirstOrDefault();
                                    PM.Amount_Non = PM.Amount_Non + 1;
                                    db.SaveChanges();
                                    InboxController Inbox  = new InboxController();
                                    var             member = db.ProjectMembers.Where(m => m.ProjectID == project.ProjectID).ToList();
                                    foreach (var c in member)
                                    {
                                        var    re       = db.Users.Where(m => m.User_ID == c.UserID).FirstOrDefault();
                                        var    se       = db.Users.Where(m => m.User_ID == project.CreateBy).FirstOrDefault();
                                        string receiver = re.User_Email;
                                        string subject  = project.Name;
                                        string mess     = "<html><body><p>โครการ" + project.Name + "</p><p>ได้มีสถานะเป็นเสร็จสมบูรณ์</p></body></html>";
                                        string sender   = se.User_Email;
                                        Inbox.SendEmail(receiver, subject, mess, sender);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(View());
        }