Beispiel #1
0
        public ActionResult ShowSIT()
        {
            if ((Session["userID"]) == null)
            {
                return(RedirectToAction("Index", "Login"));
            }
            Session["Defect_SIT"] = 0;
            SITModel         data  = new SITModel();
            List <SITModel>  model = new List <SITModel>();
            ReportController R     = new ReportController();
            int projectID          = Convert.ToInt32(Session["ProjectID"]);

            R.Summary(projectID);
            var project = db.Projects.Where(m => m.ProjectID == projectID).FirstOrDefault();

            data.CreateBy       = project.CreateBy;
            data.Project_Status = project.Status;
            var sit = db.SITs.Where(m => m.Project_ID == projectID).ToList();

            Session["Show"] = 0;
            foreach (var n in sit)
            {
                var QA     = db.Users.Where(m => m.User_ID == n.QA_ID).FirstOrDefault();
                var Tester = db.Users.Where(m => m.User_ID == n.Tester_ID).FirstOrDefault();
                var Dev    = db.Users.Where(m => m.User_ID == n.Dev_ID).FirstOrDefault();
                model.Add(new SITModel
                {
                    SIT_ID      = n.SIT_ID,
                    Name        = n.Name,
                    Detail      = n.Detail,
                    Status      = n.Status,
                    QA_Name     = QA.User_Name,
                    Tester_Name = Tester.User_Name,
                    Dev_Name    = Dev.User_Name,
                    CreateDate  = n.CreateDate
                });
            }
            ViewBag.DataList = model;
            return(View(data));
        }
        public ActionResult ShowTask()
        {
            if ((Session["userID"]) == null)
            {
                return(RedirectToAction("Index", "Login"));
            }
            ProjectController P = new ProjectController();

            Session["Save"]       = 0;
            Session["SIT_Defect"] = 0;
            ReportController R = new ReportController();
            int ProjectID      = Convert.ToInt32(Session["ProjectID"]);
            int userID         = Convert.ToInt32(Session["userID"]);

            P.Check_Project(userID);
            R.Summary(ProjectID);
            Sum_AVG(ProjectID);
            string              Taskname    = null;
            string              Handle      = null;
            string              DevName     = null;
            TaskModel           model       = new TaskModel();
            List <SubTaskModel> SubTaskList = new List <SubTaskModel>();
            List <TaskModel>    TaskList    = new List <TaskModel>();
            var ProjectManager = db.Projects.Where(m => m.ProjectID == ProjectID).FirstOrDefault();
            var item           = db.Tasks.Where(m => m.ProjectID == ProjectID).ToList();
            var r = db.ProjectMembers.Where(m => m.ProjectID == ProjectID && m.UserID == userID).FirstOrDefault();

            model.CreateBy       = ProjectManager.CreateBy;
            model.Project_Status = ProjectManager.Status;
            foreach (var i in item)
            {
                //PM และ CM
                if (r.Role == 1 || r.Role == 5)
                {
                    //TaskList.Add(new TaskModel
                    //{
                    //    TaskID = i.TaskID,
                    //    TaskName = i.TaskName,
                    //    TotalPercent = i.TotalPercent,
                    //    CreateDate = i.CreateDate,
                    //    UpdateDate = i.UpdateDate,
                    //    CreateBy = i.CreateBy
                    //});
                    Taskname = i.TaskName;
                    var item2 = db.SubTasks.Where(m => m.TaskID == i.TaskID).OrderByDescending(t => t.TaskID).ToList();
                    foreach (var s in item2)
                    {
                        var nameDev = db.Users.Where(m => m.User_ID == s.SubDevID).FirstOrDefault();
                        DevName = nameDev.User_Name;
                        if (s.Handle == 0)
                        {
                            Handle = "ลูกค้า";
                        }
                        else
                        {
                            var nameHandle = db.Users.Where(m => m.User_ID == s.Handle).FirstOrDefault();
                            Handle = nameHandle.User_Name;
                        }
                        //    number = number + s.SubPercent;
                        SubTaskList.Add(new SubTaskModel
                        {
                            TaskID            = s.TaskID,
                            TaskName          = Taskname,
                            SubID             = s.SubID,
                            SubName           = s.SubName,
                            Handle            = Handle,
                            SubStatus         = s.SubStatus,
                            SubPercent        = s.SubPercent,
                            SubDescriptionDev = s.SubDescriptionDev,
                            SubDevID          = DevName,
                            SubDevSend        = s.SubDevSend,
                            CreateDate        = s.CreateDate,
                            UpdateDate        = s.UpdateDate,
                            CreateBy          = s.CreateBy
                        });
                        //  ++countList;
                    }
                }
                // Dev
                else if (r.Role == 2)
                {
                    var st = db.SubTasks.Where(m => m.TaskID == i.TaskID && m.SubDevID == userID).ToList();
                    foreach (var s in st)
                    {
                        var nameDev = db.Users.Where(m => m.User_ID == s.SubDevID).FirstOrDefault();
                        DevName = nameDev.User_Name;
                        if (s.Handle == 0)
                        {
                            Handle = "ลูกค้า";
                        }
                        else
                        {
                            var nameHandle = db.Users.Where(m => m.User_ID == s.Handle).FirstOrDefault();
                            Handle = nameHandle.User_Name;
                        }
                        var t = db.Tasks.Where(m => m.TaskID == s.TaskID).FirstOrDefault();
                        TaskList.Add(new TaskModel
                        {
                            TaskID       = t.TaskID,
                            TaskName     = t.TaskName,
                            TotalPercent = t.TotalPercent,
                            CreateDate   = t.CreateDate,
                            UpdateDate   = t.UpdateDate,
                            CreateBy     = t.CreateBy
                        });
                        SubTaskList.Add(new SubTaskModel
                        {
                            TaskID            = s.TaskID,
                            TaskName          = t.TaskName,
                            SubID             = s.SubID,
                            SubName           = s.SubName,
                            Handle            = Handle,
                            SubStatus         = s.SubStatus,
                            SubPercent        = s.SubPercent,
                            SubDescriptionDev = s.SubDescriptionDev,
                            SubDevID          = DevName,
                            SubDevSend        = s.SubDevSend,
                            CreateDate        = s.CreateDate,
                            UpdateDate        = s.UpdateDate,
                            CreateBy          = s.CreateBy
                        });
                    }
                }
                //Tester
                else if (r.Role == 3)
                {
                    var t = db.Tasks.Where(m => m.TaskID == i.TaskID && m.TestID == userID).ToList();
                    foreach (var it in t)
                    {
                        TaskList.Add(new TaskModel
                        {
                            TaskID       = it.TaskID,
                            TaskName     = it.TaskName,
                            TotalPercent = it.TotalPercent,
                            CreateDate   = it.CreateDate,
                            UpdateDate   = it.UpdateDate,
                            CreateBy     = it.CreateBy
                        });
                        var st = db.SubTasks.Where(m => m.TaskID == it.TaskID).ToList();
                        foreach (var si in st)
                        {
                            var nameDev = db.Users.Where(m => m.User_ID == si.SubDevID).FirstOrDefault();
                            DevName = nameDev.User_Name;
                            if (si.Handle == 0)
                            {
                                Handle = "ลูกค้า";
                            }
                            else
                            {
                                var nameHandle = db.Users.Where(m => m.User_ID == si.Handle).FirstOrDefault();
                                Handle = nameHandle.User_Name;
                            }
                            SubTaskList.Add(new SubTaskModel
                            {
                                TaskID            = si.TaskID,
                                TaskName          = it.TaskName,
                                SubID             = si.SubID,
                                SubName           = si.SubName,
                                Handle            = Handle,
                                SubStatus         = si.SubStatus,
                                SubPercent        = si.SubPercent,
                                SubDescriptionDev = si.SubDescriptionDev,
                                SubDevID          = DevName,
                                SubDevSend        = si.SubDevSend,
                                CreateDate        = si.CreateDate,
                                UpdateDate        = si.UpdateDate,
                                CreateBy          = si.CreateBy
                            });
                        }
                    }
                }
                //QA
                else if (r.Role == 4)
                {
                    var t = db.Tasks.Where(m => m.TaskID == i.TaskID && m.QAID == userID).ToList();
                    foreach (var it in t)
                    {
                        TaskList.Add(new TaskModel
                        {
                            TaskID       = it.TaskID,
                            TaskName     = it.TaskName,
                            TotalPercent = it.TotalPercent,
                            CreateDate   = it.CreateDate,
                            UpdateDate   = it.UpdateDate,
                            CreateBy     = it.CreateBy
                        });
                        var st = db.SubTasks.Where(m => m.TaskID == it.TaskID).ToList();
                        foreach (var si in st)
                        {
                            var nameDev = db.Users.Where(m => m.User_ID == si.SubDevID).FirstOrDefault();
                            DevName = nameDev.User_Name;
                            if (si.Handle == 0)
                            {
                                Handle = "ลูกค้า";
                            }
                            else
                            {
                                var nameHandle = db.Users.Where(m => m.User_ID == si.Handle).FirstOrDefault();
                                Handle = nameHandle.User_Name;
                            }
                            SubTaskList.Add(new SubTaskModel
                            {
                                TaskID            = si.TaskID,
                                TaskName          = it.TaskName,
                                SubID             = si.SubID,
                                SubName           = si.SubName,
                                Handle            = Handle,
                                SubStatus         = si.SubStatus,
                                SubPercent        = si.SubPercent,
                                SubDescriptionDev = si.SubDescriptionDev,
                                SubDevID          = DevName,
                                SubDevSend        = si.SubDevSend,
                                CreateDate        = si.CreateDate,
                                UpdateDate        = si.UpdateDate,
                                CreateBy          = si.CreateBy
                            });
                        }
                    }
                }
            }

            ViewBag.DataList2 = SubTaskList;
            ViewBag.DataList  = TaskList;
            return(View(model));
        }