Пример #1
0
 public ActionResult Create(Report model)
 {
     if (Validate(model))
     {
         var assignTask = TaskBO.AssignTaskGetById(model.AssignTaskId);
         var report     = new Report
         {
             ReportResult     = model.ReportResult,
             AssignTaskId     = model.AssignTaskId,
             CompletedPercent = model.CompletedPercent,
             NextTask         = model.NextTask,
             CreateDate       = DateTime.Now,
             ReportDate       = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day),
             CreateBy         = CurrentUser.Id,
             ModifyBy         = CurrentUser.Id,
             ModifyDate       = DateTime.Now,
             TaskId           = assignTask != null ?assignTask.TaskId : 0,
             UserReport       = CurrentUser.Id,
             CommentDate      = DateTime.Now,
             ReportType       = model.ReportType
         };
         TaskBO.ReportInsert(report);
         AlertBO.Insert(report.ReportResult, (int)AlertType.Report, 0, assignTask.CreateBy);
         TaskBO.AssignTaskUpdateCompleted(model.AssignTaskId, model.CompletedPercent);
         return(RedirectToAction("Index"));
     }
     PrepareData();
     return(View(model));
 }
Пример #2
0
        public ActionResult UpdateEmployee(int subtaskId, int userId)
        {
            var subtask = TaskBO.AssignTaskGetById(subtaskId);

            if (subtask == null)
            {
                return(RedirectToAction("NotFound", "Home"));
            }
            subtask.UserId = userId;
            TaskBO.AssignTaskUpdate(subtask);
            return(RedirectToAction("Index", new { id = subtaskId }));
        }
Пример #3
0
        public ActionResult Delete(int id)
        {
            var assignTask = TaskBO.AssignTaskGetById(id);

            if (assignTask == null)
            {
                return(RedirectToAction("NotFound", "Home"));
            }

            TaskBO.AssignTaskDelete(id);
            AlertBO.Delete(id, (int)AlertType.AssignTask);
            return(RedirectToAction("Index", new { id = assignTask.TaskId }));
        }
Пример #4
0
        public ActionResult ListReport(ReportSearchModel searchModel)
        {
            if (searchModel == null)
            {
                searchModel = new ReportSearchModel();
            }
            DateTime sdate;
            DateTime edate;

            DateTime.TryParseExact(searchModel.StartDate, Helper.FormatDate,
                                   new CultureInfo("en-US"),
                                   DateTimeStyles.None,
                                   out sdate);
            DateTime.TryParseExact(searchModel.EndDate, Helper.FormatDate,
                                   new CultureInfo("en-US"),
                                   DateTimeStyles.None,
                                   out edate);

            var reports = TaskBO.ReportSearch(searchModel.UserId, sdate, edate);

            var user = new List <User>
            {
                new User {
                    UserName = "******"
                }
            };

            user.AddRange(UserBO.GetByDepartmentId(CurrentUser.DepartmentLeader));
            ViewBag.Users = user;
            var temReport = new List <Report>();

            if (reports != null && reports.Count > 0)
            {
                for (int i = 0; i < reports.Count; i++)
                {
                    reports[i].AssignTask = TaskBO.AssignTaskGetById(reports[i].AssignTaskId);
                    reports[i].Task       = TaskBO.GetById(reports[i].AssignTask.TaskId);
                    reports[i].User       = UserBO.GetById(reports[i].UserReport);


                    if (reports[i].User.DepartmentId == CurrentUser.DepartmentLeader)
                    {
                        temReport.Add(reports[i]);
                    }
                }
            }

            searchModel.Reports = temReport;
            return(View(searchModel));
        }
Пример #5
0
        public ActionResult Edit(AssignTask assignTask)
        {
            var assignTaskSave = TaskBO.AssignTaskGetById(assignTask.Id);

            if (assignTaskSave == null)
            {
                return(RedirectToAction("NotFound", "Home"));
            }

            if (assignTaskSave.UserId > 0)
            {
                assignTaskSave.UserId      = assignTask.UserId;
                assignTaskSave.Requirement = assignTask.Requirement;
                assignTaskSave.ModifyBy    = CurrentUser.Id;
                assignTaskSave.ModifyDate  = DateTime.Now;

                if (!string.IsNullOrEmpty(assignTask.StartAndEndDate) && assignTask.StartAndEndDate.Split('-').Length == 2)
                {
                    var      strStart = assignTask.StartAndEndDate.Split('-')[0].Trim();
                    var      strEnd   = assignTask.StartAndEndDate.Split('-')[1].Trim();
                    DateTime sdate;
                    DateTime edate;
                    if (DateTime.TryParseExact(strStart, Helper.FormatDate,
                                               new CultureInfo("en-US"),
                                               DateTimeStyles.None,
                                               out sdate))
                    {
                        assignTask.StartDate = sdate;
                    }

                    if (DateTime.TryParseExact(strEnd, Helper.FormatDate,
                                               new CultureInfo("en-US"),
                                               DateTimeStyles.None,
                                               out edate))
                    {
                        assignTask.EndDate = edate;
                    }

                    TaskBO.AssignTaskUpdate(assignTask);
                }
                return(RedirectToAction("Index", new { id = assignTaskSave.TaskId }));
            }

            ViewBag.Task  = TaskBO.GetById(assignTask.TaskId);
            ViewBag.Users = UserBO.GetByDepartmentId(CurrentUser.DepartmentLeader);
            return(View("Create", assignTask));
        }
Пример #6
0
        public ActionResult UpdateEmployee(int id)
        {
            var subtask = TaskBO.AssignTaskGetById(id);

            if (subtask == null)
            {
                return(RedirectToAction("NotFound", "Home"));
            }
            ViewBag.SubTask = subtask;
            ViewBag.Task    = TaskBO.GetById(subtask.TaskId);
            ViewBag.Users   = UserBO.GetByDepartmentId(CurrentUser.DepartmentLeader);
            if (subtask.UserId <= 0 && ViewBag.Users != null && ViewBag.Users.Count > 0)
            {
                subtask.UserId = ViewBag.Users[0].Id;
            }
            return(View());
        }
Пример #7
0
        public ActionResult Edit(int id)
        {
            var assignTask = TaskBO.AssignTaskGetById(id);

            //AssignTask model;
            if (assignTask != null)
            {
                assignTask.StartAndEndDate = assignTask.StartDate.ToString(Helper.FormatDate) + " - " + assignTask.EndDate.ToString(Helper.FormatDate);
            }
            else
            {
                return(RedirectToAction("NotFound", "Home"));
            }
            ViewBag.Task  = TaskBO.GetById(assignTask.TaskId);
            ViewBag.Users = UserBO.GetByDepartmentId(CurrentUser.DepartmentLeader);
            return(View("Create", assignTask));
        }
Пример #8
0
        public ActionResult Create(int assignTaskId)
        {
            var assignTask = TaskBO.AssignTaskGetById(assignTaskId);

            if (assignTask == null)
            {
                return(RedirectToAction("NotFound", "Home"));
            }

            var report = new Report
            {
                AssignTaskId = assignTaskId
            };

            PrepareData();
            return(View(report));
        }
Пример #9
0
        //
        // GET: /Report/

        public ActionResult Index(string date)
        {
            var      lstreport = new List <Report>();
            DateTime sdate;

            if (!DateTime.TryParseExact(date, Helper.FormatDate,
                                        new CultureInfo("en-US"),
                                        DateTimeStyles.None,
                                        out sdate))
            {
                sdate = DateTime.Now;
            }
            var reports = TaskBO.ReportByUserReportAndReportDate(CurrentUser.Id, sdate.ToString("dd/MM/yyyy"));

            if (reports != null && reports.Count > 0)
            {
                foreach (var item in reports)
                {
                    item.AssignTask = TaskBO.AssignTaskGetById(item.AssignTaskId);
                }
            }
            ViewBag.Date = sdate;
            return(View(reports ?? new List <Report>()));
        }