Esempio n. 1
0
        private void CalculateCost()
        {
            ManagerValidation MV = new ManagerValidation();
            bool correctForm     = MV.CalculateCostValidation(ListOfMaintask, ListOfResources);

            if (correctForm)
            {
                double   tmp          = 0;
                DateTime startProject = DateTime.Now;
                DateTime endProject;

                foreach (var resources in ListOfResources)
                {
                    tmp += resources.Cost;
                }

                if (ListOfMaintask.Count() > 0)
                {
                    startProject = ListOfMaintask[0].EarlyStart;
                }
                endProject = DateTime.Now;

                foreach (var mt in ListOfMaintask)
                {
                    if (startProject.CompareTo(mt.EarlyStart) > 0)
                    {
                        startProject = mt.EarlyStart;
                    }

                    if (endProject.CompareTo(mt.LateFinish) < 0)
                    {
                        endProject = mt.LateFinish;
                    }
                }

                TimeSpan interval = endProject - startProject;
                int      days     = interval.Days;

                int month = (int)Math.Ceiling(((double)days) / 30); // OK

                double allSalary = 0;
                foreach (var user in Global.user.Team.Users)
                {
                    allSalary += user.Salary;
                }

                allSalary = allSalary * month;

                tmp  = tmp + allSalary;
                Cost = tmp;
            }
        }
Esempio n. 2
0
        private void AddMainTask()
        {
            bool checkName = true;

            foreach (var t in ListOfMaintask)
            {
                if (t.Name == NameMainTask)
                {
                    checkName = false;
                }
            }

            if (checkName == true && Effort > 0 && NameMainTask.Length > 0)
            {
                MainTask mainTask = new MainTask
                {
                    Name               = NameMainTask,
                    Effort             = Effort,
                    EarlyFinish        = EarlyFinish,
                    EarlyStart         = EarlyStart,
                    LateFinish         = LateFinish,
                    LateStart          = LateStart,
                    PrecedingMainTasks = new List <MainTask>(),
                    Status             = false,
                    Project            = SelectedProject
                };
                ListOfMaintask.Add(mainTask);

                dbContext.MainTask.Add(mainTask);
                dbContext.SaveChanges();


                setVariable();
            }
            else
            {
                ErrorMessage er = new ErrorMessage("The name exists or effort <= 0!");
                er.ShowDialog();
            }
        }