protected override void Add()
        {
            Console.Clear();
            TaskRepo repo = new TaskRepo("tasks.txt");
            Task     task = new Task();

            task.ParentId = AuthenticationService.LoggedUser.Id;
            Console.WriteLine("*****  ADD NEW TASK  *****");
            Console.WriteLine("Title");
            task.Title = Console.ReadLine();
            Console.WriteLine("Description");
            task.Description = Console.ReadLine();
            Console.WriteLine("ResponsibleUserID");
            task.ResponsibleUser = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Creator");
            task.Creator = Console.ReadLine();
            Console.WriteLine("****** S T A T U S ******");
            task.Status = Convert.ToString(WhichStatus());
            var time = DateTime.Now;

            task.CreateTime = time;
            task.LastChange = time;
            repo.Save(task);
            Console.Clear();
            Console.WriteLine("*******************************");
            Console.WriteLine("********* COMPLETED!!! ********");
            Console.WriteLine("*******************************");
            Thread.Sleep(1500);
        }
Exemple #2
0
        private void tsMainNew_Click(object sender, EventArgs e)
        {
            MTasks  item    = new MTasks();
            NewTask newTask = new NewTask(item);

            if (newTask.ShowDialog() == DialogResult.OK)
            {
                TaskRepo edd = new TaskRepo();
                edd.Save(item);
                SetDataSources();
            }
        }
Exemple #3
0
        private void toolStripButton3_Click_1(object sender, EventArgs e)
        {
            Int32 selectedRowCount = dataGridView1.Rows.GetRowCount(DataGridViewElementStates.Selected);

            if (selectedRowCount > 0)
            {
                MTasks   task = (MTasks)tasksBindingSource1.Current;
                TaskRepo edd  = new TaskRepo();
                task.Final = Convert.ToBoolean(true);
                edd.Save(task);
                SetDataSources();
            }
        }
Exemple #4
0
        private void tsMainEdit_Click(object sender, EventArgs e)
        {
            Int32 selectedRowCount = dataGridView1.Rows.GetRowCount(DataGridViewElementStates.Selected);

            if (selectedRowCount > 0)
            {
                MTasks   task     = (MTasks)tasksBindingSource1.Current;
                EditTask editTask = new EditTask(task);

                if (editTask.ShowDialog() == DialogResult.OK)
                {
                    TaskRepo edd = new TaskRepo();
                    edd.Save(task);
                    SetDataSources();
                }
            }
        }
        protected override void Edit()
        {
            Console.Clear();
            All();
            Console.WriteLine("*** CHOOSE BY ID WHO TO EDIT ***");
            Console.Write("         ID: ");
            int      id   = int.Parse(Console.ReadLine());
            TaskRepo repo = new TaskRepo("tasks.txt");
            Task     task = new Task();
            Task     u    = new Task();

            task       = repo.GetById(id);
            u.Id       = task.Id;
            u.ParentId = task.ParentId;
            Console.Write("******** OLD TITLE : ");
            Console.WriteLine(task.Title);
            Console.Write("******** NEW TITLE : ");
            u.Title = Console.ReadLine();
            Console.Write("******** OLD DESCRIPTION : ");
            Console.WriteLine(task.Description);
            Console.Write("******** OLD DESCRIPTION : ");
            u.Description = Console.ReadLine();
            Console.Write("******** OLD RESPONSIBLE USER ID : ");
            Console.WriteLine(task.ResponsibleUser);
            Console.Write("******** OLD RESPONSIBLE USER ID : ");
            u.ResponsibleUser = Convert.ToInt32(Console.ReadLine());
            Console.Write("******** OLD CREATOR : ");
            Console.WriteLine(task.Creator);
            Console.Write("******** NEW CREATOR : ");
            u.Creator = Console.ReadLine();
            Console.Write("******** OLD STATUS : ");
            Console.WriteLine(task.Status);
            Console.Write("******** NEW STATUS : ");
            u.Status = Convert.ToString(WhichStatus());
            var time = DateTime.Now;

            u.LastChange = time;
            u.CreateTime = task.CreateTime;
            repo.Save(u);
            Console.Clear();
            Console.WriteLine("*******************************");
            Console.WriteLine("********* COMPLETED!!! ********");
            Console.WriteLine("*******************************");
            Thread.Sleep(1500);
        }
Exemple #6
0
        private void Add()
        {
            Console.Clear();
            MTasks user   = new MTasks();
            bool   Status = false;

            try
            {
                Console.WriteLine("Add new task");
                Console.Write("+Title: ");
                user.Title = Console.ReadLine();
                Console.Write("+Whats the task: ");
                user.Description = Console.ReadLine();
                user.Creator     = Login.LoggedUser.UserId;
                Console.Write("+Finish time: ");
                user.EstTime = int.Parse(Console.ReadLine());
                Console.Write("+Assigne to: ");
                user.Assigned = int.Parse(Console.ReadLine());
                DateTime saveNow = DateTime.Now;
                user.CreTime = saveNow;
                Console.WriteLine();
                Status = true;
            }
            catch (Exception ex)
            {
                Console.Clear();
                Console.WriteLine(ex.Message);
                Console.ReadKey(true);
                Status = false;
            }
            Users    item     = new Users();
            UserRepo userRepo = new UserRepo(filepath);

            item = userRepo.GetById(user.Assigned);
            if (Status == true && item.UserId > 0)
            {
                TaskRepo taskRepository = new TaskRepo(tasksFilepath);
                taskRepository.Save(user);

                Console.WriteLine("Task added successfully");
                Console.ReadKey(true);
            }
        }
        protected override void DeleteFilter(int id)
        {
            TaskRepo    taskRepository = RepositoryFactory.GetTasksRepository();
            List <Task> tasks          = taskRepository.GetAll().FindAll(task => task.UserId == id && task.ResponsibleUser == id);

            foreach (var task in tasks)
            {
                taskRepository.Delete(task);
            }

            List <Task> tasksRespU = taskRepository.GetAll();

            foreach (var task in tasksRespU)
            {
                if (task.ResponsibleUser == AuthenticationManager.LoggedUser.Id)
                {
                    task.UserId = AuthenticationManager.LoggedUser.Id;

                    taskRepository.Save(task);
                }
            }

            CommentRepo    comRepository = RepositoryFactory.GetCommentsRepository();
            List <Comment> comments      = comRepository.GetAll().FindAll(com => com.CreatedBy == id);

            foreach (var com in comments)
            {
                comRepository.Delete(com);
            }

            LoggedWorkRepo    loggedWorkRepo = RepositoryFactory.GetLoggedWorksRepository();
            List <LoggedWork> loggedWorks    = loggedWorkRepo.GetAll().FindAll(lw => lw.UserId == id);

            foreach (var lw in loggedWorks)
            {
                loggedWorkRepo.Delete(lw);
            }
        }
        private void ChangeStatus(Entities.Task task)
        {
            Console.Clear();
            TaskRepo repo = new TaskRepo("tasks.txt");

            Entities.Task u = new Entities.Task();
            u.Id              = task.Id;
            u.ParentId        = task.ParentId;
            u.Title           = task.Title;
            u.Description     = task.Description;
            u.ResponsibleUser = task.ResponsibleUser;
            u.Creator         = task.Creator;
            Console.WriteLine("********************************");
            Console.Write("******** OLD STATUS : ");
            Console.WriteLine(task.Status);
            Console.Write("******** NEW STATUS : ");
            u.Status = Convert.ToString(WhichStatus());
            Console.WriteLine("********************************");
            var time = DateTime.Now;

            u.LastChange = time;
            u.CreateTime = task.CreateTime;
            repo.Save(u);
            CommentView comentView = new CommentView();

            comentView.AddComment(task);
            Console.Clear();
            Console.WriteLine("*******************************");
            Console.WriteLine("********* COMPLETED!!! ********");
            Console.WriteLine("*******************************");
            Thread.Sleep(1500);
            Console.Clear();
            PrintRepo(u);
            Console.WriteLine();
            Console.WriteLine();
            RenderMenu(u);
        }