public TaskDetailsForm(string Id)
 {
     this.context = new PmContext();
     InitializeComponent();
     currentTaskId         = decimal.Parse(Id);
     currentTask           = context.PROJECT_TASKS.Find(currentTaskId);
     ProjectNameTb.Enabled = false;
 }
示例#2
0
        private void Create_Click(object sender, EventArgs e)
        {
            if (!IsValidInput(task_Name_TB) ||
                !IsValidSelection(task_Priority_CB)
                )
            {
                return;
            }

            if (taskStartDate.Value.Date < DateTime.Now.Date ||
                taskEndDate.Value.Date < DateTime.Now.Date ||
                taskEndDate.Value < taskStartDate.Value)
            {
                MessageBox.Show("Невалидна дата!");
                return;
            }
            if (context.PROJECT_TASKS.Any(o => o.TASK_NAME == task_Name_TB.Text))
            {
                MessageBox.Show("Вече съществува задача с това име!");
                return;
            }

            var task = new PROJECT_TASKS();

            task.TASK_NAME = task_Name_TB.Text;
            if (task_Priority_CB.SelectedIndex == Priority.HighPriorityIndex)
            {
                task.TASK_PRIORITY = "H";
            }
            else if (task_Priority_CB.SelectedIndex == Priority.MediumPriorityIndex)
            {
                task.TASK_PRIORITY = "M";
            }
            else if (task_Priority_CB.SelectedIndex == Priority.LowPriorityIndex)
            {
                task.TASK_PRIORITY = "L";
            }
            task.TASK_DESCRIPTION = task_Description_RTB.Text;
            task.TAS_DELIVERABLES = task_Result_RTB.Text;
            task.TASK_BEGIN       = taskStartDate.Value;
            task.TASK_END         = taskEndDate.Value;
            task.TASK_STATUS      = TaskStatus.TaskStatusPlannedId;
            task.TASK_READY       = 0;
            task.PROJECT_ID       = currentProject.PROJECT_ID;
            var expertId = decimal.Parse(ExpertsCb.SelectedValue.ToString());

            task.EXPRET_ID  = expertId;
            task.TASK_READY = 0;
            task.TASK_HOURS = 0;

            context.PROJECT_TASKS.Add(task);
            context.SaveChanges();
            MessageBox.Show($"Задачата е добавена успешно!");



            ProjectDetailsForm form = Application.OpenForms.OfType <ProjectDetailsForm>().FirstOrDefault();

            if (form != null)
            {
                form.PopulateTasksGV();
                this.Close();
            }
        }