Exemple #1
0
        public ProjectTask AddProjectTask(ProjectTask projecttask)
        {
            List <ProjectTask> projecttasks   = ProjectTasks.Where(c => c.TaskId.Equals(projecttask.TaskId)).ToList();
            Project            prj            = Projects.Where(x => x.ProjectID == projecttask.ProjectID).Select(x => x).FirstOrDefault();
            People             ppl            = Peoples.Where(x => x.Deleted == false).Where(x => x.PeopleID == projecttask.PeopleID).Select(x => x).FirstOrDefault();
            Customer           cust           = Customers.Where(x => x.CustomerId == projecttask.CustomerId).Select(x => x).FirstOrDefault();
            ProjectTask        objProjectTask = new ProjectTask();

            if (projecttasks.Count == 0)
            {
                projecttask.CreatedBy   = projecttask.CreatedBy;
                projecttask.CreatedDate = DateTime.Now;
                projecttask.UpdatedDate = DateTime.Now;
                //projecttask.ProjectName = projecttask.ProjectName;
                projecttask.ProjectName  = prj.ProjectName;
                projecttask.CustomerName = cust.Name;
                projecttask.PeopleID     = ppl.PeopleID;

                ProjectTasks.Add(projecttask);
                int id = this.SaveChanges();
                return(projecttask);
            }
            else
            {
                //objProject.Exception = "Already";
                return(objProjectTask);
            }
            //this.ProjectTasks.Add(projecttask);
            //this.SaveChanges();
            //return projecttask;
        }
        private ProjectTasks CreateProjectTask(ProjectTasks projectTasks, bool isNeed = false)
        {
            //instead of trigger
            var addedTask = db.ProjectTasks.Add(projectTasks);

            if (!isNeed)
            {
                var board = db.UserBoards.FirstOrDefault(t => t.ProjectId == addedTask.ProjectId && t.Order == 0);

                if (board == null)
                {
                    db.UserBoards.Add(new UserBoards()
                    {
                        Title      = "Новые",
                        ProjectId  = addedTask.ProjectId,
                        Order      = 0,
                        IsArchived = false //userBoard
                    });
                }

                db.UserBoardTasks.Add(new UserBoardTasks()
                {
                    TaskId      = addedTask.Id,
                    UserBoardId = board.Id
                });
            }

            db.SaveChanges();

            return(projectTasks);
        }
        public async Task <IActionResult> EditTask(int id, [FromBody] ProjectTasks task)
        {
            _context.ProjectTasks.Update(task);
            await _context.SaveChangesAsync();

            await SaveHistory(id);

            return(Ok());
        }
        public async Task AddTask([FromBody] ProjectTasks task)
        {
            _context.ProjectTasks.Add(task);
            System.Diagnostics.Debug.WriteLine(JsonConvert.SerializeObject(task));
            _context.SaveChanges();
            int id = (await _context.ProjectTasks.LastAsync()).Id;

            System.Diagnostics.Debug.WriteLine("id" + id);
            await SaveHistory(id);
        }
Exemple #5
0
        public void OnDropTask(IElement source, IElement destination)
        {
            var startIndex       = ProjectTasks.IndexOf((ITask)source);
            var destinationIndex = ProjectTasks.IndexOf((ITask)destination);

            ProjectTasks.Move(startIndex, destinationIndex);
            ((ITask)source).OrderNumber      = (uint)destinationIndex;
            ((ITask)destination).OrderNumber = (uint)startIndex;

            DataBase.UpdateTask(source);
            DataBase.UpdateTask(destination);
        }
Exemple #6
0
        /// <summary>
        /// Deletes a task
        /// </summary>
        /// <param name="taskId"></param>
        internal void DeleteTask(int taskId)
        {
            using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(Helper.CnnVal("TGDB")))
            {
                ProjectTasks newTask = new ProjectTasks();
                newTask.TaskId = taskId;

                List <ProjectTasks> task = new List <ProjectTasks>();
                task.Add(newTask);

                connection.Execute("dbo.spDeleteTaskRecord @TaskId", task);
            }
        }
        public IHttpActionResult PutProjectTasks(int id, ProjectTasks projectTasks)
        {
            //projectTasks.CreatedOn = DateTime.Now;
            if (projectTasks.StartedOn != null)
            {
                projectTasks.StartedOn = Convert.ToDateTime(projectTasks.StartedOn).ToLocalTime();
            }
            if (projectTasks.EndedOn != null)
            {
                projectTasks.EndedOn = Convert.ToDateTime(projectTasks.EndedOn).ToLocalTime();
            }

            if (projectTasks.EstimatedEndsOn != null)
            {
                projectTasks.EstimatedEndsOn = Convert.ToDateTime(projectTasks.EstimatedEndsOn).ToLocalTime();
            }

            if (User.Identity.GetUserId() != null)
            {
                projectTasks.CreatedBy = User.Identity.GetUserId();
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != projectTasks.Id)
            {
                return(BadRequest());
            }

            db.Entry(projectTasks).State = EntityState.Modified;
            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProjectTasksExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task <IActionResult> DeleteTask(int id)
        {
            ProjectTasks task = await _context.ProjectTasks.FirstOrDefaultAsync(t => t.Id == id);

            if (task == null)
            {
                return(NotFound());
            }
            await DeleteAllSubtasks(task);

            await _context.SaveChangesAsync();

            return(Ok());
        }
Exemple #9
0
        /// <summary>
        /// All data write operations for tblProject
        /// </summary>
        #region Data Write
        /// <summary>
        /// Inserts a new project into tblTask
        /// </summary>
        internal void UpdateTaskStatus(int taskId, string taskStatus)
        {
            using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(Helper.CnnVal("TGDB")))
            {
                ProjectTasks newTask = new ProjectTasks();
                newTask.TaskId     = taskId;
                newTask.TaskStatus = taskStatus;

                List <ProjectTasks> task = new List <ProjectTasks>();
                task.Add(newTask);

                connection.Execute("dbo.spTaskU1 @TaskId, @TaskStatus", task);
            }
        }
        public async Task CreateAsync(CreateTaskViewModel model)
        {
            var task = new ProjectTasks
            {
                Tittle             = model.Tittle,
                Description        = model.Description,
                EstimatedWorkHours = model.EstWorkHours,
                Status             = model.Status,
                CreatedOn          = DateTime.UtcNow,
                IsDeleted          = false,
                ProjectId          = model.ProjectId
            };

            await this.tasksRepository.AddAsync(task);

            await this.tasksRepository.SaveChangesAsync();
        }
 private void AddToChildrenProperty(TaskNode node, ProjectTasks task)
 {
     if (task.InverseParentTask == null)
     {
         return;
     }
     foreach (ProjectTasks child in task.InverseParentTask)
     {
         TaskNode childNode = new TaskNode
         {
             data = new TaskNode.TaskNodeData {
                 id = child.Id, title = child.Title, description = child.Description
             }
         };
         node.children.Add(childNode);
         AddToChildrenProperty(childNode, child);
     }
 }
Exemple #12
0
        public void DeleteTask(object param)
        {
            MessageBoxResult result = MessageBox.Show("Do you want to delete this Task?", "Warning", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (result == MessageBoxResult.Yes)
            {
                var task = (IElement)param;
                if (task is ITask ts)
                {
                    DataBase.DeleteTask(ts);
                    ProjectTasks.Remove(ts);
                }
                if (task is ISubTask subTask)
                {
                    DataBase.DeleteSubTask(subTask);
                    ProjectTasks[GetSubTaskParentIndex(subTask)].SubTasks.Remove(subTask);
                }
            }
        }
Exemple #13
0
        /// <summary>
        /// Inserts a new task
        /// </summary>
        /// <param name="taskName"></param>
        /// <param name="taskDescription"></param>
        /// <param name="taskProgress"></param>
        /// <param name="taskAssignedTo"></param>
        /// <param name="projectName"></param>
        /// <param name="userId"></param>
        /// <param name="projectId"></param>
        /// <param name="taskStatus"></param>
        internal void InsertTask(string taskName, string taskDescription, string taskProgress, string taskAssignedTo, string projectName, int userId, int projectId, string taskStatus)
        {
            using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(Helper.CnnVal("TGDB")))
            {
                ProjectTasks newTask = new ProjectTasks();
                newTask.TaskName        = taskName;
                newTask.TaskDescription = taskDescription;
                newTask.TaskProgress    = taskProgress;
                newTask.TaskAssignedTo  = taskAssignedTo;
                newTask.ProjectName     = projectName;
                newTask.UserId          = userId;
                newTask.ProjectId       = projectId;
                newTask.TaskStatus      = taskStatus;

                List <ProjectTasks> task = new List <ProjectTasks>();
                task.Add(newTask);

                connection.Execute("dbo.spTaskC1 @TaskName, @TaskDescription, @TaskProgress, @TaskAssignedTo, @ProjectName, @UserId, @ProjectId, @TaskStatus", task);
            }
        }
        private async Task DeleteAllSubtasks(ProjectTasks task)
        {
            List <ProjectTasks> tasks = await _context.ProjectTasks.ToListAsync();

            foreach (ProjectTasks childTask in tasks)
            {
                if (childTask.ParentTaskId == task.Id)
                {
                    await DeleteAllSubtasks(childTask);
                }
            }

            List <Files> files = await _context.Files.ToListAsync();

            foreach (Files f in files)
            {
                if (f.TaskId == task.Id)
                {
                    _context.Files.Remove(f);
                }
            }
            List <Comments> comments = await _context.Comments.ToListAsync();

            foreach (Comments c in comments)
            {
                if (c.ProjectTaskId == task.Id)
                {
                    _context.Comments.Remove(c);
                }
            }
            List <ProjectTaskHistory> history = await _context.ProjectTaskHistory.ToListAsync();

            foreach (ProjectTaskHistory h in history)
            {
                if (h.TaskId == task.Id)
                {
                    _context.ProjectTaskHistory.Remove(h);
                }
            }
            _context.ProjectTasks.Remove(task);
        }
Exemple #15
0
        public async Task <IActionResult> AddNewTaskAsync(AddNewTaskViewModel addNewTaskViewModel)
        {
            if (ModelState.IsValid)
            {
                var userId = _context.CalendarroUsers.FirstOrDefault(x => x.EMail.Equals(User.Identity.Name)).UserId;

                HttpContext.Session.TryGetValue("Project", out var project);

                if (project == null)
                {
                    return(RedirectToAction("Index", "Home"));
                }

                var options = new JsonSerializerOptions {
                    WriteIndented = true
                };

                var proj      = System.Text.Json.JsonSerializer.Deserialize <ProjectDto>(project, options);
                var projectId = proj.ProjectId;


                var task = new ProjectTasks()
                {
                    CreateDate = DateTime.Now,
                    TaskName   = addNewTaskViewModel.Name,
                    FinishDate = addNewTaskViewModel.FinishDate.DateTime,
                    UserId     = userId,
                    ProjectId  = projectId,
                    KanbanId   = addNewTaskViewModel.Kanban
                };

                _context.ProjectTasks.Add(task);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index), new { projectId = proj.ProjectId }));
            }

            return(RedirectToAction(nameof(Index)));
        }
Exemple #16
0
        public async Task <IActionResult> AddTaskAsync(AddNewTaskViewModel addNewTaskViewModel)
        {
            if (ModelState.IsValid)
            {
                var task = new ProjectTasks()
                {
                    CreateDate = DateTime.Now,
                    TaskName   = addNewTaskViewModel.Name,
                    FinishDate = addNewTaskViewModel.FinishDate.DateTime,
                    // do zmiany
                    UserId    = 1,
                    ProjectId = 1,
                    KanbanId  = addNewTaskViewModel.Kanban
                                //ProjectId = HttpContext.Session.GetInt32("KanbanId").Value
                };

                _context.ProjectTasks.Add(task);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(nameof(Index), addNewTaskViewModel));
        }
        public async Task <string> GetTask(int id)
        {
            ProjectTasks task = await _context.ProjectTasks.FirstOrDefaultAsync(t => t.Id == id);

            JSONDynamicContract contract = new JSONDynamicContract();

            contract.IncludeProperties(new List <string>()
            {
                "Id", "Title", "StartedOn", "EndedOn",
                "Url", "StatusId", "TaskTypeId",
                "AssignedUserId", "EstimatedEndsOn",
                "ParentTaskId", "ProjectId",
                "UserId", "Description", "CreatedOn",
                "CompletedPercent"
            });
            string serializedTask = JsonConvert.SerializeObject(task, Formatting.Indented,
                                                                new JsonSerializerSettings {
                ContractResolver = contract
            });

            System.Diagnostics.Debug.WriteLine(serializedTask);
            return(serializedTask);
        }
Exemple #18
0
        public List <DayProjects> GetTasksGroupedPerDayPerProject(List <AspNetTasks> listOfTasks)
        {
            List <DayProjects> tasksGroupedPerDayPerProject = new List <DayProjects>();

            List <AspNetTasks> distinctDays = listOfTasks
                                              .GroupBy(t => t.EndDate.Date)
                                              .Select(g => g.First())
                                              .OrderBy(t => t.EndDate)
                                              .ToList();

            foreach (var day in distinctDays)
            {
                DayProjects dayWithProjectsWithTasks = new DayProjects();
                dayWithProjectsWithTasks.Date = day.EndDate;

                List <AspNetTasks> dailyTasks = listOfTasks.Where(t => t.EndDate.Date == day.EndDate.Date).ToList();

                List <AspNetTasks> distinctProjects = dailyTasks
                                                      .GroupBy(t => t.Project.ProjectID)
                                                      .Select(g => g.First())
                                                      .ToList();

                foreach (var project in distinctProjects)
                {
                    ProjectTasks projectWithDailyTasks = new ProjectTasks();
                    projectWithDailyTasks.ProjectName = project.Project.ProjectName;
                    projectWithDailyTasks.ProjectID   = project.Project.ProjectID;
                    projectWithDailyTasks.ListOfTasks = dailyTasks.Where(t => t.Project.ProjectID == project.Project.ProjectID).ToList();

                    dayWithProjectsWithTasks.ProjectsWithTasks.Add(projectWithDailyTasks);
                }

                tasksGroupedPerDayPerProject.Add(dayWithProjectsWithTasks);
            }

            return(tasksGroupedPerDayPerProject);
        }
        //Get Project Tasks
        public static JavaList <ProjectTasks> GetProjectTasks(int pId)
        {
            var          tasks    = new JavaList <ProjectTasks>();
            ProjectTasks allTasks = null;

            tasks.Clear();

            DBHelper dbh = new DBHelper();
            ICursor  c   = dbh.ReadAllProjectTasks(pId);

            while (c.MoveToNext())
            {
                string taskId        = c.GetString(0);
                string task          = c.GetString(1);
                string taskProject   = c.GetString(2);
                string taskDesc      = c.GetString(3);
                string taskStart     = c.GetString(4);
                string taskDeadline  = c.GetString(5);
                string taskExpBudget = c.GetString(6);
                string taskActBudget = c.GetString(7);
                string taskStatus    = c.GetString(8);

                allTasks              = new ProjectTasks();
                allTasks.Id           = Convert.ToInt32(taskId);
                allTasks.Task         = task;
                allTasks.Project      = Convert.ToInt32(taskProject);
                allTasks.TaskDesc     = taskDesc;
                allTasks.TaskStart    = taskStart;
                allTasks.TaskDeadline = taskDeadline;
                allTasks.ExpectedCost = Convert.ToDecimal(taskExpBudget);
                allTasks.ActualCost   = Convert.ToDecimal(taskActBudget);
                allTasks.TaskStatus   = taskStatus;
                tasks.Add(allTasks);
            }

            return(tasks);
        }
Exemple #20
0
        public ProjectTask PutProjectTask(ProjectTask objCust)
        {
            ProjectTask proj = ProjectTasks.Where(x => x.TaskId == objCust.TaskId).FirstOrDefault();
            Project     prj  = Projects.Where(x => x.ProjectID == objCust.ProjectID).Select(x => x).FirstOrDefault();
            Customer    cust = Customers.Where(x => x.CustomerId == objCust.CustomerId).Select(x => x).FirstOrDefault();

            if (proj != null)
            {
                proj.UpdatedDate    = DateTime.Now;
                proj.TaskTypeId     = objCust.TaskTypeId;
                proj.AllocatedHours = objCust.AllocatedHours;
                proj.Priority       = objCust.Priority;
                proj.Name           = objCust.Name;
                proj.StartDate      = objCust.StartDate;
                proj.EndDate        = objCust.EndDate;
                proj.CustomerId     = objCust.CustomerId;
                proj.ProjectID      = objCust.ProjectID;
                proj.Assignee       = objCust.Assignee;

                proj.ProjectName  = prj.ProjectName;
                proj.CustomerName = cust.Name;

                proj.Discription = objCust.Discription;
                proj.CreatedBy   = objCust.CreatedBy;
                proj.UpdatedDate = DateTime.Now;
                proj.UpdateBy    = objCust.UpdateBy;

                ProjectTasks.Attach(proj);
                this.Entry(proj).State = EntityState.Modified;
                this.SaveChanges();
                return(objCust);
            }
            else
            {
                return(null);
            }
        }
Exemple #21
0
        protected void gridTasks_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
        {
            ProjectTasks Project = new ProjectTasks();

            Project.Title            = (String)e.NewValues["Title"];
            Project.Description      = (String)e.NewValues["Description"];
            Project.CMStextReview    = (String)e.NewValues["CMStextReview"];
            Project.StartDate        = (String)e.NewValues["StartDate"];
            Project.EstimatedEndDate = (String)e.NewValues["EstimatedEndDate"];
            Project.TargetDate1      = (String)e.NewValues["TargetDate1"];
            Project.TargetDate2      = (String)e.NewValues["TargetDate2"];
            Project.TargetDate3      = (String)e.NewValues["TargetDate3"];
            Project.Status           = (String)e.NewValues["Status"];
            Project.ActualEndDate    = (String)e.NewValues["ActualEndDate"];
            Project.CMSreviewDate    = (String)e.NewValues["CMSreviewDate"];

            //Project.Roadmap = (Boolean)e.NewValues["Roadmap"];
            if (e.NewValues["Roadmap"] == null)
            {
                Project.Roadmap = false;
            }
            else
            {
                Project.Roadmap = (bool)e.NewValues["Roadmap"];
            };
            //Check if user has enterprise level permission. If so, allow their choice of Home, if not, force project level


            rc_services.NewProjectTasks(Project);
            bool deliverablescreen = false;

            gridTasks.DataSource = rc_services.GetProjectTasks(deliverablescreen);
            e.Cancel             = true;
            gridTasks.CancelEdit();
            gridTasks.DataBind();
        }
Exemple #22
0
        protected void gridTasks_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
        {
            ProjectTasks Project = new ProjectTasks();

            Project.Id               = (String)e.Keys["Id"];
            Project.Title            = (String)e.NewValues["Title"];
            Project.Description      = (String)e.NewValues["Description"];
            Project.CMStextReview    = (String)e.NewValues["CMStextReview"];
            Project.StartDate        = (String)e.NewValues["StartDate"];
            Project.EstimatedEndDate = (String)e.NewValues["EstimatedEndDate"];
            Project.TargetDate1      = (String)e.NewValues["TargetDate1"];
            Project.TargetDate2      = (String)e.NewValues["TargetDate2"];
            Project.TargetDate3      = (String)e.NewValues["TargetDate3"];
            Project.Status           = (String)e.NewValues["Status"];
            Project.ActualEndDate    = (String)e.NewValues["ActualEndDate"];
            Project.CMSreviewDate    = (String)e.NewValues["CMSreviewDate"];

            if (e.NewValues["Roadmap"] == null)
            {
                Project.Roadmap = false;
            }
            else
            {
                Project.Roadmap = (bool)e.NewValues["Roadmap"];
            };

            rc_services.EditProjectTasks(Project);

            bool EnterpriseAuthorized = rc_services.CheckPermission("ent_roadmap");
            bool deliverablescreen    = false;

            gridTasks.DataSource = rc_services.GetProjectTasks(deliverablescreen);
            e.Cancel             = true;
            gridTasks.CancelEdit();
            gridTasks.DataBind();
        }
        private async Task SaveHistory(int taskId)
        {
            ProjectTasks task = await _context.ProjectTasks.FirstOrDefaultAsync(t => t.Id == taskId);

            ProjectTaskHistory history = new ProjectTaskHistory();

            history.AssignedUserId   = task.AssignedUserId;
            history.CompletedPercent = task.CompletedPercent;
            history.Description      = task.Description;
            history.StartedOn        = task.StartedOn;
            history.EndedOn          = task.EndedOn;
            history.EstimatedEndsOn  = task.EstimatedEndsOn;
            history.ParentTaskId     = task.ParentTaskId;
            history.ProjectId        = task.ProjectId;
            history.StatusId         = task.StatusId;
            history.TaskId           = task.Id;
            history.TaskTypeId       = task.TaskTypeId;
            history.Title            = task.Title;
            history.UserId           = task.UserId;

            history.ChangedOn = DateTime.Now;
            _context.ProjectTaskHistory.Add(history);
            await _context.SaveChangesAsync();
        }
        public ProjectBoards CopyBoard(ProjectBoards projectBoard, int ID)
        {
            var originalBoard = db.ProjectBoards
                                .Where(p => p.BoardId == projectBoard.BoardId)
                                .Include(p => p.ProjectColumns)
                                .SingleOrDefault();

            ProjectBoards newBoard = new ProjectBoards();

            newBoard.BoardId        = 0;
            newBoard.Client         = projectBoard.Client;
            newBoard.Configuration  = originalBoard.Configuration;
            newBoard.Name           = projectBoard.Name;
            newBoard.UpdateDate     = DateTime.Now;
            newBoard.User           = HttpContext.Current.User.Identity.Name.ToString();
            newBoard.ProjectColumns = new List <ProjectColumns>();

            foreach (var Column in originalBoard.ProjectColumns.ToList())
            {
                ProjectColumns newColumn = new ProjectColumns();
                newColumn.Description  = Column.Description;
                newColumn.Name         = Column.Name;
                newColumn.UpdateDate   = Column.UpdateDate;
                newColumn.ProjectBoard = newBoard;

                foreach (var Story in Column.ProjectStories.ToList())
                {
                    ProjectStories newStory = new ProjectStories();
                    newStory.AcceptanceCriteria = Story.AcceptanceCriteria;
                    newStory.Complexity         = Story.Complexity;
                    newStory.Description        = Story.Description;
                    newStory.DueDate            = Story.DueDate;
                    newStory.Effort             = Story.Effort;
                    newStory.ElapsedTime        = Story.ElapsedTime;
                    newStory.Moscow             = Story.Moscow;
                    newStory.Name           = Story.Name;
                    newStory.RAG            = Story.RAG;
                    newStory.Requested      = Story.Requested;
                    newStory.RequestedDate  = Story.RequestedDate;
                    newStory.SLADays        = Story.SLADays;
                    newStory.StartDate      = Story.StartDate;
                    newStory.Timebox        = Story.Timebox;
                    newStory.UpdateDate     = Story.UpdateDate;
                    newStory.User           = Story.User;
                    newStory.ProjectColumns = newColumn;

                    foreach (var Task in Story.ProjectTasks.ToList())
                    {
                        ProjectTasks newTasks = new ProjectTasks();
                        newTasks.RemainingTime  = Task.RemainingTime;
                        newTasks.Status         = Task.Status;
                        newTasks.TaskName       = Task.TaskName;
                        newTasks.TaskUser       = Task.TaskUser;
                        newTasks.UpdateDate     = Task.UpdateDate;
                        newTasks.ProjectStories = newStory;
                    }
                    newColumn.ProjectStories.Add(newStory);
                }
                newBoard.ProjectColumns.Add(newColumn);
            }
            ;
            return(newBoard);
        }
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            if (inflater == null)
            {
                inflater = (LayoutInflater)context.GetSystemService(Context.LayoutInflaterService);
            }

            if (convertView == null)
            {
                convertView = inflater.Inflate(Resource.Layout.TaskItemMaster, parent, false);
            }

            LinearLayout myTaskCost     = convertView.FindViewById <LinearLayout>(Resource.Id.TaskCostWrap);
            TextView     myTaskId       = convertView.FindViewById <TextView>(Resource.Id.TaskID);
            TextView     myTask         = convertView.FindViewById <TextView>(Resource.Id.TaskName);
            TextView     myTaskStart    = convertView.FindViewById <TextView>(Resource.Id.TaskStarts);
            TextView     myTaskDeadline = convertView.FindViewById <TextView>(Resource.Id.TaskDeadline);
            TextView     myTaskExpCost  = convertView.FindViewById <TextView>(Resource.Id.TaskExpCost);
            TextView     myTaskActCost  = convertView.FindViewById <TextView>(Resource.Id.TaskActCost);
            TextView     myTaskStatus   = convertView.FindViewById <TextView>(Resource.Id.TaskStatus);
            TextView     myTaskNotify   = convertView.FindViewById <TextView>(Resource.Id.TaskNotification);

            task = tasks[position];

            myTaskId.Text       = task.Id.ToString();
            myTask.Text         = task.Task;
            myTaskStart.Text    = task.TaskStart;
            myTaskDeadline.Text = task.TaskDeadline;
            myTaskExpCost.Text  = task.ExpectedCost.ToString();
            myTaskStatus.Text   = task.TaskStatus;


            myTaskCost.Visibility = ViewStates.Gone;


            if (!task.ActualCost.Equals(""))
            {
                myTaskActCost.Text = task.ActualCost.ToString();
            }

            int days = Convert.ToInt32(DateTime.Parse(task.TaskDeadline).Subtract(DateTime.Today).TotalDays);

            if (task.TaskStatus.Equals("Pending"))
            {
                myTaskStatus.SetTextColor(Android.Graphics.Color.Rgb(183, 28, 28));
                if (days < 0)
                {
                    myTaskNotify.SetBackgroundColor(Android.Graphics.Color.Rgb(183, 28, 28));
                    myTaskNotify.SetTextColor(Android.Graphics.Color.White);
                    myTaskNotify.Text = "Task is " + (days * -1) + " past deadline. Do something!";
                }
                if (days == 0)
                {
                    myTaskNotify.Text = "Today is the task's deadline. Do something!";
                    myTaskNotify.SetBackgroundColor(Android.Graphics.Color.Rgb(240, 98, 146));
                }
                else if (days > 0 && days <= 14)
                {
                    myTaskNotify.Text = days + " day(s) left to task deadline. Do something!";
                    myTaskNotify.SetBackgroundColor(Android.Graphics.Color.Rgb(244, 143, 177));
                }
                else if (days > 14)
                {
                    myTaskNotify.Text = days + " days left to goal deadline";
                }
            }
            if (task.TaskStatus.Equals("Completed"))
            {
                myTaskNotify.Visibility   = ViewStates.Gone;
                myTaskDeadline.Visibility = ViewStates.Gone;
            }

            return(convertView);
        }
Exemple #26
0
        //Save DataSet Method
        public void SaveAll()
        {
            // if there are changes
            if (this.HasChanges())
            {
                if (Employees.GetChanges(DataRowState.Added) != null ||
                    Employees.GetChanges(DataRowState.Modified) != null)
                {
                    try
                    {
                        DataServices.SaveTable(FileName, EmployeesSELECT,
                                               Employees.GetChanges(DataRowState.Added));
                    }
                    catch (Exception ex)
                    { Console.WriteLine(ex.Message); }

                    try
                    {
                        DataServices.SaveTable(FileName, EmployeesSELECT,
                                               Employees.GetChanges(DataRowState.Modified));
                    }
                    catch (Exception ex)
                    { Console.WriteLine(ex.Message); }
                }

                // if there are rows to add or update
                if (TaskEmployees.GetChanges(DataRowState.Added) != null ||
                    TaskEmployees.GetChanges(DataRowState.Modified) != null)
                {
                    try
                    {
                        DataServices.SaveTable(FileName, TaskEmployeesSELECT,
                                               TaskEmployees.GetChanges(DataRowState.Added));
                    }
                    catch (Exception ex)
                    { Console.WriteLine(ex.Message); }

                    try
                    {
                        DataServices.SaveTable(FileName, TaskEmployeesSELECT,
                                               TaskEmployees.GetChanges(DataRowState.Modified));
                    }
                    catch (Exception ex)
                    { Console.WriteLine(ex.Message); }
                }

                // if there are rows to write to database
                if (ProjectTasks.GetChanges() != null)
                {
                    try
                    {
                        DataServices.SaveTable(FileName, ProjectTasksSELECT,
                                               ProjectTasks.GetChanges());
                    }
                    catch (Exception ex)
                    { Console.WriteLine(ex.Message); }

                    try
                    {
                        DataServices.SaveTable(FileName, ProjectTasksSELECT,
                                               ProjectTasks.GetChanges(DataRowState.Modified));
                    }
                    catch (Exception ex)
                    { Console.WriteLine(ex.Message); }
                }

                if (Projects.GetChanges(DataRowState.Deleted) != null)
                {
                    try
                    {
                        DataServices.SaveTable(FileName, ProjectsSELECT,
                                               Projects.GetChanges(DataRowState.Deleted));
                    }
                    catch (Exception ex)
                    { Console.WriteLine(ex.Message); }

                    try
                    {
                        DataServices.SaveTable(FileName, ProjectsSELECT,
                                               Projects.GetChanges(DataRowState.Modified));
                    }
                    catch (Exception ex)
                    { Console.WriteLine(ex.Message); }
                }
            }
        }
Exemple #27
0
        public void SaveTask(string taskContent)
        {
            if (_updateableTask == null)
            {
                Console.WriteLine("insert task");
                var task = new Task
                {
                    Content  = TaskContent,
                    DueDate  = TaskDueDate,
                    Priority = TaskPriority
                };
                DataBase.InsertTask(task, _project.ID);
                ProjectTasks.Add(task);
            }
            else
            {
                if (_updateableTask is Task task)
                {
                    if (!_isSubTask)
                    {
                        Console.WriteLine("update task");
                        var index = ProjectTasks.IndexOf(task);
                        task.Content  = TaskContent;
                        task.DueDate  = TaskDueDate;
                        task.Priority = TaskPriority;
                        //ProjectTasks.Insert(index, task);
                        //ProjectTasks.RemoveAt(index + 1);
                        DataBase.UpdateTask(task);
                        _updateableTask = null;
                    }
                    else
                    {
                        Console.WriteLine("insert subtask");
                        var newSubTask = new SubTask
                        {
                            Content  = TaskContent,
                            DueDate  = TaskDueDate,
                            Priority = TaskPriority
                        };
                        DataBase.InsertSubTask(newSubTask, task.ID);
                        task.SubTasks.Add(newSubTask);
                    }
                }

                if (_updateableTask is SubTask subTask)
                {
                    Console.WriteLine("Update subtask");
                    var subtaskIndex = -1;
                    var taskIndex    = -1;
                    for (int i = 0; i < ProjectTasks.Count; i++)
                    {
                        for (int j = 0; j < ProjectTasks[i].SubTasks.Count; j++)
                        {
                            if (Equals(_updateableTask, ProjectTasks[i].SubTasks[j]))
                            {
                                taskIndex    = i;
                                subtaskIndex = j;
                            }
                        }
                    }

                    subTask.Content  = TaskContent;
                    subTask.DueDate  = TaskDueDate;
                    subTask.Priority = TaskPriority;
                    //ProjectTasks[taskIndex].SubTasks.Insert(subtaskIndex, subTask);
                    //ProjectTasks[taskIndex].SubTasks.RemoveAt(subtaskIndex + 1);
                    DataBase.UpdateTask(subTask);
                    _updateableTask = null;
                    _isSubTask      = false;
                }
                _isSubTask         = false;
                _editableComponent = null;
            }
            ShowAddTaskPanel();
            ResetNewTaskProperties();
        }
 void IApplyEvent <TasksAddedToProject> .Apply(TasksAddedToProject e)
 {
     ProjectTasks.AddRange(e.ProjectTasks);
 }
Exemple #29
0
 public IEnumerable <ProjectTask> AllProjectTaskbyCompanyId(int cmpid)
 {
     return(ProjectTasks.Where(c => c.CompanyId == cmpid).AsEnumerable());
 }